Source for file HtmlBody.php

Documentation is available at HtmlBody.php

  1. <?php
  2. /*
  3. * This file is part of Sylar.
  4. *
  5. * Sylar is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Sylar is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with Sylar. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * @copyright Copyright Sylar Development Team
  19. * @license http://www.gnu.org/licenses/ GNU Public License V2.0
  20. * @see https://launchpad.net/sylar/
  21. * @see http://www.giano-solutions.com
  22. */
  23.  
  24.  
  25.  
  26. import('sylar.presentation.html.Html');
  27. import('sylar.presentation.html.HtmlDiv');
  28.  
  29. /**
  30. * Html Body Element
  31. *
  32. * This object containes DIV object that will compose the Html page.
  33. * Css and Style will care about layout
  34. *
  35. * @package Sylar
  36. * @version 1.0
  37. * @since 31/mar/08
  38. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  39. * @copyright Sylar Development Team
  40. */
  41. class Sylar_HtmlBody extends Sylar_Html{
  42. // An array of Sylar_HtmlDiv
  43. private $aDivArchive;
  44. function __construct(){
  45. // Inizialize the array
  46. $this->aDivArchive = array();
  47. }
  48. function __destruct(){
  49. // nothing to do at the moment
  50. }
  51.  
  52. // Public Methods
  53. //__________________________________________________________________________
  54. /**
  55. * Add a Div to Body
  56. *
  57. * @see Sylar_HtmlDiv
  58. *
  59. * @return void
  60. * @param Sylar_HtmlDiv $oDiv the object with Div information and content
  61. */
  62. public function addDiv(Sylar_HtmlDiv $oDiv){
  63. if($oDiv != null){
  64. $this->aDivArchive[] = $oDiv;
  65. }
  66. }
  67. /**
  68. * return the Html source
  69. * it return html code of entire object
  70. *
  71. * @return string
  72. */
  73. public function getHtmlSource(){
  74. return $this->render();
  75. }
  76. /**
  77. * Display the page
  78. * it prints the object Html source on screen
  79. *
  80. * @return void
  81. */
  82. public function show(){
  83. echo $this->render();
  84. }
  85. // Protected Methods
  86. //__________________________________________________________________________
  87. /**
  88. * Design Html BODY tag
  89. * it push all div in the body and prepare html code
  90. *
  91. * @return string
  92. */
  93. protected function render(){
  94. $sTagHtml = "\n<body>\n";
  95. // Floating Style in the page <style> #classname: etc... </style>
  96. foreach ($this->aDivArchive as $val) {
  97. $sTagHtml .= "\n\t".$val->getHtmlSource();
  98. }
  99. $sTagHtml .= "\n\n</body>";
  100. return $sTagHtml;
  101. }
  102. }
  103. ?>

Documentation generated on Thu, 24 Apr 2008 16:14:14 +0200 by phpDocumentor 1.3.0RC3