/** * @see IDX_Panel::getOptions() */ public function getOptions() { $idx = Util_IDX::getIdx(); $db_idx = Util_IDX::getDatabase(); $query = "SELECT DISTINCT `" . $idx->field($this->field) . "` AS `value` FROM `" . $idx->getTable() . "`" . (!empty($extra) ? ' WHERE ' . $extra : '') . " ORDER BY `" . $idx->field($this->field) . "` DESC LIMIT 20;"; if ($result = $db_idx->query($query)) { while ($option = $db_idx->fetchArray($result)) { $options[] = $option['value']; } } else { return false; } if (!empty($options)) { $post = array(); $confirmed = array(); foreach ($options as $val) { $pre = explode(',', $val); //confirm and add to array foreach ($pre as $opt) { $opt = preg_replace('/(^\\s+)|(\\s{2,})|(\\s+$)|(\\n)|(\\r)/', ' ', $opt); //trim and remove exessive spacing if (!in_array_nocase($opt, $confirmed) && !empty($opt)) { if (!empty($filter)) { if (preg_match($filter, $opt)) { $confirmed[] = $opt; } } else { $confirmed[] = $opt; } } } } //sort them if (!empty($confirmed)) { asort($confirmed); foreach ($confirmed as $opt) { $post[] = array('value' => $opt, 'title' => ucwords(strtolower($opt))); } } $this->options = $post; } else { return false; } return $this->options; }
/** * REWMOD 01/31/2013 Eric B *456848651351* Reduces comma seperated options into array of single options * useful for making select lists from fields were most rows have multiple options * Can provide DB column to be pulled, or array of items to be reduced * * @global $idx, $db_idx; * @param {String} (conditional) $field column name to pull options from * @param {String} (optional) $extra extra where statement for pulling options * @param {String} (optional) $filter regex to match values. any non matches are filtered out * @param {String} (optional) $delimiter string delimiter for options, predefined as ", " * @param {Array} (conditional) $options existing array of options to be limited * * @return {Array|Bool} Array of options on success, False on failure * */ function reducedOptions($field = null, $extra = null, $filter = null, $delimiter = ', ', $options = array()) { //trying to get away from globals since 4.3 if (class_exists('Util_IDX')) { $idx = Util_IDX::getIdx(); $db_idx = Util_IDX::getDatabase(); } else { global $idx, $db_idx; } if (empty($options) && !empty($field)) { $query = "SELECT DISTINCT `" . $idx->field($field) . "` FROM `" . $idx->getTable() . "`" . (!empty($extra) ? ' WHERE ' . $extra : '') . " ORDER BY `" . $idx->field($field) . "` DESC LIMIT 20;"; if ($result = $db_idx->query($query)) { while ($option = $db_idx->fetchArray($result)) { $options[] = $option[$field]; } } else { return false; } } if (!empty($options)) { $post = array(); $confirmed = array(); foreach ($options as $val) { $pre = explode($delimiter, $val); //confirm and add to array foreach ($pre as $opt) { $opt = preg_replace('/(^\\s+)|(\\s{2,})|(\\s+$)|(\\n)|(\\r)/', ' ', $opt); //trim and remove exessive spacing if (!in_array_nocase($opt, $confirmed) && !empty($opt)) { if (!empty($filter)) { if (preg_match($filter, $opt)) { $confirmed[] = $opt; } } else { $confirmed[] = $opt; } } } } //sort them if (!empty($confirmed)) { asort($confirmed); foreach ($confirmed as $opt) { $post[] = array('value' => $opt, 'title' => ucwords(strtolower($opt))); } } return $post; } else { return false; } }
} // Set $_REQUEST Criteria $criteria = is_array($criteria) ? $criteria : array(); $_REQUEST = search_criteria($idx, $criteria); // Page Limit $criteria['page_limit'] = !empty($criteria['page_limit']) && $criteria['page_limit'] > 0 ? $criteria['page_limit'] : 5; // Price Range Links $criteria['price_ranges'] = isset($criteria['price_ranges']) ? $criteria['price_ranges'] : 'true'; // Default View $criteria['view'] = isset($criteria['view']) ? $criteria['view'] : 'grid'; // Select IDX if (!empty($criteria['feed'])) { Util_IDX::switchFeed($criteria['feed']); } // IDX objects $idx = Util_IDX::getIdx(); $db_idx = Util_IDX::getDatabase(); // Order / Sort list($criteria['sort'], $criteria['order']) = explode('-', $criteria['sort_by']); $criteria['order'] = isset($_REQUEST['order']) ? $_REQUEST['order'] : $criteria['order']; $criteria['sort'] = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : $criteria['sort']; // Snippet Panels (Legacy Hack) $builder_panels = $criteria['panels']; // IDX Builder $builder = new IDX_Builder(array('map' => true, 'mode' => 'snippet', 'panels' => $criteria['panels'])); // Slugify Snippet Name $page->writeJS("\$('#snippet_id').slugify();"); // Pages using this Snippet $snippet['pages'] = array(); // Check Homepage $query = "SELECT `agent` FROM `" . TABLE_SETTINGS . "` WHERE `agent` = '" . $agent_id . "' AND `category_html` LIKE '%#" . mysql_real_escape_string($snippet['name']) . "#%';";
/** * Check Field Values * @param string $field IDX Field Name * @return boolean * @TODO Move this to IDX_Feed */ public static function checkField($field) { // IDX Feed $idx = Util_IDX::getIdx(); $db_idx = Util_IDX::getDatabase(); // IDX Field $field = $idx->field($field); // Require Field if (empty($field)) { return false; } // Cache Key $index = __METHOD__ . ':' . $idx->getName() . ':' . $db_idx->db() . ':' . $idx->getTable() . ':' . $field; // Is Cached (Server-Wide) $cache = static::$useCache && !static::$reCache ? Cache::getCache($index, true) : null; if (!is_null($cache)) { $check = $cache; // Not Cached } else { // Check for Values $check = $db_idx->fetchQuery("SELECT SQL_CACHE `" . $field . "` FROM `" . $idx->getTable() . "` WHERE `" . $field . "` IS NOT NULL AND `" . $field . "` != '' LIMIT 1;"); // Return Boolean $check = !empty($check); // Save Cache (Server-Wide) if (static::$useCache || static::$reCache) { Cache::setCache($index, $check, true); } } // Return Check return $check; }
?> "> <input type="hidden" name="map[zoom]" value="<?php echo htmlspecialchars($_REQUEST['map']['zoom']); ?> "> <input type="hidden" name="map[latitude]" value="<?php echo htmlspecialchars($_REQUEST['map']['latitude']); ?> "> <input type="hidden" name="map[longitude]" value="<?php echo htmlspecialchars($_REQUEST['map']['longitude']); ?> "> <input type="hidden" name="idx" value="<?php echo Util_IDX::getIdx()->getLink(); ?> "> <input type="hidden" name="map[radius]" value="<?php echo htmlspecialchars($_REQUEST['map']['radius']); ?> "> <input type="hidden" name="map[polygon]" value="<?php echo htmlspecialchars($_REQUEST['map']['polygon']); ?> "> <input type="hidden" name="map[ne]" value="<?php echo htmlspecialchars($_REQUEST['map']['ne']); ?> "> <input type="hidden" name="map[sw]" value="<?php
/** * @see IDX_Panel::fetchOptions() */ public static function fetchOptions($field, $where = NULL, $order = NULL) { // IDX Feed $idx = Util_IDX::getIdx(); $db_idx = Util_IDX::getDatabase(); // Filter Sub-Type By Type $types = $_REQUEST['search_type']; $types = is_array($types) ? Format::trim($types) : Format::trim(explode(',', $types)); $types = array_filter($types); // Filter Options $where = is_null($where) ? '' : $where . ' AND '; $type = $idx->field('ListingType'); if (!empty($types) && !empty($type)) { $types = array_map(array(&$db_idx, 'cleanInput'), $types); $where = "`" . $type . "` = '" . implode("' OR `" . $type . "` = '", $types) . "'"; } // Order by # of Records $field = $idx->field($field); $order = is_null($order) ? '' : $order . ','; $order .= "COUNT(`" . $field . "`) DESC"; // Fetch Options return parent::fetchOptions($field, $where, $order); }