Skip to content

Commit

Permalink
Merge remote branch 'origin/3.1/develop' into 3.1/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Jul 25, 2011
2 parents afeda5b + 2d991eb commit edd8982
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
19 changes: 12 additions & 7 deletions classes/controller/userguide.php
Expand Up @@ -120,22 +120,27 @@ public function action_docs()
return $this->index();
}

$config = Kohana::config('userguide.modules.'.$module);

// If this module's userguide pages are disabled, show the error page
if ( ! Kohana::config('userguide.modules.'.$module.'.enabled'))
if ( ! Arr::get($config, 'enabled'))
{
return $this->error(__('That module doesn\'t exist, or has userguide pages disabled.'));
}

// Get the index page from config, default to "index"
$index = Arr::get($config, 'index', 'index');

// 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 )
{
$page = 'index';
$page = $index;
}

// Find the markdown file for this page
Expand All @@ -152,7 +157,7 @@ public function action_docs()
Kodoc_Markdown::$image_url = URL::site($this->media->uri()).'/'.$module.'/';

// Set the page title
$this->template->title = $page == 'index' ? Kohana::config('userguide.modules.'.$module.'.name') : $this->title($page);
$this->template->title = ($page === $index) ? Arr::get($config, 'name') : $this->title($page);

// Parse the page contents into the template
Kodoc_Markdown::$show_toc = true;
Expand All @@ -166,17 +171,17 @@ public function action_docs()
$this->template->bind('breadcrumb', $breadcrumb);

// Bind the copyright
$this->template->copyright = Kohana::config('userguide.modules.'.$module.'.copyright');
$this->template->copyright = Arr::get($config, 'copyright');

// Add the breadcrumb trail
$breadcrumb = array();
$breadcrumb[$this->guide->uri()] = __('User Guide');
$breadcrumb[$this->guide->uri(array('module' => $module))] = Kohana::config('userguide.modules.'.$module.'.name');
$breadcrumb[$this->guide->uri(array('module' => $module))] = Arr::get($config, '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')
if ($page !== $index)
{
$breadcrumb[] = $this->template->title;
}
Expand Down
5 changes: 4 additions & 1 deletion config/userguide.php
Expand Up @@ -17,7 +17,10 @@

// Whether this modules userguide pages should be shown
'enabled' => TRUE,


// Name of the start/landing/home page
'index' => 'index',

// The name that should show up on the userguide index page
'name' => 'Userguide',

Expand Down

0 comments on commit edd8982

Please sign in to comment.