r99689 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99688‎ | r99689 | r99690 >
Date:16:24, 13 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Version 2.0-alpha: overhaul of extension, with changes to Javascript, HTML and display, along with bug fixes
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)
  • /trunk/extensions/PageSchemas/PageSchemas.css (modified) (history)
  • /trunk/extensions/PageSchemas/PageSchemas.hooks.php (modified) (history)
  • /trunk/extensions/PageSchemas/PageSchemas.js (added) (history)
  • /trunk/extensions/PageSchemas/PageSchemas.php (modified) (history)
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -56,7 +56,7 @@
5757 global $wgOut;
5858 $output = $wgOut;
5959 }
60 - $output->addModules( 'jquery' );
 60+ $output->addModules( 'ext.pageschemas.main' );
6161 }
6262
6363 public static function titleString( $title ) {
@@ -98,43 +98,59 @@
9999 return $xml_success;
100100 }
101101
102 - static function tableRowHTML($css_class, $data_type, $value = null) {
103 - $data_type = htmlspecialchars($data_type);
104 - if ( is_null( $value ) ) {
 102+ static function tableRowHTML( $css_class, $data_type, $value = null, $bgColor = null ) {
 103+ $data_type = htmlspecialchars( $data_type );
 104+ if ( !is_null( $bgColor ) ) {
 105+ // We don't actually use the passed-in background color, except as an indicator
 106+ // that this is a header row for extension data, and thus should have special
 107+ // display.
 108+ // In the future, the background color may get used, though.
 109+ $data_type = HTML::element( 'span', array( 'style' => "color: #993333;" ), $data_type );
 110+ }
 111+ if ( $value == '' ) {
105112 $content = $data_type;
106113 } else {
107 - $content = "$data_type: " . HTML::element('span', array('class' => 'rowValue'), $value);
 114+ $content = "$data_type: " . HTML::element( 'span', array( 'class' => 'rowValue' ), $value );
108115 }
109 - $cell = HTML::rawElement('td', array('colspan' => 2, 'class' => $css_class), $content);
110 - $text = HTML::rawElement('tr', null, $cell);
 116+ $cellAttrs = array( 'colspan' => 2, 'class' => $css_class );
 117+ $cell = HTML::rawElement( 'td', $cellAttrs, $content );
 118+ //$cell = "<td colspan=2><span style=\"background: white; min-width; 20px;\">.</span><span style=\"background: $bgColor;\">$content</span></td>";
 119+ $text = HTML::rawElement( 'tr', array( 'style' => 'border: 1px black solid; margin: 10px;' ), $cell );
111120 $text .= "\n";
112121 return $text;
113122 }
114123
115 - static function tableMessageRowHTML( $css_class, $name, $value ) {
116 - $cell1 = HTML::element('td', array('class' => $css_class), $name);
117 - $cell2 = HTML::element('td', array('class' => 'msg'), $value);
118 - $text = HTML::rawElement('tr', null, $cell1 . "\n" . $cell2);
 124+ static function attrRowHTML( $cssClass, $fieldName, $value ) {
 125+ $fieldNameAttrs = array( 'class' => $cssClass, 'style' => 'font-weight: normal;' );
 126+ $fieldNameCell = HTML::rawElement( 'td', $fieldNameAttrs, $fieldName );
 127+ $valueCell = HTML::element( 'td', array( 'class' => 'msg', 'style' => 'font-weight: bold;' ), $value );
 128+ $text = HTML::rawElement( 'tr', null, $fieldNameCell . "\n" . $valueCell );
119129 $text .= "\n";
120130 return $text;
121131 }
122132
123 - static function parsePageSchemas($class_schema_xml) {
 133+ static function displaySchema($schema_xml) {
124134 global $wgTitle;
125135
126136 if ( $wgTitle->getNamespace() == NS_CATEGORY ) {
127 - $text = Html::element( 'p', null, wfMsg( 'ps-schema-description' ) ) . "\n";
128 - $text .= "<table class=\"pageSchema\">\n";
129 - $name = $class_schema_xml->attributes()->name;
130 - $text .= self::tableRowHTML('paramGroup', 'PageSchema', $name);
131 - foreach ( $class_schema_xml->children() as $tag => $child ) {
132 - // TODO - need a hook call right here
133 - if ( $tag == 'semanticforms_Form' ) {
134 - $text .= self::parseFormElem($child);
135 - } elseif ($tag == 'Template') {
136 - $text .= self::parseTemplate($child);
 137+ //$text = Html::element( 'p', null, wfMsg( 'ps-schema-description' ) ) . "\n";
 138+ $text = "<table class=\"pageSchema mw-collapsible mw-collapsed\">\n";
 139+ $name = $schema_xml->attributes()->name;
 140+ $text .= self::tableRowHTML( 'pageSchemaHeader', 'Page schema' );
 141+ $displayInfoFromExtensions = array();
 142+ wfRunHooks( 'PageSchemasGetSchemaDisplayInfo', array( $schema_xml, &$displayInfoFromExtensions ) );
 143+ foreach( $displayInfoFromExtensions as $displayInfo ) {
 144+ list( $label, $elementName, $bgColor, $values ) = $displayInfo;
 145+ $text .= self::tableRowHTML( 'schemaExtensionRow', $label, $elementName, $bgColor );
 146+ foreach ( $values as $fieldName => $value ) {
 147+ $text .= self::attrRowHTML( 'schemaAttrRow', $fieldName, $value );
137148 }
138149 }
 150+ foreach ( $schema_xml->children() as $tag => $child ) {
 151+ if ( $tag == 'Template') {
 152+ $text .= self::displayTemplate($child);
 153+ }
 154+ }
139155 $text .= "</table>\n";
140156 } else {
141157 $text = "";
@@ -142,34 +158,52 @@
143159 return $text;
144160 }
145161
146 - /**
147 - * @TODO - this should move into Semantic Forms, via a hook
148 - */
149 - static function parseFormElem( $form_xml ) {
150 - $name = $form_xml->attributes()->name;
151 - $text = self::tableRowHTML('param', 'Form', $name);
152 - foreach ($form_xml->children() as $key => $value ) {
153 - $text .= self::tableMessageRowHTML( "paramAttrMsg", (string)$key, (string)$value );
 162+ static function displayTemplate ( $templateXML ) {
 163+ $name = $templateXML->attributes()->name;
 164+ $text = self::tableRowHTML( 'templateRow', 'Template', $name );
 165+ $multiple = $templateXML->attributes()->multiple;
 166+ if ( $multiple == 'multiple' ) {
 167+ $text .= self::attrRowHTML( 'schemaAttrRow', 'multiple', null );
154168 }
 169+ $displayInfoFromExtensions = array();
 170+ wfRunHooks( 'PageSchemasGetTemplateDisplayInfo', array( $templateXML, &$displayInfoFromExtensions ) );
 171+ foreach( $displayInfoFromExtensions as $displayInfo ) {
 172+ list( $label, $elementName, $bgColor, $values ) = $displayInfo;
 173+ $text .= self::tableRowHTML( 'fieldExtensionRow', $label, $elementName, $bgColor );
 174+ foreach ( $values as $fieldName => $value ) {
 175+ $text .= self::attrRowHTML( 'fieldAttrRow', $fieldName, $value );
 176+ }
 177+ }
 178+ foreach ( $templateXML->children() as $child ) {
 179+ $text .= self::displayField( $child );
 180+ }
155181 return $text;
156182 }
157183
158 - static function parseTemplate ( $template_xml ) {
159 - $name = $template_xml->attributes()->name;
160 - $text = self::tableRowHTML( 'param', 'Template', $name );
161 - foreach ( $template_xml->children() as $child ) {
162 - $text .= self::parseField( $child );
 184+ static function displayField ( $fieldXML ) {
 185+ $name = $fieldXML->attributes()->name;
 186+ $text = self::tableRowHTML( 'fieldRow', 'Field', $name );
 187+
 188+ if( ((string) $fieldXML->attributes()->list) == "list" ) {
 189+ $text .= self::attrRowHTML( 'fieldAttrRow', 'List', null );
163190 }
164 - return $text;
165 - }
166 - static function parseField ( $field_xml ) {
167 - $name = $field_xml->attributes()->name;
168 - $text = self::tableRowHTML( 'paramAttr', 'Field', $name );
169 - $text_object = array(); //different extensions will fill the html parsed text in this array via hooks
170 - wfRunHooks( 'PSParseFieldElements', array( $field_xml, &$text_object ) );
171 - foreach( $text_object as $key => $value ) {
172 - $text .= $value;
 191+ foreach ( $fieldXML->children() as $tag => $child ) {
 192+ if ( $tag == 'Label' ) {
 193+ $text .= self::attrRowHTML( 'fieldAttrRow', 'Label', $child );
 194+ }
173195 }
 196+
 197+ // Let extensions that store data within the Page Schemas XML each
 198+ // handle displaying their data, by adding to this array.
 199+ $displayInfoFromExtensions = array();
 200+ wfRunHooks( 'PageSchemasGetFieldDisplayInfo', array( $fieldXML, &$displayInfoFromExtensions ) );
 201+ foreach( $displayInfoFromExtensions as $displayInfo ) {
 202+ list( $label, $elementName, $bgColor, $values ) = $displayInfo;
 203+ $text .= self::tableRowHTML( 'fieldExtensionRow', $label, $elementName, $bgColor );
 204+ foreach ( $values as $fieldName => $value ) {
 205+ $text .= self::attrRowHTML( 'fieldAttrRow', $fieldName, $value );
 206+ }
 207+ }
174208 return $text;
175209 }
176210 }
@@ -213,7 +247,7 @@
214248 $this->pageXML = simplexml_load_string ( $pageXMLstr );
215249 /* index for template objects */
216250 $i = 0;
217 - $inherited_templates = null ;
 251+ $inherited_templates = array();
218252 foreach ( $this->pageXML->children() as $tag => $child ) {
219253 if ( $tag == 'InheritsFrom ' ) {
220254 $schema_to_inherit = (string) $child->attributes()->schema;
@@ -266,13 +300,13 @@
267301 return $this->categoryName;
268302 }
269303 }
 304+
270305 class PSTemplate {
271306 /* Stores the field objects */
272307 public $PSFields = array();
273308 public $templateName ="";
274309 public $templateXML = null;
275310 public $multiple_allowed = false;
276 - private $label_name = null;
277311
278312 function __construct( $template_xml ) {
279313 $this->templateXML = $template_xml;
@@ -296,15 +330,13 @@
297331 }
298332 }
299333 }
300 - } elseif ( $child->getName() == "Label" ) { //@TODO Label => sf:Label
301 - $this->label_name = (string)$child;
302334 } elseif ( $child->getName() == "Field" ) {
303335 $ignore = (string) $child->attributes()->ignore;
304336 if ( count($child->children()) > 0 ) { //@TODO :Can be dealt more efficiently
305337 $fieldObj = new PSTemplateField($child);
306338 $this->PSFields[$i++]= $fieldObj;
307339 } elseif ( $ignore != "true" ) {
308 - //Code to Add Templates from Inherited templates
 340+ // Code to add fields from inherited templates
309341 $field_name = (string) $child->attributes()->name;
310342 foreach( $inherited_fields as $inherited_field ) {
311343 if( $field_name == $inherited_field->getName() ){
@@ -324,8 +356,10 @@
325357 return $this->multiple_allowed;
326358 }
327359
328 - public function getLabel() {
329 - return $this->label_name;
 360+ function getObject( $objectName ) {
 361+ $object = array();
 362+ wfRunHooks( 'PageSchemasGetObject', array( $objectName, $this->templateXML, &$object ) );
 363+ return $object;
330364 }
331365
332366 function getFields() {
Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -11,104 +11,6 @@
1212 parent::__construct( 'EditSchema' );
1313 }
1414
15 - public static function addJavascript() {
16 - global $wgOut;
17 -
18 - PageSchemas::addJavascriptAndCSS();
19 -
20 - // TODO - this should be in a JS file
21 - $template_name_error_str = wfMsg( 'sf_blank_error' );
22 - $jsText =<<<END
23 -<script type="text/javascript">
24 -var fieldNum = 0;
25 -var templateNum = 0;
26 -// TODO - this function should be a jQuery 'fn' instead
27 -function psAddField(template_num) {
28 - fieldNum++;
29 - newField = jQuery('#starterField').clone().css('display', '').removeAttr('id');
30 - newHTML = newField.html().replace(/fnum/g, fieldNum);
31 - newField.html(newHTML);
32 - newField.find(".deleteField").click( function() {
33 - // Remove the encompassing div for this instance.
34 - jQuery(this).closest(".fieldBox")
35 - .fadeOut('fast', function() { jQuery(this).remove(); });
36 - });
37 - jQuery('#fieldsList_'+template_num).append(newField);
38 - addjQueryToCheckboxes();
39 -}
40 -
41 -function psAddTemplate() {
42 - templateNum++;
43 - newField = jQuery('#starterTemplate').clone().css('display', '').removeAttr('id');
44 - newHTML = newField.html().replace(/tnum/g, templateNum);
45 - newField.html(newHTML);
46 - newField.find(".deleteTemplate").click( function() {
47 - // Remove the encompassing div for this instance.
48 - jQuery(this).closest(".templateBox")
49 - .fadeOut('fast', function() { jQuery(this).remove(); });
50 - });
51 - jQuery('#templatesList').append(newField);
52 -}
53 -
54 -function updateFieldNum(field_num) {
55 - fieldNum = field_num;
56 -}
57 -
58 -function addjQueryToCheckboxes() {
59 - jQuery('.isListCheckbox').each(function() {
60 - if (jQuery(this).is(":checked")) {
61 - jQuery(this).closest('.fieldBox').find('.delimiterInput').css('display', '');
62 - } else {
63 - jQuery(this).closest('.fieldBox').find('.delimiterInput').css('display', 'none');
64 - }
65 - });
66 - jQuery('.isListCheckbox').click(function() {
67 - if (jQuery(this).is(":checked")) {
68 - jQuery(this).closest('.fieldBox').find('.delimiterInput').css('display', '');
69 - } else {
70 - jQuery(this).closest('.fieldBox').find('.delimiterInput').css('display', 'none');
71 - }
72 - });
73 - jQuery('.sectionCheckbox').each(function() {
74 - if (jQuery(this).is(":checked")) {
75 - jQuery(this).closest('.sectionBox').find('.extensionInputs').css('display', '').removeClass('hiddenSection');
76 - } else {
77 - jQuery(this).closest('.sectionBox').find('.extensionInputs').css('display', 'none').addClass('hiddenSection');
78 - }
79 - });
80 - jQuery('.sectionCheckbox').click(function() {
81 - if (jQuery(this).is(":checked")) {
82 - jQuery(this).closest('.sectionBox').find('.extensionInputs').css('display', '').removeClass('hiddenSection');
83 - } else {
84 - jQuery(this).closest('.sectionBox').find('.extensionInputs').css('display', 'none').addClass('hiddenSection');
85 - }
86 - });
87 -}
88 -
89 -jQuery(document).ready(function() {
90 - jQuery(".deleteField").click( function() {
91 - // Remove the encompassing div for this instance.
92 - jQuery(this).closest(".fieldBox")
93 - .fadeOut('fast', function() { jQuery(this).remove(); });
94 - });
95 - jQuery(".deleteTemplate").click( function() {
96 - // Remove the encompassing div for this instance.
97 - jQuery(this).closest(".templateBox")
98 - .fadeOut('fast', function() { jQuery(this).remove(); });
99 - });
100 - addjQueryToCheckboxes();
101 - jQuery('#editPageSchemaForm').submit( function() {
102 - jQuery('#starterTemplate').find("input, select, textarea").attr('disabled', 'disabled');
103 - jQuery('.hiddenSection').find("input, select, textarea").attr('disabled', 'disabled');
104 - return true;
105 - } );
106 -});
107 -</script>
108 -
109 -END;
110 - $wgOut->addScript( $jsText );
111 - }
112 -
11315 /**
11416 * Returns a nicely-formatted version of the XML passed in.
11517 *
@@ -132,8 +34,7 @@
13335 static function pageSchemaXMLFromRequest() {
13436 global $wgRequest;
13537
136 - //Generate the XML from the Form elements
137 - //$s_name = $wgRequest->getText('s_name');
 38+ // Generate the XML from the form elements.
13839 $psXML = '<PageSchema>';
13940 $additionalXML = $wgRequest->getText( 'ps_add_xml' );
14041 $psXML .= $additionalXML;
@@ -142,17 +43,17 @@
14344 $templateNum = -1;
14445 // Arrays to store the extension-specific XML entered in the form
14546 $schemaXMLFromExtensions = array();
 47+ $templateXMLFromExtensions = array();
14648 $fieldXMLFromExtensions = array();
14749 wfRunHooks( 'PageSchemasGetSchemaXML', array( $wgRequest, &$schemaXMLFromExtensions ));
 50+ wfRunHooks( 'PageSchemasGetTemplateXML', array( $wgRequest, &$templateXMLFromExtensions ));
14851 wfRunHooks( 'PageSchemasGetFieldXML', array( $wgRequest, &$fieldXMLFromExtensions ));
14952 foreach ( $schemaXMLFromExtensions as $extensionName => $xml ) {
15053 if ( !empty( $xml ) ) {
15154 $psXML .= $xml;
15255 }
15356 }
154 - $indexGlobalField = 0 ; //this variable is use to index the array returned by extensions for XML.
15557 foreach ( $wgRequest->getValues() as $var => $val ) {
156 - $suffix = substr( $var, -3 );
15758 // Ignore fields from the hidden/starter div
15859 if ( substr( $var, 0, 7 ) == 't_name_' ) {
15960 $templateNum = substr( $var, 7 );
@@ -161,6 +62,13 @@
16263 } else {
16364 $psXML .= '<Template name="'.$val.'">';
16465 }
 66+
 67+ // Get XML created by extensions for this template
 68+ foreach ( $templateXMLFromExtensions as $extensionName => $xmlPerTemplate ) {
 69+ if ( !empty( $xmlPerTemplate[$templateNum] ) ) {
 70+ $psXML .= $xmlPerTemplate[$templateNum];
 71+ }
 72+ }
16573 } elseif ( substr( $var, 0, 7 ) == 'f_name_' ) {
16674 $fieldNum = substr( $var, 7 );
16775 $fieldName = $val;
@@ -179,13 +87,12 @@
18088 $psXML .= '<Label>' . $val . '</Label>';
18189 }
18290
183 - // Get XML created by extensions
 91+ // Get XML created by extensions for this field
18492 foreach ( $fieldXMLFromExtensions as $extensionName => $xmlPerField ) {
185 - if ( !empty( $xmlPerField[$indexGlobalField] ) ) {
186 - $psXML .= $xmlPerField[$indexGlobalField];
 93+ if ( !empty( $xmlPerField[$fieldNum] ) ) {
 94+ $psXML .= $xmlPerField[$fieldNum];
18795 }
18896 }
189 - $indexGlobalField++ ;
19097 } elseif ( substr( $var, 0, 10 ) == 'f_add_xml_' ) {
19198 $psXML .= $val;
19299 $psXML .= '</Field>';
@@ -220,16 +127,23 @@
221128 )
222129 );
223130 $editSchemaPage = SpecialPage::getTitleFor( 'EditSchema' );
 131+ $text .= "<ul>\n";
224132 while ( $row = $dbr->fetchRow( $res ) ) {
225 - if ( $row[2] != null ) {
226 - $page_id_cat = $row[0];
227 - if ( Title::newFromId( $page_id_cat )->getNamespace() == NS_CATEGORY ) {
228 - $cat_text = Title::newFromId( $page_id_cat )->getText();
229 - $url = $editSchemaPage ->getFullURL() . '/' . $cat_text;
230 - $text .= Html::element( 'a', array( 'href' => $url ), $cat_text ) . '<br />';
231 - }
 133+ if ( $row[2] == null ) {
 134+ continue;
232135 }
 136+ $catTitle = Title::newFromID( $row[0] );
 137+ if ( $catTitle->getNamespace() !== NS_CATEGORY ) {
 138+ continue;
 139+ }
 140+ $catName = $catTitle->getText();
 141+ $url = $catTitle->getFullURL( 'action=editschema' );
 142+ $text .= Html::rawElement( 'li',
 143+ null,
 144+ Html::element( 'a', array( 'href' => $url ), $catName )
 145+ );
233146 }
 147+ $text .= "</ul>\n";
234148 $dbr->freeResult( $res );
235149 return $text;
236150 }
@@ -237,19 +151,28 @@
238152 /*
239153 * Returns the HTML for one section of the EditSchema form.
240154 */
241 - static function printFormSection( $label, $topColor, $html, $bgColor = 'white', $isCollapsible = false, $hasExistingValues = true ) {
242 - $className = $isCollapsible ? 'sectionBox' : '';
243 - $text = "<div class=\"$className\" style=\"background: $bgColor; border: 1px #999 solid; padding: 0px; margin-bottom: 10px; margin-top: 10px;\">\n";
244 - $text .= "<div style=\"font-weight: bold; background: $topColor; padding: 4px 7px; border-bottom: 1px #bbb solid;\">";
245 - if ( $isCollapsible ) {
 155+ static function printFormSection( $label, $headerColor, $mainHTML, $sectionClass, $hasExistingValues = true ) {
 156+ // Section header
 157+ $headerContents = '';
 158+ if ( empty( $sectionClass ) ) {
246159 $checkboxAttrs = array( 'class' => 'sectionCheckbox' );
247160 if ( $hasExistingValues ) {
248161 $checkboxAttrs['checked'] = true;
249162 }
250 - $text .= " " . Html::input( 'show_section', null, 'checkbox', $checkboxAttrs );
 163+ $headerContents .= "\n\t\t" . Html::input( 'show_section', null, 'checkbox', $checkboxAttrs ) . ' ';
251164 }
252 - $className = $isCollapsible ? 'extensionInputs' : '';
253 - $text .= "$label</div>" . "<div class=\"$className\" style=\"padding: 5px 15px;\">$html</div>\n" . "</div>\n";
 165+ $headerContents .= $label . "\n";
 166+ $sectionHTML = "\n\t\t\t\t\t" . Html::rawElement( 'div', array(
 167+ 'class' => 'sectionHeader',
 168+ 'style' => "background: $headerColor;"
 169+ ), $headerContents );
 170+
 171+ // Body of section, with all the inputs.
 172+ $sectionHTML .= "\n\t" . Html::rawElement( 'div', array( 'class' => 'sectionBody' ), "\n" . $mainHTML );
 173+
 174+ // Wrapper around the whole thing.
 175+ $className = "editSchemaSection $sectionClass";
 176+ $text = "\n\t\t\t\t" . Html::rawElement( 'div', array( 'class' => $className ), $sectionHTML ) . "\n";
254177 return $text;
255178 }
256179
@@ -258,23 +181,32 @@
259182 */
260183 static function printFieldHTMLForExtension( $valuesFromExtension ) {
261184 list( $label, $color, $html, $hasExistingValues ) = $valuesFromExtension;
262 - return self::printFormSection( $label, $color, $html, 'white', true, $hasExistingValues );
 185+ return self::printFormSection( $label, $color, $html, null, $hasExistingValues );
263186 }
264187
265188 /**
266189 * Returns the HTML for a section of the form comprising one
267190 * template field.
268191 */
269 - static function printFieldSection( $field_xml = null, $pageSchemaField = null, $field_count = 'fnum' ) {
 192+ static function printFieldSection( $field_xml = null, $pageSchemaField = null ) {
 193+ if ( is_null( $field_xml ) ) {
 194+ $fieldNum = 'fnum';
 195+ } else {
 196+ global $wgPageSchemasFieldNum;
 197+ $fieldNum = $wgPageSchemasFieldNum;
 198+ $wgPageSchemasFieldNum++;
 199+ }
 200+
270201 $fieldName = '';
271202 $delimiter = '';
272203 $fieldLabel = '';
273204 $isListAttrs = array( 'class' => 'isListCheckbox' );
274205 $delimiterAttrs = array( 'class' => 'delimiterInput' );
 206+ $text = "\n\t\t\t";
275207 if ( is_null( $field_xml ) ) {
276 - $text = '<div class="fieldBox" id="starterField" style="display: none" >';
 208+ $text .= '<div class="fieldBox" id="starterField" style="display: none" >';
277209 } else {
278 - $text = '<div class="fieldBox" >';
 210+ $text .= '<div class="fieldBox" >';
279211 $fieldName = (string)$field_xml->attributes()->name;
280212 if ( ((string)$field_xml->attributes()->delimiter) != null || ((string)$field_xml->attributes()->delimiter) != '' ) {
281213 $delimiter = (string)$field_xml->attributes()->delimiter;
@@ -288,15 +220,15 @@
289221 $isListAttrs['checked'] = 'checked';
290222 }
291223 }
292 - $fieldHTML = '<p>Field name: ';
293 - $fieldHTML .= Html::input( 'f_name_' . $field_count, $fieldName, 'text', array( 'size' => 15 ) ) . ' ';
 224+ $fieldHTML = wfMsg( 'ps-namelabel' ) . ' ';
 225+ $fieldHTML .= Html::input( 'f_name_' . $fieldNum, $fieldName, 'text', array( 'size' => 15 ) ) . ' ';
294226 $fieldHTML .= wfMsg( 'ps-displaylabel' ) . ' ';
295 - $fieldHTML .= Html::input( 'f_label_' . $field_count, $fieldLabel, 'text', array( 'size' => 15 ) );
296 - $fieldHTML .= "\t\t</p>\n";
297 - $fieldIsListInput = Html::input( 'f_is_list_' . $field_count, null, 'checkbox', $isListAttrs );
 227+ $fieldHTML .= Html::input( 'f_label_' . $fieldNum, $fieldLabel, 'text', array( 'size' => 15 ) );
 228+ $fieldHTML = Html::rawElement( 'p', null, $fieldHTML ) . "\n";
 229+ $fieldIsListInput = Html::input( 'f_is_list_' . $fieldNum, null, 'checkbox', $isListAttrs );
298230 $fieldHTML .= Html::rawElement( 'p', null, $fieldIsListInput . ' ' . wfMsg( 'ps-field-list-label' ) );
299 - $fieldDelimiterInput = Html::input ( 'f_delimiter_' . $field_count, $delimiter, 'text', array( 'size' => 3 ) );
300 - $fieldHTML .= Html::rawElement( 'p', $delimiterAttrs, wfMsg( 'ps-delimiter-label' ) . ' ' . $fieldDelimiterInput );
 231+ $fieldDelimiterInput = Html::input ( 'f_delimiter_' . $fieldNum, $delimiter, 'text', array( 'size' => 3 ) );
 232+ $fieldHTML .= "\n" . Html::rawElement( 'p', $delimiterAttrs, wfMsg( 'ps-delimiter-label' ) . ' ' . $fieldDelimiterInput );
301233
302234 // Insert HTML text from extensions
303235 $htmlFromExtensions = array();
@@ -308,20 +240,17 @@
309241 // their number set via Javascript) and field names from
310242 // other extensions (which get their number set via PHP).
311243 // Is this important to do? Probably not.
312 - $fieldHTML .= str_replace( 'num', $field_count, $html );
 244+ $fieldHTML .= str_replace( 'num', $fieldNum, $html );
313245 }
314246
315 - $add_xml_label = wfMsg('ps-add-xml-label');
316 - $fieldHTML .= <<<END
317 - <p>$add_xml_label
318 - <textarea rows=4 style="width: 100%" name="f_add_xml_$field_count"></textarea>
319 - </p>
320 -
321 -END;
 247+ // TODO - this needs to get set.
 248+ $field_add_xml = null;
 249+ $additionalXMLInput = "\n\t\t\t\t" . Html::textarea( "f_add_xml_$fieldNum", $field_add_xml, array( 'rows' => 4, 'style' => 'width: 100%;' ) );
 250+ $fieldHTML .= "<p>" . wfMsg('ps-add-xml-label') . $additionalXMLInput . "</p>\n";
322251 $fieldHTML .= Html::input( 'remove-field', wfMsg( 'ps-remove-field' ), 'button',
323252 array( 'class' => 'deleteField' )
324253 );
325 - $text .= self::printFormSection( wfMsg( 'ps-field' ), '#AAA', $fieldHTML, '#CCC' );
 254+ $text .= "\n" . self::printFormSection( wfMsg( 'ps-field' ), '#AAA', $fieldHTML, 'editSchemaFieldSection' );
326255 $text .= "\t</div><!-- fieldBox -->\n";
327256 return $text;
328257 }
@@ -336,63 +265,72 @@
337266 $pageSchemaTemplateFields = $pageSchemaTemplate->getFields();
338267 }
339268 $attrs = array();
 269+ $templateXMLElements = array();
 270+ $text = "\t";
340271 if ( is_null( $template_xml ) ) {
341 - $text = '<div class="templateBox" id="starterTemplate" style="display: none">';
 272+ $text .= '<div class="templateBox" id="starterTemplate" style="display: none">' . "\n";
342273 $templateName = '';
343 - $fields_xml_array = array( null );
344274 } else {
345 - $text = '<div class="templateBox" >';
 275+ $text .= '<div class="templateBox" >' . "\n";
346276 $templateName = (string) $template_xml->attributes()->name;
347277 if ( ( (string)$template_xml->attributes()->multiple ) == "multiple" ) {
348278 $attrs['checked'] = 'checked';
349279 }
350 - $fields_xml_array = $template_xml->children();
 280+ $templateXMLElements = $template_xml->children();
351281 }
352 - $templateNameInput = Html::input( 't_name_' . $template_num, $templateName, 'text' );
353 - $templateHTML = '<p>Name: ' . $templateNameInput . '</p> ';
 282+ $templateNameInput = wfMsg( 'ps-namelabel' ) . ' ';
 283+ $templateNameInput .= Html::input( 't_name_' . $template_num, $templateName, 'text' );
 284+ $templateHTML = "\t\t" . Html::rawElement( 'p', null, $templateNameInput ) . "\n";
354285 $templateIsMultipleInput = Html::input( 'is_multiple_' . $template_num, null, 'checkbox', $attrs );
355 - $templateHTML .= Html::rawElement( 'p', null, $templateIsMultipleInput . ' ' . wfMsg( 'ps-multiple-temp-label' ) );
 286+ $templateHTML .= "\t\t" . Html::rawElement( 'p', null, $templateIsMultipleInput . ' ' . wfMsg( 'ps-multiple-temp-label' ) );
356287 $template_add_xml = "";
357 - foreach ( $fields_xml_array as $field_xml ) {
358 - if ( !empty( $field_xml ) && $field_xml->getName() != 'Field' ) {
359 - $template_add_xml .= (string)$field_xml->asXML();
 288+ // TODO - set this correctly.
 289+ /*
 290+ foreach ( $templateXMLElements as $templateXMLElement ) {
 291+ if ( !empty( $templateXMLElement ) && $templateXMLElement->getName() != 'Field' ) {
 292+ $template_add_xml .= (string)$templateXMLElement->asXML();
360293 }
361294 }
362 - $templateHTML .= '<div id="fieldsList_'.$template_num.'">';
363 - $field_count = 0;
364 - foreach ( $fields_xml_array as $field_xml ) {
365 - if ( empty( $field_xml ) ) {
366 - $templateHTML .= self::printFieldSection();
367 - } elseif ( $field_xml->getName() == "Field" ) {
368 - $pageSchemaField = $pageSchemaTemplateFields[$field_count];
369 - $templateHTML .= self::printFieldSection( $field_xml, $pageSchemaField, $field_count );
370 - $field_count++;
 295+ */
 296+
 297+ $htmlForTemplate = array();
 298+ wfRunHooks( 'PageSchemasGetTemplateHTML', array( $pageSchemaTemplate, &$htmlForTemplate ) );
 299+ foreach ( $htmlForTemplate as $valuesFromExtension ) {
 300+ $html = self::printFieldHTMLForExtension( $valuesFromExtension );
 301+ $templateHTML .= str_replace( 'num', $template_num, $html );
 302+ }
 303+
 304+ $templateHTML .= "\n\t\t" . '<div class="fieldsList">';
 305+ $fieldNumInTemplate = 0;
 306+ // If this is a "starter" template, create the starter
 307+ // field HTML.
 308+ if ( is_null( $pageSchemaTemplate ) ) {
 309+ $templateHTML .= self::printFieldSection();
 310+ }
 311+ foreach ( $templateXMLElements as $templateXMLElement ) {
 312+ if ( empty( $templateXMLElement ) ) {
 313+ // Do nothing (?)
 314+ } elseif ( $templateXMLElement->getName() == "Field" ) {
 315+ $pageSchemaField = $pageSchemaTemplateFields[$fieldNumInTemplate];
 316+ $templateHTML .= self::printFieldSection( $templateXMLElement, $pageSchemaField );
 317+ $fieldNumInTemplate++;
371318 }
372319 }
373320 $templateHTML .= "\t</div><!-- fieldsList -->\n";
374 - $templateHTML .=<<<END
375 -<script type="text/javascript">
376 - $(document).ready(function() {
377 - updateFieldNum($field_count);
378 - });
379 -</script>
380 -
381 -END;
382321 $add_field_button = Xml::element( 'input',
383322 array(
384323 'type' => 'button',
 324+ 'class' => 'editSchemaAddField',
385325 'value' => wfMsg( 'ps-add-field' ),
386 - 'onclick' => "psAddField($template_num)"
387326 )
388327 );
389328 $templateHTML .= Xml::tags( 'p', null, $add_field_button ) . "\n";
390 - $templateHTML .= '<hr />
391 - <p>'. wfMsg('ps-add-xml-label') .'
392 - <textarea rows=4 style="width: 100%" name="t_add_xml_'.$template_num.'">'.$template_add_xml.'</textarea>
393 - </p>';
 329+ $templateHTML .= "<hr />\n";
 330+ $additionalXMLInput = "\n\t\t\t\t" . Html::textarea( "t_add_xml_$template_num", $template_add_xml, array( 'rows' => 4, 'style' => 'width: 100%;' ) );
 331+ $templateHTML .= "\n<p>" . wfMsg('ps-add-xml-label') . "\n\t\t\t\t" . $additionalXMLInput . "\n\t\t\t</p>";
394332 $templateHTML .= '<p>' . Html::input( 'remove-template', 'Remove template', 'button', array( 'class' => 'deleteTemplate' ) ) . "</p>\n";
395 - $text .= self::printFormSection( wfMsg( 'ps-template' ), '#CCC', $templateHTML, '#EEE' );
396 - $text .= " </div><!-- templateBox-->";
 333+ $text .= self::printFormSection( wfMsg( 'ps-template' ), '#CCC', $templateHTML, 'editSchemaTemplateSection' );
 334+ $text .= "\t</div><!-- templateBox-->\n";
397335 return $text;
398336 }
399337
@@ -416,22 +354,24 @@
417355 }
418356
419357 $ps_add_xml = '';
 358+ // TODO - set this correctly.
 359+ /*
420360 foreach ( $pageXMLChildren as $template_xml ) {
421 - if ( ( $template_xml->getName() != 'Template') && ( $template_xml->getName() != 'semanticforms_Form' ) ) {
 361+ if ( $template_xml->getName() != 'Template') {
422362 $ps_add_xml .= (string)$template_xml->asXML();
423363 }
424364 }
 365+ */
425366
426 - $text = '<form id="editPageSchemaForm" action="" method="post">' . "\n";
427 - $text .= '<p>' . wfMsg('ps-add-xml-label') . '
428 - <textarea rows=4 style="width: 100%" name="ps_add_xml" >' . $ps_add_xml . '</textarea>
429 - </p> ';
 367+ $text = '<form id="editSchemaForm" action="" method="post">' . "\n";
 368+ $additionalXMLInput = "\n\t\t\t\t" . Html::textarea( 'ps_add_xml', $ps_add_xml, array( 'rows' => 4, 'style' => 'width: 100%;' ) );
 369+ $text .= '<p>' . wfMsg('ps-add-xml-label') . $additionalXMLInput . "\n</p>";
430370
431371 foreach ( $htmlForSchema as $valuesFromExtension ) {
432372 $text .= self::printFieldHTMLForExtension( $valuesFromExtension );
433373 }
434374
435 - $text .= '<div id="templatesList">';
 375+ $text .= '<div id="templatesList">' . "\n";
436376
437377 $template_num = 0;
438378
@@ -448,8 +388,8 @@
449389 $add_template_button = Xml::element( 'input',
450390 array(
451391 'type' => 'button',
 392+ 'class' => 'editSchemaAddTemplate',
452393 'value' => wfMsg( 'ps-add-template' ),
453 - 'onclick' => "psAddTemplate()"
454394 )
455395 );
456396 $text .= "\t</div><!-- templatesList -->\n";
@@ -482,7 +422,7 @@
483423
484424 $this->setHeaders();
485425 $text = '<p>' . wfMsg( 'ps-page-desc-edit-schema' ) . '</p>';
486 - self::addJavascript();
 426+ PageSchemas::addJavascriptAndCSS();
487427
488428 $save_page = $wgRequest->getCheck( 'wpSave' );
489429 if ( $save_page ) {
Index: trunk/extensions/PageSchemas/PageSchemas.php
@@ -24,7 +24,7 @@
2525 'path' => __FILE__,
2626 'name' => 'Page Schemas',
2727 'author' => array( 'Ankit Garg', 'Yaron Koren' ),
28 - 'version' => '0.1',
 28+ 'version' => '0.2-alpha',
2929 'url' => 'http://www.mediawiki.org/wiki/Extension:PageSchemas',
3030 'descriptionmsg' => 'ps-desc',
3131 );
@@ -36,10 +36,9 @@
3737 $wgExtensionMessagesFiles['PageSchemas'] = $dir . 'PageSchemas.i18n.php';
3838
3939 //Job classes
40 -$wgJobClasses['createPage'] = 'PSCreatePageJob';
 40+$wgJobClasses['pageSchemasCreatePage'] = 'PSCreatePageJob';
4141 $wgAutoloadClasses['PSCreatePageJob'] = $dir . 'PS_CreatePageJob.php';
4242
43 -
4443 // Register auto load for the special page class
4544 $wgAutoloadClasses['PageSchemasHooks'] = $dir . 'PageSchemas.hooks.php';
4645 $wgAutoloadClasses['PageSchemas'] = $dir . 'PageSchemas.classes.php';
@@ -62,3 +61,25 @@
6362 $wgHooks['UnknownAction'][] = 'PSTabs::onUnknownAction';
6463 $wgHooks['SkinTemplateTabs'][] = 'PSTabs::displayTabs';
6564 $wgHooks['SkinTemplateNavigation'][] = 'PSTabs::displayTabs2';
 65+
 66+// Register client-side modules
 67+$pageSchemasResourceTemplate = array(
 68+ 'localBasePath' => $dir,
 69+ 'remoteExtPath' => 'PageSchemas'
 70+);
 71+$wgResourceModules += array(
 72+ 'ext.pageschemas.main' => $pageSchemasResourceTemplate + array(
 73+ 'scripts' => array(
 74+ 'PageSchemas.js',
 75+ ),
 76+ 'styles' => array(
 77+ 'PageSchemas.css',
 78+ ),
 79+ 'dependencies' => array(
 80+ 'jquery',
 81+ ),
 82+ ),
 83+);
 84+
 85+// Page Schemas global variables
 86+$wgPageSchemasFieldNum = 0;
Index: trunk/extensions/PageSchemas/PageSchemas.css
@@ -1,4 +1,11 @@
2 -.pageSchema td {
 2+/**
 3+ * Used to display page schema information directly on the category page.
 4+ */
 5+table.pageSchema {
 6+ border: 1px solid #ccc;
 7+}
 8+
 9+table.pageSchema td {
310 padding-right: 5px;
411 }
512
@@ -7,96 +14,92 @@
815 padding-left: 5px;
916 }
1017
11 -.pageSchema .paramGroup {
12 - background: #bbaa88;
 18+table.pageSchema .pageSchemaHeader {
1319 padding-left: 5px;
1420 }
1521
16 -body.rtl .pageSchema .paramGroup {
 22+body.rtl .pageSchema .pageSchemaHeader {
1723 padding-left: auto;
1824 padding-right: 5px;
1925 }
2026
21 -.pageSchema .paramGroup span.rowValue {
 27+table.pageSchema .pageSchemaHeader span.rowValue {
2228 font-weight: bold;
2329 }
2430
25 -.pageSchema .param {
26 - background: #d3c2a0;
27 - padding-left: 20px;
 31+.pageSchema .schemaExtensionRow {
 32+ padding-left: 5px;
2833 }
2934
30 -body.rtl .pageSchema .param {
 35+body.rtl .pageSchema .schemaExtensionRow {
3136 padding-left: auto;
32 - padding-right: 20px;
 37+ padding-right: 5px;
3338 }
3439
35 -.pageSchema .param span.rowValue {
 40+.pageSchema .schemaAttrRow {
 41+ padding-left: 25px;
 42+ background: white;
3643 font-weight: bold;
3744 }
3845
39 -.pageSchema .paramAttr {
40 - background: #eeddbb;
41 - padding-left: 35px;
42 -}
43 -
44 -body.rtl .pageSchema .paramAttr {
 46+body.rtl .pageSchema .schemaAttrRow {
4547 padding-left: auto;
46 - padding-right: 35px;
 48+ padding-left: 25px;
4749 }
4850
49 -.pageSchema .paramAttrMsg {
50 - background: #ffeecc;
51 - padding-left: 50px;
 51+table.pageSchema .templateRow {
 52+ background: #d3c2a0;
 53+ padding-left: 5px;
5254 }
5355
54 -body.rtl .pageSchema .paramAttrMsg {
 56+body.rtl .pageSchema .templaterow {
5557 padding-left: auto;
56 - padding-right: 50px;
 58+ padding-right: 5px;
5759 }
5860
59 -.pageSchema .paramOptions {
60 - padding-left: 20px;
61 - background: #ffff77;
 61+.pageSchema span.rowValue {
 62+ font-weight: bold;
6263 }
6364
64 -body.rtl .pageSchema .paramOptions {
 65+.pageSchema .fieldRow {
 66+ background: #eeddbb;
 67+ padding-left: 25px;
 68+}
 69+
 70+body.rtl .pageSchema .fieldRow {
6571 padding-left: auto;
66 - padding-right: 20px;
 72+ padding-right: 25px;
6773 }
6874
69 -.pageSchema .paramOption {
70 - padding-left: 35px;
71 - background: #ffff99;
 75+.pageSchema .fieldExtensionRow {
 76+ padding-left: 26px;
 77+ border-top: 1px solid #ddd;
7278 }
7379
74 -body.rtl .pageSchema .paramOption {
 80+body.rtl .pageSchema .fieldExtensionRow {
7581 padding-left: auto;
76 - padding-right: 35px;
 82+ padding-right: 26px;
7783 }
7884
79 -.pageSchema .paramOption span.rowValue {
 85+.pageSchema .fieldAttrRow {
 86+ padding-left: 45px;
 87+ background: white;
8088 font-weight: bold;
8189 }
8290
83 -.pageSchema .paramOptionMsg {
84 - padding-left: 50px;
85 - background: #ffffbb;
86 -}
87 -
88 -body.rtl .pageSchema .paramOptionMsg {
 91+body.rtl .pageSchema .fieldAttrRow {
8992 padding-left: auto;
90 - padding-right: 50px;
 93+ padding-left: 45px;
9194 }
9295
9396 .pageSchema .paramData {
94 - padding-left: 20px;
 97+ padding-left: 5px;
9598 background: #77dd77;
9699 }
97100
98101 body.rtl .pageSchema .paramData {
99102 padding-left: auto;
100 - padding-right: 20px;
 103+ padding-right: 5px;
101104 }
102105
103106 .pageSchema .paramData span.rowValue {
@@ -122,3 +125,28 @@
123126 padding-left: auto;
124127 padding-right: 5px;
125128 }
 129+
 130+/**
 131+ * Used in Special:EditSchema
 132+ */
 133+div.editSchemaSection {
 134+ border: 1px #999 solid;
 135+ background: white;
 136+ padding: 0px;
 137+ margin-bottom: 10px;
 138+ margin-top: 10px;
 139+}
 140+div.editSchemaTemplateSection {
 141+ background: #EEE;
 142+}
 143+div.editSchemaFieldSection {
 144+ background: #CCC;
 145+}
 146+div.editSchemaSection .sectionHeader {
 147+ font-weight: bold;
 148+ padding: 4px 7px;
 149+ border-bottom: 1px #bbb solid;
 150+}
 151+div.editSchemaSection .sectionBody {
 152+ padding: 5px 15px;
 153+}
Index: trunk/extensions/PageSchemas/PageSchemas.hooks.php
@@ -10,17 +10,16 @@
1111
1212 // Initialization
1313 public static function register( &$parser ) {
14 - global $wgOut, $wgScriptPath;
15 -
1614 // Register the hook with the parser
1715 $parser->setHook( 'PageSchema', array( 'PageSchemasHooks', 'render' ) );
18 - // add the CSS
19 - $wgOut->addStyle( $wgScriptPath . '/extensions/PageSchemas/PageSchemas.css' );
2016 return true;
2117 }
2218
2319 // Render the displayed XML, if any
2420 public static function render( $input, $args, $parser, $frame ) {
 21+ // Disable cache so that CSS will get loaded
 22+ $parser->disableCache();
 23+
2524 // If this call is contained in a transcluded page or template,
2625 // or if the input is empty, display nothing.
2726 if ( !$frame->title->equals( $parser->getTitle() ) || $input == '' ) {
@@ -38,7 +37,10 @@
3938 if ( $xml_object = PageSchemas::validateXML( $input, $error_msg ) ) {
4039 // Store the XML in the page_props table
4140 $parser->getOutput()->setProperty( 'PageSchema', $input );
42 - $text = PageSchemas::parsePageSchemas( $xml_object );
 41+ // Display the schema on the screen
 42+ global $wgOut, $wgScriptPath;
 43+ $wgOut->addStyle( $wgScriptPath . '/extensions/PageSchemas/PageSchemas.css' );
 44+ $text = PageSchemas::displaySchema( $xml_object );
4345 } else {
4446 // Store error message in the page_props table
4547 $parser->getOutput()->setProperty( 'PageSchema', $error_msg );
Index: trunk/extensions/PageSchemas/PageSchemas.js
@@ -0,0 +1,106 @@
 2+/**
 3+ * Javascript for the Page Schemas extension.
 4+ *
 5+ * @author Ankit Garg
 6+ * @author Yaron Koren
 7+ */
 8+
 9+
 10+var fieldNum = jQuery('.fieldBox:visible').length;
 11+var templateNum = jQuery('.templateBox:visible').length;
 12+
 13+jQuery.fn.editSchemaMakeTemplateDeleter = function() {
 14+ jQuery(this).click( function() {
 15+ // Remove the encompassing div for this instance.
 16+ jQuery(this).closest(".templateBox")
 17+ .fadeOut('fast', function() { jQuery(this).remove(); });
 18+ });
 19+}
 20+
 21+jQuery.fn.editSchemaMakeFieldDeleter = function() {
 22+ jQuery(this).click( function() {
 23+ // Remove the encompassing div for this instance.
 24+ jQuery(this).closest(".fieldBox")
 25+ .fadeOut('fast', function() { jQuery(this).remove(); });
 26+ });
 27+}
 28+
 29+jQuery.fn.editSchemaMakeFieldAdder = function() {
 30+ jQuery(this).click( function() {
 31+ newField = jQuery('#starterField').clone().css('display', '').removeAttr('id');
 32+ newHTML = newField.html().replace(/fnum/g, fieldNum);
 33+ newField.html(newHTML);
 34+ newField.find(".deleteField").editSchemaMakeFieldDeleter();
 35+ jQuery(this).closest('.templateBox').find('.fieldsList').append(newField);
 36+ // TODO - have this apply only to the added field, instead of all fields.
 37+ jQuery(".deleteField").editSchemaMakeFieldDeleter();
 38+ jQuery('.sectionCheckbox').click(function() {
 39+ jQuery(this).editSchemaToggleSectionDisplay();
 40+ });
 41+ jQuery('.isListCheckbox').click(function() {
 42+ jQuery(this).editSchemaToggleDelimiterInput();
 43+ });
 44+ fieldNum++;
 45+ } );
 46+}
 47+
 48+jQuery.fn.editSchemaMakeTemplateAdder = function() {
 49+ jQuery(this).click( function() {
 50+ newField = jQuery('#starterTemplate').clone().css('display', '').remove('#starterField').removeAttr('id');
 51+ newHTML = newField.html().replace(/tnum/g, templateNum);
 52+ newField.html(newHTML);
 53+ newField.find(".deleteTemplate").editSchemaMakeTemplateDeleter();
 54+ jQuery('#templatesList').append(newField);
 55+ // TODO - have this apply only to the added template, instead of all templates.
 56+ jQuery(".editSchemaAddField").editSchemaMakeFieldAdder();
 57+ jQuery('.sectionCheckbox').click(function() {
 58+ jQuery(this).editSchemaToggleSectionDisplay();
 59+ });
 60+ jQuery('.isListCheckbox').click(function() {
 61+ jQuery(this).editSchemaToggleDelimiterInput();
 62+ });
 63+ templateNum++;
 64+ } );
 65+}
 66+
 67+jQuery.fn.editSchemaToggleDelimiterInput = function() {
 68+ if (this.is(":checked")) {
 69+ this.closest('.fieldBox').find('.delimiterInput').css('display', '');
 70+ } else {
 71+ this.closest('.fieldBox').find('.delimiterInput').css('display', 'none');
 72+ }
 73+}
 74+
 75+jQuery.fn.editSchemaToggleSectionDisplay = function() {
 76+ if (this.is(":checked")) {
 77+ this.closest('.editSchemaSection').find('.sectionBody').css('display', '').removeClass('hiddenSection');
 78+ } else {
 79+ this.closest('.editSchemaSection').find('.sectionBody').css('display', 'none').addClass('hiddenSection');
 80+ }
 81+}
 82+
 83+jQuery(document).ready(function() {
 84+ // Add and delete buttons
 85+ jQuery(".deleteTemplate").editSchemaMakeTemplateDeleter();
 86+ jQuery(".editSchemaAddTemplate").editSchemaMakeTemplateAdder();
 87+ jQuery(".deleteField").editSchemaMakeFieldDeleter();
 88+ jQuery(".editSchemaAddField").editSchemaMakeFieldAdder();
 89+
 90+ // Checkboxes
 91+ jQuery('.isListCheckbox').each(function() {
 92+ jQuery(this).editSchemaToggleDelimiterInput();
 93+ });
 94+ jQuery('.isListCheckbox').click(function() {
 95+ jQuery(this).editSchemaToggleDelimiterInput();
 96+ });
 97+ jQuery('.sectionCheckbox').each(function() {
 98+ jQuery(this).editSchemaToggleSectionDisplay();
 99+ });
 100+ jQuery('.sectionCheckbox').click(function() {
 101+ jQuery(this).editSchemaToggleSectionDisplay();
 102+ });
 103+ jQuery('#editSchemaForm').submit( function() {
 104+ jQuery(':hidden').find("input, select, textarea").attr('disabled', 'disabled');
 105+ return true;
 106+ } );
 107+});

Status & tagging log