protected function registerPluginsImpl()
 {
     $pluginType = strtolower(cut_string_end(cut_string_start(get_called_class(), 'Smarty'), 's'));
     foreach (PsUtil::getClassMethods(get_called_class(), true, true, null, true) as $tagName) {
         $this->register($tagName, $pluginType);
     }
 }
Beispiel #2
0
 /**
  * Функция возвращает код журнала по его id
  */
 public static function ident2id($ident)
 {
     check_condition(starts_with($ident, self::IDENT_PREFIX), "Bad issue ident: [{$ident}]");
     $postId = cut_string_start($ident, self::IDENT_PREFIX);
     check_condition(is_numeric($postId), "Bad issue ident: [{$ident}]");
     return 1 * $postId;
 }
Beispiel #3
0
 public function getProps()
 {
     if (is_array($this->props)) {
         return $this->props;
     }
     $this->props = array();
     if (!$this->di->isFile()) {
         return $this->props;
     }
     $prop = null;
     $content = array();
     foreach ($this->di->getFileLines() as $line) {
         $line = trim($line);
         if (!$line) {
             continue;
         }
         if (starts_with($line, '[') && ends_with($line, ']')) {
             //Нашли свойство. Приверим, а нет ли информации о предыдущем свойстве
             if ($prop) {
                 $this->props[$prop] = trim(implode("\n", $content));
                 $content = array();
             }
             $prop = trim(cut_string_end(cut_string_start($line, '['), ']'));
             continue;
         }
         if (!$prop) {
             continue;
         }
         $content[] = $line;
     }
     if ($prop) {
         $this->props[$prop] = trim(implode("\n", $content));
     }
     return $this->props;
 }
 /**
  * Возвращает FoldedContext, если он имеет заданный тип
  */
 private function getContextImpl($__FUNCTION__, $checkSetted)
 {
     $context = cut_string_start($__FUNCTION__, 'get');
     check_condition(interface_exists($context), "Interface [{$context}] is not exists");
     $result = $this->getContext() instanceof $context ? $this->getContext() : null;
     check_condition(!$checkSetted || $result, "{$context} is not setted now");
     return $result;
 }
 protected function getPlugins()
 {
     $type = strtolower(cut_string_end(cut_string_start($this->CLASS, 'Smarty'), 's'));
     $result = array();
     foreach (PsUtil::getClassMethods($this->CLASS, true, true, null, true) as $method) {
         $result[$method] = $type;
     }
     return $result;
 }
Beispiel #6
0
 /**
  * smarty_block_answers или block_answers -> answers
  */
 public static function getFunctionName($__FUNCTION__)
 {
     foreach (self::$TYPES as $type) {
         if (starts_with($__FUNCTION__, $type . '_')) {
             return cut_string_start($__FUNCTION__, $type . '_');
         }
         if (starts_with($__FUNCTION__, 'smarty_' . $type . '_')) {
             return cut_string_start($__FUNCTION__, 'smarty_' . $type . '_');
         }
     }
     check_condition(false, "Bad smarty function [{$__FUNCTION__}]");
 }
Beispiel #7
0
 public final function copyDirContent2Dir($dirFrom, $dirToAbsPath, $includeDir = true, $filterName = null)
 {
     $fromDirRelPath = $this->relDirPath($dirFrom);
     $includeDirName = basename($fromDirRelPath);
     check_condition($includeDirName, "Trying to copy root directory");
     $destDirAbsPath = $dirToAbsPath instanceof DirItem ? $dirToAbsPath->getAbsPath() : DirItem::inst($dirToAbsPath)->getAbsPath();
     //$includeDir = $includeDir && $fromDirRelPath && ($fromDirRelPath != DIR_SEPARATOR);
     $content = $this->getDirContentFull($dirFrom, $filterName);
     if (empty($content)) {
         //Папка пуста. Если $includeDir=true, то просто создадим её
         if ($includeDir && $this->isDir($dirFrom)) {
             $destAbsPath = next_level_dir($destDirAbsPath, $includeDirName);
             DirItem::inst($destAbsPath)->makePath();
         }
         return;
         //---
     }
     /* @var $src DirItem */
     foreach ($content as $src) {
         $relPathNewDirFromOldDir = cut_string_start($src->getRelPath(), $fromDirRelPath);
         $destAbsPath = next_level_dir($destDirAbsPath, $includeDir ? $includeDirName : null, $relPathNewDirFromOldDir);
         $destDi = DirItem::inst($destAbsPath)->makePath();
         if ($src->isFile()) {
             $src->copyTo($destDi);
         }
     }
 }
Beispiel #8
0
 /**
  * Извлекает информацию из названия класса. Пример:
  * PL_advgraph
  * Будет извлечено PL_ и advgraph.
  * 
  * @param type $className
  * @return null
  */
 public static function extractInfoFromClassName($className, &$classPrefix, &$entity)
 {
     if (1 !== preg_match('/^[A-Z]+\\_/', $className, $matches)) {
         return false;
         //---
     }
     $ident = cut_string_start($className, $matches[0]);
     if (1 !== preg_match('/^[A-Za-z0-9]+$/', $ident, $imatches)) {
         return false;
         //---
     }
     $classPrefix = $matches[0];
     $entity = $imatches[0];
     return true;
     //---
 }
Beispiel #9
0
 public function getByKeyPrefix($prefix, $prefixCut = false)
 {
     $result = array();
     foreach ($this->data as $key => $value) {
         if (starts_with($key, $prefix)) {
             $key = $prefixCut ? cut_string_start($key, $prefix) : $key;
             $result[$key] = $value;
         }
     }
     return $result;
 }
