/** * 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; }
/** * Sets property single page parameters * @author Howard <*****@*****.**> * @param int $proeprty_id */ public function set_property_page_params($proeprty_id) { _wpl_import('libraries.property'); $current_link_url = wpl_global::get_full_url(); $property_data = wpl_property::get_property_raw_data($proeprty_id); $locale = wpl_global::get_current_language(); $this->property_page_title = wpl_property::update_property_page_title($property_data); $meta_keywords_column = 'meta_keywords'; if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($meta_keywords_column, $property_data['kind'])) { $meta_keywords_column = wpl_addon_pro::get_column_lang_name($meta_keywords_column, $locale, false); } $this->property_keywords = $property_data[$meta_keywords_column]; $meta_description_column = 'meta_description'; if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($meta_description_column, $property_data['kind'])) { $meta_description_column = wpl_addon_pro::get_column_lang_name($meta_description_column, $locale, false); } $this->property_description = $property_data[$meta_description_column]; $html = wpl_html::getInstance(); /** set title **/ $html->set_title($this->property_page_title); /** set meta keywords **/ $html->set_meta_keywords($this->property_keywords); /** set meta description **/ $html->set_meta_description($this->property_description); /** SET og meta parameters for social websites like facebook etc **/ wpl_html::$canonical = str_replace('&', '&', $current_link_url); $html->set_custom_tag('<meta property="og:type" content="property" />'); $html->set_custom_tag('<meta property="og:locale" content="' . $locale . '" />'); $content_column = 'field_308'; if (wpl_global::check_multilingual_status() and wpl_addon_pro::get_multiligual_status_by_column($content_column, $property_data['kind'])) { $content_column = wpl_addon_pro::get_column_lang_name($content_column, $locale, false); } $html->set_custom_tag('<meta property="og:url" content="' . str_replace('&', '&', $current_link_url) . '" />'); $html->set_custom_tag('<meta property="og:title" data-page-subject="true" content="' . $this->property_page_title . '" />'); $html->set_custom_tag('<meta property="og:description" content="' . strip_tags($property_data[$content_column]) . '" />'); $html->set_custom_tag('<meta property="twitter:card" content="summary" />'); $html->set_custom_tag('<meta property="twitter:title" content="' . $this->property_page_title . '" />'); $html->set_custom_tag('<meta property="twitter:description" content="' . strip_tags($property_data[$content_column]) . '" />'); $html->set_custom_tag('<meta property="twitter:url" content="' . str_replace('&', '&', $current_link_url) . '" />'); $gallery = wpl_items::get_gallery($proeprty_id, $property_data['kind']); if (is_array($gallery) and count($gallery)) { foreach ($gallery as $image) { $html->set_custom_tag('<meta property="og:image" content="' . $image['url'] . '" />'); $html->set_custom_tag('<meta property="twitter:image" content="' . $image['url'] . '" />'); } } }