ACC SHELL

Path : /srv/www/vhosts/ambfinance/admin/library/TF/View/Helper/
File Upload :
Current File : /srv/www/vhosts/ambfinance/admin/library/TF/View/Helper/Copy of TreeMenu.php

<?php
/**
 * Tree Menu view helper - takes array ("title","depth") on input and
 * returns HTML source of menu as nested ULs
 *
 * @author Tomas Fejfar
 * @example $this->helper->TreeMenu($menu);
 * @package TF
 *
 */
class TF_View_Helper_TreeMenu {

	private $_result = "";

	private $_iterator = null;

	/**
	 * Main fcn
	 *
	 * @return string HTML source code
	 */
	public function treeMenu($tree = array(), $templatePath = "../partials/menu/treeitem.phtml") {
		$this->templatePath = $templatePath;
		$this->iterator = new ArrayIterator ( $tree );
		return $this->generateMenu ($this->iterator);
	}

	/**
	 * Internal generator fcn
	 *
	 * @return string $result HTML source code
	 * @param ArrayIterator &$iterator
	 * @param int $lastdepth
	 */
	function generateMenu(&$iterator, $lastdepth = 0) {
		$this->_result .= '<ul>' . "\r\n";
		$item = $iterator->current ();
		$lastItem ["depth"] = $lastdepth;
		while ( $iterator->valid () && ($item ["depth"] == $lastItem ["depth"]) ) {
			$this->_result .= '<li>' . "\r\n";
			$uH = new Zend_View_Helper_Url();
			if($item["url"] != ""){
				$path = $uH->url(array("categoryUrl"=>$item ["url"]),"Category");
			} else {
				$path = $uH->url(array("root"=>""),"base");
			}
			$this->_result .= '<a href="'.$path.'" title="'.$item ["title"].'">'.$item ["title"] . "</a>\r\n";
			$lastItem = $item;
			$iterator->next ();
			$item = $iterator->current ();
			if ($item ["depth"] > $lastItem ["depth"]) {
				$this->generateMenu ( $iterator, $item ["depth"] );
				$item = $iterator->current ();
			}
			$this->_result .= '</li>' . "\r\n";
		}
		if ($item) {
			$this->_result .= '</ul>' . "\r\n";
		}
		return $this->_result;
	}
}

ACC SHELL 2018