Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into no
Browse files Browse the repository at this point in the history
  • Loading branch information
roheim committed Feb 23, 2012
2 parents 140c99f + 3d239f1 commit 17f391d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
9 changes: 7 additions & 2 deletions src/Helper/HeadTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,16 @@ public function toString($indent = null, $locale = null)

$separator = $this->getSeparator();
$output = '';
if(($prefix = $this->getPrefix())) {

$prefix = $this->getPrefix();
if($prefix) {
$output .= $prefix;
}

$output .= implode($separator, $items);
if(($postfix = $this->getPostfix())) {

$postfix = $this->getPostfix();
if($postfix) {
$output .= $postfix;
}

Expand Down
11 changes: 6 additions & 5 deletions src/Helper/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public function __invoke(Container $container = null)
public function __call($method, array $arguments = array())
{
// check if call should proxy to another helper
if ($helper = $this->findHelper($method, false)) {
$helper = $this->findHelper($method, false);
if ($helper) {
return call_user_func_array($helper, $arguments);
}

Expand All @@ -146,8 +147,8 @@ public function __call($method, array $arguments = array())

/**
* Set plugin loader for retrieving navigation helpers
*
* @param ShortNameLocator $loader
*
* @param ShortNameLocator $loader
* @return void
*/
public function setPluginLoader(ShortNameLocator $loader)
Expand All @@ -159,9 +160,9 @@ public function setPluginLoader(ShortNameLocator $loader)
/**
* Retrieve plugin loader for navigation helpers
*
* Lazy-loads an instance of Navigation\HelperLoader if none currently
* Lazy-loads an instance of Navigation\HelperLoader if none currently
* registered.
*
*
* @return ShortNameLocator
*/
public function getPluginLoader()
Expand Down
12 changes: 7 additions & 5 deletions src/Helper/Navigation/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,9 @@ public function renderPartial(Container $container = null,
}

// put breadcrumb pages in model
$model = array('pages' => array());
if ($active = $this->findActive($container)) {
$model = array('pages' => array());
$active = $this->findActive($container);
if ($active) {
$active = $active['page'];
$model['pages'][] = $active;
while ($parent = $active->getParent()) {
Expand All @@ -296,8 +297,8 @@ public function renderPartial(Container $container = null,
if (is_array($partial)) {
if (count($partial) != 2) {
throw new Exception\InvalidArgumentException(
'Unable to render menu: A view partial supplied as '
. 'an array must contain two values: partial view '
'Unable to render menu: A view partial supplied as '
. 'an array must contain two values: partial view '
. 'script and module where script can be found'
);
}
Expand Down Expand Up @@ -325,7 +326,8 @@ public function renderPartial(Container $container = null,
*/
public function render(Container $container = null)
{
if ($partial = $this->getPartial()) {
$partial = $this->getPartial();
if ($partial) {
return $this->renderPartial($container, $partial);
} else {
return $this->renderStraight($container);
Expand Down
31 changes: 19 additions & 12 deletions src/Helper/Navigation/Links.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ public function findAllRelations(AbstractPage $page,
if (!($flag & $relFlag)) {
continue;
}
if ($found = $this->findRelation($page, $rel, $type)) {

$found = $this->findRelation($page, $rel, $type);
if ($found) {
if (!is_array($found)) {
$found = array($found);
}
Expand Down Expand Up @@ -302,8 +304,10 @@ public function findRelation(AbstractPage $page, $rel, $type)
protected function _findFromProperty(AbstractPage $page, $rel, $type)
{
$method = 'get' . ucfirst($rel);
if ($result = $page->$method($type)) {
if ($result = $this->_convertToPages($result)) {
$result = $page->$method($type);
if ($result) {
$result = $this->_convertToPages($result);
if ($result) {
if (!is_array($result)) {
$result = array($result);
}
Expand Down Expand Up @@ -564,9 +568,9 @@ public function searchRelSubsection(AbstractPage $page)
*/
public function searchRevSection(AbstractPage $page)
{
$found = null;

if ($parent = $page->getParent()) {
$found = null;
$parent = $page->getParent();
if ($parent) {
if ($parent instanceof AbstractPage &&
$this->_findRoot($page)->hasPage($parent)) {
$found = $parent;
Expand All @@ -589,9 +593,9 @@ public function searchRevSection(AbstractPage $page)
*/
public function searchRevSubsection(AbstractPage $page)
{
$found = null;

if ($parent = $page->getParent()) {
$found = null;
$parent = $page->getParent();
if ($parent) {
if ($parent instanceof AbstractPage) {
$root = $this->_findRoot($page);
foreach ($root as $chapter) {
Expand Down Expand Up @@ -675,7 +679,8 @@ protected function _convertToPages($mixed, $recursive = true)
// first key is numeric; assume several pages
$pages = array();
foreach ($mixed as $value) {
if ($value = $this->_convertToPages($value, false)) {
$value = $this->_convertToPages($value, false);
if ($value) {
$pages[] = $value;
}
}
Expand Down Expand Up @@ -756,7 +761,8 @@ public function render(Navigation\Container $container = null)
$container = $this->getContainer();
}

if ($active = $this->findActive($container)) {
$active = $this->findActive($container);
if ($active) {
$active = $active['page'];
} else {
// no active page
Expand All @@ -771,7 +777,8 @@ public function render(Navigation\Container $container = null)
foreach ($result as $attrib => $types) {
foreach ($types as $relation => $pages) {
foreach ($pages as $page) {
if ($r = $this->renderLink($page, $attrib, $relation)) {
$r = $this->renderLink($page, $attrib, $relation);
if ($r) {
$output .= $indent . $r . self::EOL;
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/Helper/Navigation/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ public function htmlify(AbstractPage $page)
);

// does page have a href?
if ($href = $page->getHref()) {
$href = $page->getHref();
if ($href) {
$element = 'a';
$attribs['href'] = $href;
$attribs['target'] = $page->getTarget();
Expand Down Expand Up @@ -376,8 +377,9 @@ protected function _renderMenu(Container $container,
$html = '';

// find deepest active
if ($found = $this->findActive($container, $minDepth, $maxDepth)) {
$foundPage = $found['page'];
$found = $this->findActive($container, $minDepth, $maxDepth);
if ($found) {
$foundPage = $found['page'];
$foundDepth = $found['depth'];
} else {
$foundPage = null;
Expand Down Expand Up @@ -606,8 +608,8 @@ public function renderPartial(Container $container = null,
if (is_array($partial)) {
if (count($partial) != 2) {
throw new Exception\InvalidArgumentException(
'Unable to render menu: A view partial supplied as '
. 'an array must contain two values: partial view '
'Unable to render menu: A view partial supplied as '
. 'an array must contain two values: partial view '
. 'script and module where script can be found'
);
}
Expand Down Expand Up @@ -642,7 +644,8 @@ public function renderPartial(Container $container = null,
*/
public function render(Container $container = null)
{
if ($partial = $this->getPartial()) {
$partial = $this->getPartial();
if ($partial) {
return $this->renderPartial($container, $partial);
} else {
return $this->renderMenu($container);
Expand Down

0 comments on commit 17f391d

Please sign in to comment.