r91805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91804‎ | r91805 | r91806 >
Date:19:44, 9 July 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
followup r91797: also process values set outside the query parameter
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php
@@ -25,9 +25,24 @@
2626 * the result.
2727 */
2828 function execute() {
29 - $this->mOptions = $this->extractRequestParams();
30 - $this->parseDataFromQueryString( $this->mOptions, $this->mOptions['query'] );
 29+ $this->mOptions = $_POST + $_GET;
3130
 31+ // ensure 'form' key exists
 32+ if ( !array_key_exists( 'form', $this->mOptions ) ) {
 33+ $this->mOptions['form'] = null;
 34+ }
 35+
 36+ // ensure 'target' key exists
 37+ if ( !array_key_exists( 'target', $this->mOptions ) ) {
 38+ $this->mOptions['target'] = null;
 39+ }
 40+
 41+ // if query parameter was used, unpack it
 42+ if ( array_key_exists( 'query', $this->mOptions ) ) {
 43+ $this->parseDataFromQueryString( $this->mOptions, $this->mOptions['query'] );
 44+ unset( $this->mOptions['query'] );
 45+ }
 46+
3247 $this->storeSemanticData();
3348 }
3449
@@ -64,7 +79,7 @@
6580 return array(
6681 'form' => 'The form to use.',
6782 'target' => 'The target page.',
68 - 'query' => "The query string.\nFormat: template[parameter]=value\nMerge assignations using %26, i.e. template[parameter1]=value1%26template[parameter2]=value2"
 83+ 'query' => 'The query string.'
6984 );
7085 }
7186
@@ -73,7 +88,15 @@
7489 * @return mixed string or array of strings
7590 */
7691 function getDescription() {
77 - return "This module is used to remotely create or edit pages using Semantic Forms";
 92+ return <<<END
 93+This module is used to remotely create or edit pages using Semantic Forms.
 94+
 95+Add "template-name[field-name]=field-value" to the query string parameter, to set the value for a specific field.
 96+To set values for more than one field use "&", or rather its URL encoded version "%26": "template-name[field-name-1]=field-value-1%26template-name[field-name-2]=field-value-2".
 97+See the first example below.
 98+
 99+In addition to the query parameter, any parameter in the URL of the form "template-name[field-name]=field-value" will be treated as part of the query. See the second example.
 100+END;
78101 }
79102
80103 /**
@@ -81,7 +104,10 @@
82105 * @return mixed string or array of strings
83106 */
84107 protected function getExamples() {
85 - return 'api.php?action=sfautoedit&form=Event&target=SomeEvent&query=Event[Start]=2011/07/09%26Event[End]=2011/07/10';
 108+ return array(
 109+ 'With query parameter: api.php?action=sfautoedit&form=form-name&target=page-name&query=template-name[field-name-1]=field-value-1%26template-name[field-name-2]=field-value-2',
 110+ 'Without query parameter: api.php?action=sfautoedit&form=form-name&target=page-name&template-name[field-name-1]=field-value-1&template-name[field-name-2]=field-value-2'
 111+ );
86112 }
87113
88114 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91797API module to remotely create or edit pages using Semantic Formsfoxtrott18:38, 9 July 2011