File indexing completed on 2025-05-04 05:29:14
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_BuildExploreUrl 0024 { 0025 0026 /** 0027 * @param array $options 0028 * @param null|array $params 0029 * @param bool|false $withHost 0030 * @return string 0031 */ 0032 public function buildFromArray($options, $params = null, $withHost = false) 0033 { 0034 $category = null; 0035 if (isset($options['category'])) { 0036 $category = $options['category']; 0037 } 0038 $filter = null; 0039 if (isset($options['filter'])) { 0040 $filter = $options['filter']; 0041 } 0042 $order = null; 0043 if (isset($options['order'])) { 0044 $order = $options['order']; 0045 } 0046 0047 if(isset($options['fav'])) 0048 { 0049 if($params==null){ 0050 $params=array(); 0051 $params['fav'] = 1; 0052 }else{ 0053 $params['fav'] = 1; 0054 } 0055 } 0056 0057 return $this->buildExploreUrl($category, $filter, $order, $params, $withHost); 0058 } 0059 0060 /** 0061 * @param int $categoryId 0062 * @param int $filterId 0063 * @param string $order 0064 * @param null $params 0065 * @param bool $withHost 0066 * @return string 0067 */ 0068 public function buildExploreUrl($categoryId = null, $filterId = null, $order = null, $params = null, $withHost = false) 0069 { 0070 /** @var Zend_Controller_Request_Http $request */ 0071 $request = Zend_Controller_Front::getInstance()->getRequest(); 0072 0073 $host = ''; 0074 if ($withHost) { 0075 $host = $request->getScheme() . '://' . $request->getHttpHost(); 0076 } 0077 0078 $storeId = null; 0079 if (false === isset($params['store_id'])) { 0080 if ($request->getParam('domain_store_id')) { 0081 $storeId = 's/' . $request->getParam('domain_store_id') . '/'; 0082 } 0083 } else { 0084 $storeId = "s/{$params['store_id']}/"; 0085 unset($params['store_id']); 0086 } 0087 0088 $paramPage = ''; 0089 if (isset($params['page'])) { 0090 $paramPage = "page/{$params['page']}/"; 0091 unset($params['page']); 0092 } 0093 0094 $url_param = ''; 0095 if (is_array($params)) { 0096 array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); 0097 $url_param = implode('/', $params); 0098 } 0099 0100 0101 $paramCategory = ''; 0102 if (($categoryId != '') AND (false === is_array($categoryId))) { 0103 $paramCategory = "cat/{$categoryId}/"; 0104 } 0105 0106 $paramFilter = ''; 0107 if ($filterId != '') { 0108 $paramFilter = "fil/{$filterId}/"; 0109 } 0110 0111 $paramOrder = ''; 0112 if ($order != '') { 0113 $paramOrder = "ord/{$order}/"; 0114 } 0115 0116 return "{$host}/{$storeId}browse/{$paramCategory}{$paramPage}{$paramFilter}{$paramOrder}{$url_param}"; 0117 } 0118 0119 }