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


PHP CacheManager::isFileCached方法代码示例

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


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

示例1: getHTML

    function getHTML()
    {
        global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgOutputEncoding;
        global $wgSitename, $wgServer, $wgMessageCache, $wgLogo;
        # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky.
        # Hard coding strings instead.
        $noconnect = "<p><strong>Sorry! This site is experiencing technical difficulties.</strong></p><p>Try waiting a few minutes and reloading.</p><p><small>(Can't contact the database server: \$1)</small></p>";
        $mainpage = 'Main Page';
        $searchdisabled = <<<EOT
<p style="margin: 1.5em 2em 1em">{$wgSitename} search is disabled for performance reasons. You can search via Google in the meantime.
<span style="font-size: 89%; display: block; margin-left: .2em">Note that their indexes of {$wgSitename} content may be out of date.</span></p>',
EOT;
        $googlesearch = "\n<!-- SiteSearch Google -->\n<FORM method=GET action=\"http://www.google.com/search\">\n<TABLE bgcolor=\"#FFFFFF\"><tr><td>\n<A HREF=\"http://www.google.com/\">\n<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\"\nborder=\"0\" ALT=\"Google\"></A>\n</td>\n<td>\n<INPUT TYPE=text name=q size=31 maxlength=255 value=\"\$1\">\n<INPUT type=submit name=btnG VALUE=\"Google Search\">\n<font size=-1>\n<input type=hidden name=domains value=\"{$wgServer}\"><br /><input type=radio name=sitesearch value=\"\"> WWW <input type=radio name=sitesearch value=\"{$wgServer}\" checked> {$wgServer} <br />\n<input type='hidden' name='ie' value='\$2'>\n<input type='hidden' name='oe' value='\$2'>\n</font>\n</td></tr></TABLE>\n</FORM>\n<!-- SiteSearch Google -->";
        $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
        # No database access
        if (is_object($wgMessageCache)) {
            $wgMessageCache->disable();
        }
        if (trim($this->error) == '') {
            $this->error = $this->db->getProperty('mServer');
        }
        $text = str_replace('$1', $this->error, $noconnect);
        $text .= wfGetSiteNotice();
        if ($wgUseFileCache) {
            if ($wgTitle) {
                $t =& $wgTitle;
            } else {
                if ($title) {
                    $t = Title::newFromURL($title);
                } elseif (@$_REQUEST['search']) {
                    $search = $_REQUEST['search'];
                    return $searchdisabled . str_replace(array('$1', '$2'), array(htmlspecialchars($search), $wgInputEncoding), $googlesearch);
                } else {
                    $t = Title::newFromText($mainpage);
                }
            }
            $cache = new CacheManager($t);
            if ($cache->isFileCached()) {
                $msg = '<p style="color: red"><b>' . $msg . "<br />\n" . $cachederror . "</b></p>\n";
                $tag = '<div id="article">';
                $text = str_replace($tag, $tag . $msg, $cache->fetchPageText());
            }
        }
        return $text;
    }
开发者ID:puring0815,项目名称:OpenKore,代码行数:45,代码来源:Database.php

示例2: wfEmergencyAbort

/**
 * Standard fail function, called by default when a connection cannot be
 * established.
 * Displays the file cache if possible
 */
function wfEmergencyAbort(&$conn, $error)
{
    global $wgTitle, $wgUseFileCache, $title, $wgInputEncoding, $wgOutputEncoding;
    global $wgSitename, $wgServer, $wgMessageCache, $wgLogo;
    # I give up, Brion is right. Getting the message cache to work when there is no DB is tricky.
    # Hard coding strings instead.
    $noconnect = "<h1><img src='{$wgLogo}' style='float:left;margin-right:1em' alt=''>{$wgSitename} has a problem</h1><p><strong>Sorry! This site is experiencing technical difficulties.</strong></p><p>Try waiting a few minutes and reloading.</p><p><small>(Can't contact the database server: \$1)</small></p>";
    $mainpage = 'Main Page';
    $searchdisabled = <<<EOT
<p style="margin: 1.5em 2em 1em">{$wgSitename} search is disabled for performance reasons. You can search via Google in the meantime.
<span style="font-size: 89%; display: block; margin-left: .2em">Note that their indexes of {$wgSitename} content may be out of date.</span></p>',
EOT;
    $googlesearch = "\n<!-- SiteSearch Google -->\n<FORM method=GET action=\"http://www.google.com/search\">\n<TABLE bgcolor=\"#FFFFFF\"><tr><td>\n<A HREF=\"http://www.google.com/\">\n<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\"\nborder=\"0\" ALT=\"Google\"></A>\n</td>\n<td>\n<INPUT TYPE=text name=q size=31 maxlength=255 value=\"\$1\">\n<INPUT type=submit name=btnG VALUE=\"Google Search\">\n<font size=-1>\n<input type=hidden name=domains value=\"{$wgServer}\"><br /><input type=radio name=sitesearch value=\"\"> WWW <input type=radio name=sitesearch value=\"{$wgServer}\" checked> {$wgServer} <br />\n<input type='hidden' name='ie' value='\$2'>\n<input type='hidden' name='oe' value='\$2'>\n</font>\n</td></tr></TABLE>\n</FORM>\n<!-- SiteSearch Google -->";
    $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
    if (!headers_sent()) {
        header('HTTP/1.0 500 Internal Server Error');
        header('Content-type: text/html; charset=' . $wgOutputEncoding);
        /* Don't cache error pages!  They cause no end of trouble... */
        header('Cache-control: none');
        header('Pragma: nocache');
    }
    # No database access
    if (is_object($wgMessageCache)) {
        $wgMessageCache->disable();
    }
    $msg = wfGetSiteNotice();
    if ($msg == '') {
        $msg = str_replace('$1', htmlspecialchars($error), $noconnect);
    }
    $text = $msg;
    if ($wgUseFileCache) {
        if ($wgTitle) {
            $t =& $wgTitle;
        } else {
            if ($title) {
                $t = Title::newFromURL($title);
            } elseif (@$_REQUEST['search']) {
                $search = $_REQUEST['search'];
                echo $searchdisabled;
                echo str_replace(array('$1', '$2'), array(htmlspecialchars($search), $wgInputEncoding), $googlesearch);
                wfErrorExit();
            } else {
                $t = Title::newFromText($mainpage);
            }
        }
        $cache = new CacheManager($t);
        if ($cache->isFileCached()) {
            $msg = '<p style="color: red"><b>' . $msg . "<br />\n" . $cachederror . "</b></p>\n";
            $tag = '<div id="article">';
            $text = str_replace($tag, $tag . $msg, $cache->fetchPageText());
        }
    }
    echo $text;
    wfErrorExit();
}
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:60,代码来源:Database.php


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