Example #1
0
 /**
  * Действие просмотра поста комментария:
  */
 public function getLastCommentsAjaxAction(Application $application)
 {
     $cache = KVS::getInstance();
     if ($cache->exists(__CLASS__, $_GET['id'], 'preview')) {
         return unserialize($cache->get(__CLASS__, $_GET['id'], 'preview'));
     }
     $comment = Blog_BlogCommentsModel::GetComment($_GET['id']);
     $result = false;
     if ($comment) {
         $post = Blog_BlogPostsModel::GetPost($comment['post_id']);
         $comment['post_title'] = $post['title'];
         $comment['created_at'] = TemplateHelper::date('d M Y @ H:i', $comment['created_at']);
         $comment['author'] = array($comment['author'], HomeBoardHelper::getBoard($comment['author']));
         unset($comment['ip']);
         $result = $comment;
     } elseif ($post = Blog_BlogPostsModel::GetPost($_GET['id'])) {
         $result = array('id' => $post['id'], 'post_id' => $post['id'], 'post_title' => $post['title'], 'text' => $post['text'], 'author' => array($post['author'], HomeBoardHelper::getBoard($post['author'])), 'created_at' => TemplateHelper::date('d M Y @ H:i', $post['created_at']), 'post_preview' => true);
     }
     $cache->set(__CLASS__, $_GET['id'], 'preview', serialize($result));
     $cache->expire(__CLASS__, $_GET['id'], 'preview', 60 * 60);
     return $result;
 }
Example #2
0
"><?php 
            echo $comment['id'];
            ?>
</a>
							<a href="#" class="js-remove-button g-hidden">
								<img src="http://<?php 
            echo TemplateHelper::getSiteUrl();
            ?>
/ico/remove.gif" width="16" height="16" alt="<?php 
            echo $comment['id'];
            ?>
" />
							</a>
							<?php 
            if ($comment['author'] != 'anonymous') {
                $author = HomeBoardHelper::getBoard($comment['author']);
                ?>
							<a href="http://<?php 
                echo $comment['author'];
                ?>
/" class="b-comment_b-homeboard" title="Аноним выбрал принадлежность «<?php 
                echo $author[1];
                ?>
»">
								<img src="http://<?php 
                echo TemplateHelper::getSiteUrl();
                ?>
/ico/homeboards/<?php 
                echo $author[0];
                ?>
" width="16" height="16" alt="" />
Example #3
0
            return $dbh->delete('1chan_comment', 'id = ' . $dbh->q($id), 1);
        }
        return false;
    }
}
/**
 * Обработчики событий:
 */
EventModel::getInstance()->AddEventListener('add_comment', function ($data) {
    $session = Session::getInstance();
    $session->persistenceSet('last_comment_date', time());
    $session->persistenceSet('last_post_text', $data['text_original']);
    /**
     * Очистка и фильтарция:
     */
    $data['created_at'] = TemplateHelper::date('d M Y @ H:i', $data['created_at']);
    $data['author'] = array($data['author'], HomeBoardHelper::getBoard($data['author']));
    unset($data['ip']);
    unset($data['text_original']);
    $post = Blog_BlogPostsModel::GetPost($data['post_id']);
    EventModel::getInstance()->ClientBroadcast('post_' . $data['post_id'], 'add_post_comment', $data)->ClientBroadcast('post_last_comments', 'add_post_comment', array('post_id' => $post['id'], 'id' => $data['id']))->ClientBroadcast('posts', 'add_post_comment', array('id' => $data['post_id'], 'count' => $post['comments']));
    Blog_BlogStatisticsModel::updateGlobalPosting();
})->AddEventListener('remove_comment', function ($data) {
    $post = Blog_BlogPostsModel::GetPost($data['post_id']);
    EventModel::getInstance()->ClientBroadcast('post_' . $data['post_id'], 'remove_post_comment', array('id' => $data['id']))->ClientBroadcast('post_last_comments', 'remove_post_comment', array('id' => $data['id']))->ClientBroadcast('posts', 'remove_post_comment', array('id' => $data['post_id'], 'count' => $post['comments']));
})->AddEventListener('*_comment', function ($data) {
    if (array_key_exists('post_id', $data)) {
        $cache = KVS::getInstance();
        $cache->remove('Blog_BlogCommentsModel', $data['post_id'], 'comments');
    }
});
Example #4
0
							<span>
								<a href="http://<?php 
        echo TemplateHelper::getSiteUrl();
        ?>
