/**
  * Creates and returns the HTML for a single watchlist group.
  *
  * @since 0.1
  *
  * @param SWLGroup $group
  *
  * @return string
  */
 protected function getGroupHtml(SWLGroup $group)
 {
     $namespaces = $group->getNamespaces();
     foreach ($namespaces as &$ns) {
         $ns = $ns == 0 ? 'Main' : MWNamespace::getCanonicalName($ns);
     }
     return Html::rawElement('fieldset', array('id' => 'swl_group_' . $group->getId(), 'groupid' => $group->getId(), 'class' => 'swl_group', 'groupname' => $group->getName(), 'categories' => implode('|', $group->getCategories()), 'namespaces' => implode('|', $namespaces), 'properties' => implode('|', $group->getProperties()), 'concepts' => implode('|', $group->getConcepts()), 'customTexts' => implode('|', $group->getSerializedCustomTexts())), Html::element('legend', array(), $this->msg('swl-group-legend')->text()));
 }
Ejemplo n.º 2
0
 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('semanticwatchgroups') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $group = new SWLGroup($params['id'], $params['name'], $params['categories'], $params['namespaces'], $params['properties'], $params['concepts']);
     $this->getResult()->addValue(null, 'success', $group->writeToDB());
 }
 /**
  * Sets an array of CustomTexts by reading from the db
  * for this group.
  *
  * @since 0.2
  */
 protected function initCustomTexts()
 {
     if (!is_null($this->customTexts)) {
         return;
     }
     $this->customTexts = array();
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow('swl_groups', 'group_custom_texts', array('group_name' => $this->group->getName()), 'SWL::initCustomTexts');
     $set = explode('|', $row->group_custom_texts);
     foreach ($set as $elem) {
         $parts = explode('~', $elem);
         if (!array_key_exists($parts[0], $this->customTexts)) {
             $this->customTexts[$parts[0]] = array();
         }
         $this->customTexts[$parts[0]][$parts[1]] = $parts[2];
     }
 }
Ejemplo n.º 4
0
 /**
  * Returns all watchlist groups.
  *
  * @since 0.1
  *
  * @return array of SWLGroup
  */
 public static function getAll()
 {
     if (self::$groups === false) {
         self::$groups = array();
         $dbr = wfGetDB(DB_SLAVE);
         $groups = $dbr->select('swl_groups', array('group_id', 'group_name', 'group_categories', 'group_namespaces', 'group_properties', 'group_concepts'));
         foreach ($groups as $group) {
             self::$groups[] = SWLGroup::newFromDBResult($group);
         }
     }
     return self::$groups;
 }