Example #1
0
 /**
  * Generate the URL to access the category.
  *
  * @param string|NULL 'param_num', 'subchap', 'chapters'
  * @param string|NULL url to use
  * @param integer category page to link to, default:1
  * @param integer|NULL number of posts per page (used for param_num only)
  * @param string glue between url params
  */
 function get_permanent_url($link_type = NULL, $blogurl = NULL, $paged = 1, $chapter_posts_per_page = NULL, $glue = '&')
 {
     global $DB, $cacheweekly, $Settings;
     if (empty($link_type)) {
         // Use default from settings:
         $this->get_Blog();
         $link_type = $this->Blog->get_setting('chapter_links');
     }
     if (empty($blogurl)) {
         $this->get_Blog();
         $blogurl = $this->Blog->gen_blogurl();
     }
     switch ($link_type) {
         case 'param_num':
             $r = url_add_param($blogurl, 'cat=' . $this->ID, $glue);
             if (empty($chapter_posts_per_page)) {
                 // Use default from Blog
                 $this->get_Blog();
                 $chapter_posts_per_page = $this->Blog->get_setting('chapter_posts_per_page');
             }
             if (!empty($chapter_posts_per_page) && $chapter_posts_per_page != $this->Blog->get_setting('posts_per_page')) {
                 // We want a specific post per page count:
                 $r = url_add_param($r, 'posts=' . $chapter_posts_per_page, $glue);
             }
             break;
         case 'subchap':
             $this->get_Blog();
             $category_prefix = $this->Blog->get_setting('category_prefix');
             if (!empty($category_prefix)) {
                 $r = url_add_tail($blogurl, '/' . $category_prefix . '/' . $this->urlname . '/');
             } else {
                 $r = url_add_tail($blogurl, '/' . $this->urlname . '/');
             }
             break;
         case 'chapters':
         default:
             $this->get_Blog();
             $category_prefix = $this->Blog->get_setting('category_prefix');
             if (!empty($category_prefix)) {
                 $r = url_add_tail($blogurl, '/' . $category_prefix . '/' . $this->get_url_path());
             } else {
                 $r = url_add_tail($blogurl, '/' . $this->get_url_path());
             }
             break;
     }
     if ($paged > 1) {
         $r = url_add_param($r, 'paged=' . $paged, $glue);
     }
     return $r;
 }
Example #2
0
 /**
  * Generate the permalink for the item.
  *
  * Note: Each item has an unique permalink at any given time.
  * Some admin settings may however change the permalinks for previous items.
  * Note: This actually only returns the URL, to get a real link, use {@link Item::get_permanent_link()}
  *
  * @todo archives modes in clean URL mode
  *
  * @param string single, archive, subchap
  * @param string base url to use
  * @param string glue between url params
  */
 function get_permanent_url($permalink_type = '', $blogurl = '', $glue = '&')
 {
     global $DB, $cacheweekly, $Settings, $posttypes_specialtypes, $posttypes_nopermanentURL, $posttypes_catpermanentURL;
     $this->get_Blog();
     if ($this->Blog->get_setting('front_disp') == 'page' && $this->Blog->get_setting('front_post_ID') == $this->ID) {
         // This item is used as front specific page on the blog's home
         $permalink_type = 'none';
     } elseif (in_array($this->ityp_ID, $posttypes_specialtypes)) {
         // This is not an "in stream" post:
         if (in_array($this->ityp_ID, $posttypes_nopermanentURL)) {
             // This type of post is not allowed to have a permalink:
             $permalink_type = 'none';
         } elseif (in_array($this->ityp_ID, $posttypes_catpermanentURL)) {
             // This post has a permanent URL as url to main chapter:
             $permalink_type = 'cat';
         } else {
             // allowed to have a permalink:
             // force use of single url:
             $permalink_type = 'single';
         }
     } elseif (empty($permalink_type)) {
         // Normal "in stream" post:
         // Use default from collection settings (may be an "in stream" URL):
         $permalink_type = $this->Blog->get_setting('permalinks');
     }
     switch ($permalink_type) {
         case 'archive':
             return $this->get_archive_url($blogurl, $glue);
         case 'subchap':
             return $this->get_chapter_url($blogurl, $glue);
         case 'none':
             // This is a silent fallback when we try to permalink to an Item that cannot be addressed directly:
             // Link to blog home:
             return $this->Blog->gen_blogurl();
         case 'cat':
             // Link to permanent url of main chapter:
             $this->get_main_Chapter();
             return $this->main_Chapter->get_permanent_url(NULL, $blogurl, 1, NULL, $glue);
         case 'single':
         default:
             return $this->get_single_url(true, $blogurl, $glue);
     }
 }
Example #3
0
 /**
  * Generate a link to the post in the category
  *
  * @param string base url to use
  * @param string glue between url params
  */
 function get_chapter_url($blogurl = '', $glue = '&')
 {
     if (empty($blogurl)) {
         $this->get_Blog();
         $blogurl = $this->Blog->gen_blogurl();
     }
     $permalink = url_add_tail($blogurl, '/' . $this->main_Chapter->get_url_path());
     return $permalink . '#item_' . $this->ID;
 }