Exemple #1
0
 /**
  * Calls WPL views
  * @author Howard <*****@*****.**>
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $ex = explode(':', $method);
     $this->_wpl_client = array_search($this->_wpl_clients[$ex[0]], $this->_wpl_clients) ? $this->_wpl_clients[$ex[0]] : 'frontend';
     $this->_wpl_folder = $ex[1];
     $this->_wpl_file = 'wpl_main';
     $this->_wpl_class = 'wpl_' . $ex[1] . '_controller';
     $_wpl_function = trim($ex[2]) != '' ? $ex[2] : 'display';
     _wpl_import('views.' . $this->_wpl_client . '.' . $this->_wpl_folder . '.' . $this->_wpl_file);
     $_wpl_obj = new $this->_wpl_class();
     /** parameter of shortcode (setted by user) **/
     $instance = (array) $args[0];
     /** set the parameters **/
     foreach ($instance as $key => $value) {
         wpl_request::setVar($key, $value, 'method', $this->parameter_overwrite);
     }
     if ($this->_wpl_client == 'frontend') {
         /** call the function **/
         return $_wpl_obj->{$_wpl_function}($instance);
     }
     if ($this->_wpl_client == 'backend') {
         $_wpl_obj->wrapper = 1;
     }
     /** call the function **/
     $_wpl_obj->{$_wpl_function}($instance);
 }
 public function display($instance = array())
 {
     $this->uid = wpl_request::getVar('uid', 0);
     if (!$this->uid) {
         $this->uid = wpl_request::getVar('sf_select_user_id', 0);
         wpl_request::setVar('uid', $this->uid);
     }
     /** check user id **/
     if (!$this->uid) {
         /** import message tpl **/
         $this->message = __("No profile found or it's not available now!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** set the user id to search credentials **/
     wpl_request::setVar('sf_select_user_id', $this->uid);
     /** set the kind **/
     $this->kind = wpl_request::getVar('kind', '0');
     wpl_request::setVar('kind', $this->kind);
     /** User Type **/
     $this->user_type = wpl_users::get_user_user_type($this->uid);
     /** trigger event **/
     wpl_global::event_handler('profile_show', array('id' => $this->uid, 'kind' => $this->kind));
     /** import tpl **/
     $this->tpl = wpl_users::get_user_type_tpl($this->tpl_path, $this->tpl, $this->user_type);
     /** import tpl **/
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }
Exemple #3
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;
 }
 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);
 }
Exemple #5
0
 /**
  * Switch to a new language
  * @author Howard <*****@*****.**>
  * @static
  * @param string $language
  * @return boolean
  */
 public static function switch_language($language)
 {
     $path = wpl_global::get_language_mo_path($language);
     $result = wpl_global::load_textdomain(WPL_TEXTDOMAIN, $path);
     if ($result) {
         wpl_request::setVar('wpllang', $language);
     }
     return $result;
 }
 public function display($instance = array())
 {
     /** do cronjobs **/
     _wpl_import('libraries.events');
     wpl_events::do_cronjobs();
     /** check access **/
     if (!wpl_users::check_access('propertyshow')) {
         /** 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');
     /** property listing model **/
     $this->model = new wpl_property();
     $this->pid = wpl_request::getVar('pid', 0);
     $listing_id = wpl_request::getVar('mls_id', 0);
     if (trim($listing_id)) {
         $this->pid = wpl_property::pid($listing_id);
         wpl_request::setVar('pid', $this->pid);
     }
     $property = $this->model->get_property_raw_data($this->pid);
     /** no property found **/
     if (!$property or $property['finalized'] == 0 or $property['confirmed'] == 0 or $property['deleted'] == 1 or $property['expired'] >= 1) {
         /** import message tpl **/
         $this->message = __("No property found or it's not available now!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     $this->pshow_fields = $this->model->get_pshow_fields('', $property['kind']);
     $this->pshow_categories = wpl_flex::get_categories('', '', " AND `enabled`>='1' AND `kind`='" . $property['kind'] . "' AND `pshow`='1'");
     $wpl_properties = array();
     /** define current index **/
     $wpl_properties['current']['data'] = (array) $property;
     $wpl_properties['current']['raw'] = (array) $property;
     $find_files = array();
     $rendered_fields = $this->model->render_property($property, $this->pshow_fields, $find_files, true);
     $wpl_properties['current']['rendered_raw'] = $rendered_fields['ids'];
     $wpl_properties['current']['materials'] = $rendered_fields['columns'];
     foreach ($this->pshow_categories as $pshow_category) {
         $pshow_cat_fields = $this->model->get_pshow_fields($pshow_category->id, $property['kind']);
         $wpl_properties['current']['rendered'][$pshow_category->id]['self'] = (array) $pshow_category;
         $wpl_properties['current']['rendered'][$pshow_category->id]['data'] = $this->model->render_property($property, $pshow_cat_fields);
     }
     $wpl_properties['current']['items'] = wpl_items::get_items($this->pid, '', $property['kind'], '', 1);
     /** property location text **/
     $wpl_properties['current']['location_text'] = $this->model->generate_location_text((array) $property);
     /** property full link **/
     $wpl_properties['current']['property_link'] = $this->model->get_property_link((array) $property);
     /** property page title **/
     $wpl_properties['current']['property_page_title'] = $this->model->update_property_page_title($property);
     /** property title **/
     $wpl_properties['current']['property_title'] = $this->model->update_property_title($property);
     /** 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->wpl_properties = $wpl_properties;
     $this->kind = $property['kind'];
     $this->property = $wpl_properties['current'];
     /** updating the visited times and etc **/
     wpl_property::property_visited($this->pid);
     /** trigger event **/
     wpl_global::event_handler('property_show', array('id' => $this->pid));
     /** 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);
 }
Exemple #7
0
 /**
  * Sets WPL view to wplview variable. This function sets other parameters as well in $_REQUEST
  * @author Howard R <*****@*****.**>
  * @static
  * @return void
  */
 public static function set_view()
 {
     /** set view **/
     $wplview = wpl_request::getVar('wplview', '');
     if (trim($wplview) != '') {
         return;
     }
     /** checking wordpress post type (post, page, any kind of posts and ...) **/
     if (!is_page() and !is_single()) {
         return;
     }
     /** getting the post id and post content **/
     $post_id = wpl_global::get_the_ID();
     $post_content = wpl_db::get('post_content', 'posts', 'id', $post_id);
     $wplview = '';
     if (strpos($post_content, '[wpl_property_listings') !== false or strpos($post_content, '[WPL') !== false) {
         $wplview = 'property_listing';
     } elseif (strpos($post_content, '[wpl_property_show') !== false) {
         $wplview = 'property_show';
     } elseif (strpos($post_content, '[wpl_profile_listing') !== false) {
         $wplview = 'profile_listing';
     } elseif (strpos($post_content, '[wpl_profile_show') !== false) {
         $wplview = 'profile_show';
     } elseif (strpos($post_content, '[wpl_my_profile') !== false) {
         $wplview = 'profile_wizard';
     } elseif (strpos($post_content, '[wpl_add_edit_listing') !== false) {
         $wplview = 'property_wizard';
     } elseif (strpos($post_content, '[wpl_listing_manager') !== false) {
         $wplview = 'property_manager';
     } elseif (strpos($post_content, '[wpl_payments') !== false) {
         $wplview = 'payments';
     } elseif (strpos($post_content, '[wpl_addon_') !== false) {
         $pos1 = strpos($post_content, '[wpl_addon_');
         $pos2 = strpos($post_content, ' ', $pos1);
         if ($pos2 === false) {
             $pos2 = strpos($post_content, ']', $pos1);
         }
         $shortcode = trim(substr($post_content, $pos1, $pos2 - $pos1), '[_ ]');
         $shortcode = str_replace('wpl_', '', $shortcode);
         $wplview = $shortcode;
     } elseif (strpos($post_content, '[wpl_custom_') !== false) {
         $wplview = 'wpl_custom_view';
     }
     /** set view **/
     if (trim($wplview) != '') {
         wpl_request::setVar('wplview', $wplview);
     }
     $pattern = get_shortcode_regex();
     preg_match('/' . $pattern . '/s', $post_content, $matches);
     $wpl_shortcodes = array('WPL', 'wpl_property_listings', 'wpl_property_show', 'wpl_profile_listing', 'wpl_profile_show', 'wpl_my_profile', 'wpl_add_edit_listing', 'wpl_listing_manager');
     if (is_array($matches) and isset($matches[2]) and in_array($matches[2], $wpl_shortcodes)) {
         $shortcode = $matches[0];
         $params_str = trim($matches[3], ', ');
         if (trim($params_str) != '') {
             $attributes = shortcode_parse_atts($params_str);
             foreach ($attributes as $key => $value) {
                 if (trim($key) == '') {
                     continue;
                 }
                 wpl_request::setVar($key, $value, 'method', false);
             }
         }
     }
 }
 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);
 }
Exemple #9
0
 private function set_pcc()
 {
     $pcc = wpl_request::getVar('pcc', '');
     setcookie('wplpcc', $pcc, time() + 86400 * 30, '/');
     wpl_request::setVar('wplpcc', $pcc, 'COOKIE');
     echo json_encode(array('success' => 1));
     exit;
 }