| 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 | else |
|---|
| | 265 | { |
|---|
| | 266 | // If '-*' is not found and there are items in the current view's stylesheet array |
|---|
| | 267 | // loop through each one and see if there are any values that start with '-'. |
|---|
| | 268 | // If so, we add store the actual stylesheet name to the $delete array to be used below |
|---|
| | 269 | foreach ($stylesheets as $stylesheet) |
|---|
| | 270 | { |
|---|
| | 271 | if (!is_array($stylesheet)) |
|---|
| | 272 | { |
|---|
| | 273 | if (substr($stylesheet, 0, 1) == '-') |
|---|
| | 274 | { |
|---|
| | 275 | $delete[] = substr($stylesheet, 1); |
|---|
| | 276 | } |
|---|
| | 277 | } |
|---|
| | 278 | } |
|---|
| | 279 | } |
|---|
| | 280 | |
|---|
| | 281 | // 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); |
|---|
| | 289 | |
|---|
| | 290 | // If $delete_all is true, a '-*' was found above. |
|---|
| | 291 | // We remove all stylesheets from the array EXCEPT those specified in the $omit array |
|---|
| | 292 | if ($delete_all == true) |
|---|
| | 293 | { |
|---|
| | 294 | if (!in_array($key, $omit)) |
|---|
| | 295 | { |
|---|
| | 296 | unset($stylesheets[$index]); |
|---|
| | 297 | } |
|---|
| | 298 | } |
|---|
| | 299 | else |
|---|
| | 300 | { |
|---|
| | 301 | // Loop through the $delete array and see if the stylesheet name is in the array |
|---|
| | 302 | // We check for both the stylesheet and the -stylesheet. If found, we remove them. |
|---|
| | 303 | foreach ($delete as $value) |
|---|
| | 304 | { |
|---|
| | 305 | if ($key == $value OR substr($key, 1) == $value) |
|---|
| | 306 | { |
|---|
| | 307 | unset($stylesheets[$index]); |
|---|
| | 308 | } |
|---|
| | 309 | } |
|---|
| | 310 | } |
|---|
| | 311 | } |
|---|
| | 339 | $omit = array(); |
|---|
| | 340 | $delete_all = false; |
|---|
| | 341 | |
|---|
| | 342 | // Populate $javascripts with the values from ONLY the current view |
|---|
| | 343 | $javascripts = $this->getConfigValue('javascripts', $viewName); |
|---|
| | 344 | |
|---|
| | 345 | // If we find results from the view, check to see if there is a '-*' |
|---|
| | 346 | // This indicates that we will remove ALL javascripts EXCEPT for those passed in the current view |
|---|
| | 347 | if (is_array($javascripts) AND in_array('-*', $javascripts)) |
|---|
| | 348 | { |
|---|
| | 349 | $delete_all = true; |
|---|
| | 350 | foreach ($javascripts as $javascript) |
|---|
| | 351 | { |
|---|
| | 352 | if (substr($javascript, 0, 1) != '-') |
|---|
| | 353 | { |
|---|
| | 354 | $omit[] = $javascript; |
|---|
| | 355 | } |
|---|
| | 356 | } |
|---|
| | 357 | } |
|---|
| | 358 | |
|---|