Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coding style issues #899 in tests/ #926

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
130 changes: 65 additions & 65 deletions includes/ParameterInput.php
Expand Up @@ -9,54 +9,54 @@
/**
* Simple class to get a HTML input for the parameter.
* Usable for when creating a GUI from a parameter list.
*
*
* Based on 'addOptionInput' from Special:Ask in SMW 1.5.6.
*
*
* TODO: nicify HTML
*
*
* @since 1.9
*
*
* @ingroup SMW
*
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class ParameterInput {

/**
* The parameter to print an input for.
*
*
* @since 1.9
*
*
* @var ParamDefinition
*/
protected $param;

/**
* The current value for the parameter. When provided,
* it'll be used as value for the input, otherwise the
* parameters default value will be used.
*
*
* @since 1.9
*
*
* @var mixed: string or false
*/
protected $currentValue;

/**
* Name for the input.
*
*
* @since 1.9
*
*
* @var string
*/
protected $inputName;

/**
* Constructor.
*
*
* @since 1.9
*
*
* @param ParamDefinition $param
* @param mixed $currentValue
*/
Expand All @@ -65,34 +65,34 @@ public function __construct( ParamDefinition $param, $currentValue = false ) {
$this->inputName = $param->getName();
$this->param = $param;
}

/**
* Sets the current value.
*
*
* @since 1.9
*
*
* @param mixed $currentValue
*/
*/
public function setCurrentValue( $currentValue ) {
$this->currentValue = $currentValue;
}

/**
* Sets the name for the input; defaults to the name of the parameter.
*
*
* @since 1.9
*
*
* @param string $name
*/
public function setInputName( $name ) {
$this->inputName = $name;
}

/**
* Returns the HTML for the parameter input.
*
*
* @since 1.9
*
*
* @return string
*/
public function getHtml() {
Expand All @@ -102,7 +102,7 @@ public function getHtml() {
$valueList = $this->param->getAllowedValues();
}

if ( $valueList === array() ) {
if ( $valueList === array() ) {
switch ( $this->param->getType() ) {
case 'char':
case 'float':
Expand All @@ -118,38 +118,38 @@ public function getHtml() {
$html = $this->getStrInput();
break;
}
}
else {
}
else {
$html = $this->param->isList() ? $this->getCheckboxListInput( $valueList ) : $this->getSelectInput( $valueList );
}
return $html;
}

return $html;
}

/**
* Returns the value to initially display with the input.
*
*
* @since 1.9
*
*
* @return string
*/
protected function getValueToUse() {
$value = $this->currentValue === false ? $this->param->getDefault() : $this->currentValue;

if ( $this->param->isList() && is_array( $value ) ) {
$value = implode( $this->param->getDelimiter(), $value );
}

return $value;
}

/**
* Gets a short text input suitable for numbers.
*
*
* @since 1.9
*
*
* @return string
*/
*/
protected function getNumberInput() {
return Html::input(
$this->inputName,
Expand All @@ -161,14 +161,14 @@ protected function getNumberInput() {
)
);
}

/**
* Gets a text input for a string.
*
*
* @since 1.9
*
*
* @return string
*/
*/
protected function getStrInput() {
return Html::input(
$this->inputName,
Expand All @@ -180,39 +180,39 @@ protected function getStrInput() {
)
);
}

/**
* Gets a checkbox.
*
*
* @since 1.9
*
*
* @return string
*/
*/
protected function getBooleanInput() {
return Xml::check(
$this->inputName,
$this->getValueToUse()
);
}
}

