From 3cd061627a20a26ea6baea7b08a23008826997ee Mon Sep 17 00:00:00 2001
From: Vodhin <135135923+Vodhin@users.noreply.github.com>
Date: Fri, 6 Dec 2024 16:47:46 -0500
Subject: [PATCH] Bug fixes and Feature Updates
---
e_module.php | 2 +
estate_defs.php | 23 +
estate_setup.php | 25 +-
estate_sidebar_menu.php | 1 -
listings.php | 1332 +++++++++++++++++++--------------------
5 files changed, 703 insertions(+), 680 deletions(-)
diff --git a/e_module.php b/e_module.php
index 908e29e..4d861fe 100644
--- a/e_module.php
+++ b/e_module.php
@@ -38,6 +38,8 @@
}
unset($ESTPLUG,$k,$v);
+ //getperms('P') --> is now --> e_user_model::checkPluginAdminPerms()
+
// define current user's premissions
if(ADMINPERMS === '0'){
define("EST_USERPERM", 4);
diff --git a/estate_defs.php b/estate_defs.php
index 08f9459..4b0cfb5 100644
--- a/estate_defs.php
+++ b/estate_defs.php
@@ -719,6 +719,7 @@ function estGetSubDivDta($subd_idx,$subd_city=0){
$media = estGetMediaRows($subd_idx,0);
if($dbRow1 = $sql->retrieve('estate_subdiv', '*', 'subd_idx="'.$subd_idx.'"',true)){
$RET = array_merge($dbRow1[0],$media);
+ //$RET['features']['sub'] = $sql->retrieve('estate_featurelist', '*', 'featurelist_lev="0" AND featurelist_levidx="'.$subd_idx.'"',true);
}
else{
$RET = array('subd_idx'=>0,'subd_city'=>0,'subd_name'=>'','subd_type'=>2,'subd_url'=>'','subd_hoaname'=>'','subd_hoaweb'=>'','subd_hoareq'=>0,'subd_hoafee'=>0,'subd_hoafrq'=>0,'subd_hoaappr'=>0,'subd_hoaland'=>0,'subd_landfee'=>0,'subd_landfreq'=>0,'subd_description'=>'');
@@ -727,6 +728,7 @@ function estGetSubDivDta($subd_idx,$subd_city=0){
if($subd_city == 0 && intval($RET['subd_city']) > 0){$subd_city = intval($RET['subd_city']);}
if($dbRow1b = $sql->retrieve('estate_city', '*', 'city_idx="'.$subd_city.'"',true)){
$RET = array_merge($RET,$dbRow1b[0]);
+ //$RET['features']['city'] = $sql->retrieve('estate_featurelist', '*', 'featurelist_lev="3" ',true); //AND featurelist_levidx="'.$subd_city.'"
}
else{
$RET['city_idx'] = 0;
@@ -739,6 +741,27 @@ function estGetSubDivDta($subd_idx,$subd_city=0){
}
+ /*
+ if($fcats = $sql->retrieve('estate_featcats', '*', 'WHERE NOT featcat_lev = "2"',true)){
+ foreach($fcats as $fk=>$fv){
+ if(!is_array($RET['fcat'][$fv['featcat_lev']])){$RET['fcat'][$fv['featcat_lev']] = array();}
+ array_push($RET['fcat'][$fv['featcat_lev']],$fv);
+ }
+ }
+ */
+ //$RET['fcat'] = $sql->retrieve('estate_featcats', '*', 'WHERE NOT featcat_lev = "2" ORDER BY featcat_lev ASC',true);
+
+ /*
+ $TQRY = "SELECT #estate_features.*, #estate_featcats.* FROM #estate_features LEFT JOIN #estate_featcats ON feature_cat = featcat_idx WHERE NOT featcat_lev = '2'";
+ if($sql->gen($TQRY)){
+ $fi = 0;
+ while($rows = $sql->fetch()){
+ $RET['fcat'][$fi] = $rows;
+ $fi++;
+ }
+ }
+ */
+
$RET['spaces'] = array('city'=>array(),'subd'=>array());
diff --git a/estate_setup.php b/estate_setup.php
index 38a8334..2435118 100644
--- a/estate_setup.php
+++ b/estate_setup.php
@@ -52,9 +52,19 @@ function install_post($var){
else{$msg->addWarning('
'.EST_INST_INITSETUP.': '.EST_GEN_AGENT.' '.EST_GEN_PROFILES.'
- '.EST_INST_FISRTAGENTFAIL.'
');}
+ //load Preset Data
+ /** inserts some preset data into the following tables:
+ * estate_zoning
+ * estate_listypes
+ * estate_states
+ * estate_featcats
+ * estate_features
+ * estate_subdivcats
+ * estate_group
+ **/
if($sql->isEmpty('estate_features')){
- $ret3 = e107::getXml(true)->e107Import(e_PLUGIN."estate/xml/features.xml");
+ $ret3 = e107::getXml(true)->e107Import(e_PLUGIN."estate/xml/presets.xml");
if(!empty($ret3['success'])){
$msg->addSuccess(EST_INST_FEATURES1);
}
@@ -65,21 +75,10 @@ function install_post($var){
}
- if($sql->isEmpty('estate_states')){
- $ret3 = e107::getXml(true)->e107Import(e_PLUGIN."estate/xml/states.xml");
- if(!empty($ret3['success'])){
- $msg->addSuccess(EST_INST_STATES1);
- }
- if(!empty($ret3['failed'])){
- $msg->addError(EST_INST_STATES2);
- $msg->addDebug(print_a($ret3['failed'],true));
- }
- }
-
+ //load Sample Property
if($sql->isEmpty('estate_properties')){
$ret3 = e107::getXml(true)->e107Import(e_PLUGIN."estate/xml/sample_prop.xml");
if(!empty($ret3['success'])){
-
$propMSG = EST_INST_SAMPLEPROP1;
if(intval($MAINAGTID) > 0){
if($sql->update("estate_properties","prop_agent='".$MAINAGTID."', prop_agency='1' WHERE prop_idx='1' LIMIT 1")){
diff --git a/estate_sidebar_menu.php b/estate_sidebar_menu.php
index 12c8cb3..4bdafd6 100644
--- a/estate_sidebar_menu.php
+++ b/estate_sidebar_menu.php
@@ -60,7 +60,6 @@
}
if(!is_array($MENUTMPL) && isset($EST_PREF['template_menu_ord'])){
- echo 'Pref Menu Loaded
';
if(is_array($EST_PREF['template_menu_ord'])){$MENUTMPL = $EST_PREF['template_menu_ord'];}
elseif(trim($EST_PREF['template_menu_ord']) !== ''){$MENUTMPL = e107::unserialize($EST_PREF['template_menu_ord']);}
}
diff --git a/listings.php b/listings.php
index 3b73c6d..833f040 100644
--- a/listings.php
+++ b/listings.php
@@ -1,667 +1,667 @@
-isInstalled('estate')){
- require_once(HEADERF);
- $ns->tablerender(EST_GEN_LISTINGS,''.(ADMIN ? EST_GEN_PLUGNOTINST : EST_GEN_PLUGUNAVAIL).'
', 'estate-listings');
- require_once(FOOTERF);
- exit;
- }
-
-
-if(intval($EST_PREF['adminonly']) == 1){
- if(ADMIN){$estText = ''.EST_GEN_PLUGADMINONLY.'
';}
- else{
- require_once(HEADERF);
- $ns->tablerender(EST_GEN_LISTINGS,''.EST_GEN_PLUGUNAVAIL.'
', 'estate-listings');
- require_once(FOOTERF);
- exit;
- }
- }
-
-$sql = e107::getDb();
-
-if(e_QUERY){$qs = explode(".", e_QUERY);}
-else{$qs = array('list',0);}
-
-$PROPID = intval($qs[1]);
-
-
-
-e107::css('url',e_PLUGIN.'estate/js/leaflet/leaflet.css');
-e107::css('url',e_PLUGIN.'estate/js/Leaflet.markercluster/dist/MarkerCluster.css');
-e107::css('url',e_PLUGIN.'estate/js/Leaflet.markercluster/dist/MarkerCluster.Default.css');
-
-if(intval($EST_PREF['map_jssrc']) == 1 || trim($EST_PREF['map_key']) == '' || trim($EST_PREF['map_url']) == ''){
- e107::js('estate','js/leaflet/leaflet.js', 'jquery',2);
- }
-else{
- if(trim($EST_PREF['map_key']) !== '' && trim($EST_PREF['map_url']) !== ''){
- e107::js('url',$tp->toHTML($EST_PREF['map_url']).'" integrity="'.$tp->toHTML($EST_PREF['map_key']).'" crossorigin="', 'jquery',2);
- }
- else{
- e107::js('estate','js/leaflet/leaflet.js', 'jquery',2);
- }
- }
-
-
-e107::meta('mobile-web-app-capable','yes'); // example
-e107::js('estate','js/Leaflet.markercluster/dist/leaflet.markercluster.js');
-
-
-e107::js('estate','js/listing.js', 'jquery');
-require_once('estate_defs.php');
-
-$EST_ZONING = array();
-$EST_PROPTYPES = array();
-if($Z1 = $sql->retrieve("SELECT * FROM #estate_zoning",true)){
- foreach($Z1 as $row){$EST_ZONING[$row['zoning_idx']] = $row['zoning_name'];}
- }
-if($Z2 = $sql->retrieve("SELECT * FROM #estate_listypes",true)){
- foreach($Z2 as $row){$EST_PROPTYPES[$row['listype_idx']] = $row['listype_name'];}
- }
-
-
-
-if($qs[0] == 'edit' || $qs[0] == 'new'){
- require_once(e_PLUGIN.'estate/ui/oa.php');
- exit;
- }
-
-
-if(isset($_POST['fltrs'])){
- if(count($_POST['fltrs']) > 0){
- foreach($_POST['fltrs'] as $fk=>$fv){
- if(trim($fv) !== ''){$PSTFLTR .= " AND ".$fk."='".$tp->toDB($fv)."' ";}
- }
- }
- }
-
-
-$orderBy = (isset($_POST['sort']) ? $_POST['sort'][0] : "prop_dateupdated");
-$order = (isset($_POST['sort']) ? $_POST['sort'][1] : "DESC");
-$from = (isset($_POST['from']) ? intval($_POST['from']) : 0);
-$records = (isset($_POST['to']) ? intval($_POST['to']) : 25);
-
-$WHERE = "";
-if(!ADMIN){
- if(intval(USERID) > 0 && intval(EST_USERPERM) == 0){
- if(intval($EST_PREF['public_act']) !== 0 && intval($EST_PREF['public_act']) !== 255 && check_class($EST_PREF['public_act'])){
- $WHERE = "WHERE prop_uidcreate='".USERID."' ".($PROPID > 0 ? "" : " OR (prop_status > 0 AND (prop_datepull > ".$STRTIMENOW." OR prop_datepull = 0))")." ";
- }
- }
- if($WHERE == ""){$WHERE = "WHERE prop_status > 0 AND (prop_datepull > ".$STRTIMENOW." OR prop_datepull = 0) ";}
- }
-
-
-$MQRY = "SELECT #estate_properties.*, #estate_subdiv.subd_name, city_name, city_url, city_timezone, city_description, state_name, state_init, state_url, cnty_name, cnty_url, user_id,user_name,user_loginname,user_email,user_admin,user_perms,user_class,user_signature,user_image, #estate_agents.*, #estate_agencies.* FROM #estate_properties LEFT JOIN #estate_subdiv ON subd_idx = prop_subdiv LEFT JOIN #estate_city ON city_idx = prop_city LEFT JOIN #estate_county ON cnty_idx = prop_county LEFT JOIN #estate_states ON state_idx = prop_state LEFT JOIN #estate_agents ON agent_idx = prop_agent LEFT JOIN #user ON (prop_agent = 0 AND user_id = prop_uidcreate) OR (agent_uid > 0 AND user_id = agent_uid) LEFT JOIN #estate_agencies ON (agent_agcy > 0 AND agency_idx = agent_agcy) OR (agent_agcy = 0 AND agency_idx = prop_agency)";
-
-
-
-
-if($qs[0] == 'agent'){
- $AGENTID = intval($qs[1]);
- $PROPID = 0;
- $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_agent=" : " AND prop_agent=").$AGENTID." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
- }
-
-elseif($qs[0] == 'listby'){
- $AGENTID = intval($qs[1]);
- $PROPID = 0;
- $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_uidcreate=" : " AND prop_uidcreate=").$AGENTID." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
- }
-
-
-elseif($PROPID > 0){
- $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_idx=" : " AND prop_idx=").$PROPID." LIMIT 1";
- //$NPQRY = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE NOT prop_idx=" : " AND NOT prop_idx=").$PROPID." ORDER BY ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
- }
-else{
- $query = $MQRY.$WHERE.$PSTFLTR." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
- }
-
-
-$dberr = $sql->getLastErrorText();
-if($dberr){e107::getMessage()->addError($dberr);}
-unset($dberr);
-
-
-if(!$estQdta = $sql->retrieve($query,true)){
- if($PROPID > 0){
- define("EST_MENU_RENDERED",true);
- require_once(HEADERF);
- $ns->tablerender(EST_GEN_PROPERTY.' '.EST_GEN_VIEW,''.EST_GEN_PROPERTY.' #'.$PROPID.' '.EST_GEN_NOTFOUND.'
','estate-invalid');
- unset($query,$PROPID,$MQRY,$WHERE);
- require_once(FOOTERF);
- exit;
- }
- else{
- e107::getMessage()->addInfo(''.EST_GEN_NOLISTINGS.'
'.(isset($PSTFLTR) ? EST_GEN_BADFILTER1.'['.$PSTFLTR.']' : EST_GEN_CHECKLATER).'');
- }
- }
-
-
-
-include_once('ui/qry.php'); // <-- generates clean $EST_PROP array used here and oa.php
-
-
-
-
-
-$dberr = $sql->getLastErrorText();
-if($dberr){e107::getMessage()->addError($dberr);}
-unset($dberr);
-
-
-//$EST_SAVED
-
-//if(is_array($EST_PROP) && count($EST_PROP) > 0){
-
-
- if($qs[0] == 'pview'){
- //include_once('ui/preview.php');
- exit;
- }
-
- if(check_class($EST_PREF['contact_class'])){
- foreach($EST_PROP as $MPID=>$MDTA){
- if(intval($MDTA['prop_appr']) < 1){
- if(EST_USERPERM < intval($EST_PREF['public_mod']) && intval($MDTA['prop_uidcreate']) !== USERID){
- unset($EST_PROP[$MPID]);
- }
- }
- else{
- $EST_PROP[$MPID]['msgd'] = estGetPrevMsgs($MPID);
- }
- }
- }
-
- $EST_SAVED = array();
- if(check_class($EST_PREF['listing_save'])){
- if($inqDta = $sql->retrieve("SELECT * FROM #estate_msg WHERE ".($PROPID > 0 ? "msg_propidx='".$PROPID."' AND " : "")." msg_mode < '3'",true)){
- foreach($inqDta as $k=>$v){
- $MPID = intval($v['msg_propidx']);
- if(isset($EST_PROP[$MPID])){
- $EST_PROP[$MPID]['likes'] = intval($EST_PROP[$MPID]['likes']) + 1;
- }
- }
- }
-
- if($likeDta = $sql->retrieve("SELECT * FROM #estate_likes".($PROPID > 0 ? " WHERE like_pid='".$PROPID."'" : "")."",true)){
- foreach($likeDta as $k=>$v){
- $MPID = intval($v['like_pid']);
- if(isset($EST_PROP[$MPID])){
- $EST_PROP[$MPID]['likes'] = intval($EST_PROP[$MPID]['likes']) + 1;
- if(intval($v['like_uid']) == USERID && $v['like_ip'] == USERIP){
- $EST_PROP[$MPID]['saved'] = ' actv';
- $EST_SAVED[$MPID]['name'] = $EST_PROP[$MPID]['prop_name'];
- $EST_SAVED[$MPID]['thm'] = $EST_PROP[$MPID]['img'][1]['t'];
- }
- }
- }
- }
-
- unset($inqDta,$likeMsg,$likeDta,$k,$v,$MPID);
- }
-
-
-
- if($PROPID == 0 && $qs[0] == 'view'){$qs[0] = 'list';}
- if($PROPID > 0 && !isset($EST_PROP[$PROPID])){$qs[0] = 'list';}
-
- if($qs[0] == 'view'){
-
- if($PROPID > 0){
- if($EST_PROP[$PROPID]['prop_appr'] == 0){
- e107::getMessage()->addInfo(EST_PROP_APPROVE00);
- }
-
- if(intval($EST_PROP[$PROPID]['prop_status']) == 3 || intval($EST_PROP[$PROPID]['prop_status']) == 4){
- $ESTDTA = estGetSpaces($EST_PROP[$PROPID]);
- }
- else{$ESTDTA = estGetSpaces($EST_PROP[$PROPID],1);}
-
- if(isset($ESTDTA[2])){
- $EST_PROP[$PROPID]['subdiv'] = $ESTDTA[2];
- }
-
- $EST_PROP[$PROPID]['history'] = estGetPropHist($PROPID,$EST_PROP[$PROPID]['prop_dateupdated'],$EST_PROP[$PROPID]['prop_listprice'],$EST_PROP[$PROPID]['prop_status']);
-
-
- $IDIV = estViewCSS($ESTDTA);
- $EST_SPACES = $ESTDTA[1];
- $PROPDTA[0] = $EST_PROP[$PROPID];
-
-
- $TMPLREORDOK = 0;
- if(EST_USERPERM > 2){$TMPLREORDOK++;}
- elseif(EST_USERPERM == 2 && intval($PROPDTA[0]['prop_agency']) == EST_AGENCYID){$TMPLREORDOK++;}
- elseif(EST_USERPERM == 1 && intval($PROPDTA[0]['prop_agent']) == EST_AGENTID){$TMPLREORDOK++;}
- elseif(intval($PROPDTA[0]['prop_uidcreate']) == EST_SELLERUID){$TMPLREORDOK++;}
-
- if($TMPLREORDOK > 0){
- e107::js('estate','js/Sortable/Sortable.js', 'jquery');
- $TFORM1 = '';
- }
-
-
- if(intval($PROPDTA[0]['prop_uidcreate']) !== USERID){
- $PROPDTA[0]['prop_views'] = $PROPDTA[0]['prop_views'] + 1;
- $sql->update("estate_properties","prop_views='".$PROPDTA[0]['prop_views']."' WHERE prop_idx='".$PROPID."' LIMIT 1");
- }
-
- if(trim($PROPDTA[0]['prop_name']) == ''){
- if(trim($PROPDTA[0]['prop_addr1']) == ''){$PROPDTA[0]['prop_name'] = $PROPDTA[0]['prop_addr1'];}
- else{$PROPDTA[0]['prop_name'] = EST_GEN_UNNAMEDPROPERTY;}
- }
-
- $PINS = est_map_pins();
- e107::js('inline','var estMapPins = '.$PINS.'; ', 'jquery',2);
-
- $estHead = $tp->toHTML($PROPDTA[0]['prop_name'].''.$PROPDTA[0]['city_name'].', '.$PROPDTA[0]['state_name'].'
');
- $estPT = $tp->toHTML($PROPDTA[0]['prop_name'].' | '.$PROPDTA[0]['city_name'].' | '.$PROPDTA[0]['state_name']);
- define('e_PAGETITLE',$estPT);
- define('PAGE_NAME', $estPT);
-
- estGetMeta($PROPDTA,$ESTDTA,1);
-
- //e107::meta('mobile-web-app-capable','yes'); // example
-
- $sc = e107::getScBatch('estate',true);
- $sc->setVars($PROPDTA[0]);
-
- require_once(HEADERF);
- $tmpl = e107::getTemplate('estate');
- $tkey = (trim($PROPDTA[0]['prop_template_view']) !== '' ? $PROPDTA[0]['prop_template_view'] : (trim($EST_PREF['template_view']) !== '' ? $EST_PREF['template_view'] : 'default'));
-
- $TEMPLATE = $tmpl['view'][$tkey];
- $tmplct = 0;
- if(isset($PROPDTA[0]['prop_template_view_ord'])){
- if(is_array($PROPDTA[0]['prop_template_view_ord'])){$VIEWTMPL = $PROPDTA[0]['prop_template_view_ord'];}
- elseif(trim($PROPDTA[0]['prop_template_view_ord']) !== ''){$VIEWTMPL = e107::unserialize($PROPDTA[0]['prop_template_view_ord']);}
- }
-
- if(!is_array($VIEWTMPL) && isset($EST_PREF['template_view_ord'])){
- if(is_array($EST_PREF['template_view_ord'])){$VIEWTMPL = $EST_PREF['template_view_ord'];}
- elseif(trim($EST_PREF['template_view_ord']) !== ''){$VIEWTMPL = e107::unserialize($EST_PREF['template_view_ord']);}
- }
-
-
- if(is_array($TEMPLATE['txt'])){
- $tmplct = count($TEMPLATE['txt']);
- if(isset($TEMPLATE['ord']) && isset($VIEWTMPL[$tkey]) && count($VIEWTMPL[$tkey]) > 0){
- if($TMPLREORDOK > 0){
- $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
- $NEWK = array();
- $ALLK = $TEMPLATE['ord'];
- foreach($VIEWTMPL[$tkey] as $sk=>$sv){$NEWK[$sk] = $TEMPLATE['txt'][$sk];}
- foreach($ALLK as $nk=>$nv){if(!$NEWK[$nv]){$NEWK[$nv] = '';}}
- unset($ALLK,$sk,$sv,$nk,$nv,$NEWK['dummy']);
- foreach($NEWK as $ok=>$dta){
- $estText .= $tp->parseTemplate('{ADMIN_REORDER:area=view&templ='.$tkey.'&ok='.$ok.'&ov='.intval($VIEWTMPL[$tkey][$ok]).'}', false, $sc);
- $estText .= $tp->parseTemplate($dta, false, $sc).'';
- }
- unset($NEWK,$ok,$dta);
- }
- else{
- foreach($VIEWTMPL[$tkey] as $ok=>$ov){
- if(isset($TEMPLATE['txt'][$ok]) && $ov == 1){
- $estText .= $tp->parseTemplate($TEMPLATE['txt'][$ok], false, $sc);
- }
- }
- }
- }
- else{
- ksort($TEMPLATE['txt']);
- if($TMPLREORDOK > 0){
- $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
- }
- foreach($TEMPLATE['txt'] as $k=>$tmpv){
- $estText .= $tp->parseTemplate($tmpv, false, $sc);
- }
- }
- }
- else{
- if($TMPLREORDOK > 0){
- $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
- }
- $estText .= $tp->parseTemplate($TEMPLATE['txt'], false, $sc);
- }
-
- $ns->setStyle('main');
- $estText .= $tp->parseTemplate('{PROP_HOADISCLAIMERS}
', false, $sc);
- $estText .= $tp->parseTemplate('{SOCIAL_LINKS}{PROP_NEWICON}{PROP_EDITICONS:for=view}
', false, $sc);
-
- $ns->tablerender(''.$estHead,$TFORM1.''.$estText.'
'.$TFORM2,'estate-view');
-
-
- unset($estHead,$estPT,$estText,$EST_PROP,$VIEWTMPL,$TEMPLATE);
- }
-
- if(USERID == 1){
- //echo propArrayTest($PROPDTA[0]);
- }
-
- }
-
- else{
- $PINS = est_map_pins();
- e107::js('inline','var estMapPins = '.$PINS.'; ', 'jquery',2);
-
- require_once(HEADERF);
- $tmpl = e107::getTemplate('estate');
- $tkey = (trim($EST_PREF['template_list']) !== '' ? $EST_PREF['template_list'] : 'default');
- $sc = e107::getScBatch('estate',true);
- if(is_array($tmpl['list'][$tkey]['txt'])){
- ksort($tmpl['list'][$tkey]['txt']);
- foreach($tmpl['list'][$tkey]['txt'] as $k=>$tmpv){
- $estText .= $tp->parseTemplate($tmpv, false, $sc);
- }
- }
- else{
- $estText = $tp->parseTemplate($tmpl['list'][$tkey]['txt'], false, $sc);
- }
-
- $estText .= $tp->parseTemplate('{PROP_NEWICON}
', false, $sc);
-
- $ns->setStyle('main');
- $ns->tablerender(''.EST_GEN_LISTINGS,''.$estText.'
','estate-list');
- unset($estText,$EST_PROP);
- }
- //}
-
-echo '
-
-
-Estate Plugin by Vodhin
';
-require_once(FOOTERF);
-exit;
-
-
-
-/**
-* e107_class.php
-* @param string $plug_name if null getCoreTemplate method will be called
-* @param string $id - file prefix, e.g. calendar for calendar_template.php, or 'true' or 'null' for same as plugin name.
-* @param string|null $key $YOURTEMPLATE_TEMPLATE[$key]
-* @param boolean $override see {@link getThemeInfo()}
-* @param boolean $merge merge theme with plugin templates, default is false
-* @param boolean $info retrieve template info only
-*
-* function getTemplate($plug_name, $id = null, $key = null, $override = true, $merge = false, $info = false){}
-**/
-
-
-
-function estGetMeta($PROPDTA,$ESTDTA,$MODE=0){
- $tp = e107::getParser();
- $RES = array();
- if($MODE == 1){ //view page
- //$PROPDTA[0]['prop_status']
- $type = $GLOBALS['EST_LISTTYPE1'][$PROPDTA[0]['prop_listype']];
- $zone = $GLOBALS['EST_ZONING'][$PROPDTA[0]['prop_zoning']];
- $propname = $tp->toHTML($type.': '.$PROPDTA[0]['prop_name'].' ('.$zone.')');
- $propsumm = $tp->toHTML(''.strtoupper($PROPDTA[0]['city_name'].', '.$PROPDTA[0]['state_name']).' '.$PROPDTA[0]['prop_summary']);
- $propdesc2 = $tp->toHTML($PROPDTA[0]['prop_description']);
- $kwarr = array(
- $zone,
- $type,
- strtoupper($PROPDTA[0]['prop_country']),
- $PROPDTA[0]['cnty_name'],
- $PROPDTA[0]['state_name'],
- $PROPDTA[0]['city_name'],
- $PROPDTA[0]['prop_zip'],
- $PROPDTA[0]['prop_addr1'].(trim($PROPDTA[0]['prop_addr2']) !== '' ? ','.$PROPDTA[0]['prop_addr2'] : ''),
- $PROPDTA[0]['agent_name'],
- $PROPDTA[0]['agency_name'],
- );
-
- if(intval($PROPDTA[0]['prop_bedtot']) > 0){array_push($kwarr,$PROPDTA[0]['prop_bedtot'].' '.EST_GEN_BED);}
- if(intval($PROPDTA[0]['prop_bathtot']) > 0){array_push($kwarr,$PROPDTA[0]['prop_bathtot'].' '.EST_GEN_BATH);}
- if(trim($PROPDTA[0]['prop_flag']) !== ''){array_push($kwarr,$PROPDTA[0]['prop_flag']);}
-
- //
- e107::meta('description',$propsumm.' '.$propdesc2);
- e107::meta('keywords',$tp->toHTML(implode(",",$kwarr)));
- //
- //
- //
-
- //
- e107::meta('fb:app_id','1024154842269829');
- e107::meta('og:locale','en_us');
- e107::meta('og:title',$propname);
- e107::meta('og:type','website');
- e107::meta('og:url',$PROPDTA[0]['prop_link']);
- e107::meta('og:description',$propsumm.' '.$propdesc2);
-
-
-
-
- if(isset($ESTDTA[0])){
- e107::meta('og:image',EST_PTHABS_PROPTHM.$ESTDTA[0][1]['t']);
- e107::meta('twitter:image',EST_PTHABS_PROPTHM.$ESTDTA[0][1]['t']);
- //foreach($ESTDTA[0] as $mk=>$mv){
- //e107::meta('og:image',EST_PTHABS_PROPTHM.$mv['t']);
- //e107::meta('twitter:image',EST_PTHABS_PROPTHM.$mv['t']);
- //}
- }
-
-
- /*
-
-
-
-
-
-
- */
-
- //
- e107::meta('twitter:card',$propsumm);
- e107::meta('twitter:title',$propname);
- e107::meta('twitter:description',$propsumm.' '.$propdesc2);
-
-
- //e107::meta($name, $content, $extended);
- unset($type,$zone,$propname,$propsumm,$propdesc2);
- }
- else{
-
- }
-
- return $RES;
- }
-
-
-
-
-function estViewCSS($ESTDTA){
- $CSSTOP = estViewImgCSS('#estSlideShow',$ESTDTA[0]);
- if($CSSTOP[0]){
- $CSSTOP[0] = '
-
- /*Estate Plugin CSS*/
-'.$CSSTOP[0];
- e107::css('inline', $CSSTOP[0]);
- }
-
-
- if($CSSTOP[1]){$IDIV = $CSSTOP[1];}
- if($CSSTOP[2]){
- $estPreJS = '
- pics = [];';
- $pli = 0;
- foreach($CSSTOP[2] as $plk=>$plv){
- $estPreJS .= '
- pics['.$pli.'] = new Image();
- pics['.$pli.'].src = "'.EST_PTHABS_PROPTHM.$plv.'";';
- $pli++;
- }
- e107::js('inline', $estPreJS);
- }
-
-
-
- if(isset($ESTDTA[2])){
- $CSSTOP = estViewImgCSS('#estSubDivSlideShow',$ESTDTA[2]['media'],2);
- if($CSSTOP[0]){e107::css('inline', $CSSTOP[0]);}
- if($CSSTOP[1]){$IDIV .= $CSSTOP[1];}
- }
-
- if(isset($ESTDTA[1])){
- foreach($ESTDTA[1] as $k=>$v){
- foreach($v['sp'] as $sok=>$sov){
- foreach($sov as $sk=>$sv){
- if($sv['m']){
- //e107::meta('og:image',EST_PTHABS_PROPTHM.$sv['t']);
- //e107::meta('twitter:image',EST_PTHABS_PROPTHM.$sv['t']);
- $CSSTOP = estViewImgCSS('.SPACE'.$v['ord'].'x'.$sok.'x'.$sk.'img',$sv['m']);
- if($CSSTOP[0]){e107::css('inline', $CSSTOP[0]);}
- }
- }
- }
- }
- }
- return $IDIV;
- }
-
-
-function est_map_pins(){
- $pref = e107::pref();
- $sql = e107::getDb();
- $tp = e107::getParser();
- $ARR1 = array('agcy'=>array(),'prop'=>array());
-
- if(intval($GLOBALS['EST_PREF']['map_include_agency']) == 1){
-
- if($AGY = $sql->retrieve("SELECT #estate_agencies.* FROM #estate_agencies WHERE NOT agency_lat='' AND NOT agency_lon='' ",true)){
- $i = 0;
- foreach($AGY as $k=>$v){
- if(intval($v['agency_pub']) > 0){
- $ARR1['agcy'][$i] = array(
- 'idx'=>$v['agency_idx'],
- 'name1'=>$tp->toHTML($v['agency_name']),
- 'name2'=>'',
- 'addr'=>$v['agency_addr'],
- 'lat'=>$v['agency_lat'],
- 'lon'=>$v['agency_lon'],
- 'thm'=>(intval($v['agency_imgsrc']) == 1 && trim($v['agency_image']) !== '' ? EST_PTHABS_AGENCY.$tp->toHTML($v['agency_image']) : $tp->thumbUrl($pref['sitelogo'],false,false,true)),
- 'zoom'=>$GLOBALS['EST_PREF']['map_zoom_def']
- );
- $i++;
- }
- }
- }
- }
-
- if($GLOBALS['EST_PROP']){
- if(count($GLOBALS['EST_PROP']) > 0){
- if(intval($GLOBALS['PROPID']) > 0){
- foreach($GLOBALS['PROPDTA'] as $k=>$v){
- $ARR1['prop'][0] = array(
- 'idx'=>$v['prop_idx'],
- 'lat'=>$v['prop_lat'],
- 'lon'=>$v['prop_lon'],
- 'lnk'=>null,
- 'name1'=>$tp->toHTML($v['prop_name']),
- 'zoom'=>$v['prop_zoom']
- );
- }
- }
- else{
- $i = 0;
- $incs = (5 - intval($GLOBALS['EST_PREF']['map_include_sold']));
- foreach($GLOBALS['EST_PROP'] as $k=>$v){
- if(intval($v['prop_status']) > 0){
- if(intval($v['prop_status']) <= $incs){
- $ARR1['prop'][$i] = array(
- 'drop'=>estPriceDrop($v,1),
- 'hue'=>estPinColor($v),
- 'feat'=>explode(',',$v['prop_features']),
- 'idx'=>$v['prop_idx'],
- 'lat'=>$v['prop_lat'],
- 'lon'=>$v['prop_lon'],
- 'lnk'=>EST_PTH_LISTINGS.'?view.'.intval($v['prop_idx']).'.0',
- 'name1'=>$tp->toHTML($v['prop_name']),
- 'prc'=>estGetListPrice($v,1),
- 'sta'=>$tp->toHTML(estPinsPropStat($v)),
- 'stat'=>intval($v['prop_status']),
- 'thm'=>$v['img'][1]['t'],
- 'type'=>$v['prop_listype'],
- 'zoom'=>$v['prop_zoom']
- );
- $i++;
- }
- }
- }
- }
- }
- }
- return json_encode($ARR1);
- }
-
-
-function estPinColor($DTA){
- switch(intval($DTA['prop_status'])){
- case 5 :
- return 'estMarkGray';
- break;
- case 4 :
- return 'estMarkYellow';
- break;
- case 3 :
- return null;
- break;
- case 2 :
- return 'estMarkGreen';
- break;
- case 1 :
- return 'estMark';
- break;
- case 0 :
- return null;
- break;
- }
- }
-
-
-
-
-
-function estPinsPropStat($DTA){
- if(intval($DTA['prop_status']) == 5){$ret = (intval($DTA['prop_listype']) == 0 ? EST_GEN_OFFMARKET : EST_GEN_SOLD);}
- elseif(intval($DTA['prop_status']) == 4){$ret = EST_GEN_PENDING; $parm = '';}
- elseif(intval($DTA['prop_status']) == 3){$ret = $GLOBALS['EST_LISTTYPE1'][$DTA['prop_listype']]; $parm = '';}
- elseif(intval($DTA['prop_status']) == 2){
- $parm = '';
- if(intval($DTA['prop_datelive']) > 0 && intval($DTA['prop_datelive']) <= $GLOBALS['STRTIMENOW']){
- $ret = $GLOBALS['EST_LISTTYPE1'][$DTA['prop_listype']];
- }
- elseif(USERID > 0 && (intval($DTA['prop_dateprevw']) > 0 && intval($DTA['prop_dateprevw']) <= $GLOBALS['STRTIMENOW'])){
- $ret = EST_GEN_PREVIEW;
- }
- else{$ret = EST_GEN_COMINGSOON;}
- }
- elseif(intval($DTA['prop_status']) == 1){
- $ret = EST_GEN_COMINGSOON;
- if(!ADMIN){$parm = '';}
- }
- else{$ret = EST_GEN_OFFMARKET;}
- if($ret){return $ret.($parm == 'bullet' ? ' • ' : '');}
- else{return '';}
+isInstalled('estate')){
+ require_once(HEADERF);
+ $ns->tablerender(EST_GEN_LISTINGS,''.(ADMIN ? EST_GEN_PLUGNOTINST : EST_GEN_PLUGUNAVAIL).'
', 'estate-listings');
+ require_once(FOOTERF);
+ exit;
+ }
+
+
+if(intval($EST_PREF['adminonly']) == 1){
+ if(ADMIN){$estText = ''.EST_GEN_PLUGADMINONLY.'
';}
+ else{
+ require_once(HEADERF);
+ $ns->tablerender(EST_GEN_LISTINGS,''.EST_GEN_PLUGUNAVAIL.'
', 'estate-listings');
+ require_once(FOOTERF);
+ exit;
+ }
+ }
+
+$sql = e107::getDb();
+
+if(e_QUERY){$qs = explode(".", e_QUERY);}
+else{$qs = array('list',0);}
+
+$PROPID = intval($qs[1]);
+
+
+
+e107::css('url',e_PLUGIN.'estate/js/leaflet/leaflet.css');
+e107::css('url',e_PLUGIN.'estate/js/Leaflet.markercluster/dist/MarkerCluster.css');
+e107::css('url',e_PLUGIN.'estate/js/Leaflet.markercluster/dist/MarkerCluster.Default.css');
+
+if(intval($EST_PREF['map_jssrc']) == 1 || trim($EST_PREF['map_key']) == '' || trim($EST_PREF['map_url']) == ''){
+ e107::js('estate','js/leaflet/leaflet.js', 'jquery',2);
+ }
+else{
+ if(trim($EST_PREF['map_key']) !== '' && trim($EST_PREF['map_url']) !== ''){
+ e107::js('url',$tp->toHTML($EST_PREF['map_url']).'" integrity="'.$tp->toHTML($EST_PREF['map_key']).'" crossorigin="', 'jquery',2);
+ }
+ else{
+ e107::js('estate','js/leaflet/leaflet.js', 'jquery',2);
+ }
+ }
+
+
+e107::meta('mobile-web-app-capable','yes'); // example
+e107::js('estate','js/Leaflet.markercluster/dist/leaflet.markercluster.js');
+
+
+e107::js('estate','js/listing.js', 'jquery');
+require_once('estate_defs.php');
+
+$EST_ZONING = array();
+$EST_PROPTYPES = array();
+if($Z1 = $sql->retrieve("SELECT * FROM #estate_zoning",true)){
+ foreach($Z1 as $row){$EST_ZONING[$row['zoning_idx']] = $row['zoning_name'];}
+ }
+if($Z2 = $sql->retrieve("SELECT * FROM #estate_listypes",true)){
+ foreach($Z2 as $row){$EST_PROPTYPES[$row['listype_idx']] = $row['listype_name'];}
+ }
+
+
+
+if($qs[0] == 'edit' || $qs[0] == 'new'){
+ require_once(e_PLUGIN.'estate/ui/oa.php');
+ exit;
+ }
+
+
+if(isset($_POST['fltrs'])){
+ if(count($_POST['fltrs']) > 0){
+ foreach($_POST['fltrs'] as $fk=>$fv){
+ if(trim($fv) !== ''){$PSTFLTR .= " AND ".$fk."='".$tp->toDB($fv)."' ";}
+ }
+ }
+ }
+
+
+$orderBy = (isset($_POST['sort']) ? $_POST['sort'][0] : "prop_dateupdated");
+$order = (isset($_POST['sort']) ? $_POST['sort'][1] : "DESC");
+$from = (isset($_POST['from']) ? intval($_POST['from']) : 0);
+$records = (isset($_POST['to']) ? intval($_POST['to']) : 25);
+
+$WHERE = "";
+if(!ADMIN){
+ if(intval(USERID) > 0 && intval(EST_USERPERM) == 0){
+ if(intval($EST_PREF['public_act']) !== 0 && intval($EST_PREF['public_act']) !== 255 && check_class($EST_PREF['public_act'])){
+ $WHERE = "WHERE prop_uidcreate='".USERID."' ".($PROPID > 0 ? "" : " OR (prop_status > 0 AND (prop_datepull > ".$STRTIMENOW." OR prop_datepull = 0))")." ";
+ }
+ }
+ if($WHERE == ""){$WHERE = "WHERE prop_status > 0 AND (prop_datepull > ".$STRTIMENOW." OR prop_datepull = 0) ";}
+ }
+
+
+$MQRY = "SELECT #estate_properties.*, #estate_subdiv.subd_name, city_name, city_url, city_timezone, city_description, state_name, state_init, state_url, cnty_name, cnty_url, user_id,user_name,user_loginname,user_email,user_admin,user_perms,user_class,user_signature,user_image, #estate_agents.*, #estate_agencies.* FROM #estate_properties LEFT JOIN #estate_subdiv ON subd_idx = prop_subdiv LEFT JOIN #estate_city ON city_idx = prop_city LEFT JOIN #estate_county ON cnty_idx = prop_county LEFT JOIN #estate_states ON state_idx = prop_state LEFT JOIN #estate_agents ON agent_idx = prop_agent LEFT JOIN #user ON (prop_agent = 0 AND user_id = prop_uidcreate) OR (agent_uid > 0 AND user_id = agent_uid) LEFT JOIN #estate_agencies ON (agent_agcy > 0 AND agency_idx = agent_agcy) OR (agent_agcy = 0 AND agency_idx = prop_agency)";
+
+
+
+
+if($qs[0] == 'agent'){
+ $AGENTID = intval($qs[1]);
+ $PROPID = 0;
+ $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_agent=" : " AND prop_agent=").$AGENTID." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
+ }
+
+elseif($qs[0] == 'listby'){
+ $AGENTID = intval($qs[1]);
+ $PROPID = 0;
+ $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_uidcreate=" : " AND prop_uidcreate=").$AGENTID." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
+ }
+
+
+elseif($PROPID > 0){
+ $query = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE prop_idx=" : " AND prop_idx=").$PROPID." LIMIT 1";
+ //$NPQRY = $MQRY.$WHERE.(trim($WHERE) == "" ? "WHERE NOT prop_idx=" : " AND NOT prop_idx=").$PROPID." ORDER BY ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
+ }
+else{
+ $query = $MQRY.$WHERE.$PSTFLTR." ORDER BY prop_status ASC, ".$orderBy." ".$order." LIMIT ".intval($from).",".intval($records);
+ }
+
+
+$dberr = $sql->getLastErrorText();
+if($dberr){e107::getMessage()->addError($dberr);}
+unset($dberr);
+
+
+if(!$estQdta = $sql->retrieve($query,true)){
+ if($PROPID > 0){
+ define("EST_MENU_RENDERED",true);
+ require_once(HEADERF);
+ $ns->tablerender(EST_GEN_PROPERTY.' '.EST_GEN_VIEW,''.EST_GEN_PROPERTY.' #'.$PROPID.' '.EST_GEN_NOTFOUND.'
','estate-invalid');
+ unset($query,$PROPID,$MQRY,$WHERE);
+ require_once(FOOTERF);
+ exit;
+ }
+ else{
+ e107::getMessage()->addInfo(''.EST_GEN_NOLISTINGS.'
'.(isset($PSTFLTR) ? EST_GEN_BADFILTER1.'['.$PSTFLTR.']' : EST_GEN_CHECKLATER).'');
+ }
+ }
+
+
+
+include_once('ui/qry.php'); // <-- generates clean $EST_PROP array used here and oa.php
+
+
+
+
+
+$dberr = $sql->getLastErrorText();
+if($dberr){e107::getMessage()->addError($dberr);}
+unset($dberr);
+
+
+//$EST_SAVED
+
+//if(is_array($EST_PROP) && count($EST_PROP) > 0){
+
+
+ if($qs[0] == 'pview'){
+ //include_once('ui/preview.php');
+ exit;
+ }
+
+ if(check_class($EST_PREF['contact_class'])){
+ foreach($EST_PROP as $MPID=>$MDTA){
+ if(intval($MDTA['prop_appr']) < 1){
+ if(EST_USERPERM < intval($EST_PREF['public_mod']) && intval($MDTA['prop_uidcreate']) !== USERID){
+ unset($EST_PROP[$MPID]);
+ }
+ }
+ else{
+ $EST_PROP[$MPID]['msgd'] = estGetPrevMsgs($MPID);
+ }
+ }
+ }
+
+ $EST_SAVED = array();
+ if(check_class($EST_PREF['listing_save'])){
+ if($inqDta = $sql->retrieve("SELECT * FROM #estate_msg WHERE ".($PROPID > 0 ? "msg_propidx='".$PROPID."' AND " : "")." msg_mode < '3'",true)){
+ foreach($inqDta as $k=>$v){
+ $MPID = intval($v['msg_propidx']);
+ if(isset($EST_PROP[$MPID])){
+ $EST_PROP[$MPID]['likes'] = intval($EST_PROP[$MPID]['likes']) + 1;
+ }
+ }
+ }
+
+ if($likeDta = $sql->retrieve("SELECT * FROM #estate_likes".($PROPID > 0 ? " WHERE like_pid='".$PROPID."'" : "")."",true)){
+ foreach($likeDta as $k=>$v){
+ $MPID = intval($v['like_pid']);
+ if(isset($EST_PROP[$MPID])){
+ $EST_PROP[$MPID]['likes'] = intval($EST_PROP[$MPID]['likes']) + 1;
+ if(intval($v['like_uid']) == USERID && $v['like_ip'] == USERIP){
+ $EST_PROP[$MPID]['saved'] = ' actv';
+ $EST_SAVED[$MPID]['name'] = $EST_PROP[$MPID]['prop_name'];
+ $EST_SAVED[$MPID]['thm'] = $EST_PROP[$MPID]['img'][1]['t'];
+ }
+ }
+ }
+ }
+
+ unset($inqDta,$likeMsg,$likeDta,$k,$v,$MPID);
+ }
+
+
+
+ if($PROPID == 0 && $qs[0] == 'view'){$qs[0] = 'list';}
+ if($PROPID > 0 && !isset($EST_PROP[$PROPID])){$qs[0] = 'list';}
+
+ if($qs[0] == 'view'){
+
+ if($PROPID > 0){
+ if($EST_PROP[$PROPID]['prop_appr'] == 0){
+ e107::getMessage()->addInfo(EST_PROP_APPROVE00);
+ }
+
+ if(intval($EST_PROP[$PROPID]['prop_status']) == 3 || intval($EST_PROP[$PROPID]['prop_status']) == 4){
+ $ESTDTA = estGetSpaces($EST_PROP[$PROPID]);
+ }
+ else{$ESTDTA = estGetSpaces($EST_PROP[$PROPID],1);}
+
+ if(isset($ESTDTA[2])){
+ $EST_PROP[$PROPID]['subdiv'] = $ESTDTA[2];
+ }
+
+ $EST_PROP[$PROPID]['history'] = estGetPropHist($PROPID,$EST_PROP[$PROPID]['prop_dateupdated'],$EST_PROP[$PROPID]['prop_listprice'],$EST_PROP[$PROPID]['prop_status']);
+
+
+ $IDIV = estViewCSS($ESTDTA);
+ $EST_SPACES = $ESTDTA[1];
+ $PROPDTA[0] = $EST_PROP[$PROPID];
+
+
+ $TMPLREORDOK = 0;
+ if(EST_USERPERM > 2){$TMPLREORDOK++;}
+ elseif(EST_USERPERM == 2 && intval($PROPDTA[0]['prop_agency']) == EST_AGENCYID){$TMPLREORDOK++;}
+ elseif(EST_USERPERM == 1 && intval($PROPDTA[0]['prop_agent']) == EST_AGENTID){$TMPLREORDOK++;}
+ elseif(intval($PROPDTA[0]['prop_uidcreate']) == EST_SELLERUID){$TMPLREORDOK++;}
+
+ if($TMPLREORDOK > 0){
+ e107::js('estate','js/Sortable/Sortable.js', 'jquery');
+ $TFORM1 = '';
+ }
+
+
+ if(intval($PROPDTA[0]['prop_uidcreate']) !== USERID){
+ $PROPDTA[0]['prop_views'] = $PROPDTA[0]['prop_views'] + 1;
+ $sql->update("estate_properties","prop_views='".$PROPDTA[0]['prop_views']."' WHERE prop_idx='".$PROPID."' LIMIT 1");
+ }
+
+ if(trim($PROPDTA[0]['prop_name']) == ''){
+ if(trim($PROPDTA[0]['prop_addr1']) == ''){$PROPDTA[0]['prop_name'] = $PROPDTA[0]['prop_addr1'];}
+ else{$PROPDTA[0]['prop_name'] = EST_GEN_UNNAMEDPROPERTY;}
+ }
+
+ $PINS = est_map_pins();
+ e107::js('inline','var estMapPins = '.$PINS.'; ', 'jquery',2);
+
+ $estHead = $tp->toHTML($PROPDTA[0]['prop_name'].''.$PROPDTA[0]['city_name'].', '.$PROPDTA[0]['state_name'].'
');
+ $estPT = $tp->toHTML($PROPDTA[0]['prop_name'].' | '.$PROPDTA[0]['city_name'].' | '.$PROPDTA[0]['state_name']);
+ define('e_PAGETITLE',$estPT);
+ define('PAGE_NAME', $estPT);
+
+ estGetMeta($PROPDTA,$ESTDTA,1);
+
+ //e107::meta('mobile-web-app-capable','yes'); // example
+
+ $sc = e107::getScBatch('estate',true);
+ $sc->setVars($PROPDTA[0]);
+
+ require_once(HEADERF);
+ $tmpl = e107::getTemplate('estate');
+ $tkey = (trim($PROPDTA[0]['prop_template_view']) !== '' ? $PROPDTA[0]['prop_template_view'] : (trim($EST_PREF['template_view']) !== '' ? $EST_PREF['template_view'] : 'default'));
+
+ $TEMPLATE = $tmpl['view'][$tkey];
+ $tmplct = 0;
+ if(isset($PROPDTA[0]['prop_template_view_ord'])){
+ if(is_array($PROPDTA[0]['prop_template_view_ord'])){$VIEWTMPL = $PROPDTA[0]['prop_template_view_ord'];}
+ elseif(trim($PROPDTA[0]['prop_template_view_ord']) !== ''){$VIEWTMPL = e107::unserialize($PROPDTA[0]['prop_template_view_ord']);}
+ }
+
+ if(!is_array($VIEWTMPL) && isset($EST_PREF['template_view_ord'])){
+ if(is_array($EST_PREF['template_view_ord'])){$VIEWTMPL = $EST_PREF['template_view_ord'];}
+ elseif(trim($EST_PREF['template_view_ord']) !== ''){$VIEWTMPL = e107::unserialize($EST_PREF['template_view_ord']);}
+ }
+
+
+ if(is_array($TEMPLATE['txt'])){
+ $tmplct = count($TEMPLATE['txt']);
+ if(isset($TEMPLATE['ord']) && isset($VIEWTMPL[$tkey]) && count($VIEWTMPL[$tkey]) > 0){
+ if($TMPLREORDOK > 0){
+ $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
+ $NEWK = array();
+ $ALLK = $TEMPLATE['ord'];
+ foreach($VIEWTMPL[$tkey] as $sk=>$sv){$NEWK[$sk] = $TEMPLATE['txt'][$sk];}
+ foreach($ALLK as $nk=>$nv){if(!$NEWK[$nv]){$NEWK[$nv] = '';}}
+ unset($ALLK,$sk,$sv,$nk,$nv,$NEWK['dummy']);
+ foreach($NEWK as $ok=>$dta){
+ $estText .= $tp->parseTemplate('{ADMIN_REORDER:area=view&templ='.$tkey.'&ok='.$ok.'&ov='.intval($VIEWTMPL[$tkey][$ok]).'}', false, $sc);
+ $estText .= $tp->parseTemplate($dta, false, $sc).'';
+ }
+ unset($NEWK,$ok,$dta);
+ }
+ else{
+ foreach($VIEWTMPL[$tkey] as $ok=>$ov){
+ if(isset($TEMPLATE['txt'][$ok]) && $ov == 1){
+ $estText .= $tp->parseTemplate($TEMPLATE['txt'][$ok], false, $sc);
+ }
+ }
+ }
+ }
+ else{
+ ksort($TEMPLATE['txt']);
+ if($TMPLREORDOK > 0){
+ $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
+ }
+ foreach($TEMPLATE['txt'] as $k=>$tmpv){
+ $estText .= $tp->parseTemplate($tmpv, false, $sc);
+ }
+ }
+ }
+ else{
+ if($TMPLREORDOK > 0){
+ $estText .= $tp->parseTemplate('{ADMIN_REORDER_MENU:area=view&tkey='.$tkey.'&ct='.$tmplct.'}', false, $sc);
+ }
+ $estText .= $tp->parseTemplate($TEMPLATE['txt'], false, $sc);
+ }
+
+ $ns->setStyle('main');
+ $estText .= $tp->parseTemplate('{PROP_HOADISCLAIMERS}
', false, $sc);
+ $estText .= $tp->parseTemplate('{SOCIAL_LINKS}{PROP_NEWICON}{PROP_EDITICONS:for=view}
', false, $sc);
+
+ $ns->tablerender(''.$estHead,$TFORM1.''.$estText.'
'.$TFORM2,'estate-view');
+
+
+ unset($estHead,$estPT,$estText,$EST_PROP,$VIEWTMPL,$TEMPLATE);
+ }
+
+ if(USERID == 1){
+ //echo propArrayTest($PROPDTA[0]);
+ }
+
+ }
+
+ else{
+ $PINS = est_map_pins();
+ e107::js('inline','var estMapPins = '.$PINS.'; ', 'jquery',2);
+
+ require_once(HEADERF);
+ $tmpl = e107::getTemplate('estate');
+ $tkey = (trim($EST_PREF['template_list']) !== '' ? $EST_PREF['template_list'] : 'default');
+ $sc = e107::getScBatch('estate',true);
+ if(is_array($tmpl['list'][$tkey]['txt'])){
+ ksort($tmpl['list'][$tkey]['txt']);
+ foreach($tmpl['list'][$tkey]['txt'] as $k=>$tmpv){
+ $estText .= $tp->parseTemplate($tmpv, false, $sc);
+ }
+ }
+ else{
+ $estText = $tp->parseTemplate($tmpl['list'][$tkey]['txt'], false, $sc);
+ }
+
+ $estText .= $tp->parseTemplate('{PROP_NEWICON}
', false, $sc);
+
+ $ns->setStyle('main');
+ $ns->tablerender(''.EST_GEN_LISTINGS,''.$estText.'
','estate-list');
+ unset($estText,$EST_PROP);
+ }
+ //}
+
+echo '
+
+
+Estate Plugin by Vodhin
';
+require_once(FOOTERF);
+exit;
+
+
+
+/**
+* e107_class.php
+* @param string $plug_name if null getCoreTemplate method will be called
+* @param string $id - file prefix, e.g. calendar for calendar_template.php, or 'true' or 'null' for same as plugin name.
+* @param string|null $key $YOURTEMPLATE_TEMPLATE[$key]
+* @param boolean $override see {@link getThemeInfo()}
+* @param boolean $merge merge theme with plugin templates, default is false
+* @param boolean $info retrieve template info only
+*
+* function getTemplate($plug_name, $id = null, $key = null, $override = true, $merge = false, $info = false){}
+**/
+
+
+
+function estGetMeta($PROPDTA,$ESTDTA,$MODE=0){
+ $tp = e107::getParser();
+ $RES = array();
+ if($MODE == 1){ //view page
+ //$PROPDTA[0]['prop_status']
+ $type = $GLOBALS['EST_LISTTYPE1'][$PROPDTA[0]['prop_listype']];
+ $zone = $GLOBALS['EST_ZONING'][$PROPDTA[0]['prop_zoning']];
+ $propname = $tp->toHTML($type.': '.$PROPDTA[0]['prop_name'].' ('.$zone.')');
+ $propsumm = $tp->toHTML(''.strtoupper($PROPDTA[0]['city_name'].', '.$PROPDTA[0]['state_name']).' '.$PROPDTA[0]['prop_summary']);
+ $propdesc2 = $tp->toHTML($PROPDTA[0]['prop_description']);
+ $kwarr = array(
+ $zone,
+ $type,
+ strtoupper($PROPDTA[0]['prop_country']),
+ $PROPDTA[0]['cnty_name'],
+ $PROPDTA[0]['state_name'],
+ $PROPDTA[0]['city_name'],
+ $PROPDTA[0]['prop_zip'],
+ $PROPDTA[0]['prop_addr1'].(trim($PROPDTA[0]['prop_addr2']) !== '' ? ','.$PROPDTA[0]['prop_addr2'] : ''),
+ $PROPDTA[0]['agent_name'],
+ $PROPDTA[0]['agency_name'],
+ );
+
+ if(intval($PROPDTA[0]['prop_bedtot']) > 0){array_push($kwarr,$PROPDTA[0]['prop_bedtot'].' '.EST_GEN_BED);}
+ if(intval($PROPDTA[0]['prop_bathtot']) > 0){array_push($kwarr,$PROPDTA[0]['prop_bathtot'].' '.EST_GEN_BATH);}
+ if(trim($PROPDTA[0]['prop_flag']) !== ''){array_push($kwarr,$PROPDTA[0]['prop_flag']);}
+
+ //
+ e107::meta('description',$propsumm.' '.$propdesc2);
+ e107::meta('keywords',$tp->toHTML(implode(",",$kwarr)));
+ //
+ //
+ //
+
+ //
+ e107::meta('fb:app_id','1024154842269829');
+ e107::meta('og:locale','en_us');
+ e107::meta('og:title',$propname);
+ e107::meta('og:type','website');
+ e107::meta('og:url',$PROPDTA[0]['prop_link']);
+ e107::meta('og:description',$propsumm.' '.$propdesc2);
+
+
+
+
+ if(isset($ESTDTA[0])){
+ e107::meta('og:image',EST_PTHABS_PROPTHM.$ESTDTA[0][1]['t']);
+ e107::meta('twitter:image',EST_PTHABS_PROPTHM.$ESTDTA[0][1]['t']);
+ //foreach($ESTDTA[0] as $mk=>$mv){
+ //e107::meta('og:image',EST_PTHABS_PROPTHM.$mv['t']);
+ //e107::meta('twitter:image',EST_PTHABS_PROPTHM.$mv['t']);
+ //}
+ }
+
+
+ /*
+
+
+
+
+
+
+ */
+
+ //
+ e107::meta('twitter:card',$propsumm);
+ e107::meta('twitter:title',$propname);
+ e107::meta('twitter:description',$propsumm.' '.$propdesc2);
+
+
+ //e107::meta($name, $content, $extended);
+ unset($type,$zone,$propname,$propsumm,$propdesc2);
+ }
+ else{
+
+ }
+
+ return $RES;
+ }
+
+
+
+
+function estViewCSS($ESTDTA){
+ $CSSTOP = estViewImgCSS('#estSlideShow',$ESTDTA[0]);
+ if($CSSTOP[0]){
+ $CSSTOP[0] = '
+
+ /*Estate Plugin CSS*/
+'.$CSSTOP[0];
+ e107::css('inline', $CSSTOP[0]);
+ }
+
+
+ if($CSSTOP[1]){$IDIV = $CSSTOP[1];}
+ if($CSSTOP[2]){
+ $estPreJS = '
+ pics = [];';
+ $pli = 0;
+ foreach($CSSTOP[2] as $plk=>$plv){
+ $estPreJS .= '
+ pics['.$pli.'] = new Image();
+ pics['.$pli.'].src = "'.EST_PTHABS_PROPTHM.$plv.'";';
+ $pli++;
+ }
+ e107::js('inline', $estPreJS);
+ }
+
+
+
+ if(isset($ESTDTA[2])){
+ $CSSTOP = estViewImgCSS('#estSubDivSlideShow',$ESTDTA[2]['media'],2);
+ if($CSSTOP[0]){e107::css('inline', $CSSTOP[0]);}
+ if($CSSTOP[1]){$IDIV .= $CSSTOP[1];}
+ }
+
+ if(isset($ESTDTA[1])){
+ foreach($ESTDTA[1] as $k=>$v){
+ foreach($v['sp'] as $sok=>$sov){
+ foreach($sov as $sk=>$sv){
+ if($sv['m']){
+ //e107::meta('og:image',EST_PTHABS_PROPTHM.$sv['t']);
+ //e107::meta('twitter:image',EST_PTHABS_PROPTHM.$sv['t']);
+ $CSSTOP = estViewImgCSS('.SPACE'.$v['ord'].'x'.$sok.'x'.$sk.'img',$sv['m']);
+ if($CSSTOP[0]){e107::css('inline', $CSSTOP[0]);}
+ }
+ }
+ }
+ }
+ }
+ return $IDIV;
+ }
+
+
+function est_map_pins(){
+ $pref = e107::pref();
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+ $ARR1 = array('agcy'=>array(),'prop'=>array());
+
+ if(intval($GLOBALS['EST_PREF']['map_include_agency']) == 1){
+
+ if($AGY = $sql->retrieve("SELECT #estate_agencies.* FROM #estate_agencies WHERE NOT agency_lat='' AND NOT agency_lon='' ",true)){
+ $i = 0;
+ foreach($AGY as $k=>$v){
+ if(intval($v['agency_pub']) > 0){
+ $ARR1['agcy'][$i] = array(
+ 'idx'=>$v['agency_idx'],
+ 'name1'=>$tp->toHTML($v['agency_name']),
+ 'name2'=>'',
+ 'addr'=>$v['agency_addr'],
+ 'lat'=>$v['agency_lat'],
+ 'lon'=>$v['agency_lon'],
+ 'thm'=>(intval($v['agency_imgsrc']) == 1 && trim($v['agency_image']) !== '' ? EST_PTHABS_AGENCY.$tp->toHTML($v['agency_image']) : $tp->thumbUrl($pref['sitelogo'],false,false,true)),
+ 'zoom'=>$GLOBALS['EST_PREF']['map_zoom_def']
+ );
+ $i++;
+ }
+ }
+ }
+ }
+
+ if($GLOBALS['EST_PROP']){
+ if(count($GLOBALS['EST_PROP']) > 0){
+ if(intval($GLOBALS['PROPID']) > 0){
+ foreach($GLOBALS['PROPDTA'] as $k=>$v){
+ $ARR1['prop'][0] = array(
+ 'idx'=>$v['prop_idx'],
+ 'lat'=>$v['prop_lat'],
+ 'lon'=>$v['prop_lon'],
+ 'lnk'=>null,
+ 'name1'=>$tp->toHTML($v['prop_name']),
+ 'zoom'=>$v['prop_zoom']
+ );
+ }
+ }
+ else{
+ $i = 0;
+ $incs = (5 - intval($GLOBALS['EST_PREF']['map_include_sold']));
+ foreach($GLOBALS['EST_PROP'] as $k=>$v){
+ if(intval($v['prop_status']) > 0){
+ if(intval($v['prop_status']) <= $incs){
+ $ARR1['prop'][$i] = array(
+ 'drop'=>estPriceDrop($v,1),
+ 'hue'=>estPinColor($v),
+ 'feat'=>explode(',',$v['prop_features']),
+ 'idx'=>$v['prop_idx'],
+ 'lat'=>$v['prop_lat'],
+ 'lon'=>$v['prop_lon'],
+ 'lnk'=>EST_PTH_LISTINGS.'?view.'.intval($v['prop_idx']).'.0',
+ 'name1'=>$tp->toHTML($v['prop_name']),
+ 'prc'=>estGetListPrice($v,1),
+ 'sta'=>$tp->toHTML(estPinsPropStat($v)),
+ 'stat'=>intval($v['prop_status']),
+ 'thm'=>$v['img'][1]['t'],
+ 'type'=>$v['prop_listype'],
+ 'zoom'=>$v['prop_zoom']
+ );
+ $i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ return json_encode($ARR1);
+ }
+
+
+function estPinColor($DTA){
+ switch(intval($DTA['prop_status'])){
+ case 5 :
+ return 'estMarkGray';
+ break;
+ case 4 :
+ return 'estMarkYellow';
+ break;
+ case 3 :
+ return null;
+ break;
+ case 2 :
+ return 'estMarkGreen';
+ break;
+ case 1 :
+ return 'estMark';
+ break;
+ case 0 :
+ return null;
+ break;
+ }
+ }
+
+
+
+
+
+function estPinsPropStat($DTA){
+ if(intval($DTA['prop_status']) == 5){$ret = (intval($DTA['prop_listype']) == 0 ? EST_GEN_OFFMARKET : EST_GEN_SOLD);}
+ elseif(intval($DTA['prop_status']) == 4){$ret = EST_GEN_PENDING; $parm = '';}
+ elseif(intval($DTA['prop_status']) == 3){$ret = $GLOBALS['EST_LISTTYPE1'][$DTA['prop_listype']]; $parm = '';}
+ elseif(intval($DTA['prop_status']) == 2){
+ $parm = '';
+ if(intval($DTA['prop_datelive']) > 0 && intval($DTA['prop_datelive']) <= $GLOBALS['STRTIMENOW']){
+ $ret = $GLOBALS['EST_LISTTYPE1'][$DTA['prop_listype']];
+ }
+ elseif(USERID > 0 && (intval($DTA['prop_dateprevw']) > 0 && intval($DTA['prop_dateprevw']) <= $GLOBALS['STRTIMENOW'])){
+ $ret = EST_GEN_PREVIEW;
+ }
+ else{$ret = EST_GEN_COMINGSOON;}
+ }
+ elseif(intval($DTA['prop_status']) == 1){
+ $ret = EST_GEN_COMINGSOON;
+ if(!ADMIN){$parm = '';}
+ }
+ else{$ret = EST_GEN_OFFMARKET;}
+ if($ret){return $ret.($parm == 'bullet' ? ' • ' : '');}
+ else{return '';}
}
\ No newline at end of file