本文整理汇总了PHP中Varien_Data_Tree_Node::getLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Tree_Node::getLevel方法的具体用法?PHP Varien_Data_Tree_Node::getLevel怎么用?PHP Varien_Data_Tree_Node::getLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Tree_Node
的用法示例。
在下文中一共展示了Varien_Data_Tree_Node::getLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BuildBranch
public function BuildBranch(Varien_Data_Tree_Node $node)
{
$buildString = '<li style="padding-left: 16px;">';
$buildString .= '<div class="tree-level-' . $node->getLevel() . '">';
if ($node->getChildrenCount() != 0) {
$buildString .= '<div class="opener" id="opener' . $node->getId() . '" OnClick="OpenMe(this)"></div>';
} else {
$buildString .= '<div class="child"></div>';
}
$buildString .= '
<input type="checkbox" class="inputcb" id="inputcb' . $node->getId() . '" OnClick="Decide(this)" enabled="false"/>
<div class="folder"></div>
<a tabindex="1" href="#" hidefocus="on" id="linkItem"><span unselectable="on" id="extdd-' . $node->getLevel() . '">' . $node->getName() . '</a>
';
$buildString .= '</div>';
if ($node->getChildrenCount() != 0) {
$buildString .= '<ul id="ToOpen' . $node->getId() . '">';
foreach ($node->getChildren() as $child) {
$buildString .= $this->BuildBranch($child);
}
$buildString .= '</ul>';
}
$buildString .= '</li>';
return $buildString;
}
示例2: _getHtml
/**
* @param Varien_Data_Tree_Node $menuTree
* @param string $childrenWrapClass
*
* @return string
*/
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
$html = '';
$counter = 1;
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
}
$blockName = $childLevel == 0 ? 'bennoislost.easy-navigation.renderer.with-children' : 'bennoislost.easy-navigation.renderer.single';
$html .= $this->_renderBlockItem($blockName, $childrenWrapClass, $child, $outermostClassCode);
$counter++;
}
return $html;
}
示例3: _getHtml
/**
* {@inheritDoc}
*/
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
}
if ($child->hasChildren()) {
$outermostClassCode .= ' data-toggle="dropdown" ';
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>';
$html .= $this->escapeHtml($child->getName());
if ($child->hasChildren()) {
$html .= ' <b class="caret"></b>';
}
$html .= '</span></a>';
if ($child->hasChildren()) {
if (!empty($childrenWrapClass)) {
$html .= '<div class="' . $childrenWrapClass . '">';
}
$html .= '<ul class="level' . $childLevel . ' dropdown-menu">';
if (Mage::getStoreConfig('catalog/navigation/top_in_dropdown') && $childLevel == 0) {
$prefix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_prefix');
$suffix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_suffix');
$html .= '<li class="level1 level-top-in-dropdown">';
$html .= '<a href="' . $child->getUrl() . '"><span>';
$html .= $this->escapeHtml($this->__($prefix) . ' ' . $child->getName() . ' ' . $suffix);
$html .= '</span></a>';
$html .= '</li>';
$html .= '<li class="divider"></li>';
}
$html .= $this->_getHtml($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass)) {
$html .= '</div>';
}
}
$html .= '</li>';
$counter++;
}
return $html;
}
示例4: _nodeToArrayPath
/**
* Convert node to array with path information.
* Path information skips the 'Root Catalog' (level=0) and 'Default Category' (level=1) levels.
*
* @param Varien_Data_Tree_Node $node
* @return array
*/
protected function _nodeToArrayPath(Varien_Data_Tree_Node $node, $parentPath)
{
// Only basic category data
$categories = array();
$category = array();
$category['category_id'] = $node->getId();
$category['parent_id'] = $node->getParentId();
$category['name'] = $node->getName();
$category['path'] = !empty($parentPath) && $node->getLevel() > 2 ? $parentPath . '/' . $node->getName() : $node->getName();
$category['is_active'] = $node->getIsActive();
$category['position'] = $node->getPosition();
$category['level'] = $node->getLevel();
$categories[] = $category;
foreach ($node->getChildren() as $child) {
$children = $this->_nodeToArrayPath($child, $category['path']);
$categories = array_merge($categories, $children);
}
return $categories;
}
示例5: _getHtml
/**
* Recursively generates top menu html from data that is specified in $menuTree
*
* @param Varien_Data_Tree_Node $menuTree
* @param string $childrenWrapClass
* @return string
*/
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
$brandCategoryId = Mage::getStoreConfig('brand/brand/category_id');
$_helperBrands = Mage::helper('brand');
$brandUrl = Mage::getUrl($_helperBrands->getBrandsUrl());
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$categoryId = str_replace("category-node-", "", $child->getId());
//$url=($categoryId==$brandCategoryId)?$brandUrl:$child->getUrl();
$url = $child->getUrl();
$html .= '<a href="' . $url . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
if ($child->hasChildren()) {
if (!empty($childrenWrapClass)) {
$html .= '<div class="' . $childrenWrapClass . '">';
}
$html .= '<ul class="level' . $childLevel . '">';
/*if($childLevel==0)
{
$html .= '<div class="submenu">';
}*/
$html .= $this->_getHtml($child, $childrenWrapClass);
/*if($childLevel==0)
{
$html .= '</div>';
}*/
$html .= '</ul>';
if (!empty($childrenWrapClass)) {
$html .= '</div>';
}
}
$html .= '</li>';
$counter++;
}
return $html;
}
示例6: nodeToArray
function nodeToArray(Varien_Data_Tree_Node $node)
{
$result = array();
$result['category_id'] = $node->getId();
$result['parent_id'] = $node->getParentId();
$result['name'] = $node->getName();
$result['is_active'] = $node->getIsActive();
$result['position'] = $node->getPosition();
$result['level'] = $node->getLevel();
$result['children'] = array();
foreach ($node->getChildren() as $child) {
$result['children'][] = $this->nodeToArray($child);
}
return $result;
}
示例7: nodeToArray
private function nodeToArray(Varien_Data_Tree_Node $node)
{
$result = array();
$category = Mage::getModel('catalog/category')->load($node->getId());
if ($category->getAvailableForSupplier() == 1) {
$result['category_id'] = $node->getId();
$result['parent_id'] = $node->getParentId();
$result['name'] = $node->getName();
$result['is_active'] = $node->getIsActive();
$result['position'] = $node->getPosition();
$result['level'] = $node->getLevel();
}
$result['children'] = array();
foreach ($node->getChildren() as $child) {
$result['children'][] = $this->nodeToArray($child);
}
return $result;
}
示例8: _getHtml
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . ' class="nav-link">' . $this->escapeHtml($child->getName()) . '</a>';
if ($child->hasChildren()) {
if (!empty($childrenWrapClass)) {
$html .= '<div class="' . $childrenWrapClass . '">';
}
$html .= '<ul class="level' . $childLevel . '">';
$html .= $this->_getHtml($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass)) {
$html .= '</div>';
}
$html .= '<span class="subnav-toggle"><i class="icon icon-angle-down"></i><i class="icon icon-angle-up"></i></span>';
}
$html .= '</li>';
$counter++;
}
return $html;
}
示例9: _getMenuItemClasses
protected function _getMenuItemClasses(Varien_Data_Tree_Node $item)
{
$classes = array();
$classes[] = 'level' . $item->getLevel();
$classes[] = $item->getPositionClass();
if ($item->getIsFirst()) {
$classes[] = 'first';
}
if ($item->getIsActive()) {
$classes[] = 'li_on';
}
if ($item->getIsLast()) {
$classes[] = 'last';
}
if ($item->getClass()) {
$classes[] = $item->getClass();
}
if ($item->hasChildren()) {
$classes[] = 'parent';
}
return $classes;
}
示例10: _getHtml
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass = null)
{
$css = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
if ($child->getId() == 'home-link') {
++$counter;
continue;
}
if ($child->getHeaderBgColor()) {
$css .= "li.{$child->getPositionClass()} {\n";
$css .= " background-color: {$child->getHeaderBgColor()} !important;\n";
$css .= "}\n";
}
if ($child->getHeaderBgHoverColor()) {
$css .= "li.{$child->getPositionClass()}:hover {\n";
$css .= " background-color: {$child->getHeaderBgHoverColor()} !important;\n";
$css .= "}\n";
}
$css .= "#wpmm-nav li.{$child->getPositionClass()} > a {\n";
if ($child->getTitleColor()) {
$css .= " color: {$child->getTitleColor()} !important;\n";
}
$css .= "}\n";
if ($child->getTitleHoverColor()) {
$css .= "#wpmm-nav li.{$child->getPositionClass()} > a:hover {\n";
$css .= " color: {$child->getTitleHoverColor()} !important;\n";
$css .= "}\n";
}
if ($child->getLevel() == 0) {
$css .= "li.{$child->getPositionClass()} > .wpmm-nav-content {\n";
if ($child->getContentBgColor()) {
$css .= " background-color: {$child->getContentBgColor()} !important;\n";
}
if ($child->getContentBgImage()) {
$css .= " background-image: url({$child->getContentBgImage()}) !important;\n";
}
switch ($child->getContentBgImgDm()) {
case WeltPixel_MegaMenu_Model_Category_Attribute_Source_Display::REPEAT:
$css .= " background-repeat: repeat;\n";
break;
case WeltPixel_MegaMenu_Model_Category_Attribute_Source_Display::STRETCH:
$css .= " background-size: cover;\n";
break;
}
$css .= "}\n";
}
if ($child->hasChildren()) {
$css .= $this->_getHtml($child);
}
++$counter;
}
if ($childLevel == 0) {
if ($this->getDisplayMode() == WeltPixel_Selector_Model_Adminhtml_System_Config_Displaymode::BOXED) {
$css .= "#wpmm-nav {\n";
$css .= " position: relative;\n";
$css .= "}\n";
}
}
return $css;
}
示例11: _treeNodeToOption
/**
* Convert tree node to dropdown option
*
* @return array
*/
protected function _treeNodeToOption(Varien_Data_Tree_Node $node, $without)
{
$option = array();
$option['label'] = $node->getName();
if ($node->getLevel() < 2) {
$option['value'] = array();
foreach ($node->getChildren() as $childNode) {
if (!in_array($childNode->getId(), $without)) {
$option['value'][] = $this->_treeNodeToOption($childNode, $without);
}
}
} else {
$option['value'] = $node->getId();
}
return $option;
}
示例12: move
/**
* Move tree node
*
* @todo Use adapter for generate conditions
* @param Varien_Data_Tree_Node $node
* @param Varien_Data_Tree_Node $newParent
* @param Varien_Data_Tree_Node $prevNode
*/
public function move($node, $newParent, $prevNode = null)
{
$position = 1;
$oldPath = $node->getData($this->_pathField);
$newPath = $newParent->getData($this->_pathField);
$newPath = $newPath . '/' . $node->getId();
$oldPathLength = strlen($oldPath);
$newLevel = $newParent->getLevel() + 1;
$levelDisposition = $newLevel - $node->getLevel();
$data = array($this->_levelField => new Zend_Db_Expr("{$this->_levelField} + '{$levelDisposition}'"), $this->_pathField => new Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))"));
$condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
$this->_conn->beginTransaction();
$reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
try {
if ($prevNode && $prevNode->getId()) {
$reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
$position = $prevNode->getData($this->_orderField) + 1;
} else {
$reorderCondition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$newParent->getData($this->_pathField)}/[0-9]+\$");
$select = $this->_conn->select()->from($this->_table, new Zend_Db_Expr("MIN({$this->_orderField})"))->where($reorderCondition);
$position = (int) $this->_conn->fetchOne($select);
}
$this->_conn->update($this->_table, $reorderData, $reorderCondition);
$this->_conn->update($this->_table, $data, $condition);
$this->_conn->update($this->_table, array($this->_orderField => $position, $this->_levelField => $newLevel), $this->_conn->quoteInto("{$this->_idField} = ?", $node->getId()));
$this->_conn->commit();
} catch (Exception $e) {
$this->_conn->rollBack();
throw new Exception("Can't move tree node due to error: " . $e->getMessage());
}
}
示例13: _nodeToArray
protected function _nodeToArray(Varien_Data_Tree_Node $node)
{
if (empty($node)) {
return array();
}
$result = $node->debug();
$result['category_id'] = $node->getId();
$result['parent_id'] = $node->getParentId();
$result['name'] = $node->getName();
$result['is_active'] = $node->getIsActive();
$result['is_anchor'] = $node->getIsAnchor();
$result['url_key'] = $node->getUrlKey();
$result['url'] = $node->getRequestPath();
$result['position'] = $node->getPosition();
$result['level'] = $node->getLevel();
$result['products'] = $node->getProducts();
$result['children'] = array();
foreach ($node->getChildren() as $child) {
$result['children'][] = $this->_nodeToArray($child);
}
return $result;
}
示例14: _getMenuItemClasses
/**
* Returns array of menu item's classes
*
* @param Varien_Data_Tree_Node $item
* @return array
*/
protected function _getMenuItemClasses(Varien_Data_Tree_Node $item)
{
if (Mage::getStoreConfig('mpanel/general/enabled')) {
$classes = array();
$classes[] = 'level' . $item->getLevel();
$classes[] = $item->getPositionClass();
if ($item->getIsFirst()) {
$classes[] = 'first';
}
if ($item->getIsActive()) {
$classes[] = 'active';
}
if ($item->getIsLast()) {
$classes[] = 'last';
}
if ($item->getClass()) {
$classes[] = $item->getClass();
}
if ($item->hasChildren()) {
if ($item->getLevel() == 0) {
$classes[] = 'dropdown';
} else {
$classes[] = 'dropdown-submenu';
}
}
return $classes;
} else {
$classes = array();
if ($item->getIsFirst()) {
$classes[] = '';
}
if ($item->getIsActive()) {
$classes[] = 'active';
}
if ($item->getIsLast()) {
$classes[] = '';
}
if ($item->getClass()) {
$classes[] = $item->getClass();
}
if ($item->hasChildren()) {
$classes[] = 'dropdown';
}
return $classes;
}
}
示例15: _getHtml
/**
* Recursively generates top menu html from data that is specified in $menuTree
*
* @param Varien_Data_Tree_Node $menuTree
* @param string $childrenWrapClass
* @return string
*/
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$childClass = '';
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
$megamenuData = array('type' => '', 'layout' => 'menu', 'menu' => 1, 'top' => '', 'bottom' => '', 'right' => '', 'percent' => 0);
if ($childLevel == 0) {
if ($outermostClass) {
$childClass .= ' ' . $outermostClass;
}
$category = Mage::getModel('catalog/category')->load(str_replace('category-node-', '', $child->getId()));
$childClass .= ' ' . $category->getOlegnaxmegamenuType();
$megamenuData['type'] = $category->getOlegnaxmegamenuType();
$megamenuData['layout'] = $category->getOlegnaxmegamenuLayout();
$megamenuData['menu'] = $category->getOlegnaxmegamenuMenu();
$megamenuData['top'] = $category->getOlegnaxmegamenuTop();
$megamenuData['bottom'] = $category->getOlegnaxmegamenuBottom();
$megamenuData['right'] = $category->getOlegnaxmegamenuRight();
$megamenuData['percent'] = $category->getOlegnaxmegamenuRightPercent();
if ($megamenuData['menu'] == '') {
$megamenuData['menu'] = 1;
}
if ($megamenuData['percent'] == '') {
$megamenuData['percent'] = 0;
}
if (empty($megamenuData['layout'])) {
$megamenuData['layout'] = 'menu';
}
}
$showChildren = false;
$leftClass = $rightClass = $top = $bottom = $right = $menu = '';
if ($child->hasChildren() || $childLevel == 0 && $megamenuData['type'] == 'wide' && (!empty($megamenuData['top']) || !empty($megamenuData['bottom']) || !empty($megamenuData['right']) && $megamenuData['percent'] != 0)) {
$showChildren = true;
if ($megamenuData['type'] == 'wide') {
$leftClass = 'megamenu-block-col-' . (6 - $megamenuData['percent']);
$rightClass = 'megamenu-block-col-' . $megamenuData['percent'];
$top = $this->_drawMenuBlock('top', $megamenuData['top']);
$bottom = $this->_drawMenuBlock('bottom', $megamenuData['bottom']);
$right = $this->_drawMenuBlock('right', $megamenuData['right']);
}
if ($megamenuData['menu'] == 1 || $megamenuData['type'] != 'wide') {
$menu .= '<ul class="level' . $childLevel . '">';
$menu .= $this->_getHtml($child, $childrenWrapClass);
$menu .= '</ul>';
$menu .= '<div class="clear"></div>';
}
if (!$child->hasChildren() || $megamenuData['menu'] != 1) {
$childClass .= ' parent parent-fake';
}
}
$child->setClass($childClass);
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
if ($showChildren) {
if (!empty($childrenWrapClass)) {
$html .= '<div class="' . $childrenWrapClass . '">';
}
if ($childLevel == 0 && $megamenuData['type'] == 'wide') {
switch ($megamenuData['layout']) {
case 'top_menu':
$html .= '<div class="megamenu-block-col ' . $leftClass . '">';
$html .= $top;
$html .= $menu;
$html .= '</div>';
$html .= '<div class="megamenu-block-col ' . $rightClass . '">';
$html .= $right;
$html .= '</div>';
$html .= '<div class="clear"></div>';
$html .= $bottom;
break;
case 'top_menu_bottom':
$html .= '<div class="megamenu-block-col ' . $leftClass . '">';
$html .= $top;
$html .= $menu;
$html .= $bottom;
$html .= '</div>';
$html .= '<div class="megamenu-block-col ' . $rightClass . '">';
$html .= $right;
$html .= '</div>';
$html .= '<div class="clear"></div>';
//.........这里部分代码省略.........