Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
58
core/shortcut.php
Normal file
58
core/shortcut.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Êëàññ äëÿ êîðîòêîãî äîñòóïà ê ôàéëàì / ïàïêàì
|
||||
*/
|
||||
class Shortcut
|
||||
{
|
||||
static $instance = null;
|
||||
public $variables = array();
|
||||
public $list = array();
|
||||
|
||||
// Singleton pattern
|
||||
static public function getInstance ()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new Shortcut();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Äîáàâëÿåò ÿðëûê ñ èìåíåì $prefix
|
||||
* Ïóòü ìîæåò ñîäåðæàòü ïåðåìåííûå
|
||||
*/
|
||||
public function addUrl($prefix, $path)
|
||||
{
|
||||
$this->list [$prefix] = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function addVar($name, $value)
|
||||
{
|
||||
$this->variables['$' . $name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Âîçâðàùàåò ïóòü ïî èìåíè ÿðëûêà
|
||||
*/
|
||||
static function getUrl ($prefix, $name = null, $name1 = false)
|
||||
{
|
||||
$shortcut = self::getInstance();
|
||||
$names = $shortcut->variables;
|
||||
if ($name) {
|
||||
$names['$name'] = $name;
|
||||
}
|
||||
if ($name1) {
|
||||
$names['$name1'] = $name1;
|
||||
}
|
||||
if (isset($shortcut->list[$prefix])) {
|
||||
return strtr($shortcut->list[$prefix], $names);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue