Пример #1
0
 /**
  * @covers PsUtil::getClassName
  */
 public function testGetClassName()
 {
     $this->assertEquals(__CLASS__, PsUtil::getClassName(new PsUtilTest()));
     $this->assertEquals(__CLASS__, PsUtil::getClassName(__CLASS__));
     $this->assertEquals(__CLASS__, PsUtil::getClassName(__FILE__));
     $this->assertNotEquals(__FILE__, PsUtil::getClassName(__FILE__));
 }
Пример #2
0
 public static function ident($item)
 {
     if ($item instanceof AbstractPost) {
         return self::postId($item->getPostType(), $item->getIdent());
     }
     if ($item instanceof Rubric) {
         return self::rubricId($item->getPostType(), $item->getIdent());
     }
     raise_error('В IdHelper передан элемент неподдрживаемого типа: ' . PsUtil::getClassName($item));
 }
Пример #3
0
 private static function makeProvider($content)
 {
     if ($content instanceof Rubric) {
         if ($content->isTpl()) {
             return new RubricContentProviderTpl($content);
         } else {
             return new RubricContentProviderDB($content);
         }
     }
     if ($content instanceof Post) {
         if ($content->is(POST_TYPE_ISSUE)) {
             return new IssueContentProvider($content);
         }
         if ($content->isTpl()) {
             return new PostContentProviderTpl($content);
         } else {
             return new PostContentProviderDB($content);
         }
     }
     raise_error('Не удалось построить ' . __CLASS__ . ' для ' . PsUtil::getClassName($content));
 }
Пример #4
0
 /**
  * Основной метод, выполняющий построение страницы
  */
 public final function buildPage()
 {
     //Может ли данная страница вообще быть построена
     check_condition($this->builderIdent, "{$this} не может быть построена");
     //Проверим, установлена ли эта страница, как текущая
     check_condition(WebPages::isCurPage($this), "{$this} не установлена, как текущая, и не может быть построена");
     //Если у пользователя нет доступа к данной странице - выполним редирект
     if (!$this->hasAccess()) {
         $this->redirectHere();
     }
     //Теперь провалидируем установленный контекст
     $ctxt = PageContext::inst();
     check_condition($this->isIt($ctxt->getPage()), PsUtil::getClassName($ctxt) . ' проинициализирован некорректно');
     //Строим страницу
     PageBuilder::inst()->buildPage();
 }
Пример #5
0
 public final function includePanel($panelName)
 {
     if (array_key_exists($panelName, $this->includedPanels)) {
         return $this->includedPanels[$panelName];
     }
     check_condition($this instanceof PanelFolding, "Фолдинг {$this} не может работать с панелями");
     check_condition(in_array($panelName, PsUtil::getClassConsts($this, 'PANEL_')), "Панель [{$panelName}] не может быть предоставлена фолдингом {$this}");
     //Сразу отметим, что панель была запрошена, так как может возникнуть ошибка
     $this->includedPanels[$panelName] = '';
     /*
      * Уникальный код панели - тот самый, через который потом можно будет 
      * достучаться до параметров панели из javascript.
      */
     $panelUnique = $this->getUnique($panelName);
     //Стартуем профайлер
     $this->profilerStart(__FUNCTION__ . "({$panelName})");
     /** @var PluggablePanel */
     $panel = $this->buildPanel($panelName);
     //Мог вернуться и null, тогда ничего не подключаем
     if ($panel == null) {
         //Останавливаем профайлер без сохранения
         $this->profilerStop(false);
         return '';
     }
     //Останавливаем профайлер
     $this->profilerStop();
     check_condition($panel instanceof PluggablePanel, "Возвращена некорректная панель {$panelUnique}. Ожидался обект типа PluggablePanel, получен: " . PsUtil::getClassName($panel));
     //Html content
     $this->includedPanels[$panelName] = trim($panel->getHtml());
     //Js params
     $jsParams = $panel->getJsParams();
     if (!isTotallyEmpty($jsParams)) {
         PageBuilderContext::getInstance()->setJsParamsGroup(PsConstJs::PAGE_JS_GROUP_PANELS, $panelUnique, $jsParams);
     }
     //Smarty resources params
     $smartyParams4Resources = $panel->getSmartyParams4Resources();
     if (is_array($smartyParams4Resources) && !empty($smartyParams4Resources)) {
         PageBuilderContext::getInstance()->setSmartyParams4Resources($smartyParams4Resources);
     }
     return $this->includedPanels[$panelName];
 }
Пример #6
0
 /**
  * Основной метод, выполняющий построение страницы
  */
 public final function buildPage()
 {
     //Проверим, установлена ли эта страница, как текущая
     check_condition(WebPages::isCurPage($this), "{$this} не установлена, как текущая, и не может быть построена");
     //Если у пользователя нет доступа к данной странице - выполним редирект
     if (!$this->hasAccess()) {
         $this->redirectHere();
     }
     //Теперь провалидируем установленный контекст
     $ctxt = PageContext::inst();
     check_condition($this->isIt($ctxt->getPage()), PsUtil::getClassName($ctxt) . ' проинициализирован некорректно');
     $redirectPage = self::inst(is_numeric($this->pageCodeBase) ? $this->pageCodeBase : BASE_PAGE_INDEX);
     if ($ctxt->isRubricPage() && !$ctxt->getRubric()) {
         $redirectPage->redirectHere();
     }
     if ($ctxt->isPostPage() && !$ctxt->getPost()) {
         $redirectPage->redirectHere();
     }
     if ($ctxt->isPopupPage() && !PopupPagesManager::inst()->isValidPageRequested()) {
         $redirectPage->redirectHere();
     }
     PageBuilder::inst()->buildPage();
 }