Beispiel #1
0
 /**
  * Render date time
  * @author Howard <*****@*****.**>
  * @static
  * @param string $datetime
  * @param mixed $year
  * @param mixed $month
  * @param mixed $day
  * @return string
  */
 public static function render_datetime($datetime, $year = '', $month = '', $day = '')
 {
     if (trim($datetime) == '0000-00-00' or trim($datetime) == '0000-00-00 00:00:00') {
         return '';
     }
     $tmp = explode(' ', $datetime);
     $date = isset($tmp[0]) ? $tmp[0] : '';
     $time = isset($tmp[1]) ? $tmp[1] : '';
     $output = wpl_render::render_date($date) . ' ' . $time;
     return $output;
 }
Beispiel #2
0
 private function save($table_name, $table_column, $value, $item_id)
 {
     $field_type = wpl_global::get_db_field_type($table_name, $table_column);
     if ($field_type == 'datetime' or $field_type == 'date') {
         $value = wpl_render::derender_date($value);
     } else {
         $value = wpl_db::escape($value);
     }
     $res = wpl_db::set($table_name, $item_id, $table_column, $value, 'id');
     $res = (int) $res;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
Beispiel #3
0
 /**
  * Renders attachments
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $attachments
  * @return array
  */
 public static function render_attachments($attachments = array())
 {
     _wpl_import('libraries.render');
     /** force to array **/
     $attachments = (array) $attachments;
     $return = array();
     $i = 0;
     foreach ($attachments as $attachment) {
         /** force to array **/
         $attachment = (array) $attachment;
         $att_path = self::get_path($attachment['parent_id'], $attachment['parent_kind']) . $attachment['item_name'];
         $att_url = self::get_folder($attachment['parent_id'], $attachment['parent_kind']) . $attachment['item_name'];
         /** existance check **/
         if (!wpl_file::exists($att_path)) {
             continue;
         }
         $pathinfo = @pathinfo($att_path);
         $filesize = @filesize($att_path);
         $return[$i]['item_id'] = $attachment['id'];
         $return[$i]['name'] = (isset($attachment['item_extra1']) and trim($attachment['item_extra1']) != '') ? $attachment['item_extra1'] : $attachment['item_name'];
         $return[$i]['path'] = $att_path;
         $return[$i]['url'] = $att_url;
         $return[$i]['size'] = $filesize;
         $return[$i]['rendered_size'] = wpl_render::render_file_size($filesize);
         $return[$i]['title'] = (string) $attachment['item_extra1'];
         $return[$i]['description'] = (string) $attachment['item_extra2'];
         $return[$i]['category'] = $attachment['item_cat'];
         $return[$i]['ext'] = $pathinfo['extension'];
         $return[$i]['raw'] = $attachment;
         /** attachment icon **/
         $icon_url = wpl_global::get_wpl_asset_url('img/extentions/' . $pathinfo['extension'] . '.png');
         $icon_path = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'extentions' . DS . $pathinfo['extension'] . '.png';
         if (!wpl_file::exists($icon_path)) {
             $icon_url = wpl_global::get_wpl_asset_url('img/extentions/default.png');
             $icon_path = WPL_ABSPATH . DS . 'assets' . DS . 'img' . DS . 'extentions' . DS . 'default.png';
         }
         $return[$i]['icon_path'] = $icon_path;
         $return[$i]['icon_url'] = $icon_url;
         $i++;
     }
     return $return;
 }
Beispiel #4
0
 /**
  * Updates property page title
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @param boolean $force
  * @return string
  */
 public static function update_property_page_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_312';
     $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 page 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 = wpl_global::get_listings($property_data['listing'])->name;
     $property_type = wpl_global::get_property_types($property_data['property_type'])->name;
     $title = array();
     $title['property_type'] = __($property_type, WPL_TEXTDOMAIN);
     $title['listing'] = __($listing, WPL_TEXTDOMAIN);
     if (trim($property_data['rooms'])) {
         $title['rooms'] = $property_data['rooms'] . __('Room' . ($property_data['rooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     if (trim($property_data['bedrooms'])) {
         $title['bedrooms'] = $property_data['bedrooms'] . __('Bedroom' . ($property_data['bedrooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     if (trim($property_data['bathrooms'])) {
         $title['bathrooms'] = $property_data['bathrooms'] . __('Bathroom' . ($property_data['bathrooms'] > 1 ? 's' : ''), WPL_TEXTDOMAIN);
     }
     $title['price'] = __('Price', WPL_TEXTDOMAIN) . ' ' . wpl_render::render_price($property_data['price'], $property_data['price_unit']);
     $title['id'] = $property_data['mls_id'];
     $title_str = implode(' - ', $title);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_property_page_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;
 }
Beispiel #5
0
        }
        if (trim($listing_types_str)) {
            $query .= " AND `listing` IN ({$listing_types_str})";
        }
    }
    $done_this = true;
} elseif ($format == 'datemin' and !$done_this) {
    _wpl_import('libraries.render');
    $min = $value;
    $max = isset($vars['sf_datemax_' . $table_column]) ? $vars['sf_datemax_' . $table_column] : '';
    if (trim($min) != '') {
        $min = wpl_render::derender_date($min);
        $query .= " AND `" . $table_column . "` >= '" . $min . "'";
    }
    if (trim($max) != '') {
        $max = wpl_render::derender_date($max);
        $query .= " AND `" . $table_column . "` <= '" . $max . "'";
    }
    $done_this = true;
} elseif ($format == 'gallery' and !$done_this) {
    if ($value != '-1' and trim($value) != '') {
        $query .= " AND (`pic_numb`>0)";
    }
    $done_this = true;
} elseif ($format == 'tmin' and !$done_this) {
    if ($value != '-1' and trim($value) != '') {
        $min = $value;
        $max = isset($vars['sf_tmax_' . $table_column]) ? $vars['sf_tmax_' . $table_column] : 999999999999;
        $query .= " AND `" . $table_column . "` >= '" . $min . "' AND `" . $table_column . "` <= '" . $max . "'";
    }
    $done_this = true;
Beispiel #6
0
        if (trim($listing_types_str)) {
            $query .= " AND `listing` IN ({$listing_types_str})";
        }
    }
    $done_this = true;
} elseif ($format == 'datemin' and !$done_this) {
    _wpl_import('libraries.render');
    if (trim($value) != '') {
        $value = wpl_render::derender_date($value);
        $query .= " AND DATE(`" . $table_column . "`) >= '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'datemax' and !$done_this) {
    _wpl_import('libraries.render');
    if (trim($value) != '') {
        $value = wpl_render::derender_date($value);
        $query .= " AND DATE(`" . $table_column . "`) <= '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'rawdatemin' and !$done_this) {
    if (trim($value) != '') {
        $query .= " AND DATE(`" . $table_column . "`) >= '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'rawdatemax' and !$done_this) {
    if (trim($value) != '') {
        $query .= " AND DATE(`" . $table_column . "`) <= '" . $value . "'";
    }
    $done_this = true;
} elseif ($format == 'gallery' and !$done_this) {
    if ($value != '-1' and trim($value) != '') {
Beispiel #7
0
"><?php 
    echo __($label, WPL_TEXTDOMAIN);
    if (in_array($mandatory, array(1, 2))) {
        ?>
<span class="required-star">*</span><?php 
    }
    ?>
</label>
    <input type="text" id="wpl_c_<?php 
    echo $field->id;
    ?>
" name="<?php 
    echo $field->table_column;
    ?>
" value="<?php 
    echo wpl_render::render_date($value);
    ?>
" onchange="ajax_save('<?php 
    echo $field->table_name;
    ?>
', '<?php 
    echo $field->table_column;
    ?>
', this.value, '<?php 
    echo $item_id;
    ?>
', '<?php 
    echo $field->id;
    ?>
');" <?php 
    echo (isset($options['readonly']) and $options['readonly'] == 1) ? 'disabled="disabled"' : '';
Beispiel #8
0
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        $title = (isset($options['link_title']) and trim($options['link_title']) != '') ? $options['link_title'] : $value;
        $target = (isset($options['link_target']) and trim($options['link_target']) != '') ? $options['link_target'] : '_blank';
        $return['value'] = '<a href="' . $value . '" target="' . $target . '">' . $title . '</a>';
    }
    $done_this = true;
} elseif ($type == 'parent' and !$done_this) {
    if (trim($value)) {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        $return['value'] = wpl_property::update_property_title(NULL, $value);
    }
    $done_this = true;
} elseif ($type == 'date' and !$done_this) {
    if (trim($value)) {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        $return['value'] = wpl_render::render_date($value);
    }
    $done_this = true;
} elseif ($type == 'datetime' and !$done_this) {
    if (trim($value)) {
        $return['field_id'] = $field->id;
        $return['type'] = $field->type;
        $return['name'] = __($field->name, WPL_TEXTDOMAIN);
        $return['value'] = wpl_render::render_datetime($value);
    }
    $done_this = true;
}