<?php
// Flexy template settings, include with Flexy Renderer only
define('SGL_FLEXY_FORCE_COMPILE', 0);
define('SGL_FLEXY_DEBUG', 0);
define('SGL_FLEXY_FILTERS', 'SimpleTags');
define('SGL_FLEXY_ALLOW_PHP', true);
define('SGL_FLEXY_LOCALE', 'en');
define('SGL_FLEXY_COMPILER', 'Flexy');
define('SGL_FLEXY_VALID_FNS', 'include');
define('SGL_FLEXY_GLOBAL_FNS', true);
define('SGL_FLEXY_IGNORE', 0); // don't parse forms when set to true
class SGL_HtmlRenderer_FlexyStrategy extends SGL_OutputRendererStrategy
{
/**
* Director for html Flexy renderer.
*
* @param SGL_View $view
* @return string rendered html output
*/
public function render(/*SGL_View*/ &$view)
{
// suppress error notices in templates
SGL::setNoticeBehaviour(SGL_NOTICES_DISABLED);
// prepare flexy object
require_once 'HTML/Template/Flexy.php';
$flexy = $this->initEngine($view->data);
$masterTemplate = isset($view->data->masterTemplate)
? $view->data->masterTemplate
: $view->data->manager->masterTemplate;
$ok = $flexy->compile($masterTemplate);
// if some Flexy 'elements' exist in the output object, send them as
// 2nd arg to Flexy::bufferedOutputObject()
$elements = ( isset($view->data->flexyElements)
&& is_array($view->data->flexyElements))
? $view->data->flexyElements
: array();
$data = $flexy->bufferedOutputObject($view->data, $elements);
///RVS Start replace path customtemplate
if (isset($view->data->theme)) {
if (is_file(SGL_THEME_DIR . '/' . $view->data->theme . '/default/customtemplate' . '/' . $masterTemplate)) {
$data = $this->replaceUrlPath($data);
}
}
///RVS End load replace path customtemplate
SGL::setNoticeBehaviour(SGL_NOTICES_ENABLED);
return $data;
}
/**
* Replace Url Path - Replace URL seagull
*
* @author Puttipong <puttipong@rvglobalsoft.com>
* @param String $strCompileFlexy - String compile flexy
* @return String replace url seagull complete.
*/
function replaceUrlPath($strCompileFlexy)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);
$strScrDoc = preg_replace('/src="\/rvsitebuilder\/www\/project(.*?)(\/documents)/', 'src="' . SGL_BASE_URL . '/documents', $strCompileFlexy);
$strScrLib = preg_replace('/src="\/rvsitebuilder\/www(\/rvs_library)/', 'src="' . SGL_BASE_URL . '/rvs_library', $strScrDoc);
$strHrefDoc = preg_replace('/href="\/rvsitebuilder\/www\/project(.*?)(\/documents)/', 'href="' . SGL_BASE_URL . '/documents', $strScrLib);
$strHrefLib = preg_replace('/href="\/rvsitebuilder\/www(\/rvs_library)/', 'href="' . SGL_BASE_URL . '/rvs_library', $strHrefDoc);
return $strHrefLib;
}
/**
* Initialise Flexy options.
*
* @param SGL_Output $data
* @return boolean
*
* @todo move flexy constants to this class def
*/
public function initEngine(&$data)
{
// initialise template engine
$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
if (!isset($data->theme)) {
$data->theme = 'default';
}
///RVS Start load customtemplate
$pathCustom = (is_dir(SGL_THEME_DIR . '/' . $data->theme . '/default/customtemplate'))
? SGL_THEME_DIR . '/' . $data->theme . '/default/customtemplate' . PATH_SEPARATOR
: '';
///RVS End load customtemplate
$options = array(
///RVS add customtemplate
'templateDir' => $pathCustom .
//'/home/duangdao/public_html/momo' . PATH_SEPARATOR .
SGL_WEB_ROOT . PATH_SEPARATOR .
//'/home/duangdao/public_html' . PATH_SEPARATOR .
dirname(SGL_WEB_ROOT) . PATH_SEPARATOR .
// the current module's templates dir from the custom theme
SGL_THEME_DIR . '/' . $data->theme . '/' . $data->moduleName . PATH_SEPARATOR .
// the default template dir from the custom theme
SGL_THEME_DIR . '/' . $data->theme . '/default'. PATH_SEPARATOR .
// the current module's templates dir from the default theme
SGL_MOD_DIR . '/'. $data->moduleName . '/templates' . PATH_SEPARATOR .
// the configured default module's templates dir
SGL_MOD_DIR . '/'. SGL_Config::get('site.defaultModule') . '/templates' . PATH_SEPARATOR .
// the default template dir from the default theme
SGL_MOD_DIR . '/default/templates',
'templateDirOrder' => 'reverse',
'multiSource' => true,
'compileDir' => SGL_CACHE_DIR . '/tmpl/' . $data->theme,
'forceCompile' => SGL_FLEXY_FORCE_COMPILE,
'debug' => SGL_FLEXY_DEBUG,
'allowPHP' => SGL_FLEXY_ALLOW_PHP,
'filters' => SGL_FLEXY_FILTERS,
'locale' => SGL_FLEXY_LOCALE,
'compiler' => SGL_FLEXY_COMPILER,
'valid_functions' => SGL_FLEXY_VALID_FNS,
'flexyIgnore' => SGL_FLEXY_IGNORE,
'globals' => true,
'globalfunctions' => SGL_FLEXY_GLOBAL_FNS,
);
$ok = $this->setupPlugins($data, $options);
$flexy = new HTML_Template_Flexy($options);
///fix PHP 5.3
$flexy = &$flexy;
return $flexy;
}
/**
* Setup Flexy plugins if specified.
*
* @param SGL_Output $data
* @param array $options
* @return boolean
*/
public function setupPlugins(&$data, &$options)
{
// Configure Flexy to use SGL ModuleOutput Plugin
// If an Output.php file exists in module's dir
$customOutput = SGL_MOD_DIR . '/' . $data->moduleName . '/classes/Output.php';
if (is_readable($customOutput)) {
$className = ucfirst($data->moduleName) . 'Output';
if (isset($options['plugins'])) {
$options['plugins'] = $options['plugins'] + array($className => $customOutput);
} else {
$options['plugins'] = array($className => $customOutput);
}
}
return true;
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez