Example #1
0
 function OutputComment($comment)
 {
     global $langmessage;
     echo '<tr><td class="user_submitted">';
     echo '<b>' . $comment['name'] . '</b>';
     echo '<p>';
     echo $comment['comment'];
     echo '</p>';
     echo '</td><td>';
     //echo strftime(SimpleBlogCommon::$data['strftime_format'],$comment['time']);
     echo strftime("%Y-%m-%d %H:%M:%S", $comment['time']);
     echo '<br/>';
     if (SimpleBlogCommon::$data['commenter_website'] == 'nofollow' && !empty($comment['website'])) {
         echo '<a href="' . $comment['website'] . '" rel="nofollow">' . $comment['website'] . '</a>';
     } elseif (SimpleBlogCommon::$data['commenter_website'] == 'link' && !empty($comment['website'])) {
         echo '<a href="' . $comment['website'] . '">' . $comment['website'] . '</a>';
     }
     echo '</td><td>';
     echo SimpleBlogCommon::PostLink($comment['post_id'], 'View&nbsp;Post');
     echo ' &nbsp; ';
     echo common::Link('Admin_BlogComments', $langmessage['delete'], 'cmd=delete_comment&id=' . $comment['post_id'] . '&comment_time=' . $comment['time'], array('name' => 'postlink', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm']));
     echo '</td></tr>';
 }
Example #2
0
 /**
  * Abbreviate $content if a $limit greater than zero is given
  *
  */
 public function AbbrevContent($content, $post_index, $limit = 0)
 {
     if (!is_numeric($limit) || $limit == 0) {
         return $content;
     }
     $content = strip_tags($content);
     if (mb_strlen($content) < $limit) {
         return $content;
     }
     $pos = mb_strpos($content, ' ', $limit - 5);
     if ($pos > 0 && $limit + 20 > $pos) {
         $limit = $pos;
     }
     $content = mb_substr($content, 0, $limit) . ' ... ';
     $label = gpOutput::SelectText('Read More');
     return $content . SimpleBlogCommon::PostLink($post_index, $label);
 }
 /**
  * Regenerate the static content used to display the archive gadget
  *
  */
 static function GenArchiveGadget()
 {
     global $addonPathData;
     //get list of posts and times
     $list = SimpleBlogCommon::AStrToArray('post_times');
     if (!count($list)) {
         return;
     }
     //get year counts
     $archive = array();
     foreach ($list as $post_id => $time) {
         $ym = date('Y-m', $time);
         //year&month
         $archive[$ym][] = $post_id;
     }
     ob_start();
     $prev_year = false;
     echo '<ul>';
     foreach ($archive as $ym => $posts) {
         $y = substr($ym, 0, 4);
         $m = substr($ym, -2);
         if ($y != $prev_year) {
             if ($prev_year !== false) {
                 echo '</li>';
             }
             echo '<li><div class="simple_blog_gadget_year">' . $y . '</div>';
             $prev_year = $y;
         }
         $sum = count($posts);
         if (!$sum) {
             continue;
         }
         echo '<ul>';
         echo '<li><a class="blog_gadget_link">';
         $time = strtotime($ym . '-01');
         echo strftime('%B', $time);
         echo ' (' . $sum . ')</a>';
         echo '<ul class="simple_blog_category_posts nodisplay">';
         foreach ($posts as $post_id) {
             $post_title = SimpleBlogCommon::AStrGet('titles', $post_id);
             echo '<li>';
             echo SimpleBlogCommon::PostLink($post_id, $post_title);
             echo '</li>';
         }
         echo '</ul>';
         echo '</li>';
         echo '</ul>';
     }
     echo '</li></ul>';
     $content = ob_get_clean();
     $gadgetFile = $addonPathData . '/gadget_archive.php';
     gpFiles::Save($gadgetFile, $content);
 }
Example #4
0
 /**
  * Display the links at the bottom of a post
  *
  */
 public function PostLinks()
 {
     $post_key = SimpleBlogCommon::AStrKey('str_index', $this->post_id);
     echo '<p class="blog_nav_links">';
     //blog home
     $html = common::Link('Special_Blog', '%s', '', 'class="blog_home"');
     echo gpOutput::GetAddonText('Blog Home', $html);
     echo '&nbsp;';
     // check for newer posts and if post is draft
     $isDraft = false;
     if ($post_key > 0) {
         $i = 0;
         do {
             $i++;
             $next_index = SimpleBlogCommon::AStrGet('str_index', $post_key - $i);
             if (!common::loggedIn()) {
                 $isDraft = SimpleBlogCommon::AStrGet('drafts', $next_index);
             }
         } while ($isDraft);
         if (!$isDraft) {
             $html = SimpleBlogCommon::PostLink($next_index, '%s', '', 'class="blog_newer"');
             echo gpOutput::GetAddonText('Newer Entry', $html);
             echo '&nbsp;';
         }
     }
     //check for older posts and if older post is draft
     $i = 0;
     $isDraft = false;
     do {
         $i++;
         $prev_index = SimpleBlogCommon::AStrGet('str_index', $post_key + $i);
         if ($prev_index === false) {
             break;
         }
         if (!common::loggedIn()) {
             $isDraft = SimpleBlogCommon::AStrGet('drafts', $prev_index);
         }
         if (!$isDraft) {
             $html = SimpleBlogCommon::PostLink($prev_index, '%s', '', 'class="blog_older"');
             echo gpOutput::GetAddonText('Older Entry', $html);
         }
     } while ($isDraft);
     if (common::LoggedIn()) {
         echo '&nbsp;';
         echo common::Link('Admin_Blog', 'New Post', 'cmd=new_form', 'class="blog_post_new"');
     }
     echo '</p>';
 }
Example #5
0
 /**
  * Output the html for a blog post's comments
  *
  */
 function GetCommentHtml($data, $post_index)
 {
     global $langmessage;
     if (!is_array($data)) {
         continue;
     }
     foreach ($data as $key => $comment) {
         echo '<div class="comment_area">';
         echo '<p class="name">';
         if (SimpleBlogCommon::$data['commenter_website'] == 'nofollow' && !empty($comment['website'])) {
             echo '<b><a href="' . $comment['website'] . '" rel="nofollow">' . $comment['name'] . '</a></b>';
         } elseif (SimpleBlogCommon::$data['commenter_website'] == 'link' && !empty($comment['website'])) {
             echo '<b><a href="' . $comment['website'] . '">' . $comment['name'] . '</a></b>';
         } else {
             echo '<b>' . $comment['name'] . '</b>';
         }
         echo ' &nbsp; ';
         echo '<span>';
         echo strftime(SimpleBlogCommon::$data['strftime_format'], $comment['time']);
         echo '</span>';
         if (common::LoggedIn()) {
             echo ' &nbsp; ';
             $attr = 'class="delete gpconfirm" title="' . $langmessage['delete_confirm'] . '" name="postlink" data-nonce= "' . common::new_nonce('post', true) . '"';
             echo SimpleBlogCommon::PostLink($post_index, $langmessage['delete'], 'cmd=delete_comment&comment_index=' . $key, $attr);
         }
         echo '</p>';
         echo '<p class="comment">';
         echo $comment['comment'];
         echo '</p>';
         echo '</div>';
     }
 }
Example #6
0
 /**
  * Display form for submitting posts (new and edit)
  *
  * @param string $label
  * @param array $array
  * @param string $cmd
  * @param int|string $post_id
  */
 private function PostForm($label, &$array, $cmd = 'save_new', $post_id = null)
 {
     global $langmessage;
     includeFile('tool/editing.php');
     $array += array('title' => '', 'content' => '', 'subtitle' => '', 'isDraft' => false, 'categories' => array(), 'time' => time());
     if ($post_id) {
         $array += array('isDraft' => SimpleBlogCommon::AStrGet('drafts', $post_id));
     }
     $array['title'] = SimpleBlogCommon::Underscores($array['title']);
     $action = common::GetUrl('Admin_Blog');
     if ($post_id) {
         $action = common::GetUrl('Admin_Blog/' . $post_id);
     }
     echo '<form class="post_form" action="' . $action . '" method="post">';
     //save
     echo '<div style="float:right">';
     echo '<input type="hidden" name="cmd" value="' . $cmd . '" />';
     echo '<input class="gpsubmit" type="submit" name="" value="' . $langmessage['save'] . '" /> ';
     echo common::Link('Admin_Blog', $langmessage['cancel'], '', ' class="gpcancel"');
     if ($post_id) {
         echo SimpleBlogCommon::PostLink($post_id, 'View Post', '', 'target="_blank"');
     }
     echo '</div>';
     //heading
     echo '<h2 class="hmargin">' . $label . '</h2>';
     echo '<div class="sb_post_container cf">';
     echo '<div class="sb_post_container_right">';
     //title + sub-title
     echo '<div class="sb_edit_box">';
     echo '<div class="sb_edit_group">';
     echo '<label>Title</label>';
     echo '<input type="text" name="title" value="' . $array['title'] . '" required class="gpinput" />';
     echo '</div>';
     echo '<div class="sb_edit_group">';
     echo '<label>Sub-Title</label>';
     echo '<input type="text" name="subtitle" value="' . $array['subtitle'] . '" class="gpinput" />';
     echo '</div>';
     echo '</div>';
     //.sb_edit_box
     //draft + date
     echo '<div class="sb_edit_box">';
     echo '<div class="sb_edit_group">';
     echo '<label>';
     echo '<input type="checkbox" name="isDraft" value="on" data-cmd="DraftCheckbox" ';
     if ($array['isDraft']) {
         echo 'checked="true"';
     }
     echo '" /> Draft</label>';
     echo '</div>';
     $this->FieldPublish($array);
     echo '</div>';
     //categories
     echo '<div class="sb_edit_box">';
     echo '<div class="sb_edit_group">';
     self::ShowCategoryList($post_id, $array);
     echo '</div>';
     echo '</div>';
     echo '</div>';
     //.sb_container_right
     //content
     echo '<div class="sb_post_container_left">';
     gp_edit::UseCK($array['content'], 'content');
     echo '</div>';
     echo '</div>';
     //save
     echo '<div>';
     echo '</div>';
     echo '</form>';
 }