/** * Загружает глобальные настройки из файла и кеширует их в массиве GLOBALS. * Данный метод вызывается ТОЛЬКО при создании экземпляра класса. */ private function load() { check_condition(!is_array($this->GLOBALS), 'Недопустима повторная загрузка глобальных настроек'); $this->GLOBALS = array(); $this->FileMtimeUpdate(); $comment = array(); foreach ($this->DI->getFileLines() as $line) { $line = trim($line); if (!$line || starts_with($line, '/*') || ends_with($line, '*/')) { continue; } if (starts_with($line, '*')) { $line = trim(first_char_remove($line)); if ($line) { $comment[] = $line; } continue; } if (starts_with($line, 'define')) { $name = trim(array_get_value(1, explode("'", $line, 3))); check_condition($name && defined($name), "Ошибка разбора файла глобальных настроек: свойство [{$name}] не определено."); $this->GLOBALS[$name] = new PsGlobalProp($name, implode(' ', $comment)); $comment = array(); continue; } } }
public function __call($method, $arguments) { $method = first_char_remove($method); $source = $arguments[0]; /* @var $template Smarty_Internal_Template */ $template = $arguments[1]; $tplPath = $template->template_resource; //PsProfiler::inst(__CLASS__)->start($method); $result = $this->{$method}($source); //PsProfiler::inst(__CLASS__)->stop(); $call = ++$this->CALLS[$method]; $callttl = ++$this->CALLTTL; $callInfo = pad_right("[{$callttl}-{$call}].", 10, ' '); PsLogger::inst(__CLASS__)->info("{} {} filter called for template {}.", $callInfo, ucfirst($method), $tplPath); return $result; }
/** * Принимает на вход многострочный комментарий и возвращает массив строк, * из которых он состоит. Для данного комментария будет два элемента в массиве. */ public static function parseMultiLineComments($comments) { $comments = trim($comments); $lines = array(); foreach (explode("\n", $comments) as $line) { $line = trim($line); if (!$line || starts_with($line, '/*') || ends_with($line, '*/')) { continue; } if (starts_with($line, '*')) { $line = trim(first_char_remove($line)); if ($line) { $lines[] = $line; } continue; } } return $lines; }