/**
  * Answer a placeholder for a menu target
  * 
  * @param object MenuOrganizerSiteComponent $organizer
  * @return Component
  * @access protected
  * @since 12/18/07
  */
 protected function getMenuTargetPlaceholder(MenuOrganizerSiteComponent $organizer)
 {
     // Add a placeholder to our target if we don't have any children
     ob_start();
     print "<div style='height: 50px;'>";
     $authZ = Services::getService("AuthZ");
     $idMgr = Services::getService("Id");
     if ($authZ->isUserAuthorized($idMgr->getId("edu.middlebury.authorization.add_children"), $organizer->getQualifierId())) {
         print _("This Section has no Pages yet. <br/><br/>Add a Page by clicking the <strong>+ Page</strong> button for this Section and choose 'Page'.");
     } else {
         print " ";
         print "\n</div>";
         return new UnstyledBlock(ob_get_clean());
     }
     print "\n</div>";
     $placeholder = new UnstyledBlock(ob_get_clean());
     $title = str_replace('%1', $organizer->getParentComponent()->getDisplayName(), _("<em>Sub-Menu of</em> %1 <em>Target Placeholder</em>"));
     $controlsHTML = $this->getControlsHTML($organizer, $title, '', '#F00', '#F99', '#F66');
     $placeholder->setPreHTML($controlsHTML);
     $styleCollection = new StyleCollection('.placeholder_red_outline', 'placeholder_red_outline', 'Red Outline', 'A red outline around a menu placeholder');
     $styleCollection->addSP(new BorderSP('1px', 'solid', '#F00'));
     $placeholder->addStyle($styleCollection);
     return $placeholder;
 }
 /**
  * Visit a MenuOrganizerSiteComponent
  * 
  * @param object MenuOrganizerSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 6/6/08
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent)
 {
     if (!$this->_started) {
         $this->_started = true;
         return $siteComponent->getParentComponent()->acceptVisitor($this);
     }
     // If we hit a second menu, the one passed wasn't root.
     return false;
 }
 /**
  * Visit a MenuOrganizerSiteComponent
  * 
  * @param object MenuOrganizerSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent)
 {
     $parent = $siteComponent->getParentComponent();
     if (!$parent) {
         throw new OperationFailedException("No parent for " . $siteComponent->getId());
     }
     return $parent->acceptVisitor($this);
 }
 /**
  * Visit a menu organizer
  *
  * @param object MenuOrganizerSiteComponent
  * @return boolean
  * @access public
  * @since 8/1/08
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent)
 {
     $parent = $siteComponent->getParentComponent();
     return $parent->acceptVisitor($this);
 }
 /**
  * Answer a placeholder for a menu target
  * 
  * @param object MenuOrganizerSiteComponent $organizer
  * @return Component
  * @access protected
  * @since 12/18/07
  */
 protected function getMenuTargetPlaceholder(MenuOrganizerSiteComponent $organizer)
 {
     // Add a placeholder to our target if we don't have any children
     ob_start();
     $authZ = Services::getService("AuthZ");
     $idMgr = Services::getService("Id");
     if ($authZ->isUserAuthorized($idMgr->getId("edu.middlebury.authorization.add_children"), $organizer->getQualifierId())) {
         print "<div style='height: 50px; border: 1px solid #F00; margin: 0px 5px 5px 5px; padding: 5px;'>";
         print _("This Section has no Pages yet. <br/><br/>Add a Page by clicking the <strong>+ Page</strong> button for this Section and choose 'Page'.");
     } else {
         print "<div style='height: 50px; margin: 0px 5px 5px 5px; padding: 5px;'>";
         print " ";
     }
     print "\n</div>";
     $placeholder = new UnstyledBlock(ob_get_clean());
     return $placeholder;
 }
 /**
  * Visit a flow organizer and return the resultant GUI component [a container].
  * 
  * @param object FlowOrganizerSiteComponent
  * @return object Component
  * @access public
  * @since 5/18/07
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $organizer)
 {
     if ($organizer->getId() == $this->_flowOrgId) {
         return $this->visitTargetBlock();
     } else {
         return parent::visitMenuOrganizer($organizer);
     }
 }
示例#7
0
 /**
  * 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);
     }
 }
 /**
  * Answer controls for MenuOrganizer SiteComponents
  * 
  * @param SiteComponent $siteComponent
  * @return string
  * @access public
  * @since 4/17/06
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent)
 {
     // 		$this->controlsStart($siteComponent);
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::instance();
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) {
         $url = SiteDispatcher::quickURL('ui1', 'editMenu', array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->action));
         ob_start();
         print "\n\t\t\t\t<div style='text-align: center;'>";
         print "\n\t\t\t\t\t<a href='" . $url . "'>";
         print _("[ menu display options ]");
         print "</a>";
         print "\n\t\t\t\t</div>";
         $controls = ob_get_clean();
     } else {
         $controls = '';
     }
     return $controls;
     // 		return $this->controlsEnd($siteComponent);
 }
 /**
  * Add the menu display type to a menu
  * 
  * @param object MenuOrganizerSiteComponent $siteComponent
  * @param object DOMElement $element
  * @return void
  * @access protected
  * @since 6/9/08
  */
 protected function applyMenuDisplayType(MenuOrganizerSiteComponent $siteComponent, DOMElement $element)
 {
     if ($element->hasAttribute('menuDisplayType')) {
         $siteComponent->setDisplayType($element->getAttribute('menuDisplayType'));
     }
 }
 /**
  * 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)
 {
     $this->_filledTargetIds[$organizer->getId()] = $organizer->getTargetId();
     return $this->visitFlowOrganizer($organizer);
 }
 /**
  * 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;
 }