public function results($category = null) { $message = ''; $results = null; // si recibimos categoria por get emulamos post con un parametro 'category' if (!empty($category)) { $_POST['category'][] = $category; } if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['query']) && !isset($category)) { $errors = array(); $params['query'] = \strip_tags($_GET['query']); // busqueda de texto $results = \Goteo\Library\Search::text($params['query']); } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['searcher']) || !empty($category)) { // vamos montando $params con los 3 parametros y las opciones marcadas en cada uno $params = array('category' => array(), 'location' => array(), 'reward' => array()); foreach ($params as $param => $empty) { foreach ($_POST[$param] as $key => $value) { if ($value == 'all') { $params[$param] = array(); break; } $params[$param][] = "'{$value}'"; } } $params['query'] = \strip_tags($_POST['query']); // para cada parametro, si no hay ninguno es todos los valores $results = \Goteo\Library\Search::params($params); } else { throw new Redirection('/discover', Redirection::PERMANENT); } return new View('view/discover/results.html.php', array('message' => $message, 'results' => $results, 'params' => $params)); }
/** * @param $_param * @param bool $_showall * @param int $_limit * @return array * @throws \Goteo\Library\Exception */ private function _get_projects_by_skill($_param, $_add_param = null, $_showall = false, $_limit = 5) { $params = array('skills' => array(), 'category' => array(), 'location' => array(), 'reward' => array()); if (is_array($_add_param) && !empty($_add_param)) { foreach ($_add_param as $_k => $_v) { $params[$_k] = $_v; } } if (strpos($_param, ',') > 0) { $_param_array = array(); $_param_array = explode(',', $_param); foreach ($_param_array as $_prm) { $params['skills'][] = $_prm; } } else { $params['skills'][] = $_param; } // query はキーワード検索用? $params['query'] = ''; // var_dump($params); // exit; return \Goteo\Library\Search::params($params, $_showall, $_limit); }