Beispiel #10
0
function unique_from_path($dirs1, $dirs2 = null, $dirs3 = null, $dirs4 = null)
{
    return str_replace(DIR_SEPARATOR, '-', cut_string_start(cut_string_end(next_level_dir(func_get_args()), DIR_SEPARATOR), DIR_SEPARATOR));
}
Beispiel #11
0
 /**
  * КОНСТРУКТОР
  */
 protected function __construct()
 {
     $this->CLASS = get_called_class();
     $this->INSTS_CACHE = new SimpleDataCache();
     $this->UNIQUE = self::unique($this->getFoldingType(), $this->getFoldingSubType());
     $this->LOGGER = PsLogger::inst(__CLASS__ . '-' . $this->UNIQUE);
     $this->PROFILER = PsProfiler::inst(__CLASS__);
     $this->RESOURCE_TYPES_LINKED = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_LINKED);
     $this->RESOURCE_TYPES_CHECK_CHANGE = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_CHECK_CHANGE);
     //Получим текстовое описание
     $this->TO_STRING = $this->getTextDescr();
     /*
      * Проверим, что заданы размеры обложки по умолчанию, если мы работаем с картинками
      */
     if ($this->isImagesFactoryEnabled() && !$this->defaultDim()) {
         raise_error("Не заданы размеры обложки по умолчанию для фолдинга {$this}");
     }
     /*
      * Последовательность, однозначно идентифицирующая фолдинг и используемыя в различных 
      * ситуациях для связи фолдинга и его сущностей, таких как:
      * смарти функции, класс и т.д.
      * Пример: trpost, pl и т.д.
      */
     $SRC_PREFIX = trim($this->getFoldingSubType()) . $this->getFoldingType();
     $this->SMARTY_PREFIX = $SRC_PREFIX;
     //Если мы используем php-классы, то проверим, корректно ли задан префикс классов
     if ($this->isAllowedResourceType(self::RTYPE_PHP)) {
         $this->CLASS_PREFIX = strtoupper($SRC_PREFIX) . '_';
         $this->CLASS_PATH_BASE = ensure_dir_endswith_dir_separator($this->getResourcesDm()->absDirPath());
     }
     //Разберём настройки хранения фолдингов в базе
     if ($this->isWorkWithTable()) {
         $dbs = explode('.', trim($this->foldingTable()));
         $this->TABLE_VIEW = array_get_value(0, $dbs);
         $this->TABLE = cut_string_start($this->TABLE_VIEW, 'v_');
         $this->TABLE_COLUMN_IDENT = array_get_value(1, $dbs);
         $this->TABLE_COLUMN_STYPE = array_get_value(2, $dbs);
         check_condition(!!$this->TABLE && !!$this->TABLE_COLUMN_IDENT, "Некорректные настройки работы с базой для фолдинга {$this}");
         if ($this->TABLE_COLUMN_STYPE) {
             check_condition($this->hasSubType(), "Некорректные настройки работы с базой. Фолдинг {$this} не имеет подтипа.");
         }
     }
 }
 /**
  * КОНСТРУКТОР
  */
 protected function __construct()
 {
     $this->CLASS = get_called_class();
     $this->UNIQUE = self::unique($this->getFoldingType(), $this->getFoldingSubType());
     $this->LOGGER = PsLogger::inst(__CLASS__ . '-' . $this->UNIQUE);
     $this->PROFILER = PsProfiler::inst(__CLASS__);
     $this->CLASS_PREFIX = FoldedStorage::getFoldingClassPrefix($this->UNIQUE);
     $this->SMARTY_PREFIX = FoldedStorage::getFoldingSourcePrefix($this->UNIQUE);
     $this->RESOURCE_TYPES_LINKED = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_LINKED);
     $this->RESOURCE_TYPES_CHECK_CHANGE = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_CHECK_CHANGE);
     //Получим текстовое описание
     $this->TO_STRING = $this->getTextDescr();
     /*
      * Проверим, что заданы размеры обложки по умолчанию, если мы работаем с картинками
      */
     if ($this->isImagesFactoryEnabled() && !$this->defaultDim()) {
         raise_error("Не заданы размеры обложки по умолчанию для фолдинга {$this}");
     }
     //Разберём настройки хранения фолдингов в базе
     if ($this->isWorkWithTable()) {
         $dbs = explode('.', trim($this->foldingTable()));
         $this->TABLE_VIEW = array_get_value(0, $dbs);
         $this->TABLE = cut_string_start($this->TABLE_VIEW, 'v_');
         $this->TABLE_COLUMN_IDENT = array_get_value(1, $dbs);
         $this->TABLE_COLUMN_STYPE = array_get_value(2, $dbs);
         check_condition(!!$this->TABLE && !!$this->TABLE_COLUMN_IDENT, "Некорректные настройки работы с базой для фолдинга {$this}");
         if ($this->TABLE_COLUMN_STYPE) {
             check_condition($this->hasSubType(), "Некорректные настройки работы с базой. Фолдинг {$this} не имеет подтипа.");
         }
     }
 }
Beispiel #13
0
 public function getRelPathNoDs()
 {
     return cut_string_start($this->relPath, DIR_SEPARATOR);
 }
 public static function HTTP_HOST()
 {
     return cut_string_start(lowertrim(basename(self::CONST_STR(__FUNCTION__))), 'www.');
 }
Beispiel #15
0
 /**
  * Метод возвращает содержимое php файла, удаляя открывающий и закрывающий php теги
  */
 public function getFileContentsNoTags()
 {
     return trim(cut_string_end(cut_string_start($this->getDi()->getFileContents(), '<?php'), '?>'));
 }