http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98085
Revision: 98085
Author: jeroendedauw
Date: 2011-09-25 22:02:25 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
migrate param handling
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_JSONlink.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
2011-09-25 21:24:39 UTC (rev 98084)
+++
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
2011-09-25 22:02:25 UTC (rev 98085)
@@ -24,10 +24,6 @@
protected $mUserParam;
protected $mNumColumns;
- public function __construct( $format, $inline, $useValidator = true ) {
- parent::__construct( $format, $inline, $useValidator );
- }
-
/**
* @see SMWResultPrinter::handleParameters
*
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
2011-09-25 21:24:39 UTC (rev 98084)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
2011-09-25 22:02:25 UTC (rev 98085)
@@ -17,11 +17,6 @@
protected $separator = ':';
protected $fileName = 'result.dsv';
- public function __construct( $format, $inline, $useValidator = true ) {
- parent::__construct( $format, $inline );
- $this->useValidator = $useValidator;
- }
-
/**
* @see SMWResultPrinter::handleParameters
*
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php
2011-09-25 21:24:39 UTC (rev 98084)
+++
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Embedded.php
2011-09-25 22:02:25 UTC (rev 98085)
@@ -22,11 +22,19 @@
protected $m_showhead;
protected $m_embedformat;
- protected function readParameters( $params, $outputmode ) {
- parent::readParameters( $params, $outputmode );
-
- $this->m_showhead = !array_key_exists( 'embedonly', $params );
- $this->m_embedformat = array_key_exists( 'embedformat', $params
) ? trim( $params['embedformat'] ) : 'h1';
+ /**
+ * @see SMWResultPrinter::handleParameters
+ *
+ * @since 1.6.3
+ *
+ * @param array $params
+ * @param $outputmode
+ */
+ protected function handleParameters( array $params, $outputmode ) {
+ parent::handleParameters( $params, $outputmode );
+
+ $this->m_showhead = !$params['embedonly'];
+ $this->m_embedformat = $params['embedformat'];
}
public function getName() {
@@ -101,7 +109,7 @@
$format = ( $this->m_embedformat == 'ol' ) ?
'ul':$this->m_embedformat;
$link->setParameter( $format, 'embedformat' );
if ( !$this->m_showhead ) {
- $link->setParameter( '1', 'embedonly' );
+ $link->setParameter( 'on', 'embedonly' );
}
$result .= $embstart . $link->getText( SMW_OUTPUT_WIKI,
$this->mLinker ) . $embend;
}
@@ -115,11 +123,12 @@
$params['embedformat'] = new Parameter( 'embedformat' );
$params['embedformat']->setMessage( 'smw_paramdesc_embedformat'
);
- $params['embedformat']->setDefault( '' );
+ $params['embedformat']->setDefault( 'h1' );
+ $params['embedformat']->addCriteria( new CriterionInArray(
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul' ) );
$params['embedonly'] = new Parameter( 'embedonly',
Parameter::TYPE_BOOLEAN );
$params['embedonly']->setMessage( 'smw_paramdesc_embedonly' );
- $params['embedonly']->setDefault( '' );
+ $params['embedonly']->setDefault( false, false );
return $params;
}
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_JSONlink.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_JSONlink.php
2011-09-25 21:24:39 UTC (rev 98084)
+++
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_JSONlink.php
2011-09-25 22:02:25 UTC (rev 98085)
@@ -117,8 +117,8 @@
$items = "\"items\": [\n\t" . implode( ",\n\t",
$itemstack ) . "\n\t]";
// check whether a callback function is required
- if ( array_key_exists( 'callback', $this->m_params ) ) {
- $result = htmlspecialchars(
$this->m_params['callback'] ) . "({\n\t" . $properties . ",\n\t" . $items .
"\n})";
+ if ( array_key_exists( 'callback', $this->params ) ) {
+ $result = htmlspecialchars(
$this->params['callback'] ) . "({\n\t" . $properties . ",\n\t" . $items .
"\n})";
} else {
$result = "{\n\t" . $properties . ",\n\t" .
$items . "\n}";
}
@@ -132,16 +132,16 @@
}
$link = $res->getQueryLink( $label );
- if ( array_key_exists( 'callback', $this->m_params ) ) {
- $link->setParameter( htmlspecialchars(
$this->m_params['callback'] ), 'callback' );
+ if ( array_key_exists( 'callback', $this->params ) ) {
+ $link->setParameter( htmlspecialchars(
$this->params['callback'] ), 'callback' );
}
if ( $this->getSearchLabel( SMW_OUTPUT_WIKI ) != '' ) {
// used as a file name
$link->setParameter( $this->getSearchLabel(
SMW_OUTPUT_WIKI ), 'searchlabel' );
}
- if ( array_key_exists( 'limit', $this->m_params ) ) {
- $link->setParameter( htmlspecialchars(
$this->m_params['limit'] ), 'limit' );
+ if ( array_key_exists( 'limit', $this->params ) ) {
+ $link->setParameter( htmlspecialchars(
$this->params['limit'] ), 'limit' );
}
$link->setParameter( 'json', 'format' );
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php
===================================================================
---
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php
2011-09-25 21:24:39 UTC (rev 98084)
+++
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php
2011-09-25 22:02:25 UTC (rev 98085)
@@ -26,12 +26,19 @@
abstract class SMWResultPrinter {
/**
- * List of parameters, set by readParameters (which is deprecated)
- * and can be used to store parameters in readParameters.
+ * @deprecated Use $params instead
+ */
+ protected $m_params;
+
+ /**
+ * List of parameters, set by handleParameters.
+ * param name (lower case, trimmed) => param value (mixed)
*
+ * @since 1.6.3
+ *
* @var array
*/
- protected $m_params;
+ protected $params;
/**
* Text to print *before* the output in case it is *not* empty; assumed
to be wikitext.
@@ -288,7 +295,7 @@
* @param $outputmode
*/
protected function handleParameters( array $params, $outputmode ) {
- $this->m_params = $params;
+ $this->params = $params;
if ( array_key_exists( 'intro', $params ) ) { $this->mIntro =
$params['intro']; }
if ( array_key_exists( 'outro', $params ) ) { $this->mOutro =
$params['outro']; }
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs