1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Isse #2308 Remove the need for the BODYTAG constant.

This commit is contained in:
Cameron 2019-06-21 14:09:10 -07:00
parent 8ffe5f4fca
commit 1cb3f934ea
3 changed files with 50 additions and 12 deletions

View File

@ -68,7 +68,12 @@ if (varset($e107_popup) != 1)
// //
if(!deftrue('e_IFRAME')) if(!deftrue('e_IFRAME'))
{ {
parseheader($FOOTER);
$psc = array(
'</body>' => '',
);
parseheader($FOOTER, $psc);
} }
$eTimingStop = microtime(); $eTimingStop = microtime();

View File

@ -81,18 +81,22 @@ $js_body_onload = array(); // Legacy array of code to load with page.
if (!function_exists("parseheader")) if (!function_exists("parseheader"))
{ {
function parseheader($LAYOUT) function parseheader($LAYOUT, $opts=array())
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$tmp = explode("\n", $LAYOUT); $tmp = explode("\n", $LAYOUT);
$sc = e107::getScBatch('_theme_'); $sc = e107::getScBatch('_theme_');
$search = array_keys($opts);
$replace = array_values($opts);
foreach ($tmp as $line) foreach ($tmp as $line)
{ {
$line = str_replace($search, $replace, $line); // Quick-fix allow for use of {THEME} shortcode.
if (preg_match("/{.+?}/", $line)) if (preg_match("/{.+?}/", $line))
{ {
$line = str_replace('{THEME}',THEME_ABS, $line); // Quick-fix allow for use of {THEME} shortcode.
echo $tp->parseTemplate($line, true, $sc)."\n"; // retain line-breaks. echo $tp->parseTemplate($line, true, $sc)."\n"; // retain line-breaks.
} }
else else
@ -623,11 +627,12 @@ echo "</head>\n";
$def = THEME_LAYOUT; // The active layout based on custompage matches. $def = THEME_LAYOUT; // The active layout based on custompage matches.
$noBody = false;
// v2.2.2 --- Experimental -- // v2.2.2 --- Experimental --
if($tmp = e_theme::loadLayout(THEME_LAYOUT)) if($tmp = e_theme::loadLayout(THEME_LAYOUT))
{ {
$LAYOUT = $tmp; $LAYOUT = $tmp;
$noBody = true;
unset($tmp); unset($tmp);
} }
@ -699,9 +704,11 @@ echo "</head>\n";
//$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' "; //$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' ";
if($noBody === true) // New in v2.2.2 - remove need for BODYTAG.
{
if(!deftrue('BODYTAG')) //TODO Discuss a better way? echo "\n<!-- Start theme.html -->\n";
}
elseif(!deftrue('BODYTAG')) //TODO Discuss a better way?
{ {
$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' "; $body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' ";
echo "<body".$body_onload.">\n"; echo "<body".$body_onload.">\n";
@ -746,7 +753,10 @@ if(deftrue('BOOTSTRAP'))
} }
echo $LAYOUT['_modal_']; if($noBody === false)
{
echo $LAYOUT['_modal_'];
}
} }
@ -787,13 +797,21 @@ if ($e107_popup != 1) {
$HEADER = preg_replace('#(src|href)=("|\')([^:\'"]*)("|\')#','$1=$2'.THEME.'$3$4', $HEADER); $HEADER = preg_replace('#(src|href)=("|\')([^:\'"]*)("|\')#','$1=$2'.THEME.'$3$4', $HEADER);
$FOOTER = preg_replace('#(src|href)=("|\')([^:\'"]*)("|\')#','$1=$2'.THEME.'$3$4', $FOOTER); $FOOTER = preg_replace('#(src|href)=("|\')([^:\'"]*)("|\')#','$1=$2'.THEME.'$3$4', $FOOTER);
} }
$psc = array(
'{THEME}' => THEME_ABS,
'{BODY_ONLOAD}' => $body_onload,
'{LAYOUT_ID}' => 'layout-'.e107::getForm()->name2id(THEME_LAYOUT),
'{---MODAL---}' => $LAYOUT['_modal_'],
);
parseheader($HEADER); parseheader($HEADER, $psc);
// echo $HEADER; // echo $HEADER;
} }
unset($def); unset($def, $noBody, $psc);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -1345,7 +1345,7 @@ class e_menuManager {
echo $rs->form_close(); echo $rs->form_close();
echo "</div>"; echo "</div>";
$FOOTER = str_replace('</body>','', $FOOTER);
$this->parseheader($FOOTER); $this->parseheader($FOOTER);
if($this->debug) if($this->debug)
@ -1402,11 +1402,20 @@ class e_menuManager {
{ {
// $tmp = explode("\n", $LAYOUT); // $tmp = explode("\n", $LAYOUT);
if(strpos($LAYOUT,'<body ') !== false) // FIXME Find a way to remove the <body> tag from the admin header when menu-manager is active.
{
$LAYOUT = preg_replace('/<body[^>]*>/','', $LAYOUT);
}
// Split up using the same function as the shortcode handler // Split up using the same function as the shortcode handler
$tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $tmp = preg_split('#(\{\S[^\x02]*?\S\})#', $LAYOUT, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$str = array(); $str = array();
for($c = 0; $c < count($tmp); $c++) for($c = 0; $c < count($tmp); $c++)
{ {
if(preg_match("/[\{|\}]/", $tmp[$c])) if(preg_match("/[\{|\}]/", $tmp[$c]))
{ {
if($check) if($check)
@ -1501,6 +1510,12 @@ class e_menuManager {
// $tp->parseTemplate("{NAVIGATION".$cust."}",true); // $tp->parseTemplate("{NAVIGATION".$cust."}",true);
// echo "<span class='label label-info'>Navigation Area</span>"; // echo "<span class='label label-info'>Navigation Area</span>";
// } // }
elseif(strstr($str, '{---MODAL---}'))
{
echo "\n<!-- Modal would appear here --> \n";
//echo '<div id="uiAlert" class="notifications center"><!-- empty --></div>';
//echo getAlert();
}
elseif(strstr($str, "ALERT")) elseif(strstr($str, "ALERT"))
{ {
//echo "[Navigation Area]"; //echo "[Navigation Area]";