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


PHP Requirements::include_in_response方法代码示例

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


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

示例1: output

    /**
     * Send this HTTPReponse to the browser
     */
    public function output()
    {
        // Attach appropriate X-Include-JavaScript and X-Include-CSS headers
        if (Director::is_ajax()) {
            Requirements::include_in_response($this);
        }
        if (in_array($this->statusCode, self::$redirect_codes) && headers_sent($file, $line)) {
            $url = Director::absoluteURL($this->headers['Location'], true);
            $urlATT = Convert::raw2htmlatt($url);
            $urlJS = Convert::raw2js($url);
            $title = Director::isDev() ? "{$urlATT}... (output started on {$file}, line {$line})" : "{$urlATT}...";
            echo <<<EOT
<p>Redirecting to <a href="{$urlATT}" title="Click this link if your browser does not redirect you">{$title}</a></p>
<meta http-equiv="refresh" content="1; url={$urlATT}" />
<script type="text/javascript">setTimeout(function(){
\twindow.location.href = "{$urlJS}";
}, 50);</script>";
EOT;
        } else {
            $line = $file = null;
            if (!headers_sent($file, $line)) {
                header($_SERVER['SERVER_PROTOCOL'] . " {$this->statusCode} " . $this->getStatusDescription());
                foreach ($this->headers as $header => $value) {
                    header("{$header}: {$value}", true, $this->statusCode);
                }
            } else {
                // It's critical that these status codes are sent; we need to report a failure if not.
                if ($this->statusCode >= 300) {
                    user_error("Couldn't set response type to {$this->statusCode} because " . "of output on line {$line} of {$file}", E_USER_WARNING);
                }
            }
            // Only show error pages or generic "friendly" errors if the status code signifies
            // an error, and the response doesn't have any body yet that might contain
            // a more specific error description.
            if (Director::isLive() && $this->isError() && !$this->body) {
                Debug::friendlyError($this->statusCode, $this->getStatusDescription());
            } else {
                echo $this->body;
            }
        }
    }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:44,代码来源:HTTPResponse.php

示例2: output

 /**
  * Send this HTTPReponse to the browser
  */
 function output()
 {
     // Attach appropriate X-Include-JavaScript and X-Include-CSS headers
     if (Director::is_ajax()) {
         Requirements::include_in_response($this);
     }
     if (in_array($this->statusCode, self::$redirect_codes) && headers_sent($file, $line)) {
         $url = $this->headers['Location'];
         echo "<p>Redirecting to <a href=\"{$url}\" title=\"Please click this link if your browser does not redirect you\">{$url}... (output started on {$file}, line {$line})</a></p>\n\t\t\t<meta http-equiv=\"refresh\" content=\"1; url={$url}\" />\n\t\t\t<script type=\"text/javascript\">setTimeout('window.location.href = \"{$url}\"', 50);</script>";
     } else {
         if (!headers_sent()) {
             header($_SERVER['SERVER_PROTOCOL'] . " {$this->statusCode} " . $this->getStatusDescription());
             foreach ($this->headers as $header => $value) {
                 header("{$header}: {$value}");
             }
         }
         if (Director::isLive() && $this->isError()) {
             Debug::friendlyError($this->statusCode, $this->getStatusDescription());
         } else {
             echo $this->body;
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:26,代码来源:HTTPResponse.php

示例3: output

 /**
  * Send this HTTPReponse to the browser
  */
 public function output()
 {
     // Attach appropriate X-Include-JavaScript and X-Include-CSS headers
     if (Director::is_ajax()) {
         Requirements::include_in_response($this);
     }
     if (in_array($this->statusCode, self::$redirect_codes) && headers_sent($file, $line)) {
         $url = $this->headers['Location'];
         echo "<p>Redirecting to <a href=\"{$url}\" title=\"Click this link if your browser does not redirect you\">" . "{$url}... (output started on {$file}, line {$line})</a></p>\n\t\t\t<meta http-equiv=\"refresh\" content=\"1; url={$url}\" />\n\t\t\t<script type=\"text/javascript\">setTimeout('window.location.href = \"{$url}\"', 50);</script>";
     } else {
         if (!headers_sent()) {
             header($_SERVER['SERVER_PROTOCOL'] . " {$this->statusCode} " . $this->getStatusDescription());
             foreach ($this->headers as $header => $value) {
                 header("{$header}: {$value}", true, $this->statusCode);
             }
         }
         // Only show error pages or generic "friendly" errors if the status code signifies
         // an error, and the response doesn't have any body yet that might contain
         // a more specific error description.
         if (Director::isLive() && $this->isError() && !$this->body) {
             Debug::friendlyError($this->statusCode, $this->getStatusDescription());
         } else {
             echo $this->body;
         }
     }
 }
开发者ID:normann,项目名称:sapphire,代码行数:29,代码来源:HTTPResponse.php


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