mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Add option to control partial page rendering (layout drop)
XE 시절부터 layout=none 또는 isLayoutDrop=1 파라미터로 레이아웃이 없는 부분적인 페이지 렌더링을 허용하는 기능이 있었습니다. 관리자 화면에서 팝업이나 iframe을 표시하는 용도로도 사용하고, AJAX로 페이지 일부 내용만 새로고침할 때 불필요한 데이터를 주고받지 않도록 하는 데도 유용합니다. 그러나 사이트에 따라서는 레이아웃을 적용하지 않을 경우 민감한 정보가 노출되는 등의 부작용이 발생할 수도 있으므로, 이 기능을 사용하지 않도록 선택하는 옵션을 제공합니다.
This commit is contained in:
parent
e2753300ee
commit
e60ffb4e8d
7 changed files with 70 additions and 4 deletions
|
|
@ -47,7 +47,7 @@ class HTMLDisplayHandler
|
|||
* @param ModuleObject $oModule the module object
|
||||
* @return string compiled template string
|
||||
*/
|
||||
function toDoc(&$oModule)
|
||||
public function toDoc(&$oModule)
|
||||
{
|
||||
$oTemplate = TemplateHandler::getInstance();
|
||||
|
||||
|
|
@ -112,7 +112,13 @@ class HTMLDisplayHandler
|
|||
$output = '<div class="x">' . $output . '</div>';
|
||||
}
|
||||
|
||||
if(Context::get('layout') != 'none')
|
||||
// Wrap content in layout
|
||||
$use_layout = Context::get('layout') !== 'none';
|
||||
if (!$use_layout && isset($_REQUEST['layout']) && !self::isPartialPageRendering())
|
||||
{
|
||||
$use_layout = true;
|
||||
}
|
||||
if ($use_layout)
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
|
|
@ -192,12 +198,42 @@ class HTMLDisplayHandler
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if partial page rendering (dropping the layout) is enabled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPartialPageRendering()
|
||||
{
|
||||
$ppr = config('view.partial_page_rendering') ?? 'internal_only';
|
||||
if ($ppr === 'disabled')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($ppr === 'ajax_only' && empty($_SERVER['HTTP_X_REQUESTED_WITH']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($ppr === 'internal_only' && (!isset($_SERVER['HTTP_REFERER']) || !Rhymix\Framework\URL::isInternalURL($_SERVER['HTTP_REFERER'])))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($ppr === 'except_robots' && isCrawler())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* when display mode is HTML, prepare code before print.
|
||||
* @param string $output compiled template string
|
||||
* @return void
|
||||
*/
|
||||
function prepareToPrint(&$output)
|
||||
public function prepareToPrint(&$output)
|
||||
{
|
||||
if(Context::getResponseMethod() != 'HTML')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1205,7 +1205,7 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
$oModule->setLayoutFile('popup_layout');
|
||||
}
|
||||
else
|
||||
elseif (HTMLDisplayHandler::isPartialPageRendering())
|
||||
{
|
||||
$oModule->setLayoutPath('common/tpl');
|
||||
$oModule->setLayoutFile('default_layout');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue