32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/rssparser.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
46$action =
GETPOST(
'action',
'aZ09');
54$sql =
"SELECT ".$db->decrypt(
'name').
" as name FROM ".MAIN_DB_PREFIX.
"const";
55$sql .=
" WHERE ".$db->decrypt(
'name').
" LIKE 'EXTERNAL_RSS_URLRSS_%'";
57$result = $db->query($sql);
60 while ($obj = $db->fetch_object($result)) {
61 preg_match(
'/([0-9]+)$/i', $obj->name, $reg);
62 if ($reg[1] && $reg[1] > $lastexternalrss) {
63 $lastexternalrss = $reg[1];
70if ($action ==
'add' ||
GETPOST(
"modify")) {
71 $external_rss_title =
"external_rss_title_".GETPOST(
"norss",
'int');
72 $external_rss_urlrss =
"external_rss_urlrss_".GETPOST(
"norss",
'int');
74 if (
GETPOST($external_rss_urlrss,
'alpha')) {
75 $boxlabel =
'(ExternalRSSInformations)';
95 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, note)";
96 $sql .=
" VALUES ('box_external_rss.php','".$db->escape(
GETPOST(
"norss",
'int').
' ('.
GETPOST($external_rss_title,
'alpha')).
")')";
97 if (!$db->query($sql)) {
106 $consttosave =
"EXTERNAL_RSS_URLRSS_".GETPOST(
"norss",
'int');
107 $urltosave =
GETPOST($external_rss_urlrss,
'alpha');
108 $result2 =
dolibarr_set_const($db, $consttosave, $urltosave,
'chaine', 0,
'', $conf->entity);
112 if ($result1 && $result2) {
114 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
128 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"boxes_def";
129 $sql .=
" WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(
GETPOST(
"norss",
'int')).
" %'";
131 $resql = $db->query($sql);
133 $num = $db->num_rows($resql);
136 $obj = $db->fetch_object($resql);
138 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
139 $sql .=
" WHERE entity = ".$conf->entity;
140 $sql .=
" AND box_id = ".((int) $obj->rowid);
141 $resql = $db->query($sql);
143 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
144 $sql .=
" WHERE rowid = ".((int) $obj->rowid);
145 $resql = $db->query($sql);
169 if ($result1 && $result2) {
171 header(
"Location: external_rss.php");
184$form =
new Form($db);
186llxHeader(
'', $langs->trans(
"ExternalRSSSetup"));
188$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
189print
load_fiche_titre($langs->trans(
"ExternalRSSSetup"), $linkback,
'title_setup');
193print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
194print
'<input type="hidden" name="token" value="'.newToken().
'">';
196print
'<table class="noborder centpercent">';
197print
'<tr class="liste_titre">';
198print
'<td colspan="2">'.$langs->trans(
"NewRSS").
'</td>';
199print
'<td>'.$langs->trans(
"Example").
'</td>';
201print
'<tr class="impair">';
202print
'<td width="100">'.$langs->trans(
"Title").
'</td>';
203print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).
'" value=""></td>';
204print
'<td>'.$langs->trans(
'RSSUrlExample').
'</td>';
207print
'<tr class="pair">';
208print
'<td>'.$langs->trans(
'RSSUrl').
'</td>';
209print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).
'" value=""></td>';
210print
'<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
214print $form->buttonsSaveCancel(
"Add",
'');
215print
'<input type="hidden" name="action" value="add">';
216print
'<input type="hidden" name="norss" value="'.($lastexternalrss + 1).
'">';
221print
'<span class="opacitymedium">'.$langs->trans(
'RssNote').
'</span> - <a href="'.DOL_MAIN_URL_ROOT.
'/admin/boxes.php">'.$langs->trans(
'JumpToBoxes').
'</a>';
224$sql =
"SELECT rowid, file, note FROM ".MAIN_DB_PREFIX.
"boxes_def";
225$sql .=
" WHERE file = 'box_external_rss.php'";
226$sql .=
" ORDER BY note";
229$resql = $db->query($sql);
232 $num = $db->num_rows($resql);
236 $obj = $db->fetch_object($resql);
238 preg_match(
'/^([0-9]+)/i', $obj->note, $reg);
240 $keyrsstitle =
"EXTERNAL_RSS_TITLE_".$idrss;
241 $keyrssurl =
"EXTERNAL_RSS_URLRSS_".$idrss;
245 $result = $rssparser->parser($conf->global->$keyrssurl, 5, 300, $conf->externalrss->dir_temp);
248 print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
250 print
'<table class="noborder centpercent">'.
"\n";
251 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
253 print
'<tr class="liste_titre">';
254 print
"<td>".$langs->trans(
"RSS").
" ".($i + 1).
"</td>";
255 print
'<td class="right">';
256 print
'<input type="submit" class="button buttongen button-save" name="modify" value="'.$langs->trans(
"Modify").
'">';
257 print
'<input type="submit" class="button buttongen button-cancel" name="delete" value="'.$langs->trans(
"Delete").
'">';
258 print
'<input type="hidden" name="norss" value="'.$idrss.
'">';
263 print
'<tr class="oddeven">';
264 print
'<td class="titlefield">'.$langs->trans(
"Title").
"</td>";
265 print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.$idrss.
'" value="'.
dol_escape_htmltag($conf->global->$keyrsstitle).
'"></td>';
269 print
'<tr class="oddeven">';
270 print
"<td>".$langs->trans(
"URL").
"</td>";
271 print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.$idrss.
'" value="'.
dol_escape_htmltag($conf->global->$keyrssurl).
'"></td>';
275 print
'<tr class="oddeven">';
276 print
"<td>".$langs->trans(
"Status").
"</td>";
278 if ($result > 0 && empty($rss->error)) {
279 print
'<span class="ok">'.$langs->trans(
"Online").
'</div>';
281 print
'<span class="error">'.$langs->trans(
"Offline");
282 $langs->load(
"errors");
283 if ($rssparser->error) {
284 print
' - '.$langs->trans($rssparser->error);
292 if ($result > 0 && empty($rss->error)) {
293 print
'<tr class="oddeven">';
294 print
"<td>".$langs->trans(
"Logo").
"</td>";
296 $imageurl = $rssparser->getImageUrl();
297 $linkrss = $rssparser->getLink();
298 if (!preg_match(
'/^http/', $imageurl)) {
299 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
302 $imageurl = $linkrss.$imageurl;
305 if ($imageurl && preg_match(
'/^http/', $imageurl)) {
306 print
'<img height="32" src="'.$imageurl.
'">';
308 print $langs->trans(
"None");
315 $active = _isInBoxList($idrss, $boxlist) ?
'yes' :
'no';
316 print
'<tr class="oddeven">';
317 print
'<td>'.$langs->trans(
'WidgetAvailable').
'</td>';
318 print
'<td>'.yn($active).
'</td>';
321 print
'</table>'.
"\n";
342function _isInBoxList($idrss, array $boxlist)
344 foreach ($boxlist as $box) {
345 if ($box->boxcode ===
"lastrssinfos" && strpos($box->note, $idrss) !==
false) {
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static listBoxes($dbs, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
Return array of boxes qualified for area and user.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.