当前位置: 首页>>代码示例>>PHP>>正文


PHP Page\AbstractPage类代码示例

本文整理汇总了PHP中Zend\Navigation\Page\AbstractPage的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPage类的具体用法?PHP AbstractPage怎么用?PHP AbstractPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AbstractPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: htmlify

 /**
  * Returns an HTML string containing an 'a' element for the given page
  *
  * @param  AbstractPage $page  page to generate HTML for
  * @param  boolean      $hasParent if the breadcrumb has a parent
  * @return string
  */
 public function htmlify(AbstractPage $page, $hasParent = false)
 {
     $html = '<li';
     if (!$hasParent) {
         $html .= ' class="active"';
     }
     $html .= '>';
     $label = $page->getLabel();
     if (null !== ($translator = $this->getTranslator())) {
         $label = $translator->translate($label, $this->getTranslatorTextDomain());
     }
     $escaper = $this->view->plugin('escapeHtml');
     $label = $escaper($label);
     if ($page->getHref() && ($hasParent || !$hasParent && $this->getLinkLast())) {
         $anchorAttribs = $this->htmlAttribs(array('href' => $page->getHref()));
         $html .= '<a' . $anchorAttribs . '>' . $label . '</a>';
     } else {
         $html .= $label;
     }
     if ($hasParent) {
         $html .= '<span class="divider">' . $this->getSeparator() . '</span>';
     }
     $html .= '</li>';
     return $html;
 }
开发者ID:suitedJK,项目名称:ZfcTwitterBootstrap,代码行数:32,代码来源:Breadcrumbs.php

示例2: 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;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:7,代码来源:AbstractNavHelper.php

示例3: acceptAcl

 /**
  * Determines whether a page should be accepted by ACL when iterating
  *
  * Rules:
  * - If helper has no ACL, page is accepted
  * - If page has a resource or privilege defined, page is accepted
  *   if the ACL allows access to it using the helper's role
  * - If page has no resource or privilege, page is accepted
  *
  * @param  AbstractPage $page  page to check
  * @return bool                whether page is accepted by ACL
  */
 protected function acceptAcl(AbstractPage $page)
 {
     if (!($acl = $this->getAcl())) {
         // no acl registered means don't use acl
         return true;
     }
     $role = $this->getRole();
     $roles = $this->getRoles();
     $resource = $page->getResource();
     if ($resource === NULL) {
         return true;
     }
     $resource = $this->acl->hasResourceOrParent($resource);
     if ($resource === false || $resource === NULL) {
         return false;
     }
     if (!$roles) {
         $roles = array($role);
     }
     if ($resource) {
         foreach ($roles as $r) {
             /**
              * TODO: for now this has been set to allow an item if its resource is not found
              */
             if (!$acl->hasResource($resource) || $acl->isAllowed($r, $resource)) {
                 return true;
             }
         }
         return false;
     }
     return true;
 }
开发者ID:siad007,项目名称:ctrllib,代码行数:44,代码来源:Menu.php

示例4: isActive

 protected function isActive(AbstractPage $page, $recursive = true)
 {
     if ($page->get('identifier') != $this->identifier && $recursive) {
         foreach ($page->getPages() as $subPage) {
             if ($this->isActive($subPage, $recursive)) {
                 return true;
             }
         }
         return false;
     }
     return $page->get('identifier') == $this->identifier;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:12,代码来源:Json.php

示例5: htmlifyLabel

 public function htmlifyLabel(AbstractPage $page)
 {
     $label = $this->translate($page->getLabel(), $page->getTextDomain());
     /** @var \Zend\View\Helper\EscapeHtml $escaper */
     $escaper = $this->view->plugin('escapeHtml');
     $label = $escaper($label);
     if (isset($page->icon)) {
         $attribs = array('class' => 'fa fa-' . $page->icon);
         $label = '<i ' . $this->htmlAttribs($attribs) . '></i> ' . $label;
     }
     return $label;
 }
开发者ID:kashandarash,项目名称:blog-example,代码行数:12,代码来源:AdminBreadcrumbs.php

示例6: 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));
 }
