Changeset 6377
- Timestamp:
- 12/07/07 21:14:08 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/csOopCssPlugin/trunk/lib/BasecsOopCss.class.php
r6344 r6377 40 40 $this->_selectors[$args[0]] = $selector; 41 41 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 } 42 50 } 43 51 elseif(get_class($args[0]) == 'csOopCssSelector') … … 94 102 public function __toString() 95 103 { 104 $this->_compressSelectors(); 96 105 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; 97 130 } 98 131 } plugins/csOopCssPlugin/trunk/lib/BasecsOopCssSelector.class.php
r6344 r6377 27 27 $args = func_get_args(); 28 28 $this->_selector = ($args[0] != null) ? $args[0] : null; 29 } 30 31 public function setSelector($value='') 32 { 33 $this->_selector = $value; 29 34 } 30 35 … … 97 102 public function __toString() 98 103 { 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 = ''; 100 120 foreach($this->_styles as $s) 101 121 { 102 122 $out .= $s."\n"; 103 123 } 104 $out .= "}";105 124 return $out; 106 125 }