PHP Classes

File: lib/internal/compile.compile_custom_function.php

Recommend this page to a friend!
  Classes of David Tamas   g-template-php   lib/internal/compile.compile_custom_function.php   Download  
File: lib/internal/compile.compile_custom_function.php
Role: Example script
Content type: text/plain
Description: Example script
Class: g-template-php
Process and render templates generating PHP code
Author: By
Last change:
Date: 5 years ago
Size: 1,057 bytes
 

Contents

Class file image Download
<?php
/**
 * gTemplate Internal Function
 * Compiles the custom functions
 *
 * @package gTemplate
 * @subpackage internalFunctions
 */

function compile_compile_custom_function($function, $modifiers, $arguments, &$_result, &$gTpl) {
    if (
$function = $gTpl->_plugin_exists($function, "function")) {
       
$_args = $gTpl->_parse_arguments($arguments);
        foreach (
$_args as $key => $value) {
            if (
is_bool($value)) {
               
$value = $value ? 'true' : 'false';
            }
            if (
is_null($value)) {
               
$value = 'null';
            }
           
$_args[$key] = "'$key' => $value";
        }
       
$_result = '<?php echo ';
        if (!empty(
$modifiers)) {
           
$_result .= $gTpl->_parse_modifier($function . '(array(' . implode(',', (array) $_args) . '), $gTpl)', $modifiers) . '; ';
        } else {
           
$_result .= $function . '(array(' . implode(',', (array) $_args) . '), $gTpl);';
        }
       
$_result .= '?>';
        return
true;
    } else {
        return
false;
    }
}