Warning, file /webapps/ocs-webserver/application/modules/default/views/helpers/BuildBaseUrl.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 /**
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_BuildBaseUrl extends Zend_View_Helper_Abstract
0024 {
0025 
0026     /**
0027      * @param string $action
0028      * @param array  $params
0029      * @param string $scheme
0030      *
0031      * @return string
0032      * @throws Zend_Exception
0033      */
0034     public function buildBaseUrl($action = '', $params = null, $scheme = null)
0035     {
0036         /** @var Zend_Controller_Request_Http $request */
0037         $request = Zend_Controller_Front::getInstance()->getRequest();
0038 
0039         $http_host = $request->getHttpHost();
0040         $http_scheme = isset($scheme) ? $scheme : $request->getScheme();
0041         $host = $http_scheme . '://' . $http_host;
0042 
0043         $storeId = null;
0044         if (false === isset($params['store_id'])) {
0045             if ($request->getParam('domain_store_id')) {
0046                 $storeId = '/s/' . $request->getParam('domain_store_id');
0047             }
0048         } else {
0049             $storeId = "/s/{$params['store_id']}";
0050             unset($params['store_id']);
0051         }
0052 
0053         $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null;
0054 
0055         $baseurl = "{$host}{$storeId}";
0056         if (null != $storeConfig && $storeConfig->stay_in_context == false) {
0057             $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl;
0058         }
0059 
0060         $url_param = '';
0061         if (is_array($params)) {
0062             array_walk($params, create_function('&$i,$k', '$i="$k/$i/";'));
0063             $url_param = implode('/', $params);
0064         }
0065 
0066         return "{$baseurl}/{$action}{$url_param}";
0067     }
0068 
0069     /**
0070      * @param string $action
0071      * @param array  $params
0072      *
0073      * @return string
0074      * @throws Zend_Exception
0075      */
0076     public function buildMainBaserUrl($action = '', $params = null)
0077     {
0078         $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl;
0079 
0080         $url_param = '';
0081         if (is_array($params)) {
0082             array_walk($params, create_function('&$i,$k', '$i="$k/$i/";'));
0083             $url_param = implode('/', $params);
0084         }
0085 
0086         return "{$baseurl}/{$action}{$url_param}";
0087     }
0088 
0089     public function buildExternalUrl($member_id, $action = null, $params = null)
0090     {
0091         $url_param = '';
0092         if (is_array($params)) {
0093             array_walk($params, create_function('&$i,$k', '$i="$k/$i/";'));
0094             $url_param = implode('/', $params);
0095         }
0096 
0097         if (isset($action)) {
0098             $action .= '/';
0099         }
0100 
0101         $member_host = Zend_Registry::get('config')->settings->member->page->server;
0102 
0103         return "//{$member_host}/me/{$member_id}/{$action}{$url_param}";
0104     }
0105 
0106 }