r16676 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16675‎ | r16676 | r16677 >
Date:19:45, 27 September 2006
Author:mkroetzsch
Status:old
Tags:
Comment:
introduced new file for global functions, added globals for normalising strings
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (added) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -0,0 +1,230 @@
 2+<?php
 3+/**
 4+ * Global functions and constants for Semantic MediaWiki.
 5+ */
 6+
 7+/**********************************************/
 8+/***** Header modifications *****/
 9+/**********************************************/
 10+
 11+ /**
 12+ * This method is in charge of inserting additional CSS, JScript, and meta tags
 13+ * into the html header of each page. It is either called after initialising wgout
 14+ * (requiring a patch in MediaWiki), or during parsing. Calling it during parsing,
 15+ * however, is not sufficient to get the header modifiactions into every page that
 16+ * is shipped to a reader, since the parser cache can make parsing obsolete.
 17+ *
 18+ * $out is the modified OutputPage.
 19+ */
 20+ function smwfAddHTMLHeader(&$out) {
 21+ global $smwgHeadersInPlace; // record whether headers were created already
 22+ global $smwgArticleHeadersInPlace; // record whether article name specific headers are already there
 23+ global $smwgScriptPath;
 24+
 25+ if (!$smwgHeadersInPlace) {
 26+ $toolTipScript = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_tooltip.js"></script>';
 27+ $out->addScript($toolTipScript);
 28+ $sortTableScript = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_sorttable.js"></script>';
 29+ $out->addScript($sortTableScript);
 30+
 31+ // Also we add a custom CSS file for our needs
 32+ $customCssUrl = $smwgScriptPath . '/skins/SMW_custom.css';
 33+ $out->addLink(array(
 34+ 'rel' => 'stylesheet',
 35+ 'type' => 'text/css',
 36+ 'media' => 'screen, projection',
 37+ 'href' => $customCssUrl
 38+ ));
 39+ $smwgHeadersInPlace = true;
 40+ }
 41+
 42+ if ((!$smwgArticleHeadersInPlace) && ($out->mIsarticle) && ($out->mPagetitle!='')) {
 43+ //print_r('Article ADDHTML... "'. $out->mPagetitle .'"');
 44+ global $wgContLang, $wgServer, $wgScript;
 45+
 46+ $out->addLink(array(
 47+ 'rel' => 'alternate',
 48+ 'type' => 'application/rdf+xml',
 49+ 'title' => $out->mPagetitle,
 50+ 'href' => $wgServer . $wgScript . '/' .
 51+ $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' .
 52+ str_replace('%2F', "/", urlencode(str_replace(' ', '_', $out->mPagetitle))) . '?xmlmime=rdf'
 53+ ));
 54+ $smwgArticleHeadersInPlace = true;
 55+ }
 56+
 57+
 58+ return;
 59+ }
 60+
 61+/**********************************************/
 62+/***** namespace settings *****/
 63+/**********************************************/
 64+
 65+ /**
 66+ * Init the additional namepsaces used by Semantic MediaWiki. The
 67+ * parameter denotes the least unused even namespace ID that is
 68+ * greater or equal to 100.
 69+ */
 70+ function smwfInitNamespaces($base_idx) {
 71+ global $wgExtraNamespaces, $wgNamespacesWithSubpages, $wgLanguageCode, $smwgContLang;
 72+
 73+ smwfInitContentLanguage($wgLanguageCode);
 74+
 75+ $namespaceIndex=$base_idx;
 76+
 77+ define('SMW_NS_RELATION', $namespaceIndex);
 78+ define('SMW_NS_RELATION_TALK', $namespaceIndex+1);
 79+ define('SMW_NS_ATTRIBUTE', $namespaceIndex+2);
 80+ define('SMW_NS_ATTRIBUTE_TALK', $namespaceIndex+3);
 81+ define('SMW_NS_TYPE', $namespaceIndex+4);
 82+ define('SMW_NS_TYPE_TALK', $namespaceIndex+5);
 83+
 84+ // Register namespace identifiers
 85+ if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); }
 86+ $wgExtraNamespaces = $wgExtraNamespaces +
 87+ $smwgContLang->getNamespaceArray();
 88+
 89+ // Support subpages only for talk pages by default
 90+ $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
 91+ SMW_NS_RELATION_TALK => true,
 92+ SMW_NS_ATTRIBUTE_TALK => true,
 93+ SMW_NS_TYPE_TALK => true
 94+ );
 95+
 96+ // not modified for Semantic MediaWiki
 97+ /* $wgNamespacesToBeSearchedDefault = array(
 98+ NS_MAIN => true,
 99+ );
 100+ */
 101+ }
 102+
 103+/**********************************************/
 104+/***** language settings *****/
 105+/**********************************************/
 106+
 107+ /**
 108+ * Initialise a global language object for content language. This
 109+ * must happen early on, even before user language is known, to
 110+ * determine labels for additional namespaces. In contrast, messages
 111+ * can be initialised much later when they are actually needed.
 112+ */
 113+ function smwfInitContentLanguage($langcode) {
 114+ global $smwgIP, $smwgContLang;
 115+
 116+ if (!empty($smwgContLang)) { return; }
 117+
 118+ $smwContLangClass = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
 119+
 120+ if (file_exists($smwgIP . '/languages/'. $smwContLangClass . '.php')) {
 121+ include_once( $smwgIP . '/languages/'. $smwContLangClass . '.php' );
 122+ }
 123+
 124+ // fallback if language not supported
 125+ if ( !class_exists($smwContLangClass)) {
 126+ include_once($smwgIP . '/languages/SMW_LanguageEn.php');
 127+ $smwContLangClass = 'SMW_LanguageEn';
 128+ }
 129+
 130+ $smwgContLang = new $smwContLangClass();
 131+ }
 132+
 133+ /**
 134+ * Initialise the global language object for user language. This
 135+ * must happen after the content language was initialised, since
 136+ * this language is used as a fallback.
 137+ */
 138+ function smwfInitUserLanguage($langcode) {
 139+ global $smwgIP, $smwgLang;
 140+
 141+ if (!empty($smwgLang)) { return; }
 142+
 143+ $smwLangClass = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
 144+
 145+ if (file_exists($smwgIP . '/languages/'. $smwLangClass . '.php')) {
 146+ include_once( $smwgIP . '/languages/'. $smwLangClass . '.php' );
 147+ }
 148+
 149+ // fallback if language not supported
 150+ if ( !class_exists($smwLangClass)) {
 151+ global $smwgContLang;
 152+ $smwgLang = $smwgContLang;
 153+ } else {
 154+ $smwgLang = new $smwLangClass();
 155+ }
 156+ }
 157+
 158+ /**
 159+ * Initialise messages. These settings must be applied later on, since
 160+ * the MessageCache does not exist yet when the settings are loaded in
 161+ * LocalSettings.php.
 162+ */
 163+ function smwfInitMessages() {
 164+ global $smwgMessagesInPlace; // record whether the function was already called
 165+
 166+ if ($smwgMessagesInPlace) { return; }
 167+
 168+ global $wgMessageCache, $smwgContLang, $smwgLang;
 169+ global $wgContLanguageCode, $wgLanguageCode;
 170+ // make sure that language objects exist
 171+ smwfInitContentLanguage($wgContLanguageCode);
 172+ smwfInitUserLanguage($wgLanguageCode);
 173+
 174+ $wgMessageCache->addMessages($smwgContLang->getContentMsgArray());
 175+ $wgMessageCache->addMessages($smwgLang->getUserMsgArray());
 176+
 177+ $smwgMessagesInPlace = true;
 178+ }
 179+
 180+/**********************************************/
 181+/***** other global helpers *****/
 182+/**********************************************/
 183+
 184+ /**
 185+ * Return true if semantic data should be processed and displayed for this page.
 186+ * @return bool
 187+ */
 188+ function smwfIsSemanticsProcessed($namespace) {
 189+ global $smwgNamespacesWithSemanticLinks;
 190+ return !empty($smwgNamespacesWithSemanticLinks[$namespace]);
 191+ }
 192+
 193+
 194+ /**
 195+ * Takes a title text and turns it safely into its DBKey.
 196+ * This function reimplements the title normalization as done
 197+ * in Title.php in order to achieve conversion with less overhead.
 198+ */
 199+ function smwfNormalTitleDBKey( $text ) {
 200+ return str_replace(' ', '_', ucfirst($text));
 201+ ///// The long and secure way. Use if problems occur.
 202+ // $t = Title::newFromText( $text );
 203+ // if ($t != NULL) {
 204+ // return $t->getDBkey();
 205+ // }
 206+ // return $text;
 207+ }
 208+
 209+ /**
 210+ * Takes a text and turns it into a normalised version.
 211+ * This function reimplements the title normalization as done
 212+ * in Title.php in order to achieve conversion with less overhead.
 213+ */
 214+ function smwfNormalTitleText( $text ) {
 215+ return str_replace('_', ' ', ucfirst($text));
 216+ ///// The long and secure way. Use if problems occur.
 217+ // $t = Title::newFromText( $text );
 218+ // if ($t != NULL) {
 219+ // return $t->getText();
 220+ // }
 221+ // return $text;
 222+ }
 223+
 224+ /**
 225+ * Escapes text in a way that allows it to be used as XML
 226+ * content (e.g. as an string value for some property).
 227+ */
 228+ function smwfXMLContentEncode($text) {
 229+ return str_replace(array('&','<','>'),array('&amp;','&lt;','&gt;'),$text);
 230+ }
 231+?>
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php
@@ -468,7 +468,7 @@
469469
470470 function processValue($value,&$datavalue) {
471471 if ($value!='') { //do not accept empty strings
472 - $xsdvalue = str_replace(array('&','<','>'),array('&amp;','&lt;','&gt;'),$value);
 472+ $xsdvalue = smwfXMLContentEncode($value);
473473 // 255 below matches smw_attributes.value_xsd definition in smwfMakeSemanticTables()
474474 // Note that depending on database encoding and UTF-8 settings, longer or
475475 // shorter strings than this with int'l characters may exceed database field.
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php
@@ -214,7 +214,7 @@
215215 $this->mLimit = min($smwgIQMaxLimit, max(1,$param['limit'] + 0)); //integer between 1 and $smwgMaxLimit
216216 }
217217 if (array_key_exists('sort', $param)) {
218 - $this->mSort = $this->normalizeTitle($param['sort']);
 218+ $this->mSort = smwfNormalTitleDBKey($param['sort']);
219219 }
220220 if (array_key_exists('order', $param)) {
221221 if (('descending'==$param['order'])||('reverse'==$param['order'])||('desc'==$param['order'])) {
@@ -424,14 +424,14 @@
425425 if ('' == $label) $label = $wgContLang->getNSText(NS_CATEGORY);
426426 $result->mPrint['C'] = array($label,SMW_IQ_PRINT_CATS);
427427 } elseif ( '::' == $op ) {
428 - $result->mPrint['R:' . $qparts[0]] = array($label,SMW_IQ_PRINT_RELS,$this->normalizeTitle($qparts[0]));
 428+ $result->mPrint['R:' . $qparts[0]] = array($label,SMW_IQ_PRINT_RELS,smwfNormalTitleDBKey($qparts[0]));
429429 } elseif ( ':=' == $op ) {
430430 $av = SMWDataValue::newAttributeValue($qparts[0]);
431431 $unit = mb_substr($qparts[2],1);
432432 if ($unit != '') { // desired unit selected:
433433 $av->setDesiredUnits(array($unit));
434434 }
435 - $result->mPrint['A:' . $qparts[0]] = array($label,SMW_IQ_PRINT_ATTS,$this->normalizeTitle($qparts[0]),$av);
 435+ $result->mPrint['A:' . $qparts[0]] = array($label,SMW_IQ_PRINT_ATTS,smwfNormalTitleDBKey($qparts[0]),$av);
436436 } // else: operators like :=> are not supported for printing and are silently ignored
437437 $this->mPrintoutCount++;
438438 }
@@ -466,14 +466,14 @@
467467 $condition = "$pagetable.page_id=$curtable.cl_from";
468468 // TODO: make subcat-inclusion more efficient
469469 foreach ($values as $idx => $v) {
470 - $values[$idx] = $this->normalizeTitle($v);
 470+ $values[$idx] = smwfNormalTitleDBKey($v);
471471 }
472472 $this->includeSubcategories($values,$smwgIQSubcategoryInclusions);
473473 foreach ($values as $v) {
474474 $or_conditions[] = "$curtable.cl_to=" . $this->dbr->addQuotes($v);
475475 }
476476 } elseif ('::' == $op ) { // condition on relations
477 - $relation = $this->normalizeTitle($qparts[0]);
 477+ $relation = smwfNormalTitleDBKey($qparts[0]);
478478 $result->mTables .= ',' . $this->dbr->tableName('smw_relations') . " AS $curtable";
479479 $condition = "$pagetable.page_id=$curtable.subject_id AND $curtable.relation_title=" . $this->dbr->addQuotes($relation);
480480 if ('' != $sq_title) { // objects supplied by subquery
@@ -485,7 +485,7 @@
486486 // Also, redirects are not taken into account for sub-queries
487487 // anymore now.
488488 foreach ($values as $idx => $v) {
489 - $values[$idx] = $this->normalizeTitle($v);
 489+ $values[$idx] = smwfNormalTitleDBKey($v);
490490 }
491491 $value = $this->normalizeRedirects($values);
492492 // search for values
@@ -506,7 +506,7 @@
507507 //Note: I do not think we have to include redirects here. Redirects should not
508508 // have annotations, so one can just write up the query correctly! -- mak
509509 foreach ($values as $v) {
510 - $v = $this->normalizeTitle($v);
 510+ $v = smwfNormalTitleDBKey($v);
511511 if (':' == mb_substr($v,0,1)) $v = mb_substr($v,1); // remove initial ':'
512512 // TODO: should this be done when normalizing the title???
513513 $ns_idx = $wgContLang->getNsIndex(mb_substr($v,0,-2)); // assume format "Namespace:+"
@@ -519,7 +519,7 @@
520520 }
521521 }
522522 } else { // some attribute operator
523 - $attribute = $this->normalizeTitle($qparts[0]);
 523+ $attribute = smwfNormalTitleDBKey($qparts[0]);
524524 $av = SMWDataValue::newAttributeValue($attribute);
525525 switch ($op) {
526526 case ':=>': $comparator = '>='; break;
@@ -682,22 +682,6 @@
683683 return $categories;
684684 }
685685
686 - /**
687 - * Takes a text and turns it safely into its DBKey.
688 - * If it fails to do so, the text is returned unchanged.
689 - *
690 - * FIXME: should be (1) a global function that (2) directly
691 - * creates the DB key (currently a simple ucfirst + str_replace)
692 - * for higher efficiency.
693 - */
694 - function normalizeTitle( $text ) {
695 - $t = Title::newFromText( $text );
696 - if ($t != NULL) {
697 - return $t->getDBkey();
698 - }
699 - return $text;
700 - }
701 -
702686 /*********************************************************************/
703687 /* Output helper methods */
704688 /*********************************************************************/
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -76,7 +76,7 @@
7777 static function addAttribute($attribute, $value) {
7878 // See if this attribute is a special one like e.g. "Has type"
7979 global $smwgContLang;
80 - $attribute = ucfirst($attribute); //slightly normalize label
 80+ $attribute = smwfNormalTitleText($attribute); //slightly normalize label
8181 $specprops = $smwgContLang->getSpecialPropertiesArray();
8282 $special = array_search($attribute, $specprops);
8383
@@ -100,13 +100,12 @@
101101 }
102102 }
103103
104 -
105104 /**
106105 * This method adds a new relation with the given target to the storage.
107106 */
108107 static function addRelation($relation, $target) {
109108 global $smwgContLang;
110 - $relation = ucfirst($relation);
 109+ $relation = smwfNormalTitleText($relation);
111110 $srels = $smwgContLang->getSpecialPropertiesArray();
112111 $special = array_search($relation, $srels);
113112
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php
@@ -43,9 +43,12 @@
4444
4545
4646 // PHP fails to find relative includes at some level of inclusion:
47 -$pathfix = $IP . $smwgScriptPath;
 47+//$pathfix = $IP . $smwgScriptPath;
4848
49 -// load settings for inline queries first
 49+// load global functions
 50+require_once($smwgIP . '/includes/SMW_GlobalFunctions.php');
 51+
 52+// load (default) settings for inline queries first
5053 require_once($smwgIP . '/includes/SMW_InlineQueries.php');
5154
5255 // get local configuration ...
@@ -92,189 +95,6 @@
9396 /**********************************************/
9497
9598 global $wgExtensionCredits;
96 -$wgExtensionCredits['parserhook'][]= array('name'=>'Semantic MediaWiki', 'version'=>$smwgVersion, 'author'=>'Klaus Lassleben, Markus Kr&ouml;tzsch, Kai H&uuml;ner, Denny Vrandecic, S Page', 'url'=>'https://sourceforge.net/projects/semediawiki/', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines and humans');
 99+$wgExtensionCredits['parserhook'][]= array('name'=>'Semantic MediaWiki', 'version'=>$smwgVersion, 'author'=>'Klaus Lassleben, Markus Kr&ouml;tzsch, Kai H&uuml;ner, Denny Vrandecic, S Page', 'url'=>'http://sourceforge.net/projects/semediawiki/', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines and humans');
97100
98 -/**********************************************/
99 -/***** Header modifications *****/
100 -/**********************************************/
101 -
102 - /**
103 - * This method is in charge of inserting additional CSS, JScript, and meta tags
104 - * into the html header of each page. It is either called after initialising wgout
105 - * (requiring a patch in MediaWiki), or during parsing. Calling it during parsing,
106 - * however, is not sufficient to get the header modifiactions into every page that
107 - * is shipped to a reader, since the parser cache can make parsing obsolete.
108 - *
109 - * $out is the modified OutputPage.
110 - */
111 - function smwfAddHTMLHeader(&$out) {
112 - global $smwgHeadersInPlace; // record whether headers were created already
113 - global $smwgArticleHeadersInPlace; // record whether article name specific headers are already there
114 - global $smwgScriptPath;
115 -
116 - if (!$smwgHeadersInPlace) {
117 - $toolTipScript = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_tooltip.js"></script>';
118 - $out->addScript($toolTipScript);
119 - $sortTableScript = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_sorttable.js"></script>';
120 - $out->addScript($sortTableScript);
121 -
122 - // Also we add a custom CSS file for our needs
123 - $customCssUrl = $smwgScriptPath . '/skins/SMW_custom.css';
124 - $out->addLink(array(
125 - 'rel' => 'stylesheet',
126 - 'type' => 'text/css',
127 - 'media' => 'screen, projection',
128 - 'href' => $customCssUrl
129 - ));
130 - $smwgHeadersInPlace = true;
131 - }
132 -
133 - if ((!$smwgArticleHeadersInPlace) && ($out->mIsarticle) && ($out->mPagetitle!='')) {
134 - //print_r('Article ADDHTML... "'. $out->mPagetitle .'"');
135 - global $wgContLang, $wgServer, $wgScript;
136 -
137 - $out->addLink(array(
138 - 'rel' => 'alternate',
139 - 'type' => 'application/rdf+xml',
140 - 'title' => $out->mPagetitle,
141 - 'href' => $wgServer . $wgScript . '/' .
142 - $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' .
143 - str_replace('%2F', "/", urlencode(str_replace(' ', '_', $out->mPagetitle))) . '?xmlmime=rdf'
144 - ));
145 - $smwgArticleHeadersInPlace = true;
146 - }
147 -
148 -
149 - return;
150 - }
151 -
152 -/**********************************************/
153 -/***** namespace settings *****/
154 -/**********************************************/
155 -
156 - /**
157 - * Init the additional namepsaces used by Semantic MediaWiki. The
158 - * parameter denotes the least unused even namespace ID that is
159 - * greater or equal to 100.
160 - */
161 - function smwfInitNamespaces($base_idx) {
162 - global $wgExtraNamespaces, $wgNamespacesWithSubpages, $wgLanguageCode, $smwgContLang;
163 -
164 - smwfInitContentLanguage($wgLanguageCode);
165 -
166 - $namespaceIndex=$base_idx;
167 -
168 - define('SMW_NS_RELATION', $namespaceIndex);
169 - define('SMW_NS_RELATION_TALK', $namespaceIndex+1);
170 - define('SMW_NS_ATTRIBUTE', $namespaceIndex+2);
171 - define('SMW_NS_ATTRIBUTE_TALK', $namespaceIndex+3);
172 - define('SMW_NS_TYPE', $namespaceIndex+4);
173 - define('SMW_NS_TYPE_TALK', $namespaceIndex+5);
174 -
175 - // Register namespace identifiers
176 - if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); }
177 - $wgExtraNamespaces = $wgExtraNamespaces +
178 - $smwgContLang->getNamespaceArray();
179 -
180 - // Support subpages only for talk pages by default
181 - $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
182 - SMW_NS_RELATION_TALK => true,
183 - SMW_NS_ATTRIBUTE_TALK => true,
184 - SMW_NS_TYPE_TALK => true
185 - );
186 -
187 - // not modified for Semantic MediaWiki
188 - /* $wgNamespacesToBeSearchedDefault = array(
189 - NS_MAIN => true,
190 - );
191 - */
192 - }
193 -
194 -/**********************************************/
195 -/***** language settings *****/
196 -/**********************************************/
197 -
198 - /**
199 - * Initialise a global language object for content language. This
200 - * must happen early on, even before user language is known, to
201 - * determine labels for additional namespaces. In contrast, messages
202 - * can be initialised much later when they are actually needed.
203 - */
204 - function smwfInitContentLanguage($langcode) {
205 - global $smwgIP, $smwgContLang;
206 -
207 - if (!empty($smwgContLang)) { return; }
208 -
209 - $smwContLangClass = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
210 -
211 - if (file_exists($smwgIP . '/languages/'. $smwContLangClass . '.php')) {
212 - include_once( $smwgIP . '/languages/'. $smwContLangClass . '.php' );
213 - }
214 -
215 - // fallback if language not supported
216 - if ( !class_exists($smwContLangClass)) {
217 - include_once($smwgIP . '/languages/SMW_LanguageEn.php');
218 - $smwContLangClass = 'SMW_LanguageEn';
219 - }
220 -
221 - $smwgContLang = new $smwContLangClass();
222 - }
223 -
224 - /**
225 - * Initialise the global language object for user language. This
226 - * must happen after the content language was initialised, since
227 - * this language is used as a fallback.
228 - */
229 - function smwfInitUserLanguage($langcode) {
230 - global $smwgIP, $smwgLang;
231 -
232 - if (!empty($smwgLang)) { return; }
233 -
234 - $smwLangClass = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
235 -
236 - if (file_exists($smwgIP . '/languages/'. $smwLangClass . '.php')) {
237 - include_once( $smwgIP . '/languages/'. $smwLangClass . '.php' );
238 - }
239 -
240 - // fallback if language not supported
241 - if ( !class_exists($smwLangClass)) {
242 - global $smwgContLang;
243 - $smwgLang = $smwgContLang;
244 - } else {
245 - $smwgLang = new $smwLangClass();
246 - }
247 - }
248 -
249 - /**
250 - * Initialise messages. These settings must be applied later on, since
251 - * the MessageCache does not exist yet when the settings are loaded in
252 - * LocalSettings.php.
253 - */
254 - function smwfInitMessages() {
255 - global $smwgMessagesInPlace; // record whether the function was already called
256 -
257 - if ($smwgMessagesInPlace) { return; }
258 -
259 - global $wgMessageCache, $smwgContLang, $smwgLang;
260 - global $wgContLanguageCode, $wgLanguageCode;
261 - // make sure that language objects exist
262 - smwfInitContentLanguage($wgContLanguageCode);
263 - smwfInitUserLanguage($wgLanguageCode);
264 -
265 - $wgMessageCache->addMessages($smwgContLang->getContentMsgArray());
266 - $wgMessageCache->addMessages($smwgLang->getUserMsgArray());
267 -
268 - $smwgMessagesInPlace = true;
269 - }
270 -
271 - /**
272 - * Return true if semantic data should be processed and displayed for this page.
273 - * @return bool
274 - */
275 - function smwfIsSemanticsProcessed($namespace) {
276 - global $smwgNamespacesWithSemanticLinks;
277 - return !empty($smwgNamespacesWithSemanticLinks[$namespace]);
278 - }
279 -
280 -
281101 ?>

Status & tagging log