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


PHP Pimcore_Tool::getHostname方法代码示例

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


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

示例1: match

 /**
  * @param  $path
  * @param bool $partial
  * @return array|bool
  */
 public function match($path, $partial = false)
 {
     $matchFound = false;
     $config = Pimcore_Config::getSystemConfig();
     $routeingDefaults = Pimcore_Tool::getRoutingDefaults();
     $params = array_merge($_GET, $_POST);
     $params = array_merge($routeingDefaults, $params);
     // set the original path
     $originalPath = $path;
     // check for a registered site
     try {
         if ($config->general->domain != Pimcore_Tool::getHostname()) {
             $domain = Pimcore_Tool::getHostname();
             $site = Site::getByDomain($domain);
             $site->setRootPath($site->getRootDocument()->getFullPath());
             $path = $site->getRootDocument()->getFullPath() . $path;
             Zend_Registry::set("pimcore_site", $site);
         }
     } catch (Exception $e) {
     }
     // check for direct definition of controller/action
     if (!empty($_REQUEST["controller"]) && !empty($_REQUEST["action"])) {
         $matchFound = true;
         //$params["document"] = $this->getNearestDocumentByPath($path);
     }
     // you can also call a page by it's ID /?pimcore_document=XXXX
     if (!$matchFound) {
         if (!empty($params["pimcore_document"]) || !empty($params["pdid"])) {
             $doc = Document::getById($params["pimcore_document"] ? $params["pimcore_document"] : $params["pdid"]);
             if ($doc instanceof Document) {
                 $path = $doc->getFullPath();
             }
         }
     }
     // test if there is a suitable redirect with override = all (=> priority = 99)
     if (!$matchFound) {
         $this->checkForRedirect(true);
     }
     // test if there is a suitable page
     if (!$matchFound) {
         try {
             $document = Document::getByPath($path);
             // check for a parent hardlink with childs
             if (!$document instanceof Document) {
                 $hardlinkedParentDocument = $this->getNearestDocumentByPath($path, true);
                 if ($hardlinkedParentDocument instanceof Document_Hardlink) {
                     if ($hardLinkedDocument = Document_Hardlink_Service::getChildByPath($hardlinkedParentDocument, $path)) {
                         $document = $hardLinkedDocument;
                     }
                 }
             }
             // check for direct hardlink
             if ($document instanceof Document_Hardlink) {
                 $hardlinkParentDocument = $document;
                 $document = Document_Hardlink_Service::wrap($hardlinkParentDocument);
             }
             if ($document instanceof Document) {
                 if (in_array($document->getType(), array("page", "snippet", "email"))) {
                     if (!empty($params["pimcore_version"]) || !empty($params["pimcore_preview"]) || !empty($params["pimcore_admin"]) || !empty($params["pimcore_editmode"]) || $document->isPublished()) {
                         // check for a pretty url, and if the document is called by that, otherwise redirect to pretty url
                         if ($document instanceof Document_Page && $document->getPrettyUrl() && empty($params["pimcore_preview"]) && empty($params["pimcore_editmode"])) {
                             if (rtrim($document->getPrettyUrl(), " /") != rtrim($path, "/")) {
                                 header("Location: " . $document->getPrettyUrl(), true, 301);
                                 exit;
                             }
                         }
                         $params["document"] = $document;
                         if ($controller = $document->getController()) {
                             $params["controller"] = $controller;
                             $params["action"] = "index";
                         }
                         if ($action = $document->getAction()) {
                             $params["action"] = $action;
                         }
                         if ($module = $document->getModule()) {
                             $params["module"] = $module;
                         }
                         // check for a trailing slash in path, if exists, redirect to this page without the slash
                         // the only reason for this is: SEO, Analytics, ... there is no system specific reason, pimcore would work also with a trailing slash without problems
                         // use $originalPath because of the sites
                         // only do redirecting with GET requests
                         if (strtolower($_SERVER["REQUEST_METHOD"]) == "get") {
                             if ($config->documents->allowtrailingslash) {
                                 if ($config->documents->allowtrailingslash == "no") {
                                     if (substr($originalPath, strlen($originalPath) - 1, 1) == "/" && $originalPath != "/") {
                                         $redirectUrl = rtrim($originalPath, "/");
                                         if ($_SERVER["QUERY_STRING"]) {
                                             $redirectUrl .= "?" . $_SERVER["QUERY_STRING"];
                                         }
                                         header("Location: " . $redirectUrl, true, 301);
                                         exit;
                                     }
                                 }
                             }
                             if ($config->documents->allowcapitals) {
//.........这里部分代码省略.........
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Frontend.php

示例2: routeStartup

 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $requestUri = $request->getRequestUri();
     $excludePatterns = array();
     // only enable GET method
     if (!$request->isGet()) {
         return $this->disable();
     }
     try {
         $conf = Pimcore_Config::getSystemConfig();
         if ($conf->cache) {
             $conf = $conf->cache;
             if (!$conf->enabled) {
                 return $this->disable();
             }
             if ($conf->lifetime) {
                 $this->setLifetime((int) $conf->lifetime);
             }
             if ($conf->excludePatterns) {
                 $confExcludePatterns = explode(",", $conf->excludePatterns);
                 if (!empty($confExcludePatterns)) {
                     $excludePatterns = $confExcludePatterns;
                 }
             }
             if ($conf->excludeCookie) {
                 $cookies = explode(",", strval($conf->excludeCookie));
                 foreach ($cookies as $cookie) {
                     if (isset($_COOKIE[trim($cookie)])) {
                         return $this->disable();
                     }
                 }
             }
         } else {
             return $this->disable();
         }
     } catch (Exception $e) {
         return $this->disable();
     }
     foreach ($excludePatterns as $pattern) {
         if (preg_match($pattern, $requestUri)) {
             return $this->disable();
         }
     }
     $appendKey = "";
     // this is for example for the image-data-uri plugin
     if ($request->getParam("pimcore_cache_tag_suffix")) {
         $tags = $request->getParam("pimcore_cache_tag_suffix");
         if (is_array($tags)) {
             $appendKey = "_" . implode("_", $tags);
         }
     }
     $this->cacheKey = "output_" . md5(Pimcore_Tool::getHostname() . $requestUri) . $appendKey;
     if ($cacheItem = Pimcore_Model_Cache::load($this->cacheKey, true)) {
         header("X-Pimcore-Cache-Tag: " . $this->cacheKey, true, 200);
         header("X-Pimcore-Cache-Date: " . $cacheItem["date"]);
         foreach ($cacheItem["rawHeaders"] as $header) {
             header($header);
         }
         foreach ($cacheItem["headers"] as $header) {
             header($header['name'] . ': ' . $header['value'], $header['replace']);
         }
         echo $cacheItem["content"];
         exit;
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:65,代码来源:Cache.php

示例3: abSaveAction

 public function abSaveAction()
 {
     // source-page
     $sourceDoc = Document::getById($this->_getParam("documentId"));
     $goalDoc = Document::getByPath($this->_getParam("conversionPage"));
     if (!$sourceDoc || !$goalDoc) {
         exit;
     }
     // clean properties
     $sourceDoc = $this->clearProperties($sourceDoc);
     $goalDoc = $this->clearProperties($goalDoc);
     // google stuff
     $credentials = $this->getAnalyticsCredentials();
     $config = Pimcore_Google_Analytics::getSiteConfig($site);
     $gdata = $this->getService();
     // create new experiment
     $entryResult = $gdata->insertEntry("\r\n            <entry xmlns='http://www.w3.org/2005/Atom'\r\n                   xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                   xmlns:app='http://www.w3.org/2007/app'\r\n                   xmlns:gd='http://schemas.google.com/g/2005'>\r\n                <title>" . $this->_getParam("name") . "</title>\r\n                <gwo:analyticsAccountId>" . $config->accountid . "</gwo:analyticsAccountId>\r\n                <gwo:experimentType>AB</gwo:experimentType>\r\n                <gwo:status>Running</gwo:status>\r\n                <link rel='gwo:testUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "' />\r\n                <link rel='gwo:goalUrl' type='text/html' href='http://" . Pimcore_Tool::getHostname() . $goalDoc->getFullPath() . "' />\r\n            </entry>\r\n        ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments");
     $e = $entryResult->getExtensionElements();
     $data = array();
     foreach ($e as $a) {
         $data[$a->rootElement] = $a->getText();
     }
     // get tracking code
     $d = preg_match("/_getTracker\\(\"(.*)\"\\)/", $data["trackingScript"], $matches);
     $trackingId = $matches[1];
     // get test id
     $d = preg_match("/_trackPageview\\(\"\\/([0-9]+)/", $data["trackingScript"], $matches);
     $testId = $matches[1];
     // set original page
     $entryResult = $gdata->insertEntry("\r\n            <entry xmlns='http://www.w3.org/2005/Atom'\r\n                   xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                   xmlns:app='http://www.w3.org/2007/app'\r\n                   xmlns:gd='http://schemas.google.com/g/2005'>\r\n            <title>Original</title>\r\n            <content>http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "</content>\r\n            </entry>\r\n        ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations");
     // set testing pages
     for ($i = 1; $i < 100; $i++) {
         if ($this->_getParam("page_name_" . $i)) {
             $pageUrl = "";
             if ($this->_getParam("page_url_" . $i)) {
                 if ($variantDoc = Document::getByPath($this->_getParam("page_url_" . $i))) {
                     $pageUrl = $this->getRequest()->getScheme() . "://" . Pimcore_Tool::getHostname() . $variantDoc->getFullPath();
                     // add properties to variant page
                     $variantDoc = $this->clearProperties($variantDoc);
                     $variantDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
                     $variantDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
                     $variantDoc->save();
                 } else {
                     Logger::warn("Added a invalid URL to A/B test.");
                     exit;
                 }
             }
             /*if($this->_getParam("page_version_".$i)) {
                   $pageUrl = "http://" . Pimcore_Tool::getHostname() . $sourceDoc->getFullPath() . "?v=" . $this->_getParam("page_version_".$i);
               }
               */
             if ($pageUrl) {
                 try {
                     $entryResult = $gdata->insertEntry("\r\n                        <entry xmlns='http://www.w3.org/2005/Atom'\r\n                               xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'\r\n                               xmlns:app='http://www.w3.org/2007/app'\r\n                               xmlns:gd='http://schemas.google.com/g/2005'>\r\n                        <title>" . $this->_getParam("page_name_" . $i) . "</title>\r\n                        <content>" . $pageUrl . "</content>\r\n                        </entry>\r\n                    ", "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"] . "/abpagevariations");
                 } catch (Exception $e) {
                     Logger::err($e);
                 }
             }
         } else {
             break;
         }
     }
     // @todo START EXPERIMENT HERE
     //$entryResult = $gdata->getEntry("https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
     //$gdata->updateEntry($entryResult->getXml(),"https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
     /*$gdata->updateEntry("
           <entry xmlns='http://www.w3.org/2005/Atom'
                  xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
                  xmlns:app='http://www.w3.org/2007/app'
                  xmlns:gd='http://schemas.google.com/g/2005'>
           <gwo:status>Running</gwo:status>
           </entry>
       ","https://www.google.com/analytics/feeds/websiteoptimizer/experiments/" . $data["experimentId"]);
       */
     // source-page
     $sourceDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
     $sourceDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
     $sourceDoc->setProperty("google_website_optimizer_original_page", "bool", true);
     $sourceDoc->save();
     // conversion-page
     $goalDoc->setProperty("google_website_optimizer_test_id", "text", $testId);
     $goalDoc->setProperty("google_website_optimizer_track_id", "text", $trackingId);
     $goalDoc->setProperty("google_website_optimizer_conversion_page", "bool", true);
     $goalDoc->save();
     // clear output cache
     Pimcore_Model_Cache::clearTag("output");
     Pimcore_Model_Cache::clearTag("properties");
     $this->_helper->json(array("success" => true));
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:89,代码来源:WebsiteoptimizerController.php


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