开发者ID:kashandarash,项目名称:blog-example,代码行数:23,代码来源:Menu.php

示例7: htmlify

 /**
  * Returns an HTML string containing an 'a' element for the given page if
  * the page's href is not empty, and a 'span' element if it is empty
  *
  * Overrides {@link AbstractHelper::htmlify()}.
  *
  * @param  AbstractPage $page               page to generate HTML for
  * @param  bool         $escapeLabel        Whether or not to escape the label
  * @param  bool         $addClassToListItem Whether or not to add the page class to the list item
  * @return string
  */
 public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false)
 {
     // get attribs for element
     $attribs = array('id' => $page->getId(), 'title' => $page->getTitle());
     if ($addClassToListItem === false) {
         $attribs['class'] = $page->getClass();
     }
     // does page have a href?
     $href = $page->getHref();
     if ('#' !== $href) {
         $element = 'a';
         $attribs['href'] = $href;
         $attribs['target'] = $page->getTarget();
     } else {
         $element = 'span';
     }
     $html = '<' . $element . $this->htmlAttribs($attribs) . '>';
     $label = $page->getLabel();
     //$this->translate(, $page->getTextDomain());
     if ($escapeLabel === true) {
         /** @var \Zend\View\Helper\EscapeHtml $escaper */
         $escaper = $this->view->plugin('escapeHtml');
         $html .= $escaper($label);
     } else {
         $html .= $label;
     }
     $html .= '</' . $element . '>';
     return $html;
 }
开发者ID:jochum-mediaservices,项目名称:contentinum5.5,代码行数:40,代码来源:Mmenu.php

