• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP RepoGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: uploadImageFromUrl

 /**
  * @desc Uploads an image on a wki
  *
  * @static
  * @param string $imageUrl url address to original file
  * @param Object $oImageData an object with obligatory field "name" and optional fields: "comment", "description"
  * @param User | null $user optional User's class instance (the file will be "uploaded" by this user)
  *
  * @return array
  */
 public static function uploadImageFromUrl($imageUrl, $oImageData, $user = null)
 {
     // disable recentchange hooks
     global $wgHooks;
     $wgHooks['RecentChange_save'] = array();
     $wgHooks['RecentChange_beforeSave'] = array();
     /* prepare temporary file */
     $data = array('wpUpload' => 1, 'wpSourceType' => 'web', 'wpUploadFileURL' => $imageUrl);
     //validate of optional image data
     foreach (array(self::FILE_DATA_COMMENT_OPION_NAME, self::FILE_DATA_DESC_OPION_NAME) as $option) {
         if (!isset($oImageData->{$option})) {
             $oImageData->{$option} = $oImageData->name;
         }
     }
     $upload = F::build('UploadFromUrl');
     /* @var $upload UploadFromUrl */
     $upload->initializeFromRequest(F::build('FauxRequest', array($data, true)));
     $upload->fetchFile();
     $upload->verifyUpload();
     // create destination file
     $title = Title::newFromText($oImageData->name, NS_FILE);
     $file = F::build('WikiaLocalFile', array($title, RepoGroup::singleton()->getLocalRepo()));
     /* @var $file WikiaLocalFile */
     /* real upload */
     $result = $file->upload($upload->getTempPath(), $oImageData->comment, $oImageData->description, File::DELETE_SOURCE, false, false, $user);
     return array('status' => $result->ok, 'page_id' => $title->getArticleID(), 'errors' => $result->errors);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:37,代码来源:ImagesService.class.php


示例2: getRepo

 /**
  * @return FileRepo
  */
 function getRepo()
 {
     if (!isset($this->repo)) {
         $this->repo = RepoGroup::singleton()->getLocalRepo();
     }
     return $this->repo;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:10,代码来源:rebuildImages.php


示例3: execute

 public function execute()
 {
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDb();
     // how far back should this look for files to delete?
     global $wgUploadStashMaxAge;
     $this->output("Getting list of files to clean up...\n");
     $res = $dbr->select('uploadstash', 'us_key', 'us_timestamp < ' . $dbr->addQuotes($dbr->timestamp(time() - $wgUploadStashMaxAge)), __METHOD__);
     if (!is_object($res) || $res->numRows() == 0) {
         $this->output("No files to cleanup!\n");
         // nothing to do.
         return;
     }
     // finish the read before starting writes.
     $keys = array();
     foreach ($res as $row) {
         array_push($keys, $row->us_key);
     }
     $this->output('Removing ' . count($keys) . " file(s)...\n");
     // this could be done some other, more direct/efficient way, but using
     // UploadStash's own methods means it's less likely to fall accidentally
     // out-of-date someday
     $stash = new UploadStash($repo);
     foreach ($keys as $key) {
         try {
             $stash->getFile($key, true);
             $stash->removeFileNoAuth($key);
         } catch (UploadStashBadPathException $ex) {
             $this->output("Failed removing stashed upload with key: {$key}\n");
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:cleanupUploadStash.php


示例4: parserFunction

 public static function parserFunction($parser, $vid = null, $img = null)
 {
     global $wgTitle, $wgContLang;
     wfLoadExtensionMessages('WHVid');
     if ($vid === null || $img === null) {
         return '<div class="errorbox">' . wfMsg('missing-params') . '</div>';
     }
     $vid = htmlspecialchars($vid);
     $divId = "whvid-" . md5($vid . mt_rand(1, 1000));
     $vidUrl = self::getVidUrl($vid);
     $imgTitle = Title::newFromURL($img, NS_IMAGE);
     $imgUrl = null;
     if ($imgTitle) {
         $imgFile = RepoGroup::singleton()->findFile($imgTitle);
         $smallImgUrl = '';
         $largeImgUrl = '';
         if ($imgFile) {
             $width = 550;
             $height = 309;
             $thumb = $imgFile->getThumbnail($width, $height);
             $largeImgUrl = wfGetPad($thumb->getUrl());
             $width = 240;
             //$height = 135;
             $thumb = $imgFile->getThumbnail($width);
             $smallImgUrl = wfGetPad($thumb->getUrl());
         }
     }
     return $parser->insertStripItem(wfMsgForContent('embed-html', $divId, $vidUrl, $largeImgUrl, $smallImgUrl));
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:WHVid.body.php


示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $modulePrefix = $this->getModulePrefix();
     $prop = array_flip($params['prop']);
     $scale = $this->getScale($params);
     $result = $this->getResult();
     if (!$params['filekey'] && !$params['sessionkey']) {
         $this->dieUsage("One of filekey or sessionkey must be supplied", 'nofilekey');
     }
     // Alias sessionkey to filekey, but give an existing filekey precedence.
     if (!$params['filekey'] && $params['sessionkey']) {
         $params['filekey'] = $params['sessionkey'];
     }
     try {
         $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash($this->getUser());
         foreach ($params['filekey'] as $filekey) {
             $file = $stash->getFile($filekey);
             $finalThumbParam = $this->mergeThumbParams($file, $scale, $params['urlparam']);
             $imageInfo = ApiQueryImageInfo::getInfo($file, $prop, $result, $finalThumbParam);
             $result->addValue(array('query', $this->getModuleName()), null, $imageInfo);
             $result->addIndexedTagName(array('query', $this->getModuleName()), $modulePrefix);
         }
         // @todo Update exception handling here to understand current getFile exceptions
     } catch (UploadStashFileNotFoundException $e) {
         $this->dieUsage("File not found: " . $e->getMessage(), "invalidsessiondata");
     } catch (UploadStashBadPathException $e) {
         $this->dieUsage("Bad path: " . $e->getMessage(), "invalidsessiondata");
     }
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:30,代码来源:ApiQueryStashImageInfo.php


示例6: getLocalFile

 public function getLocalFile()
 {
     if (is_null($this->mLocalFile)) {
         $this->mLocalFile = new FakeLocalFile(Title::newFromText('Temp_file_' . time() . '.jpg', NS_FILE), RepoGroup::singleton()->getLocalRepo());
     }
     return $this->mLocalFile;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:UploadVisualizationImageFromFile.class.php


示例7: execute

 public function execute()
 {
     global $wgCityId;
     $db = wfGetDB(DB_MASTER);
     (new WikiaSQL())->SELECT('*')->FROM('page')->WHERE('page_is_redirect')->EQUAL_TO(1)->runLoop($db, function ($a, $row) use($db) {
         $title = Title::newFromID($row->page_id);
         if (!$title->isDeleted()) {
             $rev = Revision::newFromTitle($title);
             $text = $rev->getText();
             $rt = Title::newFromRedirectRecurse($text);
             if (!$rt) {
                 // page is marked as redirect but $text is not valid redirect
                 $this->output('Fixed ID: ' . $title->getArticleID() . ' Title: ' . $title->getText() . "\n");
                 // Fix page table
                 (new WikiaSQL())->UPDATE('page')->SET('page_is_redirect', 0)->WHERE('page_id')->EQUAL_TO($row->page_id)->RUN($db);
                 // remove redirect from redirect table
                 (new WikiaSQL())->DELETE('redirect')->WHERE('rd_from')->EQUAL_TO($row->page_id)->RUN($db);
                 // clear cache
                 LinkCache::singleton()->addGoodLinkObj($row->page_id, $title, strlen($text), 0, $rev->getId());
                 if ($title->getNamespace() == NS_FILE) {
                     RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
                 }
             }
         }
     });
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:fixFalseRedirects.php


示例8: execute

 public function execute()
 {
     $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
     // Make sure we have files in the title set:
     if (!empty($pageIds[NS_FILE])) {
         $titles = array_keys($pageIds[NS_FILE]);
         asort($titles);
         // Ensure the order is always the same
         $result = $this->getResult();
         $images = RepoGroup::singleton()->findFiles($titles);
         foreach ($images as $img) {
             // if its a "transcode" add the transcode status table output
             if (TimedMediaHandlerHooks::isTranscodableTitle($img->getTitle())) {
                 $transcodeStatus = WebVideoTranscode::getTranscodeState($img->getTitle()->getDBKey());
                 // remove useless properties
                 foreach ($transcodeStatus as $key => &$val) {
                     unset($val['id']);
                     unset($val['image_name']);
                     unset($val['key']);
                 }
                 $result->addValue(array('query', 'pages', $img->getTitle()->getArticleID()), 'transcodestatus', $transcodeStatus);
             }
         }
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:ApiTranscodeStatus.php


示例9: execute

 public function execute()
 {
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDb();
     $this->output("Getting list of files to clean up...\n");
     $res = $dbr->select('uploadstash', 'us_key', 'us_timestamp < ' . $dbr->timestamp(time() - UploadStash::REPO_AGE * 3600), __METHOD__);
     if (!is_object($res) || $res->numRows() == 0) {
         // nothing to do.
         return false;
     }
     // finish the read before starting writes.
     $keys = array();
     foreach ($res as $row) {
         array_push($keys, $row->us_key);
     }
     $this->output('Removing ' . count($keys) . " file(s)...\n");
     // this could be done some other, more direct/efficient way, but using
     // UploadStash's own methods means it's less likely to fall accidentally
     // out-of-date someday
     $stash = new UploadStash($repo);
     foreach ($keys as $key) {
         $stash->getFile($key, true);
         $stash->removeFileNoAuth($key);
     }
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:25,代码来源:cleanupUploadStash.php


示例10: execute

 function execute()
 {
     $subdir = $this->getOption('subdir', '');
     $verbose = $this->hasOption('verbose');
     $repo = RepoGroup::singleton()->getLocalRepo();
     if ($repo->hasSha1Storage()) {
         $this->error("Local repo uses SHA-1 file storage names; aborting.", 1);
     }
     $directory = $repo->getZonePath('public');
     if ($subdir != '') {
         $directory .= "/{$subdir}/";
     }
     if ($verbose) {
         $this->output("Scanning files under {$directory}:\n");
     }
     $list = $repo->getBackend()->getFileList(['dir' => $directory]);
     if ($list === null) {
         $this->error("Could not get file listing.", 1);
     }
     $pathBatch = [];
     foreach ($list as $path) {
         if (preg_match('#^(thumb|deleted)/#', $path)) {
             continue;
             // handle ugly nested containers on stock installs
         }
         $pathBatch[] = $path;
         if (count($pathBatch) >= $this->mBatchSize) {
             $this->checkFiles($repo, $pathBatch, $verbose);
             $pathBatch = [];
         }
     }
     $this->checkFiles($repo, $pathBatch, $verbose);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:findOrphanedFiles.php


示例11: setUpForeignRepo

 private function setUpForeignRepo()
 {
     global $wgUploadDirectory;
     $this->setMwGlobals('wgForeignFileRepos', [['class' => 'ForeignAPIRepo', 'name' => 'wikimediacommons', 'backend' => 'wikimediacommons-backend', 'apibase' => 'https://commons.wikimedia.org/w/api.php', 'hashLevels' => 2, 'fetchDescription' => true, 'descriptionCacheExpiry' => 43200, 'apiThumbCacheExpiry' => 86400, 'directory' => $wgUploadDirectory]]);
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:RepoGroupTest.php


示例12: filePath

 function filePath($name)
 {
     if (!isset($this->repo)) {
         $this->repo = RepoGroup::singleton()->getLocalRepo();
     }
     return $this->repo->getRootDirectory() . '/' . $this->repo->getHashPath($name) . $name;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:7,代码来源:cleanupImages.php


示例13: execute

 function execute()
 {
     $lastName = $this->getOption('start', '');
     $repo = RepoGroup::singleton()->getLocalRepo();
     $dbr = $repo->getSlaveDB();
     $be = $repo->getBackend();
     $mtime1 = $dbr->timestampOrNull($this->getOption('mtimeafter', null));
     $mtime2 = $dbr->timestampOrNull($this->getOption('mtimebefore', null));
     $joinTables = array('image');
     $joinConds = array('image' => array('INNER JOIN', 'img_name = page_title'));
     if ($mtime1 || $mtime2) {
         $joinTables[] = 'logging';
         $on = array('log_page = page_id', 'log_type' => array('upload', 'move', 'delete'));
         if ($mtime1) {
             $on[] = "log_timestamp > {$dbr->addQuotes($mtime1)}";
         }
         if ($mtime2) {
             $on[] = "log_timestamp < {$dbr->addQuotes($mtime2)}";
         }
         $joinConds['logging'] = array('INNER JOIN', $on);
     }
     do {
         $res = $dbr->select(array_merge(array('page'), $joinTables), array('img_name' => 'DISTINCT(page_title)'), array('page_namespace' => NS_FILE, "page_title >= " . $dbr->addQuotes($lastName)), __METHOD__, array('ORDER BY' => 'page_title', 'LIMIT' => $this->mBatchSize), $joinConds);
         // Check if any of these files are missing...
         $pathsByName = array();
         foreach ($res as $row) {
             $file = $repo->newFile($row->img_name);
             $pathsByName[$row->img_name] = $file->getPath();
             $lastName = $row->img_name;
         }
         $be->preloadFileStat(array('srcs' => $pathsByName));
         foreach ($pathsByName as $path) {
             if ($be->fileExists(array('src' => $path)) === false) {
                 $this->output("{$path}\n");
             }
         }
         // Find all missing old versions of any of the files in this batch...
         if (count($pathsByName)) {
             $ores = $dbr->select('oldimage', array('oi_name', 'oi_archive_name'), array('oi_name' => array_keys($pathsByName)), __METHOD__);
             $checkPaths = array();
             foreach ($ores as $row) {
                 if (!strlen($row->oi_archive_name)) {
                     continue;
                     // broken row
                 }
                 $file = $repo->newFromArchiveName($row->oi_name, $row->oi_archive_name);
                 $checkPaths[] = $file->getPath();
             }
             foreach (array_chunk($checkPaths, $this->mBatchSize) as $paths) {
                 $be->preloadFileStat(array('srcs' => $paths));
                 foreach ($paths as $path) {
                     if ($be->fileExists(array('src' => $path)) === false) {
                         $this->output("{$path}\n");
                     }
                 }
             }
         }
     } while ($res->numRows() >= $this->mBatchSize);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:59,代码来源:findMissingFiles.php


示例14: getLocalFile

 public function getLocalFile()
 {
     if (is_null($this->mLocalFile)) {
         //TODO: find out what namespace constant 6 is
         $this->mLocalFile = new FakeLocalFile(Title::newFromText('Temp_file_' . time(), 6), RepoGroup::singleton()->getLocalRepo());
     }
     return $this->mLocalFile;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:UploadWordmarkFromFile.class.php


示例15: getFileDuplicate

 protected function getFileDuplicate($filepath)
 {
     $duplicates = RepoGroup::singleton()->findBySha1(FSFile::getSha1Base36FromPath($filepath));
     if (count($duplicates) > 0) {
         return $duplicates[0];
     }
     return null;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:8,代码来源:ApiAddMedia.php


示例16: singleton

 /**
  * Get a FileCache instance.  Typically, only one instance of FileCache
  * is needed in a MediaWiki invocation.
  */
 static function singleton()
 {
     if (self::$instance) {
         return self::$instance;
     }
     self::$instance = new FileCache(RepoGroup::singleton());
     return self::$instance;
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:12,代码来源:FileCache.php


示例17: addVideo

 /**
  * add video
  * @param string $url
  * @return string error message or array( $videoTitle, $videoPageId, $videoProvider )
  */
 public function addVideo($url)
 {
     global $wgIsGhostVideo;
     wfProfileIn(__METHOD__);
     if (!$this->wg->User->isAllowed('videoupload')) {
         wfProfileOut(__METHOD__);
         return wfMessage('videos-error-admin-only')->plain();
     }
     if (empty($url)) {
         wfProfileOut(__METHOD__);
         return wfMessage('videos-error-no-video-url')->text();
     }
     $vHelper = new VideoHandlerHelper();
     # @TODO Commenting out to fix MAIN-4436 -- Should be fixed correctly when content team is back
     #		if ( !$vHelper->isVideoProviderSupported( $url ) ) {
     #			wfProfileOut( __METHOD__ );
     #			return wfMessage( 'videos-error-provider-not-supported' )->parse();
     #		}
     try {
         // is it a WikiLink?
         $title = Title::newFromText($url, NS_FILE);
         if (!$title || !WikiaFileHelper::isFileTypeVideo($title)) {
             $title = Title::newFromText(str_replace(array('[[', ']]'), array('', ''), $url), NS_FILE);
         }
         if (!$title || !WikiaFileHelper::isFileTypeVideo($title)) {
             $file = $this->getVideoFileByUrl($url);
             if ($file) {
                 $title = $file->getTitle();
             }
         }
         if ($title && WikiaFileHelper::isFileTypeVideo($title)) {
             $videoTitle = $title;
             $videoPageId = $title->getArticleId();
             $videoProvider = '';
             wfRunHooks('AddPremiumVideo', array($title));
         } else {
             if (empty($this->wg->allowNonPremiumVideos)) {
                 wfProfileOut(__METHOD__);
                 return wfMessage('videohandler-non-premium')->parse();
             }
             list($videoTitle, $videoPageId, $videoProvider) = $this->addVideoVideoHandlers($url);
             $file = RepoGroup::singleton()->findFile($videoTitle);
         }
         if (!$file instanceof File) {
             WikiaLogger::instance()->error('\\VideoHandlerHelper->adDefaultVideoDescription() - File is empty', ['exception' => new Exception(), 'url' => $url, 'title' => $title, 'videoTitle' => $videoTitle, 'videoPageId' => $videoPageId, 'videoProvider' => $videoProvider, 'wgIsGhostVideo' => $wgIsGhostVideo]);
             wfProfileOut(__METHOD__);
             return wfMessage('videos-something-went-wrong')->parse();
         } else {
             // Add a default description if available and one doesn't already exist
             $vHelper->addDefaultVideoDescription($file);
         }
     } catch (Exception $e) {
         wfProfileOut(__METHOD__);
         return $e->getMessage();
     }
     wfProfileOut(__METHOD__);
     return array($videoTitle, $videoPageId, $videoProvider);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:63,代码来源:VideoService.class.php


示例18: update_images_bug_28348

 protected function update_images_bug_28348($start = null)
 {
     $this->output("Correcting fi_img_timestamp column in flaggedimages\n");
     $db = wfGetDB(DB_MASTER);
     if ($start === null) {
         $start = $db->selectField('flaggedimages', 'MIN(fi_rev_id)', false, __METHOD__);
     }
     $end = $db->selectField('flaggedimages', 'MAX(fi_rev_id)', false, __METHOD__);
     if (is_null($start) || is_null($end)) {
         $this->output("...flaggedimages table seems to be empty.\n");
         return;
     }
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     $count = $changed = 0;
     while ($blockEnd <= $end) {
         $this->output("...doing fi_rev_id from {$blockStart} to {$blockEnd}\n");
         $cond = "fi_rev_id BETWEEN {$blockStart} AND {$blockEnd} AND fi_img_timestamp IS NOT NULL" . " AND img_name IS NULL AND oi_name IS NULL";
         // optimize
         $res = $db->select(array('flaggedimages', 'image', 'oldimage'), '*', $cond, __FUNCTION__, array(), array('image' => array('LEFT JOIN', 'img_sha1 = fi_img_sha1 AND img_timestamp = fi_img_timestamp'), 'oldimage' => array('LEFT JOIN', 'oi_sha1 = fi_img_sha1 AND oi_timestamp = fi_img_timestamp')));
         $db->begin();
         # Go through and clean up missing items, as well as correct fr_quality...
         foreach ($res as $row) {
             $count++;
             $fi_img_timestamp = trim($row->fi_img_timestamp);
             // clear pad garbage
             if (!$fi_img_timestamp) {
                 continue;
                 // nothing to check
             }
             $time = wfTimestamp(TS_MW, $fi_img_timestamp);
             $sha1 = $row->fi_img_sha1;
             # Check if the specified file exists...
             $file = RepoGroup::singleton()->findFileFromKey($sha1, array('time' => $time));
             if (!$file) {
                 // doesn't exist?
                 $time = wfTimestamp(TS_MW, wfTimestamp(TS_UNIX, $time) + 1);
                 # Check if the fi_img_timestamp value is off by 1 second...
                 $file = RepoGroup::singleton()->findFileFromKey($sha1, array('time' => $time));
                 if ($file) {
                     $this->output("fixed file {$row->fi_name} reference in rev ID {$row->fi_rev_id}\n");
                     # Fix the fi_img_timestamp value...
                     $db->update('flaggedimages', array('fi_img_timestamp' => $db->timestamp($time)), array('fi_rev_id' => $row->fi_rev_id, 'fi_name' => $row->fi_name), __METHOD__);
                     $changed++;
                 }
             }
         }
         $db->commit();
         $db->freeResult($res);
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves(5);
     }
     $this->output("fi_img_timestamp column fixes complete ... {$count} rows [{$changed} changed]\n");
 }
开发者ID:crippsy14,项目名称:orange-smorange,代码行数:57,代码来源:fixBug28348.php


示例19: uploadImage

 /**
  * Handle image upload
  *
  * Returns array with uploaded files details or error details
  */
 public function uploadImage($uploadFieldName = self::DEFAULT_FILE_FIELD_NAME, $destFileName = null, $forceOverwrite = false)
 {
     global $IP, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     $ret = false;
     // check whether upload is enabled (RT #53714)
     if (!WikiaPhotoGalleryHelper::isUploadAllowed()) {
         $ret = array('error' => true, 'message' => wfMsg('uploaddisabled'));
         wfProfileOut(__METHOD__);
         return $ret;
     }
     $imageName = stripslashes(!empty($destFileName) ? $destFileName : $wgRequest->getFileName($uploadFieldName));
     // validate name and content of uploaded photo
     $nameValidation = $this->checkImageName($imageName, $uploadFieldName);
     if ($nameValidation == UploadBase::SUCCESS) {
         // get path to uploaded image
         $imagePath = $wgRequest->getFileTempName($uploadFieldName);
         // check if image with this name is already uploaded
         if ($this->imageExists($imageName) && !$forceOverwrite) {
             // upload as temporary file
             $this->log(__METHOD__, "image '{$imageName}' already exists!");
             $tempName = $this->tempFileName($wgUser);
             $title = Title::makeTitle(NS_FILE, $tempName);
             $localRepo = RepoGroup::singleton()->getLocalRepo();
             $file = new FakeLocalFile($title, $localRepo);
             $file->upload($wgRequest->getFileTempName($uploadFieldName), '', '');
             // store uploaded image in GarbageCollector (image will be removed if not used)
             $tempId = $this->tempFileStoreInfo($tempName);
             // generate thumbnail (to fit 200x200 box) of temporary file
             $width = min(WikiaPhotoGalleryHelper::thumbnailMaxWidth, $file->width);
             $height = min(WikiaPhotoGalleryHelper::thumbnailMaxHeight, $file->height);
             $thumbnail = $file->transform(array('height' => $height, 'width' => $width));
             // split uploaded file name into name + extension (foo-bar.png => foo-bar + png)
             list($fileName, $extensionsName) = UploadBase::splitExtensions($imageName);
             $extensionName = !empty($extensionsName) ? end($extensionsName) : '';
             $this->log(__METHOD__, 'upload successful');
             $ret = array('conflict' => true, 'name' => $imageName, 'nameParts' => array($fileName, $extensionName), 'tempId' => $tempId, 'size' => array('height' => $file->height, 'width' => $file->width), 'thumbnail' => array('height' => $thumbnail->height, 'url' => $thumbnail->url, 'width' => $thumbnail->width));
         } else {
             // use regular MW upload
             $this->log(__METHOD__, "image '{$imageName}' is new one - uploading as MW file");
             $this->log(__METHOD__, "uploading '{$imagePath}' as File:{$imageName}");
             // create title and file objects for MW image to create
             $imageTitle = Title::newFromText($imageName, NS_FILE);
             $imageFile = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo());
             // perform upload
             $result = $imageFile->upload($imagePath, '', '');
             $this->log(__METHOD__, !empty($result->ok) ? 'upload successful' : 'upload failed');
             $ret = array('success' => !empty($result->ok), 'name' => $imageName, 'size' => array('height' => !empty($result->ok) ? $imageFile->getHeight() : 0, 'width' => !empty($result->ok) ? $imageFile->getWidth() : 0));
         }
     } else {
         $reason = $nameValidation;
         $this->log(__METHOD__, "upload failed - file name is not valid (error #{$reason})");
         $ret = array('error' => true, 'reason' => $reason, 'message' => $this->translateError($reason));
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:WikiaPhotoGalleryUpload.class.php


示例20: getInitialisedRepoGroup

	protected function getInitialisedRepoGroup() {
		$repoGroup = RepoGroup::singleton();

		if ( !$repoGroup->reposInitialised ) {
			$repoGroup->initialiseRepos();
		}

		return $repoGroup;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:9,代码来源:ApiQueryFileRepoInfo.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Report类代码示例发布时间:2022-05-23
下一篇:
PHP Reply类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap