Exemple #1
0
function smarty_modifier_post_meta(PostContentProvider $postCP, $news = false)
{
    $post = $postCP->getPost();
    $postId = $post->getId();
    $type = $post->getPostType();
    $pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
    $rp = Handlers::getInstance()->getRubricsProcessorByPostType($type, false);
    $trStateToggle = null;
    $rubHref = null;
    $commentsHref = null;
    $name = null;
    if ($news) {
        $name = $post->getName();
        $name = "<span class=\"name\">{$name}</span>";
    }
    if (!$news && $post->getPostType() == POST_TYPE_TRAINING && AuthManager::isAuthorized()) {
        $trStateToggle = '<a href="#' . $postId . '" title="Изменить состояние урока" class="toggle">Пройден</a>';
    }
    $rubHref = $rp ? $rp->rubricHref($post->getRubricId(), null, 'rubric') : null;
    //    if (!$news) {
    $commentsCnt = $post->getCommentsCount();
    $commentsHref = $pp->postHref($post, "Комментариев: {$commentsCnt}", 'comments', array('class' => 'commentcount'));
    //    }
    if ($name || $trStateToggle || $rubHref || $commentsHref) {
        echo '<div class="post_meta">';
        echo "{$name}&nbsp;{$trStateToggle} {$rubHref} {$commentsHref}";
        echo '</div>';
    }
}
 protected function registerPluginsImpl()
 {
     /* @var $manager FoldedResources */
     foreach (Handlers::getInstance()->getBubbles() as $manager) {
         $this->registerBlock($manager->getSmartyPrefix());
     }
 }
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     if (!$adapter->hasAllNoEmpty('folding', self::PARAM_NEW_FOLDING_IDENT)) {
         return 'Не переданы все необходимые параметры.';
     }
     $funique = $adapter->str('folding');
     $fident = check_condition($adapter->str(self::PARAM_NEW_FOLDING_IDENT), 'Пустой идентификатор фолдинга');
     $folding = Handlers::getInstance()->getFoldingByUnique($funique);
     $folding->assertNotExistsEntity($fident);
     switch ($button) {
         case self::BUTTON_SAVE_DB:
             $action = PS_ACTION_CREATE;
             $table = TableExporter::inst()->getTable($folding);
             //Проставим руками идентификатор фолдинга для колонки из базы
             $adapter->set($folding->getTableColumnIdent(), $fident);
             $rec = $table->fetchRowFromForm($adapter->getData(), $action);
             if (!is_array($rec)) {
                 //Данные для создания записи в БД не прошли валидацию
                 return $rec;
             }
             $table->saveRec($rec, $action);
             //createFoldingDbRec($folding, $ident);
         //createFoldingDbRec($folding, $ident);
         case self::BUTTON_SAVE:
             $folding->createEntity($fident);
             break;
     }
     return new AjaxSuccess(array('url' => AP_APFoldingEdit::urlFoldingEdit($folding->getFoldedEntity($fident))));
 }
 public static function chStatusOld($id, $status)
 {
     try {
         self::$o_erip = new \Dm\Erip();
         self::$opt_status = \Bitrix\Main\Config\Option::get(self::$module_id, "order_status_code_erip");
         self::$opt_payment = \Bitrix\Main\Config\Option::get(self::$module_id, "payment_system_id");
         self::$values = CSaleOrder::GetList(array(), array("ID" => $id), false, false, array("ID", "PAY_SYSTEM_ID", "PRICE", "CURRENCY", "STATUS_ID"))->Fetch();
         if (self::$values["PAY_SYSTEM_ID"] == self::$opt_payment && $status != self::$values["STATUS_ID"] && $status == self::$opt_status) {
             static::setTehnicalInfo();
             static::setUserInfo();
             static::setMoneyInfo();
             $r = self::$o_erip->submit();
             self::$o_response = json_decode($r);
             if (isset(self::$o_response->errors)) {
                 throw new \Exception(self::$o_response->message);
             }
             if (CSaleOrder::Update($id, array("COMMENTS" => "status: " . self::$o_response->transaction->status . "\n" . "transaction_id: " . self::$o_response->transaction->transaction_id . "\n" . "order_id: " . self::$o_response->transaction->order_id . "\n" . "account_number: " . self::$o_response->transaction->erip->account_number . "\n"))) {
                 static::sendMail();
             }
             return true;
         }
     } catch (Exception $e) {
         $GLOBALS["APPLICATION"]->ThrowException($e->getMessage());
         return false;
     }
 }
