00001 <?php
00014 if ( !defined( 'MEDIAWIKI' ) ) die();
00015
00016 define( 'SD_VERSION', '1.1' );
00017
00018 $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'specialpage'][] = array(
00019 'path' => __FILE__,
00020 'name' => 'Semantic Drilldown',
00021 'version' => SD_VERSION,
00022 'author' => array( 'Yaron Koren', 'David Loomer' ),
00023 'url' => 'https://www.mediawiki.org/wiki/Extension:Semantic_Drilldown',
00024 'descriptionmsg' => 'semanticdrilldown-desc',
00025 );
00026
00027
00028 define( 'SD_SP_HAS_FILTER', 1 );
00029 define( 'SD_SP_COVERS_PROPERTY', 2 );
00030 define( 'SD_SP_HAS_VALUE', 3 );
00031 define( 'SD_SP_GETS_VALUES_FROM_CATEGORY', 4 );
00032 define( 'SD_SP_USES_TIME_PERIOD', 5 );
00033 define( 'SD_SP_REQUIRES_FILTER', 6 );
00034 define( 'SD_SP_HAS_LABEL', 7 );
00035 define( 'SD_SP_HAS_DRILLDOWN_TITLE', 8 );
00036 define( 'SD_SP_HAS_INPUT_TYPE', 9 );
00037 define( 'SD_SP_HAS_DISPLAY_PARAMETERS', 10 );
00038
00039 $sdgIP = dirname( __FILE__ );
00040
00041 require_once( $sdgIP . '/languages/SD_Language.php' );
00042
00043 $wgExtensionMessagesFiles['SemanticDrilldown'] = $sdgIP . '/languages/SD_Messages.php';
00044 $wgExtensionMessagesFiles['SemanticDrilldownAlias'] = $sdgIP . '/languages/SD_Aliases.php';
00045 $wgExtensionMessagesFiles['SemanticDrilldownMagic'] = $sdgIP . '/languages/SemanticDrilldown.i18n.magic.php';
00046
00047
00048 $wgSpecialPages['Filters'] = 'SDFilters';
00049 $wgAutoloadClasses['SDFilters'] = $sdgIP . '/specials/SD_Filters.php';
00050 $wgSpecialPageGroups['Filters'] = 'sd_group';
00051 $wgSpecialPages['CreateFilter'] = 'SDCreateFilter';
00052 $wgAutoloadClasses['SDCreateFilter'] = $sdgIP . '/specials/SD_CreateFilter.php';
00053 $wgSpecialPageGroups['CreateFilter'] = 'sd_group';
00054 $wgSpecialPages['BrowseData'] = 'SDBrowseData';
00055 $wgAutoloadClasses['SDBrowseData'] = $sdgIP . '/specials/SD_BrowseData.php';
00056 $wgSpecialPageGroups['BrowseData'] = 'sd_group';
00057
00058 $wgAutoloadClasses['SDUtils'] = $sdgIP . '/includes/SD_Utils.php';
00059 $wgAutoloadClasses['SDFilter'] = $sdgIP . '/includes/SD_Filter.php';
00060 $wgAutoloadClasses['SDFilterValue'] = $sdgIP . '/includes/SD_FilterValue.php';
00061 $wgAutoloadClasses['SDAppliedFilter'] = $sdgIP . '/includes/SD_AppliedFilter.php';
00062 $wgAutoloadClasses['SDPageSchemas'] = $sdgIP . '/includes/SD_PageSchemas.php';
00063
00064 $wgHooks['smwInitProperties'][] = 'sdfInitProperties';
00065 $wgHooks['AdminLinks'][] = 'SDUtils::addToAdminLinks';
00066 $wgHooks['MagicWordwgVariableIDs'][] = 'SDUtils::addMagicWordVariableIDs';
00067 $wgHooks['ParserBeforeTidy'][] = 'SDUtils::handleShowAndHide';
00068 $wgHooks['PageSchemasRegisterHandlers'][] = 'SDPageSchemas::registerClass';
00069
00070 $wgPageProps['hidefromdrilldown'] = 'Whether or not the page is set as HIDEFROMDRILLDOWN';
00071 $wgPageProps['showindrilldown'] = 'Whether or not the page is set as SHOWINDRILLDOWN';
00072
00073 # ##
00074 # This is the path to your installation of Semantic Drilldown as
00075 # seen from the web. Change it if required ($wgScriptPath is the
00076 # path to the base directory of your wiki). No final slash.
00077 # # TODO: fix hardcoded path
00078 $sdgScriptPath = $wgScriptPath . '/extensions/SemanticDrilldown';
00079 # #
00080
00081 # ##
00082 # If you already have custom namespaces on your site, insert
00083 # $sdgNamespaceIndex = ???;
00084 # into your LocalSettings.php *before* including this file.
00085 # The number ??? must be the smallest even namespace number
00086 # that is not in use yet. However, it should not be smaller
00087 # than 170.
00088 # #
00089 if ( !isset( $sdgNamespaceIndex ) ) {
00090 sdfInitNamespaces( 170 );
00091 } else {
00092 sdfInitNamespaces();
00093 }
00094
00095 # ##
00096 # # List separator character
00097 # ##
00098 $sdgListSeparator = ",";
00099
00100 # ##
00101 # # Variables for display
00102 # ##
00103
00104
00105 $sdgHideCategoriesByDefault = false;
00106 $sdgNumResultsPerPage = 250;
00107
00108 $sdgFiltersSmallestFontSize = - 1;
00109 $sdgFiltersLargestFontSize = - 1;
00110
00111 $sdgShowCategoriesAsTabs = false;
00112
00113
00114
00115
00116
00117
00121 function sdfInitNamespaces() {
00122 global $sdgNamespaceIndex, $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $smwgNamespacesWithSemanticLinks;
00123 global $wgLanguageCode, $sdgContLang;
00124
00125 if ( !isset( $sdgNamespaceIndex ) ) {
00126 $sdgNamespaceIndex = 170;
00127 }
00128
00129 define( 'SD_NS_FILTER', $sdgNamespaceIndex );
00130 define( 'SD_NS_FILTER_TALK', $sdgNamespaceIndex + 1 );
00131
00132 sdfInitContentLanguage( $wgLanguageCode );
00133
00134
00135 if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
00136 $wgExtraNamespaces = $wgExtraNamespaces + $sdgContLang->getNamespaces();
00137 $wgNamespaceAliases = $wgNamespaceAliases + $sdgContLang->getNamespaceAliases();
00138
00139
00140 $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
00141 SD_NS_FILTER_TALK => true
00142 );
00143
00144
00145 $smwgNamespacesWithSemanticLinks = $smwgNamespacesWithSemanticLinks + array(
00146 SD_NS_FILTER => true,
00147 SD_NS_FILTER_TALK => false
00148 );
00149 }
00150
00151
00152
00153
00154
00161 function sdfInitContentLanguage( $langcode ) {
00162 global $sdgIP, $sdgContLang;
00163
00164 if ( !empty( $sdgContLang ) ) { return; }
00165
00166 $sdContLangClass = 'SD_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
00167
00168 if ( file_exists( $sdgIP . '/languages/' . $sdContLangClass . '.php' ) ) {
00169 include_once( $sdgIP . '/languages/' . $sdContLangClass . '.php' );
00170 }
00171
00172
00173 if ( !class_exists( $sdContLangClass ) ) {
00174 include_once( $sdgIP . '/languages/SD_LanguageEn.php' );
00175 $sdContLangClass = 'SD_LanguageEn';
00176 }
00177
00178 $sdgContLang = new $sdContLangClass();
00179 }
00180
00186 function sdfInitUserLanguage( $langcode ) {
00187 global $sdgIP, $sdgLang;
00188
00189 if ( !empty( $sdgLang ) ) { return; }
00190
00191 $sdLangClass = 'SD_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
00192 if ( file_exists( $sdgIP . '/languages/' . $sdLangClass . '.php' ) ) {
00193 include_once( $sdgIP . '/languages/' . $sdLangClass . '.php' );
00194 }
00195
00196
00197 if ( !class_exists( $sdLangClass ) ) {
00198 include_once( $sdgIP . '/languages/SD_LanguageEn.php' );
00199 $sdLangClass = 'SD_LanguageEn';
00200 }
00201
00202 $sdgLang = new $sdLangClass();
00203 }
00204
00205 function sdfInitProperties() {
00206 global $sdgContLang, $wgLanguageCode;
00207 $sd_property_vals = array(
00208 SD_SP_HAS_FILTER => array( '_SD_F', '_wpg' ),
00209 SD_SP_COVERS_PROPERTY => array( '_SD_CP', '_wpp' ),
00210 SD_SP_HAS_VALUE => array( '_SD_V', '_str' ),
00211 SD_SP_GETS_VALUES_FROM_CATEGORY => array( '_SD_VC', '_wpc' ),
00212 SD_SP_USES_TIME_PERIOD => array( '_SD_TP', '_str' ),
00213 SD_SP_HAS_INPUT_TYPE => array( '_SD_IT', '_str' ),
00214 SD_SP_REQUIRES_FILTER => array( '_SD_RF', '_wpg' ),
00215 SD_SP_HAS_LABEL => array( '_SD_L', '_str' ),
00216 SD_SP_HAS_DRILLDOWN_TITLE => array( '_SD_DT', '_str' ),
00217 SD_SP_HAS_DISPLAY_PARAMETERS => array( '_SD_DP', '_str' ),
00218 );
00219
00220 $sd_prop_labels = $sdgContLang->getPropertyLabels();
00221 foreach ( $sd_prop_labels as $prop_id => $prop_alias ) {
00222 $prop_vals = $sd_property_vals[$prop_id];
00223 if ( class_exists( 'SMWDIProperty' ) ) {
00224 SMWDIProperty::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true );
00225 } else {
00226 SMWPropertyValue::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true );
00227 }
00228 }
00229
00230 if ( $wgLanguageCode != 'en' ) {
00231 $sd_prop_aliases = $sdgContLang->getPropertyAliases();
00232 foreach ( $sd_prop_aliases as $prop_alias => $prop_id ) {
00233 $prop_vals = $sd_property_vals[$prop_id];
00234 if ( class_exists( 'SMWDIProperty' ) ) {
00235 SMWDIProperty::registerPropertyAlias( $prop_vals[0], $prop_alias );
00236 } else {
00237 SMWPropertyValue::registerPropertyAlias( $prop_vals[0], $prop_alias );
00238 }
00239 }
00240 }
00241 return true;
00242 }
00243
00244
00245 if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
00246 $sdgResourceTemplate = array(
00247 'localBasePath' => $sdgIP,
00248 'remoteExtPath' => 'SemanticDrilldown'
00249 );
00250 $wgResourceModules += array(
00251 'ext.semanticdrilldown.combobox' => $sdgResourceTemplate + array(
00252 'scripts' => array(
00253 'libs/SemanticDrilldown.js',
00254 ),
00255 'styles' => array(
00256 'skins/SD_jquery_ui_overrides.css',
00257 ),
00258 'dependencies' => array(
00259 'jquery.ui.autocomplete',
00260 'jquery.ui.button',
00261 ),
00262 ),
00263 );
00264 }