/news/res/<?php 
        echo $post['id'];
        ?>
/" class="g-disabled">
									№<?php 
        echo $post['id'];
        ?>
</a>
							</span>
							<?php 
        if ($post['author'] != 'anonymous') {
            $author = HomeBoardHelper::getBoard($post['author']);
            ?>
							<span>|</span>
							<a href="http://<?php 
            echo $post['author'];
            ?>
/" class="b-comment_b-homeboard" title="Аноним выбрал принадлежность «<?php 
            echo $author[1];
            ?>
»">
								<img src="http://<?php 
            echo TemplateHelper::getSiteUrl();
            ?>
/ico/homeboards/<?php 
            echo $author[0];
            ?>
Example #5
0
 /**
  * Получение коммента:
  */
 public function getPostCommentAjaxAction()
 {
     $cache = KVS::getInstance();
     $comment = Blog_BlogCommentsModel::GetComment($_GET['id']);
     $session = Session::getInstance();
     $session->activeSet('last_visit_post_' . $comment['post_id'], time());
     if ($comment) {
         if ($_GET['title']) {
             $post = Blog_BlogPostsModel::GetPost($comment['post_id']);
             $comment['post_title'] = $post['title'];
         }
         $comment['created_at'] = TemplateHelper::date('d M Y @ H:i', $comment['created_at']);
         $comment['author'] = array($comment['author'], HomeBoardHelper::getBoard($comment['author']));
         unset($comment['ip']);
         return $comment;
     }
     return false;
 }
Example #6
0
 /**
  * Получение поста(ов) (ajax):
  */
 public function getAjaxAction(Application $application)
 {
     $board = new Board_BoardModel($_GET['board']);
     $settings = $board->getSettings();
     if (array_key_exists('id', $_GET)) {
         if (is_array($_GET['id'])) {
             $result = array();
             foreach ($_GET['id'] as $id) {
                 if ($post = $board->getPost($id)) {
                     $post['created_at'] = TemplateHelper::date($_GET['board'] != 'int' ? 'd M Y @ H:i' : 'Y-m-d @ H:i', $post['created_at']);
                     $post['board_title'] = $settings['title'];
                     $post['author'] = array($post['author'] ? $post['author'] : 'anonymous', HomeBoardHelper::getBoard($post['author']));
                     unset($post['ip']);
                     $result[] = $post;
                 }
             }
             return $result;
         } else {
             if ($post = $board->getPost($_GET['id'])) {
                 $post['created_at'] = TemplateHelper::date($_GET['board'] != 'int' ? 'd M Y @ H:i' : 'Y-m-d @ H:i', $post['created_at']);
                 $post['board_title'] = $settings['title'];
                 $post['author'] = array($post['author'] ? $post['author'] : 'anonymous', HomeBoardHelper::getBoard($post['author']));
                 unset($post['ip']);
                 return $post;
             }
             return false;
         }
     }
     if (array_key_exists('thread_id', $_GET)) {
         if ($thread = $board->getThread($_GET['thread_id'], true)) {
             $result = array();
             foreach ($thread['posts'] as $id => $post) {
                 $post['created_at'] = TemplateHelper::date($_GET['board'] != 'int' ? 'd M Y @ H:i' : 'Y-m-d @ H:i', $post['created_at']);
                 $post['board_title'] = $settings['title'];
                 $post['author'] = array($post['author'] ? $post['author'] : 'anonymous', HomeBoardHelper::getBoard($post['author']));
                 unset($post['ip']);
                 $result[] = $post;
             }
             return $result;
         }
     }
     return false;
 }