示例#1
0
 /**
  * @brief Filtring message wall data and spliting it to parents and childs
  *
  * @param Title $title title object instance
  * @param array $res a referance to array returned from recent changes
  *
  * @return array | boolean returns false if ArticleComment class does not exist
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 public function wikiActivityFilterMessageWall($title, &$res)
 {
     wfProfileIn(__METHOD__);
     $item = array();
     $item['type'] = 'new';
     $item['wall'] = true;
     $item['ns'] = $res['ns'];
     $item['timestamp'] = $res['timestamp'];
     $item['wall-comment'] = $res['rc_params']['intro'];
     $item['article-id'] = $title->getArticleID();
     $wmessage = new WallMessage($title);
     $parent = $wmessage->getTopParentObj();
     if (!in_array(true, array($wmessage->isAdminDelete(), $wmessage->isRemove()))) {
         $item['wall-title'] = $wmessage->getArticleTitle()->getPrefixedText();
         $owner = $wmessage->getWallOwner();
         $item['wall-owner'] = $owner->getName();
         $item['wall-msg'] = '';
         if (empty($parent)) {
             // parent
             $metaTitle = $wmessage->getMetaTitle();
             if (!empty($metaTitle)) {
                 $item['title'] = $metaTitle;
             } else {
                 $wmessage->load();
                 $metaTitle = $wmessage->getMetaTitle();
                 $item['title'] = empty($metaTitle) ? wfMessage('wall-no-title')->escaped() : $metaTitle;
             }
             $item['url'] = $wmessage->getMessagePageUrl();
             $res['title'] = 'message-wall-thread-#' . $title->getArticleID();
             $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse();
         } else {
             // child
             $parent->load();
             if (!in_array(true, array($parent->isRemove(), $parent->isAdminDelete()))) {
                 $title = wfMessage('wall-no-title')->escaped();
                 // in case metadata does not include title field
                 if (isset($parent->mMetadata['title'])) {
                     $title = $wmessage->getMetaTitle();
                 }
                 $this->mapParentData($item, $parent, $title);
                 $res['title'] = 'message-wall-thread-#' . $parent->getTitle()->getArticleID();
                 $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse();
             } else {
                 // message was removed or deleted
                 $item = array();
             }
         }
     } else {
         // message was removed or deleted
         $item = array();
     }
     wfRunHooks('AfterWallWikiActivityFilter', array(&$item, $wmessage));
     wfProfileOut(__METHOD__);
     return $item;
 }
 /**
  * Helper method which gets meta title from an WallMessage instance; used in WallHooksHelper::onDiffViewHeader() and WallHooksHelper::onPageHeaderEditPage()
  * @param Title $title
  * @param mixed $wmRef a variable which value will be created WallMessage instance
  *
  * @return String
  */
 private static function getMetatitleFromTitleObject($title, &$wmRef = null)
 {
     wfProfileIn(__METHOD__);
     $wm = new WallMessage($title);
     if ($wm instanceof WallMessage) {
         $wm->load();
         $metaTitle = $wm->getMetaTitle();
         if (empty($metaTitle)) {
             // if wall message is a reply
             $wmParent = $wm->getTopParentObj();
             if ($wmParent instanceof WallMessage) {
                 $wmParent->load();
                 if (!is_null($wmRef)) {
                     $wmRef = $wmParent;
                 }
                 wfProfileOut(__METHOD__);
                 return $wmParent->getMetaTitle();
             }
         }
         if (!is_null($wmRef)) {
             $wmRef = $wm;
         }
         wfProfileOut(__METHOD__);
         return $metaTitle;
     }
     wfProfileOut(__METHOD__);
     return '';
 }
 private function setMessageParentData($data, WallMessage $wm)
 {
     $acParent = $wm->getTopParentObj();
     if (empty($acParent)) {
         $this->threadTitleFull = $wm->getMetaTitle();
         $data->parent_id = null;
         $data->thread_title = $this->threadTitleFull;
         $data->parent_username = $data->wall_username;
     } else {
         $acParent->load();
         $title = $acParent->getTitle();
         $this->parentTitleDbKey = $title->getDBkey();
         $this->threadTitleFull = $acParent->getMetaTitle();
         $this->setMessageParentUserData($data, $acParent);
         $data->parent_id = $acParent->getId();
         $data->thread_title = $this->threadTitleFull;
     }
 }