Update Kohana to 3.1.3.1

This commit is contained in:
Deon George
2011-05-16 22:47:16 +10:00
parent 8b658b497a
commit ff2370c368
401 changed files with 14070 additions and 10213 deletions

View File

@@ -17,7 +17,7 @@ class Controller_Userguide extends Controller_Template {
public function before()
{
if ($this->request->action === 'media')
if ($this->request->action() === 'media')
{
// Do not template media files
$this->auto_render = FALSE;
@@ -49,7 +49,7 @@ class Controller_Userguide extends Controller_Template {
parent::before();
}
// List all modules that have userguides
public function index()
{
@@ -57,18 +57,18 @@ class Controller_Userguide extends Controller_Template {
$this->template->breadcrumb = array('User Guide');
$this->template->content = View::factory('userguide/index', array('modules' => $this->_modules()));
$this->template->menu = View::factory('userguide/menu', array('modules' => $this->_modules()));
// Don't show disqus on the index page
$this->template->hide_disqus = TRUE;
}
// Display an error if a page isn't found
public function error($message)
{
$this->request->status = 404;
$this->response->status(404);
$this->template->title = "Userguide - Error";
$this->template->content = View::factory('userguide/error',array('message' => $message));
// Don't show disqus on error pages
$this->template->hide_disqus = TRUE;
@@ -78,7 +78,7 @@ class Controller_Userguide extends Controller_Template {
// Namespace the markdown parser
Kodoc_Markdown::$base_url = URL::site($this->guide->uri()).'/'.$module.'/';
Kodoc_Markdown::$image_url = URL::site($this->media->uri()).'/'.$module.'/';
$this->template->menu = Markdown($this->_get_all_menu_markdown());
$this->template->breadcrumb = array(
$this->guide->uri() => 'User Guide',
@@ -87,14 +87,14 @@ class Controller_Userguide extends Controller_Template {
);
}
// If we are in the api browser, show the menu and show the api browser in the breadcrumbs
else if (Route::name($this->request->route) == 'docs/api')
else if (Route::name($this->request->route()) == 'docs/api')
{
$this->template->menu = Kodoc::menu();
// Bind the breadcrumb
$this->template->breadcrumb = array(
$this->guide->uri(array('page' => NULL)) => 'User Guide',
$this->request->route->uri() => 'API Browser',
$this->request->route()->uri() => 'API Browser',
'Error'
);
}
@@ -102,7 +102,7 @@ class Controller_Userguide extends Controller_Template {
else
{
$this->template->menu = View::factory('userguide/menu',array('modules' => $this->_modules()));
$this->template->breadcrumb = array($this->request->route->uri() => 'User Guide','Error');
$this->template->breadcrumb = array($this->request->route()->uri() => 'User Guide','Error');
}
}
@@ -119,19 +119,19 @@ class Controller_Userguide extends Controller_Template {
{
return $this->index();
}
// If this module's userguide pages are disabled, show the error page
if ( ! Kohana::config('userguide.modules.'.$module.'.enabled'))
{
return $this->error(__('That module doesn\'t exist, or has userguide pages disabled.'));
}
// Prevent "guide/module" and "guide/module/index" from having duplicate content
if ( $page == 'index')
{
return $this->error(__('Userguide page not found'));
}
// If a module is set, but no page was provided in the url, show the index page
if ( ! $page )
{
@@ -146,7 +146,7 @@ class Controller_Userguide extends Controller_Template {
{
return $this->error(__('Userguide page not found'));
}
// Namespace the markdown parser
Kodoc_Markdown::$base_url = URL::site($this->guide->uri()).'/'.$module.'/';
Kodoc_Markdown::$image_url = URL::site($this->media->uri()).'/'.$module.'/';
@@ -161,10 +161,10 @@ class Controller_Userguide extends Controller_Template {
// Attach this module's menu to the template
$this->template->menu = Markdown($this->_get_all_menu_markdown());
// Bind the breadcrumb
$this->template->bind('breadcrumb', $breadcrumb);
// Bind the copyright
$this->template->copyright = Kohana::config('userguide.modules.'.$module.'.copyright');
@@ -172,9 +172,9 @@ class Controller_Userguide extends Controller_Template {
$breadcrumb = array();
$breadcrumb[$this->guide->uri()] = __('User Guide');
$breadcrumb[$this->guide->uri(array('module' => $module))] = Kohana::config('userguide.modules.'.$module.'.name');
// TODO try and get parent category names (from menu). Regex magic or javascript dom stuff perhaps?
// Only add the current page title to breadcrumbs if it isn't the index, otherwise we get repeats.
if ($page != 'index')
{
@@ -198,18 +198,18 @@ class Controller_Userguide extends Controller_Template {
$this->template->content = View::factory('userguide/api/toc')
->set('classes', Kodoc::class_methods())
->set('route', $this->request->route);
->set('route', $this->request->route());
}
else
{
// Create the Kodoc_Class version of this class.
$_class = Kodoc_Class::factory($class);
// If the class requested and the actual class name are different
// (different case, orm vs ORM, auth vs Auth) redirect
if ($_class->class->name != $class)
{
$this->request->redirect($this->request->route->uri(array('class'=>$_class->class->name)));
$this->request->redirect($this->request->route()->uri(array('class'=>$_class->class->name)));
}
// If this classes immediate parent is Kodoc_Missing, then it should 404
@@ -219,13 +219,13 @@ class Controller_Userguide extends Controller_Template {
// If this classes package has been disabled via the config, 404
if ( ! Kodoc::show_class($_class))
return $this->error('That class is in package that is hidden. Check the <code>api_packages</code> config setting.');
// Everything is fine, display the class.
$this->template->title = $class;
$this->template->content = View::factory('userguide/api/class')
->set('doc', Kodoc::factory($class))
->set('route', $this->request->route);
->set('route', $this->request->route());
}
// Attach the menu to the template
@@ -240,7 +240,7 @@ class Controller_Userguide extends Controller_Template {
// Add the breadcrumb
$breadcrumb = array();
$breadcrumb[$this->guide->uri(array('page' => NULL))] = __('User Guide');
$breadcrumb[$this->request->route->uri()] = 'API Browser';
$breadcrumb[$this->request->route()->uri()] = 'API Browser';
$breadcrumb[] = $this->template->title;
}
@@ -258,21 +258,20 @@ class Controller_Userguide extends Controller_Template {
if ($file = Kohana::find_file('media/guide', $file, $ext))
{
// Check if the browser sent an "if-none-match: <etag>" header, and tell if the file hasn't changed
$this->request->check_cache(sha1($this->request->uri).filemtime($file));
$this->response->check_cache(sha1($this->request->uri()).filemtime($file), $this->request);
// Send the file content as the response
$this->request->response = file_get_contents($file);
$this->response->body(file_get_contents($file));
// Set the proper headers to allow caching
$this->response->headers('content-type', File::mime_by_ext($ext));
$this->response->headers('last-modified', date('r', filemtime($file)));
}
else
{
// Return a 404 status
$this->request->status = 404;
$this->response->status(404);
}
// Set the proper headers to allow caching
$this->request->headers['Content-Type'] = File::mime_by_ext($ext);
$this->request->headers['Content-Length'] = filesize($file);
$this->request->headers['Last-Modified'] = date('r', filemtime($file));
}
public function after()
@@ -316,66 +315,66 @@ class Controller_Userguide extends Controller_Template {
public function section($page)
{
$markdown = $this->_get_all_menu_markdown();
if (preg_match('~\*{2}(.+?)\*{2}[^*]+\[[^\]]+\]\('.preg_quote($page).'\)~mu', $markdown, $matches))
{
return $matches[1];
}
return $page;
}
public function title($page)
{
$markdown = $this->_get_all_menu_markdown();
if (preg_match('~\[([^\]]+)\]\('.preg_quote($page).'\)~mu', $markdown, $matches))
{
// Found a title for this link
return $matches[1];
}
return $page;
}
protected function _get_all_menu_markdown()
{
// Only do this once per request...
static $markdown = '';
if (empty($markdown))
{
// Get menu items
$file = $this->file($this->request->param('module').'/menu');
if ($file AND $text = file_get_contents($file))
{
// Add spans around non-link categories. This is a terrible hack.
//echo Kohana::debug($text);
//$text = preg_replace('/(\s*[\-\*\+]\s*)(.*)/','$1<span>$2</span>',$text);
$text = preg_replace('/^(\s*[\-\*\+]\s*)([^\[\]]+)$/m','$1<span>$2</span>',$text);
//echo Kohana::debug($text);
$markdown .= $text;
}
}
return $markdown;
}
// Get the list of modules from the config, and reverses it so it displays in the order the modules are added, but move Kohana to the top.
protected function _modules()
{
$modules = array_reverse(Kohana::config('userguide.modules'));
if (isset($modules['kohana']))
{
$kohana = $modules['kohana'];
unset($modules['kohana']);
$modules = array_merge(array('kohana' => $kohana), $modules);
}
// Remove modules that have been disabled via config
foreach ($modules as $key => $value)
{
@@ -384,7 +383,7 @@ class Controller_Userguide extends Controller_Template {
unset($modules[$key]);
}
}
return $modules;
}

View File

@@ -40,7 +40,7 @@ class Kohana_Kodoc {
}
}
return HTML::anchor(Route::get('docs/api')->uri(array('class' => $class)).$member, $link);
return HTML::anchor(Route::get('docs/api')->uri(array('class' => $class)).$member, $link, NULL, NULL, TRUE);
}
public static function factory($class)

View File

@@ -56,7 +56,7 @@ class Kohana_Kodoc_Class extends Kodoc {
{
foreach ($constants as $name => $value)
{
$this->constants[$name] = Kohana::debug($value);
$this->constants[$name] = Debug::vars($value);
}
}

View File

@@ -161,7 +161,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
ob_start();
// Capture the exception handler output and insert it instead
Kohana::exception_handler($e);
Kohana_exception::handler($e);
$replace[$search] = ob_get_clean();
}
@@ -243,7 +243,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
public function doTOC($text)
{
// Only add the toc do userguide pages, not api since they already have one
if (self::$show_toc AND Route::name(Request::instance()->route) == "docs/guide")
if (self::$show_toc AND Route::name(Request::current()->route()) == "docs/guide")
{
$toc = View::factory('userguide/page-toc')
->set('array', self::$_toc)

View File

@@ -53,7 +53,7 @@ class Kohana_Kodoc_Method_Param extends Kodoc {
if ($this->param->isDefaultValueAvailable())
{
$this->default = Kohana::dump($this->param->getDefaultValue());
$this->default = Debug::dump($this->param->getDefaultValue());
}
if ($this->param->isPassedByReference())

View File

@@ -74,7 +74,7 @@ class Kohana_Kodoc_Property extends Kodoc {
}
else
{
$this->value = Kohana::debug($property->getValue($class));
$this->value = Debug::vars($property->getValue($class));
}
}