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

Source for file edit_structure_inc.php

Documentation is available at edit_structure_inc.php

  1. <?php
  2. /**
  3.  * edit_structure_inc
  4.  *
  5.  * @author   Christian Fowler>
  6.  * @version  $Revision$
  7.  * @package  liberty
  8.  * @subpackage functions
  9.  */
  10.  
  11. // Copyright (c) 2004, Christian Fowler, et. al.
  12. // All Rights Reserved. See below for details and a complete list of authors.
  13. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  14.  
  15. /**
  16.  * required setup
  17.  */
  18. require_once( '../kernel/setup_inc.php' );
  19. include_once( LIBERTY_PKG_PATH.'LibertyStructure.php');
  20.  
  21. if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) {
  22.     $gBitSystem->fatalError( tra( "No structure indicated" ));
  23. } else {
  24.     global $gStructure;
  25.     $gStructure = new LibertyStructure( $_REQUEST["structure_id"] );
  26.     $gStructure->load();
  27.  
  28.     // order matters for these conditionals
  29.     if( empty( $gStructure ) || !$gStructure->isValid() ) {
  30.         $gBitSystem->fatalError( tra( 'Invalid structure' ));
  31.     }
  32.  
  33.     if( $gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id'] ) {
  34.         $rootStructure = &$gStructure;
  35.     } else {
  36.         $rootStructure = new LibertyStructure( $gStructure->mInfo['root_structure_id'] );
  37.         $rootStructure->load();
  38.         $rootStructure->loadNavigation();
  39.         $rootStructure->loadPath();
  40.     }
  41.     if( empty( $gContent ) ) {
  42.         $gContent = LibertyContent::getLibertyObject( $gStructure->getField( 'content_id' ) );
  43.         $gContent->verifyUpdatePermission();
  44.     }
  45.     $gBitSmarty->assign_by_ref( 'gStructure', $gStructure );
  46.     $gBitSmarty->assign( 'editingStructure', TRUE );
  47.     $gBitSmarty->assign('structureInfo', $gStructure->mInfo);
  48.  
  49.     // Store the actively stored structure name
  50.     $gBitUser->storePreference( 'edit_structure_name', $rootStructure->mInfo['title'] );
  51.     $gBitUser->storePreference( 'edit_structure_id', $rootStructure->mStructureId );
  52.  
  53.     if( ( isset( $_REQUEST["action"] ) && ( $_REQUEST["action"] == 'remove' ) ) || !empty( $_REQUEST["confirm"] ) ) {
  54.         $gBitUser->verifyTicket();
  55.         if( $_REQUEST["action"] == 'remove' && ($gBitThemes->isAjaxRequest() || !empty( $_REQUEST["confirm"] )) ) {
  56.             $gBitUser->verifyTicket();
  57.             if( $gStructure->removeStructureNode( $_REQUEST["structure_id"], false ) ) {
  58.                 if( $gBitThemes->isAjaxRequest() ) {
  59.                     $feedback['success'] = tra( "removed from" ).' '.$gContent->getContentTypeName();
  60.                 } else {
  61.                     bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["parent_id"] );
  62.                 }
  63.             } else {
  64.                 $feedback['error'] = $gStructure->mErrors;
  65.             }
  66.             $gBitSmarty->assign_by_ref('feedback', $feedback);
  67.         } elseif( $_REQUEST["action"] == 'remove' ) {
  68.             $gBitSystem->setBrowserTitle( tra('Confirm removal of ').$gContent->getTitle() );
  69.             $formHash['action'] = 'remove';
  70.             $formHash['remove'] = TRUE;
  71.             $formHash['structure_id'] = $_REQUEST['structure_id'];
  72.             $msgHash = array(
  73.                 'label' => tra('Remove content from Structure'),
  74.                 'confirm_item' => $gContent->getTitle().tra('and any subitems'),
  75.                 'warning' => tra('This will remove the content from the structure but will <strong>not</strong> modify or remove the content itself.'),
  76.             );
  77.             $gBitSystem->confirmDialog( $formHash,$msgHash );
  78.         }
  79.     } elseif (isset($_REQUEST["move_node"])) {
  80.         if ($_REQUEST["move_node"] == '1') {
  81.             $gStructure->moveNodeWest();
  82.         } elseif ($_REQUEST["move_node"] == '2') {
  83.             $gStructure->moveNodeNorth();
  84.         }    elseif ($_REQUEST["move_node"] == '3') {
  85.             $gStructure->moveNodeSouth();
  86.         } elseif ($_REQUEST["move_node"] == '4') {
  87.             $gStructure->moveNodeEast();
  88.         }
  89.         bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["structure_id"] );
  90.     } elseif( !empty( $_REQUEST['submit_structure'] ) ) {
  91.         if( $gStructure->storeStructure( $_REQUEST ) ) {
  92.             $feedback['success'] = tra( "Your changes were successfully saved." );
  93.         } else {
  94.             $feedback['error'] = $gStructure->mErrors;
  95.         }
  96.     } elseif (isset($_REQUEST["create"]) || (isset( $_REQUEST["action"] ) && $_REQUEST["action"] == 'add') ) {
  97.         $structureHash['root_structure_id'] = $rootStructure->mStructureId;
  98.         $structureHash['parent_id'] = $_REQUEST['structure_id'];
  99.  
  100.         $after = null;
  101.         if (isset($_REQUEST['after_ref_id'])) {
  102.             $structureHash['after_ref_id'] = $_REQUEST['after_ref_id'];
  103.         }
  104.         if (!(empty($_REQUEST['name']))) {
  105.             $gStructure->s_create_page($_REQUEST["structure_id"], $after, $_REQUEST["name"], '');
  106.         } elseif(!empty($_REQUEST['content'])) {
  107.             foreach ($_REQUEST['content'] as $conId ) {
  108.                 $structureHash['content_id'] = $conId;
  109.                 if( $new_structure_id = $gStructure->storeNode( $structureHash ) ) {
  110.                     $structureHash['after_ref_id'] = $new_structure_id;
  111.                     $feedback['success'] = tra( "added to" ).' '.$gContent->getContentTypeName();
  112.                 } else {
  113.                     $feedback['failure'] = $gStructure->mErrors;
  114.                 }
  115.             }
  116.         }
  117.     }
  118.  
  119.     $structureTocId = $rootStructure->mStructureId;
  120.     $gBitSmarty->assign( 'structureToc', $rootStructure->getToc() );
  121.     $gBitSmarty->assign( 'structureTocId', $structureTocId );
  122.     $gBitSmarty->assign_by_ref('feedback', $feedback);
  123. }
  124.     $gBitSmarty->assign( 'editingStructure', FALSE );
  125.  
  126. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:27 +0000 by phpDocumentor 1.5.0-lsces