/**
  * Main entry point for Special Pages
  *
  * @param[in] $query string  Given by MediaWiki
  */
 public function execute($query)
 {
     global $wgRequest, $wgOut, $smwgBrowseShowAll;
     $this->setHeaders();
     // get the GET parameters
     $this->articletext = $wgRequest->getVal('article');
     // @see SMWInfolink::encodeParameters
     if ($query === null && $this->getRequest()->getCheck('x')) {
         $query = $this->getRequest()->getVal('x');
     }
     // no GET parameters? Then try the URL
     if (is_null($this->articletext)) {
         $this->articletext = UrlEncoder::decode($query);
     }
     $this->subject = \SMW\DataValueFactory::getInstance()->newTypeIDValue('_wpg', $this->articletext);
     $offsettext = $wgRequest->getVal('offset');
     $this->offset = is_null($offsettext) ? 0 : intval($offsettext);
     $dir = $wgRequest->getVal('dir');
     if ($smwgBrowseShowAll) {
         $this->showoutgoing = true;
         $this->showincoming = true;
     }
     if ($dir === 'both' || $dir === 'in') {
         $this->showincoming = true;
     }
     if ($dir === 'in') {
         $this->showoutgoing = false;
     }
     if ($dir === 'out') {
         $this->showincoming = false;
     }
     $wgOut->addHTML($this->displayBrowse());
     SMWOutputs::commitToOutputPage($wgOut);
     // make sure locally collected output data is pushed to the output!
 }
 public function testEncodeDecode($input, $output)
 {
     // @codingStandardsIgnoreEnd
     if ($output === ' ') {
         $output = '';
     }
     $this->assertEquals($output, UrlEncoder::decode(UrlEncoder::encode(UrlEncoder::replace($output))));
 }
 private function decodeUriContext($context)
 {
     if ($this->m_mode !== SMW_URI_MODE_URI && $this->m_mode !== SMW_URI_MODE_ANNOURI) {
         return array($this->getURL(), $context);
     }
     // Prior to decoding turn any `-` into an internal representation to avoid
     // potential breakage
     return array(str_replace(' ', '_', $this->urlEncoder->decode(str_replace('-', '-2D', $this->getURL()))), $this->urlEncoder->decode(str_replace('-', '-2D', $context)));
 }
 public function baseTemplateToolboxDataProvider()
 {
     $specialName = str_replace('%3A', ':', \SMW\UrlEncoder::encode(\SpecialPage::getTitleFor('Browse')->getPrefixedText()));
     $provider = array();
     $provider[] = array($this->newBaseTemplateToolboxSetup('2013/11/05'), "{$specialName}/2013-2F11-2F05");
     $provider[] = array($this->newBaseTemplateToolboxSetup('2013-06-30'), "{$specialName}/2013-2D06-2D30");
     $provider[] = array($this->newBaseTemplateToolboxSetup('2013$06&30'), "{$specialName}/2013-2406-2630");
     $provider[] = array($this->newBaseTemplateToolboxSetup('2013\\Foo'), "{$specialName}/2013-5CFoo");
     return $provider;
 }
 /**
  * @since 2.1
  */
 public function initialize()
 {
     $params = explode('/', $this->queryString);
     reset($params);
     // Remove empty elements
     $params = array_filter($params, 'strlen');
     $property = isset($this->requestOptions['property']) ? $this->requestOptions['property'] : current($params);
     $value = isset($this->requestOptions['value']) ? $this->requestOptions['value'] : next($params);
     $property = $this->urlEncoder->decode($property);
     $value = str_replace(array('-25'), array('%'), $value);
     $this->property = PropertyValue::makeUserProperty($property);
     if (!$this->property->isValid()) {
         $this->propertyString = $property;
         $this->value = null;
         $this->valueString = $value;
     } else {
         $this->propertyString = $this->property->getWikiValue();
         $this->value = DataValueFactory::getInstance()->newPropertyObjectValue($this->property->getDataItem(), $this->urlEncoder->decode($value));
         $this->valueString = $this->value->isValid() ? $this->value->getWikiValue() : $value;
     }
     $this->setLimit();
     $this->setOffset();
     $this->setNearbySearch();
 }
 private function unescape($value, $escaped)
 {
     if ($this->value instanceof NumberValue) {
         $value = $escaped ? str_replace(array('-20', '-2D'), array(' ', '-'), $value) : $value;
         // Do not try to decode things like 1.2e-13
         // Signals that we don't want any precision limitation
         $this->value->setOption('no.displayprecision', true);
     } elseif ($this->value instanceof TelephoneUriValue) {
         $value = $escaped ? str_replace(array('-20', '-2D'), array(' ', '-'), $value) : $value;
         // No encoding to avoid turning +1-201-555-0123
         // into +1 1U523 or further obfuscate %2B1-2D201-2D555-2D0123 ...
     } else {
         $value = $escaped ? $this->urlEncoder->unescape($value) : $value;
     }
     return $value;
 }
 /**
  * @see SpecialPage::execute
  *
  * @param string $query string
  */
 public function execute($query)
 {
     $this->setHeaders();
     $webRequest = $this->getRequest();
     // get the GET parameters
     $articletext = $webRequest->getVal('article');
     $isEmptyRequest = $query === null && $webRequest->getVal('article') === '';
     // @see SMWInfolink::encodeParameters
     if ($query === null && $this->getRequest()->getCheck('x')) {
         $query = $this->getRequest()->getVal('x');
     }
     // no GET parameters? Then try the URL
     if ($articletext === null) {
         $articletext = UrlEncoder::decode($query);
     }
     $this->subjectDV = DataValueFactory::getInstance()->newTypeIDValue('_wpg', $articletext);
     $out = $this->getOutput();
     $out->setHTMLTitle($this->subjectDV->getTitle());
     $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.ui.button', 'mediawiki.ui.input'));
     $out->addModules(array('ext.smw.browse', 'ext.smw.tooltip'));
     $out->addHTML($this->getHtml($webRequest, $isEmptyRequest));
     $this->addExternalHelpLinks();
 }
 private function decodeUriContext($context)
 {
     // Prior to decoding turn any `-` into an internal representation to avoid
     // potential breakage
     if (!$this->showUrlContextInRawFormat) {
         $context = UrlEncoder::decode(str_replace('-', '-2D', $context));
     }
     return array($this->getURL(), $context);
 }
Exemple #9
0
 /**
  * @dataProvider urlDecodeProvider
  */
 public function testUrlDecode($string, $expected)
 {
     $this->assertEquals($expected, UrlEncoder::decode($string));
 }