private function normalize_regions_query($query) { // search for a listing associated with a Region (of any kind) whose // name matches the given search value. $query['regions'][] = array('country' => $query['region']); $query['regions'][] = array('state' => $query['region']); $query['regions'][] = array('city' => $query['region']); $query['regions'][] = array('county' => $query['region']); // search for a listing associated with region hierarchy that matches // the given search values. $query['regions'][] = array('country' => empty($query['country']) ? '' : array('=', $query['country']), 'state' => empty($query['state']) ? '' : array('=', $query['state']), 'city' => empty($query['city']) ? '' : array('=', $query['city']), 'county' => empty($query['county']) ? '' : array('=', $query['county'])); return awpcp_array_filter_recursive($query['regions']); }
public function dispatch() { global $awpcp; if ($this->should_restore_pages()) { $restored_pages = awpcp_pages_creator()->restore_missing_pages(); } else { $restored_pages = array(); } $missing = awpcp_array_filter_recursive($this->missing_pages_finder->find_missing_pages()); ob_start(); include AWPCP_DIR . '/admin/templates/admin-panel-settings-pages-settings.tpl.php'; $content = ob_get_contents(); ob_end_clean(); echo $content; }
/** * Taken and adapted from: http://stackoverflow.com/a/6795671/201354 */ function awpcp_array_filter_recursive($input, $callback = null) { foreach ($input as &$value) { if (is_array($value)) { $value = awpcp_array_filter_recursive($value, $callback); } } if (is_callable($callback)) { return array_filter($input, $callback); } else { return array_filter($input); } }