protected function createMenuLinks($includeLevel = 2, $parentLabel = true)
 {
     if ($currentItem = $this->menu->getCurrent()) {
         $links = array();
         $childItems = $currentItem->getChildren();
         $parameters = $currentItem->getParameters();
         $request = $this->getRequest();
         $showDisabled = $includeLevel > 99;
         $menuSource = $this->menu->getParameterSource();
         if ($parentItem = $currentItem->getParent()) {
             // Add only if not toplevel.
             if ($parentItem instanceof \Gems_Menu_SubMenuItem && $parentItem->has('controller')) {
                 $key = $parentItem->get('controller') . '.' . $parentItem->get('action');
                 if ($parentLabel) {
                     if (true === $parentLabel) {
                         $parentLabel = $this->_('Cancel');
                     }
                     $links[$key] = $parentItem->toActionLink($request, $this, $menuSource, $parentLabel);
                 } else {
                     $links[$key] = $parentItem->toActionLink($request, $this, $menuSource);
                 }
                 if ($includeLevel > 1) {
                     $childItems = array_merge($parentItem->getChildren(), $childItems);
                 }
             }
         }
         if ($includeLevel < 1) {
             return $links;
         }
         //The reset parameter blocks the display of buttons, so we unset it
         unset($parameters['reset']);
         if ($childItems) {
             foreach ($childItems as $menuItem) {
                 if ($menuItem !== $currentItem) {
                     // Select only children with the same parameters
                     if ($menuItem->getParameters() == $parameters) {
                         // And buttons only if include level higher than 2.
                         if ($includeLevel > 2 || !$menuItem->get('button_only')) {
                             if ($link = $menuItem->toActionLink($request, $this, $menuSource, $showDisabled)) {
                                 $key = $menuItem->get('controller') . '.' . $menuItem->get('action');
                                 $links[$key] = $link;
                             }
                         }
                     }
                 }
             }
         }
         return $links;
     }
 }
 /**
  * Hook that loads the form data from $_POST or the model
  *
  * Or from whatever other source you specify here.
  */
 protected function loadFormData()
 {
     parent::loadFormData();
     $surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
     if (isset($this->formData['survey']) && $this->formData['survey'] && !$this->_survey instanceof \Gems_Tracker_Survey) {
         $this->_survey = $this->loader->getTracker()->getSurvey($this->formData['survey']);
     }
     if ($this->_survey instanceof \Gems_Tracker_Survey) {
         // Add (optional) survey specific translators
         $extraTrans = $this->importLoader->getAnswerImporters($this->_survey);
         if ($extraTrans) {
             $this->importTranslators = $extraTrans + $this->importTranslators;
             $this->_translatorDescriptions = false;
             $this->importModel->set('trans', 'multiOptions', $this->getTranslatorDescriptions());
         }
     }
     if ($this->_survey instanceof \Gems_Tracker_Survey) {
         $this->targetModel = $this->_survey->getAnswerModel($this->locale->toString());
         $this->importer->setTargetModel($this->targetModel);
         $source = $this->menu->getParameterSource();
         $source->offsetSet('gsu_has_pdf', $this->_survey->hasPdf() ? 1 : 0);
         $source->offsetSet('gsu_active', $this->_survey->isActive() ? 1 : 0);
     }
     // \MUtil_Echo::track($this->formData);
 }
 /**
  * Constructs the form
  *
  * @param boolean $hideGroup When true group checkbox is hidden
  * @return \Gems_Form_TableForm
  */
 public function getForm($hideGroup = false)
 {
     $form = new \Gems_Form();
     $form->setAttrib('target', '_blank');
     if ($hideGroup) {
         $element = new \Zend_Form_Element_Hidden('group');
     } else {
         $element = new \Zend_Form_Element_Checkbox('group');
         $element->setLabel($this->_('Group surveys'));
     }
     $element->setValue(1);
     $form->addElement($element);
     $element = new \Zend_Form_Element_Select('format');
     $element->setLabel($this->_('Output format'));
     $outputFormats = array('html' => 'HTML');
     if ($this->_pdf->hasPdfExport()) {
         $outputFormats['pdf'] = 'PDF';
         $element->setValue('pdf');
     }
     $element->setMultiOptions($outputFormats);
     $form->addElement($element);
     $element = new \Zend_Form_Element_Submit('export');
     $element->setLabel($this->_('Export'))->setAttrib('class', 'button');
     $form->addElement($element);
     $links = $this->menu->getMenuList();
     $links->addParameterSources($this->request, $this->menu->getParameterSource());
     $links->addCurrentParent($this->_('Cancel'));
     if (count($links)) {
         $element = new \MUtil_Form_Element_Html('menuLinks');
         $element->setValue($links);
         // $element->setOrder(999);
         $form->addElement($element);
     }
     return $form;
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $menuList = $this->menu->getMenuList();
     $menuList->addParameterSources($this->request, $this->menu->getParameterSource());
     // \MUtil_Echo::track($this->request->getParams(), $this->menu->getParameterSource()->getArrayCopy());
     $this->addButtons($menuList);
     if ($menuList->render($view)) {
         return \MUtil_Html::create('div', array('class' => 'buttons', 'renderClosingTag' => true), $menuList);
     }
 }
 /**
  * overrule to add your own buttons.
  *
  * @return \Gems_Menu_MenuList
  */
 protected function getMenuList()
 {
     $links = $this->menu->getMenuList();
     $links->addParameterSources($this->request, $this->menu->getParameterSource());
     $links->addCurrentParent($this->_('Cancel'));
     if ($this->menuShowSiblings) {
         $links->addCurrentSiblings();
     }
     if ($this->menuShowChildren) {
         $links->addCurrentChildren();
     }
     return $links;
 }
 /**
  * overrule to add your own buttons.
  *
  * @return \Gems_Menu_MenuList
  */
 protected function getMenuList()
 {
     $links = $this->menu->getMenuList();
     $links->addParameterSources($this->request, $this->menu->getParameterSource());
     $source = new \Gems_Menu_ParameterSource(array('gro_id_track' => $this->trackId, 'gro_id_round' => $this->trackEngine->getPreviousRoundId($this->roundId)));
     $links->append($this->menu->getCurrent()->toActionLink(true, \MUtil_Html::raw($this->_('&lt; Previous')), $source));
     $links->addCurrentParent($this->_('Cancel'));
     $links->addCurrentChildren();
     $links->addCurrentSiblings();
     $source->offsetSet('gro_id_round', $this->trackEngine->getNextRoundId($this->roundId));
     $links->append($this->menu->getCurrent()->toActionLink(true, \MUtil_Html::raw($this->_('Next &gt;')), $source));
     return $links;
 }
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $html = $this->getHtmlSequence();
     $request = $this->request;
     $html->hr(array('class' => 'noprint'));
     $params = $request->getParams();
     $state = $params;
     // Use current state for pdf export
     if (isset($params['fullanswers'])) {
         unset($params['fullanswers']);
     } else {
         $params['fullanswers'] = 1;
     }
     $url = array('controller' => $request->getControllerName(), 'action' => $request->getActionName(), 'routereset' => true) + $params;
     $html->actionLink($url, $this->_('Toggle'));
     // Now add the menulist all buttons under answer
     $menuList = $this->menu->getMenuList();
     $menuList->addParameterSources($this->menu->getParameterSource())->addCurrentChildren();
     $html[] = $menuList;
     $html->hr(array('class' => 'noprint'));
     return $html;
 }