/**
  * Initilize settings based on the current stack of action variables and component etc
  */
 public function init()
 {
     $current_action = $this->get_variable(0);
     //on create or upload we don't need to setup Media or Gallery Query
     if ($current_action == 'create' || $current_action == 'upload') {
         mediapress()->set_action($current_action);
         mediapress()->set_edit_action($current_action);
         return;
     }
     //check for type/status
     $type_or_status = $this->get_variable(1);
     if ($current_action === 'type' && $type_or_status && mpp_is_active_type($type_or_status)) {
         $this->type = $type_or_status;
         mediapress()->is_gallery_home = true;
     } elseif ($current_action == 'status' && $type_or_status && mpp_is_active_status($type_or_status)) {
         $this->status = $type_or_status;
         mediapress()->is_gallery_home = true;
     } elseif ($gallery = mpp_gallery_exists($current_action, $this->component, $this->component_id)) {
         //Are we looking at single gallery? or Media?
         //current action in this case is checked for being  a gallery slug
         //setup current gallery & gallery query
         mediapress()->current_gallery = mpp_get_gallery($gallery);
         $this->gallery_id = $gallery->ID;
         $this->current_action = $this->get_variable(1);
         $this->current_manage_action = $this->get_variable(2);
         //setup pagination for single gallery media
         if ($this->get_variable(1) == 'page' && $this->get_variable(2) > 0) {
             $this->mpage = (int) $this->get_variable(2);
         }
     } else {
         if ($this->get_variable(0) == 'page' && $this->get_variable(1) > 0) {
             $this->gpage = (int) $this->get_variable(1);
         }
         //set it is the user galleries list view
         mediapress()->is_gallery_home = true;
     }
     //check and setup pagination args for status/type archives
     if ($this->get_variable(2) == 'page' && $this->get_variable(3) > 0) {
         $this->gpage = (int) $this->get_variable(3);
     }
 }
Example #2
0
 /**
  * Setup gallery for components like groups/events etc
  */
 public function setup_component_gallery()
 {
     //current_action = mpp_slug(mediapress)
     if (mpp_is_active_component(bp_current_component())) {
         //is Component Gallery enabled? and are we on the Component section?
         $current_action = bp_action_variable(0);
         if ($current_action == 'create' || $current_action == 'upload') {
             mediapress()->set_action($current_action);
             mediapress()->set_edit_action($current_action);
             return;
         }
         //Are we looking at single gallery? or Media?
         //current action in this case is checked for being  a gallery slug
         if ($this->action_variables && ($gallery = mpp_gallery_exists($this->action_variables[0], $this->component, $this->component_id))) {
             //setup current gallery & gallery query
             mediapress()->current_gallery = mpp_get_gallery($gallery);
             mediapress()->the_gallery_query = new MPP_Gallery_Query(array('id' => $gallery->ID));
             $this->current_action = bp_action_variable(1);
             $this->current_manage_action = bp_action_variable(2);
             if (!empty($this->action_variables[1]) && $this->action_variables[1] == 'page' && $this->action_variables[2] > 0) {
                 $this->mpage = (int) $this->action_variables[2];
             }
         } else {
             if ($this->action_variables && $this->action_variables[0] == 'page' && $this->action_variables[1] > 0) {
                 $this->gpage = (int) $this->action_variables[1];
             }
             $args = array('component_id' => $this->component_id, 'component' => $this->component, 'status' => $this->accessible_statuses);
             if ($this->gpage) {
                 $args['page'] = absint($this->gpage);
             }
             //we are on User gallery home page(gallery list)
             //we do need to check for the access level here and pass it to the query
             //how about gallery pagination?
             mediapress()->the_gallery_query = new MPP_Gallery_Query($args);
             //set it is the user galleries list view
             mediapress()->is_gallery_home = true;
         }
         //in this case, we are on the gallery directory, check if we have it enabled?
     }
 }