Exemplo n.º 1
0
 public function build()
 {
     /** property listing model **/
     $this->model = new wpl_property();
     $property = (array) $this->model->get_property_raw_data($this->pid);
     /** no property found **/
     if (!$property) {
         $this->error = "ERROR: Property id is not valid.";
         return false;
     }
     $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'");
     /** BUILD **/
     $this->built['listing']['raw'] = $property;
     $find_files = array();
     $rendered_fields = $this->model->render_property($property, $this->pshow_fields, $find_files, true);
     $this->built['listing']['materials'] = $rendered_fields['columns'];
     foreach ($this->pshow_categories as $pshow_category) {
         $pshow_cat_fields = $this->model->get_pshow_fields($pshow_category->id, $property['kind']);
         $this->built['listing']['rendered'][$pshow_category->id]['self'] = (array) $pshow_category;
         $this->built['listing']['rendered'][$pshow_category->id]['data'] = $this->model->render_property($property, $pshow_cat_fields);
     }
     $items = wpl_items::get_items($this->pid, '', $property['kind'], '', 1);
     /** render gallery **/
     $this->built['listing']['images'] = wpl_items::render_gallery($items['gallery']);
     /** render attachments **/
     $this->built['listing']['attachments'] = wpl_items::render_attachments($items['attachment']);
     /** render videos **/
     $this->built['listing']['videos'] = wpl_items::render_videos($items['video']);
     /** render rooms **/
     $this->built['listing']['rooms'] = $items['rooms'];
     /** render gallery custom sizes **/
     if (is_array($this->image_sizes)) {
         $this->built['listing']['custom_sizes'] = wpl_items::render_gallery_custom_sizes($this->pid, $items['gallery'], $this->image_sizes);
     }
     /** property full link **/
     $this->built['listing']['property_link'] = $this->model->get_property_link($property);
     /** location text **/
     $this->built['listing']['location_text'] = $property['location_text'];
     /** render agent data **/
     $rendered_agent = wpl_users::full_render($property['user_id']);
     unset($rendered_agent['data']);
     $this->built['listing']['agent'] = $rendered_agent;
     /** updating the visited times and etc **/
     $this->model->property_visited($this->pid);
     return $this->built;
 }
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 wizard($instance = array())
 {
     /** load assets **/
     $this->load_assets();
     /** check access **/
     if (!wpl_users::check_access('propertywizard')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message');
     }
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     $this->property_id = trim(wpl_request::getVar('pid')) != '' ? wpl_request::getVar('pid') : 0;
     $this->mode = $this->property_id ? 'edit' : 'add';
     if ($this->mode == 'add') {
         /** checking access **/
         if (!wpl_users::check_access($this->mode)) {
             $this->message = __("Limit reached. You can not add more property!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** generate new property **/
         $this->property_id = wpl_property::create_property_default('', $this->kind);
     }
     $this->values = wpl_property::get_property_raw_data($this->property_id);
     $this->finalized = isset($this->values['finalized']) ? $this->values['finalized'] : 0;
     $this->kind = isset($this->values['kind']) ? $this->values['kind'] : 0;
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     if ($this->mode == 'edit') {
         if (!$this->values) {
             $this->message = __("Property does not exist!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** checking access **/
         if (!wpl_users::check_access($this->mode, $this->values['user_id'])) {
             $this->message = __("You can not edit this property.", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
     }
     /** import tpl **/
     $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, 'wizard', $this->kind);
     parent::render($this->tpl_path, $this->tpl);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 public function generate_backend_categories_tabs($values)
 {
     $categories = wpl_flex::get_categories(1, $this->kind, " AND `searchmod`=1 AND `kind`='{$this->kind}' AND `enabled`>=1");
     // Tabs
     foreach ($categories as $category) {
         $path = 'widgets.search.scripts.fields_category_tabs';
         include _wpl_import($path, true, true);
     }
 }