Index: trunk/extensions/SemanticForms/includes/SF_AutoeditAPI.php |
— | — | @@ -25,9 +25,24 @@ |
26 | 26 | * the result. |
27 | 27 | */ |
28 | 28 | function execute() { |
29 | | - $this->mOptions = $this->extractRequestParams(); |
30 | | - $this->parseDataFromQueryString( $this->mOptions, $this->mOptions['query'] ); |
| 29 | + $this->mOptions = $_POST + $_GET; |
31 | 30 | |
| 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 | + |
32 | 47 | $this->storeSemanticData(); |
33 | 48 | } |
34 | 49 | |
— | — | @@ -64,7 +79,7 @@ |
65 | 80 | return array( |
66 | 81 | 'form' => 'The form to use.', |
67 | 82 | '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.' |
69 | 84 | ); |
70 | 85 | } |
71 | 86 | |
— | — | @@ -73,7 +88,15 @@ |
74 | 89 | * @return mixed string or array of strings |
75 | 90 | */ |
76 | 91 | 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; |
78 | 101 | } |
79 | 102 | |
80 | 103 | /** |
— | — | @@ -81,7 +104,10 @@ |
82 | 105 | * @return mixed string or array of strings |
83 | 106 | */ |
84 | 107 | 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 | + ); |
86 | 112 | } |
87 | 113 | |
88 | 114 | /** |