本文整理汇总了PHP中Zend\Navigation\Page\AbstractPage::isActive方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPage::isActive方法的具体用法?PHP AbstractPage::isActive怎么用?PHP AbstractPage::isActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Navigation\Page\AbstractPage
的用法示例。
在下文中一共展示了AbstractPage::isActive方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decorateDropdown
protected function decorateDropdown($content, \Zend\Navigation\Page\AbstractPage $page, $renderIcons = true, $activeIconInverse = true, array $options = array())
{
//Get attribs
$liAttribs = array('id' => $page->getId(), 'class' => 'dropdown' . ($page->isActive(true) ? ' active' : ''));
$html = "\n" . '<li' . $this->htmlAttribs($liAttribs) . '>' . "\n" . $content . "\n</li>";
return $html;
}
示例2: getLiClass
/**
* Get list item class.
*
* @param AbstractPage $page
*
* @return string
*/
public function getLiClass(AbstractPage $page)
{
/* @var $escaper \Zend\View\Helper\EscapeHtmlAttr */
$escaper = $this->getView()->plugin('escapeHtmlAttr');
$liClasses = array($this->liClass);
if ($this->getAddClassToListItem()) {
$liClasses[] = $page->getClass();
}
if ($page->hasPages()) {
$liClasses[] = $this->getLiHasMenuClass();
}
if ($page->isActive(true)) {
$liClasses[] = $this->getLiActiveClass();
}
return $escaper(implode(' ', $liClasses));
}
示例3: isActive
/**
* Returns whether page should be considered active or not
*
* This method will compare the page properties against the request uri.
*
* @param bool $recursive
* [optional] whether page should be considered
* active if any child pages are active. Default is
* false.
* @return bool whether page should be considered active or not
*/
public function isActive($recursive = false)
{
if (!$this->active) {
if ($this->getRequest() instanceof Request) {
if ($this->getRequest()->getUri()->getPath() == $this->getUri()) {
$this->active = true;
return true;
}
}
}
return parent::isActive($recursive);
}
示例4: isActive
/**
* Returns whether page should be considered active or not
*
* This method will compare the page properties against the route matches
* composed in the object.
*
* @param bool $recursive [optional] whether page should be considered
* active if any child pages are active. Default is
* false.
* @return bool whether page should be considered active or not
*/
public function isActive($recursive = false)
{
if (!$this->active) {
$reqParams = array();
if ($this->routeMatch instanceof RouteMatch) {
$reqParams = $this->routeMatch->getParams();
if ($this->routeMatch->getMatchedRouteName() === $this->getRoute()) {
$this->active = true;
return true;
}
}
$myParams = $this->params;
if (null !== $this->controller) {
$myParams['controller'] = $this->controller;
} else {
/**
* @todo In ZF1, this was configurable and pulled from the front controller
*/
$myParams['controller'] = 'index';
}
if (null !== $this->action) {
$myParams['action'] = $this->action;
} else {
/**
* @todo In ZF1, this was configurable and pulled from the front controller
*/
$myParams['action'] = 'action';
}
if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) {
$this->active = true;
return true;
}
}
return parent::isActive($recursive);
}
示例5: isActive
/**
* Returns whether page should be considered active or not
*
* This method will compare the page properties against the route matches
* composed in the object.
*
* @param bool $recursive [optional] whether page should be considered
* active if any child pages are active. Default is
* false.
* @return bool whether page should be considered active or not
*/
public function isActive($recursive = false)
{
if (!$this->active) {
$reqParams = array();
if ($this->routeMatch instanceof RouteMatch) {
$reqParams = $this->routeMatch->getParams();
if (isset($reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
$reqParams['controller'] = $reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
}
$pageParams = $this->params;
if (null !== $this->controller) {
$pageParams['controller'] = $this->controller;
}
if (null !== $this->action) {
$pageParams['action'] = $this->action;
}
if (null !== $this->getRoute()) {
if ($this->routeMatch->getMatchedRouteName() === $this->getRoute() && count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) {
$this->active = true;
return $this->active;
} else {
return parent::isActive($recursive);
}
}
}
$pageParams = $this->params;
if (null !== $this->controller) {
$pageParams['controller'] = $this->controller;
} else {
/**
* @todo In ZF1, this was configurable and pulled from the front controller
*/
$pageParams['controller'] = 'index';
}
if (null !== $this->action) {
$pageParams['action'] = $this->action;
} else {
/**
* @todo In ZF1, this was configurable and pulled from the front controller
*/
$pageParams['action'] = 'index';
}
if (count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)) {
$this->active = true;
return true;
}
}
return parent::isActive($recursive);
}
示例6: renderDropdown
protected function renderDropdown(\Zend\Navigation\Page\AbstractPage $page, $renderIcons = true, $activeIconInverse = true, array $options = array())
{
$class = $page->getClass();
$this->addWord('btn', $class);
if ($page->isActive(true)) {
$this->addWord('active', $class);
}
$page->setClass($class);
$html = parent::renderDropdown($page, $renderIcons, $activeIconInverse, $options);
return $html;
}
示例7: isActive
/**
* Returns whether page should be considered active or not
*
* This method will compare the page properties against the request object
* that is found in the front controller.
*
* @param bool $recursive [optional] whether page should be considered
* active if any child pages are active. Default is
* false.
*
* @return bool whether page should be considered active or not
*/
public function isActive($recursive = false)
{
if (!$this->active) {
$front = FrontController::getInstance();
$reqParams = $front->getRequest()->getParams();
if (!array_key_exists('module', $reqParams)) {
$reqParams['module'] = $front->getDefaultModule();
}
$myParams = $this->params;
if (null !== $this->module) {
$myParams['module'] = $this->module;
} else {
$myParams['module'] = $front->getDefaultModule();
}
if (null !== $this->controller) {
$myParams['controller'] = $this->controller;
} else {
$myParams['controller'] = $front->getDefaultControllerName();
}
if (null !== $this->action) {
$myParams['action'] = $this->action;
} else {
$myParams['action'] = $front->getDefaultAction();
}
if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) {
$this->active = true;
return true;
}
}
return parent::isActive($recursive);
}
示例8: htmlifyIcon
protected function htmlifyIcon(\Zend\Navigation\Page\AbstractPage $item, $activeIconInverse = true)
{
if ($item->icon) {
$iClass = $item->icon;
if ($activeIconInverse && $item->isActive(true)) {
$classes = explode(' ', $iClass);
$iconWhiteClassKey = array_search('icon-white', $classes);
if ($iconWhiteClassKey === false) {
//icon-white class not found
$iClass .= ' icon-white';
} else {
//icon-white class found
unset($classes[$iconWhiteClassKey]);
$iClass = implode(' ', $classes);
}
}
$icon = '<i class="' . $iClass . '"></i> ';
} else {
$icon = '';
}
return $icon;
}