當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。