Source for file LoginFormat.php

Documentation is available at LoginFormat.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. import('app.giano.presentation.Format');
  25. import('app.giano.logic.LoginEngine');
  26.  
  27.  
  28. /**
  29. * Tit File
  30. *
  31. * Desc File
  32. *
  33. * @package Sylar
  34. * @version 1.0
  35. * @since 03/apr/08
  36. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  37. * @copyright Sylar Development Team
  38. */
  39. class App_LoginFormat extends App_Format{
  40. function __construct(){
  41. parent::__construct();
  42. }
  43. function __destruct(){
  44. // nothing to do at the moment
  45. }
  46.  
  47. // Public Methods
  48. //__________________________________________________________________________
  49. public function makeLoginPage(){
  50. try{
  51. // Prepare Head and Body
  52. $oHH = parent::provideStandardHeader("Giano Login Page");
  53. $oHB = new Sylar_HtmlBody();
  54. // Controls if user is Loggedin or not
  55. $engine = new App_LoginEngine();
  56. if($engine->isUserLogged()){
  57. // Prepare and push in Body the Logged Version
  58. $oHB->addDiv($this->makeLoggedInWidget());
  59. // Then Logout
  60. $engine->performDummyLogout();
  61. }else{
  62. // Prepare and push in Body the NOT Logged Version
  63. $oHB->addDiv($this->makeLoggedOffWidget());
  64. // Then Login
  65. $engine->performDummyLogin();
  66. }
  67. //
  68. // If you want you can Add Other Content and other CSS and JS etc... in the page
  69. //
  70. // Then Return the page Object
  71. $oHP = new Sylar_HtmlPage();
  72. $oHP->setPageHead($oHH);
  73. $oHP->setPageBody($oHB);
  74. // Return the page
  75. return $oHP;
  76. } catch (ExceptionInSylar $ex){
  77. throw $ex;
  78. return null;
  79. }
  80. }
  81. public function makeLoggedInWidget(){
  82. $engine = new App_LoginEngine();
  83. $oHD = new Sylar_HtmlDiv("LoginWidget", null, "logged");
  84. $sDivContent = "
  85. <fieldset style=\"text-align:left;\">
  86. <legend><b>USER LOGGED!!!</b></legend>
  87. <i>".$engine->extractUserInfo()."</i>
  88. <br>Perform LOGOUT...
  89. </fieldset>";
  90. $oHD->appendContent($sDivContent);
  91. return $oHD;
  92. }
  93. public function makeLoggedOffWidget(){
  94. $engine = new App_LoginEngine();
  95. $oHD = new Sylar_HtmlDiv("LogOffWidget", null, "not-logged");
  96. $sDivContent = "
  97. <fieldset style=\"text-align:left;\">
  98. <legend><b>USER NOT LOGGED</b></legend>
  99. Perform LOGIN...
  100. </fieldset>";
  101. $oHD->appendContent($sDivContent);
  102. return $oHD;
  103. }
  104. }
  105. ?>

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