/** * Метод проверяет, относится ли фолдинг к SDK */ public function isSdkFolding(FoldedResources $folding) { $funique = $folding->getUnique(); if (array_key_exists($funique, $this->UNIQUE_2_PROVIDER)) { $provider = $this->UNIQUE_2_PROVIDER[$funique]; return $provider::isSdk(); } raise_error("Folding '{$folding}' is not registered in any foldings provider"); }
/** @return FoldedEntity */ public static function inst(FoldedResources $folding, $ident, $assertExists = true) { $unique = $folding->getUnique($ident); if (!array_key_exists($unique, self::$items)) { if ($assertExists) { $folding->assertExistsEntity($ident); } self::$items[$unique] = new FoldedEntity($folding, $ident); } return self::$items[$unique]; }
protected function loadIdentsRight($mident, array $params, MappingSource $cfgLeft, $identLeft) { $allIdents = $this->folding->getAccessibleIdents(); switch ($mident) { case 'RUBRIC_2_SCCONTROLLERS': if ($this->folding instanceof ShowcasesCtrlManager) { return array_diff($allIdents, $this->folding->getBaseControllerIdents()); } } return $allIdents; }
/** * Метод возвращает видимые пользователю объекты из базы */ public function getVisibleObjects(FoldedResources $folded, $objName, array $visibleIdents) { $folded->assertWorkWithTable(); $cacheKey = $folded->getUnique("visible-{$objName}"); if (!$this->CACHE->has($cacheKey)) { $view = $folded->getTableView(); $colIdent = $folded->getTableColumnIdent(); $colStype = $folded->getTableColumnStype(); $where = array(); if ($colStype) { $where[$colStype] = $folded->getFoldingSubType(); } $this->CACHE->set($cacheKey, $this->getArray(Query::select('*', $view, $where), null, ObjectQueryFetcher::inst($objName, $colIdent)->setIncludeKeys($visibleIdents))); } return $this->CACHE->get($cacheKey); }
public function buildContent() { $navigation = AdminPageNavigation::inst(); $ftype = LibResources::LIB_FOLDING_TYPE; $fsubtype = RequestArrayAdapter::inst()->str('fsubtype'); $fident = RequestArrayAdapter::inst()->str('fident'); $mode = !$fsubtype ? self::MODE_FOLDINGS_LIST : self::MODE_FOLDING_CONTENT; $PARAMS['error'] = null; switch ($mode) { case self::MODE_FOLDINGS_LIST: $PARAMS['foldings'] = array(); /* @var $manager FoldedResources */ foreach (Handlers::getInstance()->getLibManagers() as $manager) { $PARAMS['foldings'][] = array('name' => $manager->getEntityName() . ' (' . $manager->getUnique() . ')', 'url' => $this->url(array('fsubtype' => $manager->getFoldingSubType()))); } $navigation->setCurrent('Список библиотек'); break; case self::MODE_FOLDING_CONTENT: $manager = Handlers::getInstance()->getTimeLineFolding($fsubtype); $PARAMS['tlbfe'] = $manager->getTLBuilderFoldedEntity(); $PARAMS['folding']['name'] = $manager->getEntityName(); $PARAMS['folding']['fsubtype'] = $manager->getFoldingSubType(); //TODO - вынести $items = AdminLibBean::inst()->getAllNoFetch($fsubtype); $PARAMS['folding']['data'] = array(); /* @var $item LibItemDb */ foreach ($items as $item) { $item['editurl'] = AP_APFoldingEdit::urlFoldingEdit(FoldedResources::unique($ftype, $fsubtype, $item['ident'])); $PARAMS['folding']['data'][] = $item; } $navigation->addPath($this->url(), 'Список библиотек'); $navigation->setCurrent($manager->getEntityName()); break; } $PARAMS['mode'] = $mode; echo $this->getFoldedEntity()->fetchTpl($PARAMS); }
public static final function getIdent() { return FoldedResources::extractIdentFormClass(get_called_class()); }
/** * Метод создаёт новый фолдинг */ public function makeNewFolding(ArrayAdapter $adapter) { $ifaces = $adapter->arr('ifaces'); $rtypes = $adapter->arr('rtypes'); $type = lowertrim($adapter->str('FoldingType')); $subtype = lowertrim($adapter->str('FoldingSubType')); $group = $adapter->str('FoldingGroup'); $classPrefix = $adapter->str('FoldingClassPrefix'); check_condition($type, 'Не передан тип фолдинга'); check_condition($group, 'Не передана группа для фолдинга'); check_condition($classPrefix, 'Не передан префикс для классов фолдинга'); //TODO - определять директорию для воздания менеджера фолдингов. die('Folding dir is not deffined.'); $classesDi = DirItem::inst(array('sdk/kit', 'folded'), $group); check_condition(!$classesDi->isDir(), "Директория {$classesDi} уже существует"); check_condition(!$classesDi->isFile(), "Элемент {$classesDi} не может быть файлом"); $rtypes = array_intersect(array_keys(PsUtil::getClassConsts('FoldedResources', 'RTYPE_')), $rtypes); $rtypesArr = trim(implode(', self::', $rtypes)); $rtypesArr = $rtypesArr ? "self::{$rtypesArr}" : ''; $hasPhp = in_array('RTYPE_PHP', $rtypes); $classesDm = DirManager::inst($classesDi->getRelPath())->makePath(); $resourcesPatternDmTo = DirManager::resources(array('folded', $group, FoldedResources::PATTERN_NAME)); check_condition(!$resourcesPatternDmTo->isDir(), "Целевая директория {$resourcesPatternDmTo} существует"); $resourcesPatternDmFrom = DirManager::resources(array('folded', FoldedResources::PATTERN_NAME)); check_condition($resourcesPatternDmFrom->isDir(), "Некорректна директория-источник {$resourcesPatternDmFrom}"); $interfaces = array(); foreach ($this->getFoldedInterfaces($ifaces) as $name => $ifaceClass) { $ctt = $ifaceClass->getClassBody(); if ($ctt) { $interfaces[] = "/****************\n\t * {$name}\n\t ****************/\n" . $ctt; } } $smParams = $adapter->getData(); $smParams['rtypes'] = $rtypesArr; $smParams['funique'] = FoldedResources::unique($type, $subtype); $smParams['BaseClass'] = 'Base' . $classPrefix; $smParams['ManagerClass'] = $classPrefix . 'Manager'; $smParams['ResourcesClass'] = $classPrefix . 'Resources'; $smParams['implements'] = $ifaces ? 'implements ' . implode(', ', $ifaces) . ' ' : ''; $smParams['interfaces'] = $interfaces ? implode("\n\n\t", $interfaces) : ''; try { //КЛАССЫ //Resources $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'resources.tpl'), $smParams); $di = $classesDm->getDirItem(null, $smParams['ResourcesClass'], 'php'); $di->writeToFile(trim($tpl->fetch()), true); //Manager $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'manager.tpl'), $smParams); $di = $classesDm->getDirItem(null, $smParams['ManagerClass'], 'php'); $di->writeToFile(trim($tpl->fetch()), true); if ($hasPhp) { //BaseClass $tpl = PSSmarty::template(DirItem::inst(array(__DIR__, 'tpls'), 'baseclass.tpl'), $smParams); $di = $classesDm->getDirItem(null, $smParams['BaseClass'], 'php'); $di->writeToFile(trim($tpl->fetch()), true); } //ШАБЛОН ДЛЯ СУЩНОСТЕЙ $resourcesPatternDmTo->makePath(); foreach ($rtypes as $rtype) { $ext = FoldedResources::resourceTypeToExt(PsUtil::newReflectionClass('FoldedResources')->getConstant($rtype)); $diTo = $resourcesPatternDmTo->getDirItem(null, FoldedResources::PATTERN_NAME, $ext); $diFrom = $resourcesPatternDmFrom->getDirItem(null, FoldedResources::PATTERN_NAME, $ext); if ($ext == PsConst::EXT_PHP) { $diTo->writeToFile(str_replace('eclassnamebase', $smParams['BaseClass'], $diFrom->getFileContents())); continue; } $diFrom->copyTo($diTo); } } catch (Exception $ex) { $classesDm->clearDir(null, true); $resourcesPatternDmTo->clearDir(null, true); throw $ex; } }
/** * Метод патыется получить путь к сущности фолдинга по названию класса. * Все классы для сущностей фолдинга начинаются на префикс с подчёркиванием, * например PL_, на этом и основан способ подключени класса. * * Метод должен быть статическим, так как если мы попытаемся получить путь к * классу фолидна, создаваемому Handlers, то никогда его не загрузим. */ public static function tryGetFoldedEntityClassPath($className) { $prefix = FoldedResources::extractPrefixFromClass($className); $folding = $prefix ? self::getInstance()->getFoldingByClassPrefix($prefix, false) : null; if ($folding) { $ident = FoldedResources::extractIdentFormClass($className); return $folding->getClassPath($ident); } return null; }
public static function onEntityAction($action, FoldedResources $folding, $ident = null, $msg = null) { if (self::inst()->LOGGER->isEnabled()) { self::inst()->ACTIONS[$action][] = array($folding->getUnique($ident), $msg); } }
protected function loadIdentsRight($mident, array $params, MappingSource $cfgLeft, $identLeft) { return $this->folding->getAccessibleDbIdents(); }
/** * Метод удаляет строку из базы, соотвутствующую переданной сущности фолдинга */ public function deleteFoldingDbRec(FoldedResources $folding, $ident) { check_condition($folding->getTableName() === $this->getName(), "Таблица {$this->getName()} не работает с фолдингом {$folding->getEntityName()}."); $dbrec = $this->getFoldingDbRec($folding, $ident); if (is_array($dbrec)) { $this->saveRec($folding->getDbRec4Entity($ident), PS_ACTION_DELETE); } }
/** * Метод регистрации экземпляров фолдингов * * @param FoldedResources $inst - экземпляр */ protected final function register(FoldedResources $inst) { $unique = $inst->getUnique(); if (array_key_exists($unique, $this->FOLDINGS)) { PsUtil::raise('Folding \'{}\' is already registered. Cannot register \'{}\' with same unique.', $this->FOLDINGS[$unique], $inst); } else { $this->FOLDINGS[$unique] = $inst; if ($this->LOGGER->isEnabled()) { $this->LOGGER->info('+{}. {}, count: {}.', pad_left(count($this->FOLDINGS), 3, ' '), $inst, FoldedStorage::getEntitiesCount($unique)); } } }
/** @return APagesResources */ public static function inst() { return parent::inst(); }
/** * Возвращает признак - содержится ли в данном столбце идентификатор переданного фолдинга */ public function isHoldFoldingIdent(FoldedResources $folding) { return $folding->getTableColumnIdent() == $this->getName(); }
public function __construct(PostsProcessor $pp) { $this->pp = $pp; parent::__construct(); }
public function __construct(RubricsProcessor $rp) { $this->rp = $rp; parent::__construct(); }