|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: TemplatesUserRss.php 12258 2014-01-02 09:33:29Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class TemplatesUserRss. |
|
27
|
|
|
*/ |
|
28
|
|
|
class TemplatesUserRss extends TDMCreateFile |
|
|
|
|
|
|
29
|
|
|
{ |
|
|
|
|
|
|
30
|
|
|
/* |
|
31
|
|
|
* @public function constructor |
|
32
|
|
|
* @param null |
|
33
|
|
|
*/ |
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
parent::__construct(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/* |
|
43
|
|
|
* @static function &getInstance |
|
44
|
|
|
* @param null |
|
45
|
|
|
*/ |
|
46
|
|
|
/** |
|
47
|
|
|
* @return TemplatesUserRss |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function &getInstance() |
|
50
|
|
|
{ |
|
51
|
|
|
static $instance = false; |
|
52
|
|
|
if (!$instance) { |
|
53
|
|
|
$instance = new self(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return $instance; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/* |
|
60
|
|
|
* @public function write |
|
61
|
|
|
* @param $module |
|
62
|
|
|
* @param $filename |
|
63
|
|
|
*/ |
|
64
|
|
|
/** |
|
65
|
|
|
* @param $module |
|
66
|
|
|
* @param $table |
|
67
|
|
|
*/ |
|
68
|
|
|
public function write($module, $filename) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->setModule($module); |
|
71
|
|
|
$this->setFileName($filename); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/* |
|
75
|
|
|
* @private function getTemplatesUserRssXml |
|
76
|
|
|
* @param string $moduleDirname |
|
77
|
|
|
* @param string $table |
|
78
|
|
|
* @param string $language |
|
79
|
|
|
*/ |
|
80
|
|
|
/** |
|
81
|
|
|
* @param $moduleDirname |
|
82
|
|
|
* @param $table |
|
83
|
|
|
* @param $language |
|
84
|
|
|
* |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
|
|
private function getTemplatesUserRssXml() |
|
88
|
|
|
{ |
|
89
|
|
|
$ret = <<<EOT |
|
90
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
|
91
|
|
|
<rss version="2.0"> |
|
92
|
|
|
<channel> |
|
93
|
|
|
<title><{\$channel_title}></title> |
|
94
|
|
|
<link><{\$channel_link}></link> |
|
95
|
|
|
<description><{\$channel_desc}></description> |
|
96
|
|
|
<lastBuildDate><{\$channel_lastbuild}></lastBuildDate> |
|
97
|
|
|
<docs>http://backend.userland.com/rss/</docs> |
|
98
|
|
|
<generator><{\$channel_generator}></generator> |
|
99
|
|
|
<category><{\$channel_category}></category> |
|
100
|
|
|
<managingEditor><{\$channel_editor}></managingEditor> |
|
101
|
|
|
<webMaster><{\$channel_webmaster}></webMaster> |
|
102
|
|
|
<language><{\$channel_language}></language> |
|
103
|
|
|
<{if \$image_url != ""}> |
|
104
|
|
|
<image> |
|
105
|
|
|
<title><{\$channel_title}></title> |
|
106
|
|
|
<url><{\$image_url}></url> |
|
107
|
|
|
<link><{\$channel_link}></link> |
|
108
|
|
|
<width><{\$image_width}></width> |
|
109
|
|
|
<height><{\$image_height}></height> |
|
110
|
|
|
</image> |
|
111
|
|
|
<{/if}> |
|
112
|
|
|
<{foreach item=item from=\$items}> |
|
113
|
|
|
<item> |
|
114
|
|
|
<title><{\$item.title}></title> |
|
115
|
|
|
<link><{\$item.link}></link> |
|
116
|
|
|
<description><{\$item.description}></description> |
|
117
|
|
|
<pubDate><{\$item.pubdate}></pubDate> |
|
118
|
|
|
<guid><{\$item.guid}></guid> |
|
119
|
|
|
</item> |
|
120
|
|
|
<{/foreach}> |
|
121
|
|
|
</channel> |
|
122
|
|
|
</rss>\n |
|
123
|
|
|
EOT; |
|
124
|
|
|
|
|
125
|
|
|
return $ret; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/* |
|
129
|
|
|
* @public function renderFile |
|
130
|
|
|
* @param null |
|
131
|
|
|
*/ |
|
132
|
|
|
/** |
|
133
|
|
|
* @param null |
|
134
|
|
|
* |
|
135
|
|
|
* @return bool|string |
|
136
|
|
|
*/ |
|
137
|
|
|
public function render() |
|
138
|
|
|
{ |
|
139
|
|
|
$module = $this->getModule(); |
|
140
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
141
|
|
|
$filename = $this->getFileName(); |
|
142
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
|
|
|
|
|
143
|
|
|
$content = $this->getTemplatesUserRssXml(); |
|
144
|
|
|
// |
|
145
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
146
|
|
|
|
|
147
|
|
|
return $this->renderFile(); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.