| 242 | | |
|---|
| | 242 | $omit = array(); |
|---|
| | 243 | $delete = array(); |
|---|
| | 244 | $delete_all = false; |
|---|
| | 245 | |
|---|
| | 246 | // Populate $stylesheets with the values from ONLY the current view |
|---|
| | 247 | $stylesheets = $this->getConfigValue('stylesheets', $viewName); |
|---|
| | 248 | |
|---|
| | 249 | // If we find results from the view, check to see if there is a '-*' |
|---|
| | 250 | // This indicates that we will remove ALL stylesheets EXCEPT for those passed in the current view |
|---|
| | 251 | if (is_array($stylesheets) AND in_array('-*', $stylesheets)) |
|---|
| | 252 | { |
|---|
| | 253 | $delete_all = true; |
|---|
| | 254 | foreach ($stylesheets as $stylesheet) |
|---|
| | 255 | { |
|---|
| | 256 | $key = is_array($stylesheet) ? key($stylesheet) : $stylesheet; |
|---|
| | 257 | |
|---|
| | 258 | if ($key != '-*') |
|---|
| | 259 | { |
|---|
| | 260 | $omit[] = $key; |
|---|
| | 261 | } |
|---|
| | 262 | } |
|---|
| | 263 | } |
|---|
| | 264 | |
|---|
| | 265 | // If '-*' is not found and there are items in the current view's stylesheet array |
|---|
| | 266 | // loop through each one and see if there are any values that start with '-'. |
|---|
| | 267 | // If so, we add store the actual stylesheet name to the $delete array to be used below |
|---|
| | 268 | else |
|---|
| | 269 | { |
|---|
| | 270 | foreach ($stylesheets as $stylesheet) |
|---|
| | 271 | { |
|---|
| | 272 | if (!is_array($stylesheet)) |
|---|
| | 273 | { |
|---|
| | 274 | if (substr($stylesheet, 0, 1) == '-') |
|---|
| | 275 | { |
|---|
| | 276 | $delete[] = substr($stylesheet, 1); |
|---|
| | 277 | } |
|---|
| | 278 | } |
|---|
| | 279 | } |
|---|
| | 280 | } |
|---|
| | 281 | |
|---|
| | 282 | // Merge the current view's stylesheets with the app's default stylesheets |
|---|
| 251 | | if (substr($key, 0, 1) == '-') |
|---|
| 252 | | { |
|---|
| 253 | | $delete[] = $key; |
|---|
| 254 | | $delete[] = substr($key, 1); |
|---|
| 255 | | } |
|---|
| 256 | | } |
|---|
| 257 | | $stylesheets = array_diff($stylesheets, $delete); |
|---|
| | 290 | |
|---|
| | 291 | // If $delete_all is true, a '-*' was found above. |
|---|
| | 292 | // We remove all stylesheets from the array EXCEPT those specified in the $omit array |
|---|
| | 293 | if ($delete_all == true) |
|---|
| | 294 | { |
|---|
| | 295 | if (!in_array($key, $omit)) |
|---|
| | 296 | { |
|---|
| | 297 | unset($stylesheets[$index]); |
|---|
| | 298 | } |
|---|
| | 299 | } |
|---|
| | 300 | else |
|---|
| | 301 | { |
|---|
| | 302 | // Loop through the $delete array and see if the stylesheet name is in the array |
|---|
| | 303 | // We check for both the stylesheet and the -stylesheet. If found, we remove them. |
|---|
| | 304 | foreach ($delete as $value) |
|---|
| | 305 | { |
|---|
| | 306 | if ($key == $value OR substr($key, 1) == $value) |
|---|
| | 307 | { |
|---|
| | 308 | unset($stylesheets[$index]); |
|---|
| | 309 | } |
|---|
| | 310 | } |
|---|
| | 311 | } |
|---|
| | 312 | } |
|---|