/** * Listing Contact activity. It's for contacting to a listing agent. * @author Howard <*****@*****.**> * @static * @param array $params * @return boolean */ public static function contact_agent($params) { $replacements = $params[0]; $notification = new wpl_notifications('email'); $notification->prepare(2, $replacements); /** Disabled **/ if (!$notification->notification_data['enabled']) { return false; } $property_id = $params[0]['property_id']; $property = wpl_property::get_property_raw_data($property_id); $user = wpl_users::get_user($property['user_id']); $property_title = wpl_property::update_property_title($property); $replacements['listing_id'] = '<a href="' . wpl_property::get_property_link(NULL, $property_id) . '">' . $property['mls_id'] . ' (' . $property_title . ')</a>'; $notification->replacements = $notification->set_replacements($replacements); $notification->rendered_content = $notification->render_notification_content(); $notification->recipients = $notification->set_recipients(array($user->data->user_email)); $notification->send(); return true; }
private function get_parents() { $kind = wpl_request::getVar('kind', 1); $term = wpl_request::getVar('term', ''); $parents = wpl_property::select_active_properties("AND (`mls_id` LIKE '%{$term}%' OR `field_312` LIKE '%{$term}%' OR `field_313` LIKE '%{$term}%') AND `kind`='{$kind}'", '`id`, `mls_id`, `field_312`, `field_313`, `listing`, `property_type`'); $results = array(); foreach ($parents as $parent) { $label = '#' . $parent['mls_id'] . ' - ' . wpl_property::update_property_title(NULL, $parent['id']); $results[$parent['id']] = array('id' => $parent['id'], 'label' => $label, 'value' => $parent['mls_id']); } echo json_encode($results); exit; }
$smart_resize = isset($this->instance['data']['smart_resize']) ? $this->instance['data']['smart_resize'] : false; $slide_interval = isset($this->instance['data']['slide_interval']) ? $this->instance['data']['slide_interval'] : 3000; /** add Layout js **/ $js[] = (object) array('param1' => 'modern.slider', 'param2' => 'js/libraries/wpl.modern.slider.min.js'); foreach ($js as $javascript) { wpl_extensions::import_javascript($javascript); } $larg_images = $thumbnail = NULL; foreach ($wpl_properties as $key => $gallery) { if (isset($gallery["items"]["gallery"][0])) { $params = array(); $params['image_name'] = $gallery["items"]["gallery"][0]->item_name; $params['image_parentid'] = $gallery["items"]["gallery"][0]->parent_id; $params['image_parentkind'] = $gallery["items"]["gallery"][0]->parent_kind; $params['image_source'] = wpl_global::get_upload_base_path() . $params['image_parentid'] . DS . $params['image_name']; $image_title = wpl_property::update_property_title($gallery['raw']); if (isset($gallery['items']['gallery'][0]->item_extra2) and trim($gallery['items']['gallery'][0]->item_extra2) != '') { $image_alt = $gallery['items']['gallery'][0]->item_extra2; } else { $image_alt = $gallery['raw']['meta_keywords']; } $image_description = $gallery["items"]["gallery"][0]->item_extra2; if ($gallery["items"]["gallery"][0]->item_cat != 'external') { $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params); $thumbnail_url = wpl_images::create_gallary_image($thumbnail_width, $thumbnail_height, $params); } else { $image_url = $gallery["items"]["gallery"][0]->item_extra3; $thumbnail_url = $gallery["items"]["gallery"][0]->item_extra3; } $larg_images .= ' <li>
$image_width = isset($this->instance['data']['image_width']) ? $this->instance['data']['image_width'] : 90; $image_height = isset($this->instance['data']['image_height']) ? $this->instance['data']['image_height'] : 82; ?> <div class="wpl_carousel_container"> <ul class="simple_list"> <?php foreach ($wpl_properties as $key => $gallery) { if (!isset($gallery["items"]["gallery"][0])) { continue; } $params = array(); $params['image_name'] = $gallery["items"]["gallery"][0]->item_name; $params['image_parentid'] = $gallery["items"]["gallery"][0]->parent_id; $params['image_parentkind'] = $gallery["items"]["gallery"][0]->parent_kind; $params['image_source'] = wpl_global::get_upload_base_path() . $params['image_parentid'] . DS . $params['image_name']; $image_title = isset($gallery['property_title']) ? $gallery['property_title'] : wpl_property::update_property_title($gallery['raw']); if (isset($gallery['items']['gallery'][0]->item_extra2) and trim($gallery['items']['gallery'][0]->item_extra2) != '') { $image_alt = $gallery['items']['gallery'][0]->item_extra2; } else { $image_alt = $gallery['raw']['meta_keywords']; } $image_description = $gallery["items"]["gallery"][0]->item_extra2; if ($gallery["items"]["gallery"][0]->item_cat != 'external') { $image_url = wpl_images::create_gallary_image($image_width, $image_height, $params); } else { $image_url = $gallery["items"]["gallery"][0]->item_extra3; } echo ' <li> <div class="left_section"> <a itemprop="url" href="' . $gallery["property_link"] . '"><span style="width:' . $image_width . 'px;height:' . $image_height . 'px;"><img itemprop="image" src="' . $image_url . '" title="' . $image_title . '" alt="' . $image_alt . '" width="' . $image_width . '" height="' . $image_height . '" style="width: ' . $image_width . 'px; height: ' . $image_height . 'px;" /></span></a>
/** * Finalize a property and render needed data * @author Howard <*****@*****.**> * @static * @param int $property_id * @param string $mode * @param int $user_id * @return boolean */ public static function finalize($property_id, $mode = 'edit', $user_id = '') { $property = self::get_property_raw_data($property_id); $update_query = self::generate_finalize_query($property, $property_id); $update_query .= "`finalized`='1',"; if (wpl_global::check_access('confirm', $user_id)) { $update_query .= "`confirmed`='1',"; } $update_query = trim($update_query, ', '); $query = "UPDATE `#__wpl_properties` SET " . $update_query . " WHERE `id`='{$property_id}'"; wpl_db::q($query, 'update'); /** Remove Property Cache **/ wpl_property::clear_property_cache($property_id); /** Multilingual **/ if (wpl_global::check_multilingual_status()) { $languages = wpl_addon_pro::get_wpl_languages(); $current_language = wpl_global::get_current_language(); foreach ($languages as $language) { wpl_global::switch_language($language); wpl_property::update_text_search_field($property_id); wpl_property::update_alias($property); wpl_property::update_property_page_title($property); wpl_property::update_property_title($property); /** generate rendered data **/ wpl_property::generate_rendered_data($property_id); } /** Switch to current language again **/ wpl_global::switch_language($current_language); } else { wpl_property::update_text_search_field($property_id); wpl_property::update_alias($property); wpl_property::update_property_page_title($property); wpl_property::update_property_title($property); /** generate rendered data **/ wpl_property::generate_rendered_data($property_id); } /** Fixes **/ wpl_property::fix_aliases($property, $property_id); wpl_property::update_numbs($property_id, $property); /** throwing events **/ if ($mode == 'add') { wpl_events::trigger('add_property', $property_id); } elseif ($mode == 'edit') { wpl_events::trigger('edit_property', $property_id); } if (wpl_global::check_access('confirm', $user_id)) { wpl_events::trigger('property_confirm', $property_id); } return true; }
} elseif ($type == 'url' and !$done_this) { if (trim($value) != '') { $return['field_id'] = $field->id; $return['type'] = $field->type; $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);
/** * Renders Parent Field * @author Howard <*****@*****.**> * @static * @param int $property_id * @param string $parent_column * @return string */ public static function render_parent($property_id, $parent_column = 'parent', $ids = false) { $parents = array(); if ($ids) { $parents[] = $property_id; } else { $parents[] = wpl_property::update_property_title(NULL, $property_id); } $parent_id = wpl_property::get_parent($property_id); if ($parent_id) { $parents[] = self::render_parent($parent_id, $parent_column, $ids); } $glue = $ids ? ',' : ' / '; return implode($glue, $parents); }
} elseif ($type == 'parent' and !$done_this) { if (trim($value)) { $return['field_id'] = $field->id; $return['type'] = $field->type; $return['name'] = __($field->name, WPL_TEXTDOMAIN); $parents_ids = wpl_render::render_parent($value, isset($options['key']) ? $options['key'] : 'parent', true); $value_str = ''; $parents = array_reverse(explode(',', $parents_ids)); foreach ($parents as $parent) { $value_str .= '<a href="' . wpl_property::get_property_link(NULL, $parent) . '">' . trim(wpl_property::update_property_title(NULL, $parent), ', ') . '</a> / '; } $return['value'] = trim($value_str, '/ '); $parents_html_str = ''; $parents = array_reverse(explode(',', $parents_ids)); foreach ($parents as $parent) { $parents_html_str .= '<a href="' . wpl_property::get_property_link(NULL, $parent) . '"><b>' . trim(wpl_property::update_property_title(NULL, $parent), ', ') . '</b></a> / '; } $return['html'] = trim($parents_html_str, '/ '); } $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;