/**
  * 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 #2
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 #3
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>';
 }
 function ShowCategories()
 {
     echo '<h2>';
     echo gpOutput::GetAddonText('Categories');
     echo '</h2>';
     echo '<ul>';
     foreach ($this->categories as $catindex => $catname) {
         //skip hidden categories
         if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
             continue;
         }
         $cat_posts_str =& SimpleBlogCommon::$data['category_posts_' . $catindex];
         $count = substr_count($cat_posts_str, '>');
         if (!$count) {
             continue;
         }
         echo '<li>';
         echo SimpleBlogCommon::CategoryLink($catindex, $catname, $catname . ' (' . $count . ')');
         echo '</li>';
     }
     echo '</ul>';
 }
Example #5
0
 public static function UrlQuery($post_id = false, &$url, &$query)
 {
     $url = SimpleBlogCommon::$root_url;
     if ($post_id > 0) {
         switch (SimpleBlogCommon::$data['urls']) {
             case 'Full':
                 $title = SimpleBlogCommon::AStrGet('titles', $post_id);
                 $title = str_replace(array('?', ' '), array('', '_'), $title);
                 $url .= '/' . $post_id . '_' . $title;
                 break;
             case 'Tiny':
                 $url .= '/' . $post_id;
                 break;
             case 'Title':
                 $title = SimpleBlogCommon::AStrGet('titles', $post_id);
                 $title = str_replace(array('?', ' '), array('', '_'), $title);
                 $url .= '/' . $title;
                 break;
             default:
                 $query = trim($query . '&id=' . $post_id, '&');
                 break;
         }
     }
 }
Example #6
0
 /**
  * Show a list of all categories
  *
  */
 public static function ShowCategoryList($post_id, $post)
 {
     $_POST += array('category' => array());
     echo '<label>Category</label>';
     echo '<select name="category[]" multiple="multiple"  class="gpinput">';
     $categories = SimpleBlogCommon::AStrToArray('categories');
     foreach ($categories as $catindex => $catname) {
         $selected = '';
         $label = $catname;
         if ($post_id && in_array($catindex, $post['categories'])) {
             $selected = 'selected="selected"';
         } elseif (in_array($catindex, $_POST['category'])) {
             $selected = 'selected="selected"';
         }
         if (SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
             $label .= ' (Hidden)';
         }
         echo '<option value="' . $catindex . '" ' . $selected . '>' . $label . '</option>';
     }
     echo '</select>';
 }
Example #7
0
 function __construct()
 {
     global $langmessage, $addonRelativeCode, $addonFolderName, $page;
     parent::__construct();
     $this->categories = SimpleBlogCommon::AStrToArray('categories');
     $cmd = common::GetCommand();
     switch ($cmd) {
         //category commands
         case 'save_categories':
             $this->SaveCategories();
             break;
         case 'new_category':
             $this->NewCategory();
             return;
         case 'save_new_category':
             $this->SaveNewCategory();
             break;
         case 'delete_category':
             $this->DeleteCategory();
             break;
     }
     $this->Heading('Admin_BlogCategories');
     // print all categories and settings
     echo '<form name="categories" action="' . common::GetUrl('Admin_BlogCategories') . '" method="post">';
     echo '<table class="bordered">';
     echo '<tr><th>&nbsp;</th><th>Category</th><th>Number of Posts</th><th>Visible</th><th>Options</th></tr>';
     echo '<tbody class="sortable_table">';
     foreach ($this->categories as $catindex => $catname) {
         echo '<tr><td style="vertical-align:middle">';
         echo '<img src="' . $addonRelativeCode . '/static/grip.png" height="15" width="15" style="padding:2px;cursor:pointer;"/>';
         echo '</td><td>';
         echo '<input type="text" name="cattitle[' . $catindex . ']" value="' . $catname . '" class="gpinput" />';
         echo '</td><td>';
         $astr =& SimpleBlogCommon::$data['category_posts_' . $catindex];
         echo substr_count($astr, '>');
         echo '</td><td>';
         $checked = '';
         if (!SimpleBlogCommon::AStrGet('categories_hidden', $catindex)) {
             $checked = ' checked="checked"';
         }
         echo ' <input type="checkbox" name="catvis[' . $catindex . ']"' . $checked . '/> ';
         echo '</td><td>';
         echo common::Link('Admin_BlogCategories', $langmessage['delete'], 'cmd=delete_category&index=' . $catindex, ' name="postlink" class="gpconfirm" title="Delete this Category?" ');
         echo '</td></tr>';
     }
     echo '</tbody>';
     echo '</table>';
     echo '<p>';
     echo '<input type="hidden" name="cmd" value="save_categories" />';
     echo '<input type="submit" value="' . $langmessage['save_changes'] . '" class="gpsubmit"/>';
     echo ' &nbsp; ';
     echo common::Link('Admin_BlogCategories', 'Add New Category', 'cmd=new_category', ' name="gpabox" ');
     echo '</p>';
     echo '</form>';
     // print all posts
     /*
     if( count($this->itlist) ){
     	echo '<h3 onclick="$(this).next(\'form\').toggle()" style="cursor:pointer">All Blog Posts</h3>';
     	echo '<form name="allposts" action="'.common::GetUrl('Admin_BlogCategories').'" method="post" style="display:none">';
     	echo '<table style="width:100%">';
     	foreach( $this->itlist as $postindex => $postdata ){
     		echo '<tr><td>'.$postdata['title'].' ';
     		echo common::Link('Special_Blog','&#187;','id='.$postindex,'target="_blank"').'</td><td>';
     		echo '<select id="post'.$postindex.'" name="post'.$postindex.'[]" multiple="multiple" class="gpselect">';
     		foreach( $this->categories as $catindex => $catdata){
     			echo '<option value="'.$catindex.'" '.(isset($catdata[$postindex])? 'selected="selected"':'').'>'.$catdata['ct'].'</option>';
     		}
     		echo '</select>';
     		echo '</td></tr>';
     	}
     	echo '</table>';
     	echo '<input name="save_posts" type="submit" value="'.$langmessage['save'].'" class="gpsubmit" />';
     	echo '</form>';
     }
     */
 }