Advertisement
Guest User

Untitled

a guest
Apr 16th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1.     private $cache_exact_date = array();
  2.     private $cache_time_limit = array();
  3.     public function get_view_args_for_view( Ai1ec_Abstract_Query $request ) {
  4.         global $ai1ec_events_helper, $ai1ec_settings;
  5.         // Define arguments for specific calendar sub-view (month, agenda,
  6.         // posterboard, etc.)
  7.         // Preprocess action.
  8.         // Allow action w/ or w/o ai1ec_ prefix. Remove ai1ec_ if provided.
  9.         $action = $request->get( 'action' );
  10.  
  11.         if ( 0 === strncmp( $action, 'ai1ec_', 6 ) ) {
  12.             $action = substr( $action, 6 );
  13.         }
  14.         $view_args = $request->get_dict( array(
  15.             'post_ids',
  16.             'cat_ids',
  17.             'tag_ids',
  18.         ) );
  19.         $add_defaults = array(
  20.             'cat_ids' => 'default_categories',
  21.             'tag_ids' => 'default_tags',
  22.         );
  23.         foreach ( $add_defaults as $query => $default ) {
  24.             if ( empty( $view_args[$query] ) ) {
  25.                 $view_args[$query] = $ai1ec_settings->{$default};
  26.             }
  27.         }
  28.  
  29.         $type = $request->get( 'request_type' );
  30.  
  31.         $view_args['data_type'] = $this->return_data_type_for_request_type( $type );
  32.  
  33.  
  34.         $exact_date = $request->get( 'exact_date' );
  35.         if( false !== $exact_date ) {
  36.             if( ! isset( $this->cache_exact_date[$exact_date] ) ) {
  37.                 $this->cache_exact_date[$exact_date] = $this->get_exact_date( $request );
  38.             }
  39.             $exact_date = $this->cache_exact_date[$exact_date];
  40.         }
  41.         $view_args['no_navigation'] = $request->get( 'no_navigation' ) === 'true' ? true : false;
  42.  
  43.         // Find out which view of the calendar page was requested, and render it
  44.         // accordingly.
  45.         $view_args['action'] = $action;
  46.         switch( $action ) {
  47.             case 'posterboard':
  48.             case 'stream':
  49.             case 'agenda':
  50.                 $view_args += $request->get_dict( array(
  51.                 'page_offset',
  52.                 'time_limit',
  53.                 ) );
  54.                 if( false !== $exact_date ) {
  55.                     if( ! isset( $this->cache_time_limit[$exact_date] ) ) {
  56.                         $this->cache_time_limit[$exact_date] = $ai1ec_events_helper->local_to_gmt( $exact_date ) - 1;
  57.                     }
  58.                     $view_args['time_limit'] = $this->cache_time_limit[$exact_date];
  59.                 }
  60.                
  61.                 break;
  62.  
  63.             case 'month':
  64.             case 'oneday':
  65.             case 'week':
  66.                 $view_args["{$action}_offset"] = $request->get( "{$action}_offset" );
  67.                 if( false !== $exact_date ) {
  68.                     $view_args['exact_date'] = $exact_date;
  69.                 }
  70.                 break;
  71.         }
  72.         $view_args['request'] = $request;
  73.         return $view_args;
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement