controller
<?php defined('SYSPATH') or die('No direct script access.');
if ( ! $this->_auth->logged_in('login'))
{
throw new Kohana_Exception('You are not allowed to view this resource.');
}Kohana Framework, kohana 3 tutorial , kohana hmvc
<?php defined('SYSPATH') or die('No direct script access.');
if ( ! $this->_auth->logged_in('login'))
{
throw new Kohana_Exception('You are not allowed to view this resource.');
}< ?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Extend the Kohana Date helper
*/
class Date extends Kohana_Date {
/**
* Number of months in a year. Value will hold month name
*
* @static
* @uses Date::hours
* @return array Array from 1-12 with month names
*/
public static function months_with_name()
{
$months = Date::hours();
for ($i = 1; $i <= 12; $i++)
{
$timestamp = mktime(0, 0, 0, $i, 1, 2005);
$months[$i] = date("M", $timestamp);
}
return $months;
}
/**
* Checks whether a string is a date
*
* @static
* @param string date
* @return bool
*/
public static function is_date($str)
{
return (boolean) strtotime($str);
}
}
// End Date
public function save()
{
$this->slug = $this->_unique_slug(url::title(empty($this->slug) ? $this->title : $this->slug));
return parent::save();
}
private function _unique_slug($str)
{
static $i;
$original = $str;
while ($post = ORM::factory('post', $str) AND $post->loaded AND $post->id !== $this->id)
{
$str = $original.$i;
$i++;
}
return $str;
}
Route::set('post', 'post/<year>/<month>/<day>/<title>', array('year'=>'\d{4}', 'month'=>'\d{2}', 'day'=>'\d{2}'))
->defaults(array(
'controller' => 'post',
'action' => 'index',
));public function action_index($year, $month, $day, $title){
//Your code here
}