Permalink
Browse files

New - $modx->atBindInclude()

@include: php file path
in template edit
テンプレート編集画面の一行目に記述
  • Loading branch information...
yama committed May 8, 2016
1 parent b03b63c commit c4005bb0401d06ce3739d013d915e32e08ad0f56
Showing with 45 additions and 0 deletions.
  1. +7 −0 manager/includes/document.parser.class.inc.php
  2. +38 −0 manager/includes/extenders/ex_subparser.php
@@ -113,6 +113,7 @@ function __call($method_name, $arguments)
case 'addLog':
case 'atBindFile':
case 'atBindUrl':
case 'atBindInclude':
case 'changeWebUserPassword':
case 'checkPermissions':
case 'clearCache':
@@ -510,6 +511,9 @@ function prepareResponse()
$template->content = $this->atBindFile($template->content);
elseif(substr($template->content,0,4)==='@URL')
$template->content = $this->atBindUrl($template->content);
elseif(substr($template->content,0,8)==='@INCLUDE')
$template->content = $this->atBindInclude($template->content);
if($template->id)
{
@@ -530,6 +534,9 @@ function prepareResponse()
$parent->content = $this->atBindFile($parent->content);
elseif(substr($parent->content,0,4)==='@URL')
$parent->content = $this->atBindUrl($parent->content);
elseif(substr($parent->content,0,8)==='@INCLUDE')
$parent->content = $this->atBindInclude($parent->content);
if(strpos($parent->content,'[*content*]')!==false)
$template->content = str_replace('[*content*]', $template->content, $parent->content);
elseif(strpos($parent->content,'[*#content*]')!==false)
@@ -1896,6 +1896,44 @@ function atBindUrl($str='')
return $content;
}
function atBindInclude($str='')
{
global $modx;
if(strpos($str,'@INCLUDE')!==0) return $str;
if(strpos($str,"\n")!==false)
$str = substr($str,0,strpos("\n",$str));
$str = substr($str,9);
$str = trim($str);
$str = str_replace('\\','/',$str);
if(substr($str,0,1)==='/')
{
if(is_file($str) && MODX_MANAGER_PATH===substr($str,0,strlen(MODX_MANAGER_PATH)))
$file_path = false;
elseif(is_file($str) && MODX_BASE_PATH===substr($str,0,strlen(MODX_BASE_PATH)))
$file_path = $str;
elseif(MODX_BASE_PATH . trim($file_path,'/'))
$file_path = MODX_BASE_PATH . trim($file_path,'/');
else $file_path = false;
}
elseif(is_file(MODX_BASE_PATH . $str))
$file_path = MODX_BASE_PATH . $str;
elseif(is_file(MODX_BASE_PATH . "assets/templates/{$str}"))
$file_path = MODX_BASE_PATH . "assets/templates/{$str}";
else
$file_path = false;
if(!$file_path) return false;
ob_start();
$result = include($file_path);
$content = ob_get_clean();
if(!$content && $result) $content = $result;
return $content;
}
function setOption($key, $value='')
{
$this->config[$key] = $value;

0 comments on commit c4005bb

Please sign in to comment.