fix image text
[pear] / HTML / Less / Tree.php
1 <?php
2
3 /**
4  * Tree
5  *
6  * @package Less
7  * @subpackage tree
8  */
9 class HTML_Less_Tree {
10
11     public $cache_string;
12
13     public function toCSS() {
14         require_once 'HTML/Less/Output.php';
15         $output = new HTML_Less_Output();
16         $this->genCSS($output);
17         return $output->toString();
18     }
19
20     /**
21      * Generate CSS by adding it to the output object
22      *
23      * @param HTML_Less_Output $output The output
24      * @return void
25      */
26     public function genCSS($output) {
27         
28     }
29
30     /**
31      * @param HTML_Less_Tree_Ruleset[] $rules
32      */
33     public static function outputRuleset($output, $rules) {
34
35         $ruleCnt = count($rules);
36         
37         require_once 'HTML/Less/Environment.php';
38         require_once 'HTML/Less/Parser.php';
39         
40         HTML_Less_Environment::$tabLevel++;
41
42         // Compressed
43         if (HTML_Less_Parser::$options['compress']) {
44             $output->add('{');
45             for ($i = 0; $i < $ruleCnt; $i++) {
46                 $rules[$i]->genCSS($output);
47             }
48
49             $output->add('}');
50             HTML_Less_Environment::$tabLevel--;
51             return;
52         }
53
54
55         // Non-compressed
56         $tabSetStr = "\n" . str_repeat(HTML_Less_Parser::$options['indentation'], HTML_Less_Environment::$tabLevel - 1);
57         $tabRuleStr = $tabSetStr . HTML_Less_Parser::$options['indentation'];
58
59         $output->add(" {");
60         for ($i = 0; $i < $ruleCnt; $i++) {
61             $output->add($tabRuleStr);
62             $rules[$i]->genCSS($output);
63         }
64         HTML_Less_Environment::$tabLevel--;
65         $output->add($tabSetStr . '}');
66     }
67
68     public function accept($visitor) {
69         
70     }
71
72     public static function ReferencedArray($rules) {
73         foreach ($rules as $rule) {
74             if (method_exists($rule, 'markReferenced')) {
75                 $rule->markReferenced();
76             }
77         }
78     }
79
80     /**
81      * Requires php 5.3+
82      */
83     public static function __set_state($args) {
84
85         $class = get_called_class();
86         $obj = new $class(null, null, null, null);
87         foreach ($args as $key => $val) {
88             $obj->$key = $val;
89         }
90         return $obj;
91     }
92
93 }