Completed
Push — master ( d19112...f97043 )
by Jeroen De
01:22
created

SMWExternalHooks   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 70
ccs 0
cts 4
cp 0
rs 10
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onPageSchemasRegistration() 0 7 1
B addToAdminLinks() 0 42 1
1
<?php
2
3
/**
4
 * Static class for hooks handled by the Semantic MediaWiki extension.
5
 *
6
 * @since 1.7
7
 *
8
 * @file SemanticMediaWiki.hooks.php
9
 * @ingroup SMW
10
 *
11
 * @licence GNU GPL v2+
12
 * @author Jeroen De Dauw < [email protected] >
13
 * @author mwjames
14
 */
15
final class SMWExternalHooks {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
17
	/**
18
	 * TODO
19
	 *
20
	 * @since 1.7
21
	 *
22
	 * @return boolean
23
	 */
24
	public static function onPageSchemasRegistration() {
0 ignored issues
show
Coding Style introduced by
onPageSchemasRegistration uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
25
		// @codeCoverageIgnoreStart
26
		$GLOBALS['wgPageSchemasHandlerClasses'][] = 'SMWPageSchemas';
27
28
		return true;
29
		// @codeCoverageIgnoreEnd
30
	}
31
32
	/**
33
	 * Adds links to Admin Links page.
34
	 *
35
	 * @since 1.7
36
	 *
37
	 * @param ALTree $admin_links_tree
38
	 *
39
	 * @return boolean
40
	 */
41
	public static function addToAdminLinks( ALTree &$admin_links_tree ) {
42
		// @codeCoverageIgnoreStart
43
		$data_structure_section = new ALSection( wfMessage( 'smw_adminlinks_datastructure' )->text() );
44
45
		$smw_row = new ALRow( 'smw' );
46
		$smw_row->addItem( ALItem::newFromSpecialPage( 'Categories' ) );
47
		$smw_row->addItem( ALItem::newFromSpecialPage( 'Properties' ) );
48
		$smw_row->addItem( ALItem::newFromSpecialPage( 'UnusedProperties' ) );
49
		$smw_row->addItem( ALItem::newFromSpecialPage( 'SemanticStatistics' ) );
50
51
		$data_structure_section->addRow( $smw_row );
52
		$smw_admin_row = new ALRow( 'smw_admin' );
53
		$smw_admin_row->addItem( ALItem::newFromSpecialPage( 'SMWAdmin' ) );
54
55
		$data_structure_section->addRow( $smw_admin_row );
56
		$smw_docu_row = new ALRow( 'smw_docu' );
57
		$smw_name = wfMessage( 'specialpages-group-smw_group' )->text();
58
		$smw_docu_label = wfMessage( 'adminlinks_documentation', $smw_name )->text();
59
		$smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:User_manual', $smw_docu_label ) );
60
61
		$data_structure_section->addRow( $smw_docu_row );
62
		$admin_links_tree->addSection( $data_structure_section, wfMessage( 'adminlinks_browsesearch' )->text() );
63
		$smw_row = new ALRow( 'smw' );
64
		$displaying_data_section = new ALSection( wfMessage( 'smw_adminlinks_displayingdata' )->text() );
65
		$smw_row->addItem( AlItem::newFromExternalLink(
66
			'http://semantic-mediawiki.org/wiki/Help:Inline_queries',
67
			wfMessage( 'smw_adminlinks_inlinequerieshelp' )->text()
68
		) );
69
70
		$displaying_data_section->addRow( $smw_row );
71
		$admin_links_tree->addSection( $displaying_data_section, wfMessage( 'adminlinks_browsesearch' )->text() );
72
		$browse_search_section = $admin_links_tree->getSection( wfMessage( 'adminlinks_browsesearch' )->text() );
73
74
		$smw_row = new ALRow( 'smw' );
75
		$smw_row->addItem( ALItem::newFromSpecialPage( 'Browse' ) );
76
		$smw_row->addItem( ALItem::newFromSpecialPage( 'Ask' ) );
77
		$smw_row->addItem( ALItem::newFromSpecialPage( 'SearchByProperty' ) );
78
		$browse_search_section->addRow( $smw_row );
79
80
		return true;
81
		// @codeCoverageIgnoreEnd
82
	}
83
84
}
85