Ejemplo n.º 1
0
<?php

class Path_PXHTMLTales extends PXHTMLTales_Expr
{
    public function getMatchString()
    {
        return 'path';
    }
    public function handleMatch($segment)
    {
        $segment = 'PXHTMLTemplate::ctx()->resolve("' . $segment . '")';
        return $segment;
    }
}
PXHTML::registerTales('path', 'Path_PXHTMLTales');
Ejemplo n.º 2
0
<?php

class String_PXHTMLTales extends PXHTMLTales_Expr
{
    public function getMatchString()
    {
        return 'string';
    }
    public function handleMatch($segment)
    {
        // convert $$ to a marker
        $segment = $this->escapeDollarSigns($segment);
        // anything that is $stuff to a whitespace is a path
        // we'll also pick up ${path} by removing the { and } on the outside
        // of a path statement
        $segment = preg_replace('/\\$\\{(.*?)\\}/', '".PXHTMLTemplate::ctx()->resolve("$1")."', $segment);
        $segment = preg_replace('/\\$([a-zA-Z0-9_\\-\\/]+)\\s*/', '".PXHTMLTemplate::ctx()->resolve("$1")."', $segment);
        $segment = $this->unescapeDollarSigns($segment);
        return '"' . $segment . '"';
    }
}
PXHTML::registerTales('string', 'String_PXHTMLTales');
Ejemplo n.º 3
0
<?php

class PHP_PXHTMLTales extends PXHTMLTales_Expr
{
    public function getMatchString()
    {
        return 'php';
    }
    public function handleMatch($segment)
    {
        // convert $$ to a marker
        $segment = $this->escapeDollarSigns($segment);
        // anything that is $stuff to a whitespace is a path
        // we'll also pick up ${path} by removing the { and } on the outside
        // of a path statement
        $segment = preg_replace('/\\$\\{(.*?)\\}/', '$$1', $segment);
        $segment = preg_replace('/\\$([a-zA-Z0-9_\\-\\/]+)\\s*/', 'PXHTMLTemplate::ctx()->resolve("$1")', $segment);
        // return the $$ to $, which is a PHP var
        $segment = $this->unescapeDollarSigns($segment);
        $segment = str_replace('$$', '$', $segment);
        return $segment;
    }
}
PXHTML::registerTales('php', 'PHP_PXHTMLTales');
Ejemplo n.º 4
0
        $substitutions = array();
        foreach ($params_list as $param) {
            list($key, $value) = explode('=', $param);
            $key = trim($key);
            $value = trim($value);
            preg_match_all('/\\$\\{([a-zA-Z0-9_\\-\\/]+?)\\}\\s*/', $value, $matches);
            if ($matches[1]) {
                foreach ($matches[1] as $match) {
                    $value = str_replace('${' . $match . '}', '___CTX' . count($substitutions) . '___', $value);
                    array_push($substitutions, $match);
                }
            }
            $params[$key] = $value;
        }
        // generate the URL
        $url = chip('#Chippino/Router/GenerateURL')->with(array('alias' => $controller, 'params' => $params));
        $url = '"' . $url . '"';
        // sub back in all runtime resolutions
        preg_match_all('/(___CTX.*?___)/', $url, $matches);
        if (isset($matches[1])) {
            foreach ($matches[1] as $match) {
                $idx = trim($match, '_');
                $idx = str_replace('CTX', '', $idx);
                $url = str_replace($match, '".urlencode(PXHTMLTemplate::ctx()->resolve("' . $substitutions[$idx] . '"))."', $url);
            }
        }
        return $url;
    }
}
PXHTML::registerTales('url', 'Url_PXHTMLTales');