/**
  * 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 #2
0
 /**
  * Display a blog page with multiple blog posts
  *
  */
 public function ShowPage()
 {
     global $page;
     $per_page = SimpleBlogCommon::$data['per_page'];
     $page_num = 0;
     $expected_q = '';
     if (isset($_GET['page']) && is_numeric($_GET['page'])) {
         $page_num = (int) $_GET['page'];
         $expected_q = 'page=' . $page_num;
     }
     //redirect if the request isn't correct
     if ($page->requested != SimpleBlogCommon::$root_url) {
         $expected_url = common::GetUrl(SimpleBlogCommon::$root_url, $expected_q, false);
         common::Redirect($expected_url);
     }
     $start = $page_num * $per_page;
     $include_drafts = common::LoggedIn();
     $show_posts = SimpleBlogCommon::WhichPosts($start, $per_page, $include_drafts);
     $this->ShowPosts($show_posts);
     //pagination links
     echo '<p class="blog_nav_links">';
     if ($page_num > 0) {
         $html = common::Link('Special_Blog', '%s');
         echo gpOutput::GetAddonText('Blog Home', $html);
         echo '&nbsp;';
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page_num - 1), 'class="blog_newer"');
         echo gpOutput::GetAddonText('Newer Entries', $html);
         echo '&nbsp;';
     }
     if (($page_num + 1) * $per_page < SimpleBlogCommon::$data['post_count']) {
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page_num + 1), 'class="blog_older"');
         echo gpOutput::GetAddonText('Older Entries', $html);
     }
     echo '</p>';
 }
Example #3
0
 /**
  * Display a blog page with multiple blog posts
  *
  */
 function ShowPage()
 {
     $per_page = SimpleBlogCommon::$data['per_page'];
     $page = 0;
     if (isset($_GET['page']) && is_numeric($_GET['page'])) {
         $page = (int) $_GET['page'];
     }
     $start = $page * $per_page;
     $include_drafts = common::LoggedIn();
     $show_posts = SimpleBlogCommon::WhichPosts($start, $per_page, $include_drafts);
     $this->ShowPosts($show_posts);
     //pagination links
     echo '<p class="blog_nav_links">';
     if ($page > 0) {
         $html = common::Link('Special_Blog', '%s');
         echo gpOutput::GetAddonText('Blog Home', $html);
         echo '&nbsp;';
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page - 1), 'class="blog_newer"');
         echo gpOutput::GetAddonText('Newer Entries', $html);
         echo '&nbsp;';
     }
     if (($page + 1) * $per_page < SimpleBlogCommon::$data['post_count']) {
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page + 1), 'class="blog_older"');
         echo gpOutput::GetAddonText('Older Entries', $html);
     }
     if (common::LoggedIn()) {
         echo '&nbsp;';
         echo common::Link('Special_Blog', 'New Post', 'cmd=new_form');
     }
     echo '</p>';
 }