Source for file edit_book.php
Documentation is available at edit_book.php
* $Header: /cvsroot/bitweaver/_bit_wiki/edit_book.php,v 1.9 2006/05/29 17:33:07 spiderr Exp $
* Copyright (c) 2004 bitweaver.org
* Copyright (c) 2003 tikwiki.org
* Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
* $Id: edit_book.php,v 1.9 2006/05/29 17:33:07 spiderr Exp $
require_once( '../bit_setup_inc.php' );
$gBitSystem->verifyPermission( 'p_wiki_edit_book' );
if( isset ( $_COOKIE['book_section'] ) && $_COOKIE['book_section'] == 'o' ) {
$gBitSmarty->assign( 'book_section',$book_section );
include_once( WIKI_PKG_PATH. 'lookup_page_inc.php');
include_once( LIBERTY_PKG_PATH. 'LibertyStructure.php');
include_once( WIKI_PKG_PATH. 'BitBook.php');
if( isset ($_REQUEST["createstructure"]) ) {
if ((empty($_REQUEST['name']))) {
$gBitSmarty->assign('msg', tra("You must specify a name."));
$gBitSystem->display( 'error.tpl' );
//try to add a new structure
$pageId = $bookPage->findByPageName( $_REQUEST['name'] );
$bookPage->mPageId = $pageId;
$params['title'] = $_REQUEST['name'];
$params['edit'] = '{toc}';
$bookPage->store( $params );
if( $bookPage->isValid() ) {
// alias => '' is a temporary setting until alias stuff has been removed
$structureHash = array( 'content_id' => $bookPage->mContentId, 'alias' => '' );
$structure_id = $gStructure->storeNode( $structureHash );
//Cannot create a structure if a structure already exists
if (!isset ($structure_id)) {
$gBitSmarty->assign('msg', $_REQUEST['name'] . " " . tra("page not added (Exists)"));
$gBitSystem->display( 'error.tpl' );
$chapters = explode("\n", $_REQUEST["chapters"]);
foreach ($chapters as $chapter) {
$chapterName = trim($chapter);
if( !empty( $chapterName ) ) {
$nodeHash['parent_id'] = $structure_id;
$nodeHash['root_structure_id'] = $structure_id;
//try to add a new structure
$pageId = $nodePage->findByPageName( $chapterName );
$nodePage->mPageId = $pageId;
$params['title'] = trim($chapterName);
if( !$nodePage->store( $params ) ) {
vd( $bookPage->mErrors );
$nodeHash['content_id'] = $nodePage->mContentId;
$nodeHash['after_ref_id'] = $gStructure->storeNode( $nodeHash );
header( "location: ". WIKI_PKG_URL. "edit_book.php?structure_id=". $structure_id );
// Get all wiki pages for the select box
$_REQUEST['content_type_guid'] = !isset ( $_REQUEST['content_type_guid'] ) ? 'bitpage' : $_REQUEST['content_type_guid'];
// verify the book permission on structure load
$verifyStructurePermission = 'p_wiki_admin_book';
// load the javascript dynamic tree
$gBitSmarty->assign( "loadDynamicTree", TRUE );
// set the correct display template
$mid = 'bitpackage:wiki/edit_book.tpl';
include_once( LIBERTY_PKG_PATH. 'edit_structure_inc.php');
$gBitSystem->setBrowserTitle( 'Create Wiki Book' );
$mid = 'bitpackage:wiki/create_book.tpl';
$gBitSystem->setBrowserTitle( !empty($gStructure) ? 'Edit Wiki Book:'. $gStructure->mInfo["title"] : NULL );
$gBitSystem->display( $mid );
|