Completed
Push — master ( 692bc3...b58f0a )
by mw
333:43 queued 298:51
created

Specials/Admin/DeprecationNoticeTaskHandler.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SMW\MediaWiki\Specials\Admin;
4
5
use SMW\Message;
6
use Html;
7
use WebRequest;
8
9
/**
10
 * @license GNU GPL v2+
11
 * @since   3.0
12
 *
13
 * @author mwjames
14
 */
15
class DeprecationNoticeTaskHandler extends TaskHandler {
16
17
	/**
18
	 * @var OutputFormatter
19
	 */
20
	private $outputFormatter;
21
22
	/**
23
	 * @var array
24
	 */
25
	private $configList = array();
26
27
	/**
28
	 * @since 3.0
29
	 *
30
	 * @param OutputFormatter $outputFormatter
31
	 * @param array $configList
32
	 */
33
	public function __construct( OutputFormatter $outputFormatter, array $configList = array() ) {
34
		$this->outputFormatter = $outputFormatter;
35
		$this->configList = $configList;
36
	}
37
38
	/**
39
	 * @since 3.0
40
	 *
41
	 * {@inheritDoc}
42
	 */
43
	public function getHtml() {
44
45
		$noticeList = array();
46
47
		$deprecatedConfigList = array(
48
		//	'smwgCacheType' => 'smwgMainCacheType',
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
			'smwgAdminRefreshStore' => 'smwgAdminFeatures',
50
			'smwgQueryDependencyPropertyExemptionlist' => 'smwgQueryDependencyPropertyExemptionList',
51
			'smwgQueryDependencyAffiliatePropertyDetectionlist' => 'smwgQueryDependencyAffiliatePropertyDetectionList'
52
		);
53
54
		$removedConfigList = array(
55
		//	'smwgTranslate'
56
		);
57
58
		foreach ( $deprecatedConfigList as $deprecated => $new ) {
59
			if ( isset( $this->configList[$deprecated] ) ) {
60
				$noticeList[] = $this->createListItem( array( 'smw-admin-deprecation-notice-config-replacement', '$' . $deprecated, '$' . $new ) );
61
			}
62
		}
63
64
		foreach ( $removedConfigList as $removed ) {
65
			if ( isset( $this->configList[$removed] ) ) {
66
				$noticeList[] = $this->createListItem( array( 'smw-admin-deprecation-notice-config-removal', '$' . $removed ) );
67
			}
68
		}
69
70
		if ( $noticeList === array() ) {
71
			return '';
72
		}
73
74
		return Html::rawElement( 'h2', array(), $this->getMessageAsString( 'smw-admin-deprecation-notice-title' ) ) .
75
			Html::rawElement( 'div', array( 'class' => 'smw-admin-deprecation-notice-section' ),
76
				Html::rawElement( 'p', array( 'class' => 'smw-admin-deprecation-notice-docu-section plainlinks' ), $this->getMessageAsString( 'smw-admin-deprecation-notice-docu' ) ) .
77
				Html::rawElement( 'div', array( 'class' => 'plainlinks' ),
78
					Html::rawElement( 'ul', array(), implode( '', $noticeList ) )
79
			)
80
		);
81
	}
82
83
	/**
84
	 * @since 3.0
85
	 *
86
	 * {@inheritDoc}
87
	 */
88
	public function isTaskFor( $task ) {}
89
90
	/**
91
	 * @since 3.0
92
	 *
93
	 * {@inheritDoc}
94
	 */
95
	public function handleRequest( WebRequest $webRequest ) {}
96
97
	private function createListItem( $message ) {
98
		return Html::rawElement( 'li', array(), $this->getMessageAsString( $message, Message::PARSE ) );
99
	}
100
101
}
102