@@ -89,7 +89,7 @@ |
||
| 89 | 89 | * |
| 90 | 90 | * @param string $sTemplate |
| 91 | 91 | * @param boolean $return |
| 92 | - * @return mixed |
|
| 92 | + * @return null|string |
|
| 93 | 93 | */ |
| 94 | 94 | public function display($sTemplate, $return = FALSE) { |
| 95 | 95 | // Start benchmark |
@@ -20,153 +20,153 @@ |
||
| 20 | 20 | * @uses the dwoo package from http://dwoo.org |
| 21 | 21 | */ |
| 22 | 22 | class Dwootemplate extends Dwoo_Core { |
| 23 | - protected $dwoo_data = array(); |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Constructor for the DwooTemplate engine |
|
| 27 | - * |
|
| 28 | - */ |
|
| 29 | - public function __construct() { |
|
| 30 | - // Call parents constructor |
|
| 31 | - parent::__construct(); |
|
| 32 | - |
|
| 33 | - // Set the config settings |
|
| 34 | - $this->initialize(); |
|
| 35 | - |
|
| 36 | - // Assign some defaults to dwoo |
|
| 37 | - $CI = get_instance(); |
|
| 38 | - $this->dwoo_data = new Dwoo_Data(); |
|
| 39 | - $this->dwoo_data->js_files = array(); |
|
| 40 | - $this->dwoo_data->css_files = array(); |
|
| 41 | - $this->dwoo_data->CI = $CI; |
|
| 42 | - $this->dwoo_data->site_url = $CI->config->site_url(); // so we can get the full path to CI easily |
|
| 43 | - $this->dwoo_data->uniqid = uniqid(); |
|
| 44 | - $this->dwoo_data->timestamp = mktime(); |
|
| 45 | - |
|
| 46 | - log_message('debug', "Dwoo Template Class Initialized"); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Assign data to dwoo data object |
|
| 52 | - * |
|
| 53 | - * @param string $key |
|
| 54 | - * @param mixed $value |
|
| 55 | - */ |
|
| 56 | - public function assign($key, $value) { |
|
| 57 | - $this->dwoo_data->$key = $value; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Add Javascript files to template |
|
| 63 | - * |
|
| 64 | - * @param string $js |
|
| 65 | - */ |
|
| 66 | - public function add_js($js) { |
|
| 67 | - $current = $this->dwoo_data->js_files; |
|
| 68 | - $current[] = $js; |
|
| 69 | - $this->dwoo_data->js_files = $current; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Add Css stylesheets to template |
|
| 75 | - * |
|
| 76 | - * @param string $css |
|
| 77 | - */ |
|
| 78 | - public function add_css($css) { |
|
| 79 | - $current = $this->dwoo_data->css_files; |
|
| 80 | - $current[] = $css; |
|
| 81 | - $this->dwoo_data->css_files = $current; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Display or return the compiled template |
|
| 87 | - * Since we assign the results to the standard CI output module |
|
| 88 | - * you can also use the helper from CI in your templates!! |
|
| 89 | - * |
|
| 90 | - * @param string $sTemplate |
|
| 91 | - * @param boolean $return |
|
| 92 | - * @return mixed |
|
| 93 | - */ |
|
| 94 | - public function display($sTemplate, $return = FALSE) { |
|
| 95 | - // Start benchmark |
|
| 96 | - $CI = get_instance(); |
|
| 97 | - $CI->benchmark->mark('dwoo_parse_start'); |
|
| 98 | - |
|
| 99 | - // Check if file exists |
|
| 100 | - if ( !file_exists($this->template_dir . $sTemplate ) ) { |
|
| 101 | - $message = sprintf('Template file \'%s\' not found.', $sTemplate); |
|
| 102 | - show_error($message); |
|
| 103 | - log_message('error', $message); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // Create new template |
|
| 107 | - $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate); |
|
| 108 | - |
|
| 109 | - // render the template |
|
| 110 | - $template = $this->get($tpl, $this->dwoo_data); |
|
| 111 | - |
|
| 112 | - // Finish benchmark |
|
| 113 | - $CI->benchmark->mark('dwoo_parse_end'); |
|
| 114 | - |
|
| 115 | - // Return results or not ? |
|
| 116 | - if ($return == FALSE) { |
|
| 117 | - $CI->output->final_output = $template; |
|
| 118 | - } else { |
|
| 119 | - return $template; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Toggle Codeigniter profiler on/off |
|
| 126 | - * |
|
| 127 | - */ |
|
| 128 | - public function enable_profiler($toggle = TRUE) { |
|
| 129 | - $CI = get_instance(); |
|
| 130 | - $CI->output->enable_profiler($toggle); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Set http header |
|
| 136 | - * |
|
| 137 | - * @example $this->output->set_header("HTTP/1.1 200 OK"); |
|
| 138 | - * @example $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); |
|
| 139 | - * @param string $header |
|
| 140 | - */ |
|
| 141 | - public function set_header($header) { |
|
| 142 | - $CI = get_instance(); |
|
| 143 | - $CI->output->set_header($header); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Set status header |
|
| 149 | - * |
|
| 150 | - * @example $this->output->set_status_header('401'); |
|
| 151 | - * @example // Sets the header as: Unauthorized |
|
| 152 | - * @param string $header |
|
| 153 | - */ |
|
| 154 | - public function set_status_header($header) { |
|
| 155 | - $CI = get_instance(); |
|
| 156 | - $CI->output->set_status_header($header); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Assign the dwootemplate config items to the instance |
|
| 162 | - * |
|
| 163 | - */ |
|
| 164 | - private function initialize() { |
|
| 165 | - $CI = get_instance(); |
|
| 166 | - $CI->config->load('dwootemplate', TRUE); |
|
| 167 | - $config = $CI->config->item('dwootemplate'); |
|
| 168 | - foreach ($config as $key => $val) { |
|
| 169 | - $this->$key = $val; |
|
| 170 | - } |
|
| 171 | - } |
|
| 23 | + protected $dwoo_data = array(); |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Constructor for the DwooTemplate engine |
|
| 27 | + * |
|
| 28 | + */ |
|
| 29 | + public function __construct() { |
|
| 30 | + // Call parents constructor |
|
| 31 | + parent::__construct(); |
|
| 32 | + |
|
| 33 | + // Set the config settings |
|
| 34 | + $this->initialize(); |
|
| 35 | + |
|
| 36 | + // Assign some defaults to dwoo |
|
| 37 | + $CI = get_instance(); |
|
| 38 | + $this->dwoo_data = new Dwoo_Data(); |
|
| 39 | + $this->dwoo_data->js_files = array(); |
|
| 40 | + $this->dwoo_data->css_files = array(); |
|
| 41 | + $this->dwoo_data->CI = $CI; |
|
| 42 | + $this->dwoo_data->site_url = $CI->config->site_url(); // so we can get the full path to CI easily |
|
| 43 | + $this->dwoo_data->uniqid = uniqid(); |
|
| 44 | + $this->dwoo_data->timestamp = mktime(); |
|
| 45 | + |
|
| 46 | + log_message('debug', "Dwoo Template Class Initialized"); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Assign data to dwoo data object |
|
| 52 | + * |
|
| 53 | + * @param string $key |
|
| 54 | + * @param mixed $value |
|
| 55 | + */ |
|
| 56 | + public function assign($key, $value) { |
|
| 57 | + $this->dwoo_data->$key = $value; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Add Javascript files to template |
|
| 63 | + * |
|
| 64 | + * @param string $js |
|
| 65 | + */ |
|
| 66 | + public function add_js($js) { |
|
| 67 | + $current = $this->dwoo_data->js_files; |
|
| 68 | + $current[] = $js; |
|
| 69 | + $this->dwoo_data->js_files = $current; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Add Css stylesheets to template |
|
| 75 | + * |
|
| 76 | + * @param string $css |
|
| 77 | + */ |
|
| 78 | + public function add_css($css) { |
|
| 79 | + $current = $this->dwoo_data->css_files; |
|
| 80 | + $current[] = $css; |
|
| 81 | + $this->dwoo_data->css_files = $current; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Display or return the compiled template |
|
| 87 | + * Since we assign the results to the standard CI output module |
|
| 88 | + * you can also use the helper from CI in your templates!! |
|
| 89 | + * |
|
| 90 | + * @param string $sTemplate |
|
| 91 | + * @param boolean $return |
|
| 92 | + * @return mixed |
|
| 93 | + */ |
|
| 94 | + public function display($sTemplate, $return = FALSE) { |
|
| 95 | + // Start benchmark |
|
| 96 | + $CI = get_instance(); |
|
| 97 | + $CI->benchmark->mark('dwoo_parse_start'); |
|
| 98 | + |
|
| 99 | + // Check if file exists |
|
| 100 | + if ( !file_exists($this->template_dir . $sTemplate ) ) { |
|
| 101 | + $message = sprintf('Template file \'%s\' not found.', $sTemplate); |
|
| 102 | + show_error($message); |
|
| 103 | + log_message('error', $message); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // Create new template |
|
| 107 | + $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate); |
|
| 108 | + |
|
| 109 | + // render the template |
|
| 110 | + $template = $this->get($tpl, $this->dwoo_data); |
|
| 111 | + |
|
| 112 | + // Finish benchmark |
|
| 113 | + $CI->benchmark->mark('dwoo_parse_end'); |
|
| 114 | + |
|
| 115 | + // Return results or not ? |
|
| 116 | + if ($return == FALSE) { |
|
| 117 | + $CI->output->final_output = $template; |
|
| 118 | + } else { |
|
| 119 | + return $template; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Toggle Codeigniter profiler on/off |
|
| 126 | + * |
|
| 127 | + */ |
|
| 128 | + public function enable_profiler($toggle = TRUE) { |
|
| 129 | + $CI = get_instance(); |
|
| 130 | + $CI->output->enable_profiler($toggle); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Set http header |
|
| 136 | + * |
|
| 137 | + * @example $this->output->set_header("HTTP/1.1 200 OK"); |
|
| 138 | + * @example $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT'); |
|
| 139 | + * @param string $header |
|
| 140 | + */ |
|
| 141 | + public function set_header($header) { |
|
| 142 | + $CI = get_instance(); |
|
| 143 | + $CI->output->set_header($header); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Set status header |
|
| 149 | + * |
|
| 150 | + * @example $this->output->set_status_header('401'); |
|
| 151 | + * @example // Sets the header as: Unauthorized |
|
| 152 | + * @param string $header |
|
| 153 | + */ |
|
| 154 | + public function set_status_header($header) { |
|
| 155 | + $CI = get_instance(); |
|
| 156 | + $CI->output->set_status_header($header); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Assign the dwootemplate config items to the instance |
|
| 162 | + * |
|
| 163 | + */ |
|
| 164 | + private function initialize() { |
|
| 165 | + $CI = get_instance(); |
|
| 166 | + $CI->config->load('dwootemplate', TRUE); |
|
| 167 | + $config = $CI->config->item('dwootemplate'); |
|
| 168 | + foreach ($config as $key => $val) { |
|
| 169 | + $this->$key = $val; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | 172 | } |
| 173 | 173 | \ No newline at end of file |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | /** |
| 29 | 29 | * Dwoo_Adapters_ZendFramework_PluginProxy's constructor. |
| 30 | 30 | * |
| 31 | - * @param Zend_View_Interface $view |
|
| 31 | + * @param Dwoo_Adapters_ZendFramework_View $view |
|
| 32 | 32 | */ |
| 33 | 33 | public function __construct(Zend_View_Interface $view) { |
| 34 | 34 | $this->view = $view; |
@@ -66,7 +66,6 @@ |
||
| 66 | 66 | * merges the given array(s) with the current data with array_merge |
| 67 | 67 | * |
| 68 | 68 | * @param array $data the array to merge |
| 69 | - * @param array $data2 $data3 ... other arrays to merge, optional, etc. |
|
| 70 | 69 | */ |
| 71 | 70 | public function mergeData(array $data) |
| 72 | 71 | { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * compiles the provided string down to php code |
| 26 | 26 | * |
| 27 | - * @param string $templateStr the template to compile |
|
| 27 | + * @param string $template the template to compile |
|
| 28 | 28 | * @return string a compiled php code string |
| 29 | 29 | */ |
| 30 | 30 | public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template); |
@@ -34,6 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @see Dwoo_Core::addPlugin |
| 36 | 36 | * @param array $customPlugins an array of custom plugins |
| 37 | + * @return void |
|
| 37 | 38 | */ |
| 38 | 39 | public function setCustomPlugins(array $customPlugins); |
| 39 | 40 | |
@@ -44,6 +45,7 @@ discard block |
||
| 44 | 45 | * set it on the Dwoo object as it will be passed onto the compiler automatically |
| 45 | 46 | * |
| 46 | 47 | * @param Dwoo_Security_Policy $policy the security policy object |
| 48 | + * @return void |
|
| 47 | 49 | */ |
| 48 | 50 | public function setSecurityPolicy(Dwoo_Security_Policy $policy = null); |
| 49 | 51 | } |
@@ -42,6 +42,9 @@ |
||
| 42 | 42 | |
| 43 | 43 | protected $corePluginDir; |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param string $cacheDir |
|
| 47 | + */ |
|
| 45 | 48 | public function __construct($cacheDir) |
| 46 | 49 | { |
| 47 | 50 | $this->corePluginDir = DWOO_DIRECTORY . 'plugins'; |
@@ -278,7 +278,7 @@ |
||
| 278 | 278 | * |
| 279 | 279 | * @param Dwoo_Core $dwoo the dwoo instance that requests it |
| 280 | 280 | * @param string $output the template output |
| 281 | - * @return mixed full path of the cached file or false upon failure |
|
| 281 | + * @return false|string full path of the cached file or false upon failure |
|
| 282 | 282 | */ |
| 283 | 283 | public function cache(Dwoo_Core $dwoo, $output) |
| 284 | 284 | { |
@@ -53,6 +53,10 @@ |
||
| 53 | 53 | return $output; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** |
|
| 57 | + * @param string $dynamicId |
|
| 58 | + * @param string $compiledFile |
|
| 59 | + */ |
|
| 56 | 60 | public static function unescape($output, $dynamicId, $compiledFile) |
| 57 | 61 | { |
| 58 | 62 | $output = preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/s', array('self', 'unescapePhp'), $output, -1, $count); |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Dwoowelcome extends Controller { |
| 4 | 4 | |
| 5 | - function __construct() |
|
| 6 | - { |
|
| 7 | - parent::Controller(); |
|
| 8 | - } |
|
| 5 | + function __construct() |
|
| 6 | + { |
|
| 7 | + parent::Controller(); |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - function index() |
|
| 11 | - { |
|
| 12 | - $this->load->library('Dwootemplate'); |
|
| 13 | - $this->dwootemplate->assign('itshowlate', date('H:i:s')); |
|
| 14 | - $this->dwootemplate->display('dwoowelcome.tpl'); |
|
| 15 | - } |
|
| 10 | + function index() |
|
| 11 | + { |
|
| 12 | + $this->load->library('Dwootemplate'); |
|
| 13 | + $this->dwootemplate->assign('itshowlate', date('H:i:s')); |
|
| 14 | + $this->dwootemplate->display('dwoowelcome.tpl'); |
|
| 15 | + } |
|
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | $this->_sv_compile_id = $controller->name; |
| 65 | 65 | |
| 66 | 66 | $this->_dwoo->sv_this = $this; |
| 67 | - $this->_dwoo->setSecurityPolicy(); |
|
| 67 | + $this->_dwoo->setSecurityPolicy(); |
|
| 68 | 68 | |
| 69 | 69 | return; |
| 70 | 70 | } |