Skip to content

Commit 9061824

Browse files
committed
Merge pull request TYPO3-extensions#3 from markusguenther/feature_flushErrorsFromBeModule
[FEATURE] Add flush errors button to backend module
2 parents 811804c + 13b2b9b commit 9061824

File tree

4 files changed

+143
-24
lines changed

4 files changed

+143
-24
lines changed

Classes/Backend/SolrModule/IndexQueueModuleController.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
use TYPO3\CMS\Core\Messaging\FlashMessage;
2828
use TYPO3\CMS\Core\Utility\GeneralUtility;
29-
29+
use TYPO3\CMS\Core\Database\DatabaseConnection;
30+
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
3031

3132
/**
3233
* Index Queue Module
@@ -86,9 +87,11 @@ public function initializeIndexQueueAction() {
8687
);
8788
}
8889
} else {
90+
$messageLabel = 'solr.backend.index_queue_module.flashmessage.initialize.no_selection';
91+
$titleLabel = 'solr.backend.index_queue_module.flashmessage.not_initialized.title';
8992
$this->addFlashMessage(
90-
'No indexing configurations selected.',
91-
'Index Queue not initialized',
93+
LocalizationUtility::translate($messageLabel, 'Solr'),
94+
LocalizationUtility::translate($titleLabel, 'Solr'),
9295
FlashMessage::WARNING
9396
);
9497
}
@@ -103,16 +106,44 @@ public function initializeIndexQueueAction() {
103106
}
104107

105108
if (!empty($initializedIndexingConfigurations)) {
109+
$messageLabel = 'solr.backend.index_queue_module.flashmessage.initialize.success';
110+
$titleLabel = 'solr.backend.index_queue_module.flashmessage.initialize.title';
106111
$this->addFlashMessage(
107-
'Initialized indexing configurations: ' . implode(', ', $messagesForConfigurations),
108-
'Index Queue initialized',
112+
LocalizationUtility::translate($messageLabel, 'Solr', array(implode(', ', $messagesForConfigurations))),
113+
LocalizationUtility::translate($titleLabel, 'Solr'),
109114
FlashMessage::OK
110115
);
111116
}
112117

113118
$this->forward('index');
114119
}
115120

121+
/**
122+
* Removes all errors in the index queue list. So that the items can be indexed again.
123+
*
124+
* @return void
125+
*/
126+
public function flushLogErrorsAction() {
127+
/** @var DatabaseConnection $database */
128+
$database = $GLOBALS['TYPO3_DB'];
129+
$flushResult = $database->exec_UPDATEquery('tx_solr_indexqueue_item', 'errors NOT LIKE ""', array('errors' => ''));
130+
131+
$label = 'solr.backend.index_queue_module.flashmessage.success.flush_errors';
132+
$severity = FlashMessage::OK;
133+
if (!$flushResult) {
134+
$label = 'solr.backend.index_queue_module.flashmessage.error.flush_errors';
135+
$severity = FlashMessage::ERROR;
136+
}
137+
138+
$this->addFlashMessage(
139+
LocalizationUtility::translate($label, 'Solr'),
140+
LocalizationUtility::translate('solr.backend.index_queue_module.flashmessage.title', 'Solr'),
141+
$severity
142+
);
143+
144+
$this->forward('index');
145+
}
146+
116147
/**
117148
* Renders a field to select which indexing configurations to initialize.
118149
*
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2+
<xliff version="1.0">
3+
<file source-language="en" datatype="plaintext" original="messages" date="2015-03-30T11:42:09Z">
4+
<header>
5+
<generator>LFEditor</generator>
6+
</header>
7+
<body>
8+
<trans-unit id="solr.backend.index_queue_module.description" xml:space="preserve">
9+
<source>The Index Queue manages content indexing. Content enters the Index Queue by initialization below or when new content is created based on configuration. Items in the Index Queue are indexed newest changes first until all items in the queue have been indexed.</source>
10+
</trans-unit>
11+
<trans-unit id="solr.backend.index_queue_module.errors.flush_button" xml:space="preserve">
12+
<source>Flush errors</source>
13+
</trans-unit>
14+
<trans-unit id="solr.backend.index_queue_module.errors.headline" xml:space="preserve">
15+
<source>Indexing Errors</source>
16+
</trans-unit>
17+
<trans-unit id="solr.backend.index_queue_module.errors.id" xml:space="preserve">
18+
<source>ID</source>
19+
</trans-unit>
20+
<trans-unit id="solr.backend.index_queue_module.errors.item_type" xml:space="preserve">
21+
<source>Item Type</source>
22+
</trans-unit>
23+
<trans-unit id="solr.backend.index_queue_module.errors.item_uid" xml:space="preserve">
24+
<source>Item UID</source>
25+
</trans-unit>
26+
<trans-unit id="solr.backend.index_queue_module.errors.show_button" xml:space="preserve">
27+
<source>Show error</source>
28+
</trans-unit>
29+
<trans-unit id="solr.backend.index_queue_module.flashmessage.error.flush_errors" xml:space="preserve">
30+
<source>An error occured while removing the error log in the index queue.</source>
31+
</trans-unit>
32+
<trans-unit id="solr.backend.index_queue_module.flashmessage.initialize.no_selection" xml:space="preserve">
33+
<source>No indexing configurations selected.</source>
34+
</trans-unit>
35+
<trans-unit id="solr.backend.index_queue_module.flashmessage.initialize.success" xml:space="preserve">
36+
<source>Initialized indexing configurations: %s</source>
37+
</trans-unit>
38+
<trans-unit id="solr.backend.index_queue_module.flashmessage.initialize.title" xml:space="preserve">
39+
<source>Index Queue initialized</source>
40+
</trans-unit>
41+
<trans-unit id="solr.backend.index_queue_module.flashmessage.not_initialized.title" xml:space="preserve">
42+
<source>Index Queue not initialized</source>
43+
</trans-unit>
44+
<trans-unit id="solr.backend.index_queue_module.flashmessage.success.flush_errors" xml:space="preserve">
45+
<source>All errors have been reset.</source>
46+
</trans-unit>
47+
<trans-unit id="solr.backend.index_queue_module.flashmessage.title" xml:space="preserve">
48+
<source>Index Queue</source>
49+
</trans-unit>
50+
<trans-unit id="solr.backend.index_queue_module.help" xml:space="preserve">
51+
<source>Initializing the Index Queue is the most complete way to force re-indexing, or to build the Index Queue for the first time. The Index Queue Worker scheduler task will then index the items listed in the Index Queue.</source>
52+
</trans-unit>
53+
<trans-unit id="solr.backend.index_queue_module.status.errors" xml:space="preserve">
54+
<source> Errors:</source>
55+
</trans-unit>
56+
<trans-unit id="solr.backend.index_queue_module.status.headline" xml:space="preserve">
57+
<source>Index Queue Status</source>
58+
</trans-unit>
59+
<trans-unit id="solr.backend.index_queue_module.status.indexed" xml:space="preserve">
60+
<source> Indexed:</source>
61+
</trans-unit>
62+
<trans-unit id="solr.backend.index_queue_module.status.pending" xml:space="preserve">
63+
<source> Pending:</source>
64+
</trans-unit>
65+
<trans-unit id="solr.backend.index_queue_module.title" xml:space="preserve">
66+
<source>Index Queue Initialization</source>
67+
</trans-unit>
68+
</body>
69+
</file>
70+
</xliff>

Resources/Private/Templates/IndexQueueModule/Index.html

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@
88

99

1010
<div class="well">
11-
The Index Queue manages content indexing. Content enters the Index
12-
Queue by initialization below or when new content is created based on
13-
configuration. Items in the Index Queue are indexed newest changes first
14-
until all items in the queue have been indexed.
11+
<f:translate key="solr.backend.index_queue_module.description" />
1512
</div>
1613

1714

1815

19-
<h2>Index Queue Initialization</h2>
16+
<h2>
17+
<f:translate key="solr.backend.index_queue_module.title" />
18+
</h2>
2019

2120
<f:form name="editform" actionUri="{f:uri.action(controller:'Administration', arguments:{module:'{module.name}', moduleAction:'initializeIndexQueue'} )}">
2221

2322
<f:format.raw>{indexQueueInitializationSelector}</f:format.raw>
2423
<f:form.submit name="initializeIndexQueue" value="Queue Selected Content for Indexing" />
2524
<solr:backend.button.HelpButton title="Index Queue Initialization">
26-
Initializing the Index Queue is the most complete way to force
27-
re-indexing, or to build the Index Queue for the first time. The Index
28-
Queue Worker scheduler task will then index the items listed in the
29-
Index Queue.
25+
<f:translate key="solr.backend.index_queue_module.help" />
3026
</solr:backend.button.HelpButton>
3127

3228
</f:form>
@@ -41,13 +37,21 @@ <h2>Index Queue Initialization</h2>
4137

4238
<div class="row-fluid">
4339
<div class="span8 well">
44-
<h2>Indexing Errors</h2>
40+
<h2>
41+
<f:translate key="solr.backend.index_queue_module.errors.headline" />
42+
</h2>
4543

4644
<table class="table">
4745
<tr>
48-
<th>ID</th>
49-
<th>Item Type</th>
50-
<th>Item UID</th>
46+
<th>
47+
<f:translate key="solr.backend.index_queue_module.errors.id" />
48+
</th>
49+
<th>
50+
<f:translate key="solr.backend.index_queue_module.errors.item_type" />
51+
</th>
52+
<th>
53+
<f:translate key="solr.backend.index_queue_module.errors.item_uid" />
54+
</th>
5155
<th></th>
5256
</tr>
5357

@@ -60,30 +64,44 @@ <h2>Indexing Errors</h2>
6064
<script type="text/plain">
6165
{item.errors}
6266
</script>
63-
<a href="javascript:void(0);" class="show_error">Show error</a>
67+
<a href="javascript:void(0);" class="show_error">
68+
<f:translate key="solr.backend.index_queue_module.errors.show_button" />
69+
</a>
6470
</td>
6571
</tr>
6672
</f:for>
6773
</table>
74+
75+
<f:if condition="{indexqueue_errors}">
76+
<a href="{f:uri.action(controller:'Administration', arguments:{module:'{module.name}', moduleAction:'flushLogErrors'} )}"
77+
class="btn btn-default" >
78+
<f:translate key="solr.backend.index_queue_module.errors.flush_button" />
79+
</a>
80+
</f:if>
6881
</div>
6982

7083
<div class="span4 well stats_container">
71-
<h2>Index Queue Status</h2>
84+
<h2>
85+
<f:translate key="solr.backend.index_queue_module.status.headline" />
86+
</h2>
7287

7388
<canvas id="indexqueue_stats_chart" width="100" height="100"></canvas>
7489

7590
<div style="clear: both;"></div>
7691

7792
<div class="legend">
78-
<span class="color" style="background: #EB813F;"></span> Pending:
93+
<span class="color" style="background: #EB813F;"></span>
94+
<f:translate key="solr.backend.index_queue_module.status.pending" />
7995
<span id="pending_numbers"></span>
8096
</div>
8197
<div class="legend">
82-
<span class="color" style="background: #FF3D3D;"></span> Errors:
98+
<span class="color" style="background: #FF3D3D;"></span>
99+
<f:translate key="solr.backend.index_queue_module.status.errors" />
83100
<span id="error_numbers"></span>
84101
</div>
85102
<div class="legend">
86-
<span class="color" style="background: #9FC299;"></span> Indexed:
103+
<span class="color" style="background: #9FC299;"></span>
104+
<f:translate key="solr.backend.index_queue_module.status.indexed" />
87105
<span id="indexed_numbers"></span>
88106
</div>
89107
</div>

ext_tables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
ApacheSolrForTypo3\Solr\Backend\SolrModule\AdministrationModuleManager::registerModule(
119119
'ApacheSolrForTypo3.' . $_EXTKEY,
120120
'IndexQueue',
121-
array('index,initializeIndexQueue')
121+
array('index,initializeIndexQueue,flushLogErrors')
122122
);
123123

124124
ApacheSolrForTypo3\Solr\Backend\SolrModule\AdministrationModuleManager::registerModule(

0 commit comments

Comments
 (0)