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


PHP XenForo_Application::gzipContentIfSupported方法代码示例

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


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

示例1: renderJson

 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $maxid = Dark_TaigaChat_Helper_Global::processMessagesForView($this->_params, $this);
     $template = $this->createTemplateObject($this->_templateName, $this->_params);
     $template->setParams($this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $rendered = $template->render();
     $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
     $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
     $params = array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid, "motd" => $this->_params['taigachat']['motd'], "numInChat" => $this->_params['taigachat']['numInChat']);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $params += array("_visitor_conversationsUnread" => "IGNORE", "_visitor_alertsUnread" => "IGNORE");
     }
     //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered);
     $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput($params, empty($this->_params['taigachat']['publichtml']));
     if (empty($this->_params['taigachat']['publichtml'])) {
         $extraHeaders = XenForo_Application::gzipContentIfSupported($derp);
         foreach ($extraHeaders as $extraHeader) {
             header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
         }
     }
     return $derp;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:27,代码来源:List.php

示例2: renderJson

 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $maxUpdate = Dark_TaigaChat_Helper_Global::processMessagesForView($this->_params, $this);
     $messages = $this->_params['taigachat']['messages'];
     if ($options->dark_taigachat_reverse) {
         $messages = array_reverse($messages);
     }
     $twelveHour = false;
     $template = $this->createTemplateObject("dark_taigachat_robots");
     if (!empty($this->_params['taigachat']['publichtml'])) {
         /** @var XenForo_Model_Language */
         $languageModel = XenForo_Model::create('XenForo_Model_Language');
         $language = $languageModel->getLanguageById(XenForo_Phrase::getLanguageId());
         if ($language['time_format'] == 'g:i A') {
             $twelveHour = true;
         }
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $robots = $template->render();
     $outputMessages = array();
     $previous = null;
     $template = $this->createTemplateObject("dark_taigachat_message", $this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     foreach ($messages as &$message) {
         $template->setParam("message", $message);
         $rendered = $template->render();
         $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
         $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
         $outputMessages[] = array("id" => $message['id'], "previous" => empty($previous) ? 0 : $previous['id'], "last_update" => $message['last_update'], "html" => $rendered);
         $previous = $message;
     }
     $template = $this->createTemplateObject("dark_taigachat_online_users", $this->_params);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $template->setLanguageId(XenForo_Phrase::getLanguageId());
         $template->setStyleId($options->defaultStyleId);
     }
     $outputOnlineUsers = $template->render();
     $params = array("robots" => $robots, "messages" => $outputMessages, "messageIds" => $this->_params['taigachat']['messageIds'], "onlineUsers" => $outputOnlineUsers, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxUpdate, "motd" => $this->_params['taigachat']['motd'], "numInChat" => $this->_params['taigachat']['numInChat'], "twelveHour" => $twelveHour);
     if (!empty($this->_params['taigachat']['publichtml'])) {
         $params += array("_visitor_conversationsUnread" => "IGNORE", "_visitor_alertsUnread" => "IGNORE");
     }
     $jsonOutput = XenForo_ViewRenderer_Json::jsonEncodeForOutput($params, empty($this->_params['taigachat']['publichtml']));
     if (empty($this->_params['taigachat']['publichtml'])) {
         $extraHeaders = XenForo_Application::gzipContentIfSupported($jsonOutput);
         foreach ($extraHeaders as $extraHeader) {
             header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
         }
     }
     return $jsonOutput;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:55,代码来源:List.php

示例3: renderJson

 public function renderJson()
 {
     $options = XenForo_Application::get('options');
     $formatter = XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_Tenori', array('view' => $this));
     switch ($options->dark_taigachat_bbcode) {
         case 'Full':
             $formatter->displayableTags = true;
             break;
         case 'Basic':
         default:
             $formatter->displayableTags = array('img', 'url', 'email', 'b', 'u', 'i', 's', 'color');
             break;
         case 'None':
             $formatter->displayableTags = array('url', 'email');
             break;
     }
     $formatter->getTagsAgain();
     $parser = new XenForo_BbCode_Parser($formatter);
     if ($options->dark_taigachat_imagemode == 'Link') {
         foreach ($this->_params['taigachat']['messages'] as &$message) {
             $message['message'] = str_ireplace(array("[img]", "[/img]"), array("[url]", "[/url]"), $message['message']);
         }
     }
     $maxid = $this->_params['taigachat']['lastrefresh'];
     foreach ($this->_params['taigachat']['messages'] as &$message) {
         if ($options->dark_taigachat_bbcode == 'Full') {
             $message['message'] = XenForo_Helper_String::autoLinkBbCode($message['message']);
         } else {
             // We don't want to parse youtube etc. urls if [media] is disabled
             $autoLinkParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Dark_TaigaChat_BbCode_Formatter_BbCode_AutoLink', false));
             $message['message'] = $autoLinkParser->render($message['message']);
         }
         if ($message['id'] > $maxid) {
             $maxid = $message['id'];
         }
     }
     XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['taigachat']['messages'], $parser);
     if ($options->dark_taigachat_direction) {
         $this->_params['taigachat']['messages'] = array_reverse($this->_params['taigachat']['messages']);
     }
     $template = $this->createTemplateObject($this->_templateName, $this->_params);
     $template->setParams($this->_params);
     $rendered = $template->render();
     $rendered = preg_replace('/\\s+<\\/(.*?)>\\s+</si', ' </$1> <', $rendered);
     $rendered = preg_replace('/\\s+<(.*?)([ >])/si', ' <$1$2', $rendered);
     //$rendered = str_replace(array("\r", "\n", "\t"), "", $rendered);
     $derp = XenForo_ViewRenderer_Json::jsonEncodeForOutput(array("templateHtml" => $rendered, "reverse" => $options->dark_taigachat_direction, "lastrefresh" => $maxid));
     $extraHeaders = XenForo_Application::gzipContentIfSupported($derp);
     foreach ($extraHeaders as $extraHeader) {
         header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
     }
     return $derp;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:53,代码来源:List.php

示例4: run

 /**
  * Runs the request, handling from routing straight through to response output.
  * Primary method to be used by the external API.
  *
  * @return string|null Returns a string if {@link $_sendResponse} is false
  */
 public function run()
 {
     ob_start();
     XenForo_Application::set('fc', $this);
     $this->setup();
     $this->setRequestPaths();
     $showDebugOutput = $this->showDebugOutput();
     $this->_dependencies->preLoadData();
     XenForo_CodeEvent::fire('front_controller_pre_route', array($this));
     $routeMatch = $this->route();
     XenForo_CodeEvent::fire('front_controller_pre_dispatch', array($this, &$routeMatch));
     $controllerResponse = $this->dispatch($routeMatch);
     if (!$controllerResponse) {
         XenForo_Error::noControllerResponse($routeMatch, $this->_request);
         exit;
     }
     $viewRenderer = $this->_getViewRenderer($routeMatch->getResponseType());
     if (!$viewRenderer) {
         // note: should only happen if there's an error getting the default renderer, which should never happen :)
         XenForo_Error::noViewRenderer($this->_request);
         exit;
     }
     $containerParams = array('majorSection' => $routeMatch->getMajorSection(), 'minorSection' => $routeMatch->getMinorSection());
     XenForo_CodeEvent::fire('front_controller_pre_view', array($this, &$controllerResponse, &$viewRenderer, &$containerParams));
     $content = $this->renderView($controllerResponse, $viewRenderer, $containerParams);
     if ($showDebugOutput) {
         $content = $this->renderDebugOutput($content);
     }
     $bufferedContents = ob_get_contents();
     ob_end_clean();
     if ($bufferedContents !== '' && is_string($content)) {
         if (preg_match('#<body[^>]*>#sU', $content, $match)) {
             $content = str_replace($match[0], $match[0] . $bufferedContents, $content);
         } else {
             $content = $bufferedContents . $content;
         }
     }
     XenForo_CodeEvent::fire('front_controller_post_view', array($this, &$content));
     if ($this->_sendResponse) {
         $headers = $this->_response->getHeaders();
         $isText = false;
         foreach ($headers as $header) {
             if ($header['name'] == 'Content-Type') {
                 if (strpos($header['value'], 'text/') === 0) {
                     $isText = true;
                 }
                 break;
             }
         }
         if ($isText && is_string($content) && $content) {
             $extraHeaders = XenForo_Application::gzipContentIfSupported($content);
             foreach ($extraHeaders as $extraHeader) {
                 $this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]);
             }
         }
         if (is_string($content) && $content && !ob_get_level() && XenForo_Application::get('config')->enableContentLength) {
             if ($this->_response->getHttpResponseCode() >= 400 && strpos($this->_request->getServer('HTTP_USER_AGENT', ''), 'IEMobile') !== false) {
                 // Windows mobile bug - 400+ errors cause the standard browser error
                 // to be output if a content length is sent. ...Err, what?
             } else {
                 $this->_response->setHeader('Content-Length', strlen($content), true);
             }
         }
         $this->_response->sendHeaders();
         if ($content instanceof XenForo_FileOutput) {
             $content->output();
         } else {
             echo $content;
         }
     } else {
         return $content;
     }
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:79,代码来源:FrontController.php

示例5: run

 /**
  * Runs the request, handling from routing straight through to response output.
  * Primary method to be used by the external API.
  *
  * @return string|null Returns a string if {@link $_sendResponse} is false
  */
 public function run($innerContent = "", $newParams = array())
 {
     ob_start();
     $this->setup();
     $this->setRequestPaths();
     $showDebugOutput = $this->showDebugOutput();
     $this->_dependencies->preLoadData();
     XenForo_CodeEvent::fire('front_controller_pre_route', array($this));
     $routeMatch = $this->route();
     XenForo_CodeEvent::fire('front_controller_pre_dispatch', array($this, &$routeMatch));
     $controllerResponse = $this->dispatch($routeMatch);
     if (!$controllerResponse) {
         XenForo_Error::noControllerResponse($routeMatch, $this->_request);
         exit;
     }
     $viewRenderer = $this->_getViewRenderer($routeMatch->getResponseType());
     if (!$viewRenderer) {
         // note: should only happen if there's an error getting the default renderer, which should never happen :)
         XenForo_Error::noViewRenderer($this->_request);
         exit;
     }
     $containerParams = array('majorSection' => $routeMatch->getMajorSection(), 'minorSection' => $routeMatch->getMinorSection());
     XenForo_CodeEvent::fire('front_controller_pre_view', array($this, &$controllerResponse, &$viewRenderer, &$containerParams));
     $content = $this->renderView($controllerResponse, $viewRenderer, $containerParams, $innerContent, $newParams);
     if ($showDebugOutput) {
         $content = $this->renderDebugOutput($content);
     }
     $bufferedContents = ob_get_contents();
     ob_end_clean();
     if ($bufferedContents !== '') {
         $content = $bufferedContents . $content;
     }
     XenForo_CodeEvent::fire('front_controller_post_view', array($this, &$content));
     if ($this->_sendResponse) {
         $headers = $this->_response->getHeaders();
         $isText = false;
         foreach ($headers as $header) {
             if ($header['name'] == 'Content-Type') {
                 if (strpos($header['value'], 'text/') === 0) {
                     $isText = true;
                 }
                 break;
             }
         }
         if ($isText && is_string($content) && $content) {
             $extraHeaders = XenForo_Application::gzipContentIfSupported($content);
             foreach ($extraHeaders as $extraHeader) {
                 $this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]);
             }
         }
         if (is_string($content) && $content && !ob_get_level() && XenForo_Application::get('config')->enableContentLength) {
             $this->_response->setHeader('Content-Length', strlen($content), true);
         }
         $this->_response->sendHeaders();
         if ($content instanceof XenForo_FileOutput) {
             $content->output();
         } else {
             //$uncompressed = gzuncompress($content);
             //echo $uncompressed;
             echo $content;
         }
     } else {
         return $content;
     }
 }
开发者ID:Troposphir,项目名称:troposphir,代码行数:71,代码来源:XenForo_FrontC.php

示例6: _outputLinkRedirect

 /**
  * Intercept a request for a link redirect
  *
  * @param string|bool $error If non-false, an error that occurred when validating the request
  */
 protected function _outputLinkRedirect($error)
 {
     if ($error === 'invalid_url') {
         header('Content-Type: text/html; utf-8', true, 500);
         die('Invalid URL');
     }
     if (empty(XenForo_Application::getOptions()->imageLinkProxy['links'])) {
         $error = 'disabled';
     }
     if (!$error) {
         /* @var $proxyModel XenForo_Model_LinkProxy */
         $proxyModel = XenForo_Model::create('XenForo_Model_LinkProxy');
         $proxyModel->logVisit($this->_url);
         header('Location: ' . $this->_url, true, 302);
         exit;
     }
     $request = new Zend_Controller_Request_Http();
     XenForo_Session::startPublicSession($request);
     $this->_dependencies->preRenderView();
     if (!preg_match('#^https?://#i', $this->_url)) {
         throw new Exception('Unsafe proxy URL: ' . $this->_url);
     }
     $printable = urldecode($this->_url);
     if (!preg_match('/./u', $printable)) {
         $printable = $this->_url;
     }
     $renderer = new XenForo_ViewRenderer_HtmlPublic($this->_dependencies, $this->_response, $request);
     $contents = $renderer->createTemplateObject('link_redirect', array('url' => $this->_url, 'printable' => $printable, 'parts' => parse_url($this->_url)));
     $containerParams = $this->_dependencies->getEffectiveContainerParams(array(), $request);
     $output = $renderer->renderContainer($contents, $containerParams);
     $extraHeaders = XenForo_Application::gzipContentIfSupported($output);
     foreach ($extraHeaders as $extraHeader) {
         $this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]);
     }
     $this->_response->setHeader('X-Proxy-Error', $error);
     $this->_response->sendHeaders();
     echo $output;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:43,代码来源:ProxyOutput.php

示例7: displayCss

 /**
  * Outputs the specified CSS. Also outputs the necessary HTTP headers.
  *
  * @param string $css
  */
 public function displayCss($css)
 {
     header('Content-type: text/css; charset=utf-8');
     header('Expires: Wed, 01 Jan 2020 00:00:00 GMT');
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->_styleModifiedDate) . ' GMT');
     header('Cache-Control: public');
     $extraHeaders = XenForo_Application::gzipContentIfSupported($css);
     foreach ($extraHeaders as $extraHeader) {
         header("{$extraHeader['0']}: {$extraHeader['1']}", $extraHeader[2]);
     }
     if (is_string($css) && $css && !ob_get_level() && XenForo_Application::get('config')->enableContentLength) {
         header('Content-Length: ' . strlen($css));
     }
     echo $css;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:20,代码来源:CssOutput.php


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