YaWK  24.1
Yet another WebKit
widget-new.php
Go to the documentation of this file.
1 <?php
2 
3 use YAWK\backend;
4 use YAWK\db;
5 use YAWK\language;
6 use YAWK\widget;
7 
8 /** @var $db db */
9 /** @var $lang language */
10 
11 // TEMPLATE WRAPPER - HEADER & breadcrumbs
12 echo "
13  <!-- Content Wrapper. Contains page content -->
14  <div class=\"content-wrapper\" id=\"content-FX\">
15  <!-- Content Header (Page header) -->
16  <section class=\"content-header\">";
17 /* draw Title on top */
18 echo backend::getTitle($lang['WIDGET+'], $lang['WIDGETS+_SUBTEXT']);
19 echo"<ol class=\"breadcrumb\">
20  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
21  <li><a href=\"index.php?page=widgets\" title=\"$lang[WIDGETS]\"> $lang[WIDGETS]</a></li>
22  <li class=\"active\"><a href=\"index.php?page=widget-new\" title=\"".$lang['WIDGET+']."\"> ".$lang['WIDGET+']."</a></li>
23  </ol>
24  </section>
25  <!-- Main content -->
26  <section class=\"content\">";
27 /* page content start here */
28 
29 
30 // DELETE? if(!isset($_POST['widgetType'])){
31 ?>
32  <div class="row">
33  <div class="col-md-5">
34  <div class="box box-default">
35  <div class="box-body">
36  <div class="box-header with-border"><h3 class="box-title"><?php echo $lang['WIDGET+']; ?></h3></div>
37  <br>
38  <form action="index.php?page=widgets&add=1" role="form" method="post">
39  <label for="widgetType"><?php echo $lang['CREATE']; ?>:</label>
40  <select id="widgetType" name="widgetType" class="form-control">
41  <option value="empty" name="empty" disabled selected aria-disabled="true" aria-selected="true"><?php echo $lang['SELECT_WIDGET']; ?></option>
42  <?php
43  foreach(YAWK\widget::getWidgetsArray($db) as $widget){
44  echo "<option value=\"".$widget['id']."\"";
45 
46  if (isset($_POST['widget'])) {
47  if($_POST['widget'] === $page['id']){
48  echo " selected=\"selected\"";
49  }
50  else if($widget->widget === $widget['id'] && !$_POST['widget']){
51  echo " selected=\"selected\"";
52  }
53  }
54  echo ">".$widget['name']."</option>";
55  }
56  ?>
57  </select>
58  <label for="pageID"><?php echo $lang['ON_PAGE']; ?>:
59  <?php echo backend::printTooltip($lang['TT_WIDGET_PAGE']); ?></label>
60  <select id="pageID" name="pageID" class="form-control">
61  <option value="0"><?php echo $lang['ON_ALL_PAGES']; ?></option>
62  <?php
63  foreach(YAWK\sys::getPages($db) as $page){
64  echo "<option value=\"".$page['id']."\"";
65 
66  if (isset($_POST['pageID'])) {
67  if($_POST['pageID'] === $page['id']){
68  echo " selected=\"selected\"";
69  }
70  else if($page->page === $page['id'] && !$_POST['page']){
71  echo " selected=\"selected\"";
72  }
73  }
74  echo ">".$page['title']."</option>";
75  }
76  ?>
77  </select>
78  <label for="position"><?php echo $lang['AT_POSITION']; ?>
79  <?php echo backend::printTooltip($lang['TT_WIDGET_POS']); ?></label>
80  <select id="position" name="positions" class="form-control">
81  <option value=""></option>
82  <?php
83  $i = 0;
84  foreach(YAWK\template::getTemplatePositions($db) as $positions){
86  echo "<option value=\"".$position[$i]."\"";
87 
88  if (isset($_POST['positions'])) {
89  if($_POST['0'] === $position['positions']){
90  echo " selected=\"selected\"";
91  }
92  else if($position->positions === $position['positions'] && !$_POST['positions']){
93  echo " selected=\"selected\"";
94  }
95  }
96  echo ">".$position[$i]."</option>";
97  $i++;
98  }
99  ?>
100  </select><br>
101  <input type="submit" class="btn btn-success pull-right" value="<?php echo $lang['CREATE']; ?>">
102  </form>
103  </div>
104  </div>
105  </div>
106  <div class="col-md-7">
107  <div class="box box-default">
108  <div class="box-body">
109  <div class="box-header with-border"><h3 class="box-title"><?php echo $lang['WIDGET']." ".$lang['OVERVIEW']; ?></h3></div>
110  <div class="box-body">
111  <?php
112 
114  if (isset($widgetTypes) && (is_array($widgetTypes)))
115  { // draw widget types list data
116  foreach ($widgetTypes as $widget)
117  {
118  // check widget contains language files
119  if (is_dir('../system/widgets/'.$widget['folder'].'/language/'))
120  { // inject (add) language tags to core $lang array
121  $widgetLang = \YAWK\language::inject($lang, "../system/widgets/".$widget['folder']."/language/");
122  }
123 
124  // walk through widget list
125  echo '<div class="box box-default">';
126  echo '<div class="box-header with-border"><h3 class="box-title"><b>'.$widget['name'].'</b></h3>
127  <br><span class="text-muted">'.$widget['description'].'</span>';
128  if ($widget['status'] != 1) { echo 'WIDGET IS DISABLED'; }
129  echo'<small><span class="pull-right text-muted">ID: '.$widget['id'].'</span></small>
130  </div>';
131 
132  echo '<div class="box-body">';
133  echo '<div class="row">';
134 
135  if (!empty($widget['icon']))
136  {
137  if (!empty($widget['color'])){ $colorMarkup = 'color:#'.$widget['color'].';'; }
138  else { $colorMarkup='color:#666'; }
139  echo '<div class="col-md-4 text-center" style="top:-20px;">';
140  echo '<h1><i class="'.$widget['icon'].'" style="vertical-align:middle;'.$colorMarkup.'"></i></h1>';
141  }
142  else {
143  echo '<div class="col-md-4 text-center">';
144  }
145 
146  echo '</div>';
147  echo '<div class="col-md-8">';
148  // RIGHT COL, extended info + help
149  if (!empty($widgetLang['WIDGET_INFO']))
150  {
151  echo $widgetLang['WIDGET_INFO'];
152  }
153  else
154  {
155  echo '<small class="text-muted">'.$lang['WIDGET_INFO_MISSING'].'<br><small>add WIDGET_INFO to system/widgets/'.$widget['folder'].'/language/</small></small>';
156  }
157  echo '</div>';
158  echo '</div>';
159 
160  echo '</div>';
161  echo '</div>';
162  }
163  } // end if widgetTypes array is set
164  ?>
165  </div>
166  </div>
167  </div>
168  </div>
169  </div>
170 
171 
172 <?php
173 // DELETE? }
174 ?>
print $lang['FILEMAN_UPLOAD']
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
Mysqli database class; returns db connection object.
Definition: db.php:16
The language class - support multilingual backend.
Definition: language.php:17
static inject(array $lang, string $pathToFile)
allow plugins to inject language tags to $lang array
Definition: language.php:439
Widgets are small, useful tools that you can include everywhere in your website.
Definition: widget.php:22
static getAllWidgetTypes($db)
Return all widget types as associative array.
Definition: widget.php:1211
type
Definition: menu-new.php:35
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
$page
Definition: pages.php:355
$positions
Definition: index.php:55
$template name
$position[$i]
$widgetTypes
Definition: widget-new.php:113
$i
Definition: widget-new.php:83