Skip to content

Commit 02fb5c5

Browse files
ShadowhandShadowhand
authored andcommitted
Updated default welcome controller and views. Much more attractive now.
1 parent e81233e commit 02fb5c5

File tree

6 files changed

+110
-7
lines changed

6 files changed

+110
-7
lines changed

Kohana License.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5+
6+
<title>Kohana License</title>
7+
8+
</head>
9+
<body>
10+
11+
<h2>Kohana License Agreement</h2>
12+
13+
<p>This license is a legal agreement between you and the Kohana Software Foundation for the use of Kohana Framework (the "Software"). By obtaining the Software you agree to comply with the terms and conditions of this license.</p>
14+
15+
<p>Copyright (c) 2007-2008 Kohana Team<br/>All rights reserved.</p>
16+
17+
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
18+
19+
<ul>
20+
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
21+
<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
22+
<li>Neither the name of the Kohana nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.</li>
23+
</ul>
24+
25+
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
26+
27+
<p><small>NOTE: This license is modeled after the BSD software license.</small></p>
28+
29+
</body>
30+
</html>

application/controllers/examples.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function index()
2424
get_class_methods(get_parent_class($this))
2525
);
2626

27+
sort($examples);
28+
2729
echo "<strong>Examples:</strong>\n";
2830
echo "<ul>\n";
2931

@@ -47,14 +49,14 @@ public function archive($build = FALSE)
4749
$archive = new Archive('zip');
4850

4951
// Add welcome.php with the name of test.php
50-
$archive->add(APPPATH.'controllers/welcome.php', 'test.php');
52+
$archive->add(APPPATH.'views/', 'shitty/views', TRUE);
5153

5254
// Download the built archive
5355
$archive->download('test.zip');
5456
}
5557
else
5658
{
57-
echo html::anchor(Router::$current_uri.'/build', 'Download welcome.php as test.php');
59+
echo html::anchor(Router::$current_uri.'/build', 'Download views');
5860
}
5961
}
6062

@@ -95,7 +97,6 @@ function rss()
9597
*/
9698
function session()
9799
{
98-
$this->load->database();
99100
$s = new Session();
100101

101102
echo 'SESSID: <pre>'.session_id()."</pre>\n";

application/controllers/welcome.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
11
<?php defined('SYSPATH') or die('No direct script access.');
22
/**
3+
* @package Core
4+
*
35
* Default Kohana controller.
46
*/
57
class Welcome_Controller extends Controller {
68

79
public function index()
810
{
11+
// In Kohana, all views are loaded and treated as objects.
912
$welcome = new View('welcome');
10-
$welcome->message = 'This is the default Kohana index page. You can edit <tt>application/controllers/welcome.php</tt> now.';
13+
14+
// You can assign anything variable to a view by using standard OOP
15+
// methods. In my welcome view, the $title variable will be assigned
16+
// the value I give it here.
17+
$welcome->title = 'Welcome to Kohana!';
18+
19+
// An array of links to display. Assiging variables to views is completely
20+
// asyncronous. Variables can be set in any order, and can be any type
21+
// of data, including objects.
22+
$welcome->links = array
23+
(
24+
'License' => url::base(FALSE).'Kohana License.html',
25+
'Home Page' => 'http://kohanaphp.com/',
26+
'Documentation' => 'http://doc.kohanaphp.com/',
27+
'Forum' => 'http://forum.kohanaphp.com/',
28+
);
29+
30+
// Using views inside of views is completely transparent. In the welcome
31+
// view, printing the $content variable will render the welcome_content view.
32+
$welcome->content = new View('welcome_content');
33+
34+
// Using render(TRUE) forces the view to display now, instead of
35+
// returning an HTML string.
1136
$welcome->render(TRUE);
1237
}
1338

39+
public function _default()
40+
{
41+
// By defining a method called _default, all pages routed to this controller
42+
// that result in 404 errors will be handled by this method, instead of
43+
// being displayed as "Page Not Found" errors.
44+
echo 'This is a _default handler. If you expected the index page, you need to use: welcome/index/'.substr(Router::$current_uri, 8);
45+
}
46+
1447
}

application/views/welcome.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1-
<h2>Welcome!</h2>
2-
<p><?php echo $message ?></p>
3-
<hr/>
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5+
6+
<title><?php echo $title ?></title>
7+
8+
<style type="text/css">
9+
html { background: #83c018; }
10+
body { width: 700px; margin: 2em auto; background: transparent url('<?php echo url::base(FALSE).'kohana.png' ?>') center 0 no-repeat; font-size: 76%; font-family: Arial, Verdana, sans-serif; color: #111; line-height: 1.5; text-align: center; }
11+
div, h2, a, p, code, ul { font-family: inherit; color: inherit; padding: 0; margin: 0; text-align: baseline; text-decoration: none; }
12+
h2 { padding: 200px 0 0; }
13+
a { text-decoration: underline; }
14+
ul { list-style: none; padding: 1em 0; }
15+
ul li { display: inline; padding-right: 1em; }
16+
ul li:before { content: '» '; }
17+
code { color: #381a0c; }
18+
p.intro { padding: 1em 0; font-size: 1.2em; }
19+
p.copyright { font-size: 0.8em; text-transform: uppercase; color: #44640b; }
20+
</style>
21+
22+
</head>
23+
<body>
24+
25+
<h2><?php echo $title ?></h2>
26+
<?php echo $content ?>
27+
28+
<ul>
29+
<?php foreach ($links as $title => $url): ?>
30+
<li><?php echo html::anchor($url, $title) ?></li>
31+
<?php endforeach ?>
32+
</ul>
33+
34+
<p class="copyright">Copyright &copy;2007-2008 Kohana Team</p>
35+
36+
</body>
37+
</html>

application/views/welcome_content.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p class="intro">This is the default Kohana index page. You may also access this page as <code><?php echo html::anchor('welcome/index', 'welcome/index') ?></code>.</p>
2+
3+
<p>To change what gets displayed for this page, edit <code>application/controllers/welcome.php</code>.</p>
4+
5+
<p>To change this text, edit <code>application/views/welcome.php</code> and <code>application/views/welcome_content.php</code>.

kohana.png

22.9 KB
Loading

0 commit comments

Comments
 (0)