Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Local_Kvartira_View extends Kvartira_View {
- function main ( $realty_id ) {
- $result=false;
- require_once(SITEBILL_DOCUMENT_ROOT.'/apps/system/lib/model/model.php');
- require_once(SITEBILL_DOCUMENT_ROOT.'/apps/system/lib/admin/structure/structure_manager.php');
- require_once(SITEBILL_DOCUMENT_ROOT.'/apps/system/lib/admin/users/user_object_manager.php');
- $Structure_Manager = new Structure_Manager();
- $category_structure = $Structure_Manager->loadCategoryStructure();
- $user_object_manager = new User_Object_Manager();
- $data_model = new Data_Model();
- $form_data = $data_model->get_kvartira_model(false, false);
- $form_data_language = $data_model->get_kvartira_model(false, true);
- $data_model_shared = $data_model->get_kvartira_model(false, true);
- $form_data['data']['fio']['name'] = 'fio';
- $form_data['data']['fio']['title'] = Multilanguage::_('L_FIO');
- $form_data['data']['fio']['value'] = '';
- $form_data['data']['fio']['length'] = 40;
- $form_data['data']['fio']['type'] = 'safe_string';
- $form_data['data']['fio']['required'] = 'on';
- $form_data['data']['fio']['unique'] = 'off';
- $form_data['data']['phone']['name'] = 'phone';
- $form_data['data']['phone']['title'] = Multilanguage::_('L_PHONE');
- $form_data['data']['phone']['value'] = '';
- $form_data['data']['phone']['length'] = 40;
- $form_data['data']['phone']['type'] = 'safe_string';
- $form_data['data']['phone']['required'] = 'on';
- $form_data['data']['phone']['unique'] = 'off';
- if ( $this->getConfigValue('theme') == 'etown' or $this->getConfigValue('theme') == 'domdizart' ) {
- $form_data['data']['url']['name'] = 'url';
- $form_data['data']['url']['title'] = Multilanguage::_('URL_NAME','system');
- $form_data['data']['url']['value'] = '';
- $form_data['data']['url']['length'] = 40;
- $form_data['data']['url']['type'] = 'safe_string';
- $form_data['data']['url']['required'] = 'off';
- $form_data['data']['url']['unique'] = 'off';
- }
- if($this->getConfigValue('more_fields_in_lk')==1){
- require_once(SITEBILL_DOCUMENT_ROOT.'/apps/system/lib/system/user/data/user_data.php');
- $UDM=new User_Data_Manager();
- $form_data=$UDM->init_more_fields($form_data);
- $this->template->assign('see_my_fields', '1');
- }
- $form_user = $user_object_manager->get_user_model();
- $form_data = $data_model->init_model_data_from_db ( 'data', 'id', $realty_id, $form_data['data'], true );
- $form_data_language = $data_model->init_model_data_from_db ( 'data', 'id', $realty_id, $form_data_language['data'], true );
- $data_model_shared = $data_model->init_model_data_from_db ( 'data', 'id', $realty_id, $data_model_shared['data'], true );
- if(!$form_data){
- return $result;
- }
- $result=true;
- $form_data = $data_model->init_language_values($form_data, $form_data_language);
- $topic_id=0;
- if(isset($form_data['topic_id'])){
- $topic_id=(int)$form_data['topic_id']['value'];
- }
- if($topic_id!=0){
- foreach ( $form_data as $key => $item_array ) {
- if($topic_id!=0 && isset($item_array['active_in_topic']) && $item_array['active_in_topic']!=0){
- $active_array_ids = explode(',',$item_array['active_in_topic']);
- $child_cats = array();
- foreach ($active_array_ids as $item_id => $check_active_id) {
- $child_cats_compare = $Structure_Manager->get_all_childs($check_active_id, $category_structure);
- if ( is_array($child_cats_compare) ) {
- $child_cats = array_merge($child_cats, $child_cats_compare);
- }
- $child_cats[]=$check_active_id;
- }
- if(!in_array($topic_id, $child_cats)){
- unset($form_data[$key]);
- continue;
- }
- }
- }
- }
- if($this->getConfigValue('apps.realtypro.show_contact.enable')){
- $form_user = $data_model->init_model_data_from_db ( 'user', 'user_id', $data_model_shared['user_id']['value'], $form_user['user'], true);
- }else{
- $form_user = $data_model->init_model_data_from_db ( 'user', 'user_id', $data_model_shared['user_id']['value'], $form_user['user'], true);
- }
- if(isset($form_data['date_added']) && $form_data['date_added']['value']!=''){
- $form_data['date_added']['value_string']=date('d-m-Y', strtotime($form_data['date_added']['value']));
- }
- if ( $this->getConfigValue('apps.company.timelimit') ) {
- //check timelimit for this company
- $current_time = time();
- $query = "select re_data.* from re_data, re_user u, re_company c where re_data.id=$realty_id and re_data.user_id=u.user_id and u.company_id=c.company_id and c.start_date <= $current_time and c.end_date >= $current_time";
- $this->db->exec($query);
- $this->db->fetch_assoc();
- if ( $this->db->row['id'] == '' ) {
- $this->template->assign('error_message', Multilanguage::_('L_MESSAGE_ARCHIVED_AD'));
- $this->template->assign('main_file_tpl', 'error_message.tpl');
- return false;
- }
- }
- if ( $this->getConfigValue('apps.company.enable') ) {
- require_once (SITEBILL_DOCUMENT_ROOT.'/apps/company/admin/admin.php');
- $company_admin = new company_admin();
- $company_profile = $company_admin->load_by_id($form_user['company_id']['value']);
- if ( $company_profile ) {
- $this->template->assign('company_profile', $company_profile);
- }
- $this->template->assign('user_company_data', $company_admin->getUserCompanyData($form_user['user_id']['value']));
- }
- if(isset($form_data['topic_id'])){
- $form_data['topic_id']['value_string']=$category_structure['catalog'][$form_data['topic_id']['value']]['name'];
- }
- foreach($form_data as $hvd){
- if($hvd['tab']==''){
- $hvd_tabbed[$this->getConfigValue('default_tab_name')][]=$hvd;
- }else{
- $hvd_tabbed[$hvd['tab']][]=$hvd;
- }
- }
- $this->template->assert('hvd_tabbed',$hvd_tabbed);
- require_once SITEBILL_DOCUMENT_ROOT.'/apps/currency/admin/admin.php';
- $CA=new currency_admin();
- $simparams=array(
- 'id'=>(int)$form_data['id']['value'],
- 'topic_id'=>(int)$form_data['topic_id']['value'],
- 'city_id'=>(int)$form_data['city_id']['value'],
- 'district_id'=>(int)$form_data['district_id']['value'],
- 'street_id'=>(int)$form_data['street_id']['value'],
- );
- $this->template->assign('similar_data', $this->getSimilar($category_structure,$simparams));
- if($form_user['login']['value']=='_unregistered'){
- $form_user['fio']['value']=$form_data['fio']['value'];
- $form_user['phone']['value']=$form_data['phone']['value'];
- }
- if($this->getConfigValue('use_google_map')){
- $this->template->assign('map_type', 'google');
- }
- $this->template->assign('admin_user_id', $this->getAdminUserId());
- $this->template->assign('current_user_id', $this->getSessionUserId());
- $this->template->assign('photo', $form_data['image']['image_array']);
- $this->template->assign('user_data', $form_user);
- $this->template->assign('yandex_map_key', $this->getConfigValue('yandex_map_key'));
- $this->template->assign('pmap', $this->getConfigValue('pmap'));
- $params['topic_id'] = (int)$form_data['topic_id']['value'];
- $d=$this->get_category_breadcrumbs( $params, $category_structure, SITEBILL_MAIN_URL.'/' );
- $this->template->assign('realty_breadcrumbs', explode(' / ', $d));
- $this->template->assign('breadcrumbs', $this->get_category_breadcrumbs( $params, $category_structure, SITEBILL_MAIN_URL.'/' ) );
- $hasTlocation=false;
- $tlocationElement='';
- foreach($form_data as $key=>$val){
- if($val['type']=='tlocation'){
- $hasTlocation=true;
- $tlocationElement=$key;
- $form_data['country_id']['value_string']=$val['value_string']['country_id'];
- $form_data['region_id']['value_string']=$val['value_string']['region_id'];
- $form_data['city_id']['value_string']=$val['value_string']['city_id'];
- $form_data['district_id']['value_string']=$val['value_string']['district_id'];
- $form_data['street_id']['value_string']=$val['value_string']['street_id'];
- }
- }
- $this->template->assign('data', $form_data);
- //начало формирования мета-информации и заголовков
- if($hasTlocation){
- $title=$this->get_category_breadcrumbs_string( $params, $category_structure, SITEBILL_MAIN_URL.'/' ).", ".$form_data[$tlocationElement]['tlocation_string'].", ".number_format($form_data['price']['value'],0,',',' ');
- }else{
- $title=$this->get_category_breadcrumbs_string( $params, $category_structure, SITEBILL_MAIN_URL.'/' ).", ".$form_data['city_id']['value_string'].", ".$form_data['street_id']['value_string'].", ".number_format($form_data['price']['value'],0,',',' ');
- }
- if($form_data['meta_title']['value']==''){
- $meta_title=$title;
- }else{
- $meta_title=$form_data['meta_title']['value'];
- }
- $this->template->assign('meta_title', $meta_title);
- $this->template->assign('title', $title);
- if($form_data['meta_description']['value']!=''){
- $this->template->assign('meta_description', $form_data['meta_description']['value']);
- }
- if($form_data['meta_keywords']['value']!=''){
- $this->template->assign('meta_keywords', $form_data['meta_keywords']['value']);
- }
- //конец формирования мета-информации и заголовков
- if(1==$this->getConfigValue('apps.comment.enable')){
- require_once SITEBILL_DOCUMENT_ROOT.'/apps/comment/admin/admin.php';
- require_once SITEBILL_DOCUMENT_ROOT.'/apps/comment/site/site.php';
- $CoM=new comment_site();
- require_once(SITEBILL_DOCUMENT_ROOT.'/apps/system/lib/system/user/login.php');
- $Login = new Login();
- $user_id=(int)$Login->getSessionUserId();
- $commentsPanel=$CoM->generateCommentPanel($user_id, 'data', $realty_id);
- }
- $gdata=array();
- $gd=array();
- foreach ($form_data as $key=>$value){
- if($key=='city_id'){
- $gd['city']=SiteBill::iconv(SITE_ENCODING, 'utf-8', $value['value_string']);
- }elseif($key=='street_id'){
- $gd['street']=SiteBill::iconv(SITE_ENCODING, 'utf-8', $value['value_string']);
- }elseif($key=='price'){
- $gd['price']=$value['value'];
- }elseif($key=='topic_id'){
- $gd['type_sh']=SiteBill::iconv(SITE_ENCODING, 'utf-8', $value['value_string']);
- }else{
- $gd[$key]=$value['value'];
- }
- }
- if(file_exists(SITEBILL_DOCUMENT_ROOT.'/template/frontend/'.$this->getConfigValue('theme').'/realty_on_map.tpl')){
- global $smarty;
- $smarty->assign('realty', $gd);
- $html=$smarty->fetch(SITEBILL_DOCUMENT_ROOT.'/template/frontend/'.$this->getConfigValue('theme').'/realty_on_map.tpl');
- $html = str_replace("\r\n", ' ', $html);
- $html = str_replace("\n", ' ', $html);
- $html = str_replace("\t", ' ', $html);
- $html = addslashes($html);
- }else{
- $html = '';
- }
- $gd['html']=SiteBill::iconv(SITE_ENCODING, 'utf-8', $html);
- $gd['href']='#';
- $geoobjects_collection=array();
- if(isset($form_data['geo']) && $form_data['geo']['value']['lat']!='' && $form_data['geo']['value']['lng']!=''){
- $gd['geo_lat']=$form_data['geo']['value']['lat'];
- $gd['geo_lng']=$form_data['geo']['value']['lng'];
- $gc=$gd['geo_lat'].'_'.$gd['geo_lng'];
- $geoobjects_collection[$gc]['html'].=$gd['html'];
- $geoobjects_collection[$gc]['count']++;
- $geoobjects_collection[$gc]['lat']=$gd['geo_lat'];
- $geoobjects_collection[$gc]['lng']=$gd['geo_lng'];
- }
- $this->template->assert('geoobjects_collection_clustered', json_encode($geoobjects_collection));
- if ( $this->getConfigValue('theme') != 'estate' and !file_exists(SITEBILL_DOCUMENT_ROOT.'/template/frontend/'.$this->getConfigValue('theme').'/realty_view.tpl') ) {
- $this->template->assign('main_file_tpl', '../estate/realty_view.tpl');
- } else {
- $this->template->assign('main_file_tpl', 'realty_view.tpl');
- }
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement