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

Source for file list_pages.php

Documentation is available at list_pages.php

  1. <?php
  2. /**
  3.  * @package wiki
  4.  * @subpackage functions
  5.  */
  6.  
  7. /**
  8.  * required setup
  9.  */
  10. require_once( '../kernel/setup_inc.php' );
  11. require_once( WIKI_PKG_PATH.'BitPage.php' );
  12.  
  13. // verify stuff
  14. $gBitSystem->verifyPackage( 'wiki' );
  15. $gBitSystem->verifyPermission( 'p_wiki_list_pages' );
  16.  
  17. $gContent = new BitPage();
  18. $gContent->invokeServices( 'content_list_function', $_REQUEST );
  19.  
  20. /* mass-remove:
  21.    the checkboxes are sent as the array $_REQUEST["checked[]"], values are the wiki-PageNames,
  22.    e.g. $_REQUEST["checked"][3]="HomePage"
  23.    $_REQUEST["batch_submit"] holds the value of the "with selected do..."-option list
  24.    we look if any page's checkbox is on and if remove_pages is selected.
  25.    then we check permission to delete pages.
  26.    if so, we call BitPage::expunge for all the checked pages.  */
  27. if( isset( $_REQUEST["batch_submit"] ) && isset( $_REQUEST["checked"] ) && $_REQUEST["batch_submit"] == "remove_pages" ) {
  28.  
  29.     // Now check permissions to remove the selected pages
  30.     $gContent->verifyUserPermission( 'p_wiki_remove_page' );
  31.  
  32.     if( !empty( $_REQUEST['cancel'] )) {
  33.         // user cancelled - just continue on, doing nothing
  34.     } elseif( empty( $_REQUEST['confirm'] )) {
  35.         $formHash['delete'] = TRUE;
  36.         $formHash['batch_submit'] = 'remove_pages';
  37.         foreach( $_REQUEST["checked"] as $del ) {
  38.             $tmpPage = new BitPage( $del);
  39.             if( $tmpPage->load() && !empty( $tmpPage->mInfo['title'] )) {
  40.                 $info = $tmpPage->mInfo['title'];
  41.             } else {
  42.                 $info = $del;
  43.             }
  44.             $formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>'.$info;
  45.         }
  46.         $gBitSystem->confirmDialog( $formHash, 
  47.                 array( 
  48.                     'warning' => tra('Are you sure you want to delete these pages?') . ' (' . tra('Count: ') . count( $_REQUEST["checked"] ) . ')',                
  49.                     'error' => tra('This cannot be undone!'),
  50.                 )
  51.             );
  52.     } else {
  53.         foreach( $_REQUEST["checked"] as $deletepage ) {
  54.             $tmpPage = new BitPage( $deletepage );
  55.             if( !$tmpPage->load() || !$tmpPage->expunge() ) {
  56.                 array_merge( $errors, array_values( $tmpPage->mErrors ));
  57.             }
  58.         }
  59.         if( !empty( $errors )) {
  60.             $gBitSmarty->assign_by_ref( 'errors', $errors );
  61.         }
  62.     }
  63. }
  64.  
  65. $gBitSmarty->assign_by_ref( "gContent", $gContent );
  66.  
  67. if( !empty( $_REQUEST['sort_mode'] )) {
  68.     $listHash['sort_mode'] = preg_replace( '/^user_/', 'creator_user_', $_REQUEST['sort_mode'] );
  69. }
  70. $listHash = $_REQUEST;
  71. $listHash['extras'] = TRUE;
  72. $listpages = $gContent->getList( $listHash );
  73.  
  74. // we will probably need a better way to do this
  75. $listHash['listInfo']['parameters']['find_title']       = !empty( $listHash['find_title'] ) ? $listHash['find_title'] : '';
  76. $listHash['listInfo']['parameters']['find_author']      = !empty( $listHash['find_author'] ) ? $listHash['find_author'] : '';
  77. $listHash['listInfo']['parameters']['find_last_editor'] = !empty( $listHash['find_last_editor'] ) ? $listHash['find_last_editor'] : '';
  78. $listHash['listInfo']['ihash']['content_type_guid'] = BITPAGE_CONTENT_TYPE_GUID;
  79.  
  80. $gBitSmarty->assign_by_ref( 'listpages', $listpages );
  81. $gBitSmarty->assign_by_ref( 'listInfo', $listHash['listInfo'] );
  82.  
  83. // Display the template
  84. $gBitSystem->display( 'bitpackage:wiki/list_pages.tpl', tra( 'Wiki Pages' ), array( 'display_mode' => 'list' ));
  85. ?>

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