Beispiel #1
0
/**
 * compiled function plugin :  display a constant. Not available in untrusted templates.
 *
 * <pre>{const 'foo'}</pre>
 *
 * @param \Jelix\Castor\CompilerCore $compiler the template compiler
 * @param array $param   0=>$string the constant name
 *
 * @return string the php code corresponding to the function content
 */
function jtpl_cfunction_text_const(\Jelix\Castor\CompilerCore $compiler, $param = array())
{
    if (!$compiler->trusted) {
        $compiler->doError1('errors.tplplugin.untrusted.not.available', 'const');
        return '';
    }
    if (count($param) == 1) {
        return 'echo constant(' . $param[0] . ');';
    } else {
        $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number', 'const', '1');
        return '';
    }
}
Beispiel #2
0
/**
 * function plugin :  include a template into another template.
 *
 * <pre>{include 'myModule~foo'}</pre>
 *
 * @param \Jelix\Castor\CompilerCore $compiler the template compiler
 * @param array $param   0=>$string the template selector (string)
 *
 * @return string the php code corresponding to the function content
 */
function jtpl_cfunction_common_include(\Jelix\Castor\CompilerCore $compiler, $param = array())
{
    if (!$compiler->trusted) {
        $compiler->doError1('errors.tplplugin.untrusted.not.available', 'include');
        return '';
    }
    if (count($param) == 1) {
        $compiler->addMetaContent('$t->meta(' . $param[0] . ');');
        return '$t->display(' . $param[0] . ');';
    } else {
        $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number', 'include', '1');
        return '';
    }
}