diff --git a/application/controllers/Home.php b/application/controllers/Home.php
index 9adad0d..ae46e18 100644
--- a/application/controllers/Home.php
+++ b/application/controllers/Home.php
@@ -708,9 +708,9 @@ private function load_blog_rss_feed()
libxml_use_internal_errors(true);
$blog_xml_var = simplexml_load_string($blog_posts, 'SimpleXMLElement', LIBXML_NOCDATA);
- if($blog_xml_var === false)
+ if($blog_xml_var === false)
$blog_xml_var = array();
- $this->load->vars('blog_posts', $blog_xml_var);
+ $this->load->vars('blog_posts', $blog_xml_var);
}
@@ -1221,7 +1221,6 @@ public function search(){
switch ($this->language) {
case SCIELO_LANG:
- //$url = WORDPRESS_API_PATH."/swp_api/search?nopaging=true&s=";
$paged_url = WORDPRESS_API_PATH."/swp_api/search?posts_per_page=10&s=";
$url = WORDPRESS_API_PATH."/swp_api/search?nopaging=true&s=";
break;
@@ -1238,108 +1237,127 @@ public function search(){
}
// receive input value
- $q = $this->input->get('q');
-
- // Clear input content to avoid xss
- $q = htmlspecialchars(strip_tags($q));
-
- // Rides Json paged url and embodies to accept blank
- $paged_json_url = $paged_url.rawurlencode($q);
-
- // Rides Json url and emboda to accept blank
- $json_url = $url.rawurlencode($q);
-
- // If page number is posted, assign it in the query. $ this-> uri-> segment (3) represents page number
- if($this->uri->segment(3)){
- $page_num = $this->uri->segment(3);
- $paged_json_url = $paged_json_url."&page=".$page_num;
- }
-
- // Receive value sent by already formatted search field
- $data["query"] = $q;
-
- // Gets json from nonpaged search
- $data["json"] = $this->doSearch($q, $json_url);
-
- // gets json from paged search
- $data["paged_json"] = $this->doSearch($q, $paged_json_url);
-
-
- /*
- ## Making pagination
- */
- $this->load->library('pagination');
-
- $scielo_url = ($this->language == SCIELO_LANG) ? base_url($this->language . '/') : base_url();
-
- // Displays total query results for pagination creation
- $search_total_rows = count($data["json"]);
-
- // Url to assemble pagination results
- $data["url"] = base_url()."home/search/";
-
-
- // Display number of pages in url and not number of records displayed
- $config['use_page_numbers'] = TRUE;
-
- // Keep field values sent via get when reloading page
- $config['reuse_query_string'] = TRUE;
-
-
- // commented because the route was not made for this url/pt
- // $config['base_url'] = $scielo_url.'home/search/';
- $config['base_url'] = base_url().'home/search';
+ $q = $this->input->get('q');
+ // Clear input content to avoid xss
+ $q = htmlspecialchars(strip_tags($q));
+
+ // Rides Json paged url and embodies to accept blank
+ $paged_json_url = $paged_url.rawurlencode($q);
+
+ // Rides Json url and emboda to accept blank
+ $json_url = $url.rawurlencode($q);
+
+ // If page number is posted, assign it in the query. $ this-> uri-> segment (3) represents page number
+ if($this->uri->segment(3)){
+ $page_num = $this->uri->segment(3);
+ $paged_json_url = $paged_json_url."&page=".$page_num;
+ }
- $config['total_rows'] = $search_total_rows;
- $config['per_page'] = 10;
+ // Error status
+ $data["error"] = 0;
- $config['full_tag_open'] = '
';
+ // Receive value sent by already formatted search field
+ $data["query"] = $q;
- $config['first_link'] = lang('pagination_first_link');
- $config['last_link'] = lang('pagination_last_link');
+
+ // Gets json from nonpaged search
+ $data["json"] = $this->doSearch($q, $json_url);
+
+ if(!isset($data["json"]["error"])) {
+ $data["paged_json"] = $this->doSearch($q, $paged_json_url);
- $config['first_tag_open'] = '';
- $config['first_tag_close'] = '';
+ if(!isset($data["paged_json"]["error"])) {
+ /*
+ ## Making pagination
+ */
+ $this->load->library('pagination');
+
+ // Displays total query results for pagination creation
+ if($data["json"]){
+ $search_total_rows = count($data["json"]);
+ }else{
+ $search_total_rows = 0;
+ }
+ // Url to assemble pagination results
+ $data["url"] = base_url()."home/search/";
+
+
+ // Display number of pages in url and not number of records displayed
+ $config['use_page_numbers'] = TRUE;
+
+ // Keep field values sent via get when reloading page
+ $config['reuse_query_string'] = TRUE;
+
+
+ // commented because the route was not made for this url/pt
+ // $config['base_url'] = $scielo_url.'home/search/';
+ $config['base_url'] = base_url().'home/search';
+
+ // Pagination
+ $config['total_rows'] = $search_total_rows;
+ $config['per_page'] = 10;
- $config['last_tag_open'] = '';
- $config['last_tag_close'] = '';
+ $config['full_tag_open'] = '';
- $config['next_tag_open'] = '';
- $config['next_tag_close'] = '';
+ $config['first_link'] = lang('pagination_first_link');
+ $config['last_link'] = lang('pagination_last_link');
- $config['prev_tag_open'] = '';
- $config['prev_tag_close'] = '';
+ $config['first_tag_open'] = '';
+ $config['first_tag_close'] = '';
- $config['cur_tag_open'] = '';
- $config['cur_tag_close'] = '';
+ $config['last_tag_open'] = '';
+ $config['last_tag_close'] = '';
- $config['num_tag_open'] = '';
- $config['num_tag_close'] = '';
+ $config['next_tag_open'] = '';
+ $config['next_tag_close'] = '';
+ $config['prev_tag_open'] = '';
+ $config['prev_tag_close'] = '';
+
+ $config['cur_tag_open'] = '';
+ $config['cur_tag_close'] = '';
+
+ $config['num_tag_open'] = '';
+ $config['num_tag_close'] = '';
+
+ $this->pagination->initialize($config);
+
+ } else {
+ $data["error"] = 1;
+ }
+ } else {
+ $data["error"] = 1;
+ }
// set page title
$pageMetadata = array('acf' => array('pageTitle' => ucfirst(lang('search_btn')) . ' | SciELO.org'));
$this->PageMetadata->initialize($pageMetadata);
+
+ $this->load->view("/pages/search_results", $data);
- $this->pagination->initialize($config);
- $this->load->view("/pages/search_results", $data);
- }
+ }
/**
* Internal search query
*/
- public function doSearch($q, $json_url){
-
- $rtn = array();
- $q = strtolower($q);
- $json = file_get_contents($json_url);
- $searchResult = json_decode($json,true);
- $rtn = $searchResult;
-
- return $rtn;
-
- }
+ public function doSearch($q, $json_url){
+ $searchResult = "";
+ $q = strtolower($q);
+ $json = @file_get_contents($json_url);
+
+ if ($json === false) {
+ $searchResult = array(
+ "error" => true
+ );
+ } else {
+ $searchResult = json_decode($json,true);
+ }
+
+ return $searchResult;
+
+ }
+
}
diff --git a/application/language/english/scielo_lang.php b/application/language/english/scielo_lang.php
index b0b4068..4a2fae4 100644
--- a/application/language/english/scielo_lang.php
+++ b/application/language/english/scielo_lang.php
@@ -91,6 +91,7 @@
$lang['search_btn'] = 'Search';
$lang['clean_btn'] = 'Clear';
$lang["content_error"] = 'Sorry, this content is currently unavailable';
+$lang["search_content_error"] = 'An error occurred while searching. Please try again later.';
$lang['with_initial_letter'] = ' with the initial letter ';
$lang["internal_search_placeholder"] = "Criteria, guides, announcements etc";
$lang['displaying_results_for_term'] = 'Displaying results for term ';
diff --git a/application/language/portuguese-brazilian/scielo_lang.php b/application/language/portuguese-brazilian/scielo_lang.php
index cbf9bda..17442ec 100644
--- a/application/language/portuguese-brazilian/scielo_lang.php
+++ b/application/language/portuguese-brazilian/scielo_lang.php
@@ -90,6 +90,7 @@
$lang['search_btn'] = 'Buscar';
$lang['clean_btn'] = 'Limpar';
$lang["content_error"] = 'Desculpe, este conteúdo está temporariamente indisponível.';
+$lang["search_content_error"] = 'Ocorreu um erro durante a busca. Por favor tente novamente mais tarde.';
$lang["internal_search_placeholder"] = "Critérios, guias, comunicados etc";
$lang['displaying_results_for_term'] = 'Exibindo resultados para o termo ';
$lang['no_items_found_for_term'] = 'Nenhum item encontrado para o termo ';
diff --git a/application/language/spanish/scielo_lang.php b/application/language/spanish/scielo_lang.php
index 557a2ce..2b7334f 100644
--- a/application/language/spanish/scielo_lang.php
+++ b/application/language/spanish/scielo_lang.php
@@ -90,6 +90,7 @@
$lang['search_btn'] = 'Búsqueda';
$lang['clean_btn'] = 'Limpiar';
$lang["content_error"] = 'Lo sentimos, este contenido no está disponible en este momento';
+$lang["search_content_error"] = 'Ocurrió un error al buscar. Por favor intenta nuevamente más tarde.';
$lang['with_initial_letter'] = ' con la letra inicial ';
$lang["internal_search_placeholder"] = "Criterios, guías, anuncios, etc.";
$lang['displaying_results_for_term'] = 'Mostrando resultados para el término ';
diff --git a/application/views/pages/search_results.php b/application/views/pages/search_results.php
index 6c2db26..34df85f 100644
--- a/application/views/pages/search_results.php
+++ b/application/views/pages/search_results.php
@@ -50,6 +50,9 @@
load->view('partials/internal-search-box'); ?>
+
+
+
@@ -137,20 +140,30 @@
+
-
+
+
+
+
+
+
+
+ = lang('search_content_error'); ?>
+
+
+
+
+
-
-
diff --git a/static/sass/style.scss b/static/sass/style.scss
index 9dd7f4c..9c45da4 100644
--- a/static/sass/style.scss
+++ b/static/sass/style.scss
@@ -1369,6 +1369,22 @@ section{
transform: translate(-50%,0);
}
}
+
+ &.card-internal-search{
+ min-height: 28rem;
+ padding-top: 19rem;
+ margin-bottom: 3rem;
+ line-height: 100%;
+
+ @media (max-width: $screen-xs-max) {
+ padding-top: 6rem;
+ line-height: 1.4rem;
+ min-height: 1px;
+ padding-bottom: 2rem;
+ padding-left: 1rem;
+ padding-right: 1rem;
+ }
+ }
}
}