33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/rssparser.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
42$action =
GETPOST(
'action',
'aZ09');
55$sql =
"SELECT ".$db->decrypt(
'name').
" as name FROM ".MAIN_DB_PREFIX.
"const";
56$sql .=
" WHERE ".$db->decrypt(
'name').
" LIKE 'EXTERNAL_RSS_URLRSS_%'";
58$result = $db->query($sql);
61 while ($obj = $db->fetch_object($result)) {
62 preg_match(
'/([0-9]+)$/i', $obj->name, $reg);
63 if ($reg[1] && $reg[1] > $lastexternalrss) {
64 $lastexternalrss = $reg[1];
71if ($action ==
'add' ||
GETPOST(
"modify")) {
72 $external_rss_title =
"external_rss_title_".GETPOSTINT(
"norss");
73 $external_rss_urlrss =
"external_rss_urlrss_".GETPOSTINT(
"norss");
75 if (
GETPOST($external_rss_urlrss,
'alpha')) {
76 $boxlabel =
'(ExternalRSSInformations)';
96 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, note)";
97 $sql .=
" VALUES ('box_external_rss.php', '".$db->escape(
GETPOSTINT(
"norss").
" (".
GETPOST($external_rss_title)).
")')";
98 if (!$db->query($sql)) {
107 $consttosave =
"EXTERNAL_RSS_URLRSS_".GETPOSTINT(
"norss");
108 $urltosave =
GETPOST($external_rss_urlrss,
'alpha');
109 $result2 =
dolibarr_set_const($db, $consttosave, $urltosave,
'chaine', 0,
'', $conf->entity);
113 if ($result1 && $result2) {
115 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
129 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"boxes_def";
130 $sql .=
" WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(
GETPOSTINT(
"norss")).
" %'";
132 $resql = $db->query($sql);
134 $num = $db->num_rows($resql);
137 $obj = $db->fetch_object($resql);
139 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
140 $sql .=
" WHERE entity = ".$conf->entity;
141 $sql .=
" AND box_id = ".((int) $obj->rowid);
142 $resql = $db->query($sql);
144 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
145 $sql .=
" WHERE rowid = ".((int) $obj->rowid);
146 $resql = $db->query($sql);
170 if ($result1 && $result2) {
172 header(
"Location: external_rss.php");
185$form =
new Form($db);
187llxHeader(
'', $langs->trans(
"ExternalRSSSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-external_rss');
189$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
190print
load_fiche_titre($langs->trans(
"ExternalRSSSetup"), $linkback,
'title_setup');
194print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
195print
'<input type="hidden" name="token" value="'.newToken().
'">';
197print
'<div class="div-table-responsive-no-min">';
198print
'<table class="noborder centpercent">';
200print
'<tr class="liste_titre">';
201print
'<td colspan="2">'.$langs->trans(
"NewRSS").
'</td>';
202print
'<td>'.$langs->trans(
"Example").
'</td>';
205print
'<tr class="oddeven">';
206print
'<td width="100">'.$langs->trans(
"Title").
'</td>';
207print
'<td><input type="text" class="flat minwidth300" name="external_rss_title_'.($lastexternalrss + 1).
'" value=""></td>';
208print
'<td>'.$langs->trans(
'RSSUrlExample').
'</td>';
211print
'<tr class="oddeven">';
212print
'<td>'.$langs->trans(
'RSSUrl').
'</td>';
213print
'<td><input type="text" class="flat minwidth300" name="external_rss_urlrss_'.($lastexternalrss + 1).
'" value=""></td>';
214print
'<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
220print $form->buttonsSaveCancel(
"Add",
'');
221print
'<input type="hidden" name="action" value="add">';
222print
'<input type="hidden" name="norss" value="'.($lastexternalrss + 1).
'">';
227print
'<span class="opacitymedium">'.$langs->trans(
'RssNote').
'</span>';
229print
'<a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.$langs->trans(
'JumpToBoxes').
'</a>';
232$sql =
"SELECT rowid, file, note FROM ".MAIN_DB_PREFIX.
"boxes_def";
233$sql .=
" WHERE file = 'box_external_rss.php'";
234$sql .=
" ORDER BY note";
237$resql = $db->query($sql);
240 $num = $db->num_rows($resql);
244 $obj = $db->fetch_object($resql);
246 preg_match(
'/^([0-9]+)/i', $obj->note, $reg);
248 $keyrsstitle =
"EXTERNAL_RSS_TITLE_".$idrss;
249 $keyrssurl =
"EXTERNAL_RSS_URLRSS_".$idrss;
253 $result = $rssparser->parser(
getDolGlobalString($keyrssurl), 5, 300, $conf->externalrss->dir_temp);
256 print
'<form name="externalrssconfig" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
258 print
'<table class="noborder centpercent">'.
"\n";
259 print
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
261 print
'<tr class="liste_titre">';
262 print
"<td>".$langs->trans(
"RSS").
" ".($i + 1).
"</td>";
263 print
'<td class="right">';
264 print
'<input type="submit" class="button buttongen button-save" name="modify" value="'.$langs->trans(
"Modify").
'">';
265 print
'<input type="submit" class="button buttongen button-cancel" name="delete" value="'.$langs->trans(
"Delete").
'">';
266 print
'<input type="hidden" name="norss" value="'.$idrss.
'">';
271 print
'<tr class="oddeven">';
272 print
'<td class="titlefield">'.$langs->trans(
"Title").
"</td>";
277 print
'<tr class="oddeven">';
278 print
"<td>".$langs->trans(
"URL").
"</td>";
283 print
'<tr class="oddeven">';
284 print
"<td>".$langs->trans(
"Status").
"</td>";
286 if ($result > 0 && empty($rssparser->error)) {
287 print
'<span class="ok">'.img_picto($langs->trans(
"Online"),
'tick',
'class="pictofixedwidth"').$langs->trans(
"Online").
'</div>';
289 print
'<span class="error">'.$langs->trans(
"Offline");
290 $langs->load(
"errors");
291 if ($rssparser->error) {
292 print
' - '.$langs->trans($rssparser->error);
300 if ($result > 0 && empty($rss->error)) {
301 print
'<tr class="oddeven">';
302 print
"<td>".$langs->trans(
"Logo").
"</td>";
304 $imageurl = $rssparser->getImageUrl();
305 $linkrss = $rssparser->getLink();
306 if (!preg_match(
'/^http/', $imageurl)) {
307 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
310 $imageurl = $linkrss.$imageurl;
313 if ($imageurl && preg_match(
'/^http/', $imageurl)) {
314 print
'<img height="32" src="'.$imageurl.
'">';
316 print $langs->trans(
"None");
323 $active =
_isInBoxList($idrss, $boxlist) ?
'yes' :
'no';
324 print
'<tr class="oddeven">';
325 print
'<td>'.$langs->trans(
'WidgetAvailable').
'</td>';
326 print
'<td>'.yn($active);
327 print
' - <a href="'.DOL_URL_ROOT.
'/admin/boxes.php?backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">';
328 print $langs->trans(
"JumpToBoxes");
333 print
'</table>'.
"\n";
356 foreach ($boxlist as $box) {
357 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()
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 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.