ElementNode::_renderArrayValue PHP Метод

_renderArrayValue() приватный Метод

This method concatenates all the parts using $separtor as glue. If the context is 'txt' and at least one part is php, the returned string will be encapsuled inside If the context is 'php' the string returned will be a valid php code.
private _renderArrayValue ( $parts, $separator = ' ', $context = 'txt' )
$context The context into which the value will be inserted. Can be 'txt' (default) or 'php'
    private function _renderArrayValue($parts, $separator = ' ', $context = 'txt')
    {
        $hasPhp = false;
        $values = array();
        foreach ($parts as $p) {
            if ($p['t'] == 'php') {
                $hasPhp = true;
                $values[] = $p['v'];
            } else {
                $values[] = "'{$p['v']}'";
            }
        }
        if (!$hasPhp) {
            $quote = '';
            if ('php' == $context) {
                $quote = "'";
            }
            $value = '';
            foreach ($parts as $p) {
                $value .= "{$separator}{$p['v']}";
            }
            return $quote . trim($value, $separator) . $quote;
        } else {
            $value = join(".", $values);
            $value = str_replace("'.'", $separator, $value);
            $value = str_replace(".'", ".'{$separator}", $value);
            $value = str_replace("'.", "{$separator}'.", $value);
            if ('txt' == $context) {
                return '<?php echo ' . $value . '; ?>';
            }
            return $value;
        }
    }