@@ -35,219 +35,219 @@ |
||
| 35 | 35 | |
| 36 | 36 | class MetaCollection implements MetaInterface { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Stores the meta values the user has set. |
|
| 40 | - * |
|
| 41 | - * @var array |
|
| 42 | - */ |
|
| 43 | - protected $meta = []; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Stores the standard meta-value names |
|
| 47 | - * Mostly here for reference, I guess. |
|
| 48 | - * |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - protected $std_meta = [ |
|
| 52 | - 'application-name', |
|
| 53 | - 'author', |
|
| 54 | - 'copyright', |
|
| 55 | - 'description', |
|
| 56 | - 'generator', |
|
| 57 | - 'keywords', |
|
| 58 | - 'robots', |
|
| 59 | - 'googlebot' |
|
| 60 | - ]; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Stores the HTTP-Equiv meta tags |
|
| 64 | - * since they need to be rendered differently. |
|
| 65 | - * |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 68 | - protected $http_equiv_meta = [ |
|
| 69 | - 'cache-control', |
|
| 70 | - 'content-language', |
|
| 71 | - 'content-type', |
|
| 72 | - 'default-style', |
|
| 73 | - 'expires', |
|
| 74 | - 'pragma', |
|
| 75 | - 'refresh', |
|
| 76 | - 'set-cookie' |
|
| 77 | - ]; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Stores the document's character encoding. |
|
| 81 | - * |
|
| 82 | - * @var string |
|
| 83 | - */ |
|
| 84 | - public $charset = 'utf-8'; |
|
| 85 | - |
|
| 86 | - //-------------------------------------------------------------------- |
|
| 87 | - |
|
| 88 | - public function __construct($ci) |
|
| 89 | - { |
|
| 90 | - $ci->config->load('html_meta', true); |
|
| 91 | - |
|
| 92 | - $config = $ci->config->item('html_meta'); |
|
| 93 | - |
|
| 94 | - $this->meta = $config['meta']; |
|
| 95 | - |
|
| 96 | - $this->http_equiv_meta = array_merge($this->http_equiv_meta, $config['http-equiv']); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - //-------------------------------------------------------------------- |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Sets a single meta item. |
|
| 104 | - * $alias can also be an array of key/value pairs to set. |
|
| 105 | - * |
|
| 106 | - * @param string|array $alias |
|
| 107 | - * @param null $value |
|
| 108 | - * |
|
| 109 | - * @return mixed |
|
| 110 | - */ |
|
| 111 | - public function set($alias, $value=null, $escape=true) |
|
| 112 | - { |
|
| 113 | - if (is_array($alias)) |
|
| 114 | - { |
|
| 115 | - foreach ($alias as $key => $val) |
|
| 116 | - { |
|
| 117 | - $this->set($key, $val); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return $this; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Charset |
|
| 124 | - if (strtolower($alias) == 'charset') |
|
| 125 | - { |
|
| 126 | - $this->charset = $value; |
|
| 127 | - |
|
| 128 | - return $this; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
| 132 | - |
|
| 133 | - return $this; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - //-------------------------------------------------------------------- |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Returns a single meta item. |
|
| 140 | - * |
|
| 141 | - * @param $alias |
|
| 142 | - * |
|
| 143 | - * @return mixed |
|
| 144 | - */ |
|
| 145 | - public function get($alias) |
|
| 146 | - { |
|
| 147 | - $alias = strtolower($alias); |
|
| 148 | - |
|
| 149 | - return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - //-------------------------------------------------------------------- |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Renders out all defined meta tags. |
|
| 156 | - * |
|
| 157 | - * @return mixed |
|
| 158 | - */ |
|
| 159 | - public function renderTags() |
|
| 160 | - { |
|
| 161 | - if (! count($this->meta)) |
|
| 162 | - { |
|
| 163 | - return null; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $output = ''; |
|
| 167 | - |
|
| 168 | - // Character Encoding |
|
| 169 | - $output .= "\t<meta charset=\"{$this->charset}\" >"; |
|
| 170 | - |
|
| 171 | - // Everything else |
|
| 172 | - foreach ($this->meta as $name => $content) |
|
| 173 | - { |
|
| 174 | - if (is_array($content)) |
|
| 175 | - { |
|
| 176 | - $content = implode(',', $content); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if (empty($content)) |
|
| 180 | - { |
|
| 181 | - continue; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Http Equivalent meta tags. |
|
| 185 | - if (in_array($name, $this->http_equiv_meta)) |
|
| 186 | - { |
|
| 187 | - $output .= "\t<meta http-equiv=\"{$name}\" content=\"{$content}\">\n"; |
|
| 188 | - } |
|
| 189 | - // Standard Meta Tag |
|
| 190 | - else { |
|
| 191 | - $output .= "\t<meta name=\"{$name}\" content=\"{$content}\">\n"; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $output; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - //-------------------------------------------------------------------- |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Registers a new HTTP Equivalent meta tag so it can be |
|
| 202 | - * rendered out properly. |
|
| 203 | - * |
|
| 204 | - * @param $name |
|
| 205 | - * |
|
| 206 | - * @return $this |
|
| 207 | - */ |
|
| 208 | - public function registerHTTPEquivTag($name) |
|
| 209 | - { |
|
| 210 | - if (is_null($name)) |
|
| 211 | - { |
|
| 212 | - return $this; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $this->http_equiv_meta[] = strtolower($name); |
|
| 216 | - |
|
| 217 | - return $this; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - //-------------------------------------------------------------------- |
|
| 221 | - |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Convenience implementation to set a value |
|
| 225 | - * as if it was a property of the class. |
|
| 226 | - * |
|
| 227 | - * @param $alias |
|
| 228 | - * @param null $value |
|
| 229 | - */ |
|
| 230 | - public function __set($alias, $value=null) |
|
| 231 | - { |
|
| 232 | - $this->set($alias, $value); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - //-------------------------------------------------------------------- |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Convenience method to access a value |
|
| 239 | - * as if it was a property of the class. |
|
| 240 | - * |
|
| 241 | - * @param $alias |
|
| 242 | - * |
|
| 243 | - * @return mixed |
|
| 244 | - */ |
|
| 245 | - public function __get($alias) |
|
| 246 | - { |
|
| 247 | - return $this->get($alias); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - //-------------------------------------------------------------------- |
|
| 38 | + /** |
|
| 39 | + * Stores the meta values the user has set. |
|
| 40 | + * |
|
| 41 | + * @var array |
|
| 42 | + */ |
|
| 43 | + protected $meta = []; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Stores the standard meta-value names |
|
| 47 | + * Mostly here for reference, I guess. |
|
| 48 | + * |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + protected $std_meta = [ |
|
| 52 | + 'application-name', |
|
| 53 | + 'author', |
|
| 54 | + 'copyright', |
|
| 55 | + 'description', |
|
| 56 | + 'generator', |
|
| 57 | + 'keywords', |
|
| 58 | + 'robots', |
|
| 59 | + 'googlebot' |
|
| 60 | + ]; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Stores the HTTP-Equiv meta tags |
|
| 64 | + * since they need to be rendered differently. |
|
| 65 | + * |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | + protected $http_equiv_meta = [ |
|
| 69 | + 'cache-control', |
|
| 70 | + 'content-language', |
|
| 71 | + 'content-type', |
|
| 72 | + 'default-style', |
|
| 73 | + 'expires', |
|
| 74 | + 'pragma', |
|
| 75 | + 'refresh', |
|
| 76 | + 'set-cookie' |
|
| 77 | + ]; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Stores the document's character encoding. |
|
| 81 | + * |
|
| 82 | + * @var string |
|
| 83 | + */ |
|
| 84 | + public $charset = 'utf-8'; |
|
| 85 | + |
|
| 86 | + //-------------------------------------------------------------------- |
|
| 87 | + |
|
| 88 | + public function __construct($ci) |
|
| 89 | + { |
|
| 90 | + $ci->config->load('html_meta', true); |
|
| 91 | + |
|
| 92 | + $config = $ci->config->item('html_meta'); |
|
| 93 | + |
|
| 94 | + $this->meta = $config['meta']; |
|
| 95 | + |
|
| 96 | + $this->http_equiv_meta = array_merge($this->http_equiv_meta, $config['http-equiv']); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + //-------------------------------------------------------------------- |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Sets a single meta item. |
|
| 104 | + * $alias can also be an array of key/value pairs to set. |
|
| 105 | + * |
|
| 106 | + * @param string|array $alias |
|
| 107 | + * @param null $value |
|
| 108 | + * |
|
| 109 | + * @return mixed |
|
| 110 | + */ |
|
| 111 | + public function set($alias, $value=null, $escape=true) |
|
| 112 | + { |
|
| 113 | + if (is_array($alias)) |
|
| 114 | + { |
|
| 115 | + foreach ($alias as $key => $val) |
|
| 116 | + { |
|
| 117 | + $this->set($key, $val); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return $this; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Charset |
|
| 124 | + if (strtolower($alias) == 'charset') |
|
| 125 | + { |
|
| 126 | + $this->charset = $value; |
|
| 127 | + |
|
| 128 | + return $this; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
| 132 | + |
|
| 133 | + return $this; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + //-------------------------------------------------------------------- |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Returns a single meta item. |
|
| 140 | + * |
|
| 141 | + * @param $alias |
|
| 142 | + * |
|
| 143 | + * @return mixed |
|
| 144 | + */ |
|
| 145 | + public function get($alias) |
|
| 146 | + { |
|
| 147 | + $alias = strtolower($alias); |
|
| 148 | + |
|
| 149 | + return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + //-------------------------------------------------------------------- |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Renders out all defined meta tags. |
|
| 156 | + * |
|
| 157 | + * @return mixed |
|
| 158 | + */ |
|
| 159 | + public function renderTags() |
|
| 160 | + { |
|
| 161 | + if (! count($this->meta)) |
|
| 162 | + { |
|
| 163 | + return null; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $output = ''; |
|
| 167 | + |
|
| 168 | + // Character Encoding |
|
| 169 | + $output .= "\t<meta charset=\"{$this->charset}\" >"; |
|
| 170 | + |
|
| 171 | + // Everything else |
|
| 172 | + foreach ($this->meta as $name => $content) |
|
| 173 | + { |
|
| 174 | + if (is_array($content)) |
|
| 175 | + { |
|
| 176 | + $content = implode(',', $content); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if (empty($content)) |
|
| 180 | + { |
|
| 181 | + continue; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Http Equivalent meta tags. |
|
| 185 | + if (in_array($name, $this->http_equiv_meta)) |
|
| 186 | + { |
|
| 187 | + $output .= "\t<meta http-equiv=\"{$name}\" content=\"{$content}\">\n"; |
|
| 188 | + } |
|
| 189 | + // Standard Meta Tag |
|
| 190 | + else { |
|
| 191 | + $output .= "\t<meta name=\"{$name}\" content=\"{$content}\">\n"; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $output; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + //-------------------------------------------------------------------- |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Registers a new HTTP Equivalent meta tag so it can be |
|
| 202 | + * rendered out properly. |
|
| 203 | + * |
|
| 204 | + * @param $name |
|
| 205 | + * |
|
| 206 | + * @return $this |
|
| 207 | + */ |
|
| 208 | + public function registerHTTPEquivTag($name) |
|
| 209 | + { |
|
| 210 | + if (is_null($name)) |
|
| 211 | + { |
|
| 212 | + return $this; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $this->http_equiv_meta[] = strtolower($name); |
|
| 216 | + |
|
| 217 | + return $this; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + //-------------------------------------------------------------------- |
|
| 221 | + |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Convenience implementation to set a value |
|
| 225 | + * as if it was a property of the class. |
|
| 226 | + * |
|
| 227 | + * @param $alias |
|
| 228 | + * @param null $value |
|
| 229 | + */ |
|
| 230 | + public function __set($alias, $value=null) |
|
| 231 | + { |
|
| 232 | + $this->set($alias, $value); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + //-------------------------------------------------------------------- |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Convenience method to access a value |
|
| 239 | + * as if it was a property of the class. |
|
| 240 | + * |
|
| 241 | + * @param $alias |
|
| 242 | + * |
|
| 243 | + * @return mixed |
|
| 244 | + */ |
|
| 245 | + public function __get($alias) |
|
| 246 | + { |
|
| 247 | + return $this->get($alias); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + //-------------------------------------------------------------------- |
|
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php namespace Myth\Themers; |
| 2 | 2 | |
| 3 | -require_once dirname(__FILE__) .'/escape.php'; |
|
| 3 | +require_once dirname(__FILE__).'/escape.php'; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Sprint |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return mixed |
| 110 | 110 | */ |
| 111 | - public function set($alias, $value=null, $escape=true) |
|
| 111 | + public function set($alias, $value = null, $escape = true) |
|
| 112 | 112 | { |
| 113 | 113 | if (is_array($alias)) |
| 114 | 114 | { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | return $this; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
| 131 | + $this->meta[strtolower($alias)] = $escape ? esc($value, 'htmlAttr') : $value; |
|
| 132 | 132 | |
| 133 | 133 | return $this; |
| 134 | 134 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $alias = strtolower($alias); |
| 148 | 148 | |
| 149 | - return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
| 149 | + return isset($this->meta[$alias]) ? $this->meta[$alias] : null; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | //-------------------------------------------------------------------- |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function renderTags() |
| 160 | 160 | { |
| 161 | - if (! count($this->meta)) |
|
| 161 | + if ( ! count($this->meta)) |
|
| 162 | 162 | { |
| 163 | 163 | return null; |
| 164 | 164 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param $alias |
| 228 | 228 | * @param null $value |
| 229 | 229 | */ |
| 230 | - public function __set($alias, $value=null) |
|
| 230 | + public function __set($alias, $value = null) |
|
| 231 | 231 | { |
| 232 | 232 | $this->set($alias, $value); |
| 233 | 233 | } |
@@ -38,219 +38,219 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | interface ThemerInterface |
| 40 | 40 | { |
| 41 | - /** |
|
| 42 | - * The main entryway into rendering a view. This is called from the |
|
| 43 | - * controller and is generally the last method called. |
|
| 44 | - * |
|
| 45 | - * @param string $layout If provided, will override the default layout. |
|
| 46 | - */ |
|
| 47 | - public function render($layout = null); |
|
| 48 | - |
|
| 49 | - //-------------------------------------------------------------------- |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Used within the template layout file to render the current content. |
|
| 53 | - * This content is typically used to display the current view. |
|
| 54 | - */ |
|
| 55 | - public function content(); |
|
| 56 | - |
|
| 57 | - //-------------------------------------------------------------------- |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Sets the active theme to use. This theme should be |
|
| 61 | - * relative to one of the 'theme_paths' folders. |
|
| 62 | - * |
|
| 63 | - * @param $theme |
|
| 64 | - */ |
|
| 65 | - public function setTheme($theme); |
|
| 66 | - |
|
| 67 | - //-------------------------------------------------------------------- |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Returns the current theme. |
|
| 71 | - * |
|
| 72 | - * @return mixed|string |
|
| 73 | - */ |
|
| 74 | - public function theme(); |
|
| 75 | - |
|
| 76 | - //-------------------------------------------------------------------- |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Sets the default theme to use. |
|
| 80 | - * |
|
| 81 | - * @param $theme |
|
| 82 | - * @return mixed |
|
| 83 | - */ |
|
| 84 | - public function setDefaultTheme($theme); |
|
| 85 | - |
|
| 86 | - //-------------------------------------------------------------------- |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Sets the current view file to render. |
|
| 90 | - * |
|
| 91 | - * @param $file |
|
| 92 | - * @return mixed |
|
| 93 | - */ |
|
| 94 | - public function setView($file); |
|
| 95 | - |
|
| 96 | - //-------------------------------------------------------------------- |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Returns the current view. |
|
| 100 | - * |
|
| 101 | - * @return mixed|string |
|
| 102 | - */ |
|
| 103 | - public function view(); |
|
| 104 | - |
|
| 105 | - //-------------------------------------------------------------------- |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Sets the current layout to be used. MUST be the name of one of |
|
| 109 | - * the layout files within the current theme. Case-sensitive. |
|
| 110 | - * |
|
| 111 | - * @param $file |
|
| 112 | - * @return mixed |
|
| 113 | - */ |
|
| 114 | - public function setLayout($file); |
|
| 115 | - |
|
| 116 | - //-------------------------------------------------------------------- |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Returns the active layout. |
|
| 120 | - * |
|
| 121 | - * @return mixed |
|
| 122 | - */ |
|
| 123 | - public function layout(); |
|
| 124 | - |
|
| 125 | - //-------------------------------------------------------------------- |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Stores one or more pieces of data to be passed to the views when |
|
| 129 | - * they are rendered out. |
|
| 130 | - * |
|
| 131 | - * If both $key and $value are ! empty, then it will treat it as a |
|
| 132 | - * key/value pair. If $key is an array of key/value pairs, then $value |
|
| 133 | - * is ignored and each element of the array are made available to the |
|
| 134 | - * view as if it was a single $key/$value pair. |
|
| 135 | - * |
|
| 136 | - * @param string|array $key |
|
| 137 | - * @param mixed $value |
|
| 138 | - */ |
|
| 139 | - public function set($key, $value = null); |
|
| 140 | - |
|
| 141 | - //-------------------------------------------------------------------- |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Returns a value that has been previously set(). |
|
| 145 | - * |
|
| 146 | - * @param $key |
|
| 147 | - * @return mixed |
|
| 148 | - */ |
|
| 149 | - public function get($key); |
|
| 150 | - |
|
| 151 | - //-------------------------------------------------------------------- |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Determines whether or not the view should be parsed with the |
|
| 155 | - * CodeIgniter's parser. |
|
| 156 | - * |
|
| 157 | - * @param bool $parse |
|
| 158 | - * @return mixed |
|
| 159 | - */ |
|
| 160 | - public function parseViews($parse = false); |
|
| 161 | - |
|
| 162 | - //-------------------------------------------------------------------- |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Theme paths allow you to have multiple locations for themes to be |
|
| 166 | - * stored. This might be used for separating themes for different sub- |
|
| 167 | - * applications, or a core theme and user-submitted themes. |
|
| 168 | - * |
|
| 169 | - * @param $alias The name the theme can be referenced by |
|
| 170 | - * @param $path A new path where themes can be found. |
|
| 171 | - * |
|
| 172 | - * @return mixed |
|
| 173 | - */ |
|
| 174 | - public function addThemePath($alias, $path); |
|
| 175 | - |
|
| 176 | - //-------------------------------------------------------------------- |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Removes a single theme path. |
|
| 180 | - * |
|
| 181 | - * @param $alias |
|
| 182 | - */ |
|
| 183 | - public function removeThemePath($alias); |
|
| 184 | - //-------------------------------------------------------------------- |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Loads a view file. Useful to control caching. Intended for use |
|
| 188 | - * from within view files. |
|
| 189 | - * |
|
| 190 | - * You can specify that a view should belong to a theme by prefixing |
|
| 191 | - * the name of the theme and a colon to the view name. For example, |
|
| 192 | - * "admin:header" would try to display the "header.php" file within |
|
| 193 | - * the "admin" theme. |
|
| 194 | - * |
|
| 195 | - * @param string $view |
|
| 196 | - * @param array $data |
|
| 197 | - * @param int $cache_time The number of MINUTES to cache the output |
|
| 198 | - * @return mixed |
|
| 199 | - */ |
|
| 200 | - public function display($view, $data = array(), $cache_time = 0); |
|
| 201 | - |
|
| 202 | - //-------------------------------------------------------------------- |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Sets the variant used when creating view names. These variants can |
|
| 206 | - * be anything, but by default are used to render specific templates |
|
| 207 | - * for desktop, tablet, and phone. The name of the variant is added |
|
| 208 | - * to the view name, joined by a "+" symbol. |
|
| 209 | - * |
|
| 210 | - * Example: |
|
| 211 | - * $this->setVariant('phone'); |
|
| 212 | - * $this->display('header'); |
|
| 213 | - * |
|
| 214 | - * Tries to display "views/header+phone.php" |
|
| 215 | - * |
|
| 216 | - * @param $variant |
|
| 217 | - * @return mixed |
|
| 218 | - */ |
|
| 219 | - public function setVariant($variant); |
|
| 220 | - |
|
| 221 | - //-------------------------------------------------------------------- |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Adds a new variant to the system. |
|
| 225 | - * |
|
| 226 | - * @param $name |
|
| 227 | - * @param $postfix |
|
| 228 | - * @return mixed |
|
| 229 | - */ |
|
| 230 | - public function addVariant($name, $postfix); |
|
| 231 | - |
|
| 232 | - //-------------------------------------------------------------------- |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Removes a variant from the system. |
|
| 236 | - * |
|
| 237 | - * @param $name |
|
| 238 | - * @param $postfix |
|
| 239 | - * @return mixed |
|
| 240 | - */ |
|
| 241 | - public function removeVariant($name); |
|
| 242 | - |
|
| 243 | - //-------------------------------------------------------------------- |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Runs a callback method and returns the contents to the view. |
|
| 247 | - * |
|
| 248 | - * @param $command |
|
| 249 | - * @param int $cache_minutes |
|
| 250 | - * @return mixed |
|
| 251 | - */ |
|
| 252 | - public function call($command, $cache_minutes=0); |
|
| 253 | - |
|
| 254 | - //-------------------------------------------------------------------- |
|
| 41 | + /** |
|
| 42 | + * The main entryway into rendering a view. This is called from the |
|
| 43 | + * controller and is generally the last method called. |
|
| 44 | + * |
|
| 45 | + * @param string $layout If provided, will override the default layout. |
|
| 46 | + */ |
|
| 47 | + public function render($layout = null); |
|
| 48 | + |
|
| 49 | + //-------------------------------------------------------------------- |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Used within the template layout file to render the current content. |
|
| 53 | + * This content is typically used to display the current view. |
|
| 54 | + */ |
|
| 55 | + public function content(); |
|
| 56 | + |
|
| 57 | + //-------------------------------------------------------------------- |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Sets the active theme to use. This theme should be |
|
| 61 | + * relative to one of the 'theme_paths' folders. |
|
| 62 | + * |
|
| 63 | + * @param $theme |
|
| 64 | + */ |
|
| 65 | + public function setTheme($theme); |
|
| 66 | + |
|
| 67 | + //-------------------------------------------------------------------- |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Returns the current theme. |
|
| 71 | + * |
|
| 72 | + * @return mixed|string |
|
| 73 | + */ |
|
| 74 | + public function theme(); |
|
| 75 | + |
|
| 76 | + //-------------------------------------------------------------------- |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Sets the default theme to use. |
|
| 80 | + * |
|
| 81 | + * @param $theme |
|
| 82 | + * @return mixed |
|
| 83 | + */ |
|
| 84 | + public function setDefaultTheme($theme); |
|
| 85 | + |
|
| 86 | + //-------------------------------------------------------------------- |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Sets the current view file to render. |
|
| 90 | + * |
|
| 91 | + * @param $file |
|
| 92 | + * @return mixed |
|
| 93 | + */ |
|
| 94 | + public function setView($file); |
|
| 95 | + |
|
| 96 | + //-------------------------------------------------------------------- |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Returns the current view. |
|
| 100 | + * |
|
| 101 | + * @return mixed|string |
|
| 102 | + */ |
|
| 103 | + public function view(); |
|
| 104 | + |
|
| 105 | + //-------------------------------------------------------------------- |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Sets the current layout to be used. MUST be the name of one of |
|
| 109 | + * the layout files within the current theme. Case-sensitive. |
|
| 110 | + * |
|
| 111 | + * @param $file |
|
| 112 | + * @return mixed |
|
| 113 | + */ |
|
| 114 | + public function setLayout($file); |
|
| 115 | + |
|
| 116 | + //-------------------------------------------------------------------- |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Returns the active layout. |
|
| 120 | + * |
|
| 121 | + * @return mixed |
|
| 122 | + */ |
|
| 123 | + public function layout(); |
|
| 124 | + |
|
| 125 | + //-------------------------------------------------------------------- |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Stores one or more pieces of data to be passed to the views when |
|
| 129 | + * they are rendered out. |
|
| 130 | + * |
|
| 131 | + * If both $key and $value are ! empty, then it will treat it as a |
|
| 132 | + * key/value pair. If $key is an array of key/value pairs, then $value |
|
| 133 | + * is ignored and each element of the array are made available to the |
|
| 134 | + * view as if it was a single $key/$value pair. |
|
| 135 | + * |
|
| 136 | + * @param string|array $key |
|
| 137 | + * @param mixed $value |
|
| 138 | + */ |
|
| 139 | + public function set($key, $value = null); |
|
| 140 | + |
|
| 141 | + //-------------------------------------------------------------------- |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Returns a value that has been previously set(). |
|
| 145 | + * |
|
| 146 | + * @param $key |
|
| 147 | + * @return mixed |
|
| 148 | + */ |
|
| 149 | + public function get($key); |
|
| 150 | + |
|
| 151 | + //-------------------------------------------------------------------- |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Determines whether or not the view should be parsed with the |
|
| 155 | + * CodeIgniter's parser. |
|
| 156 | + * |
|
| 157 | + * @param bool $parse |
|
| 158 | + * @return mixed |
|
| 159 | + */ |
|
| 160 | + public function parseViews($parse = false); |
|
| 161 | + |
|
| 162 | + //-------------------------------------------------------------------- |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Theme paths allow you to have multiple locations for themes to be |
|
| 166 | + * stored. This might be used for separating themes for different sub- |
|
| 167 | + * applications, or a core theme and user-submitted themes. |
|
| 168 | + * |
|
| 169 | + * @param $alias The name the theme can be referenced by |
|
| 170 | + * @param $path A new path where themes can be found. |
|
| 171 | + * |
|
| 172 | + * @return mixed |
|
| 173 | + */ |
|
| 174 | + public function addThemePath($alias, $path); |
|
| 175 | + |
|
| 176 | + //-------------------------------------------------------------------- |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Removes a single theme path. |
|
| 180 | + * |
|
| 181 | + * @param $alias |
|
| 182 | + */ |
|
| 183 | + public function removeThemePath($alias); |
|
| 184 | + //-------------------------------------------------------------------- |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Loads a view file. Useful to control caching. Intended for use |
|
| 188 | + * from within view files. |
|
| 189 | + * |
|
| 190 | + * You can specify that a view should belong to a theme by prefixing |
|
| 191 | + * the name of the theme and a colon to the view name. For example, |
|
| 192 | + * "admin:header" would try to display the "header.php" file within |
|
| 193 | + * the "admin" theme. |
|
| 194 | + * |
|
| 195 | + * @param string $view |
|
| 196 | + * @param array $data |
|
| 197 | + * @param int $cache_time The number of MINUTES to cache the output |
|
| 198 | + * @return mixed |
|
| 199 | + */ |
|
| 200 | + public function display($view, $data = array(), $cache_time = 0); |
|
| 201 | + |
|
| 202 | + //-------------------------------------------------------------------- |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Sets the variant used when creating view names. These variants can |
|
| 206 | + * be anything, but by default are used to render specific templates |
|
| 207 | + * for desktop, tablet, and phone. The name of the variant is added |
|
| 208 | + * to the view name, joined by a "+" symbol. |
|
| 209 | + * |
|
| 210 | + * Example: |
|
| 211 | + * $this->setVariant('phone'); |
|
| 212 | + * $this->display('header'); |
|
| 213 | + * |
|
| 214 | + * Tries to display "views/header+phone.php" |
|
| 215 | + * |
|
| 216 | + * @param $variant |
|
| 217 | + * @return mixed |
|
| 218 | + */ |
|
| 219 | + public function setVariant($variant); |
|
| 220 | + |
|
| 221 | + //-------------------------------------------------------------------- |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Adds a new variant to the system. |
|
| 225 | + * |
|
| 226 | + * @param $name |
|
| 227 | + * @param $postfix |
|
| 228 | + * @return mixed |
|
| 229 | + */ |
|
| 230 | + public function addVariant($name, $postfix); |
|
| 231 | + |
|
| 232 | + //-------------------------------------------------------------------- |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Removes a variant from the system. |
|
| 236 | + * |
|
| 237 | + * @param $name |
|
| 238 | + * @param $postfix |
|
| 239 | + * @return mixed |
|
| 240 | + */ |
|
| 241 | + public function removeVariant($name); |
|
| 242 | + |
|
| 243 | + //-------------------------------------------------------------------- |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Runs a callback method and returns the contents to the view. |
|
| 247 | + * |
|
| 248 | + * @param $command |
|
| 249 | + * @param int $cache_minutes |
|
| 250 | + * @return mixed |
|
| 251 | + */ |
|
| 252 | + public function call($command, $cache_minutes=0); |
|
| 253 | + |
|
| 254 | + //-------------------------------------------------------------------- |
|
| 255 | 255 | |
| 256 | 256 | } |
@@ -249,7 +249,7 @@ |
||
| 249 | 249 | * @param int $cache_minutes |
| 250 | 250 | * @return mixed |
| 251 | 251 | */ |
| 252 | - public function call($command, $cache_minutes=0); |
|
| 252 | + public function call($command, $cache_minutes = 0); |
|
| 253 | 253 | |
| 254 | 254 | //-------------------------------------------------------------------- |
| 255 | 255 | |
@@ -4,79 +4,79 @@ |
||
| 4 | 4 | |
| 5 | 5 | if (! function_exists('esc')) |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Escapes strings to make them safe for use |
|
| 9 | - * within HTML templates. Used by the auto-escaping |
|
| 10 | - * functionality in setVar() and available to |
|
| 11 | - * use within your views. |
|
| 12 | - * |
|
| 13 | - * Uses ZendFramework's Escaper to handle the actual escaping, |
|
| 14 | - * based on context. Valid contexts are: |
|
| 15 | - * - html |
|
| 16 | - * - htmlAttr |
|
| 17 | - * - js |
|
| 18 | - * - css |
|
| 19 | - * - url |
|
| 20 | - * |
|
| 21 | - * References: |
|
| 22 | - * - https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet |
|
| 23 | - * - http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html |
|
| 24 | - * |
|
| 25 | - * @param $data |
|
| 26 | - * @param $context |
|
| 27 | - * @param escaper // An instance of ZF's Escaper to avoid repeated class instantiation. |
|
| 28 | - * |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - function esc($data, $context='html', $escaper=null) |
|
| 32 | - { |
|
| 33 | - if (is_array($data)) |
|
| 34 | - { |
|
| 35 | - foreach ($data as $key => &$value) |
|
| 36 | - { |
|
| 37 | - $value = esc($value, $context); |
|
| 38 | - } |
|
| 39 | - } |
|
| 7 | + /** |
|
| 8 | + * Escapes strings to make them safe for use |
|
| 9 | + * within HTML templates. Used by the auto-escaping |
|
| 10 | + * functionality in setVar() and available to |
|
| 11 | + * use within your views. |
|
| 12 | + * |
|
| 13 | + * Uses ZendFramework's Escaper to handle the actual escaping, |
|
| 14 | + * based on context. Valid contexts are: |
|
| 15 | + * - html |
|
| 16 | + * - htmlAttr |
|
| 17 | + * - js |
|
| 18 | + * - css |
|
| 19 | + * - url |
|
| 20 | + * |
|
| 21 | + * References: |
|
| 22 | + * - https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet |
|
| 23 | + * - http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html |
|
| 24 | + * |
|
| 25 | + * @param $data |
|
| 26 | + * @param $context |
|
| 27 | + * @param escaper // An instance of ZF's Escaper to avoid repeated class instantiation. |
|
| 28 | + * |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + function esc($data, $context='html', $escaper=null) |
|
| 32 | + { |
|
| 33 | + if (is_array($data)) |
|
| 34 | + { |
|
| 35 | + foreach ($data as $key => &$value) |
|
| 36 | + { |
|
| 37 | + $value = esc($value, $context); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $context = strtolower($context); |
|
| 41 | + $context = strtolower($context); |
|
| 42 | 42 | |
| 43 | - if (! is_object($escaper)) |
|
| 44 | - { |
|
| 45 | - $escaper = new Escaper(config_item('charset')); |
|
| 46 | - } |
|
| 43 | + if (! is_object($escaper)) |
|
| 44 | + { |
|
| 45 | + $escaper = new Escaper(config_item('charset')); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // Valid context? |
|
| 49 | - if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
| 50 | - { |
|
| 51 | - throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
| 52 | - } |
|
| 48 | + // Valid context? |
|
| 49 | + if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
| 50 | + { |
|
| 51 | + throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - if (! is_string($data)) |
|
| 55 | - { |
|
| 56 | - return $data; |
|
| 57 | - } |
|
| 54 | + if (! is_string($data)) |
|
| 55 | + { |
|
| 56 | + return $data; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - switch ($context) |
|
| 60 | - { |
|
| 61 | - case 'html': |
|
| 62 | - $data = $escaper->escapeHtml($data); |
|
| 63 | - break; |
|
| 64 | - case 'htmlattr': |
|
| 65 | - $data = $escaper->escapeHtmlAttr($data); |
|
| 66 | - break; |
|
| 67 | - case 'js': |
|
| 68 | - $data = $escaper->escapeJs($data); |
|
| 69 | - break; |
|
| 70 | - case 'css': |
|
| 71 | - $data = $escaper->escapeCss($data); |
|
| 72 | - break; |
|
| 73 | - case 'url': |
|
| 74 | - $data = $escaper->escapeUrl($data); |
|
| 75 | - break; |
|
| 76 | - default: |
|
| 77 | - break; |
|
| 78 | - } |
|
| 59 | + switch ($context) |
|
| 60 | + { |
|
| 61 | + case 'html': |
|
| 62 | + $data = $escaper->escapeHtml($data); |
|
| 63 | + break; |
|
| 64 | + case 'htmlattr': |
|
| 65 | + $data = $escaper->escapeHtmlAttr($data); |
|
| 66 | + break; |
|
| 67 | + case 'js': |
|
| 68 | + $data = $escaper->escapeJs($data); |
|
| 69 | + break; |
|
| 70 | + case 'css': |
|
| 71 | + $data = $escaper->escapeCss($data); |
|
| 72 | + break; |
|
| 73 | + case 'url': |
|
| 74 | + $data = $escaper->escapeUrl($data); |
|
| 75 | + break; |
|
| 76 | + default: |
|
| 77 | + break; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return $data; |
|
| 81 | - } |
|
| 80 | + return $data; |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use Zend\Escaper\Escaper; |
| 4 | 4 | |
| 5 | -if (! function_exists('esc')) |
|
| 5 | +if ( ! function_exists('esc')) |
|
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | 8 | * Escapes strings to make them safe for use |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - function esc($data, $context='html', $escaper=null) |
|
| 31 | + function esc($data, $context = 'html', $escaper = null) |
|
| 32 | 32 | { |
| 33 | 33 | if (is_array($data)) |
| 34 | 34 | { |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $context = strtolower($context); |
| 42 | 42 | |
| 43 | - if (! is_object($escaper)) |
|
| 43 | + if ( ! is_object($escaper)) |
|
| 44 | 44 | { |
| 45 | 45 | $escaper = new Escaper(config_item('charset')); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Valid context? |
| 49 | - if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
| 49 | + if ( ! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
| 50 | 50 | { |
| 51 | - throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
| 51 | + throw new \InvalidArgumentException('Invalid Context type: '.$context); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if (! is_string($data)) |
|
| 54 | + if ( ! is_string($data)) |
|
| 55 | 55 | { |
| 56 | 56 | return $data; |
| 57 | 57 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | if (! empty($model) ) |
| 25 | 25 | { |
| 26 | - $index_method = <<<EOD |
|
| 26 | + $index_method = <<<EOD |
|
| 27 | 27 | \$this->load->library('table'); |
| 28 | 28 | |
| 29 | 29 | \$offset = \$this->uri->segment( \$this->uri->total_segments() ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if (! empty($model)) |
| 46 | 46 | { |
| 47 | - $create_method = <<<EOD |
|
| 47 | + $create_method = <<<EOD |
|
| 48 | 48 | \$this->load->helper('form'); |
| 49 | 49 | \$this->load->helper('inflector'); |
| 50 | 50 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | if (! empty($model)) |
| 74 | 74 | { |
| 75 | - $show_method = <<<EOD |
|
| 75 | + $show_method = <<<EOD |
|
| 76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
| 77 | 77 | |
| 78 | 78 | if (! \$item) |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | if (! empty($model)) |
| 96 | 96 | { |
| 97 | - $update_method = <<<EOD |
|
| 97 | + $update_method = <<<EOD |
|
| 98 | 98 | \$this->load->helper('form'); |
| 99 | 99 | \$this->load->helper('inflector'); |
| 100 | 100 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | if (! empty($model)) |
| 127 | 127 | { |
| 128 | - $delete_method = <<<EOD |
|
| 128 | + $delete_method = <<<EOD |
|
| 129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
| 130 | 130 | { |
| 131 | 131 | \$this->setMessage('Successfully deleted item.', 'success'); |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | if ($themed) |
| 147 | 147 | { |
| 148 | - $index_method .= "\$this->render();"; |
|
| 149 | - $create_method .= "\$this->render();"; |
|
| 150 | - $show_method .= "\$this->render();"; |
|
| 151 | - $update_method .= "\$this->render();"; |
|
| 148 | + $index_method .= "\$this->render();"; |
|
| 149 | + $create_method .= "\$this->render();"; |
|
| 150 | + $show_method .= "\$this->render();"; |
|
| 151 | + $update_method .= "\$this->render();"; |
|
| 152 | 152 | |
| 153 | - $fields = " |
|
| 153 | + $fields = " |
|
| 154 | 154 | /** |
| 155 | 155 | * Allows per-controller override of theme. |
| 156 | 156 | * @var null |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | //-------------------------------------------------------------------- |
| 6 | 6 | |
| 7 | 7 | $model_string = $model ? "'{$model}'" : 'null'; |
| 8 | -$lower_model = trim( strtolower($model_string), "' " ); |
|
| 8 | +$lower_model = trim(strtolower($model_string), "' "); |
|
| 9 | 9 | $lower_model_esc = strpos($lower_model, 'null') !== false ? 'null' : "'{$lower_model}'"; |
| 10 | -$lower_controller = strtolower($controller_name); |
|
| 10 | +$lower_controller = strtolower($controller_name); |
|
| 11 | 11 | |
| 12 | 12 | //-------------------------------------------------------------------- |
| 13 | 13 | // Build our Methods |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | $index_method = ''; |
| 23 | 23 | |
| 24 | -if (! empty($model) ) |
|
| 24 | +if ( ! empty($model)) |
|
| 25 | 25 | { |
| 26 | 26 | $index_method = <<<EOD |
| 27 | 27 | \$this->load->library('table'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | $create_method = ''; |
| 44 | 44 | |
| 45 | -if (! empty($model)) |
|
| 45 | +if ( ! empty($model)) |
|
| 46 | 46 | { |
| 47 | 47 | $create_method = <<<EOD |
| 48 | 48 | \$this->load->helper('form'); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | $show_method = ''; |
| 72 | 72 | |
| 73 | -if (! empty($model)) |
|
| 73 | +if ( ! empty($model)) |
|
| 74 | 74 | { |
| 75 | 75 | $show_method = <<<EOD |
| 76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | $update_method = ''; |
| 94 | 94 | |
| 95 | -if (! empty($model)) |
|
| 95 | +if ( ! empty($model)) |
|
| 96 | 96 | { |
| 97 | 97 | $update_method = <<<EOD |
| 98 | 98 | \$this->load->helper('form'); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | $delete_method = ''; |
| 125 | 125 | |
| 126 | -if (! empty($model)) |
|
| 126 | +if ( ! empty($model)) |
|
| 127 | 127 | { |
| 128 | 128 | $delete_method = <<<EOD |
| 129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | 33 | $descriptions = [ |
| 34 | - 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
| 34 | + 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
| 35 | 35 | ]; |
| 36 | 36 | |
| 37 | 37 | $long_description = <<<EOT |
@@ -4,43 +4,43 @@ |
||
| 4 | 4 | |
| 5 | 5 | <?= $uikit->row([], function() use($uikit, $fields) { |
| 6 | 6 | |
| 7 | - $sizes = [ |
|
| 8 | - 's' => 12, |
|
| 9 | - 'm' => 6, |
|
| 10 | - 'l' => 4 |
|
| 11 | - ]; |
|
| 12 | - echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
| 13 | - |
|
| 14 | - foreach ($fields as $field) |
|
| 15 | - { |
|
| 16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
| 17 | - |
|
| 18 | - switch ($field['type']) |
|
| 19 | - { |
|
| 20 | - case 'text': |
|
| 21 | - echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
| 22 | - break; |
|
| 23 | - case 'number': |
|
| 24 | - echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
| 25 | - break; |
|
| 26 | - case 'date': |
|
| 27 | - echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
| 28 | - break; |
|
| 29 | - case 'datetime': |
|
| 30 | - echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
| 31 | - break; |
|
| 32 | - case 'time': |
|
| 33 | - echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
| 34 | - break; |
|
| 35 | - case 'textarea': |
|
| 36 | - echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
| 37 | - break; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - } ); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - }); |
|
| 7 | + $sizes = [ |
|
| 8 | + 's' => 12, |
|
| 9 | + 'm' => 6, |
|
| 10 | + 'l' => 4 |
|
| 11 | + ]; |
|
| 12 | + echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
| 13 | + |
|
| 14 | + foreach ($fields as $field) |
|
| 15 | + { |
|
| 16 | + echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
| 17 | + |
|
| 18 | + switch ($field['type']) |
|
| 19 | + { |
|
| 20 | + case 'text': |
|
| 21 | + echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
| 22 | + break; |
|
| 23 | + case 'number': |
|
| 24 | + echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
| 25 | + break; |
|
| 26 | + case 'date': |
|
| 27 | + echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
| 28 | + break; |
|
| 29 | + case 'datetime': |
|
| 30 | + echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
| 31 | + break; |
|
| 32 | + case 'time': |
|
| 33 | + echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
| 34 | + break; |
|
| 35 | + case 'textarea': |
|
| 36 | + echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
| 37 | + break; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + } ); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + }); |
|
| 44 | 44 | |
| 45 | 45 | }); ?> |
| 46 | 46 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | foreach ($fields as $field) |
| 15 | 15 | { |
| 16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
| 16 | + echo $uikit->inputWrap(humanize($field['name']), null, function() use($uikit, $field) { |
|
| 17 | 17 | |
| 18 | 18 | switch ($field['type']) |
| 19 | 19 | { |
@@ -5,45 +5,45 @@ |
||
| 5 | 5 | <?= $uikit->row([], function() use($uikit, $fields) |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - $sizes = [ |
|
| 9 | - 's' => 12, |
|
| 10 | - 'm' => 6, |
|
| 11 | - 'l' => 4 |
|
| 12 | - ]; |
|
| 13 | - echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
| 14 | - { |
|
| 15 | - |
|
| 16 | - foreach ( $fields as $field ) |
|
| 17 | - { |
|
| 18 | - |
|
| 19 | - echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
| 20 | - { |
|
| 21 | - |
|
| 22 | - switch ( $field['type'] ) |
|
| 23 | - { |
|
| 24 | - case 'text': |
|
| 25 | - echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 26 | - break; |
|
| 27 | - case 'number': |
|
| 28 | - echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 29 | - break; |
|
| 30 | - case 'date': |
|
| 31 | - echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 32 | - break; |
|
| 33 | - case 'datetime': |
|
| 34 | - echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 35 | - break; |
|
| 36 | - case 'time': |
|
| 37 | - echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 38 | - break; |
|
| 39 | - case 'textarea': |
|
| 40 | - echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
| 41 | - break; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - } ); |
|
| 45 | - } |
|
| 46 | - } ); |
|
| 8 | + $sizes = [ |
|
| 9 | + 's' => 12, |
|
| 10 | + 'm' => 6, |
|
| 11 | + 'l' => 4 |
|
| 12 | + ]; |
|
| 13 | + echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
| 14 | + { |
|
| 15 | + |
|
| 16 | + foreach ( $fields as $field ) |
|
| 17 | + { |
|
| 18 | + |
|
| 19 | + echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
| 20 | + { |
|
| 21 | + |
|
| 22 | + switch ( $field['type'] ) |
|
| 23 | + { |
|
| 24 | + case 'text': |
|
| 25 | + echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 26 | + break; |
|
| 27 | + case 'number': |
|
| 28 | + echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 29 | + break; |
|
| 30 | + case 'date': |
|
| 31 | + echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 32 | + break; |
|
| 33 | + case 'datetime': |
|
| 34 | + echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 35 | + break; |
|
| 36 | + case 'time': |
|
| 37 | + echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 38 | + break; |
|
| 39 | + case 'textarea': |
|
| 40 | + echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
| 41 | + break; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + } ); |
|
| 45 | + } |
|
| 46 | + } ); |
|
| 47 | 47 | } ); |
| 48 | 48 | ?> |
| 49 | 49 | |
@@ -10,34 +10,34 @@ |
||
| 10 | 10 | 'm' => 6, |
| 11 | 11 | 'l' => 4 |
| 12 | 12 | ]; |
| 13 | - echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
| 13 | + echo $uikit->column(['sizes' => $sizes], function() use ($uikit, $fields) |
|
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - foreach ( $fields as $field ) |
|
| 16 | + foreach ($fields as $field) |
|
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
| 19 | + echo $uikit->inputWrap(humanize($field['name']), NULL, function() use ($uikit, $field) |
|
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - switch ( $field['type'] ) |
|
| 22 | + switch ($field['type']) |
|
| 23 | 23 | { |
| 24 | 24 | case 'text': |
| 25 | - echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 25 | + echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 26 | 26 | break; |
| 27 | 27 | case 'number': |
| 28 | - echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 28 | + echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 29 | 29 | break; |
| 30 | 30 | case 'date': |
| 31 | - echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 31 | + echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 32 | 32 | break; |
| 33 | 33 | case 'datetime': |
| 34 | - echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 34 | + echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 35 | 35 | break; |
| 36 | 36 | case 'time': |
| 37 | - echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 37 | + echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 38 | 38 | break; |
| 39 | 39 | case 'textarea': |
| 40 | - echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
| 40 | + echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('".$field["name"]."') ?></textarea>\n"; |
|
| 41 | 41 | break; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -12,21 +12,21 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | if ($action == 'create') |
| 14 | 14 | { |
| 15 | - $up = "\$fields = {$fields}; |
|
| 15 | + $up = "\$fields = {$fields}; |
|
| 16 | 16 | |
| 17 | 17 | \$this->dbforge->add_field(\$fields); |
| 18 | 18 | "; |
| 19 | 19 | |
| 20 | - if (! empty($primary_key)) |
|
| 21 | - { |
|
| 22 | - $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
|
| 20 | + if (! empty($primary_key)) |
|
| 21 | + { |
|
| 22 | + $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
|
| 23 | 23 | "; |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 26 | + $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 27 | 27 | "; |
| 28 | 28 | |
| 29 | - $down = "\$this->dbforge->drop_table('{$table}');"; |
|
| 29 | + $down = "\$this->dbforge->drop_table('{$table}');"; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /* |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | if ($action == 'add' && ! empty($column)) |
| 36 | 36 | { |
| 37 | - $up = "\$field = {$column_string}; |
|
| 37 | + $up = "\$field = {$column_string}; |
|
| 38 | 38 | \$this->dbforge->add_column('{$table}', \$field);"; |
| 39 | 39 | |
| 40 | - $down = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
| 40 | + $down = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /* |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | if ($action == 'remove' && ! empty($column)) |
| 47 | 47 | { |
| 48 | - $up = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
| 48 | + $up = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
| 49 | 49 | |
| 50 | - $down = "\$field = {$column_string}; |
|
| 50 | + $down = "\$field = {$column_string}; |
|
| 51 | 51 | \$this->dbforge->add_column('{$table}', \$field);"; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | \$this->dbforge->add_field(\$fields); |
| 18 | 18 | "; |
| 19 | 19 | |
| 20 | - if (! empty($primary_key)) |
|
| 20 | + if ( ! empty($primary_key)) |
|
| 21 | 21 | { |
| 22 | 22 | $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
| 23 | 23 | "; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 26 | + $up .= " \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 27 | 27 | "; |
| 28 | 28 | |
| 29 | 29 | $down = "\$this->dbforge->drop_table('{$table}');"; |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | 33 | $descriptions = [ |
| 34 | - 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
| 34 | + 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
| 35 | 35 | ]; |
| 36 | 36 | |
| 37 | 37 | $long_description = <<<EOT |