00001 <?php
00012
00013 define( 'SMW_FACTBOX_HIDDEN', 1 );
00014 define( 'SMW_FACTBOX_SPECIAL', 2 );
00015 define( 'SMW_FACTBOX_NONEMPTY', 3 );
00016 define( 'SMW_FACTBOX_SHOWN', 5 );
00017
00018
00019 define( 'SMW_EQ_NONE', 0 );
00020 define( 'SMW_EQ_SOME', 1 );
00021 define( 'SMW_EQ_FULL', 2 );
00022
00023
00024 define( 'SMW_PROPERTY_QUERY', 1 );
00025 define( 'SMW_CATEGORY_QUERY', 2 );
00026 define( 'SMW_CONCEPT_QUERY', 4 );
00027 define( 'SMW_NAMESPACE_QUERY', 8 );
00028 define( 'SMW_CONJUNCTION_QUERY', 16 );
00029 define( 'SMW_DISJUNCTION_QUERY', 32 );
00030 define( 'SMW_ANY_QUERY', 0xFFFFFFFF );
00031
00032
00033 define( 'CONCEPT_CACHE_ALL', 4 );
00034 define( 'CONCEPT_CACHE_HARD', 1 );
00035 define( 'CONCEPT_CACHE_NONE', 0 );
00036
00037
00039 define( 'SMW_HEADER_TOOLTIP', 2 );
00041 define( 'SMW_HEADER_SORTTABLE', 3 );
00043 define( 'SMW_HEADER_STYLE', 4 );
00044
00045
00046
00047
00048
00049 define( 'SMW_OUTPUT_HTML', 1 );
00050 define( 'SMW_OUTPUT_WIKI', 2 );
00051 define( 'SMW_OUTPUT_FILE', 3 );
00052
00053
00054 define( 'SMW_CMP_EQ', 1 );
00055 define( 'SMW_CMP_LEQ', 2 );
00056 define( 'SMW_CMP_GEQ', 3 );
00057 define( 'SMW_CMP_NEQ', 4 );
00058 define( 'SMW_CMP_LIKE', 5 );
00059 define( 'SMW_CMP_NLKE', 6 );
00060 define( 'SMW_CMP_LESS', 7 );
00061 define( 'SMW_CMP_GRTR', 8 );
00062
00063
00064 define( 'SMW_MDY', 785 );
00065 define( 'SMW_DMY', 673 );
00066 define( 'SMW_YMD', 610 );
00067 define( 'SMW_YDM', 596 );
00068 define( 'SMW_MY', 97 );
00069 define( 'SMW_YM', 76 );
00070 define( 'SMW_Y', 9 );
00071 define( 'SMW_YEAR', 1 );
00072 define( 'SMW_DAY', 2 );
00073 define( 'SMW_MONTH', 4 );
00074 define( 'SMW_DAY_MONTH_YEAR', 7 );
00075 define( 'SMW_DAY_YEAR', 3 );
00076
00082 function smwfIsSemanticsProcessed( $namespace ) {
00083 global $smwgNamespacesWithSemanticLinks;
00084 return !empty( $smwgNamespacesWithSemanticLinks[$namespace] );
00085 }
00086
00095 function smwfNormalTitleDBKey( $text ) {
00096 global $wgCapitalLinks;
00097
00098 $text = trim( $text );
00099
00100 if ( $wgCapitalLinks ) {
00101 $text = ucfirst( $text );
00102 }
00103
00104 return str_replace( ' ', '_', $text );
00105 }
00106
00115 function smwfNormalTitleText( $text ) {
00116 global $wgCapitalLinks;
00117
00118 $text = trim( $text );
00119
00120 if ( $wgCapitalLinks ) {
00121 $text = ucfirst( $text );
00122 }
00123
00124 return str_replace( '_', ' ', $text );
00125 }
00126
00133 function smwfXMLContentEncode( $text ) {
00134 return str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), Sanitizer::decodeCharReferences( $text ) );
00135 }
00136
00143 function smwfHTMLtoUTF8( $text ) {
00144 return Sanitizer::decodeCharReferences( $text );
00145 }
00146
00156 function smwfNumberFormat( $value, $decplaces = 3 ) {
00157 global $smwgMaxNonExpNumber;
00158
00159 $decseparator = wfMsgForContent( 'smw_decseparator' );
00160
00161
00162
00163
00164
00165
00166 $doScientific = false;
00167
00168
00169
00170
00171 if ( ( $decplaces > 0 ) && ( $value != 0 ) ) {
00172 $absValue = abs( $value );
00173 if ( $absValue >= $smwgMaxNonExpNumber ) {
00174 $doScientific = true;
00175 } elseif ( $absValue <= pow( 10, - $decplaces ) ) {
00176 $doScientific = true;
00177 } elseif ( $absValue < 1 ) {
00178 if ( $absValue <= pow( 10, - $decplaces ) ) {
00179 $doScientific = true;
00180 } else {
00181
00182 for ( $i = 0.1; $absValue <= $i; $i *= 0.1 ) {
00183 $decplaces++;
00184 }
00185 }
00186 }
00187 }
00188
00189 if ( $doScientific ) {
00190
00191 $value = sprintf( "%1.6e", $value );
00192
00193 $value = preg_replace( '/(\\.\\d+?)0*e/u', '${1}e', $value, 1 );
00194
00195
00196 if ( $decseparator !== '.' ) {
00197 $value = str_replace( '.', $decseparator, $value );
00198 }
00199 } else {
00200
00201
00202 $value = number_format( $value, $decplaces, 'x', 'y' );
00203 $value = str_replace( array( 'x', 'y' ), array( $decseparator, wfMsgForContent( 'smw_kiloseparator' ) ), $value );
00204
00205
00206
00207 $end = $decseparator . str_repeat( '0', $decplaces );
00208 $lenEnd = strlen( $end );
00209
00210 if ( substr( $value, - $lenEnd ) === $end ) {
00211 $value = substr( $value, 0, - $lenEnd );
00212 } else {
00213
00214
00215 $value = preg_replace( "/(\\$decseparator\\d+?)0*$/u", '$1', $value, 1 );
00216 }
00217 }
00218
00219 return $value;
00220 }
00221
00233 function smwfEncodeMessages( array $messages, $icon = 'warning', $seperator = ' <!--br-->', $escape = true ) {
00234 if ( count( $messages ) > 0 ) {
00235 SMWOutputs::requireResource( 'ext.smw.tooltips' );
00236
00237 if ( $escape ) {
00238 $messages = array_map( 'htmlspecialchars', $messages );
00239 }
00240
00241 if ( count( $messages ) == 1 ) {
00242 $errorList = $messages[0];
00243 }
00244 else {
00245 foreach ( $messages as &$message ) {
00246 $message = '<li>' . $message . '</li>';
00247 }
00248
00249 $errorList = '<ul>' . implode( $seperator, $messages ) . '</ul>';
00250 }
00251
00252 return '<span class="smwttpersist">' .
00253 '<span class="smwtticon">' . htmlspecialchars( $icon ) . '.png</span>' .
00254 '<span class="smwttcontent">' . $errorList . '</span>' .
00255 '</span>';
00256 } else {
00257 return '';
00258 }
00259 }
00260
00264 function smwfLoadExtensionMessages( $extensionName ) {}
00265
00275 function &smwfGetStore() {
00276 global $smwgMasterStore, $smwgDefaultStore;
00277
00278 if ( is_null( $smwgMasterStore ) ) {
00279 $smwgMasterStore = new $smwgDefaultStore();
00280 }
00281
00282 return $smwgMasterStore;
00283 }
00284
00298 function &smwfGetSparqlDatabase() {
00299 global $smwgSparqlDatabase, $smwgSparqlDefaultGraph, $smwgSparqlQueryEndpoint,
00300 $smwgSparqlUpdateEndpoint, $smwgSparqlDataEndpoint, $smwgSparqlDatabaseMaster;
00301 if ( !isset( $smwgSparqlDatabaseMaster ) ) {
00302 $smwgSparqlDatabaseMaster = new $smwgSparqlDatabase( $smwgSparqlDefaultGraph,
00303 $smwgSparqlQueryEndpoint, $smwgSparqlUpdateEndpoint, $smwgSparqlDataEndpoint );
00304 }
00305 return $smwgSparqlDatabaseMaster;
00306 }
00307
00319 function smwfGetLinker() {
00320 static $linker = false;
00321
00322 if ( $linker === false ) {
00323 $linker = class_exists( 'DummyLinker' ) ? new DummyLinker() : new Linker();
00324 }
00325
00326 return $linker;
00327 }