Exemple #5
0
 public function doProcess(ArrayAdapter $params)
 {
     $postId = $params->int('postId');
     $postType = $params->str('postType');
     $this->postCP = Handlers::getInstance()->getPostsProcessorByPostType($postType)->getPostContentProvider($postId);
     check_condition(!!$this->postCP, "Not found post with id='{$postId}' for post type='{$postType}'");
 }
Exemple #6
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $unique = $params->str(DiscussionController::JS_DATA_UNIQUE);
     $upDown = $params->bool(DiscussionController::JS_DATA_UPDOWN);
     $entity = $params->str(DiscussionController::JS_DATA_THREAD);
     $theme = $params->str(self::JS_PARAM_THEME);
     $comment = $params->str(self::JS_PARAM_COMMENT);
     $parentId = $params->int(self::JS_PARAM_PARENT_ID);
     $controller = Handlers::getInstance()->getDiscussionController($unique);
     //Валидируем тему
     if (!$parentId && $controller->getDiscussionSettings()->isThemed()) {
         if (!$theme) {
             return 'Введите тему';
         }
         $error = UserInputValidator::validateShortText($theme);
         if ($error) {
             return $error;
         }
         $theme = UserInputTools::safeShortText($theme);
     }
     //Валидируем комментарий
     if (!$comment) {
         return 'Введите комментарий';
     }
     $error = UserInputValidator::validateLongText($comment);
     if ($error) {
         return $error;
     }
     $comment = UserInputTools::safeLongText($comment);
     $msgObj = $controller->saveMessage($entity, $parentId, $comment, $theme, PsUser::inst());
     if (!$msgObj instanceof DiscussionMsg) {
         return 'Ошибка добавления сообщения';
     }
     return new AjaxSuccess($controller->buildLeaf($msgObj));
 }
Exemple #7
0
 public function doProcess(ArrayAdapter $params)
 {
     $postId = $params->int('postId');
     $postType = $params->str('postType');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($postType);
     $this->postCP = $pp->getPostContentProvider($postId);
 }
Exemple #8
0
 public function execute()
 {
     //1. ПРОВЕРИМ ВСЕ ФОЛДИНГИ, НЕТ ЛИ ИЗМЕНЁННЫХ СУЩНОСТЕЙ
     /* @var $folding FoldedResources */
     foreach (Handlers::getInstance()->getFoldings() as $folding) {
         $folding->checkAllEntitiesChanged();
     }
 }
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $entity = Handlers::getInstance()->getFoldedEntityByUnique($adapter->str('fentity'));
     $tpl = $entity->getFolding()->getInfoTpl($entity->getIdent(), $adapter->str('ftpl'));
     $content = $adapter->str('tpl');
     $tpl->getDirItem()->writeLineToFile($content, true);
     return new AjaxSuccess();
 }
function smarty_modifier_rubric_title(RubricContentProvider $rubricCP)
{
    $rubric = $rubricCP->getRubric();
    $rp = Handlers::getInstance()->getRubricsProcessorByPostType($rubric->getPostType());
    $title = $rp->rubricTitle();
    $name = $rubric->getName();
    echo "<h4>{$title}: <span>{$name}</span></h4>";
}
/**
 * Управление постом
 */
