Development

Changeset 6377

You must first sign up to be able to contribute.

Changeset 6377

Show
Ignore:
Timestamp:
12/07/07 21:14:08 (9 months ago)
Author:
Josh.Reynolds
Message:

some debugging and added _compressSelectors method on csOopCss object to find exact matches in styles and combine for more streamlined output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/csOopCssPlugin/trunk/lib/BasecsOopCss.class.php

    r6344 r6377  
    4040      $this->_selectors[$args[0]] = $selector; 
    4141      return true; 
     42    } 
     43    if(is_array($args[0])) 
     44    { 
     45      $selector = new csOopCssSelector(implode(', ', $args[0])); 
     46      foreach($args[0] as $s) 
     47      { 
     48        $this->_selectors[$args[0]] = $selector; 
     49      } 
    4250    } 
    4351    elseif(get_class($args[0]) == 'csOopCssSelector') 
     
    94102  public function __toString() 
    95103  { 
     104    $this->_compressSelectors(); 
    96105    return implode("\n\n", $this->_selectors); 
     106  } 
     107   
     108  protected function _compressSelectors() 
     109  { 
     110    $selectors = array(); 
     111    $catalog = array(); 
     112    foreach($this->_selectors as $s) 
     113    { 
     114      $key = array_search($s->stylesToString(), $catalog); 
     115      if(is_string($key)) 
     116      { 
     117        $old_key = $key; 
     118        $key .= ", ".$s->getSelector(); 
     119        $s->setSelector($key); 
     120        $selectors[$key] = $s; 
     121        unset($selectors[$old_key]); 
     122      } 
     123      else 
     124      { 
     125        $selectors[$s->getSelector()] = $s; 
     126        $catalog[$s->getSelector()] = $s->stylesToString(); 
     127      } 
     128    } 
     129    $this->_selectors = $selectors; 
    97130  } 
    98131} 
  • plugins/csOopCssPlugin/trunk/lib/BasecsOopCssSelector.class.php

    r6344 r6377  
    2727    $args = func_get_args(); 
    2828    $this->_selector = ($args[0] != null) ? $args[0] : null; 
     29  } 
     30   
     31  public function setSelector($value='') 
     32  { 
     33    $this->_selector = $value; 
    2934  } 
    3035   
     
    97102  public function __toString() 
    98103  { 
    99     $out = $this->_selector." {\n"; 
     104    if($this->_selector != null) 
     105    { 
     106      $out = $this->_selector." {\n"; 
     107      $out .= $this->stylesToString(); 
     108      $out .= "}"; 
     109      return $out; 
     110    } 
     111    else 
     112    { 
     113      return ''; 
     114    } 
     115  } 
     116   
     117  public function stylesToString() 
     118  { 
     119    $out = ''; 
    100120    foreach($this->_styles as $s) 
    101121    { 
    102122      $out .= $s."\n"; 
    103123    } 
    104     $out .= "}"; 
    105124    return $out; 
    106125  }