예제 #1
0
 public function getAll($ID_post, $status = null)
 {
     $C = new comment();
     $rows = array();
     if (is_null($status) === true) {
         $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post}");
     } else {
         if (is_array($status)) {
             $status_sql = "";
             foreach ($status as $st) {
                 $status_sql .= "status = '{$st}' OR ";
             }
             $status_sql = substr($status_sql, 0, -4);
             $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND ({$status_sql})");
         } else {
             $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND status='{$status}'");
         }
     }
     foreach ($rows as $key => $comment) {
         $comment['content'] = utils::htmlentities($comment['content']);
         $comment['content'] = utils::nl2br($comment['content']);
         $rows[$key] = $comment;
     }
     return $rows;
 }
예제 #2
0
 public function index($id = NULL)
 {
     $this->view->setLayout("admin");
     $this->view->conf = $this->conf;
     $this->title_for_layout($this->l10n->__("Comentarios - Codice CMS"));
     $comment = new comment();
     $total_rows = $comment->countCommentsByPost();
     $page = $id;
     $page = is_null($page) ? 1 : $page;
     $limit = $this->userConf['posts_per_page'];
     $offset = ($page - 1) * $limit;
     $limitQuery = $offset . "," . $limit;
     $targetpage = $this->path . 'comments/';
     $pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
     $this->view->pagination = $pagination;
     $comments = $comment->findAll(NULL, "ID DESC", $limitQuery, NULL);
     foreach ($comments as $key => $value) {
         $Post = new post();
         $post = $Post->findBy('ID', $value['ID_post']);
         $value['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']);
         $value["content"] = utils::htmlentities($value["content"]);
         $value["content"] = utils::nl2br($value["content"]);
         $comments[$key] = $value;
     }
     $this->registry->comments = $comments;
     $this->plugin->call("comments_comment_content");
     $this->view->comments = $this->registry->comments;
     $this->render();
 }
예제 #3
0
 public function addMetaTags()
 {
     global $post, $wp, $properties;
     /*
      * og: inicial
      */
     $this->properties = array('og:type' => 'article', 'og:url' => home_url($wp->request), 'og:site_name' => get_bloginfo('name'), 'og:locale' => 'pt_BR');
     /*
      *
      * og:title
      * Título do "post" que ira aparecer no PopUP do facebook e na Timeline
      *
      */
     if (is_single()) {
         $this->properties['og:title'] = get_the_title();
     } elseif (is_category()) {
         $this->properties['og:title'] = single_cat_title('', false);
     } elseif (is_tag()) {
         $this->properties['og:title'] = single_tag_title('', false);
     } else {
         $this->properties['og:title'] = get_bloginfo('name');
     }
     /*
      *
      * og:image
      * Thumbnail do "post" que ira aparecer no PopUP do facebook e na Timeline
      *
      */
     if (is_single() && has_post_thumbnail($post->ID)) {
         $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
         if (!empty($image[0])) {
             $this->properties['og:image'] = $image[0];
         } else {
             $this->properties['og:image'] = get_stylesheet_directory_uri() . '/img/logo-facebook.png';
         }
     }
     /*
      *
      * og:description
      * Descrição do "post" se tiver em um ou do site
      *
      */
     if (is_single() && !empty(get_the_excerpt())) {
         $this->properties['og:description'] = get_the_excerpt();
     } else {
         $this->properties['og:description'] = get_bloginfo('description');
     }
     /*
      * Faz um loop de todos os ogs existentes e adiciona ao head do HTML
      */
     foreach ($this->properties as $og => $og_value) {
         if ($og === 'og:url' or $og === 'og:image') {
             echo "<meta name=\"{$og}\" content=\"{$og_value}\" />\n";
         } else {
             $og_value = utils::htmlentities($og_value);
             echo "<meta name=\"{$og}\" content=\"{$og_value}\" />\n";
         }
     }
 }