Ejemplo n.º 1
0
 public static function uploadFile(PromoImage $promoImage, GlobalTitle $sourceTitle, $sourceWikiId)
 {
     $sourceFile = \GlobalFile::newFromText($sourceTitle->getText(), $sourceWikiId);
     if (!$sourceFile->exists()) {
         echo "sourceFile doesn't exist" . PHP_EOL;
         return false;
     }
     $sourceImageUrl = $sourceFile->getUrl();
     $user = User::newFromName('WikiaBot');
     $imageData = new stdClass();
     $imageData->name = $promoImage->getPathname();
     $imageData->description = $imageData->comment = wfMessage('wikiahome-image-auto-uploaded-comment')->plain();
     $result = ImagesService::uploadImageFromUrl($sourceImageUrl, $imageData, $user);
     if (!$result['status']) {
         var_dump($result['errors'], $sourceImageUrl);
     }
     return $result['status'];
 }
Ejemplo n.º 2
0
 /**
  * Wikia change begin
  * Load a shared module from dev.wikia.com.
  * @author Adam Karmiński <*****@*****.**>
  * @param  GlobalTitle $title GlobalTitle instance of a shared module.
  * @return mixed              Returns a module if found and null otherwise.
  */
 function fetchSharedModule(GlobalTitle $title, $prefix)
 {
     $key = $prefix . $title->getText();
     if (!array_key_exists($key, $this->modules)) {
         $text = $title->getContent();
         if ($text === false) {
             $this->modules[$key] = null;
             return null;
         }
         $this->modules[$key] = $this->newModule($text, $key);
     }
     return $this->modules[$key];
 }