Ejemplo n.º 1
0
 public function save()
 {
     MessageForm::save();
     if ($this->time != '') {
         $dateTime = \DateTime::createFromFormat("Y-m-d H:i", $this->time, WCF::getUser()->getTimeZone());
     }
     $data = array('subject' => $this->subject, 'message' => $this->text, 'teaser' => $this->teaser, 'time' => $this->time != '' ? $dateTime->getTimestamp() : TIME_NOW, 'enableBBCodes' => $this->enableBBCodes, 'showSignature' => $this->showSignature, 'enableHtml' => $this->enableHtml, 'imageID' => $this->imageID ?: null, 'enableSmilies' => $this->enableSmilies, 'lastChangeTime' => TIME_NOW, 'isDisabled' => $this->time != '' && $dateTime->getTimestamp() > TIME_NOW ? 1 : 0, 'lastEditor' => WCF::getUser()->username, 'lastEditorID' => WCF::getUser()->userID);
     $newsData = array('data' => $data, 'categoryIDs' => $this->categoryIDs, 'tags' => $this->tags, 'attachmentHandler' => $this->attachmentHandler);
     $action = new NewsAction(array($this->newsID), 'update', $newsData);
     $resultValues = $action->executeAction();
     $this->saved();
     // re-define after saving
     $this->news = new News($this->newsID);
     if (WCF::getSession()->getPermission('user.cms.news.canStartPoll') && MODULE_POLL) {
         $pollID = PollManager::getInstance()->save($this->news->newsID);
         if ($pollID && $pollID != $this->news->pollID) {
             $editor = new NewsEditor($this->news);
             $editor->update(array('pollID' => $pollID));
         } else {
             if (!$pollID && $this->news->pollID) {
                 $editor = new NewsEditor($this->news);
                 $editor->update(array('pollID' => null));
             }
         }
     }
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news)));
     exit;
 }
 public function execute(Cronjob $cronjob)
 {
     parent::execute($cronjob);
     $list = new NewsList();
     $list->getConditionBuilder()->add('isDisabled = ?', array(1));
     $list->getConditionBuilder()->add('time <= ?', array(TIME_NOW));
     $list->readObjects();
     $list = $list->getObjects();
     $action = new NewsAction($list, 'publish');
     $action->executeAction();
 }
Ejemplo n.º 3
0
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!empty($additionalData['languageCode'])) {
         if (($language = LanguageFactory::getInstance()->getLanguageByCode($additionalData['languageCode'])) !== null) {
             $data['languageID'] = $language->languageID;
         }
     }
     if (is_numeric($oldID)) {
         $news = new News($oldID);
         if (!$news->newsID) {
             $data['newsID'] = $oldID;
         }
     }
     // save categories
     $categoryIDs = array();
     if (!empty($additionalData['categories'])) {
         foreach ($additionalData['categories'] as $oldCategoryID) {
             $newCategoryID = ImportHandler::getInstance()->getNewID('de.codequake.cms.category.news', $oldCategoryID);
             if ($newCategoryID) {
                 $categoryIDs[] = $newCategoryID;
             }
         }
     }
     if (empty($categoryIDs)) {
         $categoryIDs[] = $this->getImportCategoryID();
     }
     $action = new NewsAction(array(), 'create', array('data' => $data, 'categoryIDs' => $categoryIDs));
     $returnValues = $action->executeAction();
     $newID = $returnValues['returnValues']->newsID;
     $news = new News($newID);
     // save tags
     if (!empty($additionalData['tags'])) {
         TagEngine::getInstance()->addObjectTags('de.codequake.cms.news', $news->newsID, $additionalData['tags'], $news->languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID());
     }
     ImportHandler::getInstance()->saveNewID('de.codequake.cms.news', $oldID, $news->newsID);
     return $news->newsID;
 }
Ejemplo n.º 4
0
 public function readData()
 {
     parent::readData();
     VisitCountHandler::getInstance()->count();
     WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.page.news'), LinkHandler::getInstance()->getLink('NewsCategoryList', array('application' => 'cms'))));
     $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.codequake.cms.news.comment');
     $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor();
     $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->newsID);
     $newsEditor = new NewsEditor($this->news->getDecoratedObject());
     $newsEditor->update(array('clicks' => $this->news->clicks + 1));
     // get Tags
     if (MODULE_TAGGING) {
         $this->tags = $this->news->getTags();
     }
     if ($this->news->teaser != '') {
         MetaTagHandler::getInstance()->addTag('description', 'description', $this->news->teaser);
     } else {
         MetaTagHandler::getInstance()->addTag('description', 'description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())));
     }
     if (!empty($this->tags)) {
         MetaTagHandler::getInstance()->addTag('keywords', 'keywords', implode(',', $this->tags));
     }
     MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->news->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true);
     MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news->getDecoratedObject())), true);
     MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true);
     if ($this->news->getImage() != null) {
         MetaTagHandler::getInstance()->addTag('og:image', 'og:image', $this->news->getImage()->getLink(), true);
     }
     if ($this->news->getUserProfile()->facebook != '') {
         MetaTagHandler::getInstance()->addTag('article:author', 'article:author', 'https://facebook.com/' . $this->news->getUserProfile()->facebook, true);
     }
     if (FACEBOOK_PUBLIC_KEY != '') {
         MetaTagHandler::getInstance()->addTag('fb:app_id', 'fb:app_id', FACEBOOK_PUBLIC_KEY, true);
     }
     MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())), true);
     if ($this->news->isNew()) {
         $newsAction = new NewsAction(array($this->news->getDecoratedObject()), 'markAsRead', array('viewableNews' => $this->news));
         $newsAction->executeAction();
     }
     // fetch likes
     if (MODULE_LIKE) {
         $objectType = LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews');
         LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->newsID));
         $this->likeData = LikeHandler::getInstance()->getLikeObjects($objectType);
     }
 }