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


PHP LocalRepo::findFile方法代码示例

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


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

示例1: findFile

 /**
  * Search repositories for an image.
  * You can also use wfFindFile() to do this.
  *
  * @param $title Title|string Title object or string
  * @param $options array Associative array of options:
  *     time:           requested time for an archived image, or false for the
  *                     current version. An image object will be returned which was
  *                     created at the specified time.
  *
  *     ignoreRedirect: If true, do not follow file redirects
  *
  *     private:        If true, return restricted (deleted) files if the current
  *                     user is allowed to view them. Otherwise, such files will not
  *                     be found.
  *
  *     bypassCache:    If true, do not use the process-local cache of File objects
  * @return File object or false if it is not found
  */
 function findFile($title, $options = array())
 {
     if (!is_array($options)) {
         // MW 1.15 compat
         $options = array('time' => $options);
     }
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $title = File::normalizeTitle($title);
     if (!$title) {
         return false;
     }
     # Check the cache
     if (empty($options['ignoreRedirect']) && empty($options['private']) && empty($options['bypassCache'])) {
         $useCache = true;
         $time = isset($options['time']) ? $options['time'] : '';
         $dbkey = $title->getDBkey();
         if (isset($this->cache[$dbkey][$time])) {
             wfDebug(__METHOD__ . ": got File:{$dbkey} from process cache\n");
             # Move it to the end of the list so that we can delete the LRU entry later
             $tmp = $this->cache[$dbkey];
             unset($this->cache[$dbkey]);
             $this->cache[$dbkey] = $tmp;
             # Return the entry
             return $this->cache[$dbkey][$time];
         } else {
             # Add a negative cache entry, may be overridden
             $this->trimCache();
             $this->cache[$dbkey][$time] = false;
             $cacheEntry =& $this->cache[$dbkey][$time];
         }
     } else {
         $useCache = false;
     }
     # Check the local repo
     $image = $this->localRepo->findFile($title, $options);
     if ($image) {
         if ($useCache) {
             $cacheEntry = $image;
         }
         return $image;
     }
     # Check the foreign repos
     foreach ($this->foreignRepos as $repo) {
         $image = $repo->findFile($title, $options);
         if ($image) {
             if ($useCache) {
                 $cacheEntry = $image;
             }
             return $image;
         }
     }
     # Not found, do not override negative cache
     return false;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:75,代码来源:RepoGroup.php

示例2: findFile

 /**
  * Search repositories for an image.
  * You can also use wfFindFile() to do this.
  *
  * @param $title Title|string Title object or string
  * @param $options array Associative array of options:
  *     time:           requested time for an archived image, or false for the
  *                     current version. An image object will be returned which was
  *                     created at the specified time.
  *
  *     ignoreRedirect: If true, do not follow file redirects
  *
  *     private:        If true, return restricted (deleted) files if the current
  *                     user is allowed to view them. Otherwise, such files will not
  *                     be found.
  *
  *     bypassCache:    If true, do not use the process-local cache of File objects
  * @return File object or false if it is not found
  */
 function findFile($title, $options = array())
 {
     if (!is_array($options)) {
         // MW 1.15 compat
         $options = array('time' => $options);
     }
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $title = File::normalizeTitle($title);
     if (!$title) {
         return false;
     }
     # Check the cache
     if (empty($options['ignoreRedirect']) && empty($options['private']) && empty($options['bypassCache'])) {
         $time = isset($options['time']) ? $options['time'] : '';
         $dbkey = $title->getDBkey();
         if (isset($this->cache[$dbkey][$time])) {
             wfDebug(__METHOD__ . ": got File:{$dbkey} from process cache\n");
             # Move it to the end of the list so that we can delete the LRU entry later
             $this->pingCache($dbkey);
             # Return the entry
             return $this->cache[$dbkey][$time];
         }
         $useCache = true;
     } else {
         $useCache = false;
     }
     # Check the local repo
     $image = $this->localRepo->findFile($title, $options);
     # Check the foreign repos
     if (!$image) {
         foreach ($this->foreignRepos as $repo) {
             $image = $repo->findFile($title, $options);
             if ($image) {
                 break;
             }
         }
     }
     $image = $image ? $image : false;
     // type sanity
     # Cache file existence or non-existence
     if ($useCache && (!$image || $image->isCacheable())) {
         $this->trimCache();
         $this->cache[$dbkey][$time] = $image;
     }
     return $image;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:67,代码来源:RepoGroup.php

示例3: findFile

 /**
  * Search repositories for an image.
  * You can also use wfFindFile() to do this.
  *
  * @param Title|string $title Title object or string
  * @param array $options Associative array of options:
  *   time:           requested time for an archived image, or false for the
  *                   current version. An image object will be returned which was
  *                   created at the specified time.
  *   ignoreRedirect: If true, do not follow file redirects
  *   private:        If true, return restricted (deleted) files if the current
  *                   user is allowed to view them. Otherwise, such files will not
  *                   be found.
  *   latest:         If true, load from the latest available data into File objects
  * @return File|bool False if title is not found
  */
 function findFile($title, $options = [])
 {
     if (!is_array($options)) {
         // MW 1.15 compat
         $options = ['time' => $options];
     }
     if (isset($options['bypassCache'])) {
         $options['latest'] = $options['bypassCache'];
         // b/c
     }
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $title = File::normalizeTitle($title);
     if (!$title) {
         return false;
     }
     # Check the cache
     $dbkey = $title->getDBkey();
     if (empty($options['ignoreRedirect']) && empty($options['private']) && empty($options['bypassCache'])) {
         $time = isset($options['time']) ? $options['time'] : '';
         if ($this->cache->has($dbkey, $time, 60)) {
             return $this->cache->get($dbkey, $time);
         }
         $useCache = true;
     } else {
         $time = false;
         $useCache = false;
     }
     # Check the local repo
     $image = $this->localRepo->findFile($title, $options);
     # Check the foreign repos
     if (!$image) {
         foreach ($this->foreignRepos as $repo) {
             $image = $repo->findFile($title, $options);
             if ($image) {
                 break;
             }
         }
     }
     $image = $image ? $image : false;
     // type sanity
     # Cache file existence or non-existence
     if ($useCache && (!$image || $image->isCacheable())) {
         $this->cache->set($dbkey, $time, $image);
     }
     return $image;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:64,代码来源:RepoGroup.php

示例4: findFile

 /**
  * Search repositories for an image.
  * You can also use wfFindFile() to do this.
  *
  * @param $title Title|string Title object or string
  * @param $options array Associative array of options:
  *     time:           requested time for an archived image, or false for the
  *                     current version. An image object will be returned which was
  *                     created at the specified time.
  *
  *     ignoreRedirect: If true, do not follow file redirects
  *
  *     private:        If true, return restricted (deleted) files if the current
  *                     user is allowed to view them. Otherwise, such files will not
  *                     be found.
  *
  *     bypassCache:    If true, do not use the process-local cache of File objects
  * @return File object or false if it is not found
  */
 function findFile($title, $options = array())
 {
     if (!is_array($options)) {
         // MW 1.15 compat
         $options = array('time' => $options);
     }
     if (!$this->reposInitialised) {
         $this->initialiseRepos();
     }
     $title = File::normalizeTitle($title);
     if (!$title) {
         return false;
     }
     # Check the cache
     if (empty($options['ignoreRedirect']) && empty($options['private']) && empty($options['bypassCache'])) {
         $useCache = true;
         $time = isset($options['time']) ? $options['time'] : '';
         $dbkey = $title->getDBkey();
         if (isset($this->cache[$dbkey][$time])) {
             wfDebug(__METHOD__ . ": got File:{$dbkey} from process cache\n");
             # Move it to the end of the list so that we can delete the LRU entry later
             $tmp = $this->cache[$dbkey];
             unset($this->cache[$dbkey]);
             $this->cache[$dbkey] = $tmp;
             # Return the entry
             return $this->cache[$dbkey][$time];
         } else {
             # Add a negative cache entry, may be overridden
             $this->trimCache();
             $this->cache[$dbkey][$time] = false;
             $cacheEntry =& $this->cache[$dbkey][$time];
         }
     } else {
         $useCache = false;
     }
     # Check the local repo
     $image = $this->localRepo->findFile($title, $options);
     if ($image) {
         if ($useCache) {
             $cacheEntry = $image;
         }
         return $image;
     }
     # Wikia change - begin
     # @author macbre
     # Check redirects before checking foreign repositories (BAC-352)
     $titleRedirected = $this->localRepo->checkRedirect($title);
     if ($titleRedirected) {
         wfDebug(__METHOD__ . ": followed redirect before checking foreign repos\n");
         $title = $titleRedirected;
     }
     # Wikia change - end
     # Check the foreign repos
     foreach ($this->foreignRepos as $repo) {
         $image = $repo->findFile($title, $options);
         if ($image) {
             /* Wikia changes begin */
             // check if the foreign repo allows local repo file blocking
             if ($repo->allowBlocking) {
                 $isDeleted = false;
                 wfRunHooks('ForeignFileDeleted', array($image, &$isDeleted));
                 if ($isDeleted) {
                     return false;
                 }
             }
             /* Wikia changes end */
             if ($useCache) {
                 $cacheEntry = $image;
             }
             return $image;
         }
     }
     /* Wikia changes begin */
     if ($title->isRedirect()) {
         // get redirected file if the foreign repo allows file redirecting
         wfRunHooks('FindRedirectedFile', array($this->foreignRepos, $title, $options, $useCache, &$image, &$cacheEntry));
         if ($image) {
             return $image;
         }
     }
     /* Wikia changes end */
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:RepoGroup.php


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