function ShowCategories()
 {
     echo '<h2>';
     echo gpOutput::GetAddonText('Categories');
     echo '</h2>';
     //$gadgetFile = $this->addonPathData.'/gadget_categories.php';
     echo '<ul>';
     foreach ($this->categories as $catindex => $catname) {
         //skip hidden categories
         if (SimpleBlogCommon::AStrValue('categories_hidden', $catindex)) {
             continue;
         }
         $cat_posts_str =& SimpleBlogCommon::$data['category_posts_' . $catindex];
         $count = substr_count($cat_posts_str, '>');
         if (!$count) {
             continue;
         }
         echo '<li>';
         echo SimpleBlogCommon::CategoryLink($catindex, $catname, $catname . ' (' . $count . ')');
         echo '</li>';
     }
     echo '</ul>';
 }
Ejemplo n.º 2
0
 /**
  * Ouptut blog categories
  *
  */
 public function Categories()
 {
     //blog categories
     if (empty($this->post['categories'])) {
         return;
     }
     $temp = array();
     foreach ($this->post['categories'] as $catindex) {
         $title = SimpleBlogCommon::AStrGet('categories', $catindex);
         if (!$title) {
             continue;
         }
         if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
             continue;
         }
         $temp[] = SimpleBlogCommon::CategoryLink($catindex, $title, $title);
     }
     if (count($temp)) {
         echo '<div class="category_container">';
         echo '<b>';
         echo gpOutput::GetAddonText('Categories');
         echo ':</b> ';
         echo implode(', ', $temp);
         echo '</div>';
     }
 }
Ejemplo n.º 3
0
 /**
  * Display the html for a single blog post
  *
  */
 public function ShowPostContent($post_index)
 {
     if (!common::LoggedIn() && SimpleBlogCommon::AStrGet('drafts', $post_index)) {
         return false;
     }
     $post = SimpleBlogCommon::GetPostContent($post_index);
     $class = $id = '';
     if (common::LoggedIn()) {
         SimpleBlog::EditLinks($post_index, $class, $id);
     }
     echo '<div class="blog_post post_list_item' . $class . '" ' . $id . '>';
     $header = '<h2 id="blog_post_' . $post_index . '">';
     if (SimpleBlogCommon::AStrGet('drafts', $post_index)) {
         $header .= '<span style="opacity:0.3;">';
         $header .= gpOutput::SelectText('Draft');
         $header .= '</span> ';
     } elseif ($post['time'] > time()) {
         $header .= '<span style="opacity:0.3;">';
         $header .= gpOutput::SelectText('Pending');
         $header .= '</span> ';
     }
     $label = SimpleBlogCommon::Underscores($post['title']);
     $header .= SimpleBlogCommon::PostLink($post_index, $label);
     $header .= '</h2>';
     SimpleBlogCommon::BlogHead($header, $post_index, $post);
     echo '<div class="twysiwygr">';
     if (!empty(SimpleBlogCommon::$data['post_abbrev']) && SimpleBlogCommon::$data['abbrev_image']) {
         $this->GetImageFromPost($post['content']);
     }
     echo $this->AbbrevContent($post['content'], $post_index, SimpleBlogCommon::$data['post_abbrev']);
     echo '</div>';
     echo '</div>';
     if (SimpleBlogCommon::$data['abbrev_cat'] && isset($post['categories']) && count($post['categories'])) {
         $temp = array();
         foreach ($post['categories'] as $catindex) {
             $title = SimpleBlogCommon::AStrGet('categories', $catindex);
             if (!$title) {
                 continue;
             }
             if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
                 continue;
             }
             $temp[] = SimpleBlogCommon::CategoryLink($catindex, $title, $title);
         }
         if (count($temp)) {
             echo '<div class="category_container">';
             echo gpOutput::GetAddonText('Categories') . ' ';
             echo implode(', ', $temp);
             echo '</div>';
         }
     }
     echo '<div class="clear"></div>';
 }
Ejemplo n.º 4
0
 /**
  * Output the html for a single blog post
  * Handle comment actions
  */
 function ShowPost($cmd)
 {
     global $langmessage, $page;
     $post = $this->GetPostContent($this->post_id);
     if ($post === false) {
         message($langmessage['OOPS']);
         return;
     }
     $commentSaved = false;
     switch ($cmd) {
         //redirect to correct url if needed
         case 'post':
             SimpleBlogCommon::UrlQuery($this->post_id, $expected_url, $query);
             $expected_url = str_replace('&amp;', '&', $expected_url);
             //because of htmlspecialchars($cattitle)
             if ($page->requested != $expected_url) {
                 $expected_url = common::GetUrl($expected_url, $query, false);
                 common::Redirect($expected_url, 301);
             }
             break;
             //close comments
         //close comments
         case 'closecomments':
             $this->CloseComments($this->post_id);
             break;
         case 'opencomments':
             $this->OpenComments($this->post_id);
             break;
             //commments
         //commments
         case 'Add Comment':
             if ($this->AddComment($this->post_id)) {
                 $commentSaved = true;
             } else {
                 echo '<div class="comment_container">';
                 $this->CommentForm($this->post_id, true);
                 echo '</div>';
                 return;
             }
             break;
         case 'delete_comment':
             $this->DeleteComment($this->post_id);
             break;
     }
     $post = $this->GetPostContent($this->post_id);
     if (!common::LoggedIn() && SimpleBlogCommon::AStrValue('drafts', $this->post_id)) {
         //How to make 404 page?
         message($langmessage['OOPS']);
         return;
     }
     $this->ShowPostContent($post, $this->post_id);
     $page->label = SimpleBlogCommon::Underscores($post['title']);
     //blog categories
     if (isset($post['categories']) && count($post['categories'])) {
         $temp = array();
         foreach ($post['categories'] as $catindex) {
             $title = SimpleBlogCommon::AStrValue('categories', $catindex);
             if (!$title) {
                 continue;
             }
             if (SimpleBlogCommon::AStrValue('categories_hidden', $catindex)) {
                 continue;
             }
             $temp[] = SimpleBlogCommon::CategoryLink($catindex, $title, $title);
         }
         if (count($temp)) {
             echo '<div class="category_container">';
             echo '<b>';
             echo gpOutput::GetAddonText('Categories');
             echo ':</b> ';
             echo implode(', ', $temp);
             echo '</div>';
         }
     }
     SimpleBlog::PostLinks($this->post_id);
     //comments
     if (SimpleBlogCommon::$data['allow_comments']) {
         echo '<div class="comment_container">';
         $this->ShowComments($this->post_id);
         if (!$commentSaved) {
             $this->CommentForm($this->post_id);
         }
         echo '</div>';
     }
 }