示例#1
0
 /**
  * Generate location text of User
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $user_data
  * @param int $user_id
  * @param string $glue
  * @return string
  */
 public static function generate_location_text($user_data, $user_id = 0, $glue = ',')
 {
     /** fetch user data if user id is setted **/
     if ($user_id) {
         $user_data = (array) wpl_users::get_wpl_user($user_id);
     }
     if (!$user_id) {
         $user_id = $user_data['id'];
     }
     $locations = array();
     if (isset($user_data['location7_name']) and trim($user_data['location7_name']) != '') {
         $locations['location7_name'] = __($user_data['location7_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location6_name']) and trim($user_data['location6_name']) != '') {
         $locations['location6_name'] = __($user_data['location6_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location5_name']) and trim($user_data['location5_name']) != '') {
         $locations['location5_name'] = __($user_data['location5_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location4_name']) and trim($user_data['location4_name']) != '') {
         $locations['location4_name'] = __($user_data['location4_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location3_name']) and trim($user_data['location3_name']) != '') {
         $locations['location3_name'] = __($user_data['location3_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location2_name']) and trim($user_data['location2_name']) != '') {
         $locations['location2_name'] = __($user_data['location2_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['zip_name']) and trim($user_data['zip_name']) != '') {
         $locations['zip_name'] = __($user_data['zip_name'], WPL_TEXTDOMAIN);
     }
     if (isset($user_data['location1_name']) and trim($user_data['location1_name']) != '') {
         $locations['location1_name'] = __($user_data['location1_name'], WPL_TEXTDOMAIN);
     }
     $location_pattern = wpl_global::get_setting('user_location_pattern');
     if (trim($location_pattern) == '') {
         $location_pattern = '[location5_name][glue][location4_name][glue][location3_name][glue][location2_name][glue][location1_name] [zip_name]';
     }
     $location_text = '';
     $location_text = isset($locations['location7_name']) ? str_replace('[location7_name]', $locations['location7_name'], $location_pattern) : str_replace('[location7_name]', '', $location_pattern);
     $location_text = isset($locations['location6_name']) ? str_replace('[location6_name]', $locations['location6_name'], $location_pattern) : str_replace('[location6_name]', '', $location_pattern);
     $location_text = isset($locations['location5_name']) ? str_replace('[location5_name]', $locations['location5_name'], $location_pattern) : str_replace('[location5_name]', '', $location_pattern);
     $location_text = isset($locations['location4_name']) ? str_replace('[location4_name]', $locations['location4_name'], $location_text) : str_replace('[location4_name]', '', $location_text);
     $location_text = isset($locations['location3_name']) ? str_replace('[location3_name]', $locations['location3_name'], $location_text) : str_replace('[location3_name]', '', $location_text);
     $location_text = isset($locations['location2_name']) ? str_replace('[location2_name]', $locations['location2_name'], $location_text) : str_replace('[location2_name]', '', $location_text);
     $location_text = isset($locations['zip_name']) ? str_replace('[zip_name]', $locations['zip_name'], $location_text) : str_replace('[zip_name]', '', $location_text);
     $location_text = isset($locations['location1_name']) ? str_replace('[location1_name]', $locations['location1_name'], $location_text) : str_replace('[location1_name]', '', $location_text);
     $location_text = str_replace('[glue]', $glue, $location_text);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_user_location_text', array('location_text' => $location_text, 'glue' => $glue, 'user_data' => $user_data)));
     $final = '';
     $ex = explode($glue, $location_text);
     foreach ($ex as $value) {
         if (trim($value) == '') {
             continue;
         }
         $final .= trim($value) . $glue . ' ';
     }
     $location_text = trim($final, $glue . ' ');
     $column = 'location_text';
     $field_id = wpl_flex::get_dbst_id($column, 2);
     $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);
     }
     /** update **/
     $query = "UPDATE `#__wpl_users` SET `{$column}`='" . $location_text . "' WHERE `id`='{$user_id}'";
     wpl_db::q($query, 'update');
     return $location_text;
 }
示例#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;
     }
 }
示例#3
0
 /**
  * Updates property title
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @param boolean $force
  * @return string
  */
 public static function update_property_title($property_data, $property_id = 0, $force = false)
 {
     /** fetch property data if property id is setted **/
     if ($property_id) {
         $property_data = self::get_property_raw_data($property_id);
     }
     if (!$property_id) {
         $property_id = $property_data['id'];
     }
     $column = 'field_313';
     $field_id = wpl_flex::get_dbst_id($column, $property_data['kind']);
     $field = wpl_flex::get_field($field_id);
     $base_column = NULL;
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $base_column = wpl_global::get_current_language() == wpl_addon_pro::get_default_language() ? $column : NULL;
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** return current title if exists **/
     if (isset($property_data[$column]) and trim($property_data[$column]) != '' and !$force) {
         return $property_data[$column];
     }
     /** first validation **/
     if (!$property_data) {
         return '';
     }
     $listing_data = wpl_global::get_listings($property_data['listing']);
     $listing = isset($listing_data->name) ? $listing_data->name : '';
     $property_type_data = wpl_global::get_property_types($property_data['property_type']);
     $property_type = isset($property_type_data->name) ? $property_type_data->name : '';
     $title = array();
     $title['property_type'] = __($property_type, WPL_TEXTDOMAIN);
     $title['listing'] = __($listing, WPL_TEXTDOMAIN);
     if ($property_data['kind']) {
         $kind_label = wpl_flex::get_kind_label($property_data['kind']);
         if (trim($kind_label)) {
             $title['kind'] = '(' . __($kind_label, WPL_TEXTDOMAIN) . ')';
         }
     }
     $title_str = implode(' ', $title);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_property_title', array('title' => $title, 'title_str' => $title_str)));
     /** update **/
     if (wpl_db::columns('wpl_properties', $column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     /** update **/
     if ($base_column and wpl_db::columns('wpl_properties', $base_column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $base_column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     return $title_str;
 }
示例#4
0
    }
    if (isset($options['if_zero']) and !$options['if_zero'] and !trim($value)) {
        $return = array();
    }
    $done_this = true;
} elseif ($type == 'mmprice' and !$done_this) {
    $return['field_id'] = $field->id;
    $return['type'] = $field->type;
    $return['name'] = __($field->name, WPL_TEXTDOMAIN);
    $rendered_price = wpl_render::render_price($value, $values[$field->table_column . '_unit']);
    if (trim($values[$field->table_column . '_max'])) {
        $rendered_price .= ' - ' . wpl_render::render_price($values[$field->table_column . '_max'], $values[$field->table_column . '_unit']);
    }
    $return['value'] = $rendered_price;
    $return['price_only'] = $rendered_price;
    $price_period = wpl_property::render_field($values['price_period'], wpl_flex::get_dbst_id('price_period', $field->kind));
    if (isset($price_period['value'])) {
        $return['value'] .= ' ' . $price_period['value'];
        $return['price_period'] = $price_period['value'];
    }
    if (isset($options['if_zero']) and $options['if_zero'] == 2 and !trim($value) and !trim($values[$field->table_column . '_max'])) {
        $return['value'] = __($options['call_text'], WPL_TEXTDOMAIN);
    }
    if (isset($options['if_zero']) and !$options['if_zero'] and !trim($value) and !trim($values[$field->table_column . '_max'])) {
        $return = array();
    }
    $done_this = true;
} elseif ($type == 'url' and !$done_this) {
    if (trim($value) != '') {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;