Skip to content

Commit

Permalink
Ordenação das listas de coleções (tk14).
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliano Maciel committed Sep 21, 2018
1 parent 16e6693 commit ec35332
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private function load_collections()

$collections = $this->put_content_in_cache('collections', SCIELO_COLLECTIONS_URL, FOUR_HOURS_TIMEOUT);

$this->Collections->initialize($collections);
$this->Collections->initialize($collections, $this->language);
}

/**
Expand Down
38 changes: 28 additions & 10 deletions application/models/Collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,25 @@ class Collections
*/
private $discontinued_list = array();

/**
* The user language selected.
*
* @var string
*/
private $language;

/**
* Gets the about json array and call other setup methods.
*
* @param array $collection_json The rest API service data converted in an array.
* @return void
*/
public function initialize($collection_json)
public function initialize($collection_json, $language)
{
$this->collection_json = $collection_json;

$this->language = $language;

$this->set_collection_lists();
}

Expand All @@ -98,7 +107,9 @@ public function get_books_list()
public function get_journals_list()
{

return $this->journals_list;
ksort($this->journals_list);

return ($this->journals_list);
}

/**
Expand All @@ -109,7 +120,9 @@ public function get_journals_list()
public function get_development_list()
{

return $this->development_list;
ksort($this->development_list);

return ($this->development_list);
}

/**
Expand All @@ -120,7 +133,9 @@ public function get_development_list()
public function get_scientific_list()
{

return $this->scientific_list;
ksort($this->scientific_list);

return ($this->scientific_list);
}

/**
Expand All @@ -130,8 +145,9 @@ public function get_scientific_list()
*/
public function get_discontinued_list()
{
ksort($this->discontinued_list);

return $this->discontinued_list;
return ($this->discontinued_list);
}

/**
Expand All @@ -147,25 +163,27 @@ private function set_collection_lists()

if ($collection['type'] == 'journals') {

$index = $collection['name'][$this->language];

if ($collection['is_active']) {

switch ($collection['status']) {

case 'certified': // Section 'Coleções certificadas'
$this->journals_list[] = (object)$collection;
case 'certified': // Section 'Coleções certificadas'
$this->journals_list[$index] = (object)$collection;
break;

case 'diffusion': // Section 'Coleção de divulgação científica'
$this->scientific_list[] = (object)$collection;
$this->scientific_list[$index] = (object)$collection;
break;

case 'development': // Section 'Coleção em desenvolvimento'
$this->development_list[] = (object)$collection;
$this->development_list[$index] = (object)$collection;
break;
}

} else {
$this->discontinued_list[] = (object)$collection;
$this->discontinued_list[$index] = (object)$collection;
}

} elseif ($collection['type'] == 'books') {
Expand Down

0 comments on commit ec35332

Please sign in to comment.