Changeset 2004

Show
Ignore:
Timestamp:
02/08/2008 07:20:03 PM (10 months ago)
Author:
Shadowhand
Message:

Updated default welcome controller and views. Much more attractive now.

Location:
trunk
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r1911 r2004  
    2525                ); 
    2626 
     27                sort($examples); 
     28 
    2729                echo "<strong>Examples:</strong>\n"; 
    2830                echo "<ul>\n"; 
     
    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 
     
    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        } 
     
    9698        function session() 
    9799        { 
    98                 $this->load->database(); 
    99100                $s = new Session(); 
    100101 
  • trunk/application/controllers/welcome.php

    r1522 r2004  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    22/** 
     3 * @package Core 
     4 * 
    35 * Default Kohana controller. 
    46 */ 
     
    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} 
  • trunk/application/views/welcome.php

    r1522 r2004  
    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"> 
     9html { background: #83c018; } 
     10body { 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; } 
     11div, h2, a, p, code, ul { font-family: inherit; color: inherit; padding: 0; margin: 0; text-align: baseline; text-decoration: none; } 
     12h2 { padding: 200px 0 0; } 
     13a { text-decoration: underline; } 
     14ul { list-style: none; padding: 1em 0; } 
     15ul li { display: inline; padding-right: 1em; } 
     16ul li:before { content: '» '; } 
     17code { color: #381a0c; } 
     18p.intro { padding: 1em 0; font-size: 1.2em; } 
     19p.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>