function smarty_modifier_post_header_controls($post)
{
    $post = $post instanceof PostContentProvider ? $post->getPost() : $post;
    $pp = Handlers::getInstance()->getPostsProcessorByPostType($post->getPostType());
    /*
     * Собираем кнопки управления
     */
    $buttons = array();
    $hintClasses = 'hint--top hint--info hint--rounded';
    //Печать поста
    $attrs = array();
    $title = 'Версия для печати';
    $attrs['href'] = '#print';
    $attrs['title'] = $title;
    $attrs['data'] = array('hint' => $title);
    $attrs['class'] = $hintClasses;
    $content = CssSpritesManager::getDirSprite(CssSpritesManager::DIR_ICO, 'print', true);
    $buttons[] = PsHtml::a($attrs, $content);
    //Оригинальный вид поста
    if (PsDefines::isReplaceFormulesWithImages()) {
        $attrs = array();
        $title = 'Просмотр ' . ps_strtolower($pp->postTitle(null, 2)) . ' без замены формул на картинки';
        $attrs['href'] = '#originalView';
        $attrs['title'] = $title;
        $attrs['data'] = array('hint' => $title);
        $attrs['class'] = $hintClasses;
        $content = CssSpritesManager::getDirSprite(CssSpritesManager::DIR_ICO, 'formula', true);
        $buttons[] = PsHtml::a($attrs, $content);
    }
    //Быстрый просмотр постов (перелистывание)
    $attrs = array();
    $title = 'Предыдущий/следующий ' . ps_strtolower($pp->postTitle(null, 1));
    $attrs['href'] = '#prevNextView';
    $attrs['title'] = $title;
    $attrs['data'] = array('hint' => $title);
    $attrs['class'] = $hintClasses;
    $content = CssSpritesManager::getDirSprite(CssSpritesManager::DIR_ICO, 'prev_next', true);
    $buttons[] = PsHtml::a($attrs, $content);
    //Предыдущий пост
    $prevPost = $pp->getPrevPost($post->getId(), false);
    if ($prevPost) {
        $attrs = array();
        $attrs['data']['hint'] = $pp->postTitle($prevPost);
        $attrs['class'] = $hintClasses;
        $content = CssSpritesManager::getDirSprite(CssSpritesManager::DIR_ICO, 'prev_s', true);
        $buttons[] = $pp->postHref($prevPost, $content, null, $attrs);
    }
    //Следующий пост
    $nextPost = $pp->getNextPost($post->getId(), false);
    if ($nextPost) {
        $attrs = array();
        $attrs['data']['hint'] = $pp->postTitle($nextPost);
        $attrs['class'] = $hintClasses;
        $content = CssSpritesManager::getDirSprite(CssSpritesManager::DIR_ICO, 'next_s', true);
        $buttons[] = $pp->postHref($nextPost, $content, null, $attrs);
    }
    return PsHtml::div(array('class' => PsConstJs::POST_HEAD_CONTROLS), implode(' ', $buttons));
}
 protected function getPlugins()
 {
     $result = array();
     /* @var $manager FoldedResources */
     foreach (Handlers::getInstance()->getBubbles() as $manager) {
         $this->registerPluginImpl($result, $manager->getSmartyPrefix());
     }
     return $result;
 }
 function __construct(Rubric $rubric = null)
 {
     $this->rubric = $rubric;
     $this->isRubric = !!$rubric;
     if ($this->isRubric) {
         $this->rp = Handlers::getInstance()->getRubricsProcessorByPostType($rubric->getPostType());
         $this->suffix = ' в ' . ps_strtolower($this->rp->rubricTitle(null, 6));
     }
 }
Exemple #14
0
 private function getAllComments()
 {
     $formules = array();
     /* @var $proc PostsProcessor */
     foreach (Handlers::getInstance()->getPostsProcessors() as $proc) {
         $formules = array_merge($formules, $proc->getCommentsFormules());
     }
     return $formules;
 }
Exemple #15
0
 /**
  * Метод пытается выдать очки пользователю на основе запроса к ajax {@link GivePointsCommon}
  */
 public function givePointsByRequest(PsUser $user, ArrayAdapter $request)
 {
     $fentity = Handlers::getInstance()->getFoldedEntityByUnique($request->str('fentity'));
     $class = $fentity->getClassInst();
     PsUtil::assertInstanceOf($class, 'PointsGiverRequest');
     $request->remove('fentity');
     $ctxt = new GivePointsContext($user->getId(), $fentity->getDbCode());
     $class->givePointsByRequest($ctxt, $request);
     return $this->checkGivePointsContext($user, $ctxt);
 }
 protected function doFinalize($CONTENT)
 {
     //1. Менеджеры, которые могут финализировать страницы, производят это
     /* @var $folding PageFinalizerFolding */
     foreach (Handlers::getInstance()->getPageFinaliseFoldings() as $folding) {
         $CONTENT = $folding->finalizePageContent($CONTENT);
     }
     //2. BubbledFolding добавляют свои ресурсы для быстрого открытия подсказок
     return $CONTENT . $this->getBubbles($CONTENT);
 }
Exemple #17
0
 protected function preload($mident, array $params)
 {
     /* @var $pp PostsProcessor */
     foreach (Handlers::getInstance()->getPostsProcessors() as $pp) {
         $folding = $pp->getFolding();
         foreach ($folding->getAccessibleDbIdents() as $ident) {
             $this->posts[] = $folding->getUnique($ident);
         }
     }
 }
Exemple #18
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $id = $params->int('id');
     $uts = $params->int('date');
     $show = $params->bool('show');
     $type = $params->str('type');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
     AdminPostsBean::inst()->updateState($pp->dbBean(), $id, $uts, $show);
     return new AjaxSuccess();
 }
 public function getUserPostCommentsCnt($userId)
 {
     $total = 0;
     /* @var $cp CommentsProcessor */
     foreach (Handlers::getInstance()->getCommentProcessors() as $cp) {
         $cnt = $cp->getUserCommentsAnswersCnt($userId);
         $total += $cnt;
     }
     return $total;
 }
 /**
  * Основной метод
  */
 protected function getPlugins()
 {
     $result = array();
     /* @var $manager FoldedResources */
     foreach (Handlers::getInstance()->getPanelProviders() as $manager) {
         $prefix = $manager->getSmartyPrefix();
         $result[$prefix . self::MODIFIER_SUFFIX] = Smarty::PLUGIN_MODIFIER;
         //Модификатор
     }
     return $result;
 }
Exemple #21
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $ftype = $params->str('ftype');
     $fsubtype = $params->str('fsubtype');
     $fident = $params->str('fident');
     $zip = Handlers::getInstance()->getFolding($ftype, $fsubtype)->export2zip($fident);
     if (!$zip->isFile()) {
         return 'Не удалось создать архив';
     }
     return new AjaxSuccess($zip->getRelPath());
 }
Exemple #22
0
 public function buildContent()
 {
     $PARAMS['uts_php'] = time();
     $PARAMS['uts_db'] = UtilsBean::inst()->getDbUnixTimeStamp();
     $posts = array();
     /* @var $pp PostsProcessor */
     foreach (Handlers::getInstance()->getPostsProcessors() as $pp) {
         $posts[$pp->postsTitle()] = AdminPostsBean::inst()->getAllPosts($pp->dbBean());
     }
     $PARAMS['data'] = $posts;
     echo $this->getFoldedEntity()->fetchTpl($PARAMS);
 }
function smarty_function_showcases_list($params, Smarty_Internal_Template &$template)
{
    $type = value_Array('type', $params);
    $postsProcessor = Handlers::getInstance()->getPostsProcessorByPostType($type);
    $posts_ids = array_key_exists('posts_ids', $params) ? $params['posts_ids'] : $postsProcessor->getPagePostsIds();
    /* @var $showcasesTpl Smarty_Internal_Template */
    $showcasesTpl = $template->smarty->createTemplate('common/showcases_list.tpl');
    $showcasesTpl->assign('posts_ids', is_array($posts_ids) ? $posts_ids : array());
    $showcasesTpl->assign('full_view', !isEmptyInArray('full_view', $params));
    $showcasesTpl->assign('type', $type);
    $showcasesTpl->display();
}
Exemple #24
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $name = $params->str('name');
     $type = $params->str('type');
     $ident = $params->str('ident');
     $rubId = $params->int('rubId');
     check_condition($name, 'Name is empty');
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($type);
     $pp->getFolding()->assertExistsEntity($ident);
     AdminPostsBean::inst()->registerPost($pp->dbBean(), $ident, $name, $rubId);
     return new AjaxSuccess();
 }
Exemple #25
0
 /**
  * Меод должен вернуть все возможные маппинги.
  * Нужно для показа в админке
  */
 protected final function allMappings()
 {
     $mappings = array();
     foreach (Handlers::getInstance()->getRubricsProcessors() as $postType => $rp) {
         $mappings[] = self::RUBRIC_2_SCCONTROLLERS($postType);
     }
     foreach (Handlers::getInstance()->getPostsProcessors() as $postType => $pp) {
         $mappings[] = self::RECOMMENDED_POSTS($postType);
     }
     $mappings[] = self::CACHE_FOLDINGS();
     $mappings[] = self::CACHE_DBENTITYS();
     return $mappings;
 }
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $clear = $adapter->bool(FORM_PARAM_YES_NO);
     $folding = Handlers::getInstance()->getFoldingByUnique($adapter->str('folding'));
     $uploadedZip = SimpleUploader::inst()->saveUploadedFile();
     try {
         $fentity = $folding->imporFromZip($uploadedZip, $clear);
     } catch (Exception $ex) {
         $uploadedZip->remove();
         throw $ex;
     }
     return new AjaxSuccess(array('url' => AP_APFoldingEdit::url($fentity)));
 }
Exemple #27
0
 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();
 }
Exemple #28
0
 protected function getWindowTplSmartyParams()
 {
     $posts = array();
     /* @var $processor PostsProcessor */
     foreach (Handlers::getInstance()->getPostsProcessors() as $processor) {
         /* @var $post Post */
         foreach ($processor->getPosts() as $post) {
             $posts[IdHelper::ident($post)] = array('name' => $processor->postTitle($post), 'url' => $processor->postUrl($post), 'cover' => $processor->getCoverDi($post->getIdent(), '64x64')->getRelPath());
         }
     }
     $params['posts'] = $posts;
     return $params;
 }
Exemple #29
0
 /** @return NavigationItem */
 private static function byPost(Post $post, $postAnonsName = 'Навигация')
 {
     $pp = Handlers::getInstance()->getPostsProcessorByPostType($post->getPostType());
     $item = self::byHref($pp->postHref($post), $postAnonsName);
     $anons = $pp->getPostContentProvider($post->getId())->getPostParams()->getAnons();
     $item->setPostData($post, $pp);
     if (empty($anons)) {
         return $item;
     }
     $item->setExtraData('chanons');
     foreach ($anons as $num => $name) {
         $item->addChild(self::byHref($pp->postHref($post, $name, "p{$num}")));
     }
     return $item;
 }
Exemple #30
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $action = $params->str('action');
     $unique = $params->str('unique');
     $folding = Handlers::getInstance()->getFoldingByUnique($unique);
     $res = 'OK';
     switch ($action) {
         case 'save_list':
             $list = $params->str('list');
             $data = $params->arr('data');
             $folding->saveList($list, $data);
             break;
         default:
             return 'Неизвестное действие: ' . $action;
     }
     return new AjaxSuccess($res);
 }