function newAttachmentData($id)
 {
     $obj = $this->cacheManager->retrieveAtachmentData($id);
     if ($obj instanceof \PageAttachment\Attachment\AttachmentData) {
         $pageAttachmentData = $obj;
     } else {
         $title = \Title::newFromID($id);
         $article = new \Article($title, NS_FILE);
         $file = \wfFindFile($title);
         $size = $file->getSize();
         $description = $this->replaceHtmlTags($file->getDescriptionText());
         $dateUploaded = $article->getTimestamp();
         $uploadedBy = null;
         if ($this->runtimeConfig->isShowUserRealName()) {
             $uploadedBy = \User::whoIsReal($article->getUser());
         }
         if ($uploadedBy == null) {
             $uploadedBy = \User::whoIs($article->getUser());
         }
         $attachedToPages = null;
         if ($this->securityManager->isRemoveAttachmentPermanentlyEnabled()) {
             $attachedToPages = $this->getAttachedToPages($id);
         }
         $pageAttachmentData = new AttachmentData($id, $title, $size, $description, $dateUploaded, $uploadedBy, $attachedToPages);
         $this->cacheManager->storeAttachmentData($pageAttachmentData);
     }
     return $pageAttachmentData;
 }
Example #2
0
 public function update(Article $article)
 {
     $id = $article->getId();
     $content = mysqli_real_escape_string($article->getContent());
     $id_author = $article->getUser()->getId();
     $query = "UPDATE article SET content='" . $content . "', id_user='******' WHERE id='" . $id . "'";
     $res = mysqli_query($this->db, $query);
     if ($res) {
         return $this->findById($id);
     } else {
         return "Internal Server Error";
     }
 }
Example #3
0
 /**
  * Get the last author with the last modification time
  * @param $article Article object
  */
 protected static function getAuthor(Article $article)
 {
     global $wgLang, $wgAllowRealName;
     $user = User::newFromId($article->getUser());
     $timestamp = $article->getTimestamp();
     if ($timestamp) {
         $d = $wgLang->date($article->getTimestamp(), true);
         $t = $wgLang->time($article->getTimestamp(), true);
     } else {
         $d = '';
         $t = '';
     }
     return wfMsg('lastmodifiedatby', $d, $t, self::userLink($user));
 }