Example #1
0
 /**
  * Get the post id from the requested url
  *
  */
 static function PostID($requested)
 {
     if (isset($_REQUEST['id']) && ctype_digit($_REQUEST['id'])) {
         return $_REQUEST['id'];
     }
     if (strpos($requested, '/') === false) {
         return false;
     }
     $parts = explode('/', $requested);
     $ints = strspn($parts[1], '0123456789');
     if ($ints) {
         return substr($parts[1], 0, $ints);
     }
     return SimpleBlogCommon::AStrKey('titles', $parts[1], true);
 }
Example #2
0
 /**
  * Get the post id from the requested url
  *
  */
 public function PostID($requested)
 {
     if (isset($_REQUEST['id']) && ctype_digit($_REQUEST['id'])) {
         return $_REQUEST['id'];
     }
     if (strpos($requested, '/') === false) {
         return;
     }
     $parts = explode('/', $requested);
     if (SimpleBlogCommon::$data['urls'] != 'Title') {
         $ints = strspn($parts[1], '0123456789');
         if ($ints) {
             return substr($parts[1], 0, $ints);
         }
     }
     $id = SimpleBlogCommon::AStrKey('titles', $parts[1], true);
     if ($id !== false) {
         return $id;
     }
     return $this->SimilarPost($parts[1]);
 }
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>';
 }