/** * Use this function for applying any filter * @author Howard <*****@*****.**> * @param string $trigger * @param array $params * @return mixed */ public static function apply($trigger, $params = array()) { /** fetch filters **/ $filters = self::get_filters($trigger, 1); if (count($filters) == 0) { return $params; } foreach ($filters as $filter) { /** generate all params **/ $all_params = array(); $all_params[0] = $params; $all_params[1] = json_decode($filter->params, true); $all_params[2] = $filter; /** import class **/ $path = _wpl_import($filter->class_location, true, true); if (!wpl_file::exists($path)) { continue; } include_once $path; /** call function **/ $filter_obj = new $filter->class_name(); $params = call_user_func(array($filter_obj, $filter->function_name), $all_params); } return $params; }
/** * How to display the widget on the screen. */ public function widget($args, $instance) { $this->widget_id = $this->number; if ($this->widget_id < 0) { $this->widget_id = abs($this->widget_id) + 1000; } $this->widget_uq_name = 'wpls' . $this->widget_id; $widget_id = $this->widget_id; $target_id = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0; $this->kind = isset($instance['kind']) ? $instance['kind'] : 0; /** add main scripts **/ wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('jquery-ui-button'); wp_enqueue_script('jquery-ui-datepicker'); echo $args['before_widget']; $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); if (trim($title) != '') { echo $args['before_title'] . $title . $args['after_title']; } $layout = 'widgets.search.tmpl.' . (isset($instance['layout']) ? $instance['layout'] : 'default'); $layout = _wpl_import($layout, true, true); $find_files = array(); /** render search fields **/ $this->rendered = $this->render_search_fields($instance, $widget_id, $find_files); if (!wpl_file::exists($layout)) { $layout = _wpl_import('widgets.search.tmpl.default', true, true); } if (wpl_file::exists($layout)) { require $layout; } else { echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN); } echo $args['after_widget']; }
/** * How to display the widget on the screen. */ public function widget($args, $instance) { $this->widget_id = $this->number; if ($this->widget_id < 0) { $this->widget_id = abs($this->widget_id) + 1000; } $this->widget_uq_name = 'wpla' . $this->widget_id; $this->instance = $instance; $widget_id = $this->widget_id; $this->css_class = isset($instance['data']['css_class']) ? $instance['data']['css_class'] : ''; /** render properties **/ $query = self::query($instance); $model = new wpl_users(); $profiles = $model->search($query); /** return if no property found **/ if (!count($profiles)) { return; } $plisting_fields = $model->get_plisting_fields(); $wpl_profiles = array(); $render_params['wpltarget'] = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0; $params = array(); foreach ($profiles as $profile) { $wpl_profiles[$profile->id] = $model->full_render($profile->id, $plisting_fields, $profile, $render_params); $params['image_parentid'] = $profile->id; /** profile picture **/ if (isset($wpl_profiles[$profile->id]['profile_picture']['url'])) { $params['image_name'] = isset($wpl_profiles[$profile->id]['profile_picture']['name']) ? $wpl_profiles[$profile->id]['profile_picture']['name'] : ''; $profile_picture_path = isset($wpl_profiles[$profile->id]['profile_picture']['path']) ? $wpl_profiles[$profile->id]['profile_picture']['path'] : ''; $wpl_profiles[$profile->id]['profile_picture']['url'] = wpl_images::create_profile_images($profile_picture_path, $instance['data']['image_width'], $instance['data']['image_height'], $params); $wpl_profiles[$profile->id]['profile_picture']['image_width'] = isset($instance['data']['image_width']) ? $instance['data']['image_width'] : ''; $wpl_profiles[$profile->id]['profile_picture']['image_height'] = isset($instance['data']['image_height']) ? $instance['data']['image_height'] : ''; } /** company logo **/ if (isset($wpl_profiles[$profile->id]['company_logo']['url'])) { $params['image_name'] = isset($wpl_profiles[$profile->id]['company_logo']['name']) ? $wpl_profiles[$profile->id]['company_logo']['name'] : ''; $company_logo_path = isset($wpl_profiles[$profile->id]['company_logo']['path']) ? $wpl_profiles[$profile->id]['company_logo']['path'] : ''; $wpl_profiles[$profile->id]['company_logo']['url'] = wpl_images::create_profile_images($company_logo_path, $instance['data']['image_width'], $instance['data']['image_height'], $params); } } echo $args['before_widget']; $title = apply_filters('widget_title', $instance['title']); if (trim($title) != '') { echo $args['before_title'] . $title . $args['after_title']; } $layout = 'widgets.agents.tmpl.' . $instance['layout']; $layout = _wpl_import($layout, true, true); if (!wpl_file::exists($layout)) { $layout = _wpl_import('widgets.agents.tmpl.default', true, true); } elseif (wpl_file::exists($layout)) { require $layout; } else { echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN); } echo $args['after_widget']; }
/** * Compile SCSS file and convert it to CSS file * @author Howard <*****@*****.**> * @param string $input * @param string $output * @return boolean */ public function compile_file($input, $output) { if (!trim($input) or !wpl_file::exists($input)) { return false; } if (!trim($output)) { return false; } $CSS = $this->scssc->compile(wpl_file::read($input)); wpl_file::write($output, $CSS); return $CSS; }
public function get_qr_image($qrfile_prefix = 'qr_', $size = 4, $outer_margin = 2) { $url = wpl_global::get_full_url(); $file_name = $qrfile_prefix . md5($url) . '.png'; $file_path = wpl_global::get_upload_base_path() . 'qrcode' . DS . $file_name; if (!wpl_file::exists($file_path)) { if (!wpl_file::exists(dirname($file_path))) { wpl_folder::create(dirname($file_path)); } $QRcode = new QRcode(); $QRcode->png($url, $file_path, 'L', $size, $outer_margin); } return wpl_global::get_upload_base_url() . 'qrcode/' . $file_name; }
public function show_tips() { $page = wpl_request::getVar('page', ''); /** First Validation **/ if (!trim($page)) { return false; } $tips = array(); $path = _wpl_import('assets.tips.' . $page, true, true); if (wpl_file::exists($path)) { $tips = (include_once $path); } /** Generate script **/ $this->generate_scripts($tips); }
/** * How to display the widget on the screen. */ public function widget($args, $instance) { $this->instance = $instance; $this->widget_id = $this->number; if ($this->widget_id < 0) { $this->widget_id = abs($this->widget_id) + 1000; } $this->widget_uq_name = 'wplc' . $this->widget_id; $widget_id = $this->widget_id; $this->css_class = isset($instance['data']['css_class']) ? $instance['data']['css_class'] : ''; /** add main scripts **/ wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-slider'); /** render properties **/ $query = self::query($instance); $model = new wpl_property(); $properties = $model->search($query); /** return if no property found **/ if (!count($properties)) { return; } $plisting_fields = $model->get_plisting_fields(); $wpl_properties = array(); $render_params['wpltarget'] = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0; foreach ($properties as $property) { $wpl_properties[$property->id] = $model->full_render($property->id, $plisting_fields, $property, $render_params); } echo $args['before_widget']; $title = apply_filters('widget_title', $instance['title']); if (trim($title) != '') { echo $args['before_title'] . $title . $args['after_title']; } $layout = 'widgets.carousel.tmpl.' . $instance['layout']; $layout = _wpl_import($layout, true, true); if (!wpl_file::exists($layout)) { $layout = _wpl_import('widgets.carousel.tmpl.default', true, true); } elseif (wpl_file::exists($layout)) { require $layout; } else { echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN); } echo $args['after_widget']; }
private function update_package() { $sid = wpl_request::getVar('sid'); $tmp_directory = wpl_global::init_tmp_folder(); $dest = $tmp_directory . 'package.zip'; $zip_file = wpl_global::get_web_page('http://billing.realtyna.com/index.php?option=com_rls&view=downloadables&task=download&sid=' . $sid . '&randomkey=' . rand(1, 100)); if (!$zip_file) { $this->response(array('success' => '0', 'error' => __('Error: #U202, Could not download the update package!', WPL_TEXTDOMAIN), 'message' => '')); } if (!class_exists('ZipArchive')) { $this->response(array('success' => '0', 'error' => __('Error: #U205, Your PHP has no ZipArchive support enabled!', WPL_TEXTDOMAIN), 'message' => '')); } if (!wpl_file::write($dest, $zip_file)) { $this->response(array('success' => '0', 'error' => __('Error: #U203, Could not create the update file!', WPL_TEXTDOMAIN), 'message' => '')); } if (!wpl_global::zip_extract($dest, $tmp_directory)) { $this->response(array('success' => '0', 'error' => __('Error: #U204, Could not extract the update file!', WPL_TEXTDOMAIN), 'message' => '')); } $script_file = $tmp_directory . 'installer.php'; if (!wpl_file::exists($script_file)) { $this->response(array('error' => __("Installer file doesn't exist!", WPL_TEXTDOMAIN), 'message' => '')); } if (!is_writable(WPL_ABSPATH . 'WPL.php')) { $this->response(array('error' => __("PHP doesn't have write access to the files and directories!", WPL_TEXTDOMAIN), 'message' => '')); } /** including installer and run the install method **/ include $script_file; if (!class_exists('wpl_installer')) { $this->response(array('error' => __("Installer class doesn't exist!", WPL_TEXTDOMAIN), 'message' => '')); } /** run install script **/ $wpl_installer = new wpl_installer(); $wpl_installer->path = $tmp_directory; if (!$wpl_installer->run()) { $this->response(array('error' => $wpl_installer->error, 'message' => '')); } /** Trigger Event **/ wpl_global::event_handler('package_updated', array('package_id' => isset($wpl_installer->addon_id) ? $wpl_installer->addon_id : 0)); $message = $wpl_installer->message ? $wpl_installer->message : __('Addon Updated.', WPL_TEXTDOMAIN); $this->response(array('error' => '', 'message' => $message)); }
/** * Renders videos * @author Howard R <*****@*****.**> * @static * @param array $videos * @return array */ public static function render_videos($videos = array()) { /** force to array **/ $videos = (array) $videos; $return = array(); $i = 0; foreach ($videos as $video) { /** force to array **/ $video = (array) $video; $return[$i]['item_id'] = $video['id']; $return[$i]['category'] = $video['item_cat']; if ($video['item_cat'] == 'video') { $video_path = self::get_path($video['parent_id'], $video['parent_kind']) . $video['item_name']; $video_url = self::get_folder($video['parent_id'], $video['parent_kind']) . $video['item_name']; /** existance check **/ if (!wpl_file::exists($video_path)) { continue; } $pathinfo = @pathinfo($video_path); $return[$i]['path'] = $video_path; $return[$i]['url'] = $video_url; $return[$i]['size'] = @filesize($video_path); $return[$i]['title'] = (string) $video['item_extra1']; $return[$i]['description'] = (string) $video['item_extra2']; $return[$i]['ext'] = $pathinfo['extension']; } elseif ($video['item_cat'] == 'video_embed') { $return[$i]['path'] = ''; $return[$i]['url'] = (string) $video['item_extra2']; $return[$i]['size'] = ''; $return[$i]['title'] = (string) $video['item_name']; $return[$i]['description'] = (string) $video['item_extra1']; $return[$i]['ext'] = ''; } $return[$i]['raw'] = $video; $i++; } return $return; }
/** * Returns image URL * @author Howard R <*****@*****.**> * @static * @param string $image * @return string|boolean */ public static function get_images_url($image = '') { /** first validation **/ if (trim($image) == '') { return false; } $path = wpl_global::get_wpl_root_path() . 'libraries' . DS . 'notifications' . DS . 'templates' . DS . 'cache' . DS . $image . '.png'; $url = wpl_global::get_wpl_url() . 'libraries/notifications/templates/cache/' . $image . '.png'; if (!wpl_file::exists($path)) { wpl_images::text_to_image($image, '000000', $path); } return $url; }
/** * For rendering and returning section contents * @author Howard <*****@*****.**> * @param string $include * @param boolean $override * @param boolean $once * @return string */ protected function _wpl_render($include, $override = true, $once = false) { $path = _wpl_import($include, $override, true); /** check exists **/ if (!wpl_file::exists($path)) { return; } ob_start(); if (!$once) { include $path; } else { include_once $path; } return ob_get_clean(); }
/** * Returns js validation code * @author Howard R <*****@*****.**> * @static * @param object $field * @return string */ public static function generate_js_validation($field) { $field = (object) $field; $label = $field->name; $mandatory = $field->mandatory; $js_string = ''; $path = WPL_ABSPATH . DS . 'libraries' . DS . 'dbst_wizard' . DS . 'js_validation' . DS . $field->type . '.php'; $override_path = WPL_ABSPATH . DS . 'libraries' . DS . 'dbst_wizard' . DS . 'js_validation' . DS . 'overrides' . DS . $field->type . '.php'; if (wpl_file::exists($override_path)) { $path = $override_path; } /** include file **/ if (wpl_file::exists($path)) { include $path; } return $js_string; }
/** * for importing internal files in object mode * @author Howard <*****@*****.**> * @param string $include * @param boolean $override * @param boolean $set_footer * @param boolean $once * @return void */ protected function _wpl_import($include, $override = true, $set_footer = false, $once = false) { $path = _wpl_import($include, $override, true); /** check exists **/ if (!wpl_file::exists($path)) { return; } if (!$set_footer) { if (!$once) { include $path; } else { include_once $path; } } else { ob_start(); if (!$once) { include $path; } else { include_once $path; } wpl_html::set_footer(ob_get_clean()); } }
/** * Creates profile image * @author Howard <*****@*****.**> * @param string $source * @param int $width * @param int $height * @param array $params * @param int $watermark * @param int $rewrite * @param int $crop * description: resize and watermark images specially */ public static function create_profile_images($source, $width, $height, $params, $watermark = 0, $rewrite = 0, $crop = '') { /** first validation **/ if (!trim($source)) { return NULL; } $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'], 2) . $resized_image_name; $image_url = wpl_items::get_folder($params['image_parentid'], 2) . $resized_image_name; /** check resized files existance and rewrite option **/ if ($rewrite or !wpl_file::exists($image_dest)) { if ($watermark) { self::resize_watermark_image($source, $image_dest, $width, $height); } else { self::resize_image($source, $image_dest, $width, $height, $crop); } } return $image_url; }
/** * * @author Howard R. <*****@*****.**> * @param string $wplpath * @param string $tpl * @param int $user_type * @return string */ public static function get_user_type_tpl($wplpath, $tpl = NULL, $user_type = NULL) { if (!trim($tpl)) { $tpl = 'default'; } if (is_null($user_type)) { return $tpl; } /** Create User Type tpl such as default_ut1.php etc. **/ $user_type_tpl = $tpl . '_ut' . $user_type; $wplpath = rtrim($wplpath, '.') . '.' . $user_type_tpl; $path = _wpl_import($wplpath, true, true); if (wpl_file::exists($path)) { return $user_type_tpl; } else { return $tpl; } }
/** * Get language .mo path * @author Howard <*****@*****.**> * @static * @param string $locale * @return string */ public static function get_language_mo_path($locale = NULL) { if (!$locale) { $locale = wpl_global::get_current_language(); } $path = WP_LANG_DIR . DS . WPL_BASENAME . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo'; if (!wpl_file::exists($path)) { $path = wpl_global::get_wpl_root_path() . 'languages' . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo'; } return $path; }
/** @input $cmd string format name @return format path **/ public function get_format_path($format) { $path = WPL_ABSPATH . 'libraries' . DS . 'io' . DS . $this->formats_folder . DS . 'overrides' . DS . $format . '.php'; if (!wpl_file::exists($path)) { $path = WPL_ABSPATH . 'libraries' . DS . 'io' . DS . $this->formats_folder . DS . $format . '.php'; } return $path; }
/** * Uninstalling WPL * @author Howard <*****@*****.**> * @return boolean */ public function uninstall_wpl() { $tables = wpl_db::select('SHOW TABLES'); $database = wpl_db::get_DBO(); foreach ($tables as $table_name => $table) { if (strpos($table_name, $database->prefix . 'wpl_') !== false) { /** drop table **/ wpl_db::q("DROP TABLE `{$table_name}`"); } } /** delete options **/ wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete'); /** remove WPL upload directory **/ 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); $upload_path = wpl_global::get_upload_base_path($blog->blog_id); if (wpl_folder::exists($upload_path)) { wpl_folder::delete($upload_path); } } switch_to_blog($original_blog_id); } else { $upload_path = wpl_global::get_upload_base_path(); if (wpl_file::exists($upload_path)) { wpl_file::delete($upload_path); } } return true; }
private function gicon_delete($icon) { if (trim($icon) == '') { $icon = wpl_request::getVar('icon'); } $dest = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'listing_types' . DS . 'gicon' . DS . $icon; if (wpl_file::exists($dest)) { wpl_file::delete($dest); } /** trigger event **/ wpl_global::event_handler('gicon_removed', array('icon' => $icon)); 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; }
/** * Executes all cronjobs * @author Howard <*****@*****.**> * @param array $params * @return boolean */ public static function do_cronjobs($params = array()) { $cronjobs = self::get_cronjobs(1); foreach ($cronjobs as $cronjob) { /** generate all params **/ $all_params = array(); $all_params[0] = $params; $all_params[1] = json_decode($cronjob->params, true); $all_params[2] = $cronjob; /** import class **/ $path = _wpl_import($cronjob->class_location, true, true); if (!wpl_file::exists($path)) { continue; } include_once $path; /** call function **/ $cron_obj = new $cronjob->class_name(); call_user_func(array($cron_obj, $cronjob->function_name), $all_params); /** update cronjob latest run **/ self::update_cronjob_latest_run($cronjob->id); } return true; }