/** * Updates topics list to given message id. It will completely override. * @param string $messageId - numeric id * @param array $relatedTopics - list of topics (article names) * @return string status - success/failure */ public function updateTopics() { $messageId = $this->request->getVal('msgid', ''); $relatedTopics = $this->request->getVal('relatedTopics', array()); // place holder data, replace this with magic $status = 'success'; $topics = array(); if (!is_array($relatedTopics)) { $relatedTopics = array(); } // cut more then 4 $relatedTopics = array_slice($relatedTopics, 0, 4); // save /** * @var $mw WallMessage */ $mw = WallMessage::newFromId($messageId); if (!empty($mw)) { $mw->load(); $mw->setRelatedTopics($this->wg->User, $relatedTopics); } foreach ($relatedTopics as $topic) { $topicTitle = Title::newFromURL($topic); $topics[] = array('topic' => $topic, 'url' => WallHelper::getTopicPageURL($topicTitle)); // I have no idea what the url will be, just a placeholder for now } // end place holder $this->response->setVal('status', $status); $this->response->setVal('topics', $topics); }
<h4 class="related-topics-heading"><?php echo wfMsg('wall-topic-heading'); ?> </h4> <ul class="related-topics"> <?php foreach ($relatedTopics as $val) { ?> <li class="related-topic" data-topic="<?php echo $val->getText(); ?> "> <a href="<?php echo WallHelper::getTopicPageURL($val); ?> "> <?php echo $val->getText(); ?> </a> </li> <?php } ?> <script id="RelatedTopicTemplate" type="text/template"> {{#topics}} <li class="related-topic" data-topic="{{topic}}"> <a href="{{url}}"> {{topic}} </a> </li>