fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

page.class.php
Go to the documentation of this file.
1 <?php
22 class Page extends FOGBase
23 {
29  protected $title;
35  protected $body;
41  protected $menu;
47  protected $media;
53  protected $theme;
59  protected $isHomepage;
65  protected $pageTitle;
71  protected $sectionTitle;
77  protected $stylesheets = array();
83  protected $javascripts = array();
89  public function __construct()
90  {
91  global $node;
92  global $sub;
93  parent::__construct();
94  if (!$this->theme) {
95  $this->theme = self::getSetting('FOG_THEME');
96  if (!$this->theme) {
97  $this->theme = 'default/fog.css';
98  } elseif (!file_exists("../management/css/$this->theme")) {
99  $this->theme = 'default/fog.css';
100  }
101  $dispTheme = "css/$this->theme";
102  $this->imagelink = 'css/'
103  . dirname($this->theme)
104  . '/images/';
105  if (!file_exists("../management/$dispTheme")) {
106  $dispTheme = 'css/default/fog.css';
107  }
108  }
109  $this
110  ->addCSS('css/animate.min.css')
111  ->addCSS('css/font-awesome.min.css')
112  ->addCSS('css/jquery-ui.css')
113  ->addCSS('css/jquery-ui.theme.css')
114  ->addCSS('css/jquery-ui.structure.css')
115  ->addCSS('css/jquery-ui-timepicker-addon.css')
116  ->addCSS('css/select2.min.css')
117  ->addCSS('css/bootstrap.min.css')
118  ->addCSS('css/bootstrap-theme.min.css')
119  ->addCSS('css/theme.bootstrap_3.css')
120  ->addCSS('css/theme.blue.css')
121  ->addCSS('css/bootstrap-dialog.min.css')
122  ->addCSS($dispTheme);
123  if (!isset($node)
124  || !$node
125  ) {
126  $node = 'home';
127  }
128  $homepages = array(
129  'home',
130  'dashboard',
131  'schema',
132  'client',
133  'ipxe',
134  'login',
135  'logout'
136  );
137  $this->isHomepage = in_array($node, $homepages)
138  || !self::$FOGUser->isValid();
139  if (self::$FOGUser->isValid()
140  && strtolower($node) != 'schema'
141  ) {
142  $this->main = array(
143  'home' => array(
144  self::$foglang['Dashboard'],
145  'fa fa-dashboard'
146  ),
147  'user' => array(
148  self::$foglang['Users'],
149  'fa fa-users'
150  ),
151  'host' => array(
152  self::$foglang['Hosts'],
153  'fa fa-desktop'
154  ),
155  'group' => array(
156  self::$foglang['Groups'],
157  'fa fa-sitemap'
158  ),
159  'image' => array(
160  self::$foglang['Images'],
161  'fa fa-picture-o'
162  ),
163  'storage' => array(
164  self::$foglang['Storage'],
165  'fa fa-archive'
166  ),
167  'snapin' => array(
168  self::$foglang['Snapin'],
169  'fa fa-files-o'
170  ),
171  'printer' => array(
172  self::$foglang['Printer'],
173  'fa fa-print'
174  ),
175  'service' => array(
176  self::$foglang['ClientSettings'],
177  'fa fa-cogs'
178  ),
179  'task' => array(
180  self::$foglang['Tasks'],
181  'fa fa-tasks'
182  ),
183  'report' => array(
184  self::$foglang['Reports'],
185  'fa fa-file-text'
186  ),
187  'about' => array(
188  self::$foglang['FOG Configuration'],
189  'fa fa-wrench'
190  )
191  );
192  if (self::getSetting('FOG_PLUGINSYS_ENABLED')) {
194  'about',
195  $this->main,
196  'plugin',
197  array(
198  self::$foglang['Plugins'],
199  'fa fa-cog'
200  )
201  );
202  }
203  $this->main = array_unique(
204  array_filter($this->main),
205  SORT_REGULAR
206  );
207  self::$HookManager
208  ->processEvent(
209  'MAIN_MENU_DATA',
210  array(
211  'main' => &$this->main
212  )
213  );
214  if (count($this->main) > 0) {
215  $links = array_keys($this->main);
216  }
217  $links = self::fastmerge(
218  (array)$links,
219  array(
220  'home',
221  'logout',
222  'hwinfo',
223  'client',
224  'schema',
225  'ipxe'
226  )
227  );
228  if ($node
229  && !in_array($node, $links)
230  ) {
231  self::redirect('index.php');
232  }
233  ob_start();
234  $count = false;
235  if (count($this->main) > 0) {
236  foreach ($this->main as $link => &$title) {
237  $links[] = $link;
238  if (!$node && $link == 'home') {
239  $node = $link;
240  }
241  $activelink = ($node == $link);
242  echo '<li'
243  . (
244  $activelink ?
245  ' class="active"' :
246  ''
247  )
248  . '>';
249  echo '<a href="?node='
250  . $link
251  . '" data-toggle="tooltip" title="'
252  . $title[0]
253  . '" data-placement="bottom">';
254  echo '<i class="'
255  . $title[1]
256  . ' fa-2x fa-fw"></i>';
257  echo '<span class="collapsedmenu-text">';
258  echo ' ';
259  echo $title[0];
260  echo '</span>';
261  echo '</a>';
262  echo '</li>';
263  unset($title);
264  }
265  }
266  $this->menu = ob_get_clean();
267  }
268  $files = array(
269  'js/jquery-latest.min.js',
270  'js/jquery.validate.min.js',
271  'js/additional-methods.min.js',
272  'js/jquery.tablesorter.combined.js',
273  'js/select2.min.js',
274  'js/jquery-migrate-latest.min.js',
275  'js/jquery.progressbar.js',
276  'js/jquery.tmpl.js',
277  'js/jquery.placeholder.js',
278  'js/jquery-ui.min.js',
279  'js/flot/jquery.flot.js',
280  'js/flot/jquery.flot.time.js',
281  'js/flot/jquery.flot.pie.js',
282  'js/flot/jquery.flot.JUMlib.js',
283  'js/flot/jquery.flot.gantt.js',
284  'js/jquery-ui-timepicker-addon.js',
285  'js/bootstrap.min.js',
286  'js/bootstrap-dialog.min.js',
287  'js/fog/fog.js',
288  'js/fog/fog.main.js',
289  'js/jscolor.min.js'
290  );
291  if (!self::$FOGUser->isValid()) {
292  $files[] = 'js/fog/fog.login.js';
293  } else {
294  $subset = $sub;
295  if ($sub == 'membership') {
296  $subset = 'edit';
297  }
298  $node = preg_replace(
299  '#_#',
300  '-',
301  $node
302  );
303  $subset = preg_replace(
304  '#_#',
305  '-',
306  $subset
307  );
308  $filepaths = array(
309  "js/fog/fog.{$node}.js",
310  "js/fog/fog.{$node}.{$subset}.js",
311  );
312  }
313  array_map(
314  function (&$jsFilepath) use (&$files) {
315  if (file_exists($jsFilepath)) {
316  array_push($files, $jsFilepath);
317  }
318  unset($jsFilepath);
319  },
320  (array)$filepaths
321  );
322  $pluginfilepaths = array(
323  "../lib/plugins/{$node}/js/fog.{$node}.js",
324  "../lib/plugins/{$node}/js/fog.{$node}.{$subset}.js",
325  );
326  array_map(
327  function (&$pluginfilepath) use (&$files) {
328  if (file_exists($pluginfilepath)) {
329  array_push($files, $pluginfilepath);
330  }
331  unset($pluginfilepath);
332  },
333  (array)$pluginfilepaths
334  );
335  if ($this->isHomepage
336  && self::$FOGUser->isValid()
337  && ($node == 'home'
338  || !$node)
339  ) {
340  array_push($files, 'js/fog/fog.dashboard.js');
341  $test = preg_match(
342  '#MSIE [6|7|8|9|10|11]#',
343  self::$useragent
344  );
345  if ($test) {
346  array_push(
347  $files,
348  'js/flot/excanvas.js'
349  );
350  }
351  }
352  if ($node === 'schema') {
353  array_push($files, 'js/fog/fog.schema.js');
354  }
355  $files = array_unique((array)$files);
356  array_map(
357  function (&$path) {
358  if (file_exists($path)) {
359  $this->addJavascript($path);
360  }
361  unset($path);
362  },
363  (array)$files
364  );
365  }
373  public function setTitle($title)
374  {
375  $this->pageTitle = $title;
376  return $this;
377  }
385  public function setSecTitle($title)
386  {
387  $this->sectionTitle = $title;
388  return $this;
389  }
397  public function addCSS($path)
398  {
399  $this->stylesheets[] = "../management/$path";
400  return $this;
401  }
409  public function addJavascript($path)
410  {
411  $this->javascripts[] = $path;
412  return $this;
413  }
419  public function startBody()
420  {
421  ob_start();
422  return $this;
423  }
429  public function endBody()
430  {
431  $this->body = ob_get_clean();
432  return $this;
433  }
439  public function render()
440  {
441  if (true === self::$showhtml) {
442  include '../management/other/index.php';
443  } else {
444  echo $this->body;
445  exit;
446  }
447  foreach (array_keys(get_defined_vars()) as $var) {
448  unset($$var);
449  }
450  return $this;
451  }
457  public static function getSearchForm()
458  {
459  global $node;
460  echo '<div class="col-md-3">';
461  if (in_array($node, self::$searchPages)) {
462  echo '<li class="pull-left">';
463  echo '<form class="navbar-form navbar-left search-wrapper" role='
464  . '"search" method="post" action="'
465  . '../management/index.php?node='
466  . $node
467  . '&sub=search">';
468  echo '<div class="input-group">';
469  echo '<input type="text" class="'
470  . 'form-control search-input" placeholder="'
471  . self::$foglang['Search']
472  . '..." name="crit"/>';
473  echo '<span class="input-group-addon search-submit">';
474  echo '<i class="fogsearch fa fa-search">';
475  echo '<span class="sr-only">';
476  echo self::$foglang['Search'];
477  echo '</span>';
478  echo '</i>';
479  echo '</span>';
480  echo '</div>';
481  echo '</form>';
482  echo '</li>';
483  }
484  echo '</div>';
485  }
491  public static function getLogout()
492  {
493  echo '<li class="pull-right">';
494  if (self::$FOGUser->isValid()) {
495  echo '<a href="../management/index.php?node=logout" '
496  . 'data-toggle="tooltip" data-placement="bottom" title="'
497  . _('Logout')
498  . ': '
499  . strtolower(
500  trim(
501  self::$FOGUser->get('name')
502  )
503  )
504  . '">';
505  echo '<i class="fa fa-sign-out fa-2x fa-fw"></i>';
506  echo '<span class="collapsedmenu-text">';
507  echo ' ';
508  echo _('Logout');
509  echo '</span>';
510  echo '</a>';
511  } else {
512  echo '<a href="../management/index.php"';
513  echo '<i class="fa fa-sign-in fa-2x fa-fw"></i>';
514  echo '<span class="collapsedmenu-text">';
515  echo ' ';
516  echo _('Login');
517  echo '</span>';
518  echo '</a>';
519  }
520  echo '</li>';
521  echo '<li class="separator hidden-lg hidden-md"></li>';
522  }
528  public static function getMainSideMenu()
529  {
530  global $node;
531  global $sub;
532  $class = self::$FOGPageManager->getFOGPageClass();
533  if (count($class->menu) < 1) {
534  return;
535  }
536  $FOGSub = new FOGSubMenu();
537  foreach ($class->menu as $l => &$t) {
538  $FOGSub->addMainItems(
539  $class->node,
540  array((string)$t => (string)$l),
541  '',
542  '',
543  'mainmenu'
544  );
545  unset($t);
546  }
547  unset($class);
548  echo $FOGSub->getMainItems($node);
549  unset($FOGSub);
550  }
556  public static function getMenuItems()
557  {
558  $class = self::$FOGPageManager->getFOGPageClass();
559  $FOGSub = new FOGSubMenu();
560  if (count($class->subMenu)) {
561  foreach ($class->subMenu as $l => &$t) {
562  $FOGSub->addItems(
563  $class->node,
564  array((string)$t => (string)$l),
565  $class->id,
566  sprintf(
567  self::$foglang['SelMenu'],
568  get_class($class->obj)
569  ),
570  'submenu'
571  );
572  unset($t);
573  }
574  unset($classSubMenu);
575  }
576  if (count($class->notes)) {
577  foreach ($class->notes as $l => &$t) {
578  $FOGSub->addNotes(
579  $class->node,
580  array((string)$t => (string)$l),
581  $class->id
582  );
583  unset($t);
584  }
585  }
586  echo $FOGSub->get($class->node);
587  }
588 }
Page\$pageTitle
$pageTitle
Definition: page.class.php:65
exit
exit
Definition: download.php:102
Page\$javascripts
$javascripts
Definition: page.class.php:83
Page\setSecTitle
setSecTitle($title)
Definition: page.class.php:385
$FOGPageManager
$FOGPageManager
Definition: index.php:23
Page\$media
$media
Definition: page.class.php:47
FOGBase\fastmerge
static fastmerge($array1)
Definition: fogbase.class.php:2415
Page\$title
$title
Definition: page.class.php:29
Page\addCSS
addCSS($path)
Definition: page.class.php:397
Page\$body
$body
Definition: page.class.php:35
$test
$test
Definition: freespace.php:37
Page\render
render()
Definition: page.class.php:439
Page\getSearchForm
static getSearchForm()
Definition: page.class.php:457
FOGSubMenu
Definition: fogsubmenu.class.php:91
Page\$sectionTitle
$sectionTitle
Definition: page.class.php:71
Page\$menu
$menu
Definition: page.class.php:41
Page\$theme
$theme
Definition: page.class.php:53
Page\addJavascript
addJavascript($path)
Definition: page.class.php:409
Page\$stylesheets
$stylesheets
Definition: page.class.php:77
Page
Definition: page.class.php:23
Page\__construct
__construct()
Definition: page.class.php:89
FOGBase
Definition: fogbase.class.php:25
FOGBase\redirect
static redirect($url='')
Definition: fogbase.class.php:831
$path
if(!is_string($_GET['path'])) $path
Definition: getfiles.php:31
$count
$count
Definition: locationcheck.php:25
FOGBase\arrayInsertAfter
static arrayInsertAfter( $key, array &$array, $new_key, $new_value)
Definition: fogbase.class.php:885
Page\startBody
startBody()
Definition: page.class.php:419
$foglang
$foglang['Display']
Definition: text.php:22
Page\getLogout
static getLogout()
Definition: page.class.php:491
Page\getMainSideMenu
static getMainSideMenu()
Definition: page.class.php:528
Page\endBody
endBody()
Definition: page.class.php:429
Page\setTitle
setTitle($title)
Definition: page.class.php:373
$link
$link
Definition: dbrunning.php:26
FOGBase\getSetting
static getSetting($key)
Definition: fogbase.class.php:2063
Page\getMenuItems
static getMenuItems()
Definition: page.class.php:556
Page\$isHomepage
$isHomepage
Definition: page.class.php:59