예제 #1
0
 public static function Instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #2
0
 public static function instance()
 {
     if (self::$instance == null) {
         self::$instance = new M_Comments();
     }
     return self::$instance;
 }
예제 #3
0
 public static function Instance()
 {
     // гарантия одного экземпляра
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #4
0
 protected function action_article()
 {
     $mArticles = M_Article::Instance();
     $this->Only = $mArticles->Only($_GET['id']);
     //print_r($this->Only);
     $this->title_h1 .= '::Выбор одной статьи';
     $m_comments = M_Comments::Instance();
     $this->All_comments = $m_comments->All_comments($_GET['id']);
     if ($_POST) {
         $this->Add_comments = $m_comments->Add_comments($this->Only['id'], $_POST['login'], $_POST['text'], $_POST['created_date']);
     } else {
         $this->Add_comments = '';
     }
     $this->content = $this->Template('v/v_article.php', array('article' => $this->Only, 'comments' => $this->All_comments, 'Add_comments' => $this->Add_comments));
     //print_r($this->All_coments);
     //$this->comments = $this->Template('v/v_comments.php', array('comments' => $this->All_comments));
 }
예제 #5
0
파일: M_Posts.php 프로젝트: Ivan-up/devblog
 public function delete($post_id)
 {
     if ($post_id <= 0) {
         return false;
     }
     $mComments = new M_Comments();
     $sql = "SELECT mlid FROM posts WHERE post_id =" . (int) $post_id;
     $result = $this->db->Select($sql);
     $mlid = isset($result[0]['mlid']) ? $result[0]['mlid'] : 0;
     if ($mComments->deleteEntriesSubject($post_id) !== false && parent::delete($post_id) > 0) {
         unset($mComments);
         if ($mlid > 0) {
             M_MenuLink::Instance()->delete($mlid);
         }
         $path = $this->ckupload_dir . 'post_' . $post_id;
         if (is_dir($path)) {
             $this->removeDirectory($path);
         }
         return true;
     }
     return false;
 }
예제 #6
0
파일: C_Page.php 프로젝트: Ivan-up/devblog
 public function action_archive()
 {
     // Получение номера страницы
     $page_num = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     if ($page_num < 1) {
         $page_num = 1;
     }
     $time = isset($_GET['date']) ? strtotime($_GET['date']) : false;
     if ($time == false) {
         $this->p404();
     }
     $date = date("Y-m-d", $time);
     $this->active = date("Y-m", $time);
     $this->title = 'Архив за ' . date("Y-m", $time);
     $this->breadCrambsActive = $this->title;
     $this->pageUrl = rtrim(M_Link::ToPage('archive'), '/');
     // Создание объекта постраничной навигации(обязательные параметры)
     $mPagination = new M_Pagination('posts', M_Link::ToPage('archive', $this->active));
     // Задание свойств объекта
     $this->pages = $mPagination->on_page(5)->page_num($page_num)->fields("post_id, post_title, post_content, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpost_date_create, views, comment_status, user_name")->left_join('users ON post_author = user_id')->where("post_status = 'publish' AND post_type = 'post' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(post_date_create BETWEEN '{$date}' AND \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDATE_ADD(LAST_DAY('{$date}'), INTERVAL 1 DAY))")->order_by('post_date_create DESC')->page();
     foreach ($this->pages as $key => $value) {
         $postion = mb_strpos($value['post_content'], '<!--anonsbreak-->');
         if ($postion !== false) {
             $this->pages[$key]['anons'] = mb_substr($value['post_content'], 0, $postion - 1);
         }
     }
     // Получение пути к шаблону
     $templateName = $this->getTemplate('v_navbar.php');
     // Получение hmlt-кода панели навигации
     $this->navBar = $this->Template($templateName, $mPagination);
     //
     $this->navParams = $mPagination->navparams();
     $mComments = M_Comments::Instance();
     $this->countComments = $mComments->countItemsByAllSubjects();
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/page/v_index.php');
     // Формирование контента страницы
     //$this->content = $this->Template($templateName, $this);
     $this->blocks['_content_page'] = $this->Template($templateName, $this);
 }
예제 #7
0
 public function action_edit()
 {
     $mArticles = M_Articles::Instance();
     $mComments = M_Comments::Instance();
     $mUsers = M_Users::Instance();
     $User = $mUsers->Get();
     if (!$mUsers->Can('EDIT_ARTICLES')) {
         $this->redirect('/editor/editor');
     }
     $this->title .= ':: Редактирование';
     $this->id = isset($this->params[0]) ? (int) $this->params[0] : 1;
     $record = $mArticles->Get($this->id);
     $article = $record[0];
     if (isset($article)) {
         $this->art_title = $article['title'];
         $this->art_text = $article['content'];
         $this->error = false;
     } else {
         $this->redirect('/editor/editor/');
     }
     // Обработка отправки формы - Удаление статьи
     if (!empty($_POST) && $_POST['delete_'] == 'on') {
         $this->msql = M_MSQL::Instance();
         $table1 = 'articles';
         $table2 = 'comments';
         $where = '`id_article` = ' . $this->id;
         if ($this->msql->delete($table1, $where) || $this->msql->delete($table2, $where)) {
             $this->redirect('/editor/editor/');
         }
     }
     // Изменение статьи
     if (!empty($_POST) && $_POST['delete_'] != 'on') {
         // Данные изменены, редирект
         if ($mArticles->is_real_article($_POST['title'], $_POST['content'])) {
             if ($mArticles->articles_edit($this->id, $_POST['title'], $_POST['content'])) {
                 $this->redirect('/editor/editor/');
             }
         } else {
             $this->art_title = $_POST['title'];
             $this->art_text = $_POST['content'];
             $error = true;
             $this->message = 'В заголовке должно присутствовать хотябы одно слово, в тексте - несколько предложений!';
         }
     }
     //Вывод
     $vars = array('layout' => 'regular', 'username' => $User["name"]);
     $this->menu = $this->Template('./v/elements/menu.php', $vars);
     $this->left_block = $mComments->latest_comments();
     $vars = array('left_block' => $this->left_block);
     $this->left_block = $this->Template('./v/elements/new_comments.php', $vars);
     $vars = array('art_title' => $this->art_title, 'art_text' => $this->art_text, 'menu' => $this->menu, 'error' => $this->error, 'left_block' => $this->left_block, 'message' => $this->message);
     $this->content = $this->Template('./v/v_edit.php', $vars);
 }
예제 #8
0
파일: C_Page.php 프로젝트: alpo008/Hello_JS
 public function action_delcom()
 {
     $mUsers = M_Users::Instance();
     $mComments = M_Comments::Instance();
     $User = $mUsers->Get();
     $this->id_comm = isset($this->params[0]) ? (int) $this->params[0] : 1;
     // Удаление комментария
     $page_redir = $mComments->comment_delete($this->id_comm);
     if ($page_redir != 0) {
         $this->redirect("/page/show/{$page_redir}");
     } else {
         $this->redirect('/');
     }
 }
예제 #9
0
파일: C_Base.php 프로젝트: Ivan-up/devblog
 public function getLastestComments()
 {
     $comments = M_Comments::Instance()->getLastestComments(5);
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/page/v_posts_lastest_comments.php');
     $_comments = $this->Template($templateName, array('comments' => $comments));
     return $_comments;
 }
예제 #10
0
 public function get_for_post($post_id)
 {
     $mComments = M_Comments::Instance();
     $mComments->setIdSubject($post_id);
     $this->isLogged = (bool) $this->user;
     if ($this->isPost() && isset($_POST["comment_btn"])) {
         $comment_id = isset($_POST['comment_id']) ? (int) $_POST['comment_id'] : 0;
         if ($this->user) {
             $_POST['comment_author_id'] = $this->user['user_id'];
             $_POST['comment_author'] = $this->user['user_name'];
             $_POST['comment_author_email'] = $this->user['login'];
         } else {
             $_POST['comment_author_id'] = 0;
         }
         $new_comment_id = $mComments->add($_POST, $comment_id);
         if (!empty($new_comment_id)) {
             $url = M_Link::ToPage('post', $post_id) . '#commentItem' . $new_comment_id;
             $this->redirect($url);
         }
         $this->messages = $mComments->errors();
         $this->fields = $_POST;
     } else {
         $this->fields = array_fill_keys(array('comment_author', 'comment_author_email', 'comment_content'), '');
     }
     // Получаем переменные для шаблона
     $this->comments = $mComments->getTree();
     $this->post_id = $post_id;
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/page/v_comments.php');
     // Формирование контента страницы
     $treeComment = $this->blocks['_content_page'] = $this->Template($templateName, $this);
     return $treeComment;
 }