Example #1
0
 /**
  * Список фолдингов
  */
 public static function listFoldings()
 {
     $managers = array(MagManager::inst(), BlogManager::inst(), TrainManager::inst());
     $foldings = array();
     foreach ($managers as $manager) {
         if ($manager instanceof RubricsProcessor) {
             $foldings[] = $manager->getRubricsFolding();
         }
         if ($manager instanceof PostsProcessor) {
             $foldings[] = $manager->getFolding();
         }
     }
     //Фолдинги
     $foldings[] = PopupPagesManager::inst();
     $foldings[] = PluginsManager::inst();
     $foldings[] = IdentPagesManager::inst();
     $foldings[] = TimeLineManager::inst();
     $foldings[] = TemplateMessages::inst();
     $foldings[] = UserPointsManager::inst();
     $foldings[] = StockManager::inst();
     $foldings[] = HelpManager::inst();
     $foldings[] = EmailManager::inst();
     $foldings[] = PSForm::inst();
     $foldings[] = DialogManager::inst();
     //Библиотеки
     $foldings[] = PoetsManager::inst();
     $foldings[] = ScientistsManager::inst();
     //Админские страницы
     $foldings[] = APagesResources::inst();
     //Базовые страницы
     $foldings[] = BasicPagesManager::inst();
     //Построитель страниц
     $foldings[] = PageBuilder::inst();
     //Управление списком предпросмотра постов
     $foldings[] = ShowcasesCtrlManager::inst();
     //Элементы в правой панели навигации
     $foldings[] = ClientBoxManager::inst();
     //Все фолдинги системы
     return $foldings;
 }
Example #2
0
 /**
  * Метод строит html листочка на дереве дискуссии:
  * 
  * <li>
  * ....
  *    <ul>
  *       <li>
  *       ....
  *       </li>
  *    </ul>
  * </li>
  * 
  * @param DiscussionMsg $msg
  */
 public final function buildLeaf(DiscussionMsg $msg, $simple = false)
 {
     $msgId = $msg->getId();
     $author = $msg->getUser();
     $isDeleted = $msg->isDeleted();
     $isUserComment = $author->isAuthorised();
     $isCanConfirm = !$isUserComment && !$msg->isConfirmed() && !$isDeleted && AuthManager::isAuthorizedAsAdmin();
     $notKnown = !$msg->isKnown() && $msg->getUserTo() && $msg->getUserTo()->isIt(PsUser::instOrNull());
     $msgUnique = $msg->getUnique();
     $threadUnique = $this->SETTINGS->getThreadUnique($msg->getThreadId());
     //Мы открываем страницу для показа этого комментария
     $liId = RequestArrayAdapter::inst()->str(GET_PARAM_GOTO_MSG) === $msgUnique ? " id=\"{$msgUnique}\"" : '';
     //Классы li
     $liClasses = array('msg');
     if ($isDeleted) {
         $liClasses[] = 'deleted';
     }
     //Классы Comment
     $divClasses = array('comment', $msgUnique);
     if ($isUserComment) {
         $divClasses[] = 'user_comment';
     }
     if ($isCanConfirm) {
         $divClasses[] = 'not_confirmed';
     }
     //Данные для Comment
     $divData['unique'] = $msgUnique;
     //Имя пользователя
     $userName = $author->getName() . ($isUserComment ? ' (вы)' : '');
     //КНОПКИ УПРАВЛЕНИЯ СВЕРХУ
     $controlsTop = array();
     if (!$simple) {
         //Кнопки управления сверху
         $controlsTop[] = PsHtml::a(array('href' => '#'), '#');
         if (!$msg->isRoot()) {
             $controlsTop[] = PsHtml::a(array('href' => '#', 'class' => 'parent'), '↑');
         }
     }
     //Кнопки голосования
     if ($this->SETTINGS->isVotable()) {
         $userCanVote = AuthManager::isAuthorized() && !$isUserComment;
         $votes = VotesManager::inst()->getVotesCount($threadUnique, $msgId);
         $likeCtrl = array();
         if ($userCanVote) {
             $vote = VotesManager::inst()->getUserVotes($threadUnique, $msgId, AuthManager::getUserId());
             $likeCtrl[] = PsHtml::a(array('class' => 'like ' . ($vote > 0 ? 'active' : 'clickable')), '+1');
             $likeCtrl[] = PsHtml::a(array('class' => 'votes' . ($vote == 0 ? '' : ' clickable') . ($votes == 0 ? '' : ($votes > 0 ? ' green' : ' red'))), abs($votes));
             $likeCtrl[] = PsHtml::a(array('class' => 'dislike ' . ($vote < 0 ? 'active' : 'clickable')), '−1');
         } else {
             $likeCtrl[] = PsHtml::a(array('class' => 'votes' . ($votes == 0 ? '' : ($votes > 0 ? ' green' : ' red'))), abs($votes));
         }
         $controlsTop[] = PsHtml::span(array('class' => 'vote'), implode('', $likeCtrl));
     }
     $controlsTop = implode('', $controlsTop);
     //КНОПКИ УПРАВЛЕНИЯ СНИЗУ
     $controlsBottom = '';
     if (!$simple && !$isDeleted) {
         $controlsBottom = array();
         $controlsBottom['id'] = $msgId;
         if ($isCanConfirm) {
             $controlsBottom[SmartyFunctions::ACTION_CONFIRM] = 'Принять';
         }
         if (!$msg->isMaxDeepLevel()) {
             $controlsBottom[SmartyFunctions::ACTION_REPLY] = 'Ответить';
         }
         if ($isUserComment) {
             $controlsBottom[SmartyFunctions::ACTION_DELETE] = 'Удалить';
         } elseif (AuthManager::isAuthorizedAsAdmin()) {
             $controlsBottom[SmartyFunctions::ACTION_DELETE] = 'Удалить (админ)';
         }
         $controlsBottom = SmartyFunctions::psctrl($controlsBottom);
     }
     //Собираем параметры в кучу
     $params['msg'] = $msg;
     $params['new'] = $notKnown;
     $params['builder'] = $this;
     $params['liId'] = $liId;
     $params['liClasses'] = implode(' ', $liClasses);
     $params['divClasses'] = implode(' ', $divClasses);
     $params['divData'] = PsHtml::data2string($divData);
     $params['msgId'] = $msgId;
     $params['simple'] = $simple;
     $params['avatar'] = $author->getAvatarImg('42x', array('class' => 'small'));
     $params['userName'] = $userName;
     $params['controlsTop'] = $controlsTop;
     $params['controlsBottom'] = $controlsBottom;
     if ($msg->isTemplated()) {
         $params['msgCtt'] = TemplateMessages::inst()->decodeTemplateMsg($msg);
     } else {
         $params['msgCtt'] = $msg;
     }
     return PSSmarty::template('discussion/common/leaf.tpl', $params)->fetch();
 }
