Example #1
0
 function __construct($args)
 {
     SimpleBlogCommon::Init();
     $search_obj = $args[0];
     $blog_label = common::GetLabelIndex('special_blog');
     $post_ids = SimpleBlogCommon::AStrToArray('str_index');
     foreach ($post_ids as $id) {
         $post = SimpleBlogCommon::GetPostContent($id);
         if (!$post) {
             continue;
         }
         $title = $blog_label . ': ' . str_replace('_', ' ', $post['title']);
         $content = str_replace('_', ' ', $post['title']) . ' ' . $post['content'];
         SimpleBlogCommon::UrlQuery($id, $url, $query);
         $search_obj->FindString($content, $title, $url, $query);
     }
 }
Example #2
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>';
 }
 /**
  * Regenerate the static content used to display the gadget
  *
  */
 static function GenGadget()
 {
     global $langmessage;
     $posts = array();
     $show_posts = SimpleBlogCommon::WhichPosts(0, SimpleBlogCommon::$data['gadget_entries']);
     ob_start();
     $label = gpOutput::SelectText('Blog');
     if (!empty($label)) {
         echo '<h3>';
         echo common::Link('Special_Blog', $label);
         echo '</h3>';
     }
     foreach ($show_posts as $post_index) {
         $post = SimpleBlogCommon::GetPostContent($post_index);
         if (!$post) {
             continue;
         }
         $header = '<b class="simple_blog_title">';
         $label = SimpleBlogCommon::Underscores($post['title']);
         $header .= SimpleBlogCommon::PostLink($post_index, $label);
         $header .= '</b>';
         SimpleBlogCommon::BlogHead($header, $post_index, $post, true);
         $content = strip_tags($post['content']);
         if (SimpleBlogCommon::$data['gadget_abbrev'] > 6 && mb_strlen($content) > SimpleBlogCommon::$data['gadget_abbrev']) {
             $cut = SimpleBlogCommon::$data['gadget_abbrev'];
             $pos = mb_strpos($content, ' ', $cut - 5);
             if ($pos > 0 && $cut + 20 > $pos) {
                 $cut = $pos;
             }
             $content = mb_substr($content, 0, $cut) . ' ... ';
             $label = gpOutput::SelectText('Read More');
             $content .= SimpleBlogCommon::PostLink($post_index, $label);
         }
         echo '<p class="simple_blog_abbrev">';
         echo $content;
         echo '</p>';
     }
     if (SimpleBlogCommon::$data['post_count'] > 3) {
         $label = gpOutput::SelectText('More Blog Entries');
         echo common::Link('Special_Blog', $label);
     }
     $gadget = ob_get_clean();
     $gadgetFile = SimpleBlogCommon::$data_dir . '/gadget.php';
     gpFiles::Save($gadgetFile, $gadget);
 }
Example #4
0
 public function __construct($post_id)
 {
     $this->post_id = $post_id;
     $this->post = SimpleBlogCommon::GetPostContent($this->post_id);
     $this->comments_closed = SimpleBlogCommon::AStrGet('comments_closed', $this->post_id);
 }
Example #5
0
 /**
  * Save an edited blog post
  * @return bool
  *
  */
 private function SaveEdit()
 {
     global $langmessage;
     //save to data file
     if (!self::SavePost($this->post_id, $this->post)) {
         message($langmessage['OOPS'] . ' (Post not saved)');
         return false;
     }
     $this->post = SimpleBlogCommon::GetPostContent($this->post_id);
     return true;
 }