[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ocs-webserver/dev] application/modules/default/controllers: Use _buildCategoriesList()
From:       Akira Ohgaki <null () kde ! org>
Date:       2017-04-01 0:12:33
Message-ID: E1cu6ef-0008Fc-DJ () code ! kde ! org
[Download RAW message or body]

Git commit 5757480158b9213e09eea29053a89b61fcf0928f by Akira Ohgaki.
Committed on 01/04/2017 at 00:11.
Pushed by akiraohgaki into branch 'dev'.

Use _buildCategoriesList()

M  +1    -80   application/modules/default/controllers/Ocsv1Controller.php

https://commits.kde.org/ocs-webserver/5757480158b9213e09eea29053a89b61fcf0928f

diff --git a/application/modules/default/controllers/Ocsv1Controller.php \
b/application/modules/default/controllers/Ocsv1Controller.php index aaecd5f..66e1756 \
                100644
--- a/application/modules/default/controllers/Ocsv1Controller.php
+++ b/application/modules/default/controllers/Ocsv1Controller.php
@@ -701,86 +701,7 @@ class Ocsv1Controller extends Zend_Controller_Action
             //$this->_sendErrorResponse(999, '');
         }
 
-        //$catArray = Zend_Registry::get('application_store_category_list');
-        $tableCategories = new Default_Model_DbTable_ProjectCategory();
-        $categories = null;
-
-        if (Zend_Registry::isRegistered('store_category_list')) {
-            $categories = \
                $tableCategories->fetchActive(Zend_Registry::get('store_category_list'));
                
-        } else {
-            $categories = $tableCategories->fetchAllActive();
-        }
-
-        $categoriesList = array();
-
-        if ($categories) {
-            foreach ($categories as $category) {
-                if (is_array($category)) {
-                    $category = (object)$category;
-                }
-
-                // Top-level category
-                $categoryTitle = $category->title;
-                $categoryDisplayName = $category->title;
-                if (!empty($category->name_legacy)) {
-                    $categoryTitle = $category->name_legacy;
-                }
-                $categoryXdgType = '';
-                if (!empty($category->xdg_type)) {
-                    $categoryXdgType = $category->xdg_type;
-                }
-                if ($this->_format == 'json') {
-                    $categoriesList[] = array(
-                        'id' => $category->project_category_id,
-                        'name' => $categoryTitle,
-                        'display_name' => $categoryDisplayName,
-                        'parent_id' => '',
-                        'xdg_type' => $categoryXdgType
-                    );
-                } else {
-                    $categoriesList[] = array(
-                        'id' => array('@text' => $category->project_category_id),
-                        'name' => array('@text' => $categoryTitle),
-                        'display_name' => array('@text' => $categoryDisplayName),
-                        'parent_id' => array('@text' => ''),
-                        'xdg_type' => array('@text' => $categoryXdgType)
-                    );
-                }
-
-                // Sub-categories
-                $subCategories = \
                $tableCategories->fetchImmediateChildren($category->project_category_id);
                
-                if (!empty($subCategories)) {
-                    foreach ($subCategories as $subCategory) {
-                        $categoryTitle = $subCategory['title'];
-                        $categoryDisplayName = $subCategory['title'];
-                        if (!empty($subCategory['name_legacy'])) {
-                            $categoryTitle = $subCategory['name_legacy'];
-                        }
-                        $categoryXdgType = '';
-                        if (!empty($subCategory['xdg_type'])) {
-                            $categoryXdgType = $subCategory['xdg_type'];
-                        }
-                        if ($this->_format == 'json') {
-                            $categoriesList[] = array(
-                                'id' => $subCategory['project_category_id'],
-                                'name' => $categoryTitle,
-                                'display_name' => $categoryDisplayName,
-                                'parent_id' => $category->project_category_id,
-                                'xdg_type' => $categoryXdgType
-                            );
-                        } else {
-                            $categoriesList[] = array(
-                                'id' => array('@text' => \
                $subCategory['project_category_id']),
-                                'name' => array('@text' => $categoryTitle),
-                                'display_name' => array('@text' => \
                $categoryDisplayName),
-                                'parent_id' => array('@text' => \
                $category->project_category_id),
-                                'xdg_type' => array('@text' => $categoryXdgType)
-                            );
-                        }
-                    }
-                }
-            }
-        }
+        $categoriesList = $this->_buildCategoriesList();
 
         if ($this->_format == 'json') {
             $response = array(


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic