Ejemplo n.º 1
0
 private function _mergeLayers($sShorthand, $aLayers, $aOldProperties, $bImportant)
 {
     $this->styleDeclaration->remove($aOldProperties);
     $oNewValueList = new PropertyValueList(array(), ',');
     foreach ($aLayers as $aValues) {
         $oLayerValueList = new PropertyValueList($aValues, ' ');
         $oNewValueList->append($oLayerValueList);
     }
     $oNewProperty = new Property($sShorthand, $oNewValueList);
     $oNewProperty->setIsImportant($bImportant);
     $this->styleDeclaration->append($oNewProperty);
 }
Ejemplo n.º 2
0
 /**
  * Reduces a list of values into a PropertyValueList object
  *
  * @param array $values a list of values
  * @param array $delimiters a list of delimiters by order of precedence
  **/
 protected static function reduceValueList(array $values, $delimiters = array(' ', ',', '/'))
 {
     /*{{{*/
     if (count($values) === 1) {
         return $values[0];
     }
     foreach ($delimiters as $delim) {
         $start = null;
         while (false !== ($start = array_search($delim, $values, true))) {
             $length = 2;
             //Number of elements to be joined
             for ($i = $start + 2; $i < count($values); $i += 2) {
                 if ($delim !== $values[$i]) {
                     break;
                 }
                 $length++;
             }
             $value_list = new PropertyValueList(array(), $delim);
             for ($i = $start - 1; $i - $start + 1 < $length * 2; $i += 2) {
                 $value_list->append($values[$i]);
             }
             array_splice($values, $start - 1, $length * 2 - 1, array($value_list));
         }
     }
     return $values[0];
 }