public function _ShowPost() { global $page; $page->label = SimpleBlogCommon::Underscores($this->post['title']); $class = $id = ''; if (common::LoggedIn()) { SimpleBlog::EditLinks($this->post_id, $class, $id); } echo '<div class="blog_post single_blog_item ' . $class . '" ' . $id . '>'; //heading $header = '<h2 id="blog_post_' . $this->post_id . '">'; if (SimpleBlogCommon::AStrGet('drafts', $this->post_id)) { $header .= '<span style="opacity:0.3;">'; $header .= gpOutput::SelectText('Draft'); $header .= '</span> '; } elseif ($this->post['time'] > time()) { $header .= '<span style="opacity:0.3;">'; $header .= gpOutput::SelectText('Pending'); $header .= '</span> '; } $header .= SimpleBlogCommon::PostLink($this->post_id, $page->label); $header .= '</h2>'; SimpleBlogCommon::BlogHead($header, $this->post_id, $this->post); //content echo '<div class="twysiwygr">'; echo $this->post['content']; echo '</div>'; echo '</div>'; echo '<br/>'; echo '<div class="clear"></div>'; $this->Categories(); $this->PostLinks(); $this->Comments(); }
/** * 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); }
/** * Display the html for a single blog post * */ function ShowPostContent(&$post, &$post_index, $limit = 0) { global $langmessage; if (!common::LoggedIn() && SimpleBlogCommon::AStrValue('drafts', $post_index)) { return false; //How to make 404 page? } //If user enter random Blog url, he didn't see any 404, but nothng. $id = $class = ''; if (common::LoggedIn()) { $query = 'du'; //dummy parameter SimpleBlogCommon::UrlQuery($post_index, $url, $query); $edit_link = gpOutput::EditAreaLink($edit_index, $url, $langmessage['edit'] . ' (TWYSIWYG)', $query, 'name="inline_edit_generic" rel="text_inline_edit"'); echo '<span style="display:none;" id="ExtraEditLnks' . $edit_index . '">'; echo $edit_link; echo SimpleBlogCommon::PostLink($post_index, $langmessage['edit'] . ' (All)', 'cmd=edit_post', ' style="display:none"'); echo common::Link('Special_Blog', $langmessage['delete'], 'cmd=deleteentry&del_id=' . $post_index, array('class' => 'delete gpconfirm', 'data-cmd' => 'cnreq', 'title' => $langmessage['delete_confirm'])); if (SimpleBlogCommon::$data['allow_comments']) { $comments_closed = SimpleBlogCommon::AStrValue('comments_closed', $post_index); if ($comments_closed) { $label = gpOutput::SelectText('Open Comments'); echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=opencomments', 'name="creq" style="display:none"'); } else { $label = gpOutput::SelectText('Close Comments'); echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=closecomments', 'name="creq" style="display:none"'); } } echo common::Link('Special_Blog', 'New Blog Post', 'cmd=new_form', ' style="display:none"'); echo common::Link('Admin_Blog', $langmessage['configuration'], '', ' style="display:none"'); echo '</span>'; $class .= ' editable_area'; $id = 'id="ExtraEditArea' . $edit_index . '"'; } $isDraft = ''; if (SimpleBlogCommon::AStrValue('drafts', $post_index)) { $isDraft = '<span style="opacity:0.3;">'; $isDraft .= gpOutput::SelectText('Draft'); $isDraft .= '</span> '; } echo '<div class="blog_post' . $class . '" ' . $id . '>'; $header = '<h2 id="blog_post_' . $post_index . '">'; $header .= $isDraft; $label = SimpleBlogCommon::Underscores($post['title']); $header .= SimpleBlogCommon::PostLink($post_index, $label); $header .= '</h2>'; $this->BlogHead($header, $post_index, $post); echo '<div class="twysiwygr">'; echo $this->AbbrevContent($post['content'], $post_index, $limit); echo '</div>'; echo '</div>'; echo '<br/>'; echo '<div class="clear"></div>'; }
/** * 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>'; }