/** * 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]; } }
public function execute() { global $wgUser; if (!$wgUser->isAllowed('semanticwatchgroups') || $wgUser->isBlocked()) { $this->dieUsageMsg(array('badaccess-groups')); } $params = $this->extractRequestParams(); $group = new SWLGroup(null, $params['name'], $params['categories'], $params['namespaces'], $params['properties'], $params['concepts']); $this->getResult()->addValue(null, 'success', $group->writeToDB()); $this->getResult()->addValue('group', 'id', $group->getId()); $this->getResult()->addValue('group', 'name', $group->getName()); }
/** * 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())); }