Skip to content

Commit 101fe13

Browse files
authored
fix #154
Ordena as coleções e periódicos utilizando as regras do idioma corrente
2 parents 605e2f1 + f8d91b1 commit 101fe13

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ FROM ubuntu:18.04
1414
RUN apt-get update && \
1515
DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \
1616
libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \
17-
python-pip php-sqlite3 php-xml php-mbstring php-cli cron && \
17+
python-pip php-sqlite3 php-xml php-mbstring php-cli cron \
18+
language-pack-pt language-pack-en-base language-pack-es \
19+
libicu-dev php-intl && \
1820
rm -rf /var/lib/apt/lists/* && \
1921
pip install supervisor
2022

Dockerfile-dev

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ FROM ubuntu:18.04
33
RUN apt-get update && \
44
DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 \
55
libapache2-mod-php php-gd php-curl php-memcached curl python-setuptools \
6-
python-pip php-sqlite3 php-xml php-mbstring php-cli && \
6+
python-pip php-sqlite3 php-xml php-mbstring php-cli \
7+
language-pack-pt language-pack-en-base language-pack-es \
8+
libicu-dev php-intl && \
79
rm -rf /var/lib/apt/lists/* && \
810
pip install supervisor
911

application/controllers/Home.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct()
4545
$this->load_about_link(); // The about link is the same in any page, so I load it here in the constructor.
4646
$this->load_openaccessdeclaration_link(); // The open access link in footer section, so I load it here in the constructor.
4747
$this->load_footer(); // The footer is the same in any page, so I load it here in the constructor.
48+
$this->currentLocale = setlocale(LC_ALL, 0); // it returns the current locale, e.g: pt_BR.UTF8
4849
}
4950

5051
/**
@@ -207,7 +208,7 @@ public function list_journals_by_alphabetical_order()
207208
return;
208209
}
209210

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

213214
$journals_links = $this->get_journals_links();

application/models/Journals.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ class Journals extends CI_Model
3030
public function __construct()
3131
{
3232
parent::__construct();
33+
34+
$this->db->conn_id->createFunction(
35+
'locale',
36+
function ($data, $locale = 'root') {
37+
static $collators = array();
38+
39+
if (isset($collators[$locale]) !== true) {
40+
$collators[$locale] = new \Collator($locale);
41+
}
42+
43+
return $collators[$locale]->getSortKey($data);
44+
}
45+
);
3346
}
3447

3548
/**
@@ -73,7 +86,7 @@ public function list_all_subject_areas($language)
7386
* @param string $letter
7487
* @return array
7588
*/
76-
public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false)
89+
public function list_all_journals($limit, $offset, $status = false, $matching = false, $search = false, $letter = false, $locale = 'root')
7790
{
7891

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

8396
$this->db->limit($limit, $offset);
8497
$this->db->group_by('title_search');
85-
$this->db->order_by('title_search', 'ASC');
98+
$this->db->order_by("locale('title', '$locale')");
8699

87100
return $this->get_results_obj();
88101
}

0 commit comments

Comments
 (0)