forked from fabarea/rss_display
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.ext_update.php
85 lines (72 loc) · 2.31 KB
/
class.ext_update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/*
* This file is part of the Fab/RssDisplay project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/
/**
* Updater Script for rss_display
*/
class ext_update {
public function access() {
return TRUE;
}
public function main() {
$output[] = $this->updateNewIdentity();
return sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $output));
}
/**
* Update new identity.
*
* @return string
*/
public function updateNewIdentity() {
$condition = "list_type='rss_display_pi1'";
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'tt_content', $condition);
foreach ($rows as $row) {
$flexForm = sprintf('<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
<data>
<sheet index="sDEF">
<language index="lDEF">
<field index="settings.feedUrl">
<value index="vDEF">%s</value>
</field>
<field index="settings.numberOfItems">
<value index="vDEF">%s</value>
</field>
<field index="settings.template">
<value index="vDEF">%s</value>
</field>
<field index="settings.descriptionLength">
<value index="vDEF">%s</value>
</field>
</language>
</sheet>
</data>
</T3FlexForms>',
$row['tx_rssdisplay_feed'],
$row['tx_rssdisplay_quantity'],
$row['tx_rssdisplay_descriptiondisplay'] == 1 ? 'EXT:rss_display/Resources/Private/Templates/Feed/Show.html' : 'EXT:rss_display/Resources/Private/Templates/Feed/ShowWithoutDescription.html',
$row['tx_rssdisplay_descriptionlength']
);
$values = array(
'list_type' => 'rssdisplay_pi1',
'pi_flexform' => $flexForm,
);
$this->getDatabaseConnection()->exec_UPDATEquery('tt_content', 'uid=' . intval($row['uid']), $values);
}
$result = '<strong>Update plugin signature "rssdisplay_pi1"</strong><br/>';
$result .= count($rows) . ' row(s) have been updated';
return $result;
}
/**
* Return a pointer to the database.
*
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected function getDatabaseConnection() {
return $GLOBALS['TYPO3_DB'];
}
}