Синхронизировал частично с CMS2

This commit is contained in:
origami11 2017-02-09 17:14:11 +03:00
parent 6b412f5d6f
commit f2938b1353
30 changed files with 1447 additions and 1099 deletions

View file

@ -10,7 +10,7 @@ class Shortcut
public $list = array();
// Singleton pattern
static public function getInstance ()
static public function getInstance()
{
if (self::$instance == null) {
self::$instance = new Shortcut();
@ -24,7 +24,7 @@ class Shortcut
*/
public function addUrl($prefix, $path)
{
$this->list [$prefix] = $path;
$this->list[$prefix] = $path;
}
/**
@ -38,9 +38,10 @@ class Shortcut
/**
* Возвращает путь по имени ярлыка
*/
static function getUrl ($prefix, $name = null, $name1 = false)
static function getUrl($prefix, $name = null, $name1 = null)
{
$shortcut = self::getInstance();
$names = $shortcut->variables;
if ($name) {
$names['$name'] = $name;
@ -48,10 +49,18 @@ class Shortcut
if ($name1) {
$names['$name1'] = $name1;
}
if (isset($shortcut->list[$prefix])) {
return strtr($shortcut->list[$prefix], $names);
}
return false;
return null;
}
}
static function expand($path)
{
$shortcut = self::getInstance();
$names = $shortcut->variables;
return strtr($path, $names);
}
}