Пример #1
0
 /**
  * Get list of Title objects representing existing boards
  *
  * @author Władysław Bodzek <*****@*****.**>
  *
  * @return array List of board IDs
  */
 public function getListTitles($db = DB_SLAVE, $namespace = NS_USER_WALL)
 {
     wfProfileIn(__METHOD__);
     $titles = TitleBatch::newFromConds('page_wikia_props', array('page.page_namespace' => $namespace, 'page_wikia_props.page_id = page.page_id'), __METHOD__, array('ORDER BY' => 'page_title'), $db);
     wfProfileOut(__METHOD__);
     return $titles;
 }
Пример #2
0
 public function getBoardList($db = DB_SLAVE)
 {
     $boardTitles = $this->getListTitles($db, NS_WIKIA_FORUM_BOARD);
     $titlesBatch = new TitleBatch($boardTitles);
     $orderIndexes = $titlesBatch->getWikiaProperties(WPP_WALL_ORDER_INDEX, $db);
     $boards = array();
     /** @var $title Title */
     foreach ($boardTitles as $title) {
         /** @var $board ForumBoard */
         $board = ForumBoard::newFromTitle($title);
         $title = $board->getTitle();
         $id = $title->getArticleID();
         $boardInfo = $board->getBoardInfo();
         $boardInfo['id'] = $title->getArticleID();
         $boardInfo['name'] = $title->getText();
         $boardInfo['description'] = $board->getDescriptionWithoutTemplates();
         $boardInfo['url'] = $title->getFullURL();
         $orderIndex = $orderIndexes[$id];
         $boards[$orderIndex] = $boardInfo;
     }
     krsort($boards);
     return $boards;
 }
Пример #3
0
 /**
  * Returns HTML for the "templates used on this page" list.
  *
  * @param $templates Array of templates from Article::getUsedTemplate
  * or similar
  * @param $preview Boolean: whether this is for a preview
  * @param $section Boolean: whether this is for a section edit
  * @return String: HTML output
  */
 public static function formatTemplates($templates, $preview = false, $section = false)
 {
     wfProfileIn(__METHOD__);
     $outText = '';
     if (count($templates) > 0) {
         # Do a batch existence check
         $batch = new LinkBatch();
         foreach ($templates as $title) {
             $batch->addObj($title);
         }
         $batch->execute();
         # Construct the HTML
         $outText = '<div class="mw-templatesUsedExplanation">';
         if ($preview) {
             $outText .= wfMsgExt('templatesusedpreview', array('parse'), count($templates));
         } elseif ($section) {
             $outText .= wfMsgExt('templatesusedsection', array('parse'), count($templates));
         } else {
             $outText .= wfMsgExt('templatesused', array('parse'), count($templates));
         }
         $outText .= "</div><ul>\n";
         // Wikia change - begin - @author: wladek
         // preload restrictions
         $titleBatch = new TitleBatch($templates);
         $titleBatch->loadRestrictions();
         // Wikia change - end
         usort($templates, array('Title', 'compare'));
         foreach ($templates as $titleObj) {
             $r = $titleObj->getRestrictions('edit');
             if (in_array('sysop', $r)) {
                 $protected = wfMsgExt('template-protected', array('parseinline'));
             } elseif (in_array('autoconfirmed', $r)) {
                 $protected = wfMsgExt('template-semiprotected', array('parseinline'));
             } else {
                 $protected = '';
             }
             if ($titleObj->quickUserCan('edit')) {
                 $editLink = self::link($titleObj, wfMsg('editlink'), array(), array('action' => 'edit'));
             } else {
                 $editLink = self::link($titleObj, wfMsg('viewsourcelink'), array(), array('action' => 'edit'));
             }
             $outText .= '<li>' . self::link($titleObj) . ' (' . $editLink . ') ' . $protected . '</li>';
         }
         $outText .= '</ul>';
     }
     wfProfileOut(__METHOD__);
     return $outText;
 }