| 107 | | } |
| 108 | | |
| 109 | | class NOT_Core_View { |
| 110 | | |
| 111 | | var $load = ''; |
| 112 | | var $data = array(); |
| 113 | | var $template = 'template'; |
| 114 | | |
| 115 | | /** |
| 116 | | * Constructor |
| 117 | | */ |
| 118 | | function Core_View() |
| 119 | | { |
| 120 | | $CORE =& get_instance(); |
| 121 | | $this->load =& $CORE->load; |
| 122 | | } |
| 123 | | |
| 124 | | /** |
| 125 | | * Get Variable |
| 126 | | * |
| 127 | | * @access public |
| 128 | | * @return string |
| 129 | | */ |
| 130 | | function get($key) |
| 131 | | { |
| 132 | | return (isset($this->data[$key]) ? $this->data[$key] : ''); |
| 133 | | } |
| 134 | | |
| 135 | | /** |
| 136 | | * Set Variable(s) |
| 137 | | * |
| 138 | | * @access public |
| 139 | | * @param mixed |
| 140 | | * @param mixed |
| 141 | | * @return void |
| 142 | | */ |
| 143 | | function set($key, $data = FALSE) |
| 144 | | { |
| 145 | | if (is_array($key)) |
| 146 | | { |
| 147 | | $this->data = array_merge($this->data, $key); |
| 148 | | } |
| 149 | | else |
| 150 | | { |
| 151 | | $this->data[$key] = $data; |
| 152 | | } |
| 153 | | } |
| 154 | | |
| 155 | | /** |
| 156 | | * Add to a Variable(s) |
| 157 | | * |
| 158 | | * @access public |
| 159 | | * @param string |
| 160 | | * @param string |
| 161 | | * @return void |
| 162 | | */ |
| 163 | | function add($key, $data) |
| 164 | | { |
| 165 | | if (! is_string($key) OR ! is_string($data)) |
| 166 | | return; |
| 167 | | |
| 168 | | if (isset($this->data[$key])) |
| 169 | | { |
| 170 | | $this->data[$key] .= $data; |
| 171 | | } |
| 172 | | else |
| 173 | | { |
| 174 | | $this->set($key, $data); |
| 175 | | } |
| 176 | | } |
| 177 | | |
| 178 | | /** |
| 179 | | * Delete Variables |
| 180 | | * |
| 181 | | * @access public |
| 182 | | * @param string |
| 183 | | * @return void |
| 184 | | */ |
| 185 | | function del($key) |
| 186 | | { |
| 187 | | if (isset($this->data[$key])) |
| 188 | | { |
| 189 | | unset($this->data[$key]); |
| 190 | | } |
| 191 | | } |
| 192 | | |
| 193 | | /** |
| 194 | | * Load a View |
| 195 | | * |
| 196 | | * Loads a template for inclusion into the template, or displays the template |
| 197 | | * |
| 198 | | * EXAMPLES: |
| 199 | | * Load the "blog_content" view into the "body" variable: |
| 200 | | * load('blog_content', 'body') |
| 201 | | * Load the "blog_content" view into the "blog_content" variable: |
| 202 | | * load('blog_content', TRUE) |
| 203 | | * Load the currently set template and return it as a string: |
| 204 | | * load(TRUE) |
| 205 | | * Load the current template and display it: |
| 206 | | * load() |
| 207 | | * |
| 208 | | * @access public |
| 209 | | * @param string |
| 210 | | * @param string |
| 211 | | * @return void |
| 212 | | */ |
| 213 | | function load($view = FALSE, $partial = FALSE) |
| 214 | | { |
| 215 | | if ($view == FALSE) |
| 216 | | { |
| 217 | | $view = $this->template; |
| 218 | | } |
| 219 | | elseif ($view === TRUE) |
| 220 | | { |
| 221 | | return $this->load->view($this->template, $this->data, TRUE); |
| 222 | | } |
| 223 | | |
| 224 | | if ($partial != FALSE) |
| 225 | | { |
| 226 | | $key = ($partial === TRUE) ? $view : $partial; |
| 227 | | $this->data[$key] = $this->load->view($view, $this->data, TRUE); |
| 228 | | |
| 229 | | return $this->data[$key]; |
| 230 | | } |
| 231 | | else |
| 232 | | { |
| 233 | | $this->load->view($view, $this->data); |
| 234 | | } |
| 235 | | } |