Esempio n. 1
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;
     }
 }
Esempio n. 2
0
 /**
  * Render gallery of a property based on custom sizes
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $property_id
  * @param array $images
  * @param array $custom_sizes
  * @return array
  */
 public static function render_gallery_custom_sizes($property_id, $images = '', $custom_sizes = array())
 {
     $kind = wpl_property::get_property_kind($property_id);
     if (!$images) {
         $images = wpl_items::get_items($property_id, 'gallery', $kind);
     }
     /** no image gallery **/
     if (!count($images)) {
         return array();
     }
     $return = array();
     foreach ($custom_sizes as $custom_size) {
         $custom_size = str_replace('*', '_', $custom_size);
         list($x, $y) = explode('_', $custom_size);
         if (trim($x) == '' or trim($y) == '') {
             continue;
         }
         if (!is_numeric($x) or !is_numeric($y)) {
             continue;
         }
         $i = 0;
         foreach ($images as $image) {
             /** force to array **/
             $image = (array) $image;
             $source_path = self::get_path($image['parent_id'], $image['parent_kind']) . $image['item_name'];
             $source_url = self::get_folder($image['parent_id'], $image['parent_kind']) . $image['item_name'];
             $params = array('image_name' => $image['item_name'], 'image_source' => $source_path, 'image_parentid' => $image['parent_id'], 'image_parentkind' => $image['parent_kind']);
             /** taking care for external images **/
             if ($image['item_cat'] != 'external') {
                 $dest_url = wpl_images::create_gallary_image($x, $y, $params, 0, 0);
                 $pathinfo = @pathinfo($dest_url);
                 $dest_path = self::get_path($image['parent_id'], $image['parent_kind']) . $pathinfo['basename'];
             } else {
                 $dest_url = $source_url;
                 $pathinfo = @pathinfo($dest_url);
                 $dest_path = $source_path;
             }
             $return[$custom_size][$i]['item_id'] = $image['id'];
             $return[$custom_size][$i]['custom_size'] = $custom_size;
             $return[$custom_size][$i]['path'] = $dest_path;
             $return[$custom_size][$i]['url'] = $dest_url;
             $return[$custom_size][$i]['size'] = @filesize($dest_path);
             $return[$custom_size][$i]['title'] = (string) $image['item_extra1'];
             $return[$custom_size][$i]['description'] = (string) $image['item_extra2'];
             $return[$custom_size][$i]['category'] = $image['item_cat'];
             $return[$custom_size][$i]['ext'] = $pathinfo['extension'];
             $return[$custom_size][$i]['raw'] = $image;
             $i++;
         }
     }
     return $return;
 }
Esempio n. 3
0
 /**
  * Updates text search field
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  */
 public static function update_text_search_field($property_id)
 {
     $property_data = wpl_property::get_property_raw_data($property_id);
     $kind = wpl_property::get_property_kind($property_id);
     /** get text_search fields **/
     $fields = wpl_flex::get_fields('', 1, $property_data['kind'], 'text_search', '1');
     $rendered = self::render_property($property_data, $fields);
     $text_search_data = array();
     foreach ($rendered as $data) {
         if (!isset($data['type'])) {
             continue;
         }
         if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) {
             continue;
         }
         /** default value **/
         $value = isset($data['value']) ? $data['value'] : '';
         $value2 = '';
         $type = $data['type'];
         if ($type == 'text' or $type == 'textarea') {
             $value = $data['name'] . ' ' . $data['value'];
         } elseif ($type == 'neighborhood') {
             $value = $data['name'] . (isset($data['distance']) ? ' (' . $data['distance'] . ' ' . __('MINUTES', WPL_TEXTDOMAIN) . ' ' . __('BY', WPL_TEXTDOMAIN) . ' ' . $data['by'] . ')' : '');
         } elseif ($type == 'feature') {
             $feature_value = $data['name'];
             if (isset($data['values'][0])) {
                 $feature_value .= ' ';
                 foreach ($data['values'] as $val) {
                     $feature_value .= $val . ', ';
                 }
                 $feature_value = rtrim($feature_value, ', ');
             }
             $value = $feature_value;
         } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) {
             $location_values = array();
             foreach ($data['locations'] as $location_level => $value) {
                 array_push($location_values, $data['keywords'][$location_level]);
                 $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level);
                 $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level);
                 $ex_space = explode(' ', $name);
                 foreach ($ex_space as $value_raw) {
                     array_push($location_values, $value_raw);
                 }
                 if ($name !== $abbr) {
                     array_push($location_values, $abbr);
                 }
             }
             /** Add all location fields to the location text search **/
             $location_category = wpl_flex::get_category(NULL, " AND `kind`='{$kind}' AND `prefix`='ad'");
             $location_fields = wpl_flex::get_fields($location_category->id, 1, $kind);
             foreach ($location_fields as $location_field) {
                 if (!isset($rendered[$location_field->id])) {
                     continue;
                 }
                 if (!trim($location_field->table_column)) {
                     continue;
                 }
                 if (!isset($rendered[$location_field->id]['value']) or isset($rendered[$location_field->id]['value']) and !trim($rendered[$location_field->id]['value'])) {
                     continue;
                 }
                 $ex_space = explode(' ', strip_tags($rendered[$location_field->id]['value']));
                 foreach ($ex_space as $value_raw) {
                     array_push($location_values, $value_raw);
                 }
             }
             $location_suffix_prefix = wpl_locations::get_location_suffix_prefix();
             foreach ($location_suffix_prefix as $suffix_prefix) {
                 array_push($location_values, $suffix_prefix);
             }
             $location_string = '';
             $location_values = array_unique($location_values);
             foreach ($location_values as $location_value) {
                 $location_string .= 'LOC-' . __($location_value, WPL_TEXTDOMAIN) . ' ';
             }
             $value = trim($location_string);
         } elseif (isset($data['value'])) {
             $value = $data['name'] . ' ' . $data['value'];
             if (is_numeric($data['value'])) {
                 $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']);
             }
         }
         /** set value in text search data **/
         if (trim($value) != '') {
             $text_search_data[] = strip_tags($value);
         }
         if (trim($value2) != '') {
             $text_search_data[] = strip_tags($value2);
         }
     }
     $column = 'textsearch';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     wpl_db::set('wpl_properties', $property_id, $column, wpl_db::escape(implode(' ', $text_search_data)));
 }