Index: trunk/extensions/Translate/utils/Html.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | * replaces the current value and the object itself is returned. This allows |
9 | 9 | * chaining calls. Noted as chain-accessor in the comments. Example: |
10 | 10 | * <code>$tag = new HtmlTag( 'div' ); $div = $div->content( 'foo' )->style( 'color', 'red' );</code> |
| 11 | + * Note: relies on implicit toString conversion (PHP >= 5.2) |
11 | 12 | */ |
12 | 13 | class HtmlTag { |
13 | 14 | public $tag = 'div'; |
— | — | @@ -121,6 +122,7 @@ |
122 | 123 | /** |
123 | 124 | * Returns the html output. Use this when you don't want to use |
124 | 125 | * implicit string conversion. |
| 126 | + * @return string html |
125 | 127 | */ |
126 | 128 | public function html() { |
127 | 129 | // Collapse styles |
— | — | @@ -135,10 +137,18 @@ |
136 | 138 | } |
137 | 139 | } |
138 | 140 | |
| 141 | + /** |
| 142 | + * Wrapper for html method, for implicit conversion to string. |
| 143 | + * @return string html |
| 144 | + */ |
139 | 145 | public function __toString() { |
140 | 146 | return $this->html(); |
141 | 147 | } |
142 | 148 | |
| 149 | + /** |
| 150 | + * Constructs the value for style parameter. |
| 151 | + * @return string The value for style parameter. |
| 152 | + */ |
143 | 153 | public function collapseStyles() { |
144 | 154 | $style = ''; |
145 | 155 | |
— | — | @@ -180,8 +190,12 @@ |
181 | 191 | |
182 | 192 | } |
183 | 193 | |
184 | | - |
| 194 | +/** |
| 195 | + * Class for passing data to HtmlTag. Useful when you already |
| 196 | + * have piece of html. |
| 197 | + */ |
185 | 198 | class RawHtml { |
| 199 | + /** Contents */ |
186 | 200 | public $data = ''; |
187 | 201 | |
188 | 202 | public function __construct( $data ) { |
— | — | @@ -193,6 +207,10 @@ |
194 | 208 | } |
195 | 209 | } |
196 | 210 | |
| 211 | +/** |
| 212 | + * Wrapper class which implements array properties. Useful for adding multiple |
| 213 | + * tags inside as contents of another tag. Items must be pre-escaped! |
| 214 | + */ |
197 | 215 | class TagContainer implements ArrayAccess { |
198 | 216 | public $tags = array(); |
199 | 217 | |