public function __construct() { $validator = new \Extasy\Validators\IsModelClassNameValidator($_REQUEST['type']); if (!$validator->isValid()) { throw new InvalidArgumentException('Not a valid model '); } $modelName = $_REQUEST['type']; $aType = call_user_func([$modelName, 'getFieldsInfo']); $aBegin = array('К списку "' . (!empty($aType['title']) ? $aType['title'] : '') . '" ' => 'list.php?type=' . $modelName, 'Сортировка' => '#'); $this->typeName = $modelName; $this->back = 'list.php?type=' . $modelName; parent::__construct($aBegin, 'Сортировка'); }
public function createDocument($document_name, $parent) { //////////////////////////////////////////////////////////////// global $_BASE_DATA; $parent = intval($parent); $validator = new \Extasy\Validators\IsModelClassNameValidator($document_name); if (!$validator->isValid()) { throw new \ForbiddenException('Not a model'); } $model = new $document_name(); $model->createEmptyDocument($parent); // return $model->getSitemapId(); }
public function __construct() { $type = $_REQUEST['type']; $validator = new \Extasy\Validators\IsModelClassNameValidator($type); if (!$validator->isValid()) { throw new \ForbiddenException('Not an valid model'); } $title = call_user_func(array($type, 'getLabel'), Model::labelName); $title = sprintf('Назад "%s" ', $title); $aBegin = array($title => 'list.php?type=' . $type, self::title => '#'); $this->typeName = $type; $this->back = 'list.php?type=' . $type; $this->jump_to = 'order.php?type=' . $type; parent::__construct($aBegin, 'Сортировка'); }
protected function loadDocument($id) { if (empty($this->document)) { $validator = new \Extasy\Validators\IsModelClassNameValidator($this->aUrlInfo['document_name']); if (!$validator->isValid()) { throw new ForbiddenException("Not a model: {$this->aUrlInfo['document_name']}"); } $model = $this->aUrlInfo['document_name']; $this->document = new $model(array(), $this->aUrlInfo); $found = $this->document->get($id); if (!$found) { throw new NotFoundException('Document not found'); } $this->aParse = $this->document->getParseData(); } }
/** * ------------------------------------------------------------------------------------------- * @desc Сохраняет отсортированные данные * @return * ------------------------------------------------------------------------------------------- */ public function order() { $typeName = $_POST['type']; $validator = new \Extasy\Validators\IsModelClassNameValidator($typeName); if (!$validator->isValid()) { throw new InvalidArgumentException('Not a model - ' . $typeName); } $aType = call_user_func([$typeName, 'getFieldsInfo']); $szIndex = call_user_func([$typeName, 'getIndexKey']); $i = 1; $aRows = explode("\n", $_POST['order_value']); unset($aRows[0]); foreach ($aRows as $value) { \Extasy\ORM\DBSimple::update($aType['table'], ['order' => $i], [$szIndex => $value]); $i++; } $this->afterOrder(); $this->jump($this->jump_to); }
/** * Создает документ * @param $document string имя документа * @param $place int индекс документ */ public function add($document, $place) { $place = IntegerHelper::toNatural($place); // try { $validator = new \Extasy\Validators\IsModelClassNameValidator($document); if (!$validator->isValid()) { throw new ForbiddenException('Not a model'); } $model = new $document(); $model->createEmptyDocument($place); } catch (Exception $e) { die($e); throw $e; } $this->jump(\Extasy\CMS::getDashboardWWWRoot() . 'sitemap/edit.php?id=' . $model->getSitemapId()); }
/** * Проверяет страницу, если она скрипт редиректит на страницу скрипта, иначе возвращает модель класса * @return */ protected function getModel($id) { // Получаем документ try { $aRow = SiteMap_Sample::get($id); $this->aSitemap = $aRow; } catch (SiteMapException $e) { $this->AddError(_msg('Документ не найден')); $this->jump('./'); } if (!empty($aRow['script'])) { if (!empty($aRow['script_admin_url'])) { $this->jump(\Extasy\CMS::getDashboardWWWRoot() . $aRow['script_admin_url']); } else { $this->addError('У данного скрипта нету панели редактирования'); $this->jump('./'); } } else { $this->szDocumentName = $aRow['document_name']; $this->nId = $aRow['document_id']; $validator = new \Extasy\Validators\IsModelClassNameValidator($aRow['document_name']); if (!$validator->isValid()) { throw new \ForbiddenException('Not a model class:' . $aRow['document_name']); } $szClassName = $aRow['document_name']; } $this->document = new $szClassName(); $found = $this->document->get($this->nId); if (empty($found)) { throw new NotFoundException('Document with id=' . $this->nId . ' not found'); } return $szClassName; }
/** * * Loads document by its sitemap record * @return RegisteredDocument */ public static function loadBySitemapRecord($sitemapInfo) { if (empty($sitemapInfo['document_name'])) { throw new Exception('Not an document'); } $validator = new \Extasy\Validators\IsModelClassNameValidator($sitemapInfo['document_name']); if (!$validator->isValid()) { throw new ForbiddenException("Not a model: {$sitemapInfo['document_name']}"); } $class = $sitemapInfo['document_name']; $result = new $class(); $found = $result->get($sitemapInfo['document_id']); if (empty($found)) { throw new Exception('Internal error. Document not found, but sitemap info exists '); } // $result->sitemapInfo = $sitemapInfo; return $result; }
protected static function appendParseData($sitemapInfo, $dbRowData = array(), $bWithAdditional = false) { if (!empty($sitemapInfo)) { if (!empty($bWithAdditional)) { if (!is_object($dbRowData) || empty($dbRowData)) { $validator = new \Extasy\Validators\IsModelClassNameValidator($sitemapInfo['document_name']); if (!$validator->isValid()) { throw new \ForbiddenException("Not a model: {$sitemapInfo['document_name']}"); } $szModel = $sitemapInfo['document_name']; $oDocument = new $szModel($dbRowData); } $sitemapInfo['additional'] = $oDocument->getPreviewParseData(); } else { if (is_object($dbRowData)) { $sitemapInfo['additional'] = $dbRowData->getData(); } else { if (empty($dbRowData)) { $validator = new \Extasy\Validators\IsModelClassNameValidator($sitemapInfo['document_name']); if (!$validator->isValid()) { throw new \ForbiddenException("Not a model: {$sitemapInfo['document_name']}"); } $szModel = $sitemapInfo['document_name']; $oDocument = new $szModel(); $oDocument->get($sitemapInfo['document_id']); $sitemapInfo['additional'] = $oDocument->getData(); } else { $sitemapInfo['additional'] = $dbRowData; } } } } return $sitemapInfo; }