Source for file 07.php

Documentation is available at 07.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. * Example Sylar File
  26. * Some files that shows how sylar works
  27. *
  28. * @package Sylar
  29. * @version 1.0
  30. * @since 02-2008
  31. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  32. * @copyright Sylar Development Team
  33. */
  34.  
  35. #
  36. # Include the bas Application settings
  37. #
  38.  
  39. require_once 'config/appConfig.php';
  40.  
  41.  
  42.  
  43. import('sylar.presentation.html.HtmlPage');
  44.  
  45. try{
  46. // Define the needed object: Page, Head and Body
  47. //
  48. $oHp = new Sylar_HtmlPage();
  49. $oHd = new Sylar_HtmlHead();
  50. $oHb = new Sylar_HtmlBody();
  51. // In the head set Page title
  52. $oHd->setPageTitle("Sylar Formatting Page Example!");
  53. // In the head add some Meta tag
  54. $oHd->addMetaTag("text/html; charset=utf-8", null, "content-type");
  55. $oHd->addMetaTag("width=1024", "viewport");
  56. $oHd->addMetaTag("Brdp 4 Sylar", "Author");
  57. // in the head import some Js files...
  58. $oHd->addSylarJavascript("test.js");
  59. // in the head import CSS stylesheet files
  60. $oHd->addSylarStyle("test.css");
  61. // We can add in header also floating style in css
  62. $style = "
  63. #billboard { width: 981px; margin: 0 auto; overflow: hidden; position: relative; }
  64. #autoboard { width: 981px; margin: 0 auto; }
  65. ";
  66. $oHd->addFloatingStyle($style);
  67. // And also Javascript Floating code
  68. $script = "
  69. alert('Floating Script OK!');
  70. var fr = \"fr\";
  71. // etc etc ...
  72. ";
  73. $oHd->addFloatingJsScript($script);
  74. // THE HEADER IS OK! Now prepare the Body
  75. // Add some DIV in The body with different tag and different tag collections
  76. $oDiv = new Sylar_HtmlDiv();
  77. $oDiv->setContent("DIV..... 1");
  78. $oHb->addDiv($oDiv);
  79. $oDiv = new Sylar_HtmlDiv("My_ID");
  80. $oDiv->setContent("DIV..... 2");
  81. $oHb->addDiv($oDiv);
  82. $oDiv = new Sylar_HtmlDiv(null, "My_Name");
  83. $oDiv->setContent("DIV..... 3");
  84. $oHb->addDiv($oDiv);
  85. $oDiv = new Sylar_HtmlDiv(null, null, "My_Classe_CSS");
  86. $oDiv->setContent("DIV..... 4");
  87. $oHb->addDiv($oDiv);
  88. $oDiv = new Sylar_HtmlDiv(null, null, null, "My_Style");
  89. $oDiv->setContent("DIV..... 5");
  90. $oHb->addDiv($oDiv);
  91. // An example with all attributes
  92. $oDiv = new Sylar_HtmlDiv("My_ID", "My_Name", "My_Class", "My_Style");
  93. $oDiv->setContent("DIV..... 6");
  94. $oHb->addDiv($oDiv);
  95. // An example with all attributes
  96. $oDiv = new Sylar_HtmlDiv("ALERT");
  97. $msg = "<br>Remember! This is an example! Remember that you must always separe the presentation from the logic!";
  98. $msg .= "<br><br><a href='08.php'> Presentation and Logic &raquo;</a>";
  99. $oDiv->setContent($msg);
  100. $oHb->addDiv($oDiv);
  101. // also the BODY IS OK! NOW PUSH ALL IN THE PAGE.
  102. // Add head and body in the page
  103. $oHp->setPageHead($oHd);
  104. $oHp->setPageBody($oHb);
  105. // Then Render the HTML Page.
  106. $oHp->show();
  107.  
  108. } catch (ExceptionInSylar $ex){
  109. echo $ex->getMessage();
  110. }
  111.  
  112.  
  113. //Load in your browser and look at the source!
  114.  
  115. ?>

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