/** * Main method. * * @since 0.1 * * @param string $arg */ public function execute($arg) { global $wgOut, $wgUser, $wgRequest; $this->setHeaders(); $this->outputHeader(); // If the user is authorized, display the page, if not, show an error. if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); return; } $groupsHtml = array(); foreach (SWLGroups::getAll() as $group) { $groupsHtml[] = $this->getGroupHtml($group); } $wgOut->addHTML('<div id="swl-groups">' . implode('', $groupsHtml) . '</div>'); $wgOut->addHTML(Html::rawElement('fieldset', array(), Html::element('legend', array(), wfMsg('swl-group-add-new-group')) . Html::element('span', array(), wfMsg('swl-group-name')) . ' ' . Html::element('input', array('type' => 'text', 'value' => '', 'id' => 'swl-add-group-name')) . ' ' . Html::element('input', array('type' => 'button', 'value' => wfMsg('swl-group-add-group'), 'id' => 'swl-add-group-button')))); $wgOut->addHTML(Html::element('input', array('type' => 'button', 'value' => wfMsg('swl-group-save-all'), 'id' => 'swl-save-all'))); $wgOut->addModules('ext.swl.watchlistconditions'); }
/** * Main method. * * @since 0.1 * * @param string $arg */ public function execute($arg) { global $wgOut, $wgUser; $this->setHeaders(); $this->outputHeader(); // If the user is authorized, display the page, if not, show an error. if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); return; } $wgOut->addHTML('<strong><p class="saveMessage" style=" display:none;width: 100px; alight:center;text-align:center; background: #f9f9aa; border: 1px solid #dd9">' . $this->msg('swl-group-saved')->text() . '</p></strong>'); $groupsHtml = array(); foreach (SWLGroups::getAll() as $group) { $groupsHtml[] = $this->getGroupHtml($group); } $wgOut->addHTML('<div id="swl-groups">' . implode('', $groupsHtml) . '</div>'); $wgOut->addHTML("<p>" . Html::element('input', array('type' => 'button', 'value' => $this->msg('swl-group-add-group')->text(), 'id' => 'swl-add-group-button')) . "</p>\n"); $wgOut->addHTML("<p>" . Html::element('input', array('type' => 'button', 'value' => $this->msg('swl-group-save')->text(), 'id' => 'swl-save-all')) . "</p>\n"); $wgOut->addModules('ext.swl.watchlistconditions'); }
/** * Adds the preferences of Semantic Watchlist to the list of available ones. * * @since 0.1 * * @param User $user * @param array $preferences * * @return true */ public static function onGetPreferences( User $user, array &$preferences ) { $groups = SWLGroups::getAll(); // Only show the email notification preference when email notifications are enabled. if ( $GLOBALS['egSWLEnableEmailNotify'] ) { $preferences['swl_email'] = array( 'type' => 'toggle', 'label-message' => 'swl-prefs-emailnofity', 'section' => 'swl/swlglobal', ); } // Only show the top link preference when it's enabled. if ( $GLOBALS['egSWLEnableTopLink'] ) { $preferences['swl_watchlisttoplink'] = array( 'type' => 'toggle', 'label-message' => 'swl-prefs-watchlisttoplink', 'section' => 'swl/swlglobal', ); } foreach ( $groups as /* SWLGroup */ $group ) { if ( count( $group->getProperties() ) == 0 ) { continue; } switch ( true ) { case count( $group->getCategories() ) > 0 : $type = 'category'; $name = $group->getCategories(); $name = $name[0]; break; case count( $group->getNamespaces() ) > 0 : $type = 'namespace'; $name = $group->getNamespaces(); $name = $name[0] == 0 ? wfMsg( 'main' ) : MWNamespace::getCanonicalName( $name[0] ); break; case count( $group->getConcepts() ) > 0 : $type = 'concept'; $name = $group->getConcepts(); $name = $name[0]; break; } $properties = $group->getProperties(); foreach ( $properties as &$property ) { $property = "''$property''"; } $preferences['swl_watchgroup_' . $group->getId()] = array( 'type' => 'toggle', 'label' => wfMsgExt( "swl-prefs-$type-label", 'parseinline', $group->getName(), count( $group->getProperties() ), $GLOBALS['wgLang']->listToText( $properties ), $name ), 'section' => 'swl/swlgroup', ); } return true; }
protected function getAllSwlGroups() { return \SWLGroups::getAll(); }