File indexing completed on 2025-03-09 05:22:45

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class Default_View_Helper_BuildSearchBaseUrl
0024 {
0025 
0026     /**
0027      * 
0028      * @param string $action
0029      * @param array  $params
0030      * @param bool   $withHost
0031      * @param string $scheme
0032      *
0033      * @return string
0034      */
0035     public function buildSearchBaseUrl($params = null, $withHost = false, $scheme = null)
0036     {       
0037         /** @var Zend_Controller_Request_Http $request */
0038         $request = Zend_Controller_Front::getInstance()->getRequest();
0039 
0040         $host = '';
0041         if ($withHost) {
0042             $http_host = $request->getHttpHost();
0043             $http_scheme = isset($scheme) ? $scheme : $request->getScheme();
0044             $host = $http_scheme . '://' . $http_host;
0045         }
0046 
0047         $storeId = null;
0048         if (false === isset($params['store_id'])) {
0049             if ($request->getParam('domain_store_id')) {
0050                 $storeId = 's/' . $request->getParam('domain_store_id') . '/';
0051             }
0052         } else {
0053             $storeId = "s/{$params['store_id']}/";
0054             unset($params['store_id']);
0055         }
0056 
0057         $url_param = '';
0058         if (is_array($params)) {
0059             array_walk($params, create_function('&$i,$k', '$i="$k/$i/";'));
0060             $url_param = implode('/', $params);
0061         }
0062 
0063         return "{$host}/{$storeId}search/projectSearchText/";
0064     }
0065 
0066 }