/**
* Gets a select menu for the provided values.
*
*
* @since 1.9
*
*
* @param array $valueList
*
*
* @return string
*/
*/
protected function getSelectInput( array $valueList ) {
$options = array();
$options[] = '<option value=""></option>';

$currentValues = (array)$this->getValueToUse();
if ( is_null( $currentValues ) ) {
$currentValues = array();
}

foreach ( $valueList as $value ) {
$options[] =
'<option value="' . htmlspecialchars( $value ) . '"' .
Expand All @@ -228,14 +228,14 @@ protected function getSelectInput( array $valueList ) {
implode( "\n", $options )
);
}

/**
* Gets a list of input boxes for the provided values.
*
*
* @since 1.9
*
*
* @param array $valueList
*
*
* @return string
*/
protected function getCheckboxListInput( array $valueList ) {
Expand All @@ -245,7 +245,7 @@ protected function getCheckboxListInput( array $valueList ) {
if ( is_null( $currentValues ) ) {
$currentValues = array();
}

foreach ( $valueList as $value ) {
$boxes[] = Html::rawElement(
'span',
Expand All @@ -259,8 +259,8 @@ protected function getCheckboxListInput( array $valueList ) {
Html::element( 'tt', array(), $value )
);
}

return implode( "\n", $boxes );
}

}
14 changes: 7 additions & 7 deletions includes/SMW_Outputs.php
Expand Up @@ -40,15 +40,15 @@ class SMWOutputs {
* to the output.
*/
protected static $scripts = array();

/// Protected member for temporarily storing resource modules.
protected static $resourceModules = array();

/**
* Adds a resource module to the parser output.
*
*
* @since 1.5.3
*
*
* @param string $moduleName
*/
public static function requireResource( $moduleName ) {
Expand All @@ -60,17 +60,17 @@ public static function requireResource( $moduleName ) {
* enclosing script tags. Note that the same could be achieved with
* requireHeadItems, but scripts use a special method "addScript" in
* MediaWiki OutputPage, hence we distinguish them.
*
*
* The id is used to avoid that the requirement for one script is
* recorded multiple times in SMWOutputs.
*
*
* @param string $id
* @param string $item
*/
public static function requireScript( $id, $script ) {
self::$scripts[$id] = $script;
}

/**
* Adds head items that are not Resource Loader modules. Should only
* be used for custom head items such as RSS fedd links.
Expand All @@ -80,7 +80,7 @@ public static function requireScript( $id, $script ) {
*
* Support for calling this with the old constants SMW_HEADER_STYLE
* and SMW_HEADER_TOOLTIP will vanish in SMW 1.7 at the latest.
*
*
* @param mixed $id
* @param string $item
*/
Expand Down
16 changes: 8 additions & 8 deletions includes/SMW_PageLister.php
Expand Up @@ -10,9 +10,9 @@
* different places where similar lists are used.
*
* Some code adapted from CategoryPage.php
*
*
* @ingroup SMW
*
*
* @author Nikolas Iwan
* @author Markus Krötzsch
* @author Jeroen De Dauw
Expand Down Expand Up @@ -96,7 +96,7 @@ public function getNavigationLinks( Title $title, $query = array() ) {

/**
* Format an HTML link with the given text and parameters.
*
*
* @return string
*/
protected function makeSelfLink( Title $title, $linkText, array $parameters ) {
Expand Down Expand Up @@ -199,17 +199,17 @@ public function formatList( $cutoff = 6 ) {
/**
* Format a list of SMWDIWikiPage objects chunked by letter in a three-column
* list, ordered vertically.
*
*
* @param $start integer
* @param $end integer
* @param $diWikiPages array of SMWDIWikiPage
* @param $diProperty SMWDIProperty that the wikipages are values of, or null
*
*
* @return string
*/
public static function getColumnList( $start, $end, array $diWikiPages, $diProperty ) {
global $wgContLang;

// Divide list into three equal chunks.
$chunk = (int) ( ( $end - $start + 1 ) / 3 );

Expand Down Expand Up @@ -268,12 +268,12 @@ public static function getColumnList( $start, $end, array $diWikiPages, $diPrope

/**
* Format a list of diWikiPages chunked by letter in a bullet list.
*
*
* @param $start integer
* @param $end integer
* @param $diWikiPages array of SMWDataItem
* @param $diProperty SMWDIProperty that the wikipages are values of, or null
*
*
* @return string
*/
public static function getShortList( $start, $end, array $diWikiPages, $diProperty ) {
Expand Down