NEW Externalsite module can accept iframe content.

This commit is contained in:
Laurent Destailleur 2018-02-08 19:00:13 +01:00
parent 26ee7ec5be
commit 0f51963600
4 changed files with 120 additions and 42 deletions

View File

@ -26,6 +26,8 @@
* \brief Page de configuration du module externalsite
*/
if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -50,7 +52,7 @@ if ($action == 'update')
$db->begin();
$label = GETPOST('EXTERNALSITE_LABEL','alpha');
$exturl = GETPOST('EXTERNALSITE_URL','alpha');
$exturl = GETPOST('EXTERNALSITE_URL','none');
$i+=dolibarr_set_const($db,'EXTERNALSITE_LABEL',trim($label),'chaine',0,'',$conf->entity);
$i+=dolibarr_set_const($db,'EXTERNALSITE_URL',trim($exturl),'chaine',0,'',$conf->entity);
@ -104,9 +106,12 @@ print "</tr>";
print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"EXTERNALSITE_URL\" value=\"". (GETPOST('EXTERNALSITE_URL','alpha')?GETPOST('EXTERNALSITE_URL','alpha'):(empty($conf->global->EXTERNALSITE_URL)?'':$conf->global->EXTERNALSITE_URL)) . "\" size=\"40\"></td>";
print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
print (GETPOST('EXTERNALSITE_URL','none')?GETPOST('EXTERNALSITE_URL','none'):(empty($conf->global->EXTERNALSITE_URL)?'':$conf->global->EXTERNALSITE_URL));
print '</textarea></td>';
print "<td>http://localhost/myurl/";
print "<br>http://wikipedia.org/";
print "<br>https://wikipedia.org/";
print "<br>&lt;iframe&gt;...&lt;/iframe&gt;";
print "</td>";
print "</tr>";

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,55 +17,104 @@
*/
/**
* \file htdocs/externalsite/frames.php
* \ingroup externalsite
* \brief Page that build two frames: One for menu, the other for the target page to show
* \author Laurent Destailleur
* \file htdocs/externalsite/frames.php
* \ingroup externalsite
* \brief Page that build two frames: One for menu, the other for the target page to show
* Usage:
* mydomain.com/externalsite/frames.php to show URL set into setup
* mydomain.com/externalsite/frames.php?keyforcontent to show content defined into conf->global->$keyforcontent
*/
require '../main.inc.php';
$langs->load("externalsite");
if (empty($conf->global->EXTERNALSITE_URL))
{
llxHeader();
print '<div class="error">'.$langs->trans('ExternalSiteModuleNotComplete').'</div>';
llxFooter();
}
$mainmenu=GETPOST('mainmenu', "aZ09");
$leftmenu=GETPOST('leftmenu', "aZ09");
$idmenu=GETPOST('idmenu', 'int');
$theme=GETPOST('theme', 'alpha');
$codelang=GETPOST('lang', 'aZ09');
print "
<html>
<head>
<title>Dolibarr frame for external web site</title>
</head>
<frameset ".(empty($conf->global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
<frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
<frame name=\"main\" src=\"".$conf->global->EXTERNALSITE_URL."\">
<noframes>
<body>
</body>
</noframes>
</frameset>
<noframes>
<body>
<br><div class=\"center\">
Sorry, your browser is too old or not correctly configured to view this area.<br>
Your browser must support frames.<br>
</div>
</body>
</noframes>
</html>
";
$keyforcontent = GETPOST('keyforcontent', 'aZ09');
/*
* View
*/
if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL))
{
llxHeader();
print '<div class="error">'.$langs->trans('ExternalSiteModuleNotComplete').'</div>';
llxFooter();
}
if (! empty($keyforcontent))
{
llxHeader();
print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight']-90).'px">';
if (! preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent))
{
$langs->load("errors");
print $langs->trans("Variablekeyforcontentmustbenamed", 'EXTERNAL_SITE_CONTENT_');
}
else if (empty($conf->global->$keyforcontent))
{
$langs->load("errors");
print $langs->trans("ErrorNoContentDefinedIntoVar", $keyforcontent);
}
else
{
print $conf->global->$keyforcontent;
}
print '<div>';
llxFooter();
}
else
{
if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL))
{
print "
<html>
<head>
<title>Dolibarr frame for external web site</title>
</head>
<frameset ".(empty($conf->global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
<frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
";
print '<frame name="main" src="';
print $conf->global->EXTERNALSITE_URL;
print '">';
print "
<noframes>
<body>
</body>
</noframes>
</frameset>
<noframes>
<body>
<br><div class=\"center\">
Sorry, your browser is too old or not correctly configured to view this area.<br>
Your browser must support frames.<br>
</div>
</body>
</noframes>
</html>
";
}
else
{
llxHeader();
print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight']-90).'px">';
print $conf->global->EXTERNALSITE_URL;
print '<div>';
llxFooter();
}
}

View File

@ -3206,6 +3206,20 @@ a.impayee:active { font-weight: bold; color: #550000; }
a.impayee:hover { font-weight: bold; color: #550000; }
/*
* External web site
*/
.framecontent {
width: 100%;
height: 100%;
}
.framecontent iframe {
width: 100%;
height: 100%;
}
/*
* Other

View File

@ -3265,6 +3265,16 @@ a.impayee:hover { font-weight: bold; color: #550000; }
/*
* External web site
*/
.framecontent iframe {
width: 100%;
height: 100%;
}
/*
* Other
*/