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

Language PHP Lines 145
MD5 Hash d97f06993c34fd8b3467b55fa559bf98
Repository https://github.com/gmarrot/jelix.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* @package     testapp
* @subpackage  testapp module
* @author      Laurent Jouanneau
* @contributor
* @copyright   2005-2006 Laurent Jouanneau
* @link        http://www.jelix.org
* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/

class mainCtrl extends jController {

  function index(){

      $rep = $this->getResponse('html');
      $rep->title = 'Homepage of TestApp';
      $rep->body->assign('page_title','Test App');
      $rep->body->assign('MAIN','<p>Welcome on this application to test Jelix</p>');
      return $rep;
   }

   function hello(){

      if($this->param('output') == 'text'){
         $rep = $this->getResponse('text', true);
         $rep->content = 'Hello World !';
      }else{
         $rep = $this->getResponse('html',true);
         $rep->title = 'Hello From Jelix !';
         $rep->bodyTpl = 'testapp~hello';
         $rep->body->assign('person', $this->param('person','You'));
         $rep->body->assign('value','name');
      }

      return $rep;
   }

   function hello2(){

      $rep = $this->getResponse('html',true);
      $rep->title = 'Hello 2 From Jelix !';
      $rep->bodyTpl = 'testapp~hello2';

      return $rep;
   }

   function testdao(){

    if ($id = $this->param('newid')) {
        $dao = jDao::get('config');
        $rec = jDao::createRecord('config');

        $rec->ckey = $id;
        $rec->cvalue=$this->param('newvalue','');
        $dao->insert($rec);
    }

    $rep = $this->getResponse('html');
    $rep->title = 'This is a DAO Test';
    $rep->bodyTpl = 'testapp~main';
    $rep->body->assign('person','Laurent');
    $rep->body->assignZone('MAIN', 'test');

      return $rep;
   }

    function resetdao(){
        $db = jDb::getConnection();
        $db->exec('delete from myconfig');
        
        $rep = $this->getResponse('html');
        $rep->title = 'Empty table';
        $rep->bodyTpl = 'testapp~main';
        $rep->body->assign('MAIN', 'reset done');
    
        return $rep;
    }
   
    function generateerror() {
        $rep = $this->getResponse('html');
        throw new Exception("here is an error");
    }

    function generatewarning(){

      $rep = $this->getResponse('html');
      $rep->title = 'This is a test for the debug bar';
      $tpl = new jTpl();

      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("This is a simple notice", E_USER_NOTICE);
      trigger_error("an other notice!", E_USER_NOTICE);
      trigger_error("which notice!", E_USER_NOTICE);
      trigger_error("notice the return", E_USER_NOTICE);
      trigger_error("damned, a notice!", E_USER_NOTICE);
      trigger_error("This is a simple warning", E_USER_WARNING);

      $rep->body->assign('MAIN', $tpl->fetch('loremipsum'));

      return $rep;
    }


    function testminify() {
        $config = jApp::config();
        $config->jResponseHtml['plugins'] = 'minify';
        $config->jResponseHtml['minifyCSS'] = true;
        $config->jResponseHtml['minifyJS'] = true;
        
        $resp = $this->getResponse('html', true);
        $resp->bodyTpl = 'testapp~testminify';
        $resp->addJSLink ($config->urlengine['basePath'].'testminify/js/s1.js');
        $resp->addJSLink ($config->urlengine['basePath'].'testminify/js/s2.js');
        $resp->addCSSLink($config->urlengine['basePath'].'testminify/css/style1.css');
        $resp->addCSSLink($config->urlengine['basePath'].'testminify/css/style2.css');
        return $resp;
    }

  function sitemap() {
     $resp = $this->getResponse('sitemap');
     $resp->importFromUrlsXml();
     return $resp;
  }

}
Back to Top