/** * Use this function for creating query * @author Howard <*****@*****.**> * @param array $vars * @param string $needle_str * @return string $query */ public static function create_query($vars = '', $needle_str = 'sf_') { if (!$vars) { $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET')); } /** clean vars **/ $vars = wpl_global::clean($vars); $query = ''; /** this is to include any customized and special form fields conditions **/ $path = WPL_ABSPATH . DS . 'libraries' . DS . 'create_query'; $path_exists = wpl_folder::exists($path); $find_files = array(); if ($path_exists) { $files = wpl_folder::files($path, '.php$'); } foreach ($vars as $key => $value) { /** escape value **/ $value = wpl_db::escape($value); if (strpos($key, $needle_str) === false) { continue; } $ex = explode('_', $key); $format = $ex[1]; $table_column = str_replace($needle_str . $format . '_', '', $key); $done_this = false; /** using detected files **/ if (isset($find_files[$format])) { include $path . DS . $find_files[$format]; continue; } foreach ($files as $file) { include $path . DS . $file; if ($done_this) { /** add to detected files **/ $find_files[$format] = $file; break; } } } return $query = trim($query, ' ,'); }
/** * Removes user thumbnails * @author Howard R <*****@*****.**> * @static * @param int $user_id * @return boolean */ public static function remove_thumbnails($user_id) { /** first validation **/ if (!trim($user_id)) { return false; } $ext_array = array('jpg', 'jpeg', 'gif', 'png'); $path = wpl_items::get_path($user_id, 2); $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true); foreach ($thumbnails as $thumbnail) { wpl_file::delete($thumbnail); } return true; }
/** * Get The List of Layouts in the Widget * @author Howard <*****@*****.**> * @static * @param string $widget_name * @return array */ public static function get_layouts($widget_name) { $path = WPL_ABSPATH . 'widgets' . DS . $widget_name . DS . 'tmpl'; return wpl_folder::files($path, '.php', false, false); }
/** * Generate search fields based on DBST fields * @author Steve A. <*****@*****.**> * @param array $fields * @param array $finds * @return array */ public function generate_search_fields($fields, $finds = array()) { $fields = json_decode(json_encode($fields), true); $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend'; $files = array(); $widget_id = ''; if (wpl_folder::exists($path)) { $files = wpl_folder::files($path, '.php$'); } $rendered = array(); foreach ($fields as $key => $field) { $type = $field['type']; $field_id = $field['id']; $field_data = $field; $options = json_decode($field['options'], true); $done_this = false; $html = ''; if (isset($finds[$type])) { $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">'; include $path . DS . $finds[$type]; $html .= '</span> '; $rendered[$field_id]['id'] = $field_id; $rendered[$field_id]['field_options'] = json_decode($field['options'], true); $rendered[$field_id]['html'] = $html; $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL; continue; } $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">'; foreach ($files as $file) { include $path . DS . $file; /** proceed to next field **/ if ($done_this) { $finds[$type] = $file; break; } } $html .= '</span> '; $rendered[$field_id]['id'] = $field_id; $rendered[$field_id]['field_options'] = json_decode($field['options'], true); $rendered[$field_id]['html'] = $html; $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL; } return $rendered; }
/** no direct access **/ defined('_WPLEXEC') or die('Restricted access'); if ($type == 'locations' and !$done_this) { /** import library **/ _wpl_import('libraries.locations'); $location_settings = wpl_global::get_settings('3'); # location settings switch ($field['type']) { case 'simple': if ($location_settings['location_method'] == 2) { $show = 'simple_location_database'; } else { $show = 'simple_location_text'; } break; default: $show = $field['type']; break; } /** Place-holder **/ $placeholder = (isset($field['extoption']) and trim($field['extoption'])) ? $field['extoption'] : $location_settings['locationzips_keyword'] . ', ' . $location_settings['location3_keyword'] . ', ' . $location_settings['location1_keyword']; $location_path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend' . DS . 'location_items'; $location_files = array(); if (wpl_folder::exists($location_path)) { $location_files = wpl_folder::files($location_path, '.php$'); } foreach ($location_files as $location_file) { include $location_path . DS . $location_file; } }
/** * Get layouts * @author Howard <*****@*****.**> * @static * @param string $view * @param array $exclude * @param string $client * @return array */ public static function get_layouts($view = 'property_listing', $exclude = array('message.php'), $client = 'frontend') { $path = WPL_ABSPATH . 'views' . DS . $client . DS . $view . DS . 'tmpl'; $files = wpl_folder::files($path, '.php', false, false); $layouts = array(); foreach ($files as $file) { if (in_array($file, $exclude) or strpos($file, '_k') !== false) { continue; } $layouts[] = strtolower(basename($file, '.php')); } return $layouts; }
public function render_search_fields($instance, $widget_id, $finds = array()) { /** first validation **/ if (!$instance) { return array(); } $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend'; $files = array(); if (wpl_folder::exists($path)) { $files = wpl_folder::files($path, '.php$'); } $fields = $instance['data']; uasort($fields, array('wpl_global', 'wpl_array_sort')); $rendered = array(); foreach ($fields as $key => $field) { /** proceed to next field if field is not enabled **/ if (!isset($field['enable']) or isset($field['enable']) and $field['enable'] != 'enable') { continue; } /** Fix empty id issue **/ if ((!isset($field['id']) or isset($field['id']) and !$field['id']) and $key) { $field['id'] = $key; } $field_data = (array) wpl_flex::get_field($field['id']); if (!$field_data) { continue; } $field['name'] = $field_data['name']; $type = $field_data['type']; $field_id = $field['id']; $options = json_decode($field_data['options'], true); $display = ''; $done_this = false; $html = ''; /** listing and property type specific **/ if (trim($field_data['listing_specific']) != '') { $specified_listings = explode(',', trim($field_data['listing_specific'], ', ')); $this->listing_specific_array[$field_data['id']] = $specified_listings; } elseif (trim($field_data['property_type_specific']) != '') { $specified_property_types = explode(',', trim($field_data['property_type_specific'], ', ')); $this->property_type_specific_array[$field_data['id']] = $specified_property_types; } /** Accesses **/ if (trim($field_data['accesses']) != '') { $accesses = explode(',', trim($field_data['accesses'], ', ')); $cur_membership_id = wpl_users::get_user_membership(); if (!in_array($cur_membership_id, $accesses)) { continue; } } if (isset($finds[$type])) { $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">'; include $path . DS . $finds[$type]; $html .= '</div>'; $rendered[$field_id]['id'] = $field_id; $rendered[$field_id]['field_data'] = $field_data; $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true); $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL; $rendered[$field_id]['html'] = $html; $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL; $rendered[$field_id]['display'] = $display; continue; } $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '" style="' . $display . '">'; foreach ($files as $file) { include $path . DS . $file; /** proceed to next field **/ if ($done_this) { $finds[$type] = $file; break; } } $html .= '</div>'; $rendered[$field_id]['id'] = $field_id; $rendered[$field_id]['field_data'] = $field_data; $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true); $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL; $rendered[$field_id]['html'] = $html; $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL; $rendered[$field_id]['display'] = $display; } return $rendered; }
/** @input void @return available formats @description use this function for getting available formats **/ public function get_formats() { $files = wpl_folder::files($this->get_formats_path(), '.php$', false, false); $commands = array(); foreach ($files as $file) { $ex = explode('.', $file); $commands[] = $ex[0]; } return $commands; }
/** * Removes WPL cached data * @author Howard <*****@*****.**> * @static * @param type $cache_type * @return boolean */ public static function clear_cache($cache_type = 'all') { /** first validation **/ $cache_type = strtolower($cache_type); if (trim($cache_type) == '') { return false; } /** import libraries **/ _wpl_import('libraries.property'); _wpl_import('libraries.items'); if ($cache_type == 'unfinalized_properties' or $cache_type == 'all') { $properties = wpl_db::select("SELECT `id` FROM `#__wpl_properties` WHERE `finalized`='0'", 'loadAssocList'); foreach ($properties as $property) { wpl_property::purge($property['id']); } } if ($cache_type == 'properties_cached_data' or $cache_type == 'all') { $q = " `location_text`='', `rendered`='', `alias`=''"; if (wpl_global::check_multilingual_status()) { $q = self::get_multilingual_query(array('alias', 'location_text', 'rendered')); } $query = "UPDATE `#__wpl_properties` SET " . $q; wpl_db::q($query); } if ($cache_type == 'location_texts' or $cache_type == 'all') { $q = " `location_text`=''"; if (wpl_global::check_multilingual_status()) { $q = self::get_multilingual_query(array('location_text')); } $query = "UPDATE `#__wpl_properties` SET " . $q; wpl_db::q($query); } if ($cache_type == 'listings_thumbnails' or $cache_type == 'all') { $properties = wpl_db::select("SELECT `id`, `kind` FROM `#__wpl_properties` WHERE `id`>0", 'loadAssocList'); $ext_array = array('jpg', 'jpeg', 'gif', 'png'); foreach ($properties as $property) { $path = wpl_items::get_path($property['id'], $property['kind']); $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true); foreach ($thumbnails as $thumbnail) { wpl_file::delete($thumbnail); } } } if ($cache_type == 'users_cached_data' or $cache_type == 'all') { $q = " `location_text`='', `rendered`=''"; if (wpl_global::check_multilingual_status()) { $q = self::get_multilingual_query(array('location_text', 'rendered'), 'wpl_users'); } $query = "UPDATE `#__wpl_users` SET " . $q; wpl_db::q($query); } if ($cache_type == 'users_thumbnails' or $cache_type == 'all') { $users = wpl_db::select("SELECT `id` FROM `#__wpl_users` WHERE `id`>0", 'loadAssocList'); $ext_array = array('jpg', 'jpeg', 'gif', 'png'); foreach ($users as $user) { $path = wpl_items::get_path($user['id'], 2); $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true); foreach ($thumbnails as $thumbnail) { wpl_file::delete($thumbnail); } } } /** trigger event **/ wpl_global::event_handler('cache_cleared', array('cache_type' => $cache_type)); return true; }
/** * get list of activity layout * @author Kevin J <*****@*****.**> * @static * @param type $activityName * @return array */ public static function get_activity_layout($activityName) { $layouts = wpl_folder::files(self::get_activity_folder() . $activityName . DS . 'tmpl'); $activity_layouts = array(); foreach ($layouts as $layout) { if (strpos($layout, '.html') !== false or strpos($layout, 'internal_') !== false) { continue; } $file = basename($layout, ".php"); $activity_layouts[] = $file; } return $activity_layouts; }