2 // Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
11 * This is a wrapper for implode function, which calls each function in the
12 * array $funcs on each piece in the array $pieces
14 * @param <type> $pieces
15 * @param <type> $funcs
17 function implode_funcs($glue, array $pieces, array $funcs)
19 $new_pieces = array();
20 foreach ($pieces as $piece) {
22 foreach ($funcs as $func) {
23 $new_piece = $func( $new_piece );
26 $new_pieces []= $new_piece;
29 return implode($glue, $new_pieces);
33 * * xxx todo: sanitize inputs
35 * @param <type> $default
38 function _get($var, $default = '')
41 return isset($val) && $val != '' ?
$val : $default;
45 * xxx todo: sanitize inputs
47 * @param <type> $default
50 function _post($var, $default = '')
53 return isset($val) && $val != '' ?
$val : $default;
58 return $GLOBALS['webroot'] . '/interface/super/rules';
63 return $GLOBALS['srcdir'];
68 return dirname(__FILE__
) . "/../";
71 function library_dir()
73 return base_dir() . '/library';
76 function library_src($file)
78 return library_dir() . "/$file";
81 function js_src($file)
83 echo _base_url() . '/www/js/' . $file;
86 function css_src($file)
88 echo _base_url() . '/www/css/' . $file;
91 function controller_basedir()
93 return realpath(base_dir() . '/controllers/');
95 function controller_dir($controller)
97 $dir = controller_basedir() . '/'. $controller;
98 if (realpath($dir . '/../') != controller_basedir()) {
99 throw Exception("Invalid controller '$controller'");