@@ -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 | } |
@@ -181,6 +181,9 @@ |
||
| 181 | 181 | return $this->mHasStaticValues; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | + /** |
|
| 185 | + * @param boolean $StaticValues |
|
| 186 | + */ |
|
| 184 | 187 | private function setHasStaticValues( $StaticValues ) {
|
| 185 | 188 | $this->mHasStaticValues = $StaticValues; |
| 186 | 189 | } |
@@ -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,84 +57,84 @@ 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 | |
| 102 | - public function setSelectIsMultiple( Array $other_args ) {
|
|
| 103 | - $this->mSelectIsMultiple = array_key_exists( "part_of_multiple", $other_args ); |
|
| 102 | + public function setSelectIsMultiple(Array $other_args) {
|
|
| 103 | + $this->mSelectIsMultiple = array_key_exists("part_of_multiple", $other_args);
|
|
| 104 | 104 | $this->mData["selectismultiple"] = $this->mSelectIsMultiple; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function setSelectTemplate( $input_name = "" ) {
|
|
| 108 | - $index = strpos( $input_name, "[" ); |
|
| 109 | - $this->mSelectTemplate = substr( $input_name, 0, $index ); |
|
| 107 | + public function setSelectTemplate($input_name = "") {
|
|
| 108 | + $index = strpos($input_name, "["); |
|
| 109 | + $this->mSelectTemplate = substr($input_name, 0, $index); |
|
| 110 | 110 | $this->mData['selecttemplate'] = $this->mSelectTemplate; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setSelectField( $input_name = "" ) {
|
|
| 114 | - $index = strrpos( $input_name, "[" ); |
|
| 115 | - $this->mSelectField = substr( $input_name, $index + 1, strlen( $input_name ) - $index - 2 ); |
|
| 113 | + public function setSelectField($input_name = "") {
|
|
| 114 | + $index = strrpos($input_name, "["); |
|
| 115 | + $this->mSelectField = substr($input_name, $index + 1, strlen($input_name) - $index - 2); |
|
| 116 | 116 | $this->mData['selectfield'] = $this->mSelectField; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function setValueTemplate( Array $other_args ) {
|
|
| 119 | + public function setValueTemplate(Array $other_args) {
|
|
| 120 | 120 | $this->mValueTemplate = |
| 121 | - array_key_exists( "sametemplate", $other_args ) ? $this->mSelectTemplate : $other_args["template"]; |
|
| 121 | + array_key_exists("sametemplate", $other_args) ? $this->mSelectTemplate : $other_args["template"];
|
|
| 122 | 122 | $this->mData["valuetemplate"] = $this->mValueTemplate; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function setValueField( Array $other_args ) {
|
|
| 125 | + public function setValueField(Array $other_args) {
|
|
| 126 | 126 | $this->mValueField = $other_args["field"]; |
| 127 | 127 | $this->mData["valuefield"] = $this->mValueField; |
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function setSelectRemove( Array $other_args ) {
|
|
| 132 | - $this->mSelectRemove = array_key_exists( 'rmdiv', $other_args ); |
|
| 131 | + public function setSelectRemove(Array $other_args) {
|
|
| 132 | + $this->mSelectRemove = array_key_exists('rmdiv', $other_args);
|
|
| 133 | 133 | $this->mData['selectrm'] = $this->mSelectRemove; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function setLabel( Array $other_args ) {
|
|
| 137 | - $this->mLabel = array_key_exists( 'label', $other_args ); |
|
| 136 | + public function setLabel(Array $other_args) {
|
|
| 137 | + $this->mLabel = array_key_exists('label', $other_args);
|
|
| 138 | 138 | $this->mData['label'] = $this->mLabel; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -142,15 +142,15 @@ discard block |
||
| 142 | 142 | * setDelimiter |
| 143 | 143 | * @param array $other_args |
| 144 | 144 | */ |
| 145 | - public function setDelimiter( Array $other_args ) {
|
|
| 145 | + public function setDelimiter(Array $other_args) {
|
|
| 146 | 146 | |
| 147 | 147 | $this->mDelimiter = $GLOBALS['wgPageFormsListSeparator']; |
| 148 | 148 | |
| 149 | - if ( array_key_exists( 'sep', $other_args ) ) {
|
|
| 149 | + if (array_key_exists('sep', $other_args)) {
|
|
| 150 | 150 | $this->mDelimiter = $other_args['sep']; |
| 151 | 151 | } else {
|
| 152 | 152 | // Adding Backcompatibility |
| 153 | - if ( array_key_exists( 'delimiter', $other_args ) ) {
|
|
| 153 | + if (array_key_exists('delimiter', $other_args)) {
|
|
| 154 | 154 | $this->mDelimiter = $other_args['delimiter']; |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | * setValues |
| 171 | 171 | * @param string $values (comma separated, fully parsed list of values) |
| 172 | 172 | */ |
| 173 | - private function setValues( $values ) {
|
|
| 174 | - $values = explode( $this->mDelimiter, $values ); |
|
| 175 | - $values = array_map( "trim", $values ); |
|
| 176 | - $values = array_unique( $values ); |
|
| 173 | + private function setValues($values) {
|
|
| 174 | + $values = explode($this->mDelimiter, $values); |
|
| 175 | + $values = array_map("trim", $values);
|
|
| 176 | + $values = array_unique($values); |
|
| 177 | 177 | $this->mValues = $values; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | return $this->mHasStaticValues; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - private function setHasStaticValues( $StaticValues ) {
|
|
| 184 | + private function setHasStaticValues($StaticValues) {
|
|
| 185 | 185 | $this->mHasStaticValues = $StaticValues; |
| 186 | 186 | } |
| 187 | 187 | } |