本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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 */
//.........这里部分代码省略.........