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


PHP Session::getOption方法代码示例

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


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

示例1: outputBufferEnd

 /**
  * if this method is called in self::shutdown() it forces the browser to close the connection an allows the
  * shutdown-function to run in the background
  * @static
  * @return string
  */
 public static function outputBufferEnd($data)
 {
     $output = null;
     $contentEncoding = null;
     if (headers_sent()) {
         return $data;
     }
     // cleanup admin session Set-Cookie headers if needed
     // a detailed description why this is necessary can be found in the doc-block of \Pimcore\Tool\Session::$sessionCookieCleanupNeeded
     if (Tool\Session::isSessionCookieCleanupNeeded()) {
         $headers = headers_list();
         $headers = array_reverse($headers);
         foreach ($headers as $header) {
             if (strpos($header, Tool\Session::getOption("name")) !== false) {
                 header($header, true);
                 // setting the header again with 2nd arg = true, overrides all duplicates
                 break;
             }
         }
     }
     // only send this headers in the shutdown-function, so that it is also possible to get the contents of this buffer earlier without sending headers
     if (self::$inShutdown) {
         // force closing the connection at the client, this enables to do certain tasks (writing the cache) in the "background"
         header("Connection: close\r\n");
         // check for supported content-encodings
         if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) {
             $contentEncoding = "gzip";
         }
         if (!empty($data) && $contentEncoding) {
             ignore_user_abort(true);
             // find the content-type of the response
             $front = \Zend_Controller_Front::getInstance();
             $a = $front->getResponse()->getHeaders();
             $b = array_merge(headers_list(), $front->getResponse()->getRawHeaders());
             $contentType = null;
             // first check headers in headers_list() because they overwrite all other headers => see SOAP controller
             foreach ($b as $header) {
                 if (stripos($header, "content-type") !== false) {
                     $parts = explode(":", $header);
                     if (strtolower(trim($parts[0])) == "content-type") {
                         $contentType = trim($parts[1]);
                         break;
                     }
                 }
             }
             if (!$contentType) {
                 foreach ($a as $header) {
                     if (strtolower(trim($header["name"])) == "content-type") {
                         $contentType = $header["value"];
                         break;
                     }
                 }
             }
             // prepare the response to be sent (gzip or not)
             // do not add text/xml or a wildcard for text/* here because this causes problems with the SOAP server
             $gzipContentTypes = array("@text/html@i", "@application/json@", "@text/javascript@", "@text/css@");
             $gzipIt = false;
             foreach ($gzipContentTypes as $type) {
                 if (@preg_match($type, $contentType)) {
                     $gzipIt = true;
                     break;
                 }
             }
             // gzip the contents and send connection close tthat the process can run in the background to finish
             // some tasks like writing the cache ...
             // using mb_strlen() because of PIMCORE-1509
             if ($gzipIt) {
                 $output = "‹" . substr(gzcompress($data, 2), 0, -4) . pack('V', crc32($data)) . pack('V', mb_strlen($data, "latin1"));
                 // (although all modern browsers don't need it anymore) to work properly with google adwords check & co.
                 header("Content-Encoding: {$contentEncoding}\r\n");
             }
         }
         // no gzip/deflate encoding
         if (!$output) {
             $output = $data;
         }
         if (strlen($output) > 0) {
             // check here if there is actually content, otherwise readfile() and similar functions are not working anymore
             header("Content-Length: " . mb_strlen($output, "latin1"));
         }
         header("X-Powered-By: pimcore", true);
     }
     // return the data unchanged
     return $output;
 }
开发者ID:pdaniel-frk,项目名称:pimcore,代码行数:91,代码来源:Pimcore.php

示例2: diffVersionsAction

 public function diffVersionsAction()
 {
     $versionFrom = Version::getById($this->getParam("from"));
     $docFrom = $versionFrom->loadData();
     $request = $this->getRequest();
     $sessionName = Tool\Session::getOption("name");
     $prefix = $request->getScheme() . "://" . $request->getHttpHost() . $docFrom->getFullPath() . "?pimcore_version=";
     $fromUrl = $prefix . $this->getParam("from") . "&" . $sessionName . "=" . $_COOKIE[$sessionName];
     $toUrl = $prefix . $this->getParam("to") . "&" . $sessionName . "=" . $_COOKIE[$sessionName];
     $fromFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     $toFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     $diffFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/version-diff-tmp-" . uniqid() . ".png";
     if (\Pimcore\Image\HtmlToImage::isSupported() && class_exists("Imagick")) {
         \Pimcore\Image\HtmlToImage::convert($fromUrl, $fromFile);
         \Pimcore\Image\HtmlToImage::convert($toUrl, $toFile);
         $image1 = new Imagick($fromFile);
         $image2 = new Imagick($toFile);
         if ($image1->getImageWidth() == $image2->getImageWidth() && $image1->getImageHeight() == $image2->getImageHeight()) {
             $result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
             $result[0]->setImageFormat("png");
             $result[0]->writeImage($diffFile);
             $result[0]->clear();
             $result[0]->destroy();
             $this->view->image = base64_encode(file_get_contents($diffFile));
             unlink($diffFile);
         } else {
             $this->view->image1 = base64_encode(file_get_contents($fromFile));
             $this->view->image2 = base64_encode(file_get_contents($toFile));
         }
         // cleanup
         $image1->clear();
         $image1->destroy();
         $image2->clear();
         $image2->destroy();
         unlink($fromFile);
         unlink($toFile);
     } else {
         $this->renderScript("document/diff-versions-unsupported.php");
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:40,代码来源:DocumentController.php


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