Esempio n. 1
0
 /**
  * @return String Url where user can re-upload the file
  */
 public function getUploadUrl()
 {
     wfProfileIn(__METHOD__);
     if ($this->isVideo()) {
         $this->loadFile();
         $file = $this->getDisplayedFile();
         $uploadTitle = SpecialPage::getTitleFor('WikiaVideoAdd');
         $name = $file->getName();
         $url = $uploadTitle->getFullUrl(array('name' => $name));
     } else {
         $url = parent::getUploadUrl();
     }
     wfProfileOut(__METHOD__);
     return $url;
 }
 /**
  * Initializes required fields.
  */
 private function initFields()
 {
     if ($this->oUser === null) {
         throw new BsException(__METHOD__ . ' - No user specified.');
     }
     $this->sUserDisplayName = BsCore::getInstance()->getUserDisplayName($this->oUser);
     $sUserImage = $this->oUser->getOption('MW::UserImage', '');
     //BsConfig::get() won't work on first call
     //Is it a URL? Some external image?
     $aParsedUrl = parse_url($sUserImage);
     if (!empty($sUserImage) && ($sUserImage[0] == '/' || isset($aParsedUrl['scheme']))) {
         $this->sImageUploadPath = SpecialPage::getTitleFor('Preferences')->getLinkUrl();
         $aPathInfo = pathinfo($aParsedUrl['path']);
         $aFileExtWhitelist = array('gif', 'jpg', 'jpeg', 'png');
         $this->sImagePath = $aParsedUrl['scheme'] . '://' . $aParsedUrl['host'] . $aParsedUrl['path'];
         if (!in_array(strtolower($aPathInfo['extension']), $aFileExtWhitelist)) {
             $this->sImagePath = BsConfig::get('MW::AnonUserImage');
         }
         return;
     }
     $oUserImageFile = RepoGroup::singleton()->getLocalRepo()->newFile($sUserImage);
     if ($oUserImageFile) {
         $UserImageArticle = new ImagePage($oUserImageFile->getTitle());
         $this->sImageUploadPath = $UserImageArticle->getUploadUrl();
         if ($oUserImageFile->exists() === false) {
             $this->sImagePath = BsConfig::get('MW::DefaultUserImage');
         } else {
             $oUserThumbnail = $oUserImageFile->transform(array('width' => 64, 'height' => 64));
             if ($oUserThumbnail !== false) {
                 $this->sImagePath = $oUserThumbnail->getUrl();
             } else {
                 $this->sImagePath = $oUserImageFile->getUrl();
             }
         }
     } else {
         $this->sImagePath = BsConfig::get('MW::DefaultUserImage');
     }
 }