示例8: testShouldFailIfUnableToDetermineType

 public function testShouldFailIfUnableToDetermineType()
 {
     try {
         $page = AbstractPage::factory(array('label' => 'My Invalid Page'));
     } catch (Navigation\Exception\InvalidArgumentException $e) {
         return;
     }
     $this->fail('An exception has not been thrown for invalid page type');
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:9,代码来源:PageFactoryTest.php

示例9: indexAction

 /**
  * Get the feed list and the posts of the feed we are looking at now
  *
  * @return void
  */
 public function indexAction()
 {
     $viewData = array();
     $flashMessenger = $this->flashMessenger();
     $username = $this->params()->fromRoute('username');
     $currentFeedId = $this->params()->fromRoute('feed_id');
     $userData = ApiClient::getUser($username);
     if ($userData !== FALSE) {
         $hydrator = new ClassMethods();
         $user = $hydrator->hydrate($userData, new User());
     } else {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     $subscribeForm = new SubscribeForm();
     $unsubscribeForm = new UnsubscribeForm();
     $subscribeForm->setAttribute('action', $this->url()->fromRoute('feeds-subscribe', array('username' => $username)));
     $unsubscribeForm->setAttribute('action', $this->url()->fromRoute('feeds-unsubscribe', array('username' => $username)));
     $hydrator = new ClassMethods();
     $response = ApiClient::getFeeds($username);
     $feeds = array();
     foreach ($response as $r) {
         $feeds[$r['id']] = $hydrator->hydrate($r, new Feed());
     }
     if ($currentFeedId === null && !empty($feeds)) {
         $currentFeedId = reset($feeds)->getId();
     }
     $feedsMenu = new Navigation();
     $router = $this->getEvent()->getRouter();
     $routeMatch = $this->getEvent()->getRouteMatch()->setParam('feed_id', $currentFeedId);
     foreach ($feeds as $f) {
         $feedsMenu->addPage(AbstractPage::factory(array('title' => $f->getTitle(), 'icon' => $f->getIcon(), 'route' => 'feeds', 'routeMatch' => $routeMatch, 'router' => $router, 'params' => array('username' => $username, 'feed_id' => $f->getId()))));
     }
     $currentFeed = $currentFeedId != null ? $feeds[$currentFeedId] : null;
     if ($currentFeed != null) {
         $paginator = new Paginator(new ArrayAdapter($currentFeed->getArticles()));
         $paginator->setItemCountPerPage(5);
         $paginator->setCurrentPageNumber($this->params()->fromRoute('page'));
         $viewData['paginator'] = $paginator;
         $viewData['feedId'] = $currentFeedId;
     }
     $unsubscribeForm->get('feed_id')->setValue($currentFeedId);
     $viewData['subscribeForm'] = $subscribeForm;
     $viewData['unsubscribeForm'] = $unsubscribeForm;
     $viewData['username'] = $username;
     $viewData['feedsMenu'] = $feedsMenu;
     $viewData['user'] = $user;
     $viewData['paginator'] = $paginator;
     $viewData['feedId'] = $currentFeedId;
     $viewData['feed'] = $currentFeed;
     $this->layout()->username = $username;
     if ($flashMessenger->hasMessages()) {
         $viewData['flashMessages'] = $flashMessenger->getMessages();
     }
     return $viewData;
 }
开发者ID:CPDeutschland,项目名称:zf2-api-client,代码行数:61,代码来源:IndexController.php

示例10: htmlify

 /**
  * @override htmlify from the parent/base/super class
  */
 public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false)
 {
     // !!! This method will be executed in the namespace of the class
     // !!! But the methods of the super/base class will be executed in its own namespace
     // get label and title for translating
     $label = $page->getLabel();
     $title = $page->getTitle();
     // translate label and title?
     if (null !== ($translator = $this->getTranslator())) {
         $textDomain = $this->getTranslatorTextDomain();
         if (is_string($label) && !empty($label)) {
             $label = $translator->translate($label, $textDomain);
         }
         if (is_string($title) && !empty($title)) {
             $title = $translator->translate($title, $textDomain);
         }
     }
     // get attribs for element
     $attribs = array('id' => $page->getId(), 'title' => $title);
     $attribs['class'] = '';
     if ($addClassToListItem === false) {
         $attribs['class'] = $page->getClass();
     }
     // Stoyan
     $attribs['class'] .= $attribs['class'] ? ' ' : '';
     $attribs['class'] .= $page->getAnchorClass();
     //		echo 'Menu<pre>';
     //		echo 'Class: ' . $page->getClass();
     //		echo 'Anchor Class: ' . $page->getAnchorClass();
     //		print_r($attribs);
     //		echo '</pre>';
     // does page have a href?
     $href = $page->getHref();
     if ($href) {
         $element = 'a';
         $attribs['href'] = $href;
         $attribs['target'] = $page->getTarget();
     } else {
         $element = 'span';
     }
     $html = '<' . $element . $this->htmlAttribs($attribs) . '>';
     if ($escapeLabel === true) {
         $escaper = $this->view->plugin('escapeHtml');
         $html .= $escaper($label);
     } else {
         $html .= $label;
     }
     $html .= '</' . $element . '>';
     return $html;
 }
开发者ID:houzoumi,项目名称:fmi,代码行数:53,代码来源:Menu.php

示例11: acceptAcl

 /**
  * Determines whether a page should be accepted by ACL when iterating
  *
  * Rules:
  * - If helper has no ACL, page is accepted
  * - If page has a resource or privilege defined, page is accepted
  *   if the ACL allows access to it using the helper's role
  * - If page has no resource or privilege, page is accepted
  *
  * @param  AbstractPage $page  page to check
  * @return bool                whether page is accepted by ACL
  */
 protected function acceptAcl(AbstractPage $page)
 {
     if (!($acl = $this->getAcl())) {
         // no acl registered means don't use acl
         return true;
     }
     $role = $this->getRole();
     $roles = $this->getRoles();
     $resource = $page->getResource();
     $privilege = $page->getPrivilege();
     if (!$roles) {
         $roles = array($roles);
     }
     if ($resource || $privilege) {
         foreach ($roles as $r) {
             // determine using helper role and page resource/privilege
             return $acl->hasResource($resource) && $acl->isAllowed($r, $resource);
         }
         return false;
     }
     return true;
 }
开发者ID:siad007,项目名称:ctrllib,代码行数:34,代码来源:Navigation.php

示例12: testGetChildrenShouldReturnTheCurrentPage

 public function testGetChildrenShouldReturnTheCurrentPage()
 {
     $container = new Navigation\Navigation();
     $page = Page\AbstractPage::factory(array('type' => 'uri'));
     $container->addPage($page);
     $this->assertEquals($page, $container->getChildren());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:7,代码来源:ContainerTest.php

示例13: htmlify

 /**
  * Returns an HTML string containing an 'a' element for the given page if
  * the page's href is not empty, and a 'span' element if it is empty
  *
  * Overrides {@link AbstractHelper::htmlify()}.
  *
  * @param  AbstractPage $page   page to generate HTML for
  * @param bool $escapeLabel     Whether or not to escape the label
  * @return string               HTML string for the given page
  */
 public function htmlify(AbstractPage $page, $escapeLabel = true)
 {
     // get label and title for translating
     $label = $page->getLabel();
     $title = $page->getTitle();
     // translate label and title?
     if (null !== ($translator = $this->getTranslator())) {
         $textDomain = $this->getTranslatorTextDomain();
         if (is_string($label) && !empty($label)) {
             $label = $translator->translate($label, $textDomain);
         }
         if (is_string($title) && !empty($title)) {
             $title = $translator->translate($title, $textDomain);
         }
     }
     // get attribs for element
     $attribs = array('id' => $page->getId(), 'title' => $title, 'class' => $page->getClass());
     // does page have a href?
     $href = $page->getHref();
     if ($href) {
         $element = 'a';
         $attribs['href'] = $href;
         $attribs['target'] = $page->getTarget();
     } else {
         $element = 'span';
     }
     $html = '<' . $element . $this->htmlAttribs($attribs) . '>';
     if ($escapeLabel === true) {
         $escaper = $this->view->plugin('escapeHtml');
         $html .= $escaper($label);
     } else {
         $html .= $label;
     }
     $html .= '</' . $element . '>';
     return $html;
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:46,代码来源:Menu.php

示例14: hasPage

 /**
  * Checks if the container has the given page
  *
  * @param  Page\AbstractPage $page page to look for
  * @param  bool $recursive [optional] whether to search recursively.
  *                         Default is false.
  * @return bool whether page is in container
  */
 public function hasPage(Page\AbstractPage $page, $recursive = false)
 {
     if (array_key_exists($page->hashCode(), $this->index)) {
         return true;
     } elseif ($recursive) {
         foreach ($this->pages as $childPage) {
             if ($childPage->hasPage($page, true)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:eltonoliveira,项目名称:jenkins,代码行数:21,代码来源:AbstractContainer.php

示例15: htmlify

 /**
  * Returns an HTML string containing an 'a' element for the given page
  *
  * @param  AbstractPage $page  page to generate HTML for
  * @return string
  */
 public function htmlify(AbstractPage $page)
 {
     // get label and title for translating
     $label = $page->getLabel();
     $title = $page->getTitle();
     if (null !== ($translator = $this->getTranslator())) {
         $textDomain = $this->getTranslatorTextDomain();
         if (is_string($label) && !empty($label)) {
             $label = $translator->translate($label, $textDomain);
         }
         if (is_string($title) && !empty($title)) {
             $title = $translator->translate($title, $textDomain);
         }
     }
     // get attribs for anchor element
     $attribs = array('id' => $page->getId(), 'title' => $title, 'class' => $page->getClass(), 'href' => $page->getHref(), 'target' => $page->getTarget());
     $escaper = $this->view->plugin('escapeHtml');
     return '<a' . $this->htmlAttribs($attribs) . '>' . $escaper($label) . '</a>';
 }
开发者ID:eltonoliveira,项目名称:jenkins,代码行数:25,代码来源:AbstractHelper.php


注:本文中的Zend\Navigation\Page\AbstractPage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。