本文整理汇总了PHP中wfFindFile函数的典型用法代码示例。如果您正苦于以下问题:PHP wfFindFile函数的具体用法?PHP wfFindFile怎么用?PHP wfFindFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfFindFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEmbedCode
public function getEmbedCode()
{
$articleId = $this->getVal('articleId', '');
$title = $this->getVal('fileTitle', '');
$width = $this->getVal('width', '');
$autoplay = $this->getVal('autoplay', false);
$error = '';
if (empty($title)) {
$error = $this->wf->msgForContent('videohandler-error-missing-parameter', 'title');
} else {
if (empty($width)) {
$error = $this->wf->msgForContent('videohandler-error-missing-parameter', 'width');
} else {
$title = Title::newFromText($title, NS_FILE);
$file = $title instanceof Title ? wfFindFile($title) : false;
if ($file === false) {
$error = $this->wf->msgForContent('videohandler-error-video-no-exist');
} else {
$videoId = $file->getVideoId();
$assetUrl = $file->getPlayerAssetUrl();
$embedCode = $file->getEmbedCode($articleId, $width, $autoplay, true);
$this->setVal('videoId', $videoId);
$this->setVal('asset', $assetUrl);
$this->setVal('embedCode', $embedCode);
//@todo support json embed code
}
}
}
if (!empty($error)) {
$this->setVal('error', $error);
}
}
示例2: addWikiaVars
public function addWikiaVars(&$obj, BaseTemplate &$tpl)
{
global $wgUser;
wfProfileIn(__METHOD__);
// ads
$this->setupAds($tpl);
// setup footer links
$tpl->set('footerlinks', wfMsgExt('Shared-Monobook-footer-wikia-links', 'parse'));
# rt33045
$tpl->set('contact', '<a href="' . $wgUser->getSkin()->makeUrl('Special:Contact') . '" title="Contact Wikia">Contact Wikia</a>');
# BAC-1036, CE-278
/* Replace Wikia logo path
This functionality is for finding proper path of Wiki.png instead of const one from wgLogo
wikia logo should be stored under File:Wiki.png on current wikia. If wfFindFile doesn't find it
on current wikia it tires to fallback to starter.wikia.com where the default one is stored
*/
$logoPage = Title::newFromText('Wiki.png', NS_FILE);
$logoFile = wfFindFile($logoPage);
if ($logoFile) {
$tpl->set('logopath', $logoFile->getUrl());
} else {
$tpl->set('logopath', wfReplaceImageServer($tpl->data['logopath']));
}
wfProfileOut(__METHOD__);
return true;
}
示例3: getMediaData
/**
* Get data for each gallery item
* @param array $item Data about the media item
* @param int $index Where the item shows up in the gallery
* @return array|null
*/
protected function getMediaData(array $item, $index)
{
$file = wfFindFile($item['title']);
if (!$file instanceof File) {
WikiaLogger::instance()->error('File with title: ' . $item['title'] . 'doesn\'t exist', ['class' => __CLASS__]);
return null;
}
$dimension = MediaGalleryHelper::getImageWidth($this->itemCount, $index);
$thumbUrl = WikiaFileHelper::getSquaredThumbnailUrl($file, $dimension);
$dimensions = ['width' => $dimension, 'height' => $dimension];
$thumb = $file->transform($dimensions);
if (!$thumb instanceof ThumbnailImage) {
WikiaLogger::instance()->error('ThumbnailImage from title: ' . $item['title'] . ' couldn\'t be created.', ['thumbClass' => get_class($thumb)]);
return null;
}
$thumb->setUrl($thumbUrl);
$thumbnail = $this->app->renderView('ThumbnailController', 'gallery', ['thumb' => $thumb]);
$caption = '';
if (!empty($item['caption'])) {
// parse any wikitext in caption. Logic borrowed from WikiaMobileMediaService::renderMediaGroup.
$parser = $this->getParser();
$caption = $parser->internalParse($item['caption']);
$parser->replaceLinkHolders($caption);
$caption = $parser->killMarkers($caption);
}
$title = $file->getTitle();
return ['thumbUrl' => $thumbUrl, 'thumbHtml' => $thumbnail, 'caption' => $caption, 'linkHref' => $file->getTitle()->getLinkURL(), 'title' => $title->getText(), 'dbKey' => $title->getDBKey()];
}
示例4: execute
public function execute()
{
global $wgUser;
# Change to current working directory
$oldCwd = getcwd();
chdir($oldCwd);
# Options processing
$user = $this->getOption('u', 'Delete page script');
$reason = $this->getOption('r', '');
$interval = $this->getOption('i', 0);
if ($this->hasArg()) {
$file = fopen($this->getArg(), 'r');
} else {
$file = $this->getStdin();
}
# Setup
if (!$file) {
$this->error("Unable to read file, exiting", true);
}
$wgUser = User::newFromName($user);
$dbw = wfGetDB(DB_MASTER);
# Handle each entry
for ($linenum = 1; !feof($file); $linenum++) {
$line = trim(fgets($file));
if ($line == '') {
continue;
}
$page = Title::newFromText($line);
if (is_null($page)) {
$this->output("Invalid title '{$line}' on line {$linenum}\n");
continue;
}
if (!$page->exists()) {
$this->output("Skipping nonexistent page '{$line}'\n");
continue;
}
$this->output($page->getPrefixedText());
$dbw->begin();
if ($page->getNamespace() == NS_FILE) {
$art = new ImagePage($page);
$img = wfFindFile($art->mTitle);
if (!$img || !$img->isLocal() || !$img->delete($reason)) {
$this->output(" FAILED to delete image file... ");
}
} else {
$art = new Article($page);
}
$success = $art->doDeleteArticle($reason);
$dbw->commit();
if ($success) {
$this->output(" Deleted!\n");
} else {
$this->output(" FAILED to delete article\n");
}
if ($interval) {
sleep($interval);
}
wfWaitForSlaves();
}
}
示例5: execute
/**
* Start doing stuff
*
* @param $par Mixed: parameter passed to the special page or null
*/
public function execute($par)
{
global $wgOut;
wfProfileIn(__METHOD__);
$dbr = wfGetDB(DB_SLAVE);
$where = array();
if ($this->mQuery) {
$where = array('article_tag' => $this->mQuery);
}
$foo = $dbr->select('imagetags', 'img_name', $where, __METHOD__);
$imageNames = array();
foreach ($foo as $omg) {
$imageNames[] = $omg;
}
$imageNamesString = implode(',', $imageNames);
// @todo CHECKME
$res = $dbr->select('image', array('img_name', 'img_timestamp'), array("img_name IN {$imageNamesString}"), __METHOD__, array('ORDER BY' => 'img_timestamp DESC', 'LIMIT' => TAGGEDIMGS_PER_PAGE, 'OFFSET' => $this->mStartPage * TAGGEDIMGS_PER_PAGE));
foreach ($res as $o) {
$img = wfFindFile($o->img_name);
$this->add($img, '');
}
$res = $dbr->select('imagetags', 'COUNT(img_name) AS img_count', $where, __METHOD__, array('GROUP BY' => 'article_tag'));
$o = $dbr->fetchObject($res);
if ($o) {
$this->mCount = $o->img_count;
}
$wgOut->setPageTitle(wfMsg('imagetagging-taggedimages-title', $this->mQuery ? $this->mQuery : 'all'));
$wgOut->setRobotPolicy('noindex,nofollow');
$wgOut->addHTML($this->toHTML());
wfProfileOut(__METHOD__);
}
示例6: addImage
/**
* Add image to parser output for later usage
*
* @param string $title
*/
public function addImage($title)
{
$file = wfFindFile($title);
$tmstmp = $file ? $file->getTimestamp() : false;
$sha1 = $file ? $file->getSha1() : false;
$this->parser->getOutput()->addImage($title, $tmstmp, $sha1);
}
示例7: displayCategoryTable
function displayCategoryTable()
{
global $wgOut;
$catmap = Categoryhelper::getIconMap();
ksort($catmap);
$queryString = WikihowCategoryViewer::getViewModeParam();
if (!empty($queryString)) {
$queryString = "?" . $queryString;
}
$wgOut->addHTML("<div class='section_text'>");
foreach ($catmap as $cat => $image) {
$title = Title::newFromText($image);
if ($title) {
$file = wfFindFile($title, false);
$sourceWidth = $file->getWidth();
$sourceHeight = $file->getHeight();
$heightPreference = false;
if (self::CAT_HEIGHT > self::CAT_WIDTH && $sourceWidth > $sourceHeight) {
//desired image is portrait
$heightPreference = true;
}
$thumb = $file->getThumbnail(self::CAT_WIDTH, self::CAT_HEIGHT, true, true, $heightPreference);
$category = urldecode(str_replace("-", " ", $cat));
$catTitle = Title::newFromText("Category:" . $category);
if ($catTitle) {
$wgOut->addHTML("<div class='thumbnail'><a href='{$catTitle->getLocalUrl()}{$queryString}'><img src='" . wfGetPad($thumb->getUrl()) . "' /><div class='text'><p><span>{$category}</span></p></div></a></div>");
}
}
}
$wgOut->addHTML("<div class='clearall'></div>");
$wgOut->addHTML("</div><!-- end section_text -->");
}
示例8: getImagePreview
public static function getImagePreview()
{
wfProfileIn(__METHOD__);
global $wgTitle;
// limit dimensions of returned image
global $wgRequest;
$maxWidth = $wgRequest->getInt('maxwidth', 500) - 20;
$maxHeight = $wgRequest->getInt('maxheight', 300) - 75;
$image = wfFindFile($wgTitle);
if (empty($image)) {
wfProfileOut(__METHOD__);
return array();
}
// get original dimensions of an image
$width = $image->getWidth();
$height = $image->getHeight();
// don't try to make image larger
if ($width > $maxWidth or $height > $maxHeight) {
$width = $maxWidth;
$height = $maxHeight;
}
// generate thumbnail
$thumb = $image->transform(array('width' => $width, 'height' => $height));
wfProfileOut(__METHOD__);
return array('width' => $thumb->getWidth(), 'height' => $thumb->getHeight(), 'html' => $thumb->toHtml());
}
示例9: execute
public function execute()
{
global $wgRequest;
wfProfileIn(__METHOD__);
extract($this->extractRequestParams());
$imageServing = new ImageServing(array($Id), $Size, array("w" => $Size, "h" => $Height));
foreach ($imageServing->getImages(1) as $key => $value) {
$tmpTitle = Title::newFromText($value[0]['name'], NS_FILE);
$image = wfFindFile($tmpTitle);
// BugId:31460 ForeignAPIFile does not support loading metadata from the file itself.
// Note, that ForeignAPIFile::getPath() is a dommy method and always returns false, so
// the 'File not found' dieUsage() call in the next if block is inevitable for ForeignAPIFile objects.
if ($FailOnFileNotFound && false == $image instanceof ForeignAPIFile) {
$image->loadFromFile();
// side effect forces isMissing() check to fail if file really does not exist
}
if (!($image instanceof File && $image->exists()) || $image->isMissing() || $image->mime == 'unknown/unknown') {
$this->dieUsage('File not found', 'filenotfound');
}
$width = $image->getWidth();
$height = $image->getHeight();
$imageUrl = $imageServing->getUrl($image->getName(), $width, $height);
}
$result = $this->getResult();
$result->addValue('image', $this->getModuleName(), $imageUrl);
$result->addValue('imagepage', $this->getModuleName(), $tmpTitle->getFullUrl());
wfProfileOut(__METHOD__);
}
示例10: execute
function execute($par)
{
global $wgRequest, $wgOut;
$this->setHeaders();
$this->outputHeader();
$file = !is_null($par) ? $par : $wgRequest->getText('file');
$title = Title::makeTitleSafe(NS_FILE, $file);
if (!$title instanceof Title || $title->getNamespace() != NS_FILE) {
$this->showForm($title);
} else {
$file = wfFindFile($title);
if ($file && $file->exists()) {
$url = $file->getURL();
$width = $wgRequest->getInt('width', -1);
$height = $wgRequest->getInt('height', -1);
if ($width != -1) {
$mto = $file->transform(array('width' => $width, 'height' => $height));
if ($mto && !$mto->isError()) {
$url = $mto->getURL();
}
}
$wgOut->redirect($url);
} else {
$wgOut->setStatusCode(404);
$this->showForm($title);
}
}
}
示例11: getBadge
public static function getBadge($badgeTypeId)
{
wfProfileIn(__METHOD__);
global $wgExternalSharedDB;
global $wgEnableAchievementsStoreLocalData;
$badges = array();
if (empty($wgEnableAchievementsStoreLocalData)) {
$dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
} else {
$dbr = wfGetDB(DB_SLAVE);
}
$res = $dbr->select('ach_custom_badges', array('id', 'enabled', 'sponsored', 'badge_tracking_url', 'hover_tracking_url', 'click_tracking_url'), array('id' => $badgeTypeId), __METHOD__);
if ($row = $dbr->fetchObject($res)) {
$badge = array();
$image = wfFindFile(AchConfig::getInstance()->getBadgePictureName($row->id));
if ($image) {
$hoverImage = wfFindFile(AchConfig::getInstance()->getHoverPictureName($row->id));
$badge['type_id'] = $row->id;
$badge['enabled'] = $row->enabled;
$badge['thumb_url'] = $image->createThumb(90);
$badge['awarded_users'] = AchPlatinumService::getAwardedUserNames($row->id);
$badge['is_sponsored'] = $row->sponsored;
$badge['badge_tracking_url'] = $row->badge_tracking_url;
$badge['hover_tracking_url'] = $row->hover_tracking_url;
$badge['click_tracking_url'] = $row->click_tracking_url;
$badge['hover_content_url'] = is_object($hoverImage) ? wfReplaceImageServer($hoverImage->getFullUrl()) : null;
wfProfileOut(__METHOD__);
return $badge;
}
}
wfProfileOut(__METHOD__);
return false;
}
示例12: getVideoData
public function getVideoData($titleText, $thumbnailWidth, $videoWidth = self::DEFAULT_OASIS_VIDEO_WIDTH, $autoplay = true, $useMaster = false, $cityShort = 'life', $videoHeight = '', $useJWPlayer = true, $inAjaxResponse = false)
{
wfProfileIn(__METHOD__);
$data = array();
$title = Title::newFromText($titleText, NS_FILE);
$file = wfFindFile($title);
if (!WikiaFileHelper::isVideoFile($file)) {
$data['error'] = wfMsg('related-videos-error-no-video-title');
} else {
$meta = unserialize($file->getMetadata());
$trans = $file->transform(array('width' => $thumbnailWidth, 'height' => -1));
$thumb = array('width' => $trans->width, 'height' => $trans->height, 'thumb' => $trans->url);
$data['external'] = 0;
// false means it is not set. Meaningful values: 0 and 1.
$data['id'] = $titleText;
$data['fullUrl'] = $title->getFullURL();
$data['prefixedUrl'] = $title->getPrefixedURL();
$data['description'] = $file->getDescription();
$data['duration'] = $meta['duration'];
$data['embedCode'] = null;
$data['embedJSON'] = null;
$data['provider'] = $file->minor_mime;
$data['thumbnailData'] = $thumb;
$data['title'] = $file->getTitle()->getText();
$data['timestamp'] = $file->getTimestamp();
$data['uniqueId'] = $file->getVideoUniqueId();
}
$data['owner'] = '';
$data['ownerUrl'] = '';
wfProfileOut(__METHOD__);
return $data;
}
示例13: formatImageLink
function formatImageLink($imageName, $linkTarget, $altText)
{
if (preg_match('/^(http|ftp)/', $imageName)) {
$imageUrl = $imageName;
$sizeAttrs = "";
} else {
$imageTitle = Title::makeTitleSafe(NS_IMAGE, $imageName);
if (is_null($imageTitle)) {
return "(invalid image name)";
}
$image = wfFindFile($imageTitle);
if (is_null($image)) {
return "(invalid image)";
}
$imageUrl = $image->getViewURL();
$sizeAttrs = 'width="' . IntVal($image->getWidth()) . '" height="' . IntVal($image->getHeight()) . '"';
}
if (preg_match('/^(http|ftp)/', $linkTarget)) {
$linkUrl = $linkTarget;
} else {
$linkTitle = Title::newFromText($linkTarget);
if (is_null($linkTitle)) {
return "(invalid link target)";
}
$linkUrl = $linkTitle->getLocalUrl();
}
return '<a href="' . htmlspecialchars($linkUrl) . '"><img src="' . htmlspecialchars($imageUrl) . '" ' . $sizeAttrs . ' alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '" /></a>';
}
示例14: onAfterInitialize
/**
* set appropriate status code for deleted pages
*
* @author ADi
* @author Władysław Bodzek <wladek@wikia-inc.com>
* @param Title $title
* @param Article $article
* @return bool
*/
public static function onAfterInitialize(&$title, &$article, &$output)
{
if (!$title->exists() && $title->isDeleted()) {
$setDeletedStatusCode = true;
// handle special cases
switch ($title->getNamespace()) {
case NS_CATEGORY:
// skip non-empty categories
if (Category::newFromTitle($title)->getPageCount() > 0) {
$setDeletedStatusCode = false;
}
break;
case NS_FILE:
// skip existing file with deleted description
$file = wfFindFile($title);
if ($file && $file->exists()) {
$setDeletedStatusCode = false;
}
break;
}
if ($setDeletedStatusCode) {
$output->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
}
}
return true;
}
示例15: checkDupImage
/**
* Check to see if an image was already uploaded for wikiphoto
*/
public static function checkDupImage($filename)
{
$dbr = self::getDB('read');
$contents = @file_get_contents($filename);
if ($contents) {
$sha1 = sha1($contents);
$db_title = $dbr->selectField('images_sha1', 'is_page_title', array('is_sha1' => $sha1), __METHOD__);
if ($db_title) {
$title = Title::newFromDBkey('Image:' . $db_title);
if ($title && $title->exists()) {
$file = wfFindFile($title);
if ($file) {
$path = $file->getPath();
if ($path && @file_exists($path)) {
$contents = @file_get_contents($path);
if ($contents) {
$sha1_orig = sha1($contents);
if ($sha1_orig == $sha1) {
return $title->getText();
}
}
}
}
}
}
}
return '';
}