当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Controller_Request_Http::getBasePath方法代码示例

本文整理汇总了PHP中Zend_Controller_Request_Http::getBasePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::getBasePath方法的具体用法?PHP Zend_Controller_Request_Http::getBasePath怎么用?PHP Zend_Controller_Request_Http::getBasePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Controller_Request_Http的用法示例。


在下文中一共展示了Zend_Controller_Request_Http::getBasePath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBasePath

 public function getBasePath()
 {
     $path = parent::getBasePath();
     if (empty($path)) {
         $path = '/';
     } else {
         $path = str_replace('\\', '/', $path);
     }
     return $path;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:10,代码来源:Http.php

示例2: canonicalizeRequestUrl

 /**
  * Canonicalizes the request URL based on the given link URL. Canonicalization will
  * only happen when requesting an HTML page, as it is primarily an SEO benefit.
  *
  * A response exception will be thrown is redirection is required.
  *
  * @param string $linkUrl
  */
 public function canonicalizeRequestUrl($linkUrl)
 {
     if ($this->getResponseType() != 'html') {
         return;
     }
     if (!$this->_request->isGet()) {
         return;
     }
     $linkUrl = strval($linkUrl);
     if (strlen($linkUrl) == 0) {
         return;
     }
     if ($linkUrl[0] == '.') {
         $linkUrl = substr($linkUrl, 1);
     }
     $basePath = $this->_request->getBasePath();
     $requestUri = $this->_request->getRequestUri();
     if (substr($requestUri, 0, strlen($basePath)) != $basePath) {
         return;
     }
     $routeBase = substr($requestUri, strlen($basePath));
     if (isset($routeBase[0]) && $routeBase[0] === '/') {
         $routeBase = substr($routeBase, 1);
     }
     if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $routeBase, $match)) {
         $requestUrlPrefix = $match[1];
         $requestParams = isset($match[3]) ? $match[3] : false;
     } else {
         $parts = explode('?', $routeBase);
         $requestUrlPrefix = $parts[0];
         $requestParams = isset($parts[1]) ? $parts[1] : false;
     }
     if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $linkUrl, $match)) {
         $linkUrlPrefix = $match[1];
         //$linkParams = isset($match[3]) ? $match[3] : false;
     } else {
         $parts = explode('?', $linkUrl);
         $linkUrlPrefix = $parts[0];
         //$linkParams = isset($parts[1]) ? $parts[1]: false;
     }
     if (urldecode($requestUrlPrefix) != urldecode($linkUrlPrefix)) {
         $redirectUrl = $linkUrlPrefix;
         if ($requestParams !== false) {
             $redirectUrl .= (strpos($redirectUrl, '?') === false ? '?' : '&') . $requestParams;
         }
         throw $this->responseException($this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, $redirectUrl));
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:56,代码来源:Controller.php

示例3: _initView

 public function _initView()
 {
     // init view
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     if (null == $viewRenderer->view) {
         $viewRenderer->initView();
     }
     $view = $viewRenderer->view;
     if (is_object($view)) {
         $view->doctype('XHTML1_STRICT');
         // set application charset
         $view->charset = 'UTF-8';
         // build the root url
         $request = new Zend_Controller_Request_Http();
         $siteUrl = $request->getScheme() . '://' . $request->getHttpHost();
         $view->host = $siteUrl;
         $basePath = $request->getBasePath();
         $siteUrl = $basePath == '' ? $siteUrl : $siteUrl . '/' . ltrim($basePath, '/');
         $view->baseUrl = $siteUrl;
         $siteUrl = $siteUrl . '/index.php';
         $view->rootUrl = $siteUrl;
     }
 }
开发者ID:jacksonlee1102,项目名称:education,代码行数:23,代码来源:Bootstrap.php

示例4: _getCalendarLink

 /**
  * Getting the code reference and the calendar image. Configure calendar.
  *
  * @return string
  */
 private function _getCalendarLink()
 {
     $request = new Zend_Controller_Request_Http();
     $basePath = $request->getBasePath();
     $locale = Default_Plugin_SysBox::getTranslateLocale();
     $dateFormat = $locale == 'en' ? '%m.%d.%Y' : '%d.%m.%Y';
     //--------------------------
     $calendarLink = '
         <a href="#" id="' . $this->getElement()->getName() . '_calendar">' . '<img class="calendar-image" src = "' . Default_Plugin_SysBox::getUrlRes('/js/calendar/calendar.gif') . '">
         </a>
 
         <script type="text/javascript">
             Calendar.setup(
               {
                 inputField  : "' . $this->getElement()->getName() . '",
                 ifFormat    : "' . $dateFormat . '",
                 button      : "' . $this->getElement()->getName() . '_calendar",
                 firstDay    : 1
               }
             );
         </script>
     ';
     return $calendarLink;
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:29,代码来源:Calendar.php

示例5: testBasePathAutoDiscoveryWithPhpFile

    public function testBasePathAutoDiscoveryWithPhpFile()
    {
        $_SERVER['REQUEST_URI']     = '/dir/action';
        $_SERVER['PHP_SELF']        = '/dir/index.php';
        $_SERVER['SCRIPT_FILENAME'] = '/var/web/dir/index.php';
        $request = new Zend_Controller_Request_Http();

        $this->assertEquals('/dir', $request->getBasePath(), $request->getBaseUrl());
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:HttpTest.php

示例6: getBaseURL

 /**
  * Get the base URL path
  * ex. /zf-myblog/public
  *
  * @return string
  */
 static function getBaseURL()
 {
     $request = new Zend_Controller_Request_Http();
     $basePath = $request->getBasePath();
     //$request->getHttpHost()
     return $basePath;
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:13,代码来源:SysBox.php

示例7: getRequestPaths

 /**
  * Gets the request paths from the specified request object.
  *
  * @param Zend_Controller_Request_Http $request
  *
  * @return array Keys: basePath, host, protocol, fullBasePath, requestUri
  */
 public static function getRequestPaths(Zend_Controller_Request_Http $request)
 {
     $basePath = $request->getBasePath();
     if ($basePath === '' || substr($basePath, -1) != '/') {
         $basePath .= '/';
     }
     $host = $request->getServer('HTTP_HOST');
     if (!$host) {
         $host = $request->getServer('SERVER_NAME');
         $serverPort = intval($request->getServer('SERVER_PORT'));
         if ($serverPort && $serverPort != 80 && $serverPort != 443) {
             $host .= ':' . $serverPort;
         }
     }
     $protocol = $request->isSecure() ? 'https' : 'http';
     $requestUri = $request->getRequestUri();
     return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri);
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:25,代码来源:Application.php

示例8: _initialize

 /**
  * Initialize the paths, the config values and all the render stuff.
  *
  * @return void
  */
 public function _initialize()
 {
     // Report all PHP errors
     error_reporting(-1);
     define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
     define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
     if (!defined('PHPR_CONFIG_FILE')) {
         define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.php');
     }
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
     require_once 'Zend/Loader/Autoloader.php';
     require_once 'Phprojekt/Loader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
     // Read the config file, but only the production setting
     try {
         $this->_config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
     } catch (Zend_Config_Exception $error) {
         $response = new Zend_Controller_Request_Http();
         $webPath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
         header("Location: " . $webPath . "setup.php");
         die('You need the file configuration.php to continue. Have you tried the <a href="' . $webPath . 'setup.php">setup</a> routine?' . "\n" . '<br />Original error: ' . $error->getMessage());
     }
     // Set webpath, tmpPath and applicationPath
     if (empty($this->_config->webpath)) {
         $response = new Zend_Controller_Request_Http();
         $this->_config->webpath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
     }
     define('PHPR_ROOT_WEB_PATH', $this->_config->webpath . 'index.php/');
     define('PHPR_TEMP_PATH', $this->_config->tmpPath);
     define('PHPR_USER_CORE_PATH', $this->_config->applicationPath);
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . PHPR_USER_CORE_PATH . PATH_SEPARATOR . get_include_path());
     // Set the timezone to UTC
     date_default_timezone_set('UTC');
     // Start zend session to handle all session stuff
     try {
         Zend_Session::start();
     } catch (Zend_Session_Exception $error) {
         Zend_Session::writeClose();
         Zend_Session::start();
         Zend_Session::regenerateId();
         error_log($error);
     }
     // Set a metadata cache and clean it
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => PHPR_TEMP_PATH . 'zendCache' . DIRECTORY_SEPARATOR);
     try {
         $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     } catch (Exception $error) {
         die("The directory " . PHPR_TEMP_PATH . "zendCache do not exists or not have write access.");
     }
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     // Use for Debug only
     //Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
     // Check Logs
     $this->getLog();
     $missingRequirements = array();
     // The following extensions are either needed by components of the Zend Framework that are used
     // or by P6 components itself.
     $extensionsNeeded = array('mbstring', 'iconv', 'ctype', 'gd', 'pcre', 'pdo', 'Reflection', 'session', 'SPL', 'zlib');
     // These settings need to be properly configured by the admin
     $settingsNeeded = array('magic_quotes_gpc' => 0, 'magic_quotes_runtime' => 0, 'magic_quotes_sybase' => 0);
     // Check the PHP version
     $requiredPhpVersion = "5.2.4";
     if (version_compare(phpversion(), $requiredPhpVersion, '<')) {
         // This is a requirement of the Zend Framework
         $missingRequirements[] = "- PHP Version '" . $requiredPhpVersion . "' or newer";
     }
     foreach ($extensionsNeeded as $extension) {
         if (!extension_loaded($extension)) {
             $missingRequirements[] = "- The '" . $extension . "' extension must be enabled.";
         }
     }
     // Check pdo library
     $mysql = extension_loaded('pdo_mysql');
     $sqlite = extension_loaded('pdo_sqlite2');
     $pgsql = extension_loaded('pdo_pgsql');
     if (!$mysql && !$sqlite && !$pgsql) {
         $missingRequirements[] = "- You need one of these PDO extensions: pdo_mysql, pdo_pgsql or pdo_sqlite";
     }
     foreach ($settingsNeeded as $conf => $value) {
         if (ini_get($conf) != $value) {
             $missingRequirements[] = "- The php.ini setting of '" . $conf . "' has to be '" . $value . "'.";
         }
     }
     if (!empty($missingRequirements)) {
         $message = "Your PHP does not meet the requirements needed for P6.<br />" . implode("<br />", $missingRequirements);
         die($message);
     }
     $helperPaths = $this->_getHelperPaths();
     $view = $this->_setView($helperPaths);
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
     $viewRenderer->setViewBasePathSpec(':moduleDir/Views');
     $viewRenderer->setViewScriptPathSpec(':action.:suffix');
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
//.........这里部分代码省略.........
开发者ID:joerch,项目名称:PHProjekt,代码行数:101,代码来源:Phprojekt.php

示例9: getUrl

 /**
  * returns requested url part
  *
  * @param string $part
  * @return string
  */
 public static function getUrl($part = 'full')
 {
     $request = new Zend_Controller_Request_Http();
     $pathname = $request->getBasePath();
     $hostname = $request->getHttpHost();
     $protocol = $request->getScheme();
     switch ($part) {
         case 'path':
             $url = $pathname;
             break;
         case 'host':
             $url = $hostname;
             break;
         case 'protocol':
             $url = $protocol;
             break;
         case 'full':
         default:
             $url = $protocol . '://' . $hostname . $pathname;
             break;
     }
     return $url;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:29,代码来源:Core.php

示例10: _initialize

 /**
  * Initialize the paths, the config values and all the render stuff.
  *
  * @return void
  */
 public function _initialize()
 {
     // Report all PHP errors
     error_reporting(-1);
     define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
     define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
     if (!defined('PHPR_CONFIG_FILE')) {
         define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.php');
     }
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
     require_once 'Zend/Loader/Autoloader.php';
     require_once 'Phprojekt/Loader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
     // Read the config file, but only the production setting
     try {
         $this->_config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
     } catch (Zend_Config_Exception $error) {
         $response = new Zend_Controller_Request_Http();
         $webPath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
         header("Location: " . $webPath . "setup.php");
         die('You need the file configuration.php to continue. Have you tried the <a href="' . $webPath . 'setup.php">setup</a> routine?' . "\n" . '<br />Original error: ' . $error->getMessage());
     }
     // Set webpath, tmpPath and applicationPath
     if (empty($this->_config->webpath)) {
         $response = new Zend_Controller_Request_Http();
         $this->_config->webpath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
     }
     define('PHPR_ROOT_WEB_PATH', $this->_config->webpath . 'index.php/');
     define('PHPR_TEMP_PATH', $this->_config->tmpPath);
     define('PHPR_USER_CORE_PATH', $this->_config->applicationPath);
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . PHPR_USER_CORE_PATH . PATH_SEPARATOR . get_include_path());
     // Set the timezone to UTC
     date_default_timezone_set('UTC');
     // Start zend session to handle all session stuff
     try {
         Zend_Session::start();
     } catch (Zend_Session_Exception $error) {
         Zend_Session::writeClose();
         Zend_Session::start();
         Zend_Session::regenerateId();
         error_log($error);
     }
     // Set a metadata cache and clean it
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => PHPR_TEMP_PATH . 'zendCache' . DIRECTORY_SEPARATOR);
     try {
         $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     } catch (Exception $error) {
         die("The directory " . PHPR_TEMP_PATH . "zendCache do not exists or not have write access.");
     }
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     // Use for Debug only
     //Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
     // Check Logs
     $this->getLog();
     // Check the server
     $checkServer = Phprojekt::checkExtensionsAndSettings();
     // Check the PHP version
     if (!$checkServer['requirements']['php']['checked']) {
         $missingRequirements[] = "- You need the PHP Version '" . $checkServer['requirements']['php']['required'] . "' or newer";
     }
     // Check required extension
     foreach ($checkServer['requirements']['extension'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "- The '" . $name . "' extension must be enabled.";
         }
     }
     // Check required settings
     foreach ($checkServer['requirements']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "- The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'.";
         }
     }
     // Show message
     if (!empty($missingRequirements)) {
         $message = "Your PHP does not meet the requirements needed for P6.<br />" . implode("<br />", $missingRequirements);
         die($message);
     }
     $helperPaths = $this->_getHelperPaths();
     $view = $this->_setView($helperPaths);
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
     $viewRenderer->setViewBasePathSpec(':moduleDir/Views');
     $viewRenderer->setViewScriptPathSpec(':action.:suffix');
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     foreach ($helperPaths as $helperPath) {
         Zend_Controller_Action_HelperBroker::addPath($helperPath['directory']);
     }
     $plugin = new Zend_Controller_Plugin_ErrorHandler();
     $plugin->setErrorHandlerModule('Default');
     $plugin->setErrorHandlerController('Error');
     $plugin->setErrorHandlerAction('error');
     $front = Zend_Controller_Front::getInstance();
     $front->setDispatcher(new Phprojekt_Dispatcher());
     $front->registerPlugin($plugin);
//.........这里部分代码省略.........
开发者ID:victorli,项目名称:PHProjekt,代码行数:101,代码来源:Phprojekt.php

示例11: testGetSetBasePath

 public function testGetSetBasePath()
 {
     $this->_request->setBasePath('/news');
     $this->assertEquals('/news', $this->_request->getBasePath());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:5,代码来源:HttpTest.php


注:本文中的Zend_Controller_Request_Http::getBasePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。