Source for file _chapter.class.php
Documentation is available at _chapter.class.php
* This file implements the Chapter class.
* This file is part of Quam Plures - {@link http://quamplures.net/}
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class('generic/model/_genericcategory.class.php');
* The Blog of the Item (lazy filled, use {@link get_Blog()} to access it.
* @param table Database row
* @param integer|NULLsubset to use for new object
function Chapter( $db_row = NULL, $subset_ID = NULL )
// Call parent constructor:
{ // We are creating an object here:
$this->set( 'blog_ID', $subset_ID );
{ // Wa are loading an object:
$this->blog_ID = $db_row->cat_blog_ID;
$this->urlname = $db_row->cat_urlname;
$this->order = $db_row->cat_order;
* Load data from Request form fields.
* @return boolean true if loaded data seems valid.
parent::load_from_Request();
param( 'cat_urlname', 'string' );
param( 'cat_description', 'string' );
if( $Settings->get('chapter_ordering') == 'manual' )
param( 'cat_order', 'integer' );
$ChapterCache = & get_Cache( 'ChapterCache' );
* Get URL path (made of URL names) back to the root
$r = $parent_Chapter->get_url_path(). $r;
* Generate the URL to access the category.
* @param string|NULL'param_num', 'subchap', 'chapters'
* @param string|NULLurl to use
* @param integer category page to link to, default:1
* @param integer|NULLnumber 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 = '&' )
if( empty( $link_type ) )
{ // Use default from settings:
$link_type = $this->Blog->get_setting( 'chapter_links' );
$blogurl = $this->Blog->gen_blogurl();
if( empty($chapter_posts_per_page) )
{ // Use default from 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 );
$category_prefix = $this->Blog->get_setting('category_prefix');
if( !empty( $category_prefix ) )
$category_prefix = $this->Blog->get_setting('category_prefix');
if( !empty( $category_prefix ) )
* Get the Blog object for the Chapter.
* Load the Blog object for the Chapter, without returning it.
$this->Blog = & $BlogCache->get_by_ID( $this->blog_ID );
* Insert object into DB based on previously recorded changes.
* @param boolean Whether to notify the user when the url title has been changed.
* @return boolean true on success
function dbinsert( $urlname_verbose_change = true )
if( $this->ID != 0 ) debug_die( 'Existing object cannot be inserted!' );
// validate url title / slug
$this->ID, false, $this->dbprefix. 'urlname', $this->dbIDname,
$this->dbtablename, $urlname_verbose_change ) );
* Update the DB based on previously recorded changes
* @return boolean true on success
// validate url title / slug
if( empty($this->urlname) || isset ($this->dbchanges['cat_urlname']) )
{ // Url title has changed or is empty
|