Skip to content

Commit

Permalink
fix #154
Browse files Browse the repository at this point in the history
Ordena as coleções e periódicos utilizando as regras do idioma corrente
  • Loading branch information
joffilyfe authored Oct 9, 2020
2 parents 605e2f1 + f8d91b1 commit 101fe13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ FROM ubuntu:18.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \
libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \
python-pip php-sqlite3 php-xml php-mbstring php-cli cron && \
python-pip php-sqlite3 php-xml php-mbstring php-cli cron \
language-pack-pt language-pack-en-base language-pack-es \
libicu-dev php-intl && \
rm -rf /var/lib/apt/lists/* && \
pip install supervisor

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ FROM ubuntu:18.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \
libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \
python-pip php-sqlite3 php-xml php-mbstring php-cli && \
python-pip php-sqlite3 php-xml php-mbstring php-cli \
language-pack-pt language-pack-en-base language-pack-es \
libicu-dev php-intl && \
rm -rf /var/lib/apt/lists/* && \
pip install supervisor

Expand Down
3 changes: 2 additions & 1 deletion application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct()
$this->load_about_link(); // The about link is the same in any page, so I load it here in the constructor.
$this->load_openaccessdeclaration_link(); // The open access link in footer section, so I load it here in the constructor.
$this->load_footer(); // The footer is the same in any page, so I load it here in the constructor.
$this->currentLocale = setlocale(LC_ALL, 0); // it returns the current locale, e.g: pt_BR.UTF8
}

/**
Expand Down Expand Up @@ -207,7 +208,7 @@ public function list_journals_by_alphabetical_order()
return;
}

$journals = $this->Journals->list_all_journals($limit, $offset, $params['status'], $params['matching'], $params['search'], $params['letter']);
$journals = $this->Journals->list_all_journals($limit, $offset, $params['status'], $params['matching'], $params['search'], $params['letter'], $this->currentLocale);
$total_journals = $this->Journals->total_journals($params['status'], $params['matching'], $params['search'], $params['letter']);

$journals_links = $this->get_journals_links();
Expand Down
17 changes: 15 additions & 2 deletions application/models/Journals.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ class Journals extends CI_Model
public function __construct()
{
parent::__construct();

$this->db->conn_id->createFunction(
'locale',
function ($data, $locale = 'root') {
static $collators = array();

if (isset($collators[$locale]) !== true) {
$collators[$locale] = new \Collator($locale);
}

return $collators[$locale]->getSortKey($data);
}
);
}

/**
Expand Down Expand Up @@ -73,7 +86,7 @@ public function list_all_subject_areas($language)
* @param string $letter
* @return array
*/
public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false)
public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false, $locale = 'root')
{

$this->db->from($this->journals_table);
Expand All @@ -82,7 +95,7 @@ public function list_all_journals($limit, $offset, $status = false, $matching =

$this->db->limit($limit, $offset);
$this->db->group_by('title_search');
$this->db->order_by('title_search', 'ASC');
$this->db->order_by("locale('title', '$locale')");

return $this->get_results_obj();
}
Expand Down

0 comments on commit 101fe13

Please sign in to comment.