/** * Visit a MenuOrganizerSiteComponent * * @param object MenuOrganizerSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent) { foreach ($siteComponent->getSortedSubcomponents() as $child) { $child->acceptVisitor($this, true); } }
/** * Visit a menu organizer and return the menu GUI component that corresponds * to it. * * @param object MenuOrganizerSiteComponent * @return object Component * @access public * @since 4/3/06 */ public function visitMenuOrganizer(MenuOrganizerSiteComponent $organizer) { // Choose layout direction based on number of rows if ($this->_menuNestingLevel) { $layout = new YLayout(); } else { if ($organizer->getDirection() == "Left-Right/Top-Bottom") { $layout = new XLayout(); } else { if ($organizer->getDirection() == "Right-Left/Top-Bottom") { $layout = new XLayout(); $layout->setRenderDirection("Right-Left/Top-Bottom"); } else { $layout = new YLayout(); } } } if ($this->_menuNestingLevel) { $guiContainer = new SubMenu($layout, $this->_menuNestingLevel); } else { switch ($organizer->getDisplayType()) { case 'Menu_Left': $menuIndex = MENU_LEFT; break; case 'Menu_Right': $menuIndex = MENU_RIGHT; break; case 'Menu_Top': $menuIndex = MENU_TOP; break; case 'Menu_Bottom': $menuIndex = MENU_BOTTOM; break; default: throw new OperationFailedException("Unknown Menu DisplayType, '" . $organizer->getDisplayType() . "'."); } $guiContainer = new Menu($layout, $menuIndex); } $hasChildComponents = false; $i = 0; foreach ($organizer->getSortedSubcomponents() as $child) { try { ArgumentValidator::validate($child, ExtendsValidatorRule::getRule('SiteComponent')); } catch (Exception $e) { HarmoniErrorHandler::logException($e); continue; } $childGuiComponents = $child->acceptVisitor($this, true); if ($childGuiComponents === false || is_array($childGuiComponents) && !count($childGuiComponents)) { // do nothing } else { if (is_array($childGuiComponents)) { $hasChildComponents = true; // wrap the menu item if needed $this->addFlowChildWrapper($organizer, $i, $childGuiComponents[0]); // Add each of the the menuItems/submenus foreach (array_keys($childGuiComponents) as $key) { $guiContainer->add($childGuiComponents[$key]); } } else { $hasChildComponents = true; $guiContainer->add($this->addFlowChildWrapper($organizer, $i, $childGuiComponents)); } } $i++; } // Add a placeholder if no content exists so that the screen doesn't stretch if (!$hasChildComponents) { $noticeComponent = $this->getMenuTargetPlaceholder($organizer); if (isset($this->_emptyCellContainers[$organizer->getTargetId()])) { $this->_emptyCellContainers[$organizer->getTargetId()]->insertAtPlaceholder($this->_emptyCellPlaceholders[$organizer->getTargetId()], $noticeComponent, null, null, null, TOP); unset($this->_emptyCellContainers[$organizer->getTargetId()], $this->_emptyCellPlaceholders[$organizer->getTargetId()]); } else { $this->_missingTargets[$organizer->getTargetId()] = $noticeComponent; $this->_missingTargetWidths[$organizer->getTargetId()] = null; } } return $guiContainer; }