Source for file Html.php
Documentation is available at Html.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 11: */
- 15: /**
- 16: * HTML helper.
- 17: *
- 18: * <code>
- 19: * $anchor = Html::el('a')->href($link)->setText('Nette');
- 20: * $el->class = 'myclass';
- 21: * echo $el;
- 22: *
- 23: * echo $el->startTag(), $el->endTag();
- 24: * </code>
- 25: *
- 28: */
- 30: {
- 47: public static $emptyElements = array('img'=>1,'hr'=>1,'br'=>1,'input'=>1,'meta'=>1,'area'=>1,'command'=>1,'keygen'=>1,'source'=>1,
- 48: 'base'=>1,'col'=>1,'link'=>1,'param'=>1,'basefont'=>1,'frame'=>1,'isindex'=>1,'wbr'=>1,'embed'=>1);
- 52: /**
- 53: * Static factory.
- 57: */
- 59: {
- 69: }
- 72: preg_match_all('#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i', $parts[1] . ' ', $parts, PREG_SET_ORDER);
- 75: }
- 76: }
- 79: }
- 83: /**
- 84: * Changes element's name.
- 89: */
- 91: {
- 94: }
- 99: }
- 103: /**
- 104: * Returns element's name.
- 106: */
- 108: {
- 110: }
- 114: /**
- 115: * Is element empty?
- 117: */
- 119: {
- 121: }
- 125: /**
- 126: * Overloaded setter for element's attribute.
- 130: */
- 132: {
- 134: }
- 138: /**
- 139: * Overloaded getter for element's attribute.
- 142: */
- 144: {
- 146: }
- 150: /**
- 151: * Overloaded unsetter for element's attribute.
- 154: */
- 156: {
- 158: }
- 162: /**
- 163: * Overloaded setter for element's attribute.
- 167: */
- 169: {
- 179: }
- 180: }
- 193: }
- 196: }
- 200: /**
- 201: * Special setter for element's attribute.
- 205: */
- 207: {
- 211: }
- 214: }
- 218: /**
- 219: * Sets element's HTML content.
- 223: */
- 225: {
- 234: }
- 239: }
- 243: /**
- 244: * Returns element's HTML content.
- 246: */
- 248: {
- 255: }
- 256: }
- 258: }
- 262: /**
- 263: * Sets element's textual content.
- 267: */
- 269: {
- 272: }
- 274: }
- 278: /**
- 279: * Returns element's textual content.
- 281: */
- 283: {
- 285: }
- 289: /**
- 290: * Adds new element's child.
- 293: */
- 295: {
- 297: }
- 301: /**
- 302: * Creates and adds a new Html child.
- 306: */
- 308: {
- 311: }
- 315: /**
- 316: * Inserts child node.
- 322: */
- 324: {
- 331: }
- 335: }
- 338: }
- 342: /**
- 343: * Inserts (replaces) child node (\ArrayAccess implementation).
- 347: */
- 349: {
- 351: }
- 355: /**
- 356: * Returns child node (\ArrayAccess implementation).
- 359: */
- 361: {
- 363: }
- 367: /**
- 368: * Exists child node? (\ArrayAccess implementation).
- 371: */
- 373: {
- 375: }
- 379: /**
- 380: * Removes child node (\ArrayAccess implementation).
- 383: */
- 385: {
- 388: }
- 389: }
- 393: /**
- 394: * Required by the \Countable interface.
- 396: */
- 398: {
- 400: }
- 404: /**
- 405: * Removed all children.
- 407: */
- 409: {
- 411: }
- 415: /**
- 416: * Iterates over a elements.
- 420: */
- 422: {
- 424: $deep = $deep > 0 ? RecursiveIteratorIterator::SELF_FIRST : RecursiveIteratorIterator::CHILD_FIRST;
- 429: }
- 430: }
- 434: /**
- 435: * Returns all of children.
- 436: * return array
- 437: */
- 439: {
- 441: }
- 445: /**
- 446: * Renders element's start tag, content and end tag.
- 449: */
- 451: {
- 455: // add content
- 458: }
- 464: }
- 465: }
- 467: // add end tag
- 469: }
- 472: return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));
- 473: }
- 475: }
- 480: {
- 482: }
- 486: /**
- 487: * Returns element's start tag.
- 489: */
- 491: {
- 493: return '<' . $this->name . $this->attributes() . (self::$xhtml && $this->isEmpty ? ' />' : '>');
- 497: }
- 498: }
- 502: /**
- 503: * Returns element's end tag.
- 505: */
- 507: {
- 509: }
- 513: /**
- 514: * Returns element's attributes.
- 516: */
- 518: {
- 521: }
- 525: {
- 526: // skip NULLs and false boolean attributes
- 529: // true boolean attribute
- 531: // in XHTML must use unminimized form
- 533: // in HTML should use minimized form
- 539: // prepare into temporary array
- 542: // skip NULLs & empty string; composite 'style' vs. 'others'
- 545: // composite 'style' vs. 'others'
- 547: }
- 554: }
- 556: // add new attribute
- 558: . str_replace(array('&', '"', '<', '>', '@'), array('&', '"', '<', '>', '@'), $value)
- 560: }
- 562: }
- 566: /**
- 567: * Clones all children too.
- 568: */
- 570: {
- 574: }
- 575: }
- 576: }
- 578: }
- 582: /**
- 583: * Recursive HTML element iterator. See Html::getIterator().
- 584: *
- 587: */
- 589: {
- 591: /**
- 592: * The sub-iterator for the current element.
- 594: */
- 596: {
- 598: }
- 602: /**
- 603: * Returns the count of elements.
- 605: */
- 607: {
- 609: }
- 611: }