Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -60,8 +60,10 @@ |
61 | 61 | jQuery('.isListCheckbox').click(function() { |
62 | 62 | if (jQuery(this).is(":checked")) |
63 | 63 | { |
| 64 | + alert("checked"); |
64 | 65 | jQuery(this).siblings('.delimiterInput').css('display', ''); |
65 | 66 | }else{ |
| 67 | + alert("unchecked"); |
66 | 68 | jQuery(this).siblings('.delimiterInput').css('display', 'none'); |
67 | 69 | } |
68 | 70 | }); |
— | — | @@ -79,7 +81,35 @@ |
80 | 82 | $this->setHeaders(); |
81 | 83 | $text_1 = '<p>This category does not exist yet. Create this category and its page schema: </p>'; |
82 | 84 | $text_2 = '<p>This category exists, but does not have a page schema. Create schema:" </p>'; |
83 | | - if ( $category != "" ) { |
| 85 | + $save_page = $wgRequest->getCheck( 'wpSave' ); |
| 86 | + if ($save_page) { |
| 87 | + //Generate the Xml from the Form elements |
| 88 | + $Xmltext = ""; |
| 89 | + $s_name = $wgRequest->getText('s_name'); |
| 90 | + $Xmltext .= '<PageSchema name="'.$s_name.'">'; |
| 91 | + $ps_add_xml = $wgRequest->getText('ps_add_xml'); |
| 92 | + $Xmltext .= $ps_add_xml; |
| 93 | + foreach ( $wgRequest->getValues() as $var => $val ) { |
| 94 | + if(substr($var,0,7) == 't_name_'){ |
| 95 | + $Xmltext .= '<Template name="'.$val.'">'; |
| 96 | + }else if(substr($var,0,7) == 'f_name_'){ |
| 97 | + $Xmltext .= '<Field name="'.$val.'">'; |
| 98 | + }else if(substr($var,0,8) == 'f_label_'){ |
| 99 | + $Xmltext .= '<Label>'.$val.'</Label>'; |
| 100 | + }else if(substr($var,0,10) == 'f_add_xml_'){ |
| 101 | + $Xmltext .= $val; |
| 102 | + $Xmltext .= '</Field>'; |
| 103 | + }else if(substr($var,0,10) == 't_add_xml_'){ |
| 104 | + $Xmltext .= $val; |
| 105 | + $Xmltext .= '</Template>'; |
| 106 | + } |
| 107 | + } |
| 108 | + $Xmltext .= '</PageSchema>'; |
| 109 | + wfDebugLog( 'myextension', 'Something is not right: ' . print_r( $Xmltext, true ) ); |
| 110 | + } |
| 111 | + else{ |
| 112 | + if ( $category != "" ) { |
| 113 | + |
84 | 114 | $title = Title::newFromText( $category, NS_CATEGORY ); |
85 | 115 | $pageId = $title->getArticleID(); |
86 | 116 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -114,15 +144,15 @@ |
115 | 145 | $text .= '<div id="fieldsList_1">'; |
116 | 146 | $text .= '<div class="fieldBox" >'; |
117 | 147 | $text .= '<fieldset style="background: #bbb;"><legend>Field</legend> |
118 | | - <p>Field name: <input size="15" name="name_1"> |
119 | | - Display label: <input size="15" name="label_1"> |
| 148 | + <p>Field name: <input size="15" name="f_name_1"> |
| 149 | + Display label: <input size="15" name="f_label_1"> |
120 | 150 | </p> |
121 | | - <p><input type="checkbox" name="is_list_1" class="isListCheckbox" /> |
| 151 | + <p><input type="checkbox" name="f_is_list_1" class="isListCheckbox" /> |
122 | 152 | This field can hold a list of values |
123 | 153 | </p> |
124 | | - <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="delimiter_1" /> </p></div> |
| 154 | + <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_1" /> </p></div> |
125 | 155 | <p>Additional XML: |
126 | | - <textarea rows=4 style="width: 100%" name="add_xml_1"></textarea> |
| 156 | + <textarea rows=4 style="width: 100%" name="f_add_xml_1"></textarea> |
127 | 157 | </p> |
128 | 158 | <input type="button" value="Remove field" class="deleteField" /> </div> |
129 | 159 | |
— | — | @@ -141,8 +171,22 @@ |
142 | 172 | <textarea rows=4 style="width: 100%" name="t_add_xml_1"></textarea> |
143 | 173 | </p> |
144 | 174 | <p><input type="button" value="Remove template" class="deleteTemplate" /></p> |
145 | | - </fieldset> </div>'; |
146 | | - $text .= '<div class="templateBox" id="starterTemplate" style="display: none"> |
| 175 | + </fieldset> </div></div>'; |
| 176 | + |
| 177 | + $add_template_button = Xml::element( 'input', |
| 178 | + array( |
| 179 | + 'type' => 'button', |
| 180 | + 'value' => 'Add Template', |
| 181 | + 'onclick' => "createAddTemplate()" |
| 182 | + ) |
| 183 | + ); |
| 184 | + $text .= Xml::tags( 'p', null, $add_template_button ) . "\n"; |
| 185 | + $text .= ' <hr /> |
| 186 | + <div class="editButtons"> |
| 187 | + <input type="submit" id="wpSave" name="wpSave" value="Save" /> |
| 188 | + </div>'; |
| 189 | + $text .= ' </form>'; |
| 190 | + $text .= '<div class="templateBox" id="starterTemplate" style="display: none"> |
147 | 191 | <fieldset style="background: #ddd;"> |
148 | 192 | <legend>Template</legend> |
149 | 193 | <p>Name: <input type="text" name="t_name_starter"/></p> |
— | — | @@ -157,36 +201,24 @@ |
158 | 202 | </p> |
159 | 203 | <p><input type="button" value="Remove template" class="deleteTemplate" /></p> |
160 | 204 | </fieldset> |
161 | | - </div> |
162 | | - </div> |
| 205 | + </div> |
163 | 206 | <hr /> '; |
164 | 207 | $text .= '<div class="fieldBox" id="starterField" style="display: none"> |
165 | 208 | <fieldset style="background: #bbb;"><legend>Field</legend> |
166 | | - <input size="15" name="name_starter"> |
167 | | - Display label: <input size="15" name="label_starter"> |
| 209 | + <input size="15" name="f_name_starter"> |
| 210 | + Display label: <input size="15" name="f_label_starter"> |
168 | 211 | </p> |
169 | | - <p><input type="checkbox" name="is_list_starter" /> This field can hold a list of values, separated by commas |
| 212 | + <p><input type="checkbox" name="f_is_list_starter" /> This field can hold a list of values, separated by commas |
170 | 213 |    |
171 | | - <p>Delimiter for values (default is ","): <input type="text" name="delimiter_starter" /> </p> |
| 214 | + <p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_starter" /> </p> |
172 | 215 | <p>Additional XML: |
173 | | - <textarea rows=4 style="width: 100%" name="add_xml_starter"></textarea> |
| 216 | + <textarea rows=4 style="width: 100%" name="f_add_xml_starter"></textarea> |
174 | 217 | </p> |
175 | 218 | <input type="button" value="Remove field" class="deleteField" /> |
176 | 219 | </p> |
177 | 220 | </fieldset> |
178 | 221 | </div>'; |
179 | | - $add_template_button = Xml::element( 'input', |
180 | | - array( |
181 | | - 'type' => 'button', |
182 | | - 'value' => 'Add Template', |
183 | | - 'onclick' => "createAddTemplate()" |
184 | | - ) |
185 | | - ); |
186 | | - $text .= Xml::tags( 'p', null, $add_template_button ) . "\n"; |
187 | | - $text .= ' <hr /> |
188 | | - <p><input type="submit" value="Save" /></p> '; |
189 | | - $text .= ' </form>'; |
190 | | - $wgOut->addHTML( $text ); |
| 222 | + $wgOut->addHTML( $text ); |
191 | 223 | }else{ |
192 | 224 | if( ($row[1] == 'PageSchema') && ($row[2] != null )){ |
193 | 225 | |
— | — | @@ -224,5 +256,6 @@ |
225 | 257 | $dbr->freeResult( $res ); |
226 | 258 | $wgOut->addHTML( $text ); |
227 | 259 | } |
| 260 | + } |
228 | 261 | } |
229 | 262 | } |