Example #1
0
 /**
  * This is a function for loading view
  * @author Howard <*****@*****.**>
  * @static
  * @param string $view
  * @param string $query_string
  * @param array $instance
  * @param string $function
  * @return string
  */
 public static function load($view = 'property_listing', $query_string = '', $instance = array(), $function = NULL)
 {
     /** first validations **/
     if (trim($query_string) == '') {
         $query_string = wpl_global::get_wp_qvar('wpl_qs');
     }
     /** generate pages object **/
     $controller = new wpl_controller();
     if (!$function) {
         $function = 'f:' . $view . ':display';
     }
     /** call function **/
     return call_user_func(array($controller, $function), $instance);
 }
Example #2
0
 /**
  * Checke proeprty alias and 301 redirect the page to the correct link
  * @author Howard <*****@*****.**>
  * @param int $proeprty_id
  */
 public function check_property_link($proeprty_id)
 {
     $wpl_qs = urldecode(wpl_global::get_wp_qvar('wpl_qs'));
     /** check property alias for avoiding duplicate content **/
     $called_alias = $wpl_qs;
     $column = 'alias';
     $field_id = wpl_flex::get_dbst_id($column, wpl_property::get_property_kind($proeprty_id));
     $field = wpl_flex::get_field($field_id);
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     $property_alias = $proeprty_id . '-' . urldecode(wpl_db::get($column, 'wpl_properties', 'id', $proeprty_id));
     if (trim($property_alias) != '' and $called_alias != $property_alias) {
         $url = wpl_sef::get_wpl_permalink(true) . '/' . urlencode($property_alias);
         header('HTTP/1.1 301 Moved Permanently');
         header('Location: ' . $url);
         exit;
     }
 }
Example #3
0
 /**
  * Sets parameters of a view
  * @author Howard R <*****@*****.**>
  * @static
  * @param string $view
  * @param string $query_string
  */
 public static function setVars($view = 'property_listing', $query_string = '')
 {
     /** first validations **/
     if (trim($query_string) == '') {
         $query_string = wpl_global::get_wp_qvar('wpl_qs');
     }
     $separator = wpl_global::get_setting('sef_main_separator');
     /** default value is "/" character **/
     $ex = explode($separator, $query_string);
     /** set view **/
     wpl_request::setVar('wplview', $view, 'method', false);
     if ($view == 'property_show') {
         $exp = explode('-', $ex[0]);
         wpl_request::setVar('pid', $exp[0], 'method', false);
     } elseif ($view == 'profile_show') {
         $query = "SELECT `ID` FROM `#__users` WHERE `user_login`='" . $ex[0] . "' ORDER BY ID ASC LIMIT 1";
         $uid = wpl_db::select($query, 'loadResult');
         wpl_request::setVar('uid', $uid, 'method', false);
         wpl_request::setVar('sf_select_user_id', $uid, 'method', false);
     } else {
         /** specific fields like country, state, city and ... **/
         $specific_fields = array();
         /** set location vars **/
         self::set_location_vars($ex);
         foreach ($ex as $parameter) {
             $types = array();
             $detected = explode(':', $parameter);
             if (count($detected) == 1) {
                 continue;
             } elseif (count($detected) == 2) {
                 $types[0] = 'select';
                 $fields[0] = $detected[0];
                 $values[0] = $detected[1];
                 $parsed_value = explode('-', $detected[1]);
                 if (count($parsed_value) == 2) {
                     $types[0] = 'tmin';
                     $fields[0] = $detected[0];
                     $values[0] = $parsed_value[0];
                     $types[1] = 'tmax';
                     $fields[1] = $detected[0];
                     $values[1] = $parsed_value[1];
                 } elseif (count($parsed_value) == 3) {
                     $types[0] = 'min';
                     $fields[0] = $detected[0];
                     $values[0] = $parsed_value[0];
                     $types[1] = 'max';
                     $fields[1] = $detected[0];
                     $values[1] = $parsed_value[1];
                     $types[2] = 'unit';
                     $fields[2] = $detected[0];
                     $values[2] = $parsed_value[2];
                 }
             } elseif (count($detected) == 3) {
                 $types[0] = strtolower($detected[0]);
                 $fields[0] = $detected[1];
                 $values[0] = $detected[2];
             }
             $i = 0;
             foreach ($types as $type) {
                 $field = self::parse_field(urldecode($fields[$i]), $specific_fields);
                 $value = self::get_id_by_name($field, urldecode($values[$i]));
                 if (trim($value) != '') {
                     wpl_request::setVar('sf_' . $type . '_' . $field, $value, 'method', false);
                 }
                 $i++;
             }
         }
     }
 }