Source for file 09.php

Documentation is available at 09.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. import('sylar.common.locale.Language');
  42. import('sylar.presentation.html.HtmlPage');
  43.  
  44.  
  45. try{
  46. // Prepare Head and Body
  47. $oHH = new Sylar_HtmlHead("Giano Locale Test page");
  48. $oHH->addMetaTag("text/html; charset=".APP_DEFAULT_CHARSET, null, "content-type");
  49. $oHH->addMetaTag("Brdp - Giano Solutions", "Author");
  50. $oHH->addMetaTag("Sylar, Example App", "Keywords");
  51. $oHH->addMetaTag("width=1024", "viewport");
  52. $oHH->addMetaTag("no-cache", null, "pragma");
  53. $oHH->setAppCssUrlRoot(APP_LAYOUT_CSS_URL_ROOT);
  54. $oHH->addApplicationStyle("mainGiano.css");
  55. $oHH->setAppJsUrlRoot(APP_JAVASCRIPT_URL_ROOT);
  56. $oHH->addApplicationJavascript("mainGiano.js");
  57.  
  58. // prepare Body
  59. $oHB = new Sylar_HtmlBody();
  60. // try to switch locale
  61. $LocaleDef->switchToStandardSetting(APP_DEFAULT_LOCALE);
  62. // Prepare Language engine
  63. $oLang = new Sylar_Language($LocaleDef);
  64. // Load two dictionaries from sylar Dict
  65. $oLang->loadSylarDictionary("main");
  66. $oLang->loadSylarDictionary("example");
  67. // Set Locale Application repository root
  68. $oLang->setApplicationLocaleRootFs(APP_LOCALE_ROOT_FS);
  69. // Load an example dict file from App repository
  70. $oLang->loadApplicationDictionary("main");
  71. // Create a DIV
  72. $div = new Sylar_HtmlDiv("test");
  73. $txt = "<br><br><i>Some Correct Test from Sylar Dict</i>: <u>".$oLang->provideText("Sylar_WorkFine")."</u>";
  74. $txt .= "<br><br><i>Incorrect Test example</i>: <u>".$oLang->provideText("Inexistent_lable_example")."</u>";
  75. $txt .= "<br><br><i>Some test from second Sylar Dict</i>: <u>".$oLang->provideText("Sylar_WorkFine2")."</u>";
  76. $txt .= "<br><br><i>Some text from an Application Dict</i>: <u>".$oLang->provideText("App_Desc")."</u>";
  77. $txt .= "<br><br><i>Dinamic text from an Application Dict with dinamic and multiple replace</i>: <u>".$oLang->provideText("App_Welcome", array(12, "Gianluca Giusti"))."</u>";
  78. $txt .= "<br><br><br><br><a href='10.php'>Cookie example &raquo;</a>";
  79. // add div content
  80. $div->appendContent($txt);
  81. // append div in the body
  82. $oHB->addDiv($div);
  83. // Then Push into the page Object
  84. $oHP = new Sylar_HtmlPage();
  85. $oHP->setPageHead($oHH);
  86. $oHP->setPageBody($oHB);
  87. // render Html Page
  88. $oHP->show();
  89.  
  90. } catch (ExceptionInSylar $ex){
  91. echo $ex->getMessage();
  92. }
  93.  
  94.  
  95. ?>

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