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\ApplicationFactory; |
||
6 | use SMW\MediaWiki\Renderer\HtmlFormRenderer; |
||
7 | use SMW\Message; |
||
8 | use SMW\Store; |
||
9 | use Html; |
||
10 | use WebRequest; |
||
11 | use Title; |
||
12 | use Job; |
||
13 | |||
14 | /** |
||
15 | * @license GNU GPL v2+ |
||
16 | * @since 2.5 |
||
17 | * |
||
18 | * @author mwjames |
||
19 | */ |
||
20 | class DisposeJobTaskHandler extends TaskHandler { |
||
21 | |||
22 | /** |
||
23 | * @var Store |
||
24 | */ |
||
25 | private $store; |
||
26 | |||
27 | /** |
||
28 | * @var HtmlFormRenderer |
||
29 | */ |
||
30 | private $htmlFormRenderer; |
||
31 | |||
32 | /** |
||
33 | * @var OutputFormatter |
||
34 | */ |
||
35 | private $outputFormatter; |
||
36 | |||
37 | /** |
||
38 | * @var null|Job |
||
39 | */ |
||
40 | private $refreshjob = null; |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | /** |
||
43 | * @since 2.5 |
||
44 | * |
||
45 | * @param Store $store |
||
46 | * @param HtmlFormRenderer $htmlFormRenderer |
||
47 | * @param OutputFormatter $outputFormatter |
||
48 | */ |
||
49 | public function __construct( Store $store, HtmlFormRenderer $htmlFormRenderer, OutputFormatter $outputFormatter ) { |
||
50 | $this->store = $store; |
||
51 | $this->htmlFormRenderer = $htmlFormRenderer; |
||
52 | $this->outputFormatter = $outputFormatter; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @since 2.5 |
||
57 | * |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | public function isTaskFor( $task ) { |
||
61 | return $task === 'dispose'; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @since 2.5 |
||
66 | * |
||
67 | * {@inheritDoc} |
||
68 | */ |
||
69 | public function getHtml() { |
||
70 | |||
71 | // smw-admin-outdateddisposal |
||
72 | $this->htmlFormRenderer |
||
73 | ->addHeader( 'h3', $this->getMessageAsString( 'smw-admin-outdateddisposal-title' ) ) |
||
74 | ->addParagraph( $this->getMessageAsString( 'smw-admin-outdateddisposal-intro', Message::PARSE ) ); |
||
75 | |||
76 | if ( $this->isEnabledFeature( SMW_ADM_DISPOSAL ) && !$this->hasEntityIdDisposerJob() ) { |
||
77 | $this->htmlFormRenderer |
||
78 | ->setMethod( 'post' ) |
||
79 | ->addHiddenField( 'action', 'dispose' ) |
||
80 | ->addSubmitButton( |
||
81 | $this->getMessageAsString( 'smw-admin-outdateddisposal-button' ), |
||
82 | array( |
||
83 | 'class' => '' |
||
84 | ) |
||
85 | ); |
||
86 | } elseif ( $this->isEnabledFeature( SMW_ADM_DISPOSAL ) ) { |
||
87 | $this->htmlFormRenderer |
||
88 | ->addParagraph( |
||
89 | Html::element( 'span', array( 'class' => 'smw-admin-circle-orange' ), '' ) . |
||
90 | Html::element( 'span', array( 'style' => 'font-style:italic; margin-left:25px;' ), $this->getMessageAsString( 'smw-admin-outdateddisposal-active' ) ) |
||
91 | ); |
||
92 | } else { |
||
93 | $this->htmlFormRenderer |
||
94 | ->addParagraph( $this->getMessageAsString( 'smw-admin-feature-disabled' ) ); |
||
95 | } |
||
96 | |||
97 | return Html::rawElement( 'div', array(), $this->htmlFormRenderer->getForm() ); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @since 2.5 |
||
102 | * |
||
103 | * {@inheritDoc} |
||
104 | */ |
||
105 | public function handleRequest( WebRequest $webRequest ) { |
||
106 | |||
107 | if ( $this->isEnabledFeature( SMW_ADM_DISPOSAL ) && !$this->hasEntityIdDisposerJob() ) { |
||
108 | $entityIdDisposerJob = ApplicationFactory::getInstance()->newJobFactory()->newByType( |
||
109 | 'SMW\EntityIdDisposerJob', |
||
110 | \SpecialPage::getTitleFor( 'SMWAdmin' ) |
||
111 | ); |
||
112 | |||
113 | $entityIdDisposerJob->insert(); |
||
114 | } |
||
115 | |||
116 | $this->outputFormatter->redirectToRootPage( $this->getMessageAsString( 'smw-admin-outdateddisposal-title' ) ); |
||
117 | } |
||
118 | |||
119 | private function hasEntityIdDisposerJob() { |
||
120 | |||
121 | if ( !$this->isEnabledFeature( SMW_ADM_DISPOSAL ) ) { |
||
122 | return false; |
||
123 | } |
||
124 | |||
125 | $jobQueueLookup = ApplicationFactory::getInstance()->create( |
||
126 | 'JobQueueLookup', |
||
127 | $this->store->getConnection( 'mw.db' ) |
||
128 | ); |
||
129 | |||
130 | $row = $jobQueueLookup->selectJobRowBy( |
||
131 | 'SMW\EntityIdDisposerJob' |
||
132 | ); |
||
133 | |||
134 | return $row !== null && $row !== false; |
||
135 | } |
||
136 | |||
137 | } |
||
138 |
This check marks private properties in classes that are never used. Those properties can be removed.