Esempio n. 1
0
 /**
  *  Print all categories and their contents on gadget
  *
  */
 function Run()
 {
     echo '<div class="simple_blog_gadget"><div>';
     echo '<span class="simple_blog_gadget_label">';
     echo gpOutput::GetAddonText('Categories');
     echo '</span>';
     echo '<ul>';
     foreach ($this->categories as $catdata) {
         if (!$catdata['visible']) {
             continue;
             //skip hidden categories
         }
         echo '<li>';
         $sum = count($catdata['posts']);
         echo '<a class="blog_gadget_link">' . $catdata['ct'] . ' (' . $sum . ')</a>';
         if ($sum) {
             echo '<ul class="nodisplay">';
             foreach ($catdata['posts'] as $post_index => $post_title) {
                 echo '<li>';
                 echo common::Link('Special_Blog', $post_title, 'id=' . $post_index);
                 echo '</li>';
             }
             echo '</ul>';
         }
         echo '</li>';
     }
     echo '</ul>';
     echo '</div></div>';
 }
Esempio n. 2
0
 function Form($html)
 {
     $operator_key = array_rand($this->operators);
     $operator = $this->operators[$operator_key];
     $asm_1 = rand(1, 10);
     $asm_3 = rand(1, 10);
     if ($operator_key == 3) {
         $asm_1 = $asm_1 * $asm_3;
     }
     $inputs = array();
     $inputs[] = ' <input type="hidden" name="asm_1" value="' . $asm_1 . '" /> ';
     $inputs[] = ' <input type="hidden" name="asm_2" value="' . $operator_key . '" /> ';
     $inputs[] = ' <input type="hidden" name="asm_3" value="' . $asm_3 . '" /> ';
     shuffle($inputs);
     ob_start();
     echo implode('', $inputs);
     echo '<span class="anti_spam_math">';
     echo $asm_1;
     echo '  ';
     echo gpOutput::GetAddonText($operator);
     echo '  ';
     echo $asm_3;
     echo '  ';
     echo gpOutput::GetAddonText('equals');
     echo ' <input type="text" name="asm_4" value="" size="4" maxlength="6" /> ';
     echo '</span>';
     $html .= ob_get_clean();
     return $html;
 }
Esempio n. 3
0
 /**
  *  Print all archives and their contents on gadget
  *
  */
 function Run()
 {
     if (!count($this->archives)) {
         return;
     }
     echo '<div class="simple_blog_gadget"><div>';
     echo '<span class="simple_blog_gadget_label">';
     echo gpOutput::GetAddonText('Archives');
     echo '</span>';
     $prev_year = false;
     echo '<ul>';
     foreach ($this->archives 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">' . $this->months[$m - 1] . ' (' . $sum . ')</a>';
         echo '<ul class="simple_blog_category_posts nodisplay">';
         foreach ($posts as $post_index => $post_title) {
             echo '<li>';
             echo common::Link('Special_Blog', $post_title, 'id=' . $post_index);
             echo '</li>';
         }
         echo '</ul>';
         echo '</li>';
         echo '</ul>';
     }
     echo '</li></ul>';
     echo '</div></div>';
 }
 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>';
 }
 function SimpleBlogCategories()
 {
     global $addonPathData;
     SimpleBlogCommon::AddCSS();
     $gadget_file = $addonPathData . '/gadget_categories.php';
     $content = '';
     if (file_exists($gadget_file)) {
         $content = file_get_contents($gadget_file);
     }
     //fix edit links
     if (strpos($content, 'simple_blog_gadget_label')) {
         new SimpleBlogCommon();
         $content = file_get_contents($gadget_file);
     }
     if (empty($content)) {
         return;
     }
     echo '<div class="simple_blog_gadget"><div>';
     echo '<span class="simple_blog_gadget_label">';
     echo gpOutput::GetAddonText('Categories');
     echo '</span>';
     echo $content;
     echo '</div></div>';
 }
Esempio n. 6
0
 function ShowLayoutSortablePF($items)
 {
     //for section
     if ($this->is_sect == "yes") {
         if (isset($this->sect_options['datafilter']) and $this->sect_options['datafilter'] != "") {
             $this->datafilter = $this->sect_options['datafilter'];
         }
     }
     echo '<ul id="filter-list" class="clearfix">';
     echo '<li class="filter" data-filter="all">' . gpOutput::GetAddonText('All') . '</li>';
     if (isset($this->datafilter)) {
         $pieces = explode(",", $this->datafilter);
         foreach ($pieces as $piece) {
             echo ' <li class="filter" data-filter="' . $piece . '">' . $piece . '</li>';
         }
     }
     echo '</ul>';
     echo '<div class="container" style="width:100%;">';
     echo '<div id="EC_portfolio">';
     foreach ($items as $item) {
         echo '<div class="item ' . $item['datafilter'] . '" style="width: ' . $this->ItemW . '%;">';
         if ($this->Showtitle) {
             echo '<h3>' . $item['link'] . '</h3>';
         }
         echo $item['image'];
         if ($this->ShortInfo != "no") {
             echo '<div class="shortinfo" >' . $item['short_info'] . '</div>';
         }
         //echo '<div class="readmore_EC">'.$item['readmore'].'</div>';
         echo '</div>';
     }
     echo '</div>';
     echo '</div>';
 }
Esempio n. 7
0
 function SimpleSearch()
 {
     global $page, $langmessage, $addonPathData;
     $this->config_file = $addonPathData . '/search_config.php';
     $this->GetConfig();
     if (common::LoggedIn()) {
         $page->admin_links[] = array('Special_Search', 'Configuration', 'cmd=config');
         $cmd = common::GetCommand();
         switch ($cmd) {
             case 'save_config':
                 if ($this->SaveConfig()) {
                     break;
                 }
                 return;
             case 'config':
                 $this->Config($this->search_config);
                 return;
         }
     }
     $query =& $_GET['q'];
     echo '<div class="search_results">';
     echo '<form action="' . common::GetUrl('Special_Search') . '" method="get">';
     echo '<h2>';
     echo gpOutput::GetAddonText('Search');
     echo ' &nbsp; ';
     echo '<input name="q" type="text" class="text" value="' . htmlspecialchars($query) . '"/>';
     echo '<input type="hidden" name="src" value="gadget" /> ';
     $html = '<input type="submit" name="" class="submit" value="%s" />';
     echo gpOutput::GetAddonText('Search', $html);
     echo '</h2>';
     echo '</form>';
     if (!empty($query)) {
         $query = strtolower($query);
         preg_match_all("/\\S+/", $query, $words);
         $words = array_unique($words[0]);
         $pattern = '#(';
         $bar = '';
         foreach ($words as $word) {
             $pattern .= $bar . preg_quote($word, '#');
             $bar = '|';
         }
         $pattern .= ')#Si';
         $this->SearchPages($pattern);
         $this->SearchBlog($pattern);
     }
     if (count($this->files) > 0) {
         foreach ($this->files as $result) {
             echo $result;
         }
     } else {
         echo '<p>';
         echo gpOutput::GetAddonText('Sorry, there weren\'t any results for your search. ');
         echo '</p>';
     }
     echo '</div>';
 }
Esempio n. 8
0
<?php

defined('is_running') or die('Not an entry point...');
$query = '';
if (isset($_GET['q'])) {
    $query = $_GET['q'];
}
echo '<h3>';
echo gpOutput::GetAddonText('Search');
echo '</h3>';
echo '<form action="' . common::GetUrl('Special_Search') . '" method="get">';
echo '<div>';
echo '<input name="q" type="text" class="text" value="' . htmlspecialchars($query) . '"/>';
echo '<input type="hidden" name="src" value="gadget" />';
$html = '<input type="submit" class="submit" name="" value="%s" />';
echo gpOutput::GetAddonText('Search', $html);
echo '</div>';
echo '</form>';
Esempio n. 9
0
 function ShowResults()
 {
     global $langmessage;
     if (!count($this->results)) {
         echo '<p>';
         echo gpOutput::GetAddonText($langmessage['search_no_results']);
         echo '</p>';
         return;
     }
     usort($this->results, array('special_gpsearch', 'sort'));
     // remove duplicates
     $links = array();
     foreach ($this->results as $key => $result) {
         //$link = common::GetUrl( $result['slug'], $result['query'] );
         $link = isset($result['url']) ? $result['url'] : common::GetUrl($result['slug'], $result['query']);
         $link = mb_strtolower($link);
         if (in_array($link, $links)) {
             unset($this->results[$key]);
         } else {
             $links[] = $link;
         }
     }
     $total = count($this->results);
     $len = 20;
     $total_pages = ceil($total / $len);
     $current_page = 0;
     if (isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg'])) {
         if ($_REQUEST['pg'] <= $total_pages) {
             $current_page = $_REQUEST['pg'];
         } else {
             $current_page = $total_pages - 1;
         }
     }
     $start = $current_page * $len;
     $end = min($start + $len, $total);
     $this->results = array_slice($this->results, $start, $len, true);
     echo '<p class="search_nav search_nav_top">';
     echo sprintf($langmessage['SHOWING'], $start + 1, $end, $total);
     echo '</p>';
     echo '<div class="result_list">';
     foreach ($this->results as $result) {
         echo '<div><h4>';
         //echo common::Link($result['slug'],$result['label'],$result['query']);
         echo isset($result['link']) ? $result['link'] : common::Link($result['slug'], $result['label'], $result['query']);
         echo '</h4>';
         echo $result['content'];
         if ($this->show_stats) {
             echo ' <span class="match_stats">';
             echo $result['matches'] . ' match(es) out of ' . $result['words'] . ' words ';
             echo ' </span>';
         }
         echo '</div>';
     }
     echo '</div>';
     if ($total_pages > 1) {
         echo '<ul class="search_nav search_nav_bottom pagination">';
         for ($i = 0; $i < $total_pages; $i++) {
             if ($i == $current_page) {
                 echo '<li><span>' . ($i + 1) . '</span></li> ';
                 continue;
             }
             $query = 'q=' . rawurlencode($_REQUEST['q']);
             if ($i > 0) {
                 $query .= '&pg=' . $i;
             }
             $attr = '';
             if ($this->gpabox) {
                 $attr = 'data-cmd="gpabox"';
             }
             echo '<li>' . common::Link('special_gpsearch', $i + 1, $query, $attr) . '</li>';
         }
         echo '</ul>';
     }
 }
Esempio n. 10
0
 /**
  * Potential method for allowing users to format the header area of their blog
  * However, this would make it more difficult for theme developers to design for the blog plugin
  *
  */
 function BlogHead($header, $post_index, $post, $cacheable = false)
 {
     $blog_info = '{empty_blog_piece}';
     if (!empty($post['subtitle'])) {
         $blog_info = '<span class="simple_blog_subtitle">';
         $blog_info .= $post['subtitle'];
         $blog_info .= '</span>';
     }
     $blog_date = '<span class="simple_blog_date">';
     $blog_date .= strftime($this->blogData['strftime_format'], $post['time']);
     $blog_date .= '</span>';
     $blog_comments = '{empty_blog_piece}';
     if ($this->blogData['allow_comments'] && isset($this->blogData['post_info'][$post_index]) && isset($this->blogData['post_info'][$post_index]['comments'])) {
         $blog_comments = '<span class="simple_blog_comments">';
         if ($cacheable) {
             $blog_comments .= gpOutput::SelectText('Comments');
         } else {
             $blog_comments .= gpOutput::GetAddonText('Comments');
         }
         $blog_comments .= ': ' . $this->blogData['post_info'][$post_index]['comments'];
         $blog_comments .= '</span>';
     }
     $format = '{header} <div class="simple_blog_info"> {blog_info} {separator} {blog_date} {separator} {blog_comments} </div>';
     $search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}');
     $replace = array($header, $blog_info, $blog_date, $blog_comments);
     $result = str_replace($search, $replace, $format);
     $reg = '#\\{empty_blog_piece\\}(\\s*)\\{separator\\}#';
     $result = preg_replace($reg, '\\1', $result);
     $reg = '#\\{separator\\}(\\s*){empty_blog_piece\\}#';
     $result = preg_replace($reg, '\\1', $result);
     echo str_replace('{separator}', $this->blogData['subtitle_separator'], $result);
 }
Esempio n. 11
0
 /**
  * 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>';
 }
Esempio n. 12
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>';
 }
Esempio n. 13
0
 /**
  * Show the comment form
  *
  */
 function CommentForm($showCaptcha = false)
 {
     $_POST += array('name' => '', 'website' => 'http://', 'comment' => '');
     echo '<div class="easy_comment_form">';
     echo '<h3>';
     echo gpOutput::GetAddonText('Leave Comment');
     echo '</h3>';
     echo '<form method="post" action="' . common::GetUrl($this->current_title) . '">';
     echo '<table>';
     echo '<tr>';
     echo '<td>';
     echo '<div>';
     echo gpOutput::GetAddonText('Name');
     echo '</div>';
     echo '<input type="text" name="name" class="text" value="' . htmlspecialchars($_POST['name']) . '" />';
     echo '</td>';
     echo '</tr>';
     if (!empty($this->config['commenter_website'])) {
         echo '<tr>';
         echo '<td>';
         echo '<div>';
         echo gpOutput::GetAddonText('Website');
         echo '</div>';
         echo '<input type="text" name="website" class="text" value="' . htmlspecialchars($_POST['website']) . '" />';
         echo '</td>';
         echo '</tr>';
     }
     echo '<tr>';
     echo '<td>';
     echo '<div>';
     echo gpOutput::GetAddonText('Comment');
     echo '</div>';
     echo '<textarea name="comment" cols="30" rows="7" >';
     echo htmlspecialchars($_POST['comment']);
     echo '</textarea>';
     echo '</td>';
     echo '</tr>';
     if ($this->config['comment_captcha'] && gp_recaptcha::isActive()) {
         echo '<tr>';
         echo '<td>';
         echo '<div>';
         echo gpOutput::GetAddonText('captcha');
         echo '</div>';
         gp_recaptcha::Form();
         echo '</td></tr>';
     }
     echo '<tr>';
     echo '<td>';
     echo '<input type="hidden" name="nonce" value="' . htmlspecialchars(common::new_nonce('easy_comments:' . count($this->comment_data), true)) . '" />';
     echo '<input type="hidden" name="cmd" value="easy_comment_add" />';
     $html = '<input type="submit" name="" class="submit" value="%s" />';
     echo gpOutput::GetAddonText('Add Comment', $html);
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '</form>';
     echo '</div>';
 }
Esempio n. 14
0
 /**
  * Display a blog page with multiple blog posts
  *
  */
 function ShowPage()
 {
     $per_page = SimpleBlogCommon::$data['per_page'];
     $page = 0;
     if (isset($_GET['page']) && is_numeric($_GET['page'])) {
         $page = (int) $_GET['page'];
     }
     $start = $page * $per_page;
     $include_drafts = common::LoggedIn();
     $show_posts = $this->WhichPosts($start, $per_page, $include_drafts);
     $this->ShowPosts($show_posts);
     //pagination links
     echo '<p class="blog_nav_links">';
     if ($page > 0) {
         $html = common::Link('Special_Blog', '%s');
         echo gpOutput::GetAddonText('Blog Home', $html);
         echo '&nbsp;';
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page - 1), 'class="blog_newer"');
         echo gpOutput::GetAddonText('Newer Entries', $html);
         echo '&nbsp;';
     }
     if (($page + 1) * $per_page < SimpleBlogCommon::$data['post_count']) {
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page + 1), 'class="blog_older"');
         echo gpOutput::GetAddonText('Older Entries', $html);
     }
     if (common::LoggedIn()) {
         echo '&nbsp;';
         echo common::Link('Special_Blog', 'New Post', 'cmd=new_form');
     }
     echo '</p>';
 }
Esempio n. 15
0
 /**
  * Potential method for allowing users to format the header area of their blog
  * However, this would make it more difficult for theme developers to design for the blog plugin
  *
  */
 function BlogHead($header, $post_index, $post, $cacheable = false)
 {
     //subtitle
     $blog_info = '{empty_blog_piece}';
     if (!empty($post['subtitle'])) {
         $blog_info = '<span class="simple_blog_subtitle">';
         $blog_info .= $post['subtitle'];
         $blog_info .= '</span>';
     }
     //blog date
     $blog_date = '<span class="simple_blog_date">';
     $blog_date .= strftime(SimpleBlogCommon::$data['strftime_format'], $post['time']);
     $blog_date .= '</span>';
     //blog comments
     $blog_comments = '{empty_blog_piece}';
     $count = SimpleBlogCommon::AStrValue('comment_counts', $post_index);
     if ($count > 0) {
         $blog_comments = '<span class="simple_blog_comments">';
         if ($cacheable) {
             $blog_comments .= gpOutput::SelectText('Comments');
         } else {
             $blog_comments .= gpOutput::GetAddonText('Comments');
         }
         $blog_comments .= ': ' . $count;
         $blog_comments .= '</span>';
     }
     // format content
     $format = '{header} <div class="simple_blog_info"> {blog_info} {separator} {blog_date} {separator} {blog_comments} </div>';
     $search = array('{header}', '{blog_info}', '{blog_date}', '{blog_comments}');
     $replace = array($header, $blog_info, $blog_date, $blog_comments);
     $result = str_replace($search, $replace, $format);
     $reg = '#\\{empty_blog_piece\\}(\\s*)\\{separator\\}#';
     $result = preg_replace($reg, '\\1', $result);
     $reg = '#\\{separator\\}(\\s*){empty_blog_piece\\}#';
     $result = preg_replace($reg, '\\1', $result);
     echo str_replace('{separator}', SimpleBlogCommon::$data['subtitle_separator'], $result);
 }