* @link <>
*/
class Toolkit_Template_Navigation_Factory
- extends Toolkit_NavigationFactoryAbstract
+ extends Toolkit_NavigationFactoryAbstract
{
/**
* Description for $_gateway
* @var Toolkit_Toolbox_PageGatewayAbstract
* @access private
*/
- private $_gateway;
+ private $_gateway;
/**
* Sets gateway
* @access public
* @return void
*/
- public function setGateway(Toolkit_Toolbox_PageGatewayAbstract $gateway)
- {
- $this->_gateway = $gateway;
- }
+ public function setGateway(Toolkit_Toolbox_PageGatewayAbstract $gateway)
+ {
+ $this->_gateway = $gateway;
+ }
/**
* NOTE: You have different renderers that you can choose for the main
* @access public
* @return Toolkit_Template_Navigation_SideNavigation
*/
- public function createSideNav(
- Toolkit_Toolbox_PageGatewayAbstract $gateway = null
- ) {
- return new Toolkit_Template_Navigation_SideNavigation(
- new HTML_Menu(),
- new Toolkit_Template_Navigation_Renderer_DirectTreeSideNavTitle($this->_gateway)
- );
- }
+ public function createSideNav(
+ Toolkit_Toolbox_PageGatewayAbstract $gateway = null
+ ) {
+ return new Toolkit_Template_Navigation_SideNavigation(
+ new HTML_Menu(),
+ new Toolkit_Template_Navigation_Renderer_DirectTreeSideNavTitle(
+ $this->_gateway,
+ false,
+ 'reset-list'
+ )
+ );
+ }
/**
* New main nav added can use
* @access public
* @return Toolkit_Template_Navigation_MainNavigationDynamic
*/
- public function createMainNav()
- {
- return new Toolkit_Template_Navigation_MainNavigationDynamic(
- new HTML_Menu(),
+ public function createMainNav()
+ {
+ return new Toolkit_Template_Navigation_MainNavigationDynamic(
+ new HTML_Menu(),
/**
* new Toolkit_Template_Navigation_Renderer_DirectTreeLiId(
* $this->_gateway,
* 'current'
* )
*/
- new Toolkit_Template_Navigation_Renderer_DirectTreeLastLi(
- 'lastli'
- )
- );
- }
+ new Toolkit_Template_Navigation_Renderer_DirectTreeLastLi(
+ 'lastli'
+ )
+ );
+ }
}
?>
* @see References to other sections (if any)...
*/
class Toolkit_Template_Navigation_Renderer_DirectTreeSideNavTitle
- extends HTML_Menu_DirectTreeRenderer
+ extends HTML_Menu_DirectTreeRenderer
{
- // {{{ properties
+ // {{{ properties
- /**
- * Page gateway to use
- * @var Toolkit_Toolbox_PageGatewayAbstract
- * @access private
- */
- private $_gateway;
+ /**
+ * Page gateway to use
+ * @var Toolkit_Toolbox_PageGatewayAbstract
+ * @access private
+ */
+ private $_gateway;
private $_useTitleAsLink = false;
+ private $_class = null;
- // }}}
- // {{{ __construct()
+ // }}}
+ // {{{ __construct()
- /**
- * Constructor
- *
- * @param Toolkit_Toolbox_PageGatewayAbstract $gateway Page gateway to use
- *
- * @return void
- * @access public
- */
- public function __construct(
+ /**
+ * Constructor
+ *
+ * @param Toolkit_Toolbox_PageGatewayAbstract $gateway Page gateway to use
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct(
Toolkit_Toolbox_PageGatewayAbstract $gateway,
- $useTitleAsLink = false
+ $useTitleAsLink = false,
+ $class = null
) {
- $this->_gateway = $gateway;
+ $this->_gateway = $gateway;
$this->_useTitleAsLink = $useTitleAsLink;
- }
+ $this->_class = $class;
+ }
- // }}}
+ // }}}
- // {{{ finishMenu()
+ // {{{ finishMenu()
/**
* Render nav with header before it
*
* Render the entire nav, then prepend the top level parent pages
- * navigation name as a head above the nav
+ * navigation name as a head above the nav
*
* @param integer $level Parameter description (if any) ...
- *
+ *
* @return void
* @access public
*/
- public function finishMenu($level)
- {
- parent::finishMenu($level);
- $topParentId = $this->_gateway->findTopParent($_GET['catid']);
- $page = $this->_gateway->find($topParentId);
+ public function finishMenu($level)
+ {
+ parent::finishMenu($level);
+ if (!is_null($this->_class)) {
+ $dom = new DOMDocument();
+ $htmlUTF8 = mb_convert_encoding($this->_html, 'HTML-ENTITIES', 'UTF-8');
+ @$dom->loadHTML($htmlUTF8);
+
+ $xpath = new DOMXPath($dom);
+ $element = $xpath->query("//*[@id='{$this->_id}']")->item(0);
+
+ $node = $dom->getElementsByTagName('ul')->item(0);
+ //$node->setAttribute('id', $this->_id);
+ if (!is_null($this->_class)) {
+ $node->setAttribute('class', $this->_class);
+ }
+
+ // Prevent auto tags and doctype from being added to the HTML
+ $this->_html = substr(
+ $dom->saveXML($dom->getElementsByTagName('ul')->item(0)),
+ 0
+ );
+ }
+ $topParentId = $this->_gateway->findTopParent($_GET['catid']);
+ $page = $this->_gateway->find($topParentId);
if ($this->_useTitleAsLink) {
$link = Toolkit_Template_Page::getSeoUrl(
$this->_gateway, $topParentId
= ($this->_useTitleAsLink)
? "<a href=\"{$link}\">{$page['navigation_name']}</a>"
: "{$page['navigation_name']}";
- $this->_html = "<h2>{$title}</h2>" . $this->_html;
- }
+ $this->_html = "<h2>{$title}</h2>" . $this->_html;
+ }
- // }}}
+ // }}}
}
* @see References to other sections (if any)...
*/
class Toolkit_Template_Navigation_Renderer_DirectTreeUlId
- extends HTML_Menu_DirectTreeRenderer
+ extends HTML_Menu_DirectTreeRenderer
{
- // {{{ properties
+ // {{{ properties
/**
* Id to be assigned to first ul as id
* @var string
* @access private
*/
- private $_id = null;
+ private $_id = null;
/**
* Id to be assigned to first ul as class
* @var string
private $_class = null;
/**
- * Database gateway for toolbox
+ * Database gateway for toolbox
* @var string
* @access private
*/
- private $_gateway;
+ private $_gateway;
- // }}}
- // {{{ __construct()
+ // }}}
+ // {{{ __construct()
/**
* Class constructor
* @param Toolkit_Toolbox_PageGatewayAbstract $gateway database gateway
* @param string $id id to be assigned to last li
* @param string $class id to be assigned to first ul as class
- *
+ *
* @return void
* @access public
*/
- public function __construct(
- Toolkit_Toolbox_PageGatewayAbstract $gateway,
- $id = null,
+ public function __construct(
+ Toolkit_Toolbox_PageGatewayAbstract $gateway,
+ $id = null,
$class = null
- ) {
- $this->_gateway = $gateway;
+ ) {
+ $this->_gateway = $gateway;
- if (!is_null($id)) {
- $this->_id = $id;
- }
+ if (!is_null($id)) {
+ $this->_id = $id;
+ }
if (!is_null($class)) {
- $this->_class = $class;
- }
- }
+ $this->_class = $class;
+ }
+ }
- // }}}
- // {{{ finishMenu()
+ // }}}
+ // {{{ finishMenu()
/**
* Rendering before finishing
*
- * if an id must be assigned to the last li element, then extract that
- * element from the string and adjust the opening template
+ * if an id must be assigned to the last li element, then extract that
+ * element from the string and adjust the opening template
*
* @param integer $level Parameter description (if any) ...
- *
+ *
* @return void
* @access public
*/
function finishMenu($level)
{
- parent::finishMenu($level);
- if (!is_null($this->_id)) {
- $dom = new DOMDocument();
- $htmlUTF8 = mb_convert_encoding($this->_html, 'HTML-ENTITIES', 'UTF-8');
- @$dom->loadHTML($htmlUTF8);
+ parent::finishMenu($level);
+ if (!is_null($this->_id)) {
+ $dom = new DOMDocument();
+ $htmlUTF8 = mb_convert_encoding($this->_html, 'HTML-ENTITIES', 'UTF-8');
+ @$dom->loadHTML($htmlUTF8);
- $xpath = new DOMXPath($dom);
- $element = $xpath->query("//*[@id='{$this->_id}']")->item(0);
+ $xpath = new DOMXPath($dom);
+ $element = $xpath->query("//*[@id='{$this->_id}']")->item(0);
$node = $dom->getElementsByTagName('ul')->item(0);
$node->setAttribute('id', $this->_id);
$node->setAttribute('class', $this->_class);
}
- // Prevent auto tags and doctype from being added to the HTML
- $this->_html = substr(
- $dom->saveXML($dom->getElementsByTagName('ul')->item(0)),
- 0
- );
- }
+ // Prevent auto tags and doctype from being added to the HTML
+ $this->_html = substr(
+ $dom->saveXML($dom->getElementsByTagName('ul')->item(0)),
+ 0
+ );
+ }
}
- // }}}
+ // }}}
}
/**
* Toolkit_Template_Navigation_SideNavigation
- *
+ *
* Description of Toolkit_Template_Navigation_SideNavigation
- *
+ *
* @category Toolkit
* @package Template/Navigation
* @author Jamie Kahgee <steve@gaslightmedia.com>
* @link <>
*/
class Toolkit_Template_Navigation_SideNavigation
- extends Toolkit_NavigationAbstract implements Toolkit_INavigation
+ extends Toolkit_NavigationAbstract implements Toolkit_INavigation
{
- // {{{ __construct()
+ // {{{ __construct()
/**
* Class constructor
- *
+ *
* @param HTML_Menu $menu
- * @param HTML_Menu_Renderer $rEngine
- *
+ * @param HTML_Menu_Renderer $rEngine
+ *
* @access public
*/
- public function __construct(
- HTML_Menu $menu,
- HTML_Menu_Renderer $rEngine
- ) {
- $this->menu = $menu;
- $this->rEngine = $rEngine;
- }
+ public function __construct(
+ HTML_Menu $menu,
+ HTML_Menu_Renderer $rEngine
+ ) {
+ $this->menu = $menu;
+ $this->rEngine = $rEngine;
+ }
- // }}}
- // {{{ setNavTemplates()
+ // }}}
+ // {{{ setNavTemplates()
/**
* Set nav templates
- *
+ *
* @access protected
- * @return void
+ * @return void
*/
- protected function setNavTemplates()
- {
- $tpl = '<a href="%s" %s>{Title}</a>';
- $this->rEngine->setEntryTemplate(
- HTML_MENU_ENTRY_INACTIVE,
- sprintf($tpl, '{url}', '', '{Title}')
- );
- $this->rEngine->setEntryTemplate(
- HTML_MENU_ENTRY_ACTIVE,
- sprintf($tpl, '{url}', 'id="current"', '{Title}')
- );
- $this->rEngine->setEntryTemplate(
- HTML_MENU_ENTRY_ACTIVEPATH,
- sprintf($tpl, '{url}', '', '{Title}')
- );
- }
+ protected function setNavTemplates()
+ {
+ $tpl = '<a href="%s" %s>{Title}</a>';
+ $this->rEngine->setEntryTemplate(
+ HTML_MENU_ENTRY_INACTIVE,
+ sprintf($tpl, '{url}', '', '{Title}')
+ );
+ $this->rEngine->setEntryTemplate(
+ HTML_MENU_ENTRY_ACTIVE,
+ sprintf($tpl, '{url}', 'id="current"', '{Title}')
+ );
+ $this->rEngine->setEntryTemplate(
+ HTML_MENU_ENTRY_ACTIVEPATH,
+ sprintf($tpl, '{url}', '', '{Title}')
+ );
+ }
- // }}}
- // {{{ setCurrentIndex()
+ // }}}
+ // {{{ setCurrentIndex()
/**
* Set current index
- *
+ *
* @access protected
- * @return void
+ * @return void
*/
- protected function setCurrentIndex()
- {
- $this->menu->forceCurrentIndex(filter_var($_GET['catid'], FILTER_SANITIZE_NUMBER_INT));
- }
+ protected function setCurrentIndex()
+ {
+ $this->menu->forceCurrentIndex(filter_var($_GET['catid'], FILTER_SANITIZE_NUMBER_INT));
+ }
- // }}}
- // {{{ getNavSructure()
+ // }}}
+ // {{{ getNavSructure()
/**
* Recursive function to create a multi dimensional array for sub nav
- *
- * create tree (A) at the starting page level, pass the tree up to
- * parent page, where tree (B) is created for that level. append
- * tree A to tree B as a sub under the correct parent
- *
- * @param Toolkit_Toolbox_GatewayAbstract $gateway Toolbox gateway
- * @param integer $id id to get subtree for
- * @param array $tree subtree created to be
- * passed up to the parent
- * level
- * @param integer $appendTo pageId to append the
- * passed up subtree to
+ *
+ * create tree (A) at the starting page level, pass the tree up to
+ * parent page, where tree (B) is created for that level. append
+ * tree A to tree B as a sub under the correct parent
+ *
+ * @param Toolkit_Toolbox_GatewayAbstract $gateway Toolbox gateway
+ * @param integer $id id to get subtree for
+ * @param array $tree subtree created to be
+ * passed up to the parent
+ * level
+ * @param integer $appendTo pageId to append the
+ * passed up subtree to
* @return array navigational array hash
* @access public
*/
- public function getNavStructure(
- Toolkit_Toolbox_GatewayAbstract $gateway,
- $id,
- array $tree = null,
- $appendTo = null
- ) {
- $currentPage = $gateway->findNavItem($id);
- $this->_currentPage = $currentPage['navigation_name'];
-
- $subPages = $gateway->findAllByParent($id);
+ public function getNavStructure(
+ Toolkit_Toolbox_GatewayAbstract $gateway,
+ $id,
+ array $tree = null,
+ $appendTo = null
+ ) {
+ $currentPage = $gateway->findNavItem($id);
+ $this->_currentPage = $currentPage['navigation_name'];
+
+ $subPages = $gateway->findAllByParent($id);
- $nav = array();
- foreach ($subPages as $subPage) {
- // no home page in sub nav
- if ( ($subPage['id'] != HOME_ID)
- && ($subPage['parent'] != MEMBERS_CATEGORY)
- && $subPage['active']
- ) {
- $nav[$subPage['id']] = array(
- 'Title' => htmlspecialchars($subPage['navigation_name']),
- 'url' => Toolkit_Template_Page::getSeoUrl($gateway, $subPage['id'])
- );
- }
- }
+ $nav = array();
+ foreach ($subPages as $subPage) {
+ // no home page in sub nav
+ if ( ($subPage['id'] != HOME_ID)
+ && ($subPage['parent'] != MEMBERS_CATEGORY)
+ && $subPage['active']
+ ) {
+ $nav[$subPage['id']] = array(
+ 'Title' => htmlspecialchars($subPage['navigation_name']),
+ 'url' => Toolkit_Template_Page::getSeoUrl($gateway, $subPage['id'])
+ );
+ }
+ }
- if ( is_array($tree)
- && !empty($tree)
- && array_key_exists($appendTo, $nav)
- ) {
- $nav[$appendTo]['sub'] = $tree;
- }
+ if ( is_array($tree)
+ && !empty($tree)
+ && array_key_exists($appendTo, $nav)
+ ) {
+ $nav[$appendTo]['sub'] = $tree;
+ }
- if ($currentPage['parent'] != 0) {
- return $this->getNavStructure(
- $gateway,
- $currentPage['parent'],
- $nav,
- $id
- );
- } else {
- return $nav;
- }
- }
+ if ($currentPage['parent'] != 0) {
+ return $this->getNavStructure(
+ $gateway,
+ $currentPage['parent'],
+ $nav,
+ $id
+ );
+ } else {
+ return $nav;
+ }
+ }
- // }}}
+ // }}}
}