r93467 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93466‎ | r93467 | r93468 >
Date:16:37, 29 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
added code For Extensions to generate html-text for the form
Modified paths:
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -82,42 +82,50 @@
8383 $text_1 = '<p>This category does not exist yet. Create this category and its page schema: </p>';
8484 $text_2 = '<p>This category exists, but does not have a page schema. Create schema:" </p>';
8585 $text_3 = '<p>This category exists,have a page schema. Edit schema:" </p>';
86 - self::addJavascript();
87 - $text = "";
88 - $text .= '<p>This category does not exist yet. Create this category and its page schema: </p>';
89 - $text .= ' <form id="createPageSchemaForm" action="" method="post">' . "\n";
90 - $text .= '<p>Name of schema: <input type="text" name="s_name"/> </p> ';
91 - $text .= '<p>Additional XML:
92 - <textarea rows=4 style="width: 100%" name="ps_add_xml"></textarea>
93 - </p> ';
94 - $text .= '<div id="templatesList">';
95 - $text .= '<div class="templateBox" >';
96 - $text .= '<fieldset style="background: #ddd;"><legend>Template</legend> ';
97 - $text .= '<p>Name: <input type="text" name="t_name_1"/></p> ';
98 - $text .= '<p><input type="checkbox" name="is_multiple_1"/> Allow multiple instances of this template</p> ';
99 - $text .= '<div id="fieldsList_1">';
100 - $text .= '<div class="fieldBox" >';
101 - $text .= '<fieldset style="background: #bbb;"><legend>Field</legend>
102 - <p>Field name: <input size="15" name="f_name_1">
103 - Display label: <input size="15" name="f_label_1">
104 - </p>
105 - <p><input type="checkbox" name="f_is_list_1" class="isListCheckbox" />
106 - This field can hold a list of values
107 - </p>
108 - <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_1" /> </p></div>
109 - <p>Additional XML:
110 - <textarea rows=4 style="width: 100%" name="f_add_xml_1"></textarea>
111 - </p>
112 - <input type="button" value="Remove field" class="deleteField" /></fieldset>
113 - </div>
114 - </div>
115 - ';
116 - $add_field_button = Xml::element( 'input',
117 - array(
118 - 'type' => 'button',
119 - 'value' => 'Add Field',
120 - 'onclick' => "createTemplateAddField(1)"
121 - )
 86+ self::addJavascript();
 87+ $text_extensions = array(); //This var. will save the html text returned by the extensions
 88+ $js_extensions = array();
 89+ wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions ));
 90+
 91+ $text = "";
 92+ $text .= '<p>This category does not exist yet. Create this category and its page schema: </p>';
 93+ $text .= ' <form id="createPageSchemaForm" action="" method="post">' . "\n";
 94+ $text .= '<p>Name of schema: <input type="text" name="s_name"/> </p> ';
 95+ $text .= '<p>Additional XML:
 96+ <textarea rows=4 style="width: 100%" name="ps_add_xml"></textarea>
 97+ </p> ';
 98+ $text .= '<div id="templatesList">';
 99+ $text .= '<div class="templateBox" >';
 100+ $text .= '<fieldset style="background: #ddd;"><legend>Template</legend> ';
 101+ $text .= '<p>Name: <input type="text" name="t_name_1"/></p> ';
 102+ $text .= '<p><input type="checkbox" name="is_multiple_1"/> Allow multiple instances of this template</p> ';
 103+ $text .= '<div id="fieldsList_1">';
 104+ $text .= '<div class="fieldBox" >';
 105+ $text .= '<fieldset style="background: #bbb;"><legend>Field</legend>
 106+ <p>Field name: <input size="15" name="f_name_1">
 107+ Display label: <input size="15" name="f_label_1">
 108+ </p>
 109+ <p><input type="checkbox" name="f_is_list_1" class="isListCheckbox" />
 110+ This field can hold a list of values
 111+ </p>
 112+ <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_1" /> </p></div>';
 113+ foreach( $text_extensions as $text_ex ){
 114+ $text_ex = preg_replace('/starter/', '1', $text_ex);
 115+ $text .= $text_ex ;
 116+ }
 117+ $text .= '<p>Additional XML:
 118+ <textarea rows=4 style="width: 100%" name="f_add_xml_1"></textarea>
 119+ </p>
 120+ <input type="button" value="Remove field" class="deleteField" /></fieldset>
 121+ </div>
 122+ </div>
 123+ ';
 124+ $add_field_button = Xml::element( 'input',
 125+ array(
 126+ 'type' => 'button',
 127+ 'value' => 'Add Field',
 128+ 'onclick' => "createTemplateAddField(1)"
 129+ )
122130 );
123131 $text .= Xml::tags( 'p', null, $add_field_button ) . "\n";
124132 $text .= '<hr />
@@ -165,8 +173,11 @@
166174 </p>
167175 <p><input type="checkbox" name="f_is_list_starter" class="isListCheckbox" /> This field can hold a list of values
168176 &#160;&#160;</p>
169 - <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_starter" /> </p></div>
170 - <p>Additional XML:
 177+ <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_starter" /> </p></div>';
 178+ foreach( $text_extensions as $text_ex ){
 179+ $text .= $text_ex ;
 180+ }
 181+ $text .= '<p>Additional XML:
171182 <textarea rows=4 style="width: 100%" name="f_add_xml_starter"></textarea>
172183 </p>
173184 <input type="button" value="Remove field" class="deleteField" />
@@ -206,6 +217,13 @@
207218 }
208219 }else if(substr($var,0,8) == 'f_label_'){
209220 $Xmltext .= '<Label>'.$val.'</Label>';
 221+ //Get Xml parsed from extensions,
 222+ $text_extensions = array(); //This var. will save the html text returned by the extensions
 223+ $js_extensions = array();
 224+ wfRunHooks( 'getXmlTextForFieldInputs', array( $wgRequest, &$text_extensions ));
 225+ foreach( $text_extensions as $text_ex ){
 226+ $text .= $text_ex ;
 227+ }
210228 }else if(substr($var,0,10) == 'f_add_xml_'){
211229 $Xmltext .= $val;
212230 $Xmltext .= '</Field>';

Status & tagging log