Warning, file /webapps/ocs-webserver/application/modules/default/views/helpers/FetchStoresForCatTreeJson.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 class Default_View_Helper_FetchStoresForCatTreeJson extends Zend_View_Helper_Abstract
0024 {
0025    
0026     public function fetchStoresForCatTreeJson()
0027     {        
0028 
0029        $sname = Zend_Registry::get('store_host');
0030         /** @var Zend_Cache_Core $cache */
0031         $cache = Zend_Registry::get('cache');        
0032         $cacheName = __FUNCTION__ . md5($sname).'_new';       
0033 
0034         if (false == ($domainobjects = $cache->load($cacheName))) {
0035             $tbl = new Default_Model_DbTable_ConfigStore();
0036             $result = $tbl->fetchDomainObjects();
0037                 // sort Desktop manuelly to the front
0038             $arrayDesktop = array();
0039             $arrayRest =  array();  
0040            
0041             foreach ($result as $obj) {
0042                 $tmp = array();
0043                 $tmp['order'] = $obj['order'];
0044                 $tmp['host'] = $obj['host'];
0045                 $tmp['name'] = $obj['name'];
0046                 $tmp['is_show_in_menu'] = $obj['is_show_in_menu'];
0047                 $tmp['is_show_real_domain_as_url'] = $obj['is_show_real_domain_as_url']; 
0048 
0049                 $arrayRest[] = $tmp;    
0050             }
0051             $domainobjects = array_merge($arrayDesktop, $arrayRest);
0052 
0053             
0054             $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl_store;
0055             // set group name manully
0056             foreach ($domainobjects as &$obj) {
0057 
0058                     if($sname == $obj['host']){
0059                         $obj['menuactive'] = 1;
0060                     }else{
0061                         $obj['menuactive'] = 0;
0062                     }
0063 
0064                     $domainAsUrl = $obj['is_show_real_domain_as_url'];
0065                     if($domainAsUrl)
0066                     {
0067                         $obj['menuhref'] = 'https://' . $obj['host'];
0068                     }else{
0069                         $obj['menuhref'] = $baseurl.'/s/'.$obj['name'];
0070                     }
0071             }
0072 
0073             $cache->save($domainobjects, $cacheName, array(), 3600);
0074         }
0075         return  Zend_Json::encode($domainobjects);
0076     }
0077 
0078 }