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
'<div class="div-table-responsive-no-min">';
197print
'<table class="noborder centpercent">';
199print
'<tr class="liste_titre">';
200print
'<td colspan="2">'.$langs->trans(
"NewRSS").
'</td>';
201print
'<td>'.$langs->trans(
"Example").
'</td>';
204print
'<tr class="oddeven">';
205print
'<td width="100">'.$langs->trans(
"Title").
'</td>';
206print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).
'" value=""></td>';
207print
'<td>'.$langs->trans(
'RSSUrlExample').
'</td>';
210print
'<tr class="oddeven">';
211print
'<td>'.$langs->trans(
'RSSUrl').
'</td>';
212print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).
'" value=""></td>';
213print
'<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
219print $form->buttonsSaveCancel(
"Add",
'');
220print
'<input type="hidden" name="action" value="add">';
221print
'<input type="hidden" name="norss" value="'.($lastexternalrss + 1).
'">';
226print
'<span class="opacitymedium">'.$langs->trans(
'RssNote').
'</span>';
228print
'<a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.$langs->trans(
'JumpToBoxes').
'</a>';
231$sql =
"SELECT rowid, file, note FROM ".MAIN_DB_PREFIX.
"boxes_def";
232$sql .=
" WHERE file = 'box_external_rss.php'";
233$sql .=
" ORDER BY note";
236$resql = $db->query($sql);
239 $num = $db->num_rows($resql);
243 $obj = $db->fetch_object($resql);
245 preg_match(
'/^([0-9]+)/i', $obj->note, $reg);
247 $keyrsstitle =
"EXTERNAL_RSS_TITLE_".$idrss;
248 $keyrssurl =
"EXTERNAL_RSS_URLRSS_".$idrss;
252 $result = $rssparser->parser(
getDolGlobalString($keyrssurl), 5, 300, $conf->externalrss->dir_temp);
255 print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
257 print
'<table class="noborder centpercent">'.
"\n";
258 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
260 print
'<tr class="liste_titre">';
261 print
"<td>".$langs->trans(
"RSS").
" ".($i + 1).
"</td>";
262 print
'<td class="right">';
263 print
'<input type="submit" class="button buttongen button-save" name="modify" value="'.$langs->trans(
"Modify").
'">';
264 print
'<input type="submit" class="button buttongen button-cancel" name="delete" value="'.$langs->trans(
"Delete").
'">';
265 print
'<input type="hidden" name="norss" value="'.$idrss.
'">';
270 print
'<tr class="oddeven">';
271 print
'<td class="titlefield">'.$langs->trans(
"Title").
"</td>";
276 print
'<tr class="oddeven">';
277 print
"<td>".$langs->trans(
"URL").
"</td>";
282 print
'<tr class="oddeven">';
283 print
"<td>".$langs->trans(
"Status").
"</td>";
285 if ($result > 0 && empty($rss->error)) {
286 print
'<span class="ok">'.img_picto($langs->trans(
"Online"),
'tick',
'class="pictofixedwidth"').$langs->trans(
"Online").
'</div>';
288 print
'<span class="error">'.$langs->trans(
"Offline");
289 $langs->load(
"errors");
290 if ($rssparser->error) {
291 print
' - '.$langs->trans($rssparser->error);
299 if ($result > 0 && empty($rss->error)) {
300 print
'<tr class="oddeven">';
301 print
"<td>".$langs->trans(
"Logo").
"</td>";
303 $imageurl = $rssparser->getImageUrl();
304 $linkrss = $rssparser->getLink();
305 if (!preg_match(
'/^http/', $imageurl)) {
306 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
309 $imageurl = $linkrss.$imageurl;
312 if ($imageurl && preg_match(
'/^http/', $imageurl)) {
313 print
'<img height="32" src="'.$imageurl.
'">';
315 print $langs->trans(
"None");
322 $active =
_isInBoxList($idrss, $boxlist) ?
'yes' :
'no';
323 print
'<tr class="oddeven">';
324 print
'<td>'.$langs->trans(
'WidgetAvailable').
'</td>';
325 print
'<td>'.yn($active);
326 print
' - <a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">';
327 print $langs->trans(
"JumpToBoxes");
332 print
'</table>'.
"\n";
355 foreach ($boxlist as $box) {
356 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.
getDolGlobalString($key, $default='')
Return 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.