YaWK  24.1
Yet another WebKit
dashboard.php
Go to the documentation of this file.
1 <?php
2 namespace YAWK\BACKEND
3 {
4 
5  /**
6  * @details <b>Admin LTE Dashboard Class</b>
7  *
8  * This class serves a few methods that build the Admin LTE Dashboard view in the backend.<br>
9  * <p>Methods are mostly draw functions that output html.</p>
10  *
11  * <p><i>Class covers backend template functionality.
12  * See Methods Summary for Details!</i></p>
13  *
14  * @author Daniel Retzl <[email protected]>
15  * @copyright 2009-2016 Daniel Retzl http://yawk.io
16  * @license https://opensource.org/licenses/MIT
17  * @version 1.0.0/
18  * @brief Dashboard class serves a few useful functions for the admin backend.
19  */
20  class dashboard
21  {
22 
23  /**
24  * @brief Draws a box containing the recently added static pages
25  * @param object $db the database object
26  * @param object $lang language object
27  * @param int $limit number for sql limitation
28  */
29  static function drawLatestPagesBox($db, $limit, $lang)
30  { // default latest pages
31  if (!isset($limit) || (empty($limit))) { $limit = 4; }
32  $latestPages = array();
33  $latestPages = \YAWK\page::getLatest($db, $limit);
34  // print_r($latestPages);
35 
36  echo "<!-- PRODUCT LIST -->
37  <div class=\"box box-primary\">
38  <div class=\"box-header with-border\">
39  <h3 class=\"box-title\">$lang[RECENTLY_ADDED_PAGES]</h3>
40 
41  <div class=\"box-tools pull-right\">
42  <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"collapse\"><i class=\"fa fa-minus\"></i>
43  </button>
44  <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"remove\"><i class=\"fa fa-times\"></i></button>
45  </div>
46  </div>
47  <!-- /.box-header -->
48  <div class=\"box-body\">
49  <ul class=\"products-list product-list-in-box\">";
50 
51  foreach ($latestPages AS $page => $property)
52  {
53  if ($property['published'] === "1")
54  { // page is online
55  $color = "success"; $text = "online";
56  }
57  else
58  { // page is offline
59  $color = "danger"; $text= "offline";
60  }
61  $since = \YAWK\sys::time_ago($property['date_publish'], $lang);
62  echo"<li class=\"item\">
63  <div class=\"product-img\">
64  <i class=\"fa fa-file-code-o fa-2x text-muted\"></i>
65  </div>
66  <div class=\"product-info\">
67  <a href=\"index.php?page=page-edit&alias=$property[alias]&id=$property[id]\" class=\"product-title\">$property[title]
68  <span class=\"label label-$color pull-right\">$text</span></a>
69  <span class=\"product-description\">
70  <small>$lang[PUBLISHED] $since &nbsp;"; \YAWK\backend::printTooltip($property['date_publish']); echo"</small>
71  </span>
72  </div>
73  </li>";
74  }
75 
76  echo"<!-- /.item -->
77  </ul>
78  </div>
79  <!-- /.box-body -->
80  <div class=\"box-footer text-center\">
81  <a href=\"index.php?page=pages\" class=\"uppercase\">$lang[VIEW_ALL_PAGES]</a>
82  </div>
83  <!-- /.box-footer -->
84  </div>
85  <!-- /.box -->";
86 
87  }
88 
89  /**
90  * @brief Draws a box containing the recently added users
91  * @param object $db database
92  * @param int $limit number for sql limitation
93  * @param object $lang language object
94  */
95  static function drawLatestUsers($db, $limit, $lang)
96  {
97  // set default value
98  if (!isset($limit) && (empty($limit))) { $limit = 8; }
99  // get latest users into array
100  $latestUsers = \YAWK\user::getLatestUsers($db, $limit);
101  // get n of members
102  $members = count($latestUsers);
103  echo "
104  <!-- USERS LIST -->
105  <div class=\"box box-danger\">
106  <div class=\"box-header with-border\">
107  <h3 class=\"box-title\">$lang[LATEST_MEMBERS]</h3>
108 
109  <div class=\"box-tools pull-right\">
110  <span class=\"label label-danger\">$members $lang[NEW_MEMBERS]</span>
111  <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"collapse\"><i class=\"fa fa-minus\"></i>
112  </button>
113  <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"remove\"><i class=\"fa fa-times\"></i>
114  </button>
115  </div>
116  </div>
117  <!-- /.box-header -->
118  <div class=\"box-body no-padding\">
119  <ul class=\"users-list clearfix\">";
120  foreach ($latestUsers AS $newUser)
121  {
122  $userpic = \YAWK\user::getUserImage("backend", $newUser['username'], "img-circle", 50, 50);
123  $timeAgo = \YAWK\sys::time_ago($newUser['date_created'], $lang);
124  echo "<li>
125  <a href=\"index.php?page=user-edit&user=$newUser[username]\">$userpic</a>
126  <br><a href=\"index.php?page=user-edit&user=$newUser[username]\">$newUser[username]</a>
127  <span class=\"users-list-date\">$timeAgo</span>
128  </li>";
129  }
130  echo "</ul>
131  <!-- /.users-list -->
132  </div>
133  <!-- /.box-body -->
134  <div class=\"box-footer text-center\">
135  <a href=\"index.php?page=users\" class=\"uppercase\">$lang[VIEW_ALL_MEMBERS]</a>
136  </div>
137  <!-- /.box-footer -->
138  </div>
139  <!--/.box -->";
140  }
141  }
142 }
print $lang['FILEMAN_UPLOAD']
Dashboard class serves a few useful functions for the admin backend.
Definition: dashboard.php:20
static drawLatestUsers($db, $limit, $lang)
Draws a box containing the recently added users.
Definition: dashboard.php:94
static drawLatestPagesBox($db, $limit, $lang)
Draws a box containing the recently added static pages.
Definition: dashboard.php:28
static printTooltip($toolTipText)
Draw a small question mark, enabling a tooltip on hover. toolTipText must be a string and will usuall...
Definition: backend.php:603
static getLatest($db, $limit)
get latest pages
Definition: page.php:1058
static time_ago($userdate, $lang)
how many time is been gone since given date
Definition: sys.php:1630
static getUserImage($location, $user, $cssClass, $w, $h)
return and output user image
Definition: user.php:1079
static getLatestUsers($db, $count)
get latest users and return as array
Definition: user.php:718
$page
Definition: pages.php:355