/** * @see SpecialPage::execute */ public function execute($query) { if (!$this->userCanExecute($this->getUser())) { // $this->mRestriction is private MW 1.23- throw new ExtendedPermissionsError('smw-admin', array('smw-smwadmin-permission-missing')); } $output = $this->getOutput(); $output->setPageTitle(Message::get('smwadmin', Message::TEXT, Message::USER_LANGUAGE)); $applicationFactory = ApplicationFactory::getInstance(); $mwCollaboratorFactory = $applicationFactory->newMwCollaboratorFactory(); $htmlFormRenderer = $mwCollaboratorFactory->newHtmlFormRenderer($this->getContext()->getTitle(), $this->getLanguage()); $store = $applicationFactory->getStore(); $connection = $store->getConnection('mw.db'); $outputFormatter = new OutputFormatter($output); $dataRepairSection = new DataRepairSection($connection, $htmlFormRenderer, $outputFormatter); $dataRepairSection->enabledRefreshStore($applicationFactory->getSettings()->get('smwgAdminRefreshStore')); $linkSection = new LinkSection($htmlFormRenderer, $outputFormatter); $tableSchemaUpdaterSection = new TableSchemaUpdaterSection($store, $htmlFormRenderer, $outputFormatter); $tableSchemaUpdaterSection->enabledSetupStore($applicationFactory->getSettings()->get('smwgAdminSetupStore')); $idHandlerSection = new IdHandlerSection($connection, $htmlFormRenderer, $outputFormatter); $idHandlerSection->enabledIdDisposal($applicationFactory->getSettings()->get('smwgAdminIdDisposal')); $supportSection = new SupportSection($htmlFormRenderer); // Actions switch ($this->getRequest()->getText('action')) { case 'settings': return $linkSection->outputConfigurationList(); case 'stats': return $linkSection->outputStatistics(); case 'updatetables': return $tableSchemaUpdaterSection->doUpdate($this->getRequest()); case 'idlookup': return $idHandlerSection->outputActionForm($this->getRequest(), $this->getUser()); case 'refreshstore': return $dataRepairSection->doRefresh($this->getRequest()); } // General intro $html = Message::get('smw_smwadmin_docu', Message::TEXT, Message::USER_LANGUAGE); $html .= $tableSchemaUpdaterSection->getForm(); $html .= $dataRepairSection->getForm(); $html .= $linkSection->getForm(); $html .= $supportSection->getForm(); $output->addHTML($html); }
public function testOutputActionFormWithId() { $manualEntryLogger = $this->getMockBuilder('\\SMW\\MediaWiki\\ManualEntryLogger')->disableOriginalConstructor()->getMock(); $manualEntryLogger->expects($this->once())->method('log'); $this->testEnvironment->registerObject('ManualEntryLogger', $manualEntryLogger); $entityIdDisposerJob = $this->getMockBuilder('\\SMW\\MediaWiki\\Jobs\\EntityIdDisposerJob')->disableOriginalConstructor()->getMock(); $jobFactory = $this->getMockBuilder('\\SMW\\MediaWiki\\Jobs\\JobFactory')->disableOriginalConstructor()->getMock(); $jobFactory->expects($this->atLeastOnce())->method('newEntityIdDisposerJob')->will($this->returnValue($entityIdDisposerJob)); $this->testEnvironment->registerObject('JobFactory', $jobFactory); $methods = array('setName', 'setMethod', 'addHiddenField', 'addHeader', 'addParagraph', 'addInputField', 'addSubmitButton', 'addNonBreakingSpace', 'addCheckbox'); foreach ($methods as $method) { $this->htmlFormRenderer->expects($this->any())->method($method)->will($this->returnSelf()); } $this->htmlFormRenderer->expects($this->atLeastOnce())->method('getForm'); $user = $this->getMockBuilder('\\User')->disableOriginalConstructor()->getMock(); $webRequest = $this->getMockBuilder('\\WebRequest')->disableOriginalConstructor()->getMock(); $webRequest->expects($this->at(0))->method('getText')->with($this->equalTo('id'))->will($this->returnValue(42)); $webRequest->expects($this->at(1))->method('getText')->with($this->equalTo('dispose'))->will($this->returnValue('yes')); $webRequest->expects($this->at(2))->method('getText')->with($this->equalTo('action'))->will($this->returnValue('idlookup')); $instance = new IdHandlerSection($this->connection, $this->htmlFormRenderer, $this->outputFormatter); $instance->enabledIdDisposal(true); $instance->outputActionForm($webRequest, $user); }