public function home() { /** check permission **/ wpl_global::min_access('administrator'); $this->level = trim(wpl_request::getVar('level')) != '' ? wpl_request::getVar('level') : 1; $this->parent = trim(wpl_request::getVar('sf_select_parent')) != '' ? wpl_request::getVar('sf_select_parent') : ""; $this->enabled = trim(wpl_request::getVar('sf_select_enabled')) != '' ? wpl_request::getVar('sf_select_enabled') : 1; $this->text_search = trim(wpl_request::getVar('sf_text_name')) != '' ? wpl_request::getVar('sf_text_name') : ''; $this->admin_url = wpl_global::get_wp_admin_url(); $this->load_zipcodes = trim(wpl_request::getVar('load_zipcodes')) != '' ? 1 : 0; /** set show all based on level **/ if ($this->level != 1) { $this->enabled = ''; } $possible_orders = array('id', 'name'); $orderby = in_array(wpl_request::getVar('orderby'), $possible_orders) ? wpl_request::getVar('orderby') : $possible_orders[0]; $order = in_array(strtoupper(wpl_request::getVar('order')), array('ASC', 'DESC')) ? wpl_request::getVar('order') : 'ASC'; $page_size = trim(wpl_request::getVar('page_size')) != '' ? wpl_request::getVar('page_size') : NULL; /** create where **/ $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET')); $vars = array_merge($vars, array('sf_select_parent' => $this->parent, 'sf_select_enabled' => $this->enabled)); $where_query = wpl_db::create_query($vars); $num_result = wpl_db::num("SELECT COUNT(id) FROM `#__wpl_location" . $this->level . "` WHERE 1 " . $where_query); $this->pagination = wpl_pagination::get_pagination($num_result, $page_size); $where_query .= " ORDER BY {$orderby} {$order} " . $this->pagination->limit_query; $this->wp_locations = wpl_locations::get_locations(!$this->load_zipcodes ? $this->level : 'zips', '', '', $where_query); $this->zipcode_parent_level = wpl_settings::get('zipcode_parent_level'); /** import tpl **/ parent::render($this->tpl_path, $this->tpl); }
protected function generate_slide($category) { $tpl = 'internal_slide'; $this->settings = wpl_settings::get_settings($category->id, 1, true); $this->setting_category = $category; /** import tpl **/ parent::render($this->tpl_path, $tpl); }
/** * 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; }
/** * Running installation queries and initializing WPL * @author Howard <*****@*****.**> * @return void */ public function activate_wpl() { if (wpl_folder::exists(WPL_ABSPATH . 'assets' . DS . 'install' . DS . 'files')) { /** copy files **/ $res = wpl_folder::copy(WPL_ABSPATH . 'assets' . DS . 'install' . DS . 'files', ABSPATH, '', true); /** delete files **/ wpl_folder::delete(WPL_ABSPATH . 'assets' . DS . 'install' . DS . 'files'); } /** run queries **/ $query_file = WPL_ABSPATH . 'assets' . DS . 'install' . DS . 'queries.sql'; if (wpl_file::exists($query_file)) { $queries = wpl_file::read($query_file); $queries = str_replace(";\r\n", "-=++=-", $queries); $queries = str_replace(";\r", "-=++=-", $queries); $queries = str_replace(";\n", "-=++=-", $queries); $sqls = explode("-=++=-", $queries); if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) { $original_blog_id = wpl_global::get_current_blog_id(); // Get all blogs $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn'); foreach ($blogs as $blog) { if (!isset($blog->blog_id)) { continue; } switch_to_blog($blog->blog_id); foreach ($sqls as $sql) { try { wpl_db::q($sql); } catch (Exception $e) { } } } /** delete query file **/ wpl_file::delete($query_file); switch_to_blog($original_blog_id); } else { foreach ($sqls as $sql) { try { wpl_db::q($sql); } catch (Exception $e) { } } /** delete query file **/ wpl_file::delete($query_file); } } /** run script **/ $script_file = WPL_ABSPATH . 'assets' . DS . 'install' . DS . 'script.php'; if (wpl_file::exists($script_file)) { include $script_file; /** delete script file **/ wpl_file::delete($script_file); } if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) { $original_blog_id = wpl_global::get_current_blog_id(); // Get all blogs $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn'); foreach ($blogs as $blog) { if (!isset($blog->blog_id)) { continue; } switch_to_blog($blog->blog_id); /** create propertylisting page **/ $pages = array('Properties' => '[WPL]', 'For Sale' => '[WPL sf_select_listing="9"]', 'For Rent' => '[WPL sf_select_listing="10"]', 'Vacation Rental' => '[WPL sf_select_listing="12"]'); foreach ($pages as $title => $content) { if (wpl_db::select("SELECT COUNT(post_content) FROM `#__posts` WHERE `post_content` LIKE '%{$content}%' AND `post_status` IN ('publish', 'private')", 'loadResult') != 0) { continue; } $post = array('post_title' => $title, 'post_content' => $content, 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_author' => 1); $post_id = wp_insert_post($post); if ($content == '[WPL]') { _wpl_import('libraries.settings'); wpl_settings::save_setting('main_permalink', $post_id); } } /** Add admin user to WPL **/ wpl_users::add_user_to_wpl(1); } switch_to_blog($original_blog_id); } else { /** create propertylisting page **/ $pages = array('Properties' => '[WPL]', 'For Sale' => '[WPL sf_select_listing="9"]', 'For Rent' => '[WPL sf_select_listing="10"]', 'Vacation Rental' => '[WPL sf_select_listing="12"]'); foreach ($pages as $title => $content) { if (wpl_db::select("SELECT COUNT(post_content) FROM `#__posts` WHERE `post_content` LIKE '%{$content}%' AND `post_status` IN ('publish', 'private')", 'loadResult') != 0) { continue; } $post = array('post_title' => $title, 'post_content' => $content, 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_author' => 1); $post_id = wp_insert_post($post); if ($content == '[WPL]') { _wpl_import('libraries.settings'); wpl_settings::save_setting('main_permalink', $post_id); } } /** Add admin user to WPL **/ wpl_users::add_user_to_wpl(1); } /** upgrade WPL **/ self::upgrade_wpl(); }
function __construct($username, $password, $vars, $settings) { /** smart set of settings **/ foreach ($settings as $setting => $setval) { if ($setval != '') { $this->settings[$setting] = $setval; } } // Authenticating if ($username != '') { $authenticate = wpl_users::authenticate($username, $password); if ($authenticate['status'] != 1) { $this->error = "ERROR: Authentication failed!"; return false; } $this->uid = $authenticate['uid']; } else { $this->uid = 0; } if (!wpl_global::check_access($this->settings['access_view'], $this->uid)) { $this->error = "ERROR: No access to the command!"; return false; } /** global settings **/ $this->wpl_settings = wpl_settings::get_settings(); $this->orderby = $this->wpl_settings['default_orderby']; $this->order = $this->wpl_settings['default_order']; // Include Thumbnails if (trim($vars['ithmb']) != '' and in_array($vars['ithmb'], array('0', '1'))) { $this->include_thumbnails = $vars['ithmb']; } // get special keys if (trim($vars['get_special_key']) != '' and in_array($vars['get_special_key'], array('0', '1'))) { $this->get_special_key = $vars['get_special_key']; $this->special_keys = explode('-', $vars['special_keys']); } // Set result type if (trim($vars['result_type']) != '' and in_array($vars['result_type'], array('1', '2', '3'))) { $this->result_type = $vars['result_type']; } // translate status if (trim($vars['dtranslated']) != '' and in_array($vars['dtranslated'], array('0', '1'))) { $this->dtranslated = $vars['dtranslated']; } // setting vars if (isset($vars['pictures'])) { $this->pictures = $vars['pictures']; } if (isset($vars['attachments'])) { $this->attachments = $vars['attachments']; } if (isset($vars['videos'])) { $this->attachments = $vars['videos']; } if (isset($vars['rooms'])) { $this->attachments = $vars['rooms']; } if (isset($vars['agentinfo'])) { $this->agentinfo = $vars['agentinfo']; } if (isset($vars['sort'])) { $this->orderby = $vars['sort']; } if (isset($vars['asc'])) { $this->order = $vars['asc']; } if (isset($vars['start'])) { $this->start = $vars['start']; } if (isset($vars['limit'])) { $this->limit = $vars['limit']; } if (isset($vars['type'])) { $this->type = $vars['type']; } if (isset($vars['kind'])) { $this->kind = $vars['kind']; } /** customized size of images **/ $this->image_sizes = trim($vars['image_sizes']) != '' ? explode('-', $vars['image_sizes']) : ''; // Checking essential vars foreach ($vars as $field => $value) { if (substr($field, 0, 3) != 'sf_') { continue; } if (strpos($field, 'sf_select_') === false) { $field = str_replace('sf_select', 'sf_select_', $field); } if (strpos($field, 'sf_unit_') === false) { $field = str_replace('sf_unit', 'sf_unit_', $field); } if (strpos($field, 'sf_min_') === false) { $field = str_replace('sf_min', 'sf_min_', $field); } if (strpos($field, 'sf_max_') === false) { $field = str_replace('sf_max', 'sf_max_', $field); } if (strpos($field, 'sf_tmin_') === false) { $field = str_replace('sf_tmin', 'sf_tmin_', $field); } if (strpos($field, 'sf_tmax_') === false) { $field = str_replace('sf_tmax', 'sf_tmax_', $field); } if (strpos($field, 'sf_multiple_') === false) { $field = str_replace('sf_multiple', 'sf_multiple_', $field); } if (strpos($field, 'sf_datemin_') === false) { $field = str_replace('sf_datemin', 'sf_datemin_', $field); } if (strpos($field, 'sf_datemax_') === false) { $field = str_replace('sf_datemax', 'sf_datemax_', $field); } if (strpos($field, 'sf_locationtextsearch_') === false) { $field = str_replace('sf_locationtextsearch', 'sf_locationtextsearch_', $field); } if (strpos($field, 'sf_notselect_') === false) { $field = str_replace('sf_notselect', 'sf_notselect_', $field); } if (strpos($field, 'sf_radiussearchunit_') === false) { $field = str_replace('sf_radiussearchunit', 'sf_radiussearchunit_', $field); } if (strpos($field, 'sf_text_') === false) { $field = str_replace('sf_text', 'sf_text_', $field); } if (strpos($field, 'sf_textsearch_') === false) { $field = str_replace('sf_textsearch', 'sf_textsearch_', $field); } $this->where[$field] = $value; } }
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); } /** global settings **/ $this->settings = wpl_settings::get_settings(); $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); }
<?php /** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); ?> <div class="pwizard-section"> <?php wpl_settings::generate_setting_forms($this->settings); /** including a custom file **/ $this->_wpl_import($this->tpl_path . '.custom.settings' . $this->setting_category->id); ?> </div>
/** * Checks Realtyna billing credentials * @author Howard <*****@*****.**> * @static * @return array */ public static function check_realtyna_credentials() { /** import settings library **/ _wpl_import('libraries.settings'); $current_url = wpl_global::get_full_url(); $domain = wpl_global::domain($current_url); $settings = wpl_global::get_settings(); $phpver = phpversion(); $wplversion = wpl_global::wpl_version(); $wpversion = wpl_global::wp_version(); $username = $settings['realtyna_username']; $password = $settings['realtyna_password']; $POST = array('domain' => $domain, 'wpversion' => $wpversion, 'wplversion' => $wplversion, 'phpver' => $phpver, 'username' => urlencode($username), 'password' => urlencode($password), 'command' => 'check_credentials', 'format' => 'json'); $io_handler = 'http://billing.realtyna.com/io/io.php'; $result = wpl_global::get_web_page($io_handler, $POST); $answer = json_decode($result, true); /** saving status **/ $status = isset($answer['status']) ? $answer['status'] : 0; wpl_settings::save_setting('realtyna_verified', $status, 1); $message = $status ? __('Credentials verified.', WPL_TEXTDOMAIN) : __('Invalid credentials!', WPL_TEXTDOMAIN); $success = 1; return array('success' => $success, 'message' => $message, 'status' => $status); }
/** * Removes property cache * @author Howard R <*****@*****.**> * @static * @param int $property_id * @return boolean */ public static function clear_property_cache($property_id) { /** First Validation **/ if (!trim($property_id)) { return false; } _wpl_import('libraries.settings'); $q = " `location_text`='', `rendered`=''"; if (wpl_global::check_multilingual_status()) { $q = wpl_settings::get_multilingual_query(array('location_text', 'rendered')); } $query = "UPDATE `#__wpl_properties` SET " . $q . " WHERE `id`='{$property_id}'"; return wpl_db::q($query, 'UPDATE'); }
wplj(this).remove(); }); }); } } function video_select_tab(id) { wplj('#video-tabs').find('li').removeClass('active').eq(id).addClass('active'); var _this = wplj('#video-tabs').find('li:eq(' + id + ') > a'); wplj('.video-content-wp').find('> div').hide().filter(_this.attr('href')).fadeIn(600); } </script> <?php if (wpl_settings::get('video_uploader')) { ?> <div class="content-wp hidden" id="uploader"> <div class="upload-btn-wp"> <div class="wpl-button button-1 button-upload"> <span><?php echo __('Select Files', WPL_TEXTDOMAIN); ?> </span> <input id="video_upload" type="file" name="files[]" multiple="multiple"/> </div> <div class="field-desc"> <?php echo __('Please choose all videos you want. Just click on the "Select Files" button.', WPL_TEXTDOMAIN); ?> </div>
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); }
if (isset($this->pagination->max_page) and $this->pagination->max_page > 1) { ?> <div class="pagination-wp"> <?php echo $this->pagination->show(); ?> </div> <?php } ?> <div id="wpl_location_fancybox_cnt" class="wpl_hidden_element"></div> <div id="wpl_location_settings_lightbox" class="wpl_hidden_element"> <div class="fanc-content size-width-1 fanc-settings"> <h2><?php echo __('Location Settings', WPL_TEXTDOMAIN); ?> </h2> <div class="fanc-body label-x2"> <?php $setting_records = wpl_settings::get_settings(3, 1, true); wpl_settings::generate_setting_forms($setting_records); ?> </div> </div> </div> </div> </div> <footer> <div class="logo"></div> </footer> </div>
/** * Check if setting exists or not * @author Howard <*****@*****.**> * @static * @param string $name * @param string $category * @return boolean */ public static function is_setting_exists($name, $category = '') { $condition = ''; if (trim($category) != '') { if (!is_numeric($category)) { $category = wpl_settings::get_category_id($category); } $condition .= "AND `category`='{$category}'"; } $query = "SELECT COUNT(`id`) FROM `#__wpl_settings` WHERE `setting_name`='{$name}' " . $condition; $num = wpl_db::num($query); return $num ? true : false; }
private function save_realtyna_credentials() { /** import settings library **/ _wpl_import('libraries.settings'); $username = wpl_request::getVar('username'); $password = wpl_request::getVar('password'); wpl_settings::save_setting('realtyna_username', $username, 1); wpl_settings::save_setting('realtyna_password', $password, 1); $response = wpl_global::check_realtyna_credentials(); $this->response($response); }
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); }
/** * Creates gallery image * @author Francis <*****@*****.**> * @param int $width * @param int $height * @param array $params * @param boolean $watermark * @param boolean $rewrite * description: resize and watermark images specially for gallery activity */ public static function create_gallary_image($width, $height, $params, $watermark = 0, $rewrite = 0, $crop = '') { $image_name = wpl_file::stripExt($params['image_name']); $image_ext = wpl_file::getExt($params['image_name']); $resized_image_name = 'th' . $image_name . '_' . $width . 'x' . $height . '.' . $image_ext; $image_dest = wpl_items::get_path($params['image_parentid'], $params['image_parentkind']) . $resized_image_name; $image_url = wpl_items::get_folder($params['image_parentid'], $params['image_parentkind']) . $resized_image_name; /** check resized files existance and rewrite option **/ if ($rewrite or !wpl_file::exists($image_dest)) { if ($watermark) { self::resize_watermark_image($params['image_source'], $image_dest, $width, $height); } else { /** if crop was not set, read from wpl settings **/ if (!trim($crop)) { $settings = wpl_settings::get_settings(2); $crop = $settings['image_resize_method']; } self::resize_image($params['image_source'], $image_dest, $width, $height, $crop); } } return $image_url; }
private function save_languages() { $raws = wpl_request::getVar('wpllangs', array()); $langs = array(); $lang_options = array(); foreach ($raws as $key => $raw) { if (!trim($raw['full_code'])) { continue; } $langs[$key] = $raw['full_code']; $lang_options[$key] = $raw; } wpl_settings::save_setting('lang_options', json_encode($lang_options)); wpl_addon_pro::save_languages($langs); $res = 1; $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN); $data = NULL; $response = array('success' => $res, 'message' => $message, 'data' => $data); echo json_encode($response); exit; }
/** * This is a very useful function for rendering whole data of user. you need to just pass user_id and get everything! * @author Howard R <*****@*****.**> * @static * @param int $user_id * @param array $plisting_fields * @param array $profile * @param array $params * @return array */ public static function full_render($user_id, $plisting_fields = NULL, $profile = NULL, $params = array()) { /** get plisting fields **/ if (!$plisting_fields) { $plisting_fields = self::get_plisting_fields(); } $raw_data = (array) self::get_wpl_user($user_id); if (!$profile) { $profile = (object) $raw_data; } $column = 'rendered'; if (wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } /** generate rendered data if rendered data is empty **/ if (!trim($raw_data[$column]) and wpl_settings::get('cache')) { $rendered = json_decode(wpl_users::generate_rendered_data($user_id), true); } elseif (!wpl_settings::get('cache')) { $rendered = array(); } else { $rendered = json_decode($raw_data[$column], true); } $result = array(); $result['data'] = (array) $profile; $result['items'] = wpl_items::get_items($profile->id, '', 2, '', 1); $result['raw'] = $raw_data; if (!isset($rendered['rendered']) or !isset($rendered['materials'])) { /** render data on the fly **/ $find_files = array(); $rendered_fields = self::render_profile($profile, $plisting_fields, $find_files, true); } if (isset($rendered['rendered'])) { $result['rendered'] = $rendered['rendered']; } else { $result['rendered'] = $rendered_fields['ids']; } if (isset($rendered['materials']) and $rendered['materials']) { $result['materials'] = $rendered['materials']; } else { $result['materials'] = $rendered_fields['columns']; } /** location text **/ if (isset($rendered['location_text'])) { $result['location_text'] = $rendered['location_text']; } else { $result['location_text'] = self::generate_location_text($raw_data); } /** profile full link **/ $target_id = isset($params['wpltarget']) ? $params['wpltarget'] : 0; $result['profile_link'] = self::get_profile_link($profile->id, $target_id); /** profile picture **/ if (trim($raw_data['profile_picture']) != '') { $result['profile_picture'] = array('url' => wpl_items::get_folder($profile->id, 2) . $raw_data['profile_picture'], 'path' => wpl_items::get_path($profile->id, 2) . $raw_data['profile_picture'], 'name' => $raw_data['profile_picture']); } /** company logo **/ if (trim($raw_data['company_logo']) != '') { $result['company_logo'] = array('url' => wpl_items::get_folder($profile->id, 2) . $raw_data['company_logo'], 'path' => wpl_items::get_path($profile->id, 2) . $raw_data['company_logo'], 'name' => $raw_data['company_logo']); } /** Emails url **/ if (wpl_file::exists(wpl_items::get_path($profile->id, 2) . 'main_email.png')) { $result['main_email_url'] = wpl_items::get_folder($profile->id, 2) . 'main_email.png'; } if (wpl_file::exists(wpl_items::get_path($profile->id, 2) . 'second_email.png')) { $result['second_email_url'] = wpl_items::get_folder($profile->id, 2) . 'second_email.png'; } return $result; }
private function uploader() { $settings_key = wpl_request::getVar('settings_key', ''); $file = wpl_request::getVar($settings_key, NULL, 'FILES'); $filename = wpl_global::normalize_string($file['name']); $ext_array = array('jpg', 'png', 'gif', 'jpeg'); $error = ''; $message = ''; if (!empty($file['error']) or (empty($file['tmp_name']) or $file['tmp_name'] == 'none')) { $error = __('An error ocurred uploading your file.', WPL_TEXTDOMAIN); } else { // check the extention $extention = strtolower(wpl_file::getExt($file['name'])); if (!in_array($extention, $ext_array)) { $error = __('File extension should be jpg, png or gif.', WPL_TEXTDOMAIN); } if ($error == '') { $dest = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'system' . DS . $filename; wpl_file::upload($file['tmp_name'], $dest); wpl_settings::save_setting($settings_key, $filename); } } $response = array('error' => $error, 'message' => $message); echo json_encode($response); exit; }