Exemplo n.º 1
0
 /**
  *   Проверяет страницу, если она скрипт редиректит на страницу скрипта, иначе возвращает модель класса
  * @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;
 }
Exemplo n.º 2
0
 protected static function checkParentExists($nParent)
 {
     if (empty($nParent)) {
         return;
     }
     try {
         $aParent = SiteMap_Sample::getRowFromBD($nParent);
     } catch (SiteMapException $e) {
         throw new SiteMapException('Parent element (' . $nParent . ') not found ');
     }
     return $aParent;
 }
Exemplo n.º 3
0
 public static function getRowFromBD($nId)
 {
     $nId = intval($nId);
     $aResult = SiteMap_Sample::get($nId);
     if (empty($aResult)) {
         throw new SiteMapException('Page not found');
     }
     return $aResult;
 }