From f9e19c4b0c776f6f20d3631324447bc8b2dcf63f Mon Sep 17 00:00:00 2001 From: Ramon Date: Mon, 16 Dec 2019 16:04:23 -0300 Subject: [PATCH] =?UTF-8?q?busca=20interna=20scielo.org=20com=20pagina?= =?UTF-8?q?=C3=A7ao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + application/controllers/Home.php | 128 ++++++++++++++ .../language/english/pagination_lang.php | 15 ++ application/language/english/scielo_lang.php | 3 + .../portuguese-brazilian/pagination_lang.php | 4 +- .../portuguese-brazilian/scielo_lang.php | 3 + .../language/spanish/pagination_lang.php | 4 +- application/language/spanish/scielo_lang.php | 5 +- application/views/pages/accordion.php | 2 + application/views/pages/bibliography.php | 3 + application/views/pages/booklist.php | 3 + application/views/pages/content.php | 2 + application/views/pages/menu.php | 3 + application/views/pages/search_results.php | 157 ++++++++++++++++++ .../views/partials/internal-search-box.php | 21 +++ static/sass/_bootstrap.scss | 2 +- static/sass/style.scss | 7 + 17 files changed, 358 insertions(+), 6 deletions(-) create mode 100644 application/language/english/pagination_lang.php create mode 100644 application/views/pages/search_results.php create mode 100644 application/views/partials/internal-search-box.php diff --git a/.gitignore b/.gitignore index b180731..4b9d661 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store +docker-compose-local.yml + application/cache/*/Files !application/cache/index.html !application/cache/database/data.db diff --git a/application/controllers/Home.php b/application/controllers/Home.php index e567dc0..28b8072 100644 --- a/application/controllers/Home.php +++ b/application/controllers/Home.php @@ -1211,4 +1211,132 @@ public function redirect_legacy_index_url() $lang = $this->input->get('lang', 'en'); return redirect($lang . '/', 'location', 301); } + + + /** + * Create internal search query + */ + 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; + + case SCIELO_EN_LANG: + $paged_url = WORDPRESS_API_PATH_EN."/swp_api/search?posts_per_page=10&s="; + $url = WORDPRESS_API_PATH_EN."/swp_api/search?nopaging=true&s="; + break; + + case SCIELO_ES_LANG: + $paged_url = WORDPRESS_API_PATH_ES."/swp_api/search?posts_per_page=10&s="; + $url = WORDPRESS_API_PATH_ES."/swp_api/search?nopaging=true&s="; + break; + } + + // 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); + $json_url = $json_url."&page=".$page_num; + $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'; + + + $config['total_rows'] = $search_total_rows; + $config['per_page'] = 10; + + $config['full_tag_open'] = ''; + + $config['first_link'] = lang('pagination_first_link'); + $config['last_link'] = lang('pagination_last_link'); + + $config['first_tag_open'] = '
  • '; + $config['first_tag_close'] = '
  • '; + + $config['last_tag_open'] = '
  • '; + $config['last_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); + $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; + + } + } diff --git a/application/language/english/pagination_lang.php b/application/language/english/pagination_lang.php new file mode 100644 index 0000000..331e908 --- /dev/null +++ b/application/language/english/pagination_lang.php @@ -0,0 +1,15 @@ +
    diff --git a/application/language/portuguese-brazilian/pagination_lang.php b/application/language/portuguese-brazilian/pagination_lang.php index e42eab1..e54540c 100644 --- a/application/language/portuguese-brazilian/pagination_lang.php +++ b/application/language/portuguese-brazilian/pagination_lang.php @@ -9,7 +9,7 @@ */ defined('BASEPATH') OR exit('No direct script access allowed'); -$lang['pagination_first_link'] = '‹ Primeiro'; +$lang['pagination_first_link'] = 'Primeira'; $lang['pagination_next_link'] = '>'; $lang['pagination_prev_link'] = '<'; -$lang['pagination_last_link'] = 'Último ›'; +$lang['pagination_last_link'] = 'Última'; diff --git a/application/language/portuguese-brazilian/scielo_lang.php b/application/language/portuguese-brazilian/scielo_lang.php index c1ff45a..cbf9bda 100644 --- a/application/language/portuguese-brazilian/scielo_lang.php +++ b/application/language/portuguese-brazilian/scielo_lang.php @@ -90,6 +90,9 @@ $lang['search_btn'] = 'Buscar'; $lang['clean_btn'] = 'Limpar'; $lang["content_error"] = 'Desculpe, este conteúdo está temporariamente indisponível.'; +$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 '; $lang['page_not_found_with_details'] = ' Não foi possível encontrar essa página. O conteúdo que você buscou provavelmente foi movido ou não está mais disponível.

    diff --git a/application/language/spanish/pagination_lang.php b/application/language/spanish/pagination_lang.php index 415a5a2..0759514 100644 --- a/application/language/spanish/pagination_lang.php +++ b/application/language/spanish/pagination_lang.php @@ -10,7 +10,7 @@ */ defined('BASEPATH') OR exit('No direct script access allowed'); -$lang['pagination_first_link'] = '‹ Primera'; +$lang['pagination_first_link'] = 'Primero'; $lang['pagination_next_link'] = '>'; $lang['pagination_prev_link'] = '<'; -$lang['pagination_last_link'] = 'Última ›'; +$lang['pagination_last_link'] = 'Última'; diff --git a/application/language/spanish/scielo_lang.php b/application/language/spanish/scielo_lang.php index a39ed25..557a2ce 100644 --- a/application/language/spanish/scielo_lang.php +++ b/application/language/spanish/scielo_lang.php @@ -87,10 +87,13 @@ $lang['contains'] = 'Contiene'; $lang['extact_title'] = 'Título exacto'; $lang['starts_with'] = 'Comienza con'; -$lang['search_btn'] = 'Buscar'; +$lang['search_btn'] = 'Búsqueda'; $lang['clean_btn'] = 'Limpiar'; $lang["content_error"] = 'Lo sentimos, este contenido no está disponible en este momento'; $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 '; +$lang['no_items_found_for_term'] = 'No se encontraron elementos para el término '; $lang['page_not_found_with_details'] = ' No se pudo encontrar esta página. El contenido que ha buscado probablemente se ha movido o no está disponible.

    diff --git a/application/views/pages/accordion.php b/application/views/pages/accordion.php index a096e9a..432b78d 100644 --- a/application/views/pages/accordion.php +++ b/application/views/pages/accordion.php @@ -45,6 +45,8 @@
    + load->view('partials/internal-search-box'); ?> +
    format('d/m/Y') . ")" ?> diff --git a/application/views/pages/bibliography.php b/application/views/pages/bibliography.php index 7621f1a..1a4f6fe 100644 --- a/application/views/pages/bibliography.php +++ b/application/views/pages/bibliography.php @@ -44,6 +44,9 @@
    + + load->view('partials/internal-search-box'); ?> +
    format('d/m/Y') . ")" ?> diff --git a/application/views/pages/booklist.php b/application/views/pages/booklist.php index 697c996..8653681 100644 --- a/application/views/pages/booklist.php +++ b/application/views/pages/booklist.php @@ -44,6 +44,9 @@
    + + load->view('partials/internal-search-box'); ?> +
    format('d/m/Y') . ")" ?> diff --git a/application/views/pages/content.php b/application/views/pages/content.php index fb5a23a..b6d20bc 100644 --- a/application/views/pages/content.php +++ b/application/views/pages/content.php @@ -46,6 +46,8 @@
    + + load->view('partials/internal-search-box'); ?>
    diff --git a/application/views/pages/menu.php b/application/views/pages/menu.php index 13465b5..03d3a3f 100644 --- a/application/views/pages/menu.php +++ b/application/views/pages/menu.php @@ -44,6 +44,9 @@
    + + load->view('partials/internal-search-box'); ?> +
    diff --git a/application/views/pages/search_results.php b/application/views/pages/search_results.php new file mode 100644 index 0000000..7624018 --- /dev/null +++ b/application/views/pages/search_results.php @@ -0,0 +1,157 @@ + + + +load->view('partials/header'); ?> + + + +load->view('partials/language-menu'); ?> + + +
    + +
    + +
    +
    + + load->view('partials/internal-search-box'); ?> + + + + + + + + + +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + . + +
    +
    + + + +
    + + + +
    +
    +
    + +
    +
    +
    + + +
    + + +load->view('partials/footer'); ?> + diff --git a/application/views/partials/internal-search-box.php b/application/views/partials/internal-search-box.php new file mode 100644 index 0000000..b64c366 --- /dev/null +++ b/application/views/partials/internal-search-box.php @@ -0,0 +1,21 @@ +load->helper('form'); +?> + + +
    +
    + +
    +
    + \ No newline at end of file diff --git a/static/sass/_bootstrap.scss b/static/sass/_bootstrap.scss index 8786134..5816d1e 100644 --- a/static/sass/_bootstrap.scss +++ b/static/sass/_bootstrap.scss @@ -30,7 +30,7 @@ @import "bootstrap/navs"; //@import "bootstrap/navbar"; @import "bootstrap/breadcrumbs"; - //@import "bootstrap/pagination"; + @import "bootstrap/pagination"; @import "bootstrap/pager"; //@import "bootstrap/labels"; //@import "bootstrap/badges"; diff --git a/static/sass/style.scss b/static/sass/style.scss index 54bc734..9dd7f4c 100644 --- a/static/sass/style.scss +++ b/static/sass/style.scss @@ -12,6 +12,10 @@ body{ font-family: 'Roboto', sans-serif; } +a{ + word-wrap: break-word; +} + .alert-notification{ [class^=col-]:first-child{ @@ -2498,3 +2502,6 @@ section{ padding: 0 10px 17px; } +.internal-search-box{ + margin: 0 0 15px; +}