@@ -25,22 +25,22 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function execute() { |
| 27 | 27 | |
| 28 | - $parser = new Parser( $GLOBALS['wgParserConf'] ); |
|
| 29 | - $parser->setTitle( Title::newFromText( 'NO TITLE' ) ); |
|
| 28 | + $parser = new Parser($GLOBALS['wgParserConf']); |
|
| 29 | + $parser->setTitle(Title::newFromText('NO TITLE')); |
|
| 30 | 30 | $parser->mOptions = new ParserOptions(); |
| 31 | 31 | $parser->mOutput = new ParserOutput(); |
| 32 | 32 | |
| 33 | - $apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor( $parser ); |
|
| 34 | - $apiRequestProcessor->setDebugFlag( $GLOBALS['wgSF_Select_debug'] ); |
|
| 33 | + $apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor($parser); |
|
| 34 | + $apiRequestProcessor->setDebugFlag($GLOBALS['wgSF_Select_debug']); |
|
| 35 | 35 | |
| 36 | 36 | $resultValues = $apiRequestProcessor->getJsonDecodedResultValuesForRequestParameters( |
| 37 | 37 | $this->extractRequestParams() |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $result = $this->getResult(); |
| 41 | - $result->setIndexedTagName( $resultValues->values, 'value' ); |
|
| 42 | - $result->addValue( $this->getModuleName(), 'values', $resultValues->values ); |
|
| 43 | - $result->addValue( $this->getModuleName(), 'count', $resultValues->count ); |
|
| 41 | + $result->setIndexedTagName($resultValues->values, 'value'); |
|
| 42 | + $result->addValue($this->getModuleName(), 'values', $resultValues->values); |
|
| 43 | + $result->addValue($this->getModuleName(), 'count', $resultValues->count); |
|
| 44 | 44 | |
| 45 | 45 | return true; |
| 46 | 46 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @see ApiBase::getVersion |
| 89 | 89 | */ |
| 90 | 90 | public function getVersion() { |
| 91 | - return __CLASS__ . ': 1.1'; |
|
| 91 | + return __CLASS__.': 1.1'; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | private $mValues = null; |
| 22 | 22 | private $mHasStaticValues = false; |
| 23 | 23 | |
| 24 | - private $mData = []; # array with all parameters |
|
| 24 | + private $mData = []; # array with all parameters |
|
| 25 | 25 | private $mQuery = ""; |
| 26 | 26 | private $mFunction = ""; |
| 27 | 27 | private $mSelectIsMultiple = false; |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | private $mLabel = false; |
| 34 | 34 | private $mDelimiter = ","; |
| 35 | 35 | |
| 36 | - public function __construct( & $parser ) {
|
|
| 36 | + public function __construct(& $parser) {
|
|
| 37 | 37 | $this->mParser = $parser; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Convenience function to process all parameters at once |
| 42 | 42 | */ |
| 43 | - public function processParameters( $input_name = "", $other_args ) {
|
|
| 44 | - if ( array_key_exists( "query", $other_args ) ) {
|
|
| 45 | - $this->setQuery( $other_args ); |
|
| 46 | - } elseif ( array_key_exists( "function", $other_args ) ) {
|
|
| 47 | - $this->setFunction( $other_args ); |
|
| 43 | + public function processParameters($input_name = "", $other_args) {
|
|
| 44 | + if (array_key_exists("query", $other_args)) {
|
|
| 45 | + $this->setQuery($other_args); |
|
| 46 | + } elseif (array_key_exists("function", $other_args)) {
|
|
| 47 | + $this->setFunction($other_args); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -57,45 +57,45 @@ discard block |
||
| 57 | 57 | return $this->mData; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function setQuery( $other_args ) {
|
|
| 60 | + public function setQuery($other_args) {
|
|
| 61 | 61 | $query = $other_args["query"]; |
| 62 | - $query = str_replace( [ "~", "(", ")" ], [ "=", "[", "]" ], $query );
|
|
| 62 | + $query = str_replace(["~", "(", ")"], ["=", "[", "]"], $query);
|
|
| 63 | 63 | |
| 64 | 64 | //$this->mSelectField["query"] = $query; |
| 65 | 65 | $this->mQuery = $query; |
| 66 | 66 | $this->mData['selectquery'] = $query; |
| 67 | 67 | |
| 68 | 68 | // unparametrized query |
| 69 | - if ( strpos( $query, '@@@@' ) === false ) {
|
|
| 70 | - $params = explode( ";", $query ); |
|
| 69 | + if (strpos($query, '@@@@') === false) {
|
|
| 70 | + $params = explode(";", $query);
|
|
| 71 | 71 | |
| 72 | 72 | // there is no need to run the parser, $query has been parsed already |
| 73 | 73 | //$params[0] = $wgParser->replaceVariables( $params[0] ); |
| 74 | 74 | |
| 75 | - $this->mValues = QueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI ); |
|
| 75 | + $this->mValues = QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI); |
|
| 76 | 76 | |
| 77 | - $this->setHasStaticValues( true ); |
|
| 77 | + $this->setHasStaticValues(true); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function setFunction( $other_args ) {
|
|
| 81 | + public function setFunction($other_args) {
|
|
| 82 | 82 | #global $wgParser; |
| 83 | 83 | |
| 84 | 84 | $function = $other_args["function"]; |
| 85 | - $function = '{{#' . $function . '}}';
|
|
| 86 | - $function = str_replace( [ "~", "(", ")" ], [ "=", "[", "]" ], $function );
|
|
| 85 | + $function = '{{#'.$function.'}}';
|
|
| 86 | + $function = str_replace(["~", "(", ")"], ["=", "[", "]"], $function);
|
|
| 87 | 87 | |
| 88 | 88 | //$this->mSelectField["function"] = $function; |
| 89 | 89 | $this->mFunction = $function; |
| 90 | 90 | $this->mData['selectfunction'] = $function; |
| 91 | 91 | |
| 92 | 92 | // unparametrized function |
| 93 | - if ( strpos( $function, '@@@@' ) === false ) {
|
|
| 94 | - $f = str_replace( ";", "|", $function ); |
|
| 93 | + if (strpos($function, '@@@@') === false) {
|
|
| 94 | + $f = str_replace(";", "|", $function);
|
|
| 95 | 95 | |
| 96 | - $this->setValues( $this->mParser->replaceVariables( $f ) ); |
|
| 96 | + $this->setValues($this->mParser->replaceVariables($f)); |
|
| 97 | 97 | |
| 98 | - $this->setHasStaticValues( true ); |
|
| 98 | + $this->setHasStaticValues(true); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * setSelectIsMultiple |
| 104 | 104 | * @param string[] $other_args |
| 105 | 105 | */ |
| 106 | - public function setSelectIsMultiple( Array $other_args ) {
|
|
| 107 | - $this->mSelectIsMultiple = array_key_exists( "part_of_multiple", $other_args ); |
|
| 106 | + public function setSelectIsMultiple(Array $other_args) {
|
|
| 107 | + $this->mSelectIsMultiple = array_key_exists("part_of_multiple", $other_args);
|
|
| 108 | 108 | $this->mData["selectismultiple"] = $this->mSelectIsMultiple; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * setSelectTemplate |
| 113 | 113 | * @param string $input_name |
| 114 | 114 | */ |
| 115 | - public function setSelectTemplate( $input_name = "" ) {
|
|
| 116 | - $index = strpos( $input_name, "[" ); |
|
| 117 | - $this->mSelectTemplate = substr( $input_name, 0, $index ); |
|
| 115 | + public function setSelectTemplate($input_name = "") {
|
|
| 116 | + $index = strpos($input_name, "["); |
|
| 117 | + $this->mSelectTemplate = substr($input_name, 0, $index); |
|
| 118 | 118 | $this->mData['selecttemplate'] = $this->mSelectTemplate; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | * setSelectField |
| 123 | 123 | * @param string $input_name |
| 124 | 124 | */ |
| 125 | - public function setSelectField( $input_name = "" ) {
|
|
| 126 | - $index = strrpos( $input_name, "[" ); |
|
| 127 | - $this->mSelectField = substr( $input_name, $index + 1, strlen( $input_name ) - $index - 2 ); |
|
| 125 | + public function setSelectField($input_name = "") {
|
|
| 126 | + $index = strrpos($input_name, "["); |
|
| 127 | + $this->mSelectField = substr($input_name, $index + 1, strlen($input_name) - $index - 2); |
|
| 128 | 128 | $this->mData['selectfield'] = $this->mSelectField; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | * setValueTemplate |
| 133 | 133 | * @param Array $other_args |
| 134 | 134 | */ |
| 135 | - public function setValueTemplate( Array $other_args ) {
|
|
| 135 | + public function setValueTemplate(Array $other_args) {
|
|
| 136 | 136 | $this->mValueTemplate = |
| 137 | - array_key_exists( "sametemplate", $other_args ) ? $this->mSelectTemplate : $other_args["template"]; |
|
| 137 | + array_key_exists("sametemplate", $other_args) ? $this->mSelectTemplate : $other_args["template"];
|
|
| 138 | 138 | $this->mData["valuetemplate"] = $this->mValueTemplate; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * setValueField |
| 143 | 143 | * @param array $other_args |
| 144 | 144 | */ |
| 145 | - public function setValueField( Array $other_args ) {
|
|
| 145 | + public function setValueField(Array $other_args) {
|
|
| 146 | 146 | $this->mValueField = $other_args["field"]; |
| 147 | 147 | $this->mData["valuefield"] = $this->mValueField; |
| 148 | 148 | |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * setSelectRemove |
| 153 | 153 | * @param array $other_args |
| 154 | 154 | */ |
| 155 | - public function setSelectRemove( Array $other_args ) {
|
|
| 156 | - $this->mSelectRemove = array_key_exists( 'rmdiv', $other_args ); |
|
| 155 | + public function setSelectRemove(Array $other_args) {
|
|
| 156 | + $this->mSelectRemove = array_key_exists('rmdiv', $other_args);
|
|
| 157 | 157 | $this->mData['selectrm'] = $this->mSelectRemove; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | * setLabel |
| 162 | 162 | * @param array $other_args |
| 163 | 163 | */ |
| 164 | - public function setLabel( Array $other_args ) {
|
|
| 165 | - $this->mLabel = array_key_exists( 'label', $other_args ); |
|
| 164 | + public function setLabel(Array $other_args) {
|
|
| 165 | + $this->mLabel = array_key_exists('label', $other_args);
|
|
| 166 | 166 | $this->mData['label'] = $this->mLabel; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -170,15 +170,15 @@ discard block |
||
| 170 | 170 | * setDelimiter |
| 171 | 171 | * @param array $other_args |
| 172 | 172 | */ |
| 173 | - public function setDelimiter( Array $other_args ) {
|
|
| 173 | + public function setDelimiter(Array $other_args) {
|
|
| 174 | 174 | |
| 175 | 175 | $this->mDelimiter = $GLOBALS['wgPageFormsListSeparator']; |
| 176 | 176 | |
| 177 | - if ( array_key_exists( 'sep', $other_args ) ) {
|
|
| 177 | + if (array_key_exists('sep', $other_args)) {
|
|
| 178 | 178 | $this->mDelimiter = $other_args['sep']; |
| 179 | 179 | } else {
|
| 180 | 180 | // Adding Backcompatibility |
| 181 | - if ( array_key_exists( 'delimiter', $other_args ) ) {
|
|
| 181 | + if (array_key_exists('delimiter', $other_args)) {
|
|
| 182 | 182 | $this->mDelimiter = $other_args['delimiter']; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | * setValues |
| 207 | 207 | * @param string $values (comma separated, fully parsed list of values) |
| 208 | 208 | */ |
| 209 | - private function setValues( $values ) {
|
|
| 210 | - $values = explode( $this->mDelimiter, $values ); |
|
| 211 | - $values = array_map( "trim", $values ); |
|
| 212 | - $values = array_unique( $values ); |
|
| 209 | + private function setValues($values) {
|
|
| 210 | + $values = explode($this->mDelimiter, $values); |
|
| 211 | + $values = array_map("trim", $values);
|
|
| 212 | + $values = array_unique($values); |
|
| 213 | 213 | $this->mValues = $values; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * setHasStaticValues |
| 226 | 226 | * @param boolean $StaticValues |
| 227 | 227 | */ |
| 228 | - private function setHasStaticValues( $StaticValues ) {
|
|
| 228 | + private function setHasStaticValues($StaticValues) {
|
|
| 229 | 229 | $this->mHasStaticValues = $StaticValues; |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | \ No newline at end of file |