/** * Open/Close the comments for a blog post * */ function ToggleComments($closed, $post_id) { global $langmessage; if ($closed) { SimpleBlogCommon::AStrValue('comments_closed', $post_id, 1); } else { SimpleBlogCommon::AStrRm('comments_closed', $post_id); } if (SimpleBlogCommon::SaveIndex()) { $this->comments_closed = $closed; message($langmessage['SAVED']); } else { message($langmessage['OOPS']); } }
function __construct() { global $langmessage, $addonRelativeCode, $addonFolderName, $page; $this->Init(); $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; } $page->css_admin[] = '/include/css/addons.css'; //for hmargin css pre gpEasy 3.6 $page->head_js[] = '/data/_addoncode/' . $addonFolderName . '/admin.js'; $label = gpOutput::SelectText('Blog'); echo '<h2 class="hmargin">'; echo common::Link('Special_Blog', $label); echo ' » '; echo common::Link('Admin_Blog', 'Configuration'); echo ' <span>|</span> '; echo ' Categories '; echo ' <span>|</span> '; $comments = gpOutput::SelectText('Comments'); echo common::Link('Admin_BlogComments', $comments); echo '</h2>'; // print all categories and settings echo '<form name="categories" action="' . common::GetUrl('Admin_BlogCategories') . '" method="post">'; echo '<table class="bordered">'; echo '<tr><th> </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 . '/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 ' '; 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','»','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>'; } */ }
function ShowCategories() { echo '<h2>'; echo gpOutput::GetAddonText('Categories'); echo '</h2>'; //$gadgetFile = $this->addonPathData.'/gadget_categories.php'; echo '<ul>'; foreach ($this->categories as $catindex => $catname) { //skip hidden categories if (SimpleBlogCommon::AStrValue('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>'; }
/** * Get the edit links for the post * */ 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::AStrValue('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>'; }
/** * Display the links at the bottom of a post * */ 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 ' '; // check for newer posts and if post is draft $isDraft = false; if ($post_key > 0) { $i = 0; do { $i++; $next_index = SimpleBlogCommon::AStrValue('str_index', $post_key - $i); if (!common::loggedIn()) { $isDraft = SimpleBlogCommon::AStrValue('drafts', $next_index); } } while ($isDraft); if (!$isDraft) { $html = SimpleBlogCommon::PostLink($next_index, '%s', '', 'class="blog_newer"'); echo gpOutput::GetAddonText('Newer Entry', $html); echo ' '; } } //check for older posts and if older post is draft $i = 0; $isDraft = false; do { $i++; $prev_index = SimpleBlogCommon::AStrValue('str_index', $post_key + $i); if ($prev_index === false) { break; } if (!common::loggedIn()) { $isDraft = SimpleBlogCommon::AStrValue('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 ' '; echo common::Link('Admin_Blog', 'New Post', 'cmd=new_form', 'class="blog_post_new"'); } echo '</p>'; }
/** * Add a comment to the comment data for a post * */ function AddComment($post_index) { global $langmessage; $comments_closed = SimpleBlogCommon::AStrValue('comments_closed', $post_index); if ($comments_closed) { return; } $data = $this->GetCommentData($post_index); //need a captcha? if (SimpleBlogCommon::$data['comment_captcha'] && gp_recaptcha::isActive()) { if (!isset($_POST['anti_spam_submitted'])) { return false; } elseif (!gp_recaptcha::Check()) { return false; } } if (empty($_POST['name'])) { $field = gpOutput::SelectText('Name'); message($langmessage['OOPS_REQUIRED'], $field); return false; } if (empty($_POST['comment'])) { $field = gpOutput::SelectText('Comment'); message($langmessage['OOPS_REQUIRED'], $field); return false; } $temp = array(); $temp['name'] = htmlspecialchars($_POST['name']); $temp['comment'] = nl2br(strip_tags($_POST['comment'])); $temp['time'] = time(); if (!empty($_POST['website']) && $_POST['website'] !== 'http://') { $website = $_POST['website']; if (SimpleBlogCommon::strpos($website, '://') === false) { $website = false; } if ($website) { $temp['website'] = $website; } } $data[] = $temp; if (!$this->SaveCommentData($post_index, $data)) { message($langmessage['OOPS']); return false; } message($langmessage['SAVED']); //email new comments if (!empty(SimpleBlogCommon::$data['email_comments'])) { $subject = 'New Comment'; $body = ''; if (!empty($temp['name'])) { $body .= '<p>From: ' . $temp['name'] . '</p>'; } if (!empty($temp['website'])) { $body .= '<p>Website: ' . $temp['name'] . '</p>'; } $body .= '<p>' . $temp['comment'] . '</p>'; global $gp_mailer; includeFile('tool/email_mailer.php'); $gp_mailer->SendEmail(SimpleBlogCommon::$data['email_comments'], $subject, $body); } return true; }
static function UrlQuery($post_id = false, &$url, &$query) { $url = SimpleBlogCommon::$root_url; if ($post_id > 0) { switch (SimpleBlogCommon::$data['urls']) { case 'Full': $title = SimpleBlogCommon::AStrValue('titles', $post_id); $title = str_replace(array('?', ' '), array('', '_'), $title); $url .= '/' . $post_id . '_' . $title; break; case 'Tiny': $url .= '/' . $post_id; break; default: $query = trim($query . '&id=' . $post_id, '&'); break; } } }
/** * 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('Ym', $time); //year&month $archive[$ym][] = $post_id; } ob_start(); $prev_year = false; echo '<ul>'; foreach ($archive as $ym => $posts) { $y = floor($ym / 100); $m = $ym % 100; 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">' . self::$months[$m - 1] . ' (' . $sum . ')</a>'; echo '<ul class="simple_blog_category_posts nodisplay">'; foreach ($posts as $post_id) { $post_title = SimpleBlogCommon::AStrValue('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); }
/** * 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::AStrValue('categories_hidden', $catindex)) { $label .= ' (Hidden)'; } echo '<option value="' . $catindex . '" ' . $selected . '>' . $label . '</option>'; } echo '</select>'; }