YaWK  24.1
Yet another WebKit
faq-new.php
Go to the documentation of this file.
1 <?php
2 // check if language is set
3 if (!isset($language) || (!isset($lang)))
4 { // inject (add) language tags to core $lang array
5  $lang = \YAWK\language::inject(@$lang, "../system/plugins/faq/language/");
6 }
7 if (!isset($db))
8 {
9  $db = new \YAWK\db();
10 }
11 include '../system/plugins/faq/classes/faq-backend.php';
12 if (isset($_POST['create']))
13 { // if faq object is not set
14  if (!isset($faq))
15  { // create new faq object
16  $faq = new \YAWK\PLUGINS\FAQ\faq();
17  }
18  if (!empty($_POST['question']))
19  { // escape post vars
20  $faq->question = $db->quote($_POST['question']);
21  }
22  else
23  { // question is empty
24  $faq->question = '';
25  }
26  if (!empty($_POST['answer']))
27  { // escape post var
28  $faq->answer = $db->quote($_POST['answer']);
29  }
30  else
31  { // question is empty
32  $faq->answer = '';
33  }
34 
35  if ($faq->create($db, $faq->question, $faq->answer))
36  { // success
37  print \YAWK\alert::draw("success", "$lang[SUCCESS]!", "$lang[FAQ_ADD_SUCCESS]","plugin=faq","2000");
38  exit;
39  }
40  else
41  { // create faq failed, throw error
42  \YAWK\alert::draw("danger", "$lang[ERROR]", "$lang[FAQ_ADD_FAILED]", "plugin=faq&pluginpage=faq-new","2400");
43  exit;
44  }
45 }
46 
47 // TEMPLATE WRAPPER - HEADER & breadcrumbs
48 echo "
49  <!-- Content Wrapper. Contains page content -->
50  <div class=\"content-wrapper\" id=\"content-FX\">
51  <!-- Content Header (Page header) -->
52  <section class=\"content-header\">";
53  /* draw Title on top */
54  echo \YAWK\backend::getTitle($lang['FAQ'], $lang['FAQ_SUBTEXT']);
55  echo"<ol class=\"breadcrumb\">
56  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
57  <li><a href=\"index.php?page=plugins\" title=\"$lang[PLUGINS]\"> $lang[PLUGINS]</a></li>
58  <li><a href=\"index.php?plugin=faq\" title=\"$lang[FAQ]\"> $lang[FAQ]</a></li>
59  <li class=\"active\"><a href=\"index.php?plugin=faq&pluginpage=faq-new\" title=\"$lang[ADD_QUESTION]\"> $lang[ADD_QUESTION]</a></li>
60  </ol>
61  </section>
62  <!-- Main content -->
63  <section class=\"content\">";
64  /* page content start here */
65 
66 ?>
67 <form action="index.php?plugin=faq&pluginpage=faq-new" role="form" method="POST"
68  xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
69 <div class="box box-default">
70  <div class="box-body">
71  <div class="box-header with-border">
72  <h3 class="box-title"><?php echo $lang['FAQ_ADD']; ?></h3>
73  </div>
74  <div class="box-body">
75  <input name="create" value="faq-create" type="hidden"/>
76  <textarea class="form-control" cols="55" rows="1" name="question"><?php echo $lang['FAQ_QUESTION']; ?></textarea><br>
77  <textarea class="form-control" cols="55" rows="4" name="answer"><?php echo $lang['FAQ_ANSWER']; ?></textarea><br>
78  <input id="savebutton" class="btn btn-success" type="submit" name="create" value="<?php echo $lang['FAQ_ADD_BTN']; ?>"/>&nbsp;
79 
80 
81  </div>
82  </div>
83 </div>
84 </form>
$faq
Definition: faq.php:69
print $lang['FILEMAN_UPLOAD']
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
static inject(array $lang, string $pathToFile)
allow plugins to inject language tags to $lang array
Definition: language.php:439
type
Definition: menu-new.php:35
exit
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$template name