示例#1
0
文件: LibEdit.php 项目: ilivanoff/www
 protected function executeImpl(ArrayAdapter $params)
 {
     $libType = $params->str('fsubtype');
     $libManager = Handlers::getInstance()->getLibManager($libType);
     $models = $params->arr('models');
     foreach ($models as $model) {
         $model['grup'] = $libType;
         $item = new LibItemDb($model);
         check_condition($item->getIdent(), 'Не передан идентификатор сущности');
         $libManager->saveLibItem($item, AdminLibBean::inst());
     }
     return new AjaxSuccess();
 }
示例#2
0
 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);
 }
示例#3
0
 /**
  * Функции, доступные только администраторам
  */
 public function saveLibItem(LibItemDb $item, AdminLibBean $bean)
 {
     $this->LOGGER->info("{} lib item: {}", $item->hasId() ? 'Updating' : 'Creating', $item);
     //UPDATE
     if ($item->hasId()) {
         $bean->updateLibItem($item);
         return;
         //---
     }
     //CREATE
     $id = $bean->createLibItem($item);
     $this->LOGGER->info("Lib item successfully created in DB, id: {$id}. Trying to create folded entity.");
     try {
         $this->createEntity($item->getIdent());
     } catch (Exception $ex) {
         $this->LOGGER->info("Cannot create entity, reason: {$ex->getMessage()}. Removing LibEntity from DB.");
         $bean->removeLibEntity($id);
         throw $ex;
     }
     $this->LOGGER->info('Lib entity successfully created.');
 }