Source for file Html.php
Documentation is available at Html.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see http://nettephp.com
- 12: *
- 18: */
- 26: /**
- 27: * HTML helper.
- 28: *
- 29: * <code>
- 30: * $anchor = Html::el('a')->href($link)->setText('Nette');
- 31: * $el->class = 'myclass';
- 32: * echo $el;
- 33: *
- 34: * echo $el->startTag(), $el->endTag();
- 35: * </code>
- 36: *
- 40: */
- 42: {
- 59: public static $emptyElements = array('img'=>1,'hr'=>1,'br'=>1,'input'=>1,'meta'=>1,'area'=>1,'command'=>1,'keygen'=>1,'source'=>1,
- 60: 'base'=>1,'col'=>1,'link'=>1,'param'=>1,'basefont'=>1,'frame'=>1,'isindex'=>1,'wbr'=>1,'embed'=>1);
- 64: /**
- 65: * Static factory.
- 69: */
- 71: {
- 81: }
- 84: preg_match_all('#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i', $parts[1] . ' ', $parts, PREG_SET_ORDER);
- 87: }
- 88: }
- 91: }
- 95: /**
- 96: * Changes element's name.
- 101: */
- 103: {
- 106: }
- 111: }
- 115: /**
- 116: * Returns element's name.
- 118: */
- 120: {
- 122: }
- 126: /**
- 127: * Is element empty?
- 129: */
- 131: {
- 133: }
- 137: /**
- 138: * Overloaded setter for element's attribute.
- 142: */
- 144: {
- 146: }
- 150: /**
- 151: * Overloaded getter for element's attribute.
- 154: */
- 156: {
- 158: }
- 162: /**
- 163: * Overloaded unsetter for element's attribute.
- 166: */
- 168: {
- 170: }
- 174: /**
- 175: * Overloaded setter for element's attribute.
- 179: */
- 181: {
- 191: }
- 192: }
- 205: }
- 208: }
- 212: /**
- 213: * Special setter for element's attribute.
- 217: */
- 219: {
- 223: }
- 226: }
- 230: /**
- 231: * Sets element's HTML content.
- 235: */
- 237: {
- 246: }
- 251: }
- 255: /**
- 256: * Gets element's textual content.
- 258: */
- 260: {
- 265: }
- 267: }
- 271: /**
- 272: * Sets element's textual content.
- 276: */
- 278: {
- 281: }
- 283: }
- 287: /**
- 289: */
- 291: {
- 293: }
- 297: /**
- 298: * Adds new element's child.
- 301: */
- 303: {
- 305: }
- 309: /**
- 310: * Creates and adds a new Html child.
- 314: */
- 316: {
- 319: }
- 323: /**
- 324: * Inserts child node.
- 330: */
- 332: {
- 339: }
- 343: }
- 346: }
- 350: /**
- 351: * Inserts (replaces) child node (\ArrayAccess implementation).
- 355: */
- 357: {
- 359: }
- 363: /**
- 364: * Returns child node (\ArrayAccess implementation).
- 367: */
- 369: {
- 371: }
- 375: /**
- 376: * Exists child node? (\ArrayAccess implementation).
- 379: */
- 381: {
- 383: }
- 387: /**
- 388: * Removes child node (\ArrayAccess implementation).
- 391: */
- 393: {
- 396: }
- 397: }
- 401: /**
- 402: * Required by the \Countable interface.
- 404: */
- 406: {
- 408: }
- 412: /**
- 413: * Removed all children.
- 415: */
- 417: {
- 419: }
- 423: /**
- 424: * Iterates over a elements.
- 428: */
- 430: {
- 432: $deep = $deep > 0 ? RecursiveIteratorIterator::SELF_FIRST : RecursiveIteratorIterator::CHILD_FIRST;
- 437: }
- 438: }
- 442: /**
- 443: * Returns all of children.
- 444: * return array
- 445: */
- 447: {
- 449: }
- 453: /**
- 454: * Renders element's start tag, content and end tag.
- 457: */
- 459: {
- 462: // empty elements are finished now
- 465: }
- 467: // add content
- 470: }
- 476: }
- 477: }
- 479: // add end tag
- 482: return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));
- 483: }
- 485: }
- 490: {
- 492: }
- 496: /**
- 497: * Returns element's start tag.
- 499: */
- 501: {
- 503: return '<' . $this->name . $this->attributes() . (self::$xhtml && $this->isEmpty ? ' />' : '>');
- 507: }
- 508: }
- 512: /**
- 513: * Returns element's end tag.
- 515: */
- 517: {
- 519: }
- 523: /**
- 524: * Returns element's attributes.
- 526: */
- 528: {
- 531: }
- 535: {
- 536: // skip NULLs and false boolean attributes
- 539: // true boolean attribute
- 541: // in XHTML must use unminimized form
- 543: // in HTML should use minimized form
- 549: // prepare into temporary array
- 552: // skip NULLs & empty string; composite 'style' vs. 'others'
- 555: // composite 'style' vs. 'others'
- 557: }
- 564: }
- 566: // add new attribute
- 568: . str_replace(array('&', '"', '<', '>', '@'), array('&', '"', '<', '>', '@'), $value)
- 570: }
- 572: }
- 576: /**
- 577: * Clones all children too.
- 578: */
- 580: {
- 584: }
- 585: }
- 586: }
- 588: }
- 592: /**
- 593: * Recursive HTML element iterator. See Html::getIterator().
- 594: *
- 598: */
- 600: {
- 602: /**
- 603: * The sub-iterator for the current element.
- 605: */
- 607: {
- 609: }
- 613: /**
- 614: * Returns the count of elements.
- 616: */
- 618: {
- 620: }
- 622: }