Exemplo n.º 1
0
 /**
  * written by Francis
  * description: initialize pagination and properties for property manager page
  */
 private function init_page()
 {
     /** global settings **/
     $settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1);
     $limit = wpl_request::getVar('limit', $settings['default_page_size']);
     $start = wpl_request::getVar('start', ($this->page_number - 1) * $limit);
     $orderby = wpl_request::getVar('orderby', $settings['default_orderby']);
     $order = wpl_request::getVar('order', $settings['default_order']);
     $current_user_id = wpl_users::get_cur_user_id();
     $where = array();
     /** set page if start var passed **/
     $this->page_number = $start / $limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     $this->model = new wpl_property();
     /** load user properties **/
     if (!wpl_users::is_administrator($current_user_id)) {
         $where['sf_select_user_id'] = $current_user_id;
     }
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 0);
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         parent::render($this->tpl_path, 'message');
         return false;
     }
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $where['sf_select_kind'] = $this->kind;
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     $this->model->start($start, $limit, $orderby, $order, $where, $this->kind);
     $query = $this->model->query();
     $properties = $this->model->search($query);
     $this->model->finish();
     /** get the number of all properties according to our query **/
     $properties_count = $this->model->get_properties_count();
     /** set pagination according to the number of items and limit **/
     $this->pagination = wpl_pagination::get_pagination($properties_count, $limit);
     $plisting_fields = $this->model->get_plisting_fields();
     $wpl_properties = array();
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $this->model->full_render($property->id, $plisting_fields, $property);
     }
     $this->wpl_properties = $wpl_properties;
     return true;
 }
Exemplo n.º 2
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         $this->message = __('Invalid Kind!', WPL_TEXTDOMAIN);
         /** import tpl **/
         return parent::render($this->tpl_path, 'message');
     }
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $this->dbst_types = wpl_flex::get_dbst_types(1, $this->kind);
     $this->new_dbst_id = wpl_flex::get_new_dbst_id();
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
Exemplo n.º 3
0
 public function display($instance = array())
 {
     /** check access **/
     if (!wpl_users::check_access('propertylisting')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     $this->tpl = wpl_request::getVar('tpl', 'default');
     $this->method = wpl_request::getVar('wplmethod', NULL);
     /** global settings **/
     $this->settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1, '', true);
     $this->limit = wpl_request::getVar('limit', $this->settings['default_page_size']);
     $this->start = wpl_request::getVar('start', ($this->page_number - 1) * $this->limit, '', true);
     $this->orderby = wpl_request::getVar('wplorderby', $this->settings['default_orderby'], '', true);
     $this->order = wpl_request::getVar('wplorder', $this->settings['default_order'], '', true);
     /** Set Property CSS class **/
     $this->property_css_class = !$this->wplraw ? wpl_request::getVar('wplpcc', NULL) : NULL;
     if (!$this->property_css_class) {
         $this->property_css_class = wpl_request::getVar('wplpcc', 'grid_box', 'COOKIE');
     }
     $this->property_css_class_switcher = wpl_request::getVar('wplpcc_switcher', '1');
     $this->property_listview = wpl_request::getVar('wplplv', '1');
     #Show listview or not
     /** RSS Feed Setting **/
     $this->listings_rss_enabled = isset($this->settings['listings_rss_enabled']) ? $this->settings['listings_rss_enabled'] : 0;
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 0);
     if (!$this->kind) {
         $this->kind = wpl_request::getVar('sf_select_kind', 0);
     }
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** pagination types **/
     $this->wplpagination = wpl_request::getVar('wplpagination', 'normal', '', true);
     wpl_request::setVar('wplpagination', $this->wplpagination);
     /** property listing model **/
     $this->model = new wpl_property();
     /** set page if start var passed **/
     $this->page_number = $this->start / $this->limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     $where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $this->kind);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $where, $this->kind);
     $this->model->total = $this->model->get_properties_count();
     /** validation for page_number **/
     $this->total_pages = ceil($this->model->total / $this->limit);
     if ($this->page_number <= 0 or $this->page_number > $this->total_pages) {
         $this->model->start = 0;
     }
     /** run the search **/
     $query = $this->model->query();
     $properties = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields('', $this->kind);
     $wpl_properties = array();
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $this->model->full_render($property->id, $plisting_fields, $property);
     }
     /** define current index **/
     $wpl_properties['current'] = array();
     /** apply filters (This filter must place after all proccess) **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('property_listing_after_render', array('wpl_properties' => $wpl_properties)));
     $this->pagination = wpl_pagination::get_pagination($this->model->total, $this->limit, true, $this->wplraw);
     $this->wpl_properties = $wpl_properties;
     if ($this->wplraw and $this->method == 'get_markers') {
         $markers = array('markers' => $this->model->render_markers($wpl_properties), 'total' => $this->model->total);
         echo json_encode($markers);
         exit;
     } elseif ($this->wplraw and $this->method == 'get_listings') {
         if ($this->return_listings) {
             return $wpl_properties;
         } else {
             echo json_encode($wpl_properties);
             exit;
         }
     }
     /** import tpl **/
     $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, $this->tpl, $this->kind);
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }
Exemplo n.º 4
0
 public function build()
 {
     /** property listing model **/
     $this->model = new wpl_property();
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         $this->error = "ERROR: Invalid property kind!";
         return false;
     }
     $default_where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $this->kind);
     $this->where = array_merge($default_where, $this->where);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $this->where = array_merge($vars, $this->where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $this->where);
     $this->model->total = $this->model->get_properties_count();
     $this->built['listings']['total'] = $this->model->total;
     /** run the search **/
     $query = $this->model->query();
     $properties = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields();
     foreach ($properties as $property) {
         $rendered = array();
         $rendered = $this->model->full_render($property->id, $plisting_fields, $property);
         $rendered['property_id'] = $property->id;
         $items = $rendered['items'];
         /** render gallery **/
         if ($this->pictures) {
             $rendered['images'] = wpl_items::render_gallery($items['gallery']);
         }
         /** render attachments **/
         if ($this->attachments) {
             $rendered['attachments'] = wpl_items::render_attachments($items['attachment']);
         }
         /** render videos **/
         if ($this->videos) {
             $rendered['videos'] = wpl_items::render_videos($items['video']);
         }
         /** render rooms **/
         if ($this->rooms) {
             $rendered['rooms'] = $items['rooms'];
         }
         /** render gallery custom sizes **/
         if (is_array($this->image_sizes)) {
             $rendered['custom_sizes'] = wpl_items::render_gallery_custom_sizes($property_id, $items['gallery'], $this->image_sizes);
         }
         /** render agent data **/
         if ($this->agentinfo) {
             $rendered['agent'] = wpl_users::full_render($property->user_id);
             unset($rendered['agent']['data']);
             unset($rendered['agent']['items']);
         }
         unset($rendered['items']);
         $this->built['listings'][$property->id] = $rendered;
     }
     return $this->built;
 }
Exemplo n.º 5
0
 public function display($instance = array())
 {
     /** property listing model **/
     $this->model = new wpl_users();
     /** global settings **/
     $settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1, '', true);
     $this->limit = wpl_request::getVar('limit', $settings['default_profile_page_size'], '', true);
     $this->start = wpl_request::getVar('start', ($this->page_number - 1) * $this->limit, '', true);
     $this->orderby = wpl_request::getVar('wplorderby', $settings['default_profile_orderby'], '', true);
     $this->order = wpl_request::getVar('wplorder', $settings['default_profile_order'], '', true);
     /** Set Property CSS class **/
     $this->property_css_class = wpl_request::getVar('wplpcc', NULL);
     if (!$this->property_css_class) {
         $this->property_css_class = wpl_request::getVar('wplpcc', 'grid_box', 'COOKIE');
     }
     $this->property_css_class_switcher = wpl_request::getVar('wplpcc_switcher', '1');
     /** set page if start var passed **/
     $this->page_number = $this->start / $this->limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 2);
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** pagination types **/
     $this->wplpagination = wpl_request::getVar('wplpagination', 'normal', '', true);
     wpl_request::setVar('wplpagination', $this->wplpagination);
     $where = array('sf_tmin_id' => 1, 'sf_select_access_public_profile' => 1, 'sf_select_expired' => 0);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $where);
     $this->model->total = $this->model->get_users_count();
     /** validation for page_number **/
     $this->total_pages = ceil($this->model->total / $this->limit);
     if ($this->page_number <= 0 or $this->page_number > $this->total_pages) {
         $this->model->start = 0;
     }
     /** run the search **/
     $query = $this->model->query();
     $profiles = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields();
     $wpl_profiles = array();
     foreach ($profiles as $profile) {
         $wpl_profiles[$profile->id] = $this->model->full_render($profile->id, $plisting_fields);
     }
     /** define current index **/
     $wpl_profiles['current'] = array();
     /** apply filters (This filter must place after all proccess) **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('profile_listing_after_render', array('wpl_profiles' => $wpl_profiles)));
     $this->pagination = wpl_pagination::get_pagination($this->model->total, $this->limit, true);
     $this->wpl_profiles = $wpl_profiles;
     /** import tpl **/
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }