OC_VCategories: sort categories in natural order using usort
Use usort to sort, so that the json encoding is an array.
This commit is contained in:
parent
b2011bd0a0
commit
69d584331d
|
@ -64,6 +64,7 @@ class OC_VCategories {
|
||||||
*/
|
*/
|
||||||
public function categories() {
|
public function categories() {
|
||||||
OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
|
OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
|
||||||
|
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
|
||||||
return $this->categories;
|
return $this->categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +97,6 @@ class OC_VCategories {
|
||||||
}
|
}
|
||||||
if(count($newones) > 0) {
|
if(count($newones) > 0) {
|
||||||
$this->categories = array_merge($this->categories, $newones);
|
$this->categories = array_merge($this->categories, $newones);
|
||||||
natcasesort($this->categories); // Dunno if this is necessary
|
|
||||||
if($sync === true) {
|
if($sync === true) {
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ class OC_VCategories {
|
||||||
* @brief Save the list with categories
|
* @brief Save the list with categories
|
||||||
*/
|
*/
|
||||||
private function save() {
|
private function save() {
|
||||||
|
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
|
||||||
$escaped_categories = serialize($this->categories);
|
$escaped_categories = serialize($this->categories);
|
||||||
OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG);
|
OC_Log::write('core','OC_VCategories::save: '.print_r($this->categories, true), OC_Log::DEBUG);
|
||||||
OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories);
|
OC_Preferences::setValue($this->user, $this->app, self::PREF_CATEGORIES_LABEL, $escaped_categories);
|
||||||
|
|
Loading…
Reference in New Issue