Example #3
0
 private function __construct()
 {
     PsProfiler::inst(__CLASS__)->start(__FUNCTION__);
     $managers = array(MagManager::inst(), BlogManager::inst(), TrainManager::inst());
     foreach ($managers as $manager) {
         //Соберём типы постов
         $this->postTypes[] = $manager->getPostType();
         if ($manager instanceof RubricsProcessor) {
             $this->rubricsProcessors[$manager->getPostType()] = $manager;
             $this->foldings[] = $manager->getRubricsFolding();
         }
         if ($manager instanceof PostsProcessor) {
             $this->postsProcessors[$manager->getPostType()] = $manager;
             $this->foldings[] = $manager->getFolding();
         }
         if ($manager instanceof CommentsProcessor) {
             $this->commentProcessors[$manager->getPostType()] = $manager;
             $this->discussionControllers[$manager->getDiscussionController()->getDiscussionUnique()] = $manager->getDiscussionController();
         }
         if ($manager instanceof PagePreloadListener) {
             $this->pagePreloadListeners[] = $manager;
         }
         if ($manager instanceof NewsProvider) {
             $this->newsProviders[$manager->getNewsEventType()] = $manager;
         }
     }
     //Контроллеры дискуссий
     $this->discussionControllers[FeedbackManager::inst()->getDiscussionUnique()] = FeedbackManager::inst();
     //Фолдинги
     $this->foldings[] = PopupPagesManager::inst();
     $this->foldings[] = PluginsManager::inst();
     $this->foldings[] = IdentPagesManager::inst();
     $this->foldings[] = TimeLineManager::inst();
     $this->foldings[] = TemplateMessages::inst();
     $this->foldings[] = UserPointsManager::inst();
     $this->foldings[] = StockManager::inst();
     $this->foldings[] = HelpManager::inst();
     $this->foldings[] = EmailManager::inst();
     $this->foldings[] = PSForm::inst();
     $this->foldings[] = DialogManager::inst();
     //Библиотеки
     $this->foldings[] = PoetsManager::inst();
     $this->foldings[] = ScientistsManager::inst();
     //Админские страницы
     $this->foldings[] = APagesResources::inst();
     //Базовые страницы
     $this->foldings[] = BasicPagesManager::inst();
     //Построитель страниц
     $this->foldings[] = PageBuilder::inst();
     //Управление списком предпросмотра постов
     $this->foldings[] = ShowcasesCtrlManager::inst();
     //Элементы в правой панели навигации
     $this->foldings[] = ClientBoxManager::inst();
     /*
      * Выделим различные подклассы фолдингов
      */
     foreach ($this->foldings as $folding) {
         //Фолдинги библиотек
         if ($folding instanceof LibResources) {
             $this->libs[] = $folding;
         }
         //Фолдинги обработчиков постов
         if ($folding instanceof PostFoldedResources) {
             $this->postProcessorFoldings[] = $folding;
         }
         //Фолдинги для баблов
         if ($folding instanceof BubbledFolding) {
             $this->bubbles[] = $folding;
         }
         //Фолдинги, предоставляющие панели
         if ($folding instanceof PanelFolding) {
             $this->panels[] = $folding;
         }
         //Фолдинги, финализирующие контент страницы
         if ($folding instanceof PageFinalizerFolding) {
             $this->pageFinaliseFoldings[] = $folding;
         }
         //Индексированный список фолдингов
         $this->folding2unique[$folding->getUnique()] = $folding;
         //Префиксы smarty к фолдингам
         $this->folding2smartyPrefix[$folding->getSmartyPrefix()] = $folding;
         //Префиксы классов к фолдингам
         if ($folding->getClassPrefix()) {
             $this->folding2classPrefix[$folding->getClassPrefix()] = $folding;
         }
     }
     PsProfiler::inst(__CLASS__)->stop();
 }