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';
51$action =
GETPOST(
'action',
'aZ09');
65$sql =
"SELECT ".$db->decrypt(
'name').
" as name FROM ".MAIN_DB_PREFIX.
"const";
66$sql .=
" WHERE ".$db->decrypt(
'name').
" LIKE 'EXTERNAL_RSS_URLRSS_%'";
68$result = $db->query($sql);
71 while ($obj = $db->fetch_object($result)) {
72 preg_match(
'/([0-9]+)$/i', $obj->name, $reg);
73 if ($reg[1] && $reg[1] > $lastexternalrss) {
74 $lastexternalrss = $reg[1];
81if ($action ==
'add' ||
GETPOST(
"modify")) {
82 $external_rss_title =
"external_rss_title_".GETPOSTINT(
"norss");
83 $external_rss_urlrss =
"external_rss_urlrss_".GETPOSTINT(
"norss");
85 if (
GETPOST($external_rss_urlrss,
'alpha')) {
86 $boxlabel =
'(ExternalRSSInformations)';
106 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, note)";
107 $sql .=
" VALUES ('box_external_rss.php', '".$db->escape(
GETPOSTINT(
"norss").
" (".
GETPOST($external_rss_title)).
")')";
108 if (!$db->query($sql)) {
118 $consttosave =
"EXTERNAL_RSS_URLRSS_".GETPOSTINT(
"norss");
119 $urltosave =
GETPOST($external_rss_urlrss,
'alpha');
124 if ($result1 && $result2) {
126 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
140 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"boxes_def";
141 $sql .=
" WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(
GETPOSTINT(
"norss")).
" %'";
143 $resql = $db->query($sql);
145 $num = $db->num_rows($resql);
148 $obj = $db->fetch_object($resql);
150 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
151 $sql .=
" WHERE entity = ".$conf->entity;
152 $sql .=
" AND box_id = ".((int) $obj->rowid);
153 $resql = $db->query($sql);
155 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
156 $sql .=
" WHERE rowid = ".((int) $obj->rowid);
157 $resql = $db->query($sql);
182 if ($result1 && $result2) {
184 header(
"Location: external_rss.php");
197$form =
new Form($db);
199llxHeader(
'', $langs->trans(
"ExternalRSSSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-external_rss');
201$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
202print
load_fiche_titre($langs->trans(
"ExternalRSSSetup"), $linkback,
'title_setup');
206print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
207print
'<input type="hidden" name="token" value="'.newToken().
'">';
209print
'<div class="div-table-responsive-no-min">';
210print
'<table class="noborder centpercent">';
212print
'<tr class="liste_titre">';
213print
'<td colspan="2">'.$langs->trans(
"NewRSS").
'</td>';
214print
'<td>'.$langs->trans(
"Example").
'</td>';
217print
'<tr class="oddeven">';
218print
'<td width="100">'.$langs->trans(
"Title").
'</td>';
219print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).
'" value=""></td>';
220print
'<td>'.$langs->trans(
'RSSUrlExample').
'</td>';
223print
'<tr class="oddeven">';
224print
'<td>'.$langs->trans(
'RSSUrl').
'</td>';
225print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).
'" value=""></td>';
226print
'<td>https://news.google.com/news?ned=us&topic=h&output=rss<br>https://www.dolibarr.org/rss</td>';
232print $form->buttonsSaveCancel(
"Add",
'');
233print
'<input type="hidden" name="action" value="add">';
234print
'<input type="hidden" name="norss" value="'.($lastexternalrss + 1).
'">';
239print
'<span class="opacitymedium">'.$langs->trans(
'RssNote').
'</span>';
241print
'<a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.$langs->trans(
'JumpToBoxes').
'</a>';
244$sql =
"SELECT rowid, file, note FROM ".MAIN_DB_PREFIX.
"boxes_def";
245$sql .=
" WHERE file = 'box_external_rss.php'";
246$sql .=
" ORDER BY note";
249$resql = $db->query($sql);
252 $num = $db->num_rows($resql);
256 $obj = $db->fetch_object($resql);
258 preg_match(
'/^([0-9]+)/i', $obj->note, $reg);
260 $keyrsstitle =
"EXTERNAL_RSS_TITLE_".$idrss;
261 $keyrssurl =
"EXTERNAL_RSS_URLRSS_".$idrss;
268 print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
270 print
'<table class="noborder centpercent">'.
"\n";
271 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
273 print
'<tr class="liste_titre">';
274 print
"<td>".$langs->trans(
"RSS").
" ".($i + 1).
"</td>";
275 print
'<td class="right">';
276 print
'<input type="submit" class="button buttongen button-save" name="modify" value="'.$langs->trans(
"Modify").
'">';
277 print
'<input type="submit" class="button buttongen button-cancel" name="delete" value="'.$langs->trans(
"Delete").
'">';
278 print
'<input type="hidden" name="norss" value="'.$idrss.
'">';
283 print
'<tr class="oddeven">';
284 print
'<td class="titlefield">'.$langs->trans(
"Title").
"</td>";
289 print
'<tr class="oddeven">';
290 print
"<td>".$langs->trans(
"URL").
"</td>";
295 print
'<tr class="oddeven">';
296 print
"<td>".$langs->trans(
"Status").
"</td>";
298 if ($result > 0 && empty($rssparser->error)) {
299 print
'<span class="ok">'.img_picto($langs->trans(
"Online"),
'tick',
'class="pictofixedwidth"').$langs->trans(
"Online").
'</div>';
301 print
'<span class="error">'.$langs->trans(
"Offline");
302 $langs->load(
"errors");
303 if ($rssparser->error) {
304 print
' - '.$langs->trans($rssparser->error);
312 if ($result > 0 && empty($rssparser->error)) {
313 print
'<tr class="oddeven">';
314 print
"<td>".$langs->trans(
"Logo").
"</td>";
316 $imageurl = $rssparser->getImageUrl();
317 $linkrss = $rssparser->getLink();
318 if (!preg_match(
'/^http/', $imageurl)) {
319 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
322 $imageurl = $linkrss.$imageurl;
325 if ($imageurl && preg_match(
'/^http/', $imageurl)) {
326 print
'<img height="32" src="'.$imageurl.
'">';
328 print $langs->trans(
"None");
335 $active =
_isInBoxList((
int) $idrss, $boxlist) ?
'yes' :
'no';
336 print
'<tr class="oddeven">';
337 print
'<td>'.$langs->trans(
'WidgetAvailable').
'</td>';
338 print
'<td>'.yn($active);
339 print
' - <a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">';
340 print $langs->trans(
"JumpToBoxes");
345 print
'</table>'.
"\n";
368 foreach ($boxlist as $box) {
369 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.