示例#1
0
 function __construct()
 {
     global $page, $addonFolderName;
     parent::__construct();
     $this->dir = SimpleBlogCommon::$data_dir . '/comments';
     $this->GetCache();
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'delete_comment':
             $this->DeleteComment();
             break;
     }
     $this->ShowRecent();
 }
示例#2
0
 function __construct()
 {
     global $langmessage;
     parent::__construct();
     $cmd = common::GetCommand();
     switch ($cmd) {
         //regen
         case 'regen':
             SimpleBlogCommon::GenStaticContent();
             message($langmessage['SAVED']);
             break;
             //config
         //config
         case 'save_config':
             if ($this->SaveConfig()) {
                 SimpleBlogCommon::GenStaticContent();
             }
             break;
     }
     $this->Config();
 }
示例#3
0
 /**
  * Save the post
  *
  */
 public static function SavePost($post_id, $post)
 {
     global $langmessage;
     $_POST += array('title' => '', 'content' => '', 'subtitle' => '', 'isDraft' => '', 'category' => array());
     $title = htmlspecialchars($_POST['title']);
     $title = trim($title);
     if (empty($title)) {
         message($langmessage['TITLE_REQUIRED']);
         return false;
     }
     self::GetPostedTime();
     //different time
     //organize posts based on publish time
     SimpleBlogCommon::AStrSet('post_times', $post_id, $_POST['time']);
     $post_times = SimpleBlogCommon::AStrToArray('post_times');
     arsort($post_times);
     $str_index = array_keys($post_times);
     SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($str_index);
     //get next static gen time
     SimpleBlogCommon::NextGenTime();
     //create post array
     $post['title'] = $title;
     $post['content'] = $_POST['content'];
     $post['subtitle'] = htmlspecialchars($_POST['subtitle']);
     $post['categories'] = $_POST['category'];
     $post['time'] = $_POST['time'];
     unset($post['isDraft']);
     //save to data file
     if (!parent::SavePost($post_id, $post)) {
         return false;
     }
     //draft
     if ($_POST['isDraft'] === 'on') {
         SimpleBlogCommon::AStrSet('drafts', $post_id, 1);
     } else {
         SimpleBlogCommon::AStrRm('drafts', $post_id);
     }
     SimpleBlogCommon::AStrSet('titles', $post_id, $title);
     self::UpdatePostCategories($post_id);
     //find and update the edited post in categories and archives
     if (!SimpleBlogCommon::SaveIndex()) {
         message($langmessage['OOPS'] . ' (Index not saved)');
         return false;
     }
     SimpleBlogCommon::GenStaticContent();
     message($langmessage['SAVED']);
     return true;
 }
示例#4
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::AStrValue('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>';
     }
     */
 }