@@ -403,6 +403,34 @@ private function consumeUntil($sEnd) {
403
403
private function inputLeft () {
404
404
return mb_substr ($ this ->sText , $ this ->iCurrentPosition , -1 , $ this ->sCharset );
405
405
}
406
+
407
+ /**
408
+ * Appends a string to the sText CSS string.
409
+ * This allows you to add multiple strings before parsing
410
+ * @param string $sText
411
+ *
412
+ * @author dschaefer
413
+ * @since 12/30/2010
414
+ *
415
+ * @example $CSSParser = new CSSParser(file_get_contents("css/default.css"));
416
+ * $CSSParser->append(file_get_contents("css/custom.css"));
417
+ */
418
+ public function append ($ sText , $ sCharest =NULL ){
419
+ if (!isset ($ sCharest )){ $ sCharest = $ this ->sCharset ; }
420
+ $ this ->sText .= $ sText ;
421
+ $ this ->setCharset ($ sCharest );
422
+ }
423
+
424
+ /**
425
+ * Simply returns the private $sText variable
426
+ * @return string
427
+ *
428
+ * @author dschaefer
429
+ * @since 12/30/2010
430
+ */
431
+ public function getContents (){
432
+ return $ this ->sText ;
433
+ }
406
434
}
407
435
408
436
abstract class CSSList {
@@ -472,18 +500,27 @@ protected function allValues($oElement, &$aResult, $sSearchString = null) {
472
500
* are multiple selectors in the rule set, then each one will
473
501
* have their own array element.
474
502
*
503
+ * Fixed Bug: The CSSSelector->aSelector is not being set correctly
504
+ *
475
505
* @param array $aResult
476
506
*
477
- * @author dschaefer 12/23/2010
507
+ * @author dschaefer
508
+ * @since 12/23/2010
478
509
*/
479
510
protected function allUniqueRuleSets (&$ aResult ){
480
- foreach ($ this ->aContents as $ mContent ) {
511
+ foreach ($ this ->aContents as $ mContent ){
481
512
if ($ mContent instanceof CSSRuleSet) {
482
- foreach ($ mContent ->getSelector () as $ aSelector ){
483
- $ aResult [$ aSelector ] = $ mContent ;
513
+ foreach ($ mContent ->getSelector () as $ sSelector ){
514
+ if (!isset ($ aResult [$ sSelector ])){
515
+ $ aResult [$ sSelector ] = new CSSSelector ();
516
+ }
517
+ $ aResult [$ sSelector ]->setSelector ($ sSelector );
518
+ foreach ($ mContent ->getRules () as $ oRule ){
519
+ $ aResult [$ sSelector ]->addRule ($ oRule );
520
+ }
484
521
}
485
522
} else if ($ mContent instanceof CSSList) {
486
- $ mContent ->allRuleSets ($ aResult );
523
+ $ mContent ->allUniqueRuleSets ($ aResult );
487
524
}
488
525
}
489
526
}
0 commit comments