Exemple #1
0
 /**
  * Getsa unit data
  * @author Howard <*****@*****.**>
  * @static
  * @param int $id
  * @return array
  */
 public static function get_unit($id)
 {
     /** first validation **/
     if (trim($id) == '') {
         return array();
     }
     $unit = wpl_units::get_units('', '', " AND `id`='" . $id . "'");
     return isset($unit[0]) ? $unit[0] : NULL;
 }
Exemple #2
0
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';
Exemple #3
0
 public function generate_currency_page()
 {
     $this->units = wpl_units::get_units(4, '', '');
     /** import tpl **/
     parent::render($this->tpl_path, 'internal_unit_manager_currency');
 }
Exemple #4
0
 private function generate_edit_page($user_id = '')
 {
     $this->user_info = wpl_users::get_user($user_id);
     $this->fields = wpl_db::columns('wpl_users');
     $this->user_data = wpl_users::get_wpl_user($user_id);
     $this->data = $this->user_data;
     $this->units = wpl_units::get_units(4);
     $this->listings = wpl_listing_types::get_listing_types();
     $this->property_types = wpl_property_types::get_property_types();
     $this->memberships = wpl_users::get_wpl_memberships();
     $this->membership_types = wpl_users::get_membership_types();
     parent::render($this->tpl_path, 'edit');
     exit;
 }
 /**
  *	get a currency id and exchange rate it by unit library
  **/
 private function update_a_exchange_rate($unit_id, $currency_code)
 {
     $res = wpl_units::update_a_exchange_rate($unit_id, $currency_code);
     $success = $res ? true : false;
     $response = array('success' => $success, 'res' => $res);
     echo json_encode($response);
     exit;
 }
Exemple #6
0
     $default_division_value = 1000;
 } elseif ($type == 'volume') {
     $unit_type = 3;
     $default_max_value = 1000;
     $default_division_value = 50;
 } elseif ($type == 'area') {
     $unit_type = 2;
     $default_max_value = 10000;
     $default_division_value = 100;
 } elseif ($type == 'length') {
     $unit_type = 1;
     $default_max_value = 100;
     $default_division_value = 10;
 }
 /** get units **/
 $units = wpl_units::get_units($unit_type);
 /** MIN/MAX extoptions **/
 $extoptions = explode(',', $field['extoption']);
 $min_value = (isset($extoptions[0]) and trim($extoptions[0]) != '') ? $extoptions[0] : 0;
 $max_value = isset($extoptions[1]) ? $extoptions[1] : $default_max_value;
 $division = isset($extoptions[2]) ? $extoptions[2] : $default_division_value;
 $separator = isset($extoptions[3]) ? $extoptions[3] : ',';
 switch ($field['type']) {
     case 'minmax':
         $show = 'minmax';
         $input_type = 'text';
         break;
     case 'minmax_slider':
         $show = 'minmax_slider';
         $input_type = 'hidden';
         break;
Exemple #7
0
 /**
  * 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;
 }
Exemple #8
0
        $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;
}
Exemple #9
0
" class="wpl_listing_saved_span"></span>
<?php 
    $done_this = true;
} elseif (in_array($type, array('mmprice', 'mmvolume', 'mmarea', 'mmlength')) and !$done_this) {
    _wpl_import('libraries.units');
    if ($type == 'mmprice') {
        $units = wpl_units::get_units(4);
    }
    if ($type == 'mmvolume') {
        $units = wpl_units::get_units(3);
    }
    if ($type == 'mmarea') {
        $units = wpl_units::get_units(2);
    }
    if ($type == 'mmlength') {
        $units = wpl_units::get_units(1);
    }
    $value_max = isset($values[$field->table_column . '_max']) ? $values[$field->table_column . '_max'] : 0;
    ?>
<label for="wpl_c_<?php 
    echo $field->id;
    ?>
"><?php 
    echo __($label, WPL_TEXTDOMAIN);
    if (in_array($mandatory, array(1, 2))) {
        ?>
<span class="required-star">*</span><?php 
    }
    ?>
</label>
<input onkeyup="wpl_thousand_sep('wpl_c_<?php 
Exemple #10
0
        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);
?>
</label>
            <input type="text" id="pr_price_min" name="sf_min_price" />
        </div>
        
        <div class="plugin-row wpl_shortcode_parameter wpl_hidden_element pr_property_listing">
            <label for="pr_price_max"><?php 
echo __('Price (Max)', WPL_TEXTDOMAIN);
?>
</label>
            <input type="text" id="pr_price_max" name="sf_max_price" />
        </div>
        
        <div class="plugin-row wpl_shortcode_parameter wpl_hidden_element pr_property_listing">
            <?php 
$units = wpl_units::get_units(4);
?>
            <label for="pr_price_unit_selectbox"><?php 
echo __('Price Unit', WPL_TEXTDOMAIN);
?>
</label>
            <select id="pr_price_unit_selectbox" name="sf_unit_price">
                <?php 
foreach ($units as $unit) {
    ?>
				<option value="<?php 
    echo $unit['id'];
    ?>
"><?php 
    echo __($unit['name'], WPL_TEXTDOMAIN);
    ?>
Exemple #12
0
 /**
  * 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;
 }