Exemplo n.º 1
0
 /**
  * Extend like function to merge an array of preferences into
  * the options array.
  *
  * @param (mixed) options: Array of preferences to merge into options
  */
 public function merge($options = array())
 {
     $modes = CSSCompression::modes();
     if ($options && is_array($options) && count($options)) {
         $this->Control->mode = $this->custom;
         foreach ($this->options as $key => $value) {
             if (!isset($options[$key])) {
                 continue;
             } else {
                 if (strtolower($options[$key]) == 'on') {
                     $this->options[$key] = true;
                 } else {
                     if (strtolower($options[$key]) == 'off') {
                         $this->options[$key] = false;
                     } else {
                         $this->options[$key] = intval($options[$key]);
                     }
                 }
             }
         }
     } else {
         if ($options && is_string($options) && array_key_exists($options, $modes)) {
             $this->Control->mode = $options;
             // Default all to true, the mode has to force false
             foreach ($this->options as $key => $value) {
                 if ($key != 'readability') {
                     $this->options[$key] = true;
                 }
             }
             // Merge mode into options
             foreach ($modes[$options] as $key => $value) {
                 $this->options[$key] = $value;
             }
         }
     }
     return $this->options;
 }