wiki
[ class tree: wiki ] [ index: wiki ] [ all elements ]

Source for file edit_book.php

Documentation is available at edit_book.php

  1. <?php
  2. /**
  3.  * $Header: /cvsroot/bitweaver/_bit_wiki/edit_book.php,v 1.9 2006/05/29 17:33:07 spiderr Exp $
  4.  *
  5.  * Copyright (c) 2004 bitweaver.org
  6.  * Copyright (c) 2003 tikwiki.org
  7.  * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  8.  * All Rights Reserved. See copyright.txt for details and a complete list of authors.
  9.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
  10.  *
  11.  * $Id: edit_book.php,v 1.9 2006/05/29 17:33:07 spiderr Exp $
  12.  * @package wiki
  13.  * @subpackage functions
  14.  */
  15.  
  16. /**
  17.  * required setup
  18.  */
  19. require_once'../bit_setup_inc.php' );
  20.  
  21. $gBitSystem->verifyPermission'p_wiki_edit_book' );
  22.  
  23. ifisset$_COOKIE['book_section'&& $_COOKIE['book_section'== 'o' {
  24.     $book_section 'block';
  25. else {
  26.     $book_section 'none';
  27. }
  28. $gBitSmarty->assign'book_section',$book_section );
  29.  
  30. include_onceWIKI_PKG_PATH.'lookup_page_inc.php');
  31. include_onceLIBERTY_PKG_PATH.'LibertyStructure.php');
  32. include_onceWIKI_PKG_PATH.'BitBook.php');
  33.  
  34. global $gStructure;
  35.  
  36. ifisset($_REQUEST["createstructure"]) ) {
  37.     if ((empty($_REQUEST['name']))) {
  38.         $gBitSmarty->assign('msg'tra("You must specify a name."));
  39.         $gBitSystem->display'error.tpl' );
  40.         die;
  41.     }
  42.  
  43.     //try to add a new structure
  44.     $bookPage new BitBook();
  45.     $pageId $bookPage->findByPageName$_REQUEST['name');
  46.     if$pageId {
  47.         $bookPage->mPageId $pageId;
  48.         $bookPage->load();
  49.     else {
  50.         $params['title'$_REQUEST['name'];
  51.         $params['edit''{toc}';
  52.         $bookPage->store$params );
  53.     }
  54.  
  55.     if$bookPage->isValid() ) {
  56.         $gStructure new LibertyStructure();
  57.         // alias => '' is a temporary setting until alias stuff has been removed
  58.         $structureHash array'content_id' => $bookPage->mContentId'alias' => '' );
  59.         $structure_id $gStructure->storeNode$structureHash );
  60.         //Cannot create a structure if a structure already exists
  61.         if (!isset($structure_id)) {
  62.             $gBitSmarty->assign('msg'$_REQUEST['name'" " tra("page not added (Exists)"));
  63.             $gBitSystem->display'error.tpl' );
  64.             die;
  65.         }
  66.  
  67.         $chapters explode("\n"$_REQUEST["chapters"]);
  68.         foreach ($chapters as $chapter{
  69.             $chapterName trim($chapter);
  70.             if!empty$chapterName ) ) {
  71.                 unset$params );
  72.                 unset$nodeHash );
  73.                 $nodeHash['parent_id'$structure_id;
  74.                 $nodeHash['root_structure_id'$structure_id;
  75.                 $nodeHash['level'1;
  76.                 //try to add a new structure
  77.                 $nodePage new BitPage();
  78.                 $pageId $nodePage->findByPageName$chapterName );
  79.                 if$pageId {
  80.                     $nodePage->mPageId $pageId;
  81.                     $nodePage->load();
  82.                 else {
  83.                     $params['title'trim($chapterName);
  84.                     $params['edit''';
  85.                     if!$nodePage->store$params ) ) {
  86.                         vd$bookPage->mErrors );
  87.                     }
  88.                 }
  89.                 $nodeHash['content_id'$nodePage->mContentId;
  90.                 $nodeHash['after_ref_id'$gStructure->storeNode$nodeHash );
  91.             }
  92.         }
  93.         header"location: ".WIKI_PKG_URL."edit_book.php?structure_id=".$structure_id );
  94.     }
  95. elseif@BitBase::verifyId$_REQUEST["structure_id") ) {
  96.     // Get all wiki pages for the select box
  97.     $_REQUEST['content_type_guid'!isset$_REQUEST['content_type_guid''bitpage' $_REQUEST['content_type_guid'];
  98.     // verify the book permission on structure load
  99.     $verifyStructurePermission 'p_wiki_admin_book';
  100.     // load the javascript dynamic tree
  101.     $gBitSmarty->assign"loadDynamicTree"TRUE );
  102.     // set the correct display template
  103.     $mid 'bitpackage:wiki/edit_book.tpl';
  104.     include_onceLIBERTY_PKG_PATH.'edit_structure_inc.php');
  105. else {
  106.     $gBitSystem->setBrowserTitle'Create Wiki Book' );
  107.     $mid 'bitpackage:wiki/create_book.tpl';
  108. }
  109. $gBitSystem->setBrowserTitle!empty($gStructure'Edit Wiki Book:'.$gStructure->mInfo["title"NULL );
  110. // Display the template
  111. $gBitSystem->display$mid );
  112. ?>

Documentation generated on Thu, 15 Feb 2007 20:38:27 +0000 by phpDocumentor 1.3.0