Ejemplo n.º 1
0
 /**
  * Updates locationtextsearch data. It runes by WPL cronjob!
  * @author Howard <*****@*****.**>
  * @static
  */
 public static function update_locationtextsearch_data()
 {
     /** detele wpl_locationtextsearch completely **/
     wpl_db::q("DELETE FROM `#__wpl_locationtextsearch`");
     /** Don't run in case of many listings **/
     if (wpl_db::num('', 'wpl_properties') > 2500) {
         wpl_db::q("UPDATE `#__wpl_cronjobs` SET `enabled`='0' WHERE `id`='1'");
         return false;
     }
     _wpl_import('libraries.property');
     $properties = wpl_property::select_active_properties('', '`id`,`location1_name`,`location2_name`,`location3_name`,`location4_name`,`location5_name`,`location6_name`,`location7_name`,`zip_name`');
     $locations = array();
     foreach ($properties as $property) {
         $pid = $property['id'];
         $locations[$pid] = array();
         $locations[$pid]['full_location'] = '';
         $locations[$pid]['zip'] = '';
         for ($j = 1; $j <= 7; $j++) {
             $locations[$pid][$j] = '';
         }
         for ($i = 7; $i >= 1; $i--) {
             $locations[$pid]['full_location'] .= ', ' . $property['location' . $i . '_name'];
             if ($i <= 7 and trim($property['location7_name'])) {
                 $locations[$pid]['7'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 6 and trim($property['location6_name'])) {
                 $locations[$pid]['6'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 5 and trim($property['location5_name'])) {
                 $locations[$pid]['5'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 4 and trim($property['location4_name'])) {
                 $locations[$pid]['4'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 3 and trim($property['location3_name'])) {
                 $locations[$pid]['3'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 2 and trim($property['location2_name'])) {
                 $locations[$pid]['2'] .= ', ' . $property['location' . $i . '_name'];
             }
             if ($i <= 1 and trim($property['location1_name'])) {
                 $locations[$pid]['1'] .= ', ' . $property['location' . $i . '_name'];
             }
         }
         /** remove extra , and spaces if any **/
         foreach ($locations[$pid] as $key => $location) {
             $locations[$pid][$key] = trim($location, ', ');
         }
         /** add zip code **/
         $locations[$pid]['zip'] = $property['zip_name'] . ', ' . $locations[$pid]['full_location'];
     }
     /** make a new location array **/
     $unique_locations = array();
     foreach ($locations as $pid => $location) {
         foreach ($location as $location_level => $location_string) {
             $unique_locations[] = $location_string;
         }
     }
     $unique_locations = array_unique($unique_locations);
     foreach ($unique_locations as $location_text) {
         $query = "SELECT `kind`, COUNT(id) AS count FROM `#__wpl_properties` WHERE `deleted`='0' AND `finalized`='1' AND `confirmed`='1' AND `expired`='0' AND `location_text` LIKE '%" . wpl_db::escape($location_text) . "%' GROUP BY `kind`";
         $counts = wpl_db::select($query, 'loadAssocList');
         $total_count = 0;
         foreach ($counts as $count) {
             $total_count += $count['count'];
         }
         /** add to wpl_locationtextsearch **/
         $query = "INSERT INTO `#__wpl_locationtextsearch` (`location_text`,`count`,`counts`) VALUES ('" . wpl_db::escape($location_text) . "','{$total_count}','" . json_encode($counts) . "')";
         wpl_db::q($query);
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 /**
  * Returns all WPL item links (Used in sitemap feature)
  * @author Howard <*****@*****.**>
  * @static
  * @since 1.8.0
  * @param array $exclude
  * @return array
  */
 public static function get_wpl_item_links($exclude = array())
 {
     $links = array();
     /** WPL Properties **/
     $properties = wpl_property::select_active_properties(NULL, '`id`');
     foreach ($properties as $property) {
         /** exclude **/
         if (isset($exclude['properties']) and in_array($property['id'], $exclude['properties'])) {
             continue;
         }
         $property_data = wpl_db::select("SELECT `id`,`alias`,`last_modified_time_stamp` FROM `#__wpl_properties` WHERE `id`='" . $property['id'] . "'", 'loadAssoc');
         $link = wpl_property::get_property_link($property_data);
         $links[] = array('link' => $link, 'time' => strtotime($property_data['last_modified_time_stamp']));
     }
     /** WPL Profiles **/
     $profiles = wpl_users::get_wpl_users();
     foreach ($profiles as $profile) {
         /** exclude **/
         if (isset($exclude['profiles']) and in_array($profile->ID, $exclude['profiles'])) {
             continue;
         }
         $link = wpl_users::get_profile_link($profile->ID);
         $links[] = array('link' => $link, 'time' => strtotime($profile->last_modified_time_stamp));
     }
     return $links;
 }