ACC SHELL
<?php
// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
class Page
{
private static $current = null;
public $breadbrumbs;
public static function current()
{
if (self::$current === null)
self::$current = new Page();
return self::$current;
}
public function breadcrumb($text, $url = false)
{
$GLOBALS["page"]['breadcrumbs'][] = array(
'text' => $text,
'url' => $url,
);
}
public function __get($key)
{
return $this->get($key);
}
public function __set($key, $value)
{
$this->set($key, $value);
}
public function get($key, $value = null)
{
if (isset($GLOBALS["page"][$key]))
return $GLOBALS["page"][$key];
else
return $value;
}
public function set($key, $value)
{
if ($value === null)
unset($GLOBALS["page"][$key]);
else
$GLOBALS["page"][$key] = $value;
}
public function location($pattern = null)
{
if ($pattern === null)
{
if (($temp = U::request('page_location')) !== null)
page()->location = $temp;
if (page()->location !== null)
{
page()->location = ltrim(page()->location, '/');
if (strrchr(page()->location, '/'))
{
page()->file = substr(strrchr(page()->location, '/'), 1);
page()->directory = substr(page()->location, 0, strlen(page()->location) - strlen(page()->file));
}
else
{
page()->file = page()->location;
page()->directory = '';
}
if (!page()->file)
page()->file = 'index';
page()->location = page()->directory . page()->file;
}
}
else
{
if (($pattern === true) || (is_string($pattern) && empty($pattern)))
return true;
else if ($pattern === false)
return false;
if ($negative = (substr($pattern, 0, 1) == '!'))
$pattern = substr($pattern, 1);
if (substr($pattern, 0, 1) == '~')
return preg_match($pattern, page()->location);
else
return ($pattern == page()->location);
}
}
}
function page()
{
return Page::current();
}
?>
ACC SHELL 2018