34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/rssparser.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
43$action =
GETPOST(
'action',
'aZ09');
56$sql =
"SELECT ".$db->decrypt(
'name').
" as name FROM ".MAIN_DB_PREFIX.
"const";
57$sql .=
" WHERE ".$db->decrypt(
'name').
" LIKE 'EXTERNAL_RSS_URLRSS_%'";
59$result = $db->query($sql);
62 while ($obj = $db->fetch_object($result)) {
63 preg_match(
'/([0-9]+)$/i', $obj->name, $reg);
64 if ($reg[1] && $reg[1] > $lastexternalrss) {
65 $lastexternalrss = $reg[1];
72if ($action ==
'add' ||
GETPOST(
"modify")) {
73 $external_rss_title =
"external_rss_title_".GETPOSTINT(
"norss");
74 $external_rss_urlrss =
"external_rss_urlrss_".GETPOSTINT(
"norss");
76 if (
GETPOST($external_rss_urlrss,
'alpha')) {
77 $boxlabel =
'(ExternalRSSInformations)';
97 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, note)";
98 $sql .=
" VALUES ('box_external_rss.php', '".$db->escape(
GETPOSTINT(
"norss").
" (".
GETPOST($external_rss_title)).
")')";
99 if (!$db->query($sql)) {
109 $consttosave =
"EXTERNAL_RSS_URLRSS_".GETPOSTINT(
"norss");
110 $urltosave =
GETPOST($external_rss_urlrss,
'alpha');
111 $result2 =
dolibarr_set_const($db, $consttosave, $urltosave,
'chaine', 0,
'', $conf->entity);
115 if ($result1 && $result2) {
117 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
131 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"boxes_def";
132 $sql .=
" WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(
GETPOSTINT(
"norss")).
" %'";
134 $resql = $db->query($sql);
136 $num = $db->num_rows($resql);
139 $obj = $db->fetch_object($resql);
141 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
142 $sql .=
" WHERE entity = ".$conf->entity;
143 $sql .=
" AND box_id = ".((int) $obj->rowid);
144 $resql = $db->query($sql);
146 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
147 $sql .=
" WHERE rowid = ".((int) $obj->rowid);
148 $resql = $db->query($sql);
173 if ($result1 && $result2) {
175 header(
"Location: external_rss.php");
188$form =
new Form($db);
190llxHeader(
'', $langs->trans(
"ExternalRSSSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-external_rss');
192$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
193print
load_fiche_titre($langs->trans(
"ExternalRSSSetup"), $linkback,
'title_setup');
197print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
198print
'<input type="hidden" name="token" value="'.newToken().
'">';
200print
'<div class="div-table-responsive-no-min">';
201print
'<table class="noborder centpercent">';
203print
'<tr class="liste_titre">';
204print
'<td colspan="2">'.$langs->trans(
"NewRSS").
'</td>';
205print
'<td>'.$langs->trans(
"Example").
'</td>';
208print
'<tr class="oddeven">';
209print
'<td width="100">'.$langs->trans(
"Title").
'</td>';
210print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).
'" value=""></td>';
211print
'<td>'.$langs->trans(
'RSSUrlExample').
'</td>';
214print
'<tr class="oddeven">';
215print
'<td>'.$langs->trans(
'RSSUrl').
'</td>';
216print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).
'" value=""></td>';
217print
'<td>https://news.google.com/news?ned=us&topic=h&output=rss<br>https://www.dolibarr.org/rss</td>';
223print $form->buttonsSaveCancel(
"Add",
'');
224print
'<input type="hidden" name="action" value="add">';
225print
'<input type="hidden" name="norss" value="'.($lastexternalrss + 1).
'">';
230print
'<span class="opacitymedium">'.$langs->trans(
'RssNote').
'</span>';
232print
'<a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.$langs->trans(
'JumpToBoxes').
'</a>';
235$sql =
"SELECT rowid, file, note FROM ".MAIN_DB_PREFIX.
"boxes_def";
236$sql .=
" WHERE file = 'box_external_rss.php'";
237$sql .=
" ORDER BY note";
240$resql = $db->query($sql);
243 $num = $db->num_rows($resql);
247 $obj = $db->fetch_object($resql);
249 preg_match(
'/^([0-9]+)/i', $obj->note, $reg);
251 $keyrsstitle =
"EXTERNAL_RSS_TITLE_".$idrss;
252 $keyrssurl =
"EXTERNAL_RSS_URLRSS_".$idrss;
256 $result = $rssparser->parser(
getDolGlobalString($keyrssurl), 5, 300, $conf->externalrss->dir_temp);
259 print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
261 print
'<table class="noborder centpercent">'.
"\n";
262 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
264 print
'<tr class="liste_titre">';
265 print
"<td>".$langs->trans(
"RSS").
" ".($i + 1).
"</td>";
266 print
'<td class="right">';
267 print
'<input type="submit" class="button buttongen button-save" name="modify" value="'.$langs->trans(
"Modify").
'">';
268 print
'<input type="submit" class="button buttongen button-cancel" name="delete" value="'.$langs->trans(
"Delete").
'">';
269 print
'<input type="hidden" name="norss" value="'.$idrss.
'">';
274 print
'<tr class="oddeven">';
275 print
'<td class="titlefield">'.$langs->trans(
"Title").
"</td>";
280 print
'<tr class="oddeven">';
281 print
"<td>".$langs->trans(
"URL").
"</td>";
286 print
'<tr class="oddeven">';
287 print
"<td>".$langs->trans(
"Status").
"</td>";
289 if ($result > 0 && empty($rssparser->error)) {
290 print
'<span class="ok">'.img_picto($langs->trans(
"Online"),
'tick',
'class="pictofixedwidth"').$langs->trans(
"Online").
'</div>';
292 print
'<span class="error">'.$langs->trans(
"Offline");
293 $langs->load(
"errors");
294 if ($rssparser->error) {
295 print
' - '.$langs->trans($rssparser->error);
303 if ($result > 0 && empty($rssparser->error)) {
304 print
'<tr class="oddeven">';
305 print
"<td>".$langs->trans(
"Logo").
"</td>";
307 $imageurl = $rssparser->getImageUrl();
308 $linkrss = $rssparser->getLink();
309 if (!preg_match(
'/^http/', $imageurl)) {
310 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
313 $imageurl = $linkrss.$imageurl;
316 if ($imageurl && preg_match(
'/^http/', $imageurl)) {
317 print
'<img height="32" src="'.$imageurl.
'">';
319 print $langs->trans(
"None");
326 $active =
_isInBoxList((
int) $idrss, $boxlist) ?
'yes' :
'no';
327 print
'<tr class="oddeven">';
328 print
'<td>'.$langs->trans(
'WidgetAvailable').
'</td>';
329 print
'<td>'.yn($active);
330 print
' - <a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">';
331 print $langs->trans(
"JumpToBoxes");
336 print
'</table>'.
"\n";
359 foreach ($boxlist as $box) {
360 if ($box->boxcode ===
"lastrssinfos" && strpos($box->note, (
string) $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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.