PageRenderTime 58ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/testapp/modules/testapp/controllers/main.classic.php

https://github.com/gmarrot/jelix
PHP | 144 lines | 107 code | 28 blank | 9 comment | 3 complexity | d97f06993c34fd8b3467b55fa559bf98 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /**
  3. * @package testapp
  4. * @subpackage testapp module
  5. * @author Laurent Jouanneau
  6. * @contributor
  7. * @copyright 2005-2006 Laurent Jouanneau
  8. * @link http://www.jelix.org
  9. * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  10. */
  11. class mainCtrl extends jController {
  12. function index(){
  13. $rep = $this->getResponse('html');
  14. $rep->title = 'Homepage of TestApp';
  15. $rep->body->assign('page_title','Test App');
  16. $rep->body->assign('MAIN','<p>Welcome on this application to test Jelix</p>');
  17. return $rep;
  18. }
  19. function hello(){
  20. if($this->param('output') == 'text'){
  21. $rep = $this->getResponse('text', true);
  22. $rep->content = 'Hello World !';
  23. }else{
  24. $rep = $this->getResponse('html',true);
  25. $rep->title = 'Hello From Jelix !';
  26. $rep->bodyTpl = 'testapp~hello';
  27. $rep->body->assign('person', $this->param('person','You'));
  28. $rep->body->assign('value','name');
  29. }
  30. return $rep;
  31. }
  32. function hello2(){
  33. $rep = $this->getResponse('html',true);
  34. $rep->title = 'Hello 2 From Jelix !';
  35. $rep->bodyTpl = 'testapp~hello2';
  36. return $rep;
  37. }
  38. function testdao(){
  39. if ($id = $this->param('newid')) {
  40. $dao = jDao::get('config');
  41. $rec = jDao::createRecord('config');
  42. $rec->ckey = $id;
  43. $rec->cvalue=$this->param('newvalue','');
  44. $dao->insert($rec);
  45. }
  46. $rep = $this->getResponse('html');
  47. $rep->title = 'This is a DAO Test';
  48. $rep->bodyTpl = 'testapp~main';
  49. $rep->body->assign('person','Laurent');
  50. $rep->body->assignZone('MAIN', 'test');
  51. return $rep;
  52. }
  53. function resetdao(){
  54. $db = jDb::getConnection();
  55. $db->exec('delete from myconfig');
  56. $rep = $this->getResponse('html');
  57. $rep->title = 'Empty table';
  58. $rep->bodyTpl = 'testapp~main';
  59. $rep->body->assign('MAIN', 'reset done');
  60. return $rep;
  61. }
  62. function generateerror() {
  63. $rep = $this->getResponse('html');
  64. throw new Exception("here is an error");
  65. }
  66. function generatewarning(){
  67. $rep = $this->getResponse('html');
  68. $rep->title = 'This is a test for the debug bar';
  69. $tpl = new jTpl();
  70. trigger_error("This is a simple notice", E_USER_NOTICE);
  71. trigger_error("This is a simple notice", E_USER_NOTICE);
  72. trigger_error("This is a simple notice", E_USER_NOTICE);
  73. trigger_error("This is a simple notice", E_USER_NOTICE);
  74. trigger_error("This is a simple notice", E_USER_NOTICE);
  75. trigger_error("This is a simple notice", E_USER_NOTICE);
  76. trigger_error("This is a simple notice", E_USER_NOTICE);
  77. trigger_error("This is a simple notice", E_USER_NOTICE);
  78. trigger_error("This is a simple notice", E_USER_NOTICE);
  79. trigger_error("This is a simple notice", E_USER_NOTICE);
  80. trigger_error("This is a simple notice", E_USER_NOTICE);
  81. trigger_error("This is a simple notice", E_USER_NOTICE);
  82. trigger_error("This is a simple notice", E_USER_NOTICE);
  83. trigger_error("This is a simple notice", E_USER_NOTICE);
  84. trigger_error("This is a simple notice", E_USER_NOTICE);
  85. trigger_error("This is a simple notice", E_USER_NOTICE);
  86. trigger_error("This is a simple notice", E_USER_NOTICE);
  87. trigger_error("This is a simple notice", E_USER_NOTICE);
  88. trigger_error("This is a simple notice", E_USER_NOTICE);
  89. trigger_error("This is a simple notice", E_USER_NOTICE);
  90. trigger_error("an other notice!", E_USER_NOTICE);
  91. trigger_error("which notice!", E_USER_NOTICE);
  92. trigger_error("notice the return", E_USER_NOTICE);
  93. trigger_error("damned, a notice!", E_USER_NOTICE);
  94. trigger_error("This is a simple warning", E_USER_WARNING);
  95. $rep->body->assign('MAIN', $tpl->fetch('loremipsum'));
  96. return $rep;
  97. }
  98. function testminify() {
  99. $config = jApp::config();
  100. $config->jResponseHtml['plugins'] = 'minify';
  101. $config->jResponseHtml['minifyCSS'] = true;
  102. $config->jResponseHtml['minifyJS'] = true;
  103. $resp = $this->getResponse('html', true);
  104. $resp->bodyTpl = 'testapp~testminify';
  105. $resp->addJSLink ($config->urlengine['basePath'].'testminify/js/s1.js');
  106. $resp->addJSLink ($config->urlengine['basePath'].'testminify/js/s2.js');
  107. $resp->addCSSLink($config->urlengine['basePath'].'testminify/css/style1.css');
  108. $resp->addCSSLink($config->urlengine['basePath'].'testminify/css/style2.css');
  109. return $resp;
  110. }
  111. function sitemap() {
  112. $resp = $this->getResponse('sitemap');
  113. $resp->importFromUrlsXml();
  114. return $resp;
  115. }
  116. }