source: branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/url.php @ 755

Last change on this file since 755 was 755, checked in by ramonb, 11 years ago
  • add Dwoo
File size: 1.7 KB
Line 
1<?php
2
3/**
4 * <strong>Agavi specific plugin</strong>
5 *
6 * uses AgaviRouting to create an url
7 *
8 * <pre>
9 *  * route : the route name, optional (by default the current url is returned)
10 *  * params : an array with variables to build the route, optional
11 *  * options : an array of options to pass to the routing object, optional
12 *  * rest : for convenience, you can just pass named parameters that will be used as
13 *           the params array, but you must not provide the params array in this case
14 * </pre>
15 *
16 * Examples:
17 * <code>
18 * {a url("route.name" array(param="Value", param2=$otherVal))}Here is a link{/a}
19 * <form action="{url}"> {* without any parameter it just returns the current url *}
20 * </code>
21 *
22 * This software is provided 'as-is', without any express or implied warranty.
23 * In no event will the authors be held liable for any damages arising from the use of this software.
24 *
25 * @author     Jordi Boggiano <j.boggiano@seld.be>
26 * @copyright  Copyright (c) 2008, Jordi Boggiano
27 * @license    http://dwoo.org/LICENSE   Modified BSD License
28 * @link       http://dwoo.org/
29 * @version    1.0.0
30 * @date       2008-10-23
31 * @package    Dwoo
32 */
33function Dwoo_Plugin_url_compile(Dwoo_Compiler $compiler, $route = null, $params = null, $options = null, array $rest = array())
34{
35        if ($params == 'null') {
36                if (count($rest)) {
37                        $params = array();
38                        foreach ($rest as $k=>$v) {
39                                if (is_numeric($k)) {
40                                        $params[] = $k.'=>'.$v;
41                                } else {
42                                        $params[] = '"'.$k.'"=>'.$v;
43                                }
44                        }
45                        $params = 'array('.implode(', ', $params).')';
46                } else {
47                        $params = 'array()';
48                }
49        }
50        if ($options == 'null') {
51                $options = 'array()';
52        }
53        return '$this->data[\'ro\']->gen('.$route.', '.$params.', '.$options.')';
54}
Note: See TracBrowser for help on using the repository browser.