Example #1
0
 /**
  * Get blog's category ordering value in case of root categories, parent Chapter subcat ordering otherwise
  *
  * @return string parent subcat ordering
  */
 function get_parent_subcat_ordering()
 {
     if (empty($this->parent_ID)) {
         // Return the default blog setting
         $this->load_Blog();
         return $this->Blog->get_setting('category_ordering');
     }
     $this->get_parent_Chapter();
     return $this->parent_Chapter->get_subcat_ordering();
 }
Example #2
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 #3
0
 /**
  * Get "nice" title of the Item
  * @return string
  */
 function get_title($params = array())
 {
     global $ReqURL, $Blog, $MainList;
     // Set default post navigation
     $def_post_navigation = empty($Blog) ? 'same_blog' : $Blog->get_setting('post_navigation');
     // Make sure we are not missing any param:
     $params = array_merge(array('before' => '', 'after' => '', 'format' => 'htmlbody', 'link_type' => '#', 'link_class' => '#', 'max_length' => '', 'target_blog' => '', 'nav_target' => NULL, 'post_navigation' => $def_post_navigation, 'title_field' => 'title'), $params);
     // Set post navigation target
     $nav_target = $params['nav_target'] === NULL && isset($MainList) && !empty($MainList->nav_target) ? $MainList->nav_target : $params['nav_target'];
     $blogurl = '';
     if (!empty($Blog) && $this->check_cross_post_nav($params['target_blog'], $Blog->ID)) {
         $blogurl = $Blog->gen_blogurl();
     }
     $title = format_to_output($this->{$params}['title_field'], $params['format']);
     if ($params['max_length'] != '') {
         // Crop long title
         $title = strmaxlen($title, intval($params['max_length']));
     }
     if (empty($title)) {
         return;
     }
     if ($params['link_type'] == '#') {
         // Use default link type from settings:
         if ($this->is_intro()) {
             // This is an intro, do not link title by default:
             $params['link_type'] = 'none';
         } elseif (is_same_url($this->get_permanent_url('', $blogurl, '&'), $ReqURL)) {
             // We are on the single url already:
             $params['link_type'] = 'none';
         } else {
             if ($this->ptyp_ID == 3000) {
                 // tblue> This is a sidebar link, link to its "link to" URL by default:
                 $params['link_type'] = 'linkto_url';
             } else {
                 // This is a normal post: use default link strategy from Blog settings:
                 $this->get_Blog();
                 $params['link_type'] = $this->Blog->get_setting('title_link_type');
             }
         }
     }
     switch ($params['link_type']) {
         case 'auto':
             $url = empty($this->url) ? $this->get_permanent_url() : $this->url;
             break;
         case 'permalink':
             $url = $this->get_permanent_url('', $blogurl);
             break;
         case 'linkto_url':
             $url = $this->url;
             break;
         case 'admin_view':
             $url = '?ctrl=items&blog=' . $this->get_blog_ID() . '&p=' . $this->ID;
             break;
         case 'none':
         default:
     }
     if (!empty($url)) {
         // url is set, also add navigation param if it is necessary
         $url = $this->add_navigation_param($url, $params['post_navigation'], $nav_target);
     }
     $link_class = '';
     if ($params['link_class'] != '#') {
         $link_class = ' class="' . $params['link_class'] . '"';
     }
     $r = $params['before'];
     if (!empty($url)) {
         $r .= '<a href="' . $url . '"' . $link_class . '>' . $title . '</a>';
     } else {
         $r .= $title;
     }
     $r .= $params['after'];
     return $r;
 }
Example #4
0
 /**
  * Template function: display title for item and link to related URL
  */
 function title($params = array())
 {
     // Make sure we are not missing any param:
     $params = array_merge(array('before' => '', 'after' => '', 'format' => 'htmlbody', 'link_type' => '#'), $params);
     $title = format_to_output($this->title, $params['format']);
     if (empty($title)) {
         return;
     }
     if ($params['link_type'] == '#') {
         // Use default link type from settings:
         $this->get_Blog();
         $params['link_type'] = $this->Blog->get_setting('title_link_type');
     }
     switch ($params['link_type']) {
         case 'permalink':
             $url = $this->get_permanent_url();
             break;
         case 'linkto_url':
             $url = $this->url;
             break;
         case 'admin_view':
             $url = '?ctrl=items&amp;blog=' . $this->blog_ID . '&amp;p=' . $this->ID;
             break;
         case 'none':
         default:
     }
     echo $params['before'];
     if (!empty($url)) {
         echo '<a href="' . $url . '">' . $title . '</a>';
     } else {
         echo $title;
     }
     echo $params['after'];
 }