Development

Changeset 1446

You must first sign up to be able to contribute.

Changeset 1446

Show
Ignore:
Timestamp:
06/14/06 21:51:36 (2 years ago)
Author:
slickrick
Message:

* Added the ability to remove all javaScripts at once via [-*]
Note: Kept array_diff() separation method for JS since they do not have parameters.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/slickrick/lib/config/sfViewConfigHandler.class.php

    r1445 r1446  
    254254    foreach ($stylesheets as $stylesheet) 
    255255    { 
    256     $key = is_array($stylesheet) ? key($stylesheet) : $stylesheet; 
     256      $key = is_array($stylesheet) ? key($stylesheet) : $stylesheet; 
    257257       
    258258      if ($key != '-*') 
    259259      { 
    260260        $omit[] = $key; 
    261    
     261     
    262262    } 
    263263  } 
     
    270270    foreach ($stylesheets as $stylesheet) 
    271271    { 
    272     if (!is_array($stylesheet)) 
    273    
     272      if (!is_array($stylesheet)) 
     273     
    274274        if (substr($stylesheet, 0, 1) == '-') 
    275275        { 
    276276        $delete[] = substr($stylesheet, 1); 
    277277        } 
    278    
     278     
    279279    } 
    280280  } 
     
    295295          if (!in_array($key, $omit)) 
    296296          { 
    297           unset($stylesheets[$index]); 
     297            unset($stylesheets[$index]); 
    298298          } 
    299299        } 
     
    304304          foreach ($delete as $value) 
    305305          { 
    306           if ($key == $value OR substr($key, 1) == $value) 
    307          
     306            if ($key == $value OR substr($key, 1) == $value) 
     307           
    308308              unset($stylesheets[$index]); 
    309          
     309           
    310310          } 
    311311        } 
     
    338338    } 
    339339 
     340     
     341    $omit = array(); 
     342    $delete_all = false; 
     343     
     344    // Populate $javascripts with the values from ONLY the current view 
     345    $javascripts = $this->getConfigValue('javascripts', $viewName); 
     346     
     347    // If we find results from the view, check to see if there is a '-*' 
     348    // This indicates that we will remove ALL javascripts EXCEPT for those passed in the current view 
     349  if (is_array($javascripts) AND in_array('-*', $javascripts)) 
     350  { 
     351    $delete_all = true; 
     352    foreach ($javascripts as $javascript) 
     353    {      
     354      if (substr($javascript, 0, 1) != '-') 
     355      { 
     356        $omit[] = $javascript; 
     357      } 
     358    } 
     359  }     
     360     
    340361    $javascripts = $this->mergeConfigValue('javascripts', $viewName); 
    341362    if (is_array($javascripts)) 
    342363    { 
    343364      // remove javascripts marked with a beginning '-' 
     365      // We exclude any javascripts that were omitted above 
    344366      $delete = array(); 
     367       
    345368      foreach ($javascripts as $javascript) 
    346369      { 
    347         if (substr($javascript, 0, 1) == '-'
     370        if (!in_array($javascript, $omit) && (substr($javascript, 0, 1) == '-' || $delete_all == true)
    348371        { 
    349372          $delete[] = $javascript;