Exemple #1
0
 /**
  * Возвращает последний фолдинг для журнала. Если фолдингов вообще нет - вернётся null.
  */
 private function getLastFoldingIdent()
 {
     $foldings = $this->getFolding()->getAllIdents();
     usort($foldings, function ($f1, $f2) {
         return MagManager::ident2id($f1) > MagManager::ident2id($f2) ? 1 : -1;
     });
     return count($foldings) == 0 ? null : end($foldings);
 }
Exemple #2
0
function smarty_block_part($params, $content, Smarty_Internal_Template &$smarty)
{
    if (!$content) {
        return;
    }
    $post = PostFetchingContext::getInstance()->getPost();
    $postType = $post->getPostType();
    $content = trim($content);
    $descr = value_Array(array('desc', 'descr'), $params);
    switch ($postType) {
        case POST_TYPE_ISSUE:
            //ЖУРНАЛ
            if ($content == 'EDITOR') {
                $postId = MagManager::ident2id($post->getIdent());
                echo "<h4 class=\"ps-post-head section\"><span>Выпуск {$postId}.</span> Редакторская колонка</h4>";
            } else {
                switch ($content) {
                    case 'WHOIS':
                        $content = 'Кто это?';
                        break;
                    case 'TASKS':
                        PostFetchingContext::getInstance()->resetTasksNumber();
                        $content = 'Задачки на подумать';
                        break;
                    case 'TASKS_A':
                        $content = 'Ответы на задачи предыдущего номера';
                        break;
                    case 'CITATA':
                        $content = 'Цитата номера';
                        break;
                    case 'VERSE':
                        $content = "Стихи, {$descr}";
                        break;
                    case 'HUMOR':
                        $content = 'Студенческий юмор';
                        break;
                }
                $curNum = PostFetchingContext::getInstance()->addAnons($content);
                echo "<h4 id=\"p{$curNum}\" class=\"section\"><span>Часть#{$curNum}.</span> {$content}</h4>";
            }
            break;
        case POST_TYPE_TRAINING:
            //УПРАЖНЕНИЯ
            $curNum = PostFetchingContext::getInstance()->addAnons($content);
            echo "<h5 id=\"p{$curNum}\" class=\"paragraph\">{$curNum}. {$content}</h5>";
            break;
        default:
            check_condition(false, __FUNCTION__ . ' function cannot be used with post type ' . $postType);
    }
}
Exemple #3
0
 public function registerPost(PostsBean $bean, $ident, $name, $rubId)
 {
     $hasRub = $bean instanceof RubricsBean;
     $table = $bean->getPostsTable();
     $postId;
     $post = $this->getPostByIdent($bean, $ident);
     if ($post == null) {
         if ($hasRub) {
             $postId = $this->insert("INSERT INTO {$table}\n(id_rubric, name, ident, b_show, dt_publication, rev_count, content, content_showcase, b_tpl) \nVALUES (?, ?, ?, 0, unix_timestamp(), 0, null, null, 1)", array($rubId, $name, $ident));
         } else {
             $postId = MagManager::ident2id($ident);
             $this->insert("INSERT INTO {$table}\n(id_post, name, ident, b_show, rev_count) \nVALUES (?, ?, ?, 0, 0)", array($postId, $name, $ident));
         }
     } else {
         $postId = $post->getId();
     }
     $this->update("update {$table} set name=? where id_post=?", array($name, $postId));
     if ($hasRub) {
         $this->update("update {$table} set id_rubric=? where id_post=?", array($rubId, $postId));
     }
 }