Example #1
0
 function BlogSearch($args)
 {
     global $addonPathData;
     $this->Init();
     $search_obj = $args[0];
     $label = common::GetLabelIndex('special_blog');
     $full_path = $addonPathData . '/index.php';
     // config of installed addon to get to know how many post files are
     if (!file_exists($full_path)) {
         return;
     }
     require $full_path;
     $fileIndexMax = floor($blogData['post_index'] / 20);
     // '20' I found in SimpleBlogCommon.php function GetPostFile (line 62)
     for ($fileIndex = 0; $fileIndex <= $fileIndexMax; $fileIndex++) {
         $postFile = $addonPathData . '/posts_' . $fileIndex . '.php';
         if (!file_exists($postFile)) {
             continue;
         }
         require $postFile;
         foreach ($posts as $id => $post) {
             $title = $label . ': ' . str_replace('_', ' ', $post['title']);
             $content = str_replace('_', ' ', $post['title']) . ' ' . $post['content'];
             SimpleBlogCommon::UrlQuery($id, $url, $query);
             $search_obj->FindString($content, $title, $url, $query);
         }
         $posts = array();
     }
 }
Example #2
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 #3
0
 /**
  * Run commands
  *
  */
 public function PostCommands()
 {
     global $page;
     $cmd = common::GetCommand();
     if (empty($cmd)) {
         //redirect to correct url if needed
         SimpleBlogCommon::UrlQuery($this->post_id, $expected_url, $query);
         $expected_url = str_replace('&amp;', '&', $expected_url);
         //because of htmlspecialchars($cattitle)
         if ($page->requested != $expected_url) {
             $expected_url = common::GetUrl($expected_url, $query, false);
             common::Redirect($expected_url);
         }
         return;
     }
     switch ($cmd) {
         case 'Add Comment':
             $this->AddComment();
             break;
     }
 }
Example #4
0
 /**
  * Get the edit links for the post
  *
  * @param string $class
  * @param string $id
  */
 public static function EditLinks($post_index, &$class, &$id)
 {
     global $langmessage;
     $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"');
     $class = ' editable_area';
     $id = 'id="ExtraEditArea' . $edit_index . '"';
     echo '<span style="display:none;" id="ExtraEditLnks' . $edit_index . '">';
     echo $edit_link;
     echo common::Link('Admin_Blog/' . $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::AStrGet('comments_closed', $post_index);
         if ($comments_closed) {
             $label = gpOutput::SelectText('Open Comments');
             echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=opencomments', 'name="cnreq" style="display:none"');
         } else {
             $label = gpOutput::SelectText('Close Comments');
             echo SimpleBlogCommon::PostLink($post_index, $label, 'cmd=closecomments', 'name="cnreq" style="display:none"');
         }
     }
     echo common::Link('Admin_Blog', 'New Blog Post', 'cmd=new_form', ' style="display:none"');
     echo common::Link('Admin_Blog', $langmessage['administration'], '', ' style="display:none"');
     echo '</span>';
 }
Example #5
0
 /**
  * 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>';
 }
 static function PostUrl($post = false, $query = '')
 {
     SimpleBlogCommon::UrlQuery($post, $url, $query);
     return common::GetUrl($url, $query);
 }