/**
  * Build page title
  *
  * @access	private
  */
 private function build_title()
 {
     if (VPost::search_button(false) || VGet::search()) {
         $this->_title = 'Posts > Search results for "' . $this->_search . '"';
     } elseif ($this->_status != 'all') {
         $this->_title = ucfirst($this->_status) . 'ed Posts';
     } else {
         $this->_title = 'Posts';
     }
 }
 /**
  * Retrieve wanted medias metadata from the database
  *
  * @access	private
  */
 private function get_medias()
 {
     try {
         $to_read['table'] = 'media';
         $to_read['columns'] = array('MEDIA_ID');
         if (VPost::search_button(false) || VGet::search()) {
             $to_read['condition_columns'][':name'] = 'media_name';
             $to_read['condition_select_types'][':name'] = 'LIKE';
             $to_read['condition_values'][':name'] = '%' . $this->_search . '%';
             $to_read['value_types'][':name'] = 'str';
         } elseif (VRequest::filter(false)) {
             if (VRequest::date('all') !== 'all') {
                 $to_read['condition_columns'][':date'] = 'media_date';
                 $to_read['condition_select_types'][':date'] = 'LIKE';
                 $to_read['condition_values'][':date'] = VRequest::date('1970-01') . '%';
                 $to_read['value_types'][':date'] = 'str';
             }
             if (VRequest::category('all') !== 'all') {
                 $to_read['condition_types'][':cat'] = 'AND';
                 $to_read['condition_columns'][':cat'] = 'media_category';
                 $to_read['condition_select_types'][':cat'] = 'LIKE';
                 $to_read['condition_values'][':cat'] = '%' . VRequest::category() . '%';
                 $to_read['value_types'][':cat'] = 'str';
             }
         } elseif (VGet::action() == 'edit' && VGet::id()) {
             $to_read['condition_columns'][':id'] = 'MEDIA_ID';
             $to_read['condition_select_types'][':id'] = '=';
             $to_read['condition_values'][':id'] = VGet::id();
             $to_read['value_types'][':id'] = 'int';
         } elseif (VGet::author()) {
             $to_read['condition_columns'][':author'] = 'media_author';
             $to_read['condition_select_types'][':author'] = '=';
             $to_read['condition_values'][':author'] = VGet::author();
             $to_read['value_types'][':author'] = 'int';
         }
         $to_read['condition_types'][':type'] = 'AND';
         $to_read['condition_columns'][':type'] = 'media_type';
         $to_read['condition_select_types'][':type'] = 'LIKE';
         $to_read['condition_values'][':type'] = $this->_view_type . '%';
         $to_read['value_types'][':type'] = 'str';
         $to_read['condition_types'][':album'] = 'AND';
         $to_read['condition_columns'][':album'] = 'media_album';
         $to_read['condition_select_types'][':album'] = '=';
         $to_read['condition_values'][':album'] = '0';
         $to_read['value_types'][':album'] = 'int';
         //pass $to_read by parameter to have same conditions
         $this->get_pagination($to_read);
         $this->get_dates($to_read);
         $to_read['order'] = array('media_date', 'desc');
         $to_read['limit'] = array($this->_limit_start, parent::ITEMS);
         $this->_medias = $this->_db->read($to_read);
         if (!empty($this->_medias)) {
             foreach ($this->_medias as &$item) {
                 $item = new Media($item['MEDIA_ID']);
                 $user = new User();
                 $user->_id = $item->_author;
                 $user->read('_username');
                 $item->_author_name = $user->_username;
             }
         } elseif (empty($this->_medias) && VGet::action() == 'edit') {
             throw new Exception('Invalid media!');
         }
     } catch (Exception $e) {
         $this->_action_msg = ActionMessages::custom_wrong($e->getMessage());
         $this->_medias = null;
         $this->_medias[0] = new Media();
     }
 }
 /**
  * Build the html page title
  *
  * @access	private
  */
 private function build_title()
 {
     if (VGet::action() == 'reply') {
         return 'Comment > in reponse to "' . VGet::comment_name() . '"';
     } elseif (VGet::action() == 'edit') {
         return 'Edit Comment';
     } elseif (VPost::search_button(false) || VGet::search()) {
         return 'Comments > Search results for "' . $this->_search . '"';
     } else {
         return 'Comments';
     }
 }
 /**
  * Retrieve albums from the database
  *
  * @access	private
  */
 private function get_albums()
 {
     try {
         $to_read['table'] = 'media';
         $to_read['columns'] = array('MEDIA_ID');
         $to_read['condition_columns'][':t'] = 'media_type';
         $to_read['condition_select_types'][':t'] = '=';
         $to_read['condition_values'][':t'] = 'album';
         $to_read['value_types'][':t'] = 'str';
         $to_read['order'] = array('media_date', 'DESC');
         if (VRequest::filter(false)) {
             if (VRequest::date() != 'all') {
                 $to_read['condition_types'][':d'] = 'AND';
                 $to_read['condition_columns'][':d'] = 'media_date';
                 $to_read['condition_select_types'][':d'] = 'LIKE';
                 $to_read['condition_values'][':d'] = VRequest::date('1970-01') . '%';
                 $to_read['value_types'][':d'] = 'str';
             }
             if (VRequest::category() != 'all') {
                 $to_read['condition_types'][':c'] = 'AND';
                 $to_read['condition_columns'][':c'] = 'media_category';
                 $to_read['condition_select_types'][':c'] = 'LIKE';
                 $to_read['condition_values'][':c'] = '%' . VRequest::category() . '%';
                 $to_read['value_types'][':c'] = 'str';
             }
         } elseif (VPost::search_button(false) || VGet::search()) {
             $to_read['condition_types'][':n'] = 'AND';
             $to_read['condition_columns'][':n'] = 'media_name';
             $to_read['condition_select_types'][':n'] = 'LIKE';
             $to_read['condition_values'][':n'] = '%' . $this->_search . '%';
             $to_read['value_types'][':n'] = 'str';
         } elseif ((VGet::action() == 'edit' || VGet::action() == 'upload' || VGet::action() == 'edit_image') && VGet::id()) {
             $to_read['condition_types'][':id'] = 'AND';
             $to_read['condition_columns'][':id'] = 'MEDIA_ID';
             $to_read['condition_select_types'][':id'] = '=';
             $to_read['condition_values'][':id'] = VGet::id();
             $to_read['value_types'][':id'] = 'int';
             if (VGet::action() == 'edit') {
                 $this->get_pictures();
             } elseif (VGet::action() == 'edit_image' && VGet::pid()) {
                 $this->get_picture();
             }
         }
         //pass $to_read by parameter to have same conditions
         $this->get_pagination($to_read);
         $this->get_dates($to_read);
         $to_read['order'] = array('media_date', 'desc');
         $to_read['limit'] = array($this->_limit_start, parent::ITEMS);
         $this->_albums = $this->_db->read($to_read);
         if (!empty($this->_albums)) {
             foreach ($this->_albums as &$album) {
                 $album = new Media($album['MEDIA_ID']);
                 $user = new User();
                 $user->_id = $album->_author;
                 $user->read('_username');
                 $album->_author_name = $user->_username;
             }
         } elseif (empty($this->_content) && (VGet::action() == 'edit' || VGet::action() == 'upload')) {
             $this->_albums[0] = new Media();
             throw new Exception('Invalid album!');
         }
     } catch (Exception $e) {
         $this->_action_msg = ActionMessages::custom_wrong($e->getMessage());
     }
 }