Kohana v3.3.5
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
* Kohana user guide and api browser.
|
||||
*
|
||||
* @package Kohana/Userguide
|
||||
* @category Controllers
|
||||
* @category Controller
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
abstract class Kohana_Controller_Userguide extends Controller_Template {
|
||||
|
||||
@@ -76,7 +78,7 @@ abstract class Kohana_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')
|
||||
elseif (Route::name($this->request->route()) == 'docs/api')
|
||||
{
|
||||
$this->template->menu = Kodoc::menu();
|
||||
|
||||
@@ -116,13 +118,13 @@ abstract class Kohana_Controller_Userguide extends Controller_Template {
|
||||
}
|
||||
|
||||
// Prevent "guide/module" and "guide/module/index" from having duplicate content
|
||||
if ( $page == 'index')
|
||||
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 )
|
||||
if ( ! $page)
|
||||
{
|
||||
$page = 'index';
|
||||
}
|
||||
@@ -141,12 +143,14 @@ abstract class Kohana_Controller_Userguide extends Controller_Template {
|
||||
Kodoc_Markdown::$image_url = URL::site($this->media->uri()).'/'.$module.'/';
|
||||
|
||||
// Set the page title
|
||||
$this->template->title = $page == 'index' ? Kohana::$config->load('userguide.modules.'.$module.'.name') : $this->title($page);
|
||||
$this->template->title = ($page == 'index')
|
||||
? Kohana::$config->load('userguide.modules.'.$module.'.name')
|
||||
: $this->title($page);
|
||||
|
||||
// Parse the page contents into the template
|
||||
Kodoc_Markdown::$show_toc = true;
|
||||
Kodoc_Markdown::$show_toc = TRUE;
|
||||
$this->template->content = Kodoc_Markdown::markdown(file_get_contents($file));
|
||||
Kodoc_Markdown::$show_toc = false;
|
||||
Kodoc_Markdown::$show_toc = FALSE;
|
||||
|
||||
// Attach this module's menu to the template
|
||||
$this->template->menu = Kodoc_Markdown::markdown($this->_get_all_menu_markdown());
|
||||
@@ -358,11 +362,7 @@ abstract class Kohana_Controller_Userguide extends Controller_Template {
|
||||
if ($file AND $text = file_get_contents($file))
|
||||
{
|
||||
// Add spans around non-link categories. This is a terrible hack.
|
||||
//echo Debug::vars($text);
|
||||
|
||||
//$text = preg_replace('/(\s*[\-\*\+]\s*)(.*)/','$1<span>$2</span>',$text);
|
||||
$text = preg_replace('/^(\s*[\-\*\+]\s*)([^\[\]]+)$/m','$1<span>$2</span>',$text);
|
||||
//echo Debug::vars($text);
|
||||
$markdown .= $text;
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2008-2012 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc {
|
||||
|
||||
@@ -34,6 +34,10 @@ class Kohana_Kodoc {
|
||||
{
|
||||
$member = '#property:'.substr($matches[3], 1);
|
||||
}
|
||||
elseif (preg_match('/^[A-Z_\x7f-\xff][A-Z0-9_\x7f-\xff]*$/', $matches[3]))
|
||||
{
|
||||
$member = '#constant:'.substr($matches[3],0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$member = '#'.$matches[3];
|
||||
@@ -275,7 +279,7 @@ class Kohana_Kodoc {
|
||||
* @param string $text Content of the tag
|
||||
* @return void
|
||||
*/
|
||||
$add_tag = function($tag, $text) use ($html, &$tags)
|
||||
$add_tag = function ($tag, $text) use ($html, & $tags)
|
||||
{
|
||||
// Don't show @access lines, they are shown elsewhere
|
||||
if ($tag !== 'access')
|
||||
@@ -290,7 +294,7 @@ class Kohana_Kodoc {
|
||||
}
|
||||
};
|
||||
|
||||
$comment = $tag = null;
|
||||
$comment = $tag = NULL;
|
||||
$end = count($lines[1]) - 1;
|
||||
|
||||
foreach ($lines[1] as $i => $line)
|
||||
@@ -415,12 +419,12 @@ class Kohana_Kodoc {
|
||||
*
|
||||
* Module developers can therefore add their own transparent extension
|
||||
* namespaces and exclude them from the userguide.
|
||||
*
|
||||
* @param string $class The name of the class to check for transparency
|
||||
* @param array $classes An optional list of all defined classes
|
||||
* @return false If this is not a transparent extension class
|
||||
* @return string The name of the class that extends this (in the case provided)
|
||||
* @throws InvalidArgumentException If the $classes array is provided and the $class variable is not lowercase
|
||||
*
|
||||
* @param string $class The name of the class to check for transparency
|
||||
* @param array $classes An optional list of all defined classes
|
||||
* @return false If this is not a transparent extension class
|
||||
* @return string The name of the class that extends this (in the case provided)
|
||||
* @throws InvalidArgumentException If the $classes array is provided and the $class variable is not lowercase
|
||||
*/
|
||||
public static function is_transparent($class, $classes = NULL)
|
||||
{
|
||||
@@ -447,11 +451,11 @@ class Kohana_Kodoc {
|
||||
// Cater for Foo extends Module_Foo naming
|
||||
$child_class = $segments[1];
|
||||
}
|
||||
|
||||
|
||||
// It is only a transparent class if the unprefixed class also exists
|
||||
if ($classes AND ! isset($classes[$child_class]))
|
||||
return FALSE;
|
||||
|
||||
|
||||
// Return the name of the child class
|
||||
return $child_class;
|
||||
}
|
||||
@@ -462,5 +466,4 @@ class Kohana_Kodoc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // End Kodoc
|
||||
|
@@ -5,8 +5,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2009-2012 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc_Class extends Kodoc {
|
||||
|
||||
@@ -45,7 +45,7 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
* the class. Reads the class modifiers, constants and comment. Parses the
|
||||
* comment to find the description and tags.
|
||||
*
|
||||
* @param string class name
|
||||
* @param string Class name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($class)
|
||||
@@ -59,7 +59,7 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
|
||||
$this->constants = $this->class->getConstants();
|
||||
|
||||
// If ReflectionClass::getParentClass() won't work if the class in
|
||||
// If ReflectionClass::getParentClass() won't work if the class in
|
||||
// question is an interface
|
||||
if ($this->class->isInterface())
|
||||
{
|
||||
@@ -154,7 +154,7 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
|
||||
return $props;
|
||||
}
|
||||
|
||||
|
||||
protected function _prop_sort($a, $b)
|
||||
{
|
||||
// If one property is public, and the other is not, it goes on top
|
||||
@@ -162,13 +162,13 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
return -1;
|
||||
if ($b->isPublic() AND ( ! $a->isPublic()))
|
||||
return 1;
|
||||
|
||||
|
||||
// If one property is protected and the other is private, it goes on top
|
||||
if ($a->isProtected() AND $b->isPrivate())
|
||||
return -1;
|
||||
if ($b->isProtected() AND $a->isPrivate())
|
||||
return 1;
|
||||
|
||||
|
||||
// Otherwise just do alphabetical
|
||||
return strcmp($a->name, $b->name);
|
||||
}
|
||||
@@ -191,14 +191,15 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort methods based on their visibility and declaring class based on:
|
||||
* - methods will be sorted public, protected, then private.
|
||||
* - methods that are declared by an ancestor will be after classes
|
||||
*
|
||||
* * methods will be sorted public, protected, then private.
|
||||
* * methods that are declared by an ancestor will be after classes
|
||||
* declared by the current class
|
||||
* - lastly, they will be sorted alphabetically
|
||||
*
|
||||
* * lastly, they will be sorted alphabetically
|
||||
*
|
||||
*/
|
||||
protected function _method_sort($a, $b)
|
||||
{
|
||||
@@ -207,16 +208,16 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
return -1;
|
||||
if ($b->isPublic() AND ( ! $a->isPublic()))
|
||||
return 1;
|
||||
|
||||
|
||||
// If one method is protected and the other is private, it goes on top
|
||||
if ($a->isProtected() AND $b->isPrivate())
|
||||
return -1;
|
||||
if ($b->isProtected() AND $a->isPrivate())
|
||||
return 1;
|
||||
|
||||
|
||||
// The methods have the same visibility, so check the declaring class depth:
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
echo Debug::vars('a is '.$a->class.'::'.$a->name,'b is '.$b->class.'::'.$b->name,
|
||||
'are the classes the same?', $a->class == $b->class,'if they are, the result is:',strcmp($a->name, $b->name),
|
||||
@@ -276,4 +277,5 @@ class Kohana_Kodoc_Class extends Kodoc {
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
} // End Kodoc_Class
|
||||
|
@@ -5,8 +5,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2009-2012 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
|
||||
@@ -21,9 +21,10 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
public static $image_url = '';
|
||||
|
||||
/**
|
||||
* Currently defined heading ids.
|
||||
* Currently defined heading ids.
|
||||
* Used to prevent creating multiple headings with same id.
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_heading_ids = array();
|
||||
|
||||
@@ -36,7 +37,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
* Slightly less terrible way to make it so the TOC only shows up when we
|
||||
* want it to. set this to true to show the toc.
|
||||
*/
|
||||
public static $show_toc = false;
|
||||
public static $show_toc = FALSE;
|
||||
|
||||
/**
|
||||
* Transform some text using [Kodoc_Markdown]
|
||||
@@ -78,8 +79,8 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
// Show table of contents for userguide pages
|
||||
$this->document_gamut['doTOC'] = 100;
|
||||
|
||||
// PHP4 makes me sad.
|
||||
parent::MarkdownExtra_Parser();
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,25 +89,27 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
* Heading 1
|
||||
* =========
|
||||
*
|
||||
* @param array Matches from regex call
|
||||
* @return string Generated html
|
||||
* @param array Matches from regex call
|
||||
* @return string Generated html
|
||||
*/
|
||||
function _doHeaders_callback_setext($matches)
|
||||
function _doHeaders_callback_setext($matches)
|
||||
{
|
||||
if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
|
||||
if ($matches[3] == '-' AND preg_match('{^- }', $matches[1]))
|
||||
return $matches[0];
|
||||
$level = $matches[3]{0} == '=' ? 1 : 2;
|
||||
$level = ($matches[3]{0} == '=') ? 1 : 2;
|
||||
$attr = $this->_doHeaders_attr($id =& $matches[2]);
|
||||
|
||||
// Only auto-generate id if one doesn't exist
|
||||
if(empty($attr))
|
||||
if (empty($attr))
|
||||
{
|
||||
$attr = ' id="'.$this->make_heading_id($matches[1]).'"';
|
||||
}
|
||||
|
||||
// Add this header to the page toc
|
||||
$this->_add_to_toc($level,$matches[1],$this->make_heading_id($matches[1]));
|
||||
|
||||
$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
return "\n".$this->hashBlock($block)."\n\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,23 +117,25 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
*
|
||||
* # Heading 1
|
||||
*
|
||||
* @param array Matches from regex call
|
||||
* @return string Generated html
|
||||
* @param array Matches from regex call
|
||||
* @return string Generated html
|
||||
*/
|
||||
function _doHeaders_callback_atx($matches)
|
||||
function _doHeaders_callback_atx($matches)
|
||||
{
|
||||
$level = strlen($matches[1]);
|
||||
$attr = $this->_doHeaders_attr($id =& $matches[3]);
|
||||
|
||||
// Only auto-generate id if one doesn't exist
|
||||
if(empty($attr))
|
||||
if (empty($attr))
|
||||
{
|
||||
$attr = ' id="'.$this->make_heading_id($matches[2]).'"';
|
||||
}
|
||||
|
||||
// Add this header to the page toc
|
||||
$this->_add_to_toc($level, $matches[2], $this->make_heading_id(empty($matches[3]) ? $matches[2] : $matches[3]));
|
||||
|
||||
$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
return "\n".$this->hashBlock($block)."\n\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -138,14 +143,14 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
* Makes a heading id from the heading text
|
||||
* If any heading share the same name then subsequent headings will have an integer appended
|
||||
*
|
||||
* @param string The heading text
|
||||
* @return string ID for the heading
|
||||
* @param string The heading text
|
||||
* @return string ID for the heading
|
||||
*/
|
||||
function make_heading_id($heading)
|
||||
{
|
||||
$id = url::title($heading, '-', TRUE);
|
||||
|
||||
if(isset($this->_heading_ids[$id]))
|
||||
if (isset($this->_heading_ids[$id]))
|
||||
{
|
||||
$id .= '-';
|
||||
|
||||
@@ -155,8 +160,8 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
{
|
||||
$id .= $count;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
@@ -166,8 +171,6 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
{
|
||||
$replace = array();
|
||||
|
||||
$replace = array();
|
||||
|
||||
foreach ($matches as $set)
|
||||
{
|
||||
list($search, $view) = $set;
|
||||
@@ -203,7 +206,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
*
|
||||
* [filesystem](about.filesystem "Optional title")
|
||||
*
|
||||
* @param string span text
|
||||
* @param string Span text
|
||||
* @return string
|
||||
*/
|
||||
public function doBaseURL($text)
|
||||
@@ -217,7 +220,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
*
|
||||
* 
|
||||
*
|
||||
* @param string span text
|
||||
* @param string Span text
|
||||
* @return string
|
||||
*/
|
||||
public function doImageURL($text)
|
||||
@@ -231,7 +234,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
*
|
||||
* [Class_Name], [Class::method] or [Class::$property]
|
||||
*
|
||||
* @param string span text
|
||||
* @param string Span text
|
||||
* @return string
|
||||
*/
|
||||
public function doAPI($text)
|
||||
@@ -244,7 +247,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
*
|
||||
* [!!] Remember the milk!
|
||||
*
|
||||
* @param string span text
|
||||
* @param string Span text
|
||||
* @return string
|
||||
*/
|
||||
public function doNotes($text)
|
||||
@@ -264,7 +267,7 @@ class Kohana_Kodoc_Markdown extends MarkdownExtra_Parser {
|
||||
'name' => $name,
|
||||
'id' => $id);
|
||||
}
|
||||
|
||||
|
||||
public function doTOC($text)
|
||||
{
|
||||
// Only add the toc do userguide pages, not api since they already have one
|
||||
|
@@ -5,28 +5,28 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc_Method extends Kodoc {
|
||||
|
||||
/**
|
||||
* @var ReflectionMethod The ReflectionMethod for this class
|
||||
* @var ReflectionMethod The ReflectionMethod for this class
|
||||
*/
|
||||
public $method;
|
||||
|
||||
/**
|
||||
* @var array array of Kodoc_Method_Param
|
||||
* @var array Array of Kodoc_Method_Param
|
||||
*/
|
||||
public $params;
|
||||
|
||||
/**
|
||||
* @var array the things this function can return
|
||||
* @var array The things this function can return
|
||||
*/
|
||||
public $return = array();
|
||||
|
||||
/**
|
||||
* @var string the source code for this function
|
||||
* @var string The source code for this function
|
||||
*/
|
||||
public $source;
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc_Method_Param extends Kodoc {
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Undocumented
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
* @since 3.0.7
|
||||
*/
|
||||
abstract class Kohana_Kodoc_Missing {
|
||||
|
@@ -5,8 +5,8 @@
|
||||
* @package Kohana/Userguide
|
||||
* @category Base
|
||||
* @author Kohana Team
|
||||
* @copyright (c) 2009-2012 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
* @copyright (c) 2008-2013 Kohana Team
|
||||
* @license http://kohanaframework.org/license
|
||||
*/
|
||||
class Kohana_Kodoc_Property extends Kodoc {
|
||||
|
||||
|
Reference in New Issue
Block a user