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


PHP AjaxResponse::checkLastModified方法代码示例

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


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

示例1: ajax

 /**
  * Ajax call. This is called by efCategoryTreeAjaxWrapper, which is used to
  * load CategoryTreeFunctions.php on demand.
  */
 function ajax($category, $mode)
 {
     global $wgDBname;
     $title = self::makeTitle($category);
     if (!$title) {
         return false;
     }
     #TODO: error message?
     $this->mIsAjaxRequest = true;
     # Retrieve page_touched for the category
     $dbkey = $title->getDBkey();
     $dbr =& wfGetDB(DB_SLAVE);
     $touched = $dbr->selectField('page', 'page_touched', array('page_namespace' => NS_CATEGORY, 'page_title' => $dbkey), __METHOD__);
     $mckey = "{$wgDBname}:categorytree({$mode}):{$dbkey}";
     //FIXME: would need to add depth parameter.
     $response = new AjaxResponse();
     if ($response->checkLastModified($touched)) {
         return $response;
     }
     if ($response->loadFromMemcached($mckey, $touched)) {
         return $response;
     }
     $html = $this->renderChildren($title, $mode);
     //FIXME: would need to pass depth parameter.
     if ($html == '') {
         $html = ' ';
     }
     #HACK: Safari doesn't like empty responses.
     #see Bug 7219 and http://bugzilla.opendarwin.org/show_bug.cgi?id=10716
     $response->addText($html);
     $response->storeInMemcached($mckey, 86400);
     return $response;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:37,代码来源:CategoryTreeFunctions.php

示例2: efAjaxTest

/**
 * Entry point for Ajax, registered in $wgAjaxExportList.
 * This loads CategoryTreeFunctions.php and calls CategoryTree::ajax()
 */
function efAjaxTest($text, $usestring, $httpcache, $lastmod, $error)
{
    $text = htmlspecialchars($text) . "(" . wfTimestampNow() . ")";
    if ($usestring) {
        return $text;
    } else {
        $response = new AjaxResponse($text);
        if ($error) {
            throw new Exception($text);
        }
        if ($httpcache) {
            $response->setCacheDuration(24 * 60 * 60);
        }
        # cache for a day
        if ($lastmod) {
            $response->checkLastModified('19700101000001');
            # never modified
        }
        return $response;
    }
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:AjaxTest.php

示例3: ajax

 /**
  * Ajax call. This is called by efCategoryTreeAjaxWrapper, which is used to
  * load CategoryTreeFunctions.php on demand.
  * @param $category
  * @param $depth int
  * @return AjaxResponse|bool
  */
 function ajax($category, $depth = 1)
 {
     global $wgLang, $wgContLang, $wgRenderHashAppend;
     $title = self::makeTitle($category);
     if (!$title) {
         return false;
         # TODO: error message?
     }
     # Retrieve page_touched for the category
     $dbkey = $title->getDBkey();
     $dbr = wfGetDB(DB_SLAVE);
     $touched = $dbr->selectField('page', 'page_touched', array('page_namespace' => NS_CATEGORY, 'page_title' => $dbkey), __METHOD__);
     $mckey = wfMemcKey("categorytree(" . $this->getOptionsAsCacheKey($depth) . ")", $dbkey, $wgLang->getCode(), $wgContLang->getExtraHashOptions(), $wgRenderHashAppend);
     $response = new AjaxResponse();
     if ($response->checkLastModified($touched)) {
         return $response;
     }
     if ($response->loadFromMemcached($mckey, $touched)) {
         return $response;
     }
     $html = $this->renderChildren($title, $depth);
     if ($html == '') {
         # HACK: Safari doesn't like empty responses.
         # see Bug 7219 and http://bugzilla.opendarwin.org/show_bug.cgi?id=10716
         $html = ' ';
     }
     $response->addText($html);
     $response->storeInMemcached($mckey, 86400);
     return $response;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:37,代码来源:CategoryTreeFunctions.php

示例4: AjaxResponse

 /**
  Returns colored markup.
 	 
  @return colored markup.
 */
 static function ajax_getColoredText($page_title_raw, $page_id_raw = NULL, $rev_id_raw = NULL)
 {
     global $wgParser, $wgWikiTrustContentServerURL, $wgWikiTrustApiURL, $wgUser;
     global $wgMemc;
     $response = new AjaxResponse("");
     $request_headers = apache_request_headers();
     // Try to use gzip for the content, if possible.
     // Ian - This isn't working with redherring, for some reason.
     if (strstr($request_headers["Accept-Encoding"], "gzip")) {
         //  $response->setContentType("gzip");
     }
     // Can set this to use client side caching, but this can also cause
     // problems.
     // Mark that the content can be cached
     // $response->setCacheDuration(self::TRUST_CACHE_VALID);
     if (!$page_id_raw || !$rev_id_raw) {
         $data = array('action' => 'query', 'prop' => 'revisions', 'titles' => $page_title_raw, 'rvlimit' => '1', 'rvprop' => 'ids', 'format' => 'json');
         $page_info_raw = file_get_contents($wgWikiTrustApiURL . http_build_query($data));
         $page_json = json_decode($page_info_raw, true);
         $pages_arr = array_keys($page_json["query"]["pages"]);
         // Now, parse out only what we need
         if (!$page_id_raw) {
             $page_id_raw = $pages_arr[0];
         }
         if (!$rev_id_raw) {
             $rev_id_raw = $page_json["query"]["pages"][$page_id_raw]["revisions"][0]["revid"];
         }
     }
     $dbr =& wfGetDB(DB_SLAVE);
     $page_id = $dbr->strencode($page_id_raw, $dbr);
     $rev_id = $dbr->strencode($rev_id_raw, $dbr);
     $page_title = $dbr->strencode($page_title_raw, $dbr);
     // Check the If-Modified-Since header.
     // If the timestamp of the requested revision is earlier than the IMS
     // header, return 304 and do nothing further.
     $rev_ts = '19700101000000';
     $res = $dbr->select(self::util_getDbTable('wikitrust_colored_markup'), array('revision_createdon'), array('revision_id' => $rev_id), array());
     if ($res && $dbr->numRows($res) > 0) {
         $row = $dbr->fetchRow($res);
         $rev_ts = $row['revision_createdon'];
         if (!$rev_ts) {
             $rev_ts = '19700101000000';
         }
     }
     $dbr->freeResult($res);
     if ($response->checkLastModified($rev_ts)) {
         return $response;
     }
     // See if we have a cached version of the colored text, or if
     // we need to generate new text.
     $memcKey = wfMemcKey('revisiontext', 'revid', $rev_id);
     $cached_text = $wgMemc->get($memcKey);
     if ($cached_text) {
         $response->addText($cached_text);
         return $response;
     }
     // Since we are here, we need to get the colored HTML the hard way.
     $ctx = stream_context_create(array('http' => array('timeout' => self::TRUST_TIMEOUT)));
     // TODO: Should we do doing this via HTTPS?  Or POST?
     // TODO: in RemoteMode, shouldn't we use local database?
     $colored_raw = file_get_contents($wgWikiTrustContentServerURL . "rev=" . urlencode($rev_id) . "&page=" . urlencode($page_id) . "&page_title=" . urlencode($page_title) . "&time=" . urlencode(wfTimestampNow()) . "&user=0", 0, $ctx);
     if ($colored_raw && $colored_raw != self::NOT_FOUND_TEXT_TOKEN) {
         // Inflate. Pick off the first 10 bytes for python-php conversion.
         $colored_raw = gzinflate(substr($colored_raw, 10));
         // Pick off the median value first.
         $colored_data = explode(",", $colored_raw, 2);
         $colored_text = $colored_data[1];
         if (preg_match("/^[+-]?(([0-9]+)|([0-9]*\\.[0-9]+|[0-9]+\\.[0-9]*)|\n\t\t\t    (([0-9]+|([0-9]*\\.[0-9]+|[0-9]+\\.[0-9]*))[eE][+-]?[0-9]+))\$/", $colored_data[0])) {
             self::$median = $colored_data[0];
             if ($colored_data[0] == 0) {
                 self::$median = self::TRUST_DEFAULT_MEDIAN;
             }
         }
         // First, make sure that there are not any instances of our tokens in the colored_text
         $colored_text = str_replace(self::TRUST_OPEN_TOKEN, "", $colored_text);
         $colored_text = str_replace(self::TRUST_CLOSE_TOKEN, "", $colored_text);
         $colored_text = preg_replace("/'/", "'", $colored_text, -1);
         $colored_text = preg_replace("/&/", "&", $colored_text, -1);
         $colored_text = preg_replace("/</", self::TRUST_OPEN_TOKEN, $colored_text, -1);
         $colored_text = preg_replace("/>/", self::TRUST_CLOSE_TOKEN, $colored_text, -1);
         $title = Title::newFromText($page_title);
         $options = ParserOptions::newFromUser($wgUser);
         $parsed = $wgParser->parse($colored_text, $title, $options);
         $text = $parsed->getText();
         $count = 0;
         // Update the trust tags
         $text = preg_replace_callback("/\\{\\{#t:(\\d+),(\\d+),(.*?)\\}\\}/", "WikiTrust::color_handleParserRe", $text, -1, $count);
         // Update open, close, images, and links.
         $text = preg_replace('/' . self::TRUST_OPEN_TOKEN . '/', "<", $text, -1, $count);
         // Regex broken for some pages.
         // Removing for now.
         /**
               $text = preg_replace('/<a href="(.*?)(File):(.*?)" (.*?)>/'
         			   , self::TRUST_OPEN_TOKEN, $text, -1, $count);
               $text = preg_replace('/<a href="(.*?)(Image):(.*?)" (.*?)>/'
//.........这里部分代码省略.........
开发者ID:xzhao314,项目名称:WikiTrust,代码行数:101,代码来源:RemoteMode.php

示例5: wfAnswersGetEditPointsAjax

/**
 * @author Maciej Błaszkowski <marooned at wikia-inc.com>
 */
function wfAnswersGetEditPointsAjax()
{
    global $wgRequest, $wgSquidMaxage;
    $userId = intval($wgRequest->getVal('userId'));
    $points = AttributionCache::getInstance()->getUserEditPoints($userId);
    $timestamp = AttributionCache::getInstance()->getUserLastModifiedFromCache($userId);
    $timestamp = !empty($timestamp) ? $timestamp : wfTimestampNow();
    $data = array('points' => $points, 'timestamp' => wfTimestampNow());
    $json = json_encode($data);
    $response = new AjaxResponse($json);
    $response->setContentType('application/json; charset=utf-8');
    $response->checkLastModified(strtotime($timestamp));
    $response->setCacheDuration($wgSquidMaxage);
    return $response;
}
开发者ID:yusufchang,项目名称:app,代码行数:18,代码来源:Answers.php


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