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

Source for file get_content_list_inc.php

Documentation is available at get_content_list_inc.php

  1. <?php
  2. /**
  3.  * get_content_list
  4.  *
  5.  * @author   Christian Fowler>
  6.  * @version  $Revision$
  7.  * @package  liberty
  8.  * @subpackage functions
  9.  */
  10.  
  11. /**
  12.  * required setup
  13.  */
  14. require_once( LIBERTY_PKG_PATH."LibertyContent.php" );
  15. global $gContent;
  16. global $gLibertySystem;
  17.  
  18. if( empty( $gContent ) || !is_object( $gContent ) ) {
  19.     $gContent = new LibertyContent();
  20. }
  21.  
  22. $contentTypeGuids = array();
  23. if( !empty( $_REQUEST['content_type_guid'] )) {
  24.     if( !is_array( $_REQUEST['content_type_guid'] )) {
  25.         $guids = explode( ",", $_REQUEST['content_type_guid'] );
  26.     } else {
  27.         $guids = $_REQUEST['content_type_guid'];
  28.     }
  29.     /**
  30.      * if an empty string was passed in an array (likely since it is used for ALL) then the user has requested all so return all
  31.      * even if they have requested additional content types too - ALL is ALL
  32.      * this check is reversed in that if no empty string in the array then we pass the array of content types to be limited on
  33.      **/
  34.  
  35.     if( !in_array( "", $guids ) ){
  36.         $contentTypeGuids = $guids;
  37.     }
  38. }
  39.  
  40. // get_content_list_inc doesn't use $_REQUEST parameters as it might not be the only list in the page that needs sorting and limiting
  41. if( empty( $contentListHash ) ) {
  42.     $contentListHash = array(
  43.         'content_type_guid' => $contentSelect = empty( $_REQUEST['content_type_guid'] ) ? NULL : $contentTypeGuids,
  44.         // pagination offset
  45.         'offset'            => !empty( $offset_content ) ? $offset_content : NULL,
  46.         // maximum number of records displayed on a page
  47.         'max_records'       => !empty( $max_content ) ? $max_content : ( !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : 100 ),
  48.         // sort by this: <table column>_asc (or _desc)
  49.         'sort_mode'         => !empty( $content_sort_mode ) ? $content_sort_mode : 'title_asc',
  50.         // limit the result to this set
  51.         'find'              => !empty( $_REQUEST["find"] ) ? $_REQUEST["find"] : NULL,
  52.         // display this page number - replaces antiquated offset
  53.         'page'              => !empty( $_REQUEST["list_page"] ) ? $_REQUEST["list_page"] : NULL,
  54.         // only display content by this user
  55.         'user_id'           => @BitBase::verifyId( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : NULL,
  56.         // only display content modified more recently than this (UTC timestamp)
  57.         'from_date'         => !empty( $_REQUEST["from_date"] ) ? $_REQUEST["from_date"] : NULL,
  58.         // only display content modified before this (UTC timestamp)
  59.         'until_date'        => !empty( $_REQUEST["until_date"] ) ? $_REQUEST["until_date"] : NULL,
  60.         // get a thumbnail - off by default because it is expensive
  61.         'thumbnail_size'    => !empty( $_REQUEST["thumbnail_size"] ) ? $_REQUEST["thumbnail_size"] : NULL,
  62.     );
  63.  
  64.     if( !empty( $_REQUEST['output'] ) && ( $_REQUEST['output'] == 'json' || $_REQUEST['output'] == 'ajax' ) ) {    
  65.         foreach( $_REQUEST as $key => $value ) {
  66.             if ( !is_array($value) ){
  67.                 if( strstr( $value, ',' ) ) {
  68.                     $_REQUEST[$key] = explode( ",", $value );
  69.                 }
  70.             }
  71.         }
  72.     }
  73.  
  74.     $contentListHash = array_merge( $_REQUEST, $contentListHash );
  75. }
  76.  
  77. // Finally we're ready to get some content
  78. $contentList = $gContent->getContentList( $contentListHash );
  79.  
  80. if( empty( $contentTypes ) ) {
  81.     $contentTypes = array( '' => tra( 'All Content' ) );
  82.     foreach( $gLibertySystem->mContentTypes as $cType ) {
  83.         $contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName( $cType['content_type_guid'], TRUE );
  84.     }
  85.     asort( $contentTypes );
  86. }
  87. global $gBitSystem, $gBitUser;
  88. if( $gBitSystem->isFeatureActive( 'liberty_display_status' ) &&  $gBitUser->hasPermission( 'p_liberty_view_all_status' )) {
  89.     $contentStatuses = $gContent->getAvailableContentStatuses();
  90.     $contentStatuses[''] = 'All Statuses';
  91.     $contentStatuses['not_available'] = 'All but Available';
  92.     $gBitSmarty->assign( 'content_statuses', $contentStatuses );
  93. }
  94. ?>

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