sofadesign (owner)

Revisions

gist: 162680 Download_button fork
public
Public Clone URL: git://gist.github.com/162680.git
Embed All Files: show embed
limonade-snippet.flash-features.php #
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
<?php
// LIMONADE FLASH FEATURES EXAMPLES
require_once 'lib/limonade.php';
function configure()
{
  option('env', ENV_DEVELOPMENT);
}
 
 
function before()
{
  layout('html_default_layout');
}
 
 
dispatch('/', 'index');
  function index()
  {
    // those flashs will be avilable on next page
    flash('notice', 'Will be displayed on page two');
    flash('errors', 'first error message', 'second error message', 'third error message');
    set('page_title', 'Index Page');
    set('next', '/two');
    return html('<p>Hellooo!</p>');
  }
  
dispatch('/two', 'index_two');
  function index_two()
  {
    flash('notice', 'Will be displayed on page three');
    set('page_title', 'Page Two');
    set('next', '/three');
    return html('<p>Hellooo!</p>');
  }
  
dispatch('/three', 'index_three');
  function index_three()
  {
    set('page_title', 'Page three');
    set('next', '/');
    return html('<p>click to next to go back to first page. There will be no flash message</p>');
  }
  
dispatch('/reset', 'index_reset');
  function index_reset()
  {
    set('page_title', 'Page reset');
    set('next', '/');
    return html('<p>click to next to go back to first page. There will be no flash message</p>');
  }
 
run();
 
 
# ___ HTML ____
 
function html_default_layout($vars){ extract($vars);?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flash features example</title>
<link rel="stylesheet" href="<?=url_for('/_lim_css/screen.css')?>" type="text/css" media="screen">
</head>
<body>
<div id="header">
<h1>Limonade</h1>
</div>
<div id="content">
<div id="main">
<h1>Page: <?=h($page_title)?></h1>
<?=$content;?>
<section>
<h4>Current flash messages ($flash)</h4>
<pre><code>
<?= var_dump($flash); ?>
</code></pre>
 
<h4>Current flash messages (flash_now())</h4>
<pre><code>
<?= var_dump(flash_now()); ?>
</code></pre>
 
<h4>Flash messages that will be displayed on next page(flash())</h4>
<pre><code>
<?= var_dump(flash()); ?>
</code></pre>
</section>
</div>
<hr>
<nav>
<p><strong>Menu:</strong>
<a href="<?=url_for('/reset')?>">Reset all flashs and goto index</a>
<? if($next): ?>| <a href="<?=url_for($next)?>">Next page</a><? endif;?>
</p>
</nav>
<hr>
</div>
</body>
</html>
<?};