コード例 #1
0
 /**
  * factory method, create either Item or List object from title
  *
  * @author ADi
  * @param Title $title
  * @return TopListBase
  */
 public static function newFromTitle(Title $title)
 {
     $object = null;
     if ($title->getNamespace() == NS_TOPLIST) {
         if (!$title->isSubpage()) {
             $object = TopList::newFromTitle($title);
         } else {
             $object = TopListItem::newFromTitle($title);
         }
     }
     return $object;
 }
コード例 #2
0
 /**
  * Add a vote for the item
  *
  * @author ADi
  *
  */
 public static function voteItem()
 {
     global $wgRequest;
     $result = array('result' => false);
     $titleText = $wgRequest->getVal('title');
     if (!empty($titleText)) {
         $item = TopListItem::newFromText($titleText);
         if ($item instanceof TopListItem && $item->getList() instanceof TopList && $item->getList()->exists() && $item->getList()->userCanVote()) {
             $result['result'] = $item->vote();
             $result['votedId'] = $item->getTitle()->getSubpageText();
             $result['message'] = wfMsg('toplists-list-item-voted');
             $result['listBody'] = TopListParser::parse($item->getList());
         }
     }
     $json = json_encode($result);
     $response = new AjaxResponse($json);
     $response->setContentType('application/json; charset=utf-8');
     return $response;
 }
コード例 #3
0
ファイル: TopList.class.php プロジェクト: Tjorriemorrie/app
 /**
  * @author ADi
  */
 public function removeItems()
 {
     foreach ($this->mTitle->getSubpages() as $subpageTitle) {
         $item = TopListItem::newFromTitle($subpageTitle);
         $item->remove();
     }
 }