Index: trunk/extensions/SemanticMediaWiki/SemanticMediaWiki.hooks.php |
— | — | @@ -35,4 +35,123 @@ |
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | |
| 39 | + /** |
| 40 | + * TODO |
| 41 | + * |
| 42 | + * @since 1.7 |
| 43 | + * |
| 44 | + * @return true |
| 45 | + */ |
| 46 | + public static function onPageSchemasRegistration() { |
| 47 | + $GLOBALS['wgPageSchemasHandlerClasses'][] = 'SMWPageSchemas'; |
| 48 | + return true; |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Adds links to Admin Links page. |
| 53 | + * |
| 54 | + * @since 1.7 |
| 55 | + * |
| 56 | + * @param array $admin_links_tree |
| 57 | + * |
| 58 | + * @return true |
| 59 | + */ |
| 60 | + public static function addToAdminLinks( array &$admin_links_tree ) { |
| 61 | + $data_structure_section = new ALSection( wfMsg( 'smw_adminlinks_datastructure' ) ); |
| 62 | + |
| 63 | + $smw_row = new ALRow( 'smw' ); |
| 64 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'Categories' ) ); |
| 65 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'Properties' ) ); |
| 66 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'UnusedProperties' ) ); |
| 67 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'SemanticStatistics' ) ); |
| 68 | + |
| 69 | + $data_structure_section->addRow( $smw_row ); |
| 70 | + $smw_admin_row = new ALRow( 'smw_admin' ); |
| 71 | + $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'SMWAdmin' ) ); |
| 72 | + |
| 73 | + $data_structure_section->addRow( $smw_admin_row ); |
| 74 | + $smw_docu_row = new ALRow( 'smw_docu' ); |
| 75 | + $smw_name = wfMsg( 'specialpages-group-smw_group' ); |
| 76 | + $smw_docu_label = wfMsg( 'adminlinks_documentation', $smw_name ); |
| 77 | + $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:User_manual', $smw_docu_label ) ); |
| 78 | + |
| 79 | + $data_structure_section->addRow( $smw_docu_row ); |
| 80 | + $admin_links_tree->addSection( $data_structure_section, wfMsg( 'adminlinks_browsesearch' ) ); |
| 81 | + $smw_row = new ALRow( 'smw' ); |
| 82 | + $displaying_data_section = new ALSection( wfMsg( 'smw_adminlinks_displayingdata' ) ); |
| 83 | + $smw_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:Inline_queries', wfMsg( 'smw_adminlinks_inlinequerieshelp' ) ) ); |
| 84 | + |
| 85 | + $displaying_data_section->addRow( $smw_row ); |
| 86 | + $admin_links_tree->addSection( $displaying_data_section, wfMsg( 'adminlinks_browsesearch' ) ); |
| 87 | + $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) ); |
| 88 | + |
| 89 | + $smw_row = new ALRow( 'smw' ); |
| 90 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'Browse' ) ); |
| 91 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'Ask' ) ); |
| 92 | + $smw_row->addItem( ALItem::newFromSpecialPage( 'SearchByProperty' ) ); |
| 93 | + $browse_search_section->addRow( $smw_row ); |
| 94 | + |
| 95 | + return true; |
| 96 | + } |
| 97 | + |
| 98 | + |
| 99 | + /** |
| 100 | + * Register special classes for displaying semantic content on Property and |
| 101 | + * Concept pages. |
| 102 | + * |
| 103 | + * @since 1.7 |
| 104 | + * |
| 105 | + * @param $title Title |
| 106 | + * @param $article Article or null |
| 107 | + * |
| 108 | + * @return true |
| 109 | + */ |
| 110 | + public static function onArticleFromTitle( Title &$title, /* Article */ &$article ) { |
| 111 | + if ( $title->getNamespace() == SMW_NS_PROPERTY ) { |
| 112 | + $article = new SMWPropertyPage( $title ); |
| 113 | + } elseif ( $title->getNamespace() == SMW_NS_CONCEPT ) { |
| 114 | + $article = new SMWConceptPage( $title ); |
| 115 | + } |
| 116 | + |
| 117 | + return true; |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * This hook registers parser functions and hooks to the given parser. It is |
| 122 | + * called during SMW initialisation. Note that parser hooks are something different |
| 123 | + * than MW hooks in general, which explains the two-level registration. |
| 124 | + * |
| 125 | + * @since 1.7 |
| 126 | + */ |
| 127 | + public static function onParserFirstCallInit( Parser &$parser ) { |
| 128 | + $parser->setFunctionHook( 'ask', array( 'SMWAsk', 'render' ) ); |
| 129 | + $parser->setFunctionHook( 'show', array( 'SMWShow', 'render' ) ); |
| 130 | + $parser->setFunctionHook( 'subobject', array( 'SMWSubobject', 'render' ) ); |
| 131 | + $parser->setFunctionHook( 'concept', array( 'SMWConcept', 'render' ) ); |
| 132 | + $parser->setFunctionHook( 'set', array( 'SMWSet', 'render' ) ); |
| 133 | + $parser->setFunctionHook( 'set_recurring_event', array( 'SMWSetRecurringEvent', 'render' ) ); |
| 134 | + $parser->setFunctionHook( 'declare', array( 'SMWDeclare', 'render' ), SFH_OBJECT_ARGS ); |
| 135 | + |
| 136 | + return true; // Always return true, in order not to stop MW's hook processing! |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Adds the 'Powered by Semantic MediaWiki' button right next to the default |
| 141 | + * 'Powered by MediaWiki' button at the bottom of every page. This works |
| 142 | + * only with MediaWiki 1.17+. |
| 143 | + * It might make sense to make this configurable via a variable, if some |
| 144 | + * admins don't want it. |
| 145 | + * |
| 146 | + * @since 1.7 |
| 147 | + * |
| 148 | + * @return true |
| 149 | + */ |
| 150 | + public static function addPoweredBySMW( &$text, $skin ) { |
| 151 | + global $smwgScriptPath; |
| 152 | + $url = htmlspecialchars( "$smwgScriptPath/skins/images/smw_button.png" ); |
| 153 | + $text .= ' <a href="http://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki"><img src="'. $url . '" alt="Powered by Semantic MediaWiki" /></a>'; |
| 154 | + |
| 155 | + return true; // Always return true, in order not to stop MW's hook processing! |
| 156 | + } |
| 157 | + |
39 | 158 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PageSchemas.php |
— | — | @@ -11,11 +11,6 @@ |
12 | 12 | */ |
13 | 13 | |
14 | 14 | class SMWPageSchemas extends PSExtensionHandler { |
15 | | - public static function registerClass() { |
16 | | - global $wgPageSchemasHandlerClasses; |
17 | | - $wgPageSchemasHandlerClasses[] = 'SMWPageSchemas'; |
18 | | - return true; |
19 | | - } |
20 | 15 | |
21 | 16 | public static function getDisplayColor() { |
22 | 17 | return '#DEF'; |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php |
— | — | @@ -79,13 +79,31 @@ |
80 | 80 | $wgHooks['LanguageGetMagic'][] = 'smwfAddMagicWords'; // setup names for parser functions (needed here) |
81 | 81 | |
82 | 82 | $wgHooks['ParserTestTables'][] = 'smwfOnParserTestTables'; |
83 | | - $wgHooks['AdminLinks'][] = 'smwfAddToAdminLinks'; |
84 | | - $wgHooks['PageSchemasRegisterHandlers'][] = 'SMWPageSchemas::registerClass'; |
| 83 | + $wgHooks['AdminLinks'][] = 'SMWHooks::addToAdminLinks'; |
| 84 | + $wgHooks['PageSchemasRegisterHandlers'][] = 'SMWHooks::onPageSchemasRegistration'; |
| 85 | + |
85 | 86 | $wgHooks['ParserFirstCallInit'][] = 'SMWSMWDoc::staticInit'; |
86 | 87 | $wgHooks['LanguageGetMagic'][] = 'SMWSMWDoc::staticMagic'; |
87 | 88 | $wgHooks['ParserFirstCallInit'][] = 'SMWInfo::staticInit'; |
88 | 89 | $wgHooks['LanguageGetMagic'][] = 'SMWInfo::staticMagic'; |
89 | 90 | |
| 91 | + $wgHooks['InternalParseBeforeLinks'][] = 'SMWParserExtensions::onInternalParseBeforeLinks'; // parse annotations in [[link syntax]] |
| 92 | + $wgHooks['ArticleDelete'][] = 'SMWParseData::onArticleDelete'; // delete annotations |
| 93 | + $wgHooks['TitleMoveComplete'][] = 'SMWParseData::onTitleMoveComplete'; // move annotations |
| 94 | + $wgHooks['LinksUpdateConstructed'][] = 'SMWParseData::onLinksUpdateConstructed'; // update data after template change and at save |
| 95 | + $wgHooks['ParserAfterTidy'][] = 'SMWParseData::onParserAfterTidy'; // fetch some MediaWiki data for replication in SMW's store |
| 96 | + $wgHooks['NewRevisionFromEditComplete'][] = 'SMWParseData::onNewRevisionFromEditComplete'; // fetch some MediaWiki data for replication in SMW's store |
| 97 | + $wgHooks['OutputPageParserOutput'][] = 'SMWFactbox::onOutputPageParserOutput'; // copy some data for later Factbox display |
| 98 | + $wgHooks['ArticleFromTitle'][] = 'SMWHooks::onArticleFromTitle'; // special implementations for property/type articles |
| 99 | + $wgHooks['ParserFirstCallInit'][] = 'SMWHooks::onParserFirstCallInit'; |
| 100 | + |
| 101 | + if ( $GLOBALS['smwgToolboxBrowseLink'] ) { |
| 102 | + $wgHooks['SkinTemplateToolboxEnd'][] = 'smwfShowBrowseLink'; |
| 103 | + } |
| 104 | + |
| 105 | + $wgHooks['SkinAfterContent'][] = 'SMWFactbox::onSkinAfterContent'; // draw Factbox below categories |
| 106 | + $wgHooks['SkinGetPoweredBy'][] = 'SMWHooks::addPoweredBySMW'; |
| 107 | + |
90 | 108 | if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) { |
91 | 109 | // For MediaWiki 1.17 alpha and later. |
92 | 110 | $wgHooks['ExtensionTypes'][] = 'smwfAddSemanticExtensionType'; |
— | — | @@ -405,23 +423,7 @@ |
406 | 424 | |
407 | 425 | ///// register hooks ///// |
408 | 426 | require_once( $smwgIP . 'includes/SMW_RefreshTab.php' ); |
409 | | - |
410 | | - $wgHooks['InternalParseBeforeLinks'][] = 'SMWParserExtensions::onInternalParseBeforeLinks'; // parse annotations in [[link syntax]] |
411 | | - $wgHooks['ArticleDelete'][] = 'SMWParseData::onArticleDelete'; // delete annotations |
412 | | - $wgHooks['TitleMoveComplete'][] = 'SMWParseData::onTitleMoveComplete'; // move annotations |
413 | | - $wgHooks['LinksUpdateConstructed'][] = 'SMWParseData::onLinksUpdateConstructed'; // update data after template change and at save |
414 | | - $wgHooks['ParserAfterTidy'][] = 'SMWParseData::onParserAfterTidy'; // fetch some MediaWiki data for replication in SMW's store |
415 | | - $wgHooks['NewRevisionFromEditComplete'][] = 'SMWParseData::onNewRevisionFromEditComplete'; // fetch some MediaWiki data for replication in SMW's store |
416 | | - $wgHooks['OutputPageParserOutput'][] = 'SMWFactbox::onOutputPageParserOutput'; // copy some data for later Factbox display |
417 | | - $wgHooks['ArticleFromTitle'][] = 'smwfOnArticleFromTitle'; // special implementations for property/type articles |
418 | | - $wgHooks['ParserFirstCallInit'][] = 'smwfRegisterParserFunctions'; |
419 | | - |
420 | | - if ( $smwgToolboxBrowseLink ) { |
421 | | - $wgHooks['SkinTemplateToolboxEnd'][] = 'smwfShowBrowseLink'; |
422 | | - } |
423 | | - |
424 | | - $wgHooks['SkinAfterContent'][] = 'SMWFactbox::onSkinAfterContent'; // draw Factbox below categories |
425 | | - $wgHooks['SkinGetPoweredBy'][] = 'smwfAddPoweredBySMW'; |
| 427 | + |
426 | 428 | if ( isset($wgFooterIcons["poweredby"]) |
427 | 429 | && isset($wgFooterIcons["poweredby"]["semanticmediawiki"]) |
428 | 430 | && is_null( $wgFooterIcons["poweredby"]["semanticmediawiki"]["src"] ) ) { |
— | — | @@ -461,67 +463,6 @@ |
462 | 464 | } |
463 | 465 | |
464 | 466 | /** |
465 | | - * Adds links to Admin Links page. |
466 | | - */ |
467 | | -function smwfAddToAdminLinks( &$admin_links_tree ) { |
468 | | - $data_structure_section = new ALSection( wfMsg( 'smw_adminlinks_datastructure' ) ); |
469 | | - |
470 | | - $smw_row = new ALRow( 'smw' ); |
471 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'Categories' ) ); |
472 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'Properties' ) ); |
473 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'UnusedProperties' ) ); |
474 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'SemanticStatistics' ) ); |
475 | | - |
476 | | - $data_structure_section->addRow( $smw_row ); |
477 | | - $smw_admin_row = new ALRow( 'smw_admin' ); |
478 | | - $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'SMWAdmin' ) ); |
479 | | - |
480 | | - $data_structure_section->addRow( $smw_admin_row ); |
481 | | - $smw_docu_row = new ALRow( 'smw_docu' ); |
482 | | - $smw_name = wfMsg( 'specialpages-group-smw_group' ); |
483 | | - $smw_docu_label = wfMsg( 'adminlinks_documentation', $smw_name ); |
484 | | - $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:User_manual', $smw_docu_label ) ); |
485 | | - |
486 | | - $data_structure_section->addRow( $smw_docu_row ); |
487 | | - $admin_links_tree->addSection( $data_structure_section, wfMsg( 'adminlinks_browsesearch' ) ); |
488 | | - $smw_row = new ALRow( 'smw' ); |
489 | | - $displaying_data_section = new ALSection( wfMsg( 'smw_adminlinks_displayingdata' ) ); |
490 | | - $smw_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:Inline_queries', wfMsg( 'smw_adminlinks_inlinequerieshelp' ) ) ); |
491 | | - |
492 | | - $displaying_data_section->addRow( $smw_row ); |
493 | | - $admin_links_tree->addSection( $displaying_data_section, wfMsg( 'adminlinks_browsesearch' ) ); |
494 | | - $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) ); |
495 | | - |
496 | | - $smw_row = new ALRow( 'smw' ); |
497 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'Browse' ) ); |
498 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'Ask' ) ); |
499 | | - $smw_row->addItem( ALItem::newFromSpecialPage( 'SearchByProperty' ) ); |
500 | | - $browse_search_section->addRow( $smw_row ); |
501 | | - |
502 | | - return true; |
503 | | -} |
504 | | - |
505 | | - |
506 | | -/** |
507 | | - * Register special classes for displaying semantic content on Property and |
508 | | - * Concept pages. |
509 | | - * |
510 | | - * @param $title Title |
511 | | - * @param $article Article or null |
512 | | - * |
513 | | - * @return true |
514 | | - */ |
515 | | -function smwfOnArticleFromTitle( Title &$title, /* Article */ &$article ) { |
516 | | - if ( $title->getNamespace() == SMW_NS_PROPERTY ) { |
517 | | - $article = new SMWPropertyPage( $title ); |
518 | | - } elseif ( $title->getNamespace() == SMW_NS_CONCEPT ) { |
519 | | - $article = new SMWConceptPage( $title ); |
520 | | - } |
521 | | - |
522 | | - return true; |
523 | | -} |
524 | | - |
525 | | -/** |
526 | 467 | * Register tables to be added to temporary tables for parser tests. |
527 | 468 | * @todo Hard-coding this thwarts the modularity/exchangability of the SMW |
528 | 469 | * storage backend. The actual list of required tables depends on the backend |
— | — | @@ -652,41 +593,3 @@ |
653 | 594 | |
654 | 595 | wfProfileOut( 'smwfInitContentLanguage (SMW)' ); |
655 | 596 | } |
656 | | - |
657 | | -/** |
658 | | - * This hook registers parser functions and hooks to the given parser. It is |
659 | | - * called during SMW initialisation. Note that parser hooks are something different |
660 | | - * than MW hooks in general, which explains the two-level registration. |
661 | | - * |
662 | | - * @since 1.5.3 |
663 | | - */ |
664 | | -function smwfRegisterParserFunctions( Parser &$parser ) { |
665 | | - $parser->setFunctionHook( 'ask', array( 'SMWAsk', 'render' ) ); |
666 | | - $parser->setFunctionHook( 'show', array( 'SMWShow', 'render' ) ); |
667 | | - $parser->setFunctionHook( 'subobject', array( 'SMWSubobject', 'render' ) ); |
668 | | - $parser->setFunctionHook( 'concept', array( 'SMWConcept', 'render' ) ); |
669 | | - $parser->setFunctionHook( 'set', array( 'SMWSet', 'render' ) ); |
670 | | - $parser->setFunctionHook( 'set_recurring_event', array( 'SMWSetRecurringEvent', 'render' ) ); |
671 | | - $parser->setFunctionHook( 'declare', array( 'SMWDeclare', 'render' ), SFH_OBJECT_ARGS ); |
672 | | - |
673 | | - return true; // Always return true, in order not to stop MW's hook processing! |
674 | | -} |
675 | | - |
676 | | -/** |
677 | | - * Adds the 'Powered by Semantic MediaWiki' button right next to the default |
678 | | - * 'Powered by MediaWiki' button at the bottom of every page. This works |
679 | | - * only with MediaWiki 1.17+. |
680 | | - * It might make sense to make this configurable via a variable, if some |
681 | | - * admins don't want it. |
682 | | - * |
683 | | - * @since 1.5.4 |
684 | | - * |
685 | | - * @return true |
686 | | - */ |
687 | | -function smwfAddPoweredBySMW( &$text, $skin ) { |
688 | | - global $smwgScriptPath; |
689 | | - $url = htmlspecialchars( "$smwgScriptPath/skins/images/smw_button.png" ); |
690 | | - $text .= ' <a href="http://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki"><img src="'. $url . '" alt="Powered by Semantic MediaWiki" /></a>'; |
691 | | - |
692 | | - return true; // Always return true, in order not to stop MW's hook processing! |
693 | | -} |