コード例 #1
0
ファイル: draw_search.php プロジェクト: gvh1993/project-vvvh
if ($format == 'radiussearchunit' and !$done_this) {
    /** importing library **/
    _wpl_import('libraries.locations');
    $unit_id = $value;
    $address = isset($vars['sf_radiussearch']) ? $vars['sf_radiussearch'] : '';
    $radius = $vars['sf_radiussearchradius'];
    if (trim($address)) {
        $location_point = wpl_locations::get_LatLng($address);
        $latitude = $location_point[0];
        $longitude = $location_point[1];
    } else {
        $latitude = isset($vars['sf_radiussearch_lat']) ? $vars['sf_radiussearch_lat'] : 0;
        $longitude = isset($vars['sf_radiussearch_lng']) ? $vars['sf_radiussearch_lng'] : 0;
    }
    if ($latitude and $longitude and $radius and $unit_id) {
        $unit = wpl_units::get_unit($unit_id);
        if ($unit) {
            $tosi = 6371 * 1000 / $unit['tosi'];
            $radius_si = $radius * $unit['tosi'];
            $query .= " AND (( " . $tosi . " * acos( cos( radians(" . $latitude . ") ) * cos( radians( googlemap_lt ) ) * cos( radians( googlemap_ln ) - radians(" . $longitude . ") ) + sin( radians(" . $latitude . ") ) * sin( radians( googlemap_lt ) ) ) ) < " . $radius . ") AND `show_address`='1'";
        }
    }
    $done_this = true;
} elseif ($format == 'polygonsearch' and wpl_global::check_addon('aps') and !$done_this) {
    /** importing library **/
    _wpl_import('libraries.addon_aps');
    $raw_points = isset($vars['sf_polygonsearchpoints']) ? $vars['sf_polygonsearchpoints'] : '[]';
    if (version_compare(wpl_db::version(), '5.6.1', '>=')) {
        $sql_function = 'ST_Contains';
    } else {
        $sql_function = 'Contains';
コード例 #2
0
ファイル: property.php プロジェクト: amankatoch/wp-plugin
 /**
  * Generates alias of property
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @param string $glue
  * @param boolean $force
  * @return string
  */
 public static function update_alias($property_data, $property_id = 0, $glue = '-', $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 = 'alias';
     $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 alias if exists **/
     if (isset($property_data[$column]) and trim($property_data[$column]) != '' and !$force) {
         return $property_data[$column];
     }
     $alias = array();
     $alias['id'] = $property_id;
     if (trim($property_data['property_type'])) {
         $alias['property_type'] = __(wpl_global::get_property_types($property_data['property_type'])->name, WPL_TEXTDOMAIN);
     }
     if (trim($property_data['listing'])) {
         $alias['listing'] = __(wpl_global::get_listings($property_data['listing'])->name, WPL_TEXTDOMAIN);
     }
     $alias['location'] = self::generate_location_text($property_data, $property_id, '-');
     if (trim($property_data['rooms'])) {
         $alias['rooms'] = $property_data['rooms'] . __('Room' . ($property_data['rooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     if (trim($property_data['bedrooms'])) {
         $alias['bedrooms'] = $property_data['bedrooms'] . __('Bedroom' . ($property_data['bedrooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     if (trim($property_data['bathrooms'])) {
         $alias['bathrooms'] = $property_data['bathrooms'] . __('Bathroom' . ($property_data['bathrooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     $unit_data = wpl_units::get_unit($property_data['price_unit']);
     if (trim($property_data['price'])) {
         $alias['price'] = str_replace('.', '', wpl_render::render_price($property_data['price'], $unit_data['id'], $unit_data['extra']));
     }
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_property_alias', array('alias' => $alias, 'alias_str' => $alias_str)));
     $alias_pattern = wpl_global::get_setting('property_alias_pattern');
     if (trim($alias_pattern) == '') {
         $alias_pattern = '[property_type][glue][listing_type][glue][location][glue][rooms][glue][bedrooms][glue][bathrooms][glue][price]';
     }
     $alias_str = '';
     $alias_str = isset($alias['property_type']) ? str_replace('[property_type]', $alias['property_type'], $alias_pattern) : str_replace('[property_type]', '', $alias_pattern);
     $alias_str = isset($alias['listing']) ? str_replace('[listing_type]', $alias['listing'], $alias_str) : str_replace('[listing_type]', '', $alias_str);
     $alias_str = isset($alias['location']) ? str_replace('[location]', $alias['location'], $alias_str) : str_replace('[location]', '', $alias_str);
     $alias_str = isset($alias['rooms']) ? str_replace('[rooms]', $alias['rooms'], $alias_str) : str_replace('[rooms]', '', $alias_str);
     $alias_str = isset($alias['bedrooms']) ? str_replace('[bedrooms]', $alias['bedrooms'], $alias_str) : str_replace('[bedrooms]', '', $alias_str);
     $alias_str = isset($alias['bathrooms']) ? str_replace('[bathrooms]', $alias['bathrooms'], $alias_str) : str_replace('[bathrooms]', '', $alias_str);
     $alias_str = isset($alias['price']) ? str_replace('[price]', $alias['price'], $alias_str) : str_replace('[price]', '', $alias_str);
     $alias_str = str_replace('[glue]', $glue, $alias_str);
     /** escape **/
     $alias_str = wpl_db::escape(wpl_global::url_encode($alias_str));
     /** update **/
     $query = "UPDATE `#__wpl_properties` SET `{$column}`='" . $alias_str . "' WHERE `id`='" . $property_id . "'";
     wpl_db::q($query, 'update');
     if ($base_column) {
         $query = "UPDATE `#__wpl_properties` SET `{$base_column}`='" . $alias_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     return $alias_str;
 }
コード例 #3
0
ファイル: general.php プロジェクト: amankatoch/wp-plugin
        if (isset($options['if_zero']) and !$options['if_zero'] and !trim($value)) {
            $return = array();
        }
    }
    $done_this = true;
} elseif (($type == 'mmvolume' or $type == 'mmarea' or $type == 'mmlength') and !$done_this) {
    if (trim($value) != '' or trim($values[$field->table_column . '_max']) != '') {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        $return['value'] = $value == round($value) ? number_format($value, 0) : number_format($value, 2);
        if (trim($values[$field->table_column . '_max'])) {
            $return['value'] .= ' - ' . ($values[$field->table_column . '_max'] == round($values[$field->table_column . '_max']) ? number_format($values[$field->table_column . '_max'], 0) : number_format($values[$field->table_column . '_max'], 2));
        }
        /** adding unit **/
        $unit = wpl_units::get_unit($values[$field->table_column . '_unit']);
        if ($unit) {
            $return['value'] .= ' ' . $unit['name'];
        }
        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 == 'price' and !$done_this) {
    $return['field_id'] = $field->id;
    $return['type'] = $field->type;
    $return['name'] = __($field->name, WPL_TEXTDOMAIN);
コード例 #4
0
ファイル: general.php プロジェクト: amankatoch/wp-plugin
        $query .= " AND `parent` = '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'textsearch' and !$done_this) {
    if (trim($value) != '') {
        $query .= " AND `" . $table_column . "` LIKE '%" . $value . "%'";
    }
    $done_this = true;
} elseif ($format == 'text' and !$done_this) {
    if (trim($value) != '') {
        $query .= " AND `" . $table_column . "` LIKE '%" . $value . "%'";
    }
    $done_this = true;
} elseif ($format == 'unit' and !$done_this) {
    /** importing library **/
    _wpl_import('libraries.units');
    if ($value != '-1' and trim($value) != '') {
        $unit_data = wpl_units::get_unit($value);
        $min = isset($vars['sf_min_' . $table_column]) ? $vars['sf_min_' . $table_column] : 0;
        $max = isset($vars['sf_max_' . $table_column]) ? $vars['sf_max_' . $table_column] : 0;
        $si_value_min = $unit_data['tosi'] * $min;
        $si_value_max = $unit_data['tosi'] * $max;
        if ($si_value_max != 0) {
            $query .= " AND `" . $table_column . "_si` <= '" . $si_value_max . "'";
        }
        if ($si_value_min != 0) {
            $query .= " AND `" . $table_column . "_si` >= '" . $si_value_min . "'";
        }
    }
    $done_this = true;
}
コード例 #5
0
ファイル: render.php プロジェクト: gvh1993/project-vvvh
 /**
  * Renders price based on currency unit id
  * @author Howard <*****@*****.**>
  * @static
  * @param int $price
  * @param int $unit_id
  * @param string $symbol
  * @return string
  */
 public static function render_price($price, $unit_id = '', $symbol = '')
 {
     /** in case of empty unit just do it with default currency **/
     if (trim($unit_id) == '') {
         $all_units = wpl_units::get_units(4, 1);
         $unit_id = $all_units[0]['id'];
     }
     /** get currency **/
     $currency = wpl_units::get_unit($unit_id);
     if (!trim($symbol)) {
         $symbol = $currency['name'];
     }
     $decimal = 2;
     $return = '';
     $d_seperator = trim($currency['d_seperator']) != '' ? $currency['d_seperator'] : '';
     $seperator = trim($currency['seperator']) != '' ? $currency['seperator'] : '';
     /** set decimal **/
     if (!$d_seperator) {
         $decimal = 0;
     }
     /** set default value **/
     if (trim($price) == '') {
         $price = 0;
     }
     /** Convert price to float **/
     if (strpos($price, '.') !== false) {
         if (!$d_seperator) {
             $d_seperator = '.';
         }
         $price = (double) $price;
         $decimal = 2;
     }
     /** Remove decimals if the price is not float **/
     if (!is_float($price)) {
         $price = intval($price);
         $decimal = 0;
     }
     $price = number_format($price, $decimal, $d_seperator, $seperator);
     if ($currency['after_before'] == 0) {
         $return = $symbol . $price;
     } else {
         $return = $price . $symbol;
     }
     return $return;
 }