r93207 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93206‎ | r93207 | r93208 >
Date:16:44, 26 July 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
supporing delimiter in PSTemplateField.
removing unnecessary javascript code.
Modified paths:
  • /trunk/extensions/PageSchemas/PageSchemas.classes.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/PageSchemas.classes.php
@@ -19,41 +19,10 @@
2020 global $wgOut;
2121 $output = $wgOut;
2222 }
23 - $output->addModules( 'ext.semanticforms.main' );
24 - $output->addModules( 'ext.semanticforms.fancybox' );
25 - $output->addModules( 'ext.semanticforms.autogrow' );
26 - $output->addModules( 'ext.semanticforms.submit' );
27 - $output->addModules( 'ext.smw.tooltips' );
28 - $output->addModules( 'ext.smw.sorttable' );
 23+ $output->addModules( 'jquery' );
2924 }
30 - /**
31 - * Javascript files to be added regardless of the MediaWiki version
32 - * (i.e., even if the ResourceLoader exists).
33 - */
34 - public static function addJavascriptFiles( $parser ) {
35 - global $wgOut, $wgFCKEditorDir, $wgScriptPath, $wgJsMimeType;
 25+
3626
37 - $scripts = array();
38 -
39 - wfRunHooks( 'sfAddJavascriptFiles', array( &$scripts ) );
40 -
41 - // The FCKeditor extension has no defined ResourceLoader
42 - // modules yet, so we have to call the scripts directly.
43 - // @TODO Move this code into the FCKeditor extension.
44 - if ( $wgFCKEditorDir && class_exists( 'FCKEditor' ) ) {
45 - $scripts[] = "$wgScriptPath/$wgFCKEditorDir/fckeditor.js";
46 - }
47 -
48 - foreach ( $scripts as $js ) {
49 - if ( $parser ) {
50 - $script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n";
51 - $parser->getOutput()->addHeadItem( $script );
52 - } else {
53 - $wgOut->addScriptFile( $js );
54 - }
55 - }
56 - }
57 -
5827 /**
5928 * Includes the necessary Javascript and CSS files for the form
6029 * to display and work correctly.
@@ -65,85 +34,13 @@
6635
6736 if ( !$parser ) {
6837 $wgOut->addMeta( 'robots', 'noindex,nofollow' );
69 - }
 38+ }
7039
71 - self::addJavascriptFiles( $parser );
72 -
7340 // MW 1.17 +
7441 if ( class_exists( 'ResourceLoader' ) ) {
7542 self::loadJavascriptAndCSS( $parser );
7643 return;
77 - }
78 - global $sfgScriptPath, $smwgScriptPath, $wgScriptPath, $wgJsMimeType, $sfgUseFormEditPage;
79 - global $smwgJQueryIncluded, $smwgJQUIAutoIncluded;
80 - // jQuery and jQuery UI are used so often in forms, we might as
81 - // well assume they'll always be used, and include them in
82 - // every form
83 - $smwgJQueryIncluded = true;
84 - $smwgJQUIAutoIncluded = true;
85 -
86 - $css_files = array(
87 - "$smwgScriptPath/skins/SMW_custom.css",
88 - "$sfgScriptPath/skins/jquery-ui/base/jquery.ui.all.css",
89 - "$sfgScriptPath/skins/SemanticForms.css",
90 - "$sfgScriptPath/skins/SF_submit.css",
91 - "$sfgScriptPath/skins/jquery.fancybox.css"
92 - );
93 - foreach ( $css_files as $css_file ) {
94 - $link = array(
95 - 'rel' => 'stylesheet',
96 - 'type' => 'text/css',
97 - 'media' => "screen",
98 - 'href' => $css_file
99 - );
100 - if ( !is_null( $parser ) ) {
101 - $parser->getOutput()->addHeadItem( Xml::element( 'link', $link ) );
102 - } else {
103 - $wgOut->addLink( $link );
104 - }
105 - }
106 -
107 - $scripts = array();
108 - if ( !$sfgUseFormEditPage )
109 - $scripts[] = "$sfgScriptPath/libs/SF_ajax_form_preview.js";
110 - $realFunction = array( 'SMWOutputs', 'requireHeadItem' );
111 - if ( is_callable( $realFunction ) ) {
112 - SMWOutputs::requireHeadItem( SMW_HEADER_TOOLTIP );
113 - SMWOutputs::requireHeadItem( SMW_HEADER_SORTTABLE );
114 - // TODO - should this be called directly here, or is
115 - // there a "smarter" (in some way) place to put it?
116 - SMWOutputs::commitToOutputPage( $wgOut );
117 - } else {
118 - $scripts[] = "$smwgScriptPath/skins/SMW_tooltip.js";
119 - $scripts[] = "$smwgScriptPath/skins/SMW_sorttable.js";
120 - }
121 - $realFunction = array( 'OutputPage', 'includeJQuery' );
122 - if ( is_callable( $realFunction ) ) {
123 - $wgOut->includeJQuery();
124 - } else {
125 - $scripts[] = "$sfgScriptPath/libs/jquery-1.4.2.min.js";
126 - }
127 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.core.min.js";
128 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.widget.min.js";
129 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.button.min.js";
130 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.position.min.js";
131 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.autocomplete.min.js";
132 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.mouse.min.js";
133 - $scripts[] = "$sfgScriptPath/libs/jquery-ui/jquery.ui.sortable.min.js";
134 - $scripts[] = "$sfgScriptPath/libs/jquery.fancybox.js";
135 - $scripts[] = "$sfgScriptPath/libs/SF_autogrow.js";
136 - $scripts[] = "$sfgScriptPath/libs/SF_submit.js";
137 - $scripts[] = "$sfgScriptPath/libs/SemanticForms.js";
138 -
139 - global $wgOut;
140 - foreach ( $scripts as $js ) {
141 - if ( $parser ) {
142 - $script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n";
143 - $parser->getOutput()->addHeadItem( $script );
144 - } else {
145 - $wgOut->addScriptFile( $js );
146 - }
147 - }
 44+ }
14845 }
14946
15047 public static function titleString( $title ) {
@@ -439,19 +336,26 @@
440337 public $fieldName ="";
441338 public $fieldXml= null;
442339 public $fieldLabel = "";
443 - private $list_values = false;
 340+ private $list_values = false;
 341+ private $delimiter=null;
444342 function __construct( $field_xml ) {
445343 $this->fieldXml = $field_xml;
446344 $this->fieldName = (string)$this->fieldXml->attributes()->name;
447345 if( ((string)$this->fieldXml->attributes()->list) == "list") {
448346 $this->list_values = true;
449347 }
 348+ if( ((string)$this->fieldXml->attributes()->delimiter) != null || ((string)$this->fieldXml->attributes()->delimiter) != '' ){
 349+ $this->delimiter = (string)$this->fieldXml->attributes()->delimiter;
 350+ }
450351 foreach ($this->fieldXml->children() as $tag => $child ) {
451352 if ( $tag == 'Label' ) {
452353 $this->fieldLabel = (string)$child;
453354 }
454355 }
455356 }
 357+ public function getDelimiter(){
 358+ return $this->delimiter;
 359+ }
456360 function getName(){
457361 return $this->fieldName;
458362 }

Status & tagging log