Source for file _chapter.class.php
Documentation is available at _chapter.class.php
* This file implements the Chapter class.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2010 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.
* @version $Id: _chapter.class.php,v 1.16 2010/02/08 17:52:07 efy-yury Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'generic/model/_genericcategory.class.php', 'GenericCategory' );
* 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' );
* 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:
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 );
if( !empty( $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.
* @return boolean true on success
if( $this->ID !=
0 ) die( 'Existing object cannot be inserted!' );
// validate url title / slug
* 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
* $Log: _chapter.class.php,v $
* Revision 1.16 2010/02/08 17:52:07 efy-yury
* Revision 1.15 2009/10/04 20:36:04 blueyed
* Revision 1.14 2009/09/26 12:00:42 tblue246
* Revision 1.13 2009/09/25 07:32:52 efy-cantor
* replace get_cache to get_*cache
* Revision 1.12 2009/09/14 12:26:25 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.11 2009/03/08 23:57:41 fplanque
* Revision 1.10 2009/01/28 21:23:22 fplanque
* Manual ordering of categories
* Revision 1.9 2008/12/28 23:35:51 fplanque
* Autogeneration of category/chapter slugs(url names)
* Revision 1.8 2008/01/21 09:35:26 fplanque
* Revision 1.7 2008/01/07 02:53:27 fplanque
* Revision 1.6 2007/11/25 14:28:17 fplanque
* additional SEO settings
* Revision 1.5 2007/10/06 21:17:25 fplanque
* Revision 1.4 2007/10/01 13:41:06 waltercruz
* Category prefix, trying to make the code more b2evo style
* Revision 1.3 2007/09/29 01:50:49 fplanque
* temporary rollback; waiting for new version
* Revision 1.1 2007/06/25 10:59:25 fplanque
* MODULES (refactored MVC)
* Revision 1.10 2007/05/09 00:54:45 fplanque
* Attempt to normalize all URLs before adding params
* Revision 1.9 2007/04/26 00:11:06 fplanque
* Revision 1.8 2007/03/02 00:44:43 fplanque
* Revision 1.7 2007/01/15 00:38:06 fplanque
* pepped up "new blog" creation a little. To be continued.
* Revision 1.6 2006/12/11 00:32:26 fplanque
* allow_moving_chapters stting moved to UI
* chapters are now called categories in the UI
* Revision 1.5 2006/11/24 18:27:23 blueyed
* Fixed link to b2evo CVS browsing interface in file docblocks