Completed
Push — master ( b1b8c7...b37043 )
by Timo
06:43
created

ext_update   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2014-2015 Ingo Renner <[email protected]>
6
 *  All rights reserved
7
 *
8
 *  This script is part of the TYPO3 project. The TYPO3 project is
9
 *  free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  The GNU General Public License can be found at
15
 *  http://www.gnu.org/copyleft/gpl.html.
16
 *
17
 *  This script is distributed in the hope that it will be useful,
18
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 *  GNU General Public License for more details.
21
 *
22
 *  This copyright notice MUST APPEAR in all copies of the script!
23
 ***************************************************************/
24
25
26
/**
27
 * Update class for the extension manager.
28
 *
29
 * @author Ingo Renner <[email protected]>
30
 * @package TYPO3
31
 * @subpackage solr
32
 */
33
class ext_update
34
{
35
36
    /**
37
     * Determines whether the update menu entry should by shown.
38
     *
39
     * @return boolean TRUE if we need ti run an update, FALSE otherwise
40
     */
41
    public function access()
42
    {
43
        return $this->needsStaticIncludeUpdate();
44
    }
45
46
    /**
47
     * Checks for old static includes.
48
     *
49
     * @return boolean TRUE if old static includes are found, FALSE if everything's ok
50
     */
51
    protected function needsStaticIncludeUpdate()
52
    {
53
        $numInvalidIncludes = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
54
            'uid',
55
            'sys_template',
56
            'include_static_file LIKE \'%EXT:solr/static/%\''
57
        );
58
59
        return ($numInvalidIncludes > 0);
60
    }
61
62
    /**
63
     * Main update function called by the extension manager.
64
     *
65
     * @return string
66
     */
67
    public function main()
68
    {
69
        $this->updateStaticIncludes();
70
71
        return 'Done.';
72
    }
73
74
    /**
75
     * Updates references to static TypoScript includes
76
     *
77
     * @return void
78
     */
79
    protected function updateStaticIncludes()
80
    {
81
        $GLOBALS['TYPO3_DB']->sql_query(
82
            'UPDATE sys_template
83
			 SET include_static_file = REPLACE(include_static_file, \'/static/\', \'/Configuration/TypoScript/\')
84
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
85
        );
86
87
        $GLOBALS['TYPO3_DB']->sql_query(
88
            'UPDATE sys_template
89
			 SET include_static_file = REPLACE(include_static_file, \'/solr/\', \'/Solr/\')
90
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
91
        );
92
93
        $GLOBALS['TYPO3_DB']->sql_query(
94
            'UPDATE sys_template
95
			 SET include_static_file = REPLACE(include_static_file, \'/opensearch/\', \'/OpenSearch/\')
96
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
97
        );
98
99
        $GLOBALS['TYPO3_DB']->sql_query(
100
            'UPDATE sys_template
101
			 SET include_static_file = REPLACE(include_static_file, \'/everything-on/\', \'/EverythingOn/\')
102
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
103
        );
104
105
        $GLOBALS['TYPO3_DB']->sql_query(
106
            'UPDATE sys_template
107
			 SET include_static_file = REPLACE(include_static_file, \'/filter-pages/\', \'/FilterPages/\')
108
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
109
        );
110
111
        $GLOBALS['TYPO3_DB']->sql_query(
112
            'UPDATE sys_template
113
			 SET include_static_file = REPLACE(include_static_file, \'/indexqueue-news/\', \'/IndexQueueNews/\')
114
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
115
        );
116
117
        $GLOBALS['TYPO3_DB']->sql_query(
118
            'UPDATE sys_template
119
			 SET include_static_file = REPLACE(include_static_file, \'/indexqueue-ttnews/\', \'/IndexQueueTtNews/\')
120
			 WHERE include_static_file LIKE \'%EXT:solr/%\''
121
        );
122
    }
123
}
124