Example #1
0
 /**
  * Abbreviate $content if a $limit greater than zero is given
  *
  */
 function AbbrevContent($content, $post_index, $limit = 0)
 {
     if (!is_numeric($limit) || $limit == 0) {
         return $content;
     }
     $content = strip_tags($content);
     if (SimpleBlogCommon::strlen($content) < $limit) {
         return $content;
     }
     $pos = SimpleBlogCommon::strpos($content, ' ', $limit - 5);
     if ($pos > 0 && $limit + 20 > $pos) {
         $limit = $pos;
     }
     $content = SimpleBlogCommon::substr($content, 0, $limit) . ' ... ';
     $label = gpOutput::SelectText('Read More');
     return $content . SimpleBlogCommon::PostLink($post_index, $label);
 }
 /**
  * Regenerate the static content used to display the gadget
  *
  */
 function GenGadget()
 {
     global $langmessage;
     $posts = array();
     $show_posts = $this->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) {
         //get $posts
         if (!isset($posts[$post_index])) {
             $posts = $this->GetPostFile($post_index, $post_file);
         }
         if (!isset($posts[$post_index])) {
             continue;
         }
         $post =& $posts[$post_index];
         $header = '<b class="simple_blog_title">';
         $label = SimpleBlogCommon::Underscores($post['title']);
         $header .= SimpleBlogCommon::PostLink($post_index, $label);
         $header .= '</b>';
         $this->BlogHead($header, $post_index, $post, true);
         $content = strip_tags($post['content']);
         if (SimpleBlogCommon::$data['gadget_abbrev'] > 6 && SimpleBlogCommon::strlen($content) > SimpleBlogCommon::$data['gadget_abbrev']) {
             $cut = SimpleBlogCommon::$data['gadget_abbrev'];
             $pos = SimpleBlogCommon::strpos($content, ' ', $cut - 5);
             if ($pos > 0 && $cut + 20 > $pos) {
                 $cut = $pos;
             }
             $content = SimpleBlogCommon::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 = $this->addonPathData . '/gadget.php';
     gpFiles::Save($gadgetFile, $gadget);
 }