Warning, file /webapps/ocs-webserver/application/modules/default/views/helpers/FetchMetaheaderMenuJson.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_FetchMetaheaderMenuJson extends Zend_View_Helper_Abstract
0024 {
0025    
0026     public function fetchMetaheaderMenuJson()
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                 $o =  $obj['order'];   
0043                 $curOrder = floor($obj['order']/1000);      
0044                 if($curOrder<10 or $curOrder>50) continue;
0045                 $obj['calcOrder'] = $curOrder;              
0046 
0047                 $tmp = array();
0048                 $tmp['order'] = $obj['order'];
0049                 $tmp['calcOrder'] = $obj['calcOrder'];
0050                 $tmp['host'] = $obj['host'];
0051                 $tmp['name'] = $obj['name'];
0052                 $tmp['is_show_in_menu'] = $obj['is_show_in_menu'];
0053                 $tmp['is_show_real_domain_as_url'] = $obj['is_show_real_domain_as_url']; 
0054 
0055                 if($curOrder==30) {
0056                     // Desktop set calcOrder = 9 manuelly put desktop in front                    
0057                     $tmp['calcOrder'] = 9;
0058                     $arrayDesktop[] = $tmp;    
0059                 }else{
0060                     $arrayRest[] = $tmp;    
0061                 }                        
0062             }
0063             $domainobjects = array_merge($arrayDesktop, $arrayRest);
0064 
0065             
0066             $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl_store;
0067             // set group name manully
0068             foreach ($domainobjects as &$obj) {
0069 
0070                     if($sname == $obj['host']){
0071                         $obj['menuactive'] = 1;
0072                     }else{
0073                         $obj['menuactive'] = 0;
0074                     }
0075 
0076                     $order =  $obj['order'];
0077                     //OLD: z.b 150001 ende ==1 go real link otherwise /s/$name
0078                     /*$last_char_check = substr($order, -1);
0079                     if($last_char_check=='1')
0080                     {
0081                         $obj['menuhref'] = $obj['host'];
0082                     }else{
0083                         $obj['menuhref'] = $baseurl.'/s/'.$obj['name'];
0084                     }
0085                      * 
0086                      */
0087                     $domainAsUrl = $obj['is_show_real_domain_as_url'];
0088                     if($domainAsUrl)
0089                     {
0090                         $obj['menuhref'] = $obj['host'];
0091                     }else{
0092                         $obj['menuhref'] = $baseurl.'/s/'.$obj['name'];
0093                     }
0094                     
0095                     switch ($obj['calcOrder']) {
0096                         case 9:
0097                             $obj['menugroup']='Desktops';
0098                             break;
0099                         case 10:
0100                             $obj['menugroup']='Applications';
0101                             break;
0102                         case 20:
0103                             $obj['menugroup']='Addons';
0104                             break;
0105                         case 40:
0106                             $obj['menugroup']='Artwork';
0107                             break;                       
0108                         case 50:
0109                         $obj['menugroup']='Other';
0110                         break;
0111                     }
0112                          
0113             }
0114 
0115             $cache->save($domainobjects, $cacheName, array(), 3600);
0116         }
0117         return  Zend_Json::encode($domainobjects);
0118     }
0119 
0120 }