/** * Dispaly an appoitment as text * * @param value $value * @return string */ public function showAppointment($value) { if (!$value) { return $this->_('Unknown'); } if ($value instanceof \Gems_Agenda_Appointment) { $appointment = $value; } else { $appointment = $this->loader->getAgenda()->getAppointment($value); } if ($appointment instanceof \Gems_Agenda_Appointment) { if (!$this->menu instanceof \Gems_Mail) { $this->menu = $this->loader->getMenu(); } $menuItem = $this->menu->findAllowedController('appointment', 'show'); if ($menuItem) { if (!$this->request) { $this->request = \Zend_Controller_Front::getInstance()->getRequest(); } $href = $menuItem->toHRefAttribute(array('gap_id_appointment' => $appointment->getId()), $this->request); if ($href) { return \MUtil_Html::create('a', $href, $appointment->getDisplayString()); } } return $appointment->getDisplayString(); } return $value; }
/** * 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); }
/** * Set the route destination after the mail is sent */ protected function setAfterSendRoute() { if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) { $this->afterSendRouteUrl = array('action' => $this->routeAction); $keys = $this->model->getKeys(); if (count($keys) == 1) { $key = reset($keys); if (isset($this->formData[$key])) { $this->afterSendRouteUrl[\MUtil_Model::REQUEST_ID] = $this->formData[$key]; } } else { $i = 1; foreach ($keys as $key) { if (isset($this->formData[$key])) { $this->afterSendRouteUrl[\MUtil_Model::REQUEST_ID . $i] = $this->formData[$key]; } $i++; } } $this->afterSendRouteUrl['controller'] = $this->request->getControllerName(); $find['action'] = $this->afterSendRouteUrl['action']; $find['controller'] = $this->afterSendRouteUrl['controller']; if (null == $this->menu->find($find)) { $this->afterSendRouteUrl['action'] = 'index'; $this->resetRoute = true; } } }
/** * Action that switches the cron job lock on or off. */ public function cronLockAction() { // Switch lock $this->util->getCronJobLock()->reverse(); // Redirect $request = $this->getRequest(); $this->_reroute($this->menu->getCurrentParent()->toRouteUrl()); }
/** * Creates a reset button for the search form * * @return \Zend_Form_Element_Html or null */ protected function getAutoSearchReset() { if ($menuItem = $this->menu->getCurrent()) { $link = $menuItem->toActionLink($this->request, array('reset' => 1), $this->_('Reset search')); $element = new \MUtil_Form_Element_Html('reset'); $element->setValue($link); return $element; } }
/** * 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); } }
/** * Finds a specific active menu item * * @param string $defaultController * @param string|array $actions * @return array of \Gems_Menu_SubMenuItem */ protected function findMenuItems($defaultController, $actions = array('index')) { $output = array(); foreach ((array) $actions as $key => $action) { $controller = is_int($key) ? $defaultController : $key; $item = $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); if ($item) { $output[] = $item; } } return $output; }
/** * Set the footer of the browse table. * * Overrule this function to set the header differently, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model) { if ($this->displayMenu) { if (!$this->menuList) { $this->menuList = $this->menu->getCurrentMenuList($this->request, $this->_('Cancel')); } if ($this->menuList instanceof \Gems_Menu_MenuList) { $this->menuList->addParameterSources($bridge); } $bridge->tfrow($this->menuList, array('class' => 'centerAlign')); } }
/** * 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->_('< 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 >')), $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; }
/** * Returns the current html/head/title for this page. * * If the title is an array the seperator concatenates the parts. * * @param string $separator * @return string */ public function getTitle($separator = null) { if ($title_set = parent::getTitle($separator)) { return $title_set; } $title = array(); foreach ($this->menu->getActivePath($this->getRequest()) as $menuItem) { $title[] = $menuItem->get('label'); } if ($id = $this->getInstanceId()) { $title[] = $id; } return implode($separator, $title); }
public function indexAction() { $this->html->h2($this->_('Project information')); $data = $this->_getData(); $lock = $this->util->getMaintenanceLock(); if ($lock->isLocked()) { $label = $this->_('Turn Maintenance Mode OFF'); } else { $label = $this->_('Turn Maintenance Mode ON'); } $request = $this->getRequest(); $buttonList = $this->menu->getMenuList(); $buttonList->addParameterSources($request)->addByController($request->getControllerName(), 'maintenance', $label)->addByController($request->getControllerName(), 'cacheclean'); // $this->html->buttonDiv($buttonList); $this->_showTable($this->_('Version information'), $data); $this->html->buttonDiv($buttonList); }
public function indexAction() { $this->html->h2($this->_('Project information')); $versions = $this->loader->getVersions(); $data[$this->_('Project name')] = $this->project->name; $data[$this->_('Project version')] = $versions->getProjectVersion(); $data[$this->_('Gems version')] = $versions->getGemsVersion(); $data[$this->_('Gems build')] = $versions->getBuild(); $data[$this->_('Gems project')] = GEMS_PROJECT_NAME; $data[$this->_('Gems web directory')] = $this->getDirInfo(GEMS_WEB_DIR); $data[$this->_('Gems root directory')] = $this->getDirInfo(GEMS_ROOT_DIR); $data[$this->_('Gems code directory')] = $this->getDirInfo(GEMS_LIBRARY_DIR); $data[$this->_('Gems variable directory')] = $this->getDirInfo(GEMS_ROOT_DIR . '/var'); $data[$this->_('MUtil version')] = \MUtil_Version::get(); $data[$this->_('Zend version')] = \Zend_Version::VERSION; $data[$this->_('Application environment')] = APPLICATION_ENV; $data[$this->_('Application baseuri')] = $this->loader->getUtil()->getCurrentURI(); $data[$this->_('Application directory')] = $this->getDirInfo(APPLICATION_PATH); $data[$this->_('Application encoding')] = APPLICATION_ENCODING; $data[$this->_('PHP version')] = phpversion(); $data[$this->_('Server Hostname')] = php_uname('n'); $data[$this->_('Server OS')] = php_uname('s'); $data[$this->_('Time on server')] = date('r'); $driveVars = array($this->_('Session directory') => \Zend_Session::getOptions('save_path'), $this->_('Temporary files directory') => realpath(getenv('TMP'))); if ($system = getenv('SystemDrive')) { $driveVars[$this->_('System Drive')] = realpath($system); } foreach ($driveVars as $name => $drive) { $data[$name] = $this->getDirInfo($drive); } $lock = $this->util->getMaintenanceLock(); if ($lock->isLocked()) { $label = $this->_('Turn Maintenance Mode OFF'); } else { $label = $this->_('Turn Maintenance Mode ON'); } $request = $this->getRequest(); $buttonList = $this->menu->getMenuList(); $buttonList->addParameterSources($request)->addByController($request->getControllerName(), 'maintenance', $label)->addByController($request->getControllerName(), 'cacheclean'); // $this->html->buttonDiv($buttonList); $this->_showTable($this->_('Version information'), $data); $this->html->buttonDiv($buttonList); }
/** * Adds the siblings (= other children of the parent) of the current menu item to this list * * @param boolean $anyParameters When false, siblings must have the same parameter set as the current menu item * @return \Gems_Menu_MenuList (continuation pattern) */ public function addCurrentSiblings($anyParameters = false, $includeCurrent = false) { if ($current = $this->menu->getCurrent()) { if ($parent = $current->getParent()) { $parameters = $current->getParameters(); if ($includeCurrent) { $current = null; } foreach ($parent->getChildren() as $menuItem) { // Add any menu item that is not the current menu item // and that has the same parameters, unless $anyParameters is true. if ($menuItem !== $current && ($anyParameters || $menuItem->getParameters() == $parameters)) { $this->addMenuItem($menuItem); } } } } return $this; }
/** * 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) { $div = \MUtil_Html::create('div'); if ($this->surveyId && $this->data) { $div->h3(sprintf($this->_('Questions in survey %s'), $this->survey->getName())); $div->append(parent::getHtmlOutput($view)); } else { $this->addMessage($this->_('Survey not found')); if ($this->surveyId) { $div->pInfo(sprintf($this->_('Survey %s does not exist.'), $this->surveyId)); } else { $div->pInfo($this->_('Survey not specified.')); } } $item = $this->menu->getCurrentParent(); if ($item) { $div->append($item->toActionLink($this->_('Cancel'), $this->request)); } return $div; }
/** * If menu item does not exist or is not allowed, redirect to index * * @return \Gems_Snippets_ModelFormSnippetAbstract */ protected function setAfterSaveRoute() { parent::setAfterSaveRoute(); if (is_array($this->afterSaveRouteUrl)) { // Make sure controller is set if (!array_key_exists('controller', $this->afterSaveRouteUrl)) { $this->afterSaveRouteUrl['controller'] = $this->request->getControllerName(); } // Search array for menu item $find['controller'] = $this->afterSaveRouteUrl['controller']; $find['action'] = $this->afterSaveRouteUrl['action']; // If not allowed, redirect to index if (null == $this->menu->find($find)) { $this->afterSaveRouteUrl['action'] = 'index'; $this->resetRoute = true; } } // \MUtil_Echo::track($this->routeAction, $this->resetRoute); return $this; }
/** * Show the upgrades and level for a certain context * * Usage: show/context/<context> */ public function showAction() { $this->html->h3($this->getTopicTitle()); $context = $this->_getParam('id', 'gems'); $this->_upgrades->setContext($context); if ($info = $this->_upgrades->getUpgradesInfo($context)) { $this->html->table(array('class' => 'browser'))->tr()->th($this->_('Context'))->td($info['context'])->tr()->th($this->_('Level'))->td($info['level']); $data = $this->_upgrades->getUpgrades(); foreach ($data as $level => $row) { foreach ($this->menu->getCurrent()->getChildren() as $menuItem) { if ($menuItem->is('allowed', true)) { $show = true; if ($level <= $info['level'] && $menuItem->is('action', 'execute-to')) { //When this level is < current level don't allow to execute from current level to this one $show = false; } if ($level <= $info['level'] && $menuItem->is('action', 'execute-from')) { //When this level is < current level don't allow to execute from current level to this one $show = false; } if ($show) { $row['action'][] = $menuItem->toActionLinkLower($this->getRequest(), $row, array('from' => $level, 'to' => $level)); } } } $row['level'] = $level; $data[$level] = $row; } $displayColumns = array('level' => $this->_('Level'), 'info' => $this->_('Description'), 'action' => $this->_('Action')); $this->addSnippet('SelectiveTableSnippet', 'data', $data, 'class', 'browser', 'columns', $displayColumns); } else { $this->html[] = sprintf($this->_('Context %s not found!'), $context); } if ($parentItem = $this->menu->getCurrent()->getParent()) { $this->html[] = $parentItem->toActionLink($this->getRequest(), $this->_('Cancel')); } }
/** * Renders the entire report (including layout) * * @param array|string[] $respondentId * @param boolean $group Group same surveys or not * @param string $format html|pdf, the output format to use */ public function render($respondents, $group = true, $format = 'html') { $this->_group = $group; $this->html->snippet($this->_reportHeader); $respondentCount = count($respondents); $respondentIdx = 0; foreach ($respondents as $respondentId) { $respondentIdx++; $this->_exportRespondent($respondentId); if ($respondentIdx < $respondentCount) { // Add some whitespace between patients $this->html->div('', array('style' => 'height: 100px')); } } $this->html->snippet($this->_reportFooter, 'respondents', $respondents); $this->menu->setVisible(false); if ($this->escort instanceof \Gems_Project_Layout_MultiLayoutInterface) { $this->escort->layoutSwitch(); } $this->escort->postDispatch(\Zend_Controller_Front::getInstance()->getRequest()); \Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout(); \Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true); $this->view->layout()->content = $this->html->render($this->view); $content = $this->view->layout->render(); if ($format == 'pdf') { if (is_array($respondentId) && isset($respondentId['gr2o_id_organization'])) { $respondentId = $respondentId['gr2o_patient_nr']; } $filename = 'respondent-export-' . strtolower($respondentId) . '.pdf'; $content = $this->_pdf->convertFromHtml($content); $this->_pdf->echoPdfContent($content, $filename, true); } else { echo $content; } $this->menu->setVisible(true); }
protected function _getTracks($trackType, $pageRef, $trackTypeDescription) { switch ($trackType) { case 'tracks': $action = 'create'; break; case 'respondents': case 'staff': $action = 'insert'; break; } $orgId = intval($this->request->getParam(\MUtil_Model::REQUEST_ID2)); $cacheId = strtr(__CLASS__ . '_' . $trackType . '_' . $orgId, '\\/', '__'); $tracks = $this->cache->load($cacheId); if (!$tracks) { switch ($trackType) { case 'tracks': $sql = "SELECT gtr_id_track, gtr_track_name\n FROM gems__tracks\n WHERE gtr_date_start < CURRENT_TIMESTAMP AND\n (gtr_date_until IS NULL OR gtr_date_until > CURRENT_TIMESTAMP) AND\n gtr_active = 1 AND\n gtr_organizations LIKE '%|{$orgId}|%'\n ORDER BY gtr_track_name"; break; case 'respondents': $sql = "SELECT gsu_id_survey, gsu_survey_name\n FROM gems__surveys INNER JOIN gems__groups ON gsu_id_primary_group = ggp_id_group\n WHERE gsu_surveyor_active = 1 AND\n gsu_active = 1 AND\n ggp_group_active = 1 AND\n ggp_respondent_members = 1 AND\n gsu_insertable = 1 AND\n gsu_insert_organizations LIKE '%|{$orgId}|%'\n ORDER BY gsu_survey_name"; break; case 'staff': $sql = "SELECT gsu_id_survey, gsu_survey_name\n FROM gems__surveys INNER JOIN gems__groups ON gsu_id_primary_group = ggp_id_group\n WHERE gsu_surveyor_active = 1 AND\n gsu_active = 1 AND\n ggp_group_active = 1 AND\n ggp_staff_members = 1 AND\n gsu_insertable = 1 AND\n gsu_insert_organizations LIKE '%|{$orgId}|%'\n ORDER BY gsu_survey_name"; break; } $tracks = $this->db->fetchPairs($sql); $this->cache->save($tracks, $cacheId, array('surveys', 'tracks')); } $div = \MUtil_Html::create()->div(array('class' => 'toolbox btn-group')); $menuIndex = $this->menu->findController('track', 'index'); if ($tracks) { $menuCreate = $this->menu->findController('track', $action); if (!$menuCreate->isAllowed()) { return null; } if (\MUtil_Bootstrap::enabled()) { $div->button($trackTypeDescription, array('class' => 'toolanchor btn', 'data-toggle' => 'dropdown', 'type' => 'button')); $dropdownButton = $div->button(array('class' => 'btn dropdown-toggle', 'data-toggle' => 'dropdown', 'type' => 'button')); $dropdownButton->span(array('class' => 'caret', 'renderClosingTag' => true)); } else { $div->a($menuIndex->toHRefAttribute($this->request), $trackTypeDescription, array('class' => 'toolanchor')); } $data = new \MUtil_Lazy_RepeatableByKeyValue($tracks); if ($trackType == 'tracks') { $menuView = $this->menu->findController('track', 'view'); $params = array('gtr_id_track' => $data->key); } else { $menuView = $this->menu->findController('track', 'view-survey'); $params = array('gsu_id_survey' => $data->key); } if (\MUtil_Bootstrap::enabled()) { if (count($tracks) > $this->scrollTreshold) { // Add a header and scroll class so we keep rounded corners $top = $div->ul(array('class' => 'dropdown-menu', 'role' => 'menu')); $link = $top->li(array('class' => 'disabled'))->a('#'); $link->i(array('class' => 'fa fa-chevron-down fa-fw pull-left', 'renderClosingTag' => true)); $link->i(array('class' => 'fa fa-chevron-down fa-fw pull-right', 'renderClosingTag' => true)); // Add extra scroll-menu class $li = $top->li()->ul(array('class' => 'dropdown-menu scroll-menu', 'role' => 'menu'), $data)->li(); } else { $li = $div->ul(array('class' => 'dropdown-menu', 'role' => 'menu'), $data)->li(); } $link = $li->a($menuView->toHRefAttribute($this->request, $params), array('class' => 'rightFloat info')); $link->i(array('class' => 'fa fa-info-circle'))->raw(' '); if (count($tracks) > $this->scrollTreshold) { // Add a footer so we keep rounded corners $link = $top->li(array('class' => 'disabled'))->a('#'); $link->i(array('class' => 'fa fa-chevron-up fa-fw pull-left', 'renderClosingTag' => true)); $link->i(array('class' => 'fa fa-chevron-up fa-fw pull-right', 'renderClosingTag' => true)); } } else { $li = $div->ul($data)->li(); $li->a($menuView->toHRefAttribute($this->request, $params), array('class' => 'rightFloat'))->img(array('src' => 'info.png', 'width' => 12, 'height' => 12, 'alt' => $this->_('info'))); } $toolboxRowAttributes = array('class' => 'add'); $li->a($menuCreate->toHRefAttribute($this->request, $params), $data->value, $toolboxRowAttributes); } else { if (\MUtil_Bootstrap::enabled()) { $div->button($trackTypeDescription, array('class' => 'toolanchor btn disabled', 'data-toggle' => 'dropdown', 'type' => 'button')); $dropdownButton = $div->button(array('class' => 'disabled btn dropdown-toggle', 'data-toggle' => 'dropdown', 'type' => 'button')); $dropdownButton->span(array('class' => 'caret', 'renderClosingTag' => true)); $options = array('class' => 'dropdown-menu disabled', 'role' => 'menu'); } else { $div->a($menuIndex->toHRefAttribute($this->request), $trackTypeDescription, array('class' => 'toolanchor disabled')); $options = array('class' => 'disabled'); } $div->ul($this->_('None available'), $options); } return $div; }
/** * Finds a specific active menu item * * @param string $controller * @param string $action * @return \Gems_Menu_SubMenuItem */ protected function findMenuItem($controller, $action = 'index') { return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); }
/** * Redirects the user to his/her start page. * * @param \Gems_Menu $menu * @param \Zend_Controller_Request_Abstract $request * @return \Gems_Menu_SubMenuItem */ public function gotoStartPage(\Gems_Menu $menu, \Zend_Controller_Request_Abstract $request) { if ($this->isPasswordResetRequired()) { // Set menu OFF $menu->setVisible(false); $menuItem = $menu->findController('option', 'change-password'); // This may not yet be true, but is needed for the redirect. $menuItem->set('allowed', true); $menuItem->set('visible', true); } else { $menuItem = $menu->findFirst(array('allowed' => true, 'visible' => true)); } if ($menuItem) { // Prevent redirecting to the current page. if (!($menuItem->is('controller', $request->getControllerName()) && $menuItem->is('action', $request->getActionName()))) { if (!$menuItem->has('controller')) { //This is a container, try to find first active child $item = $menuItem; foreach ($item->sortByOrder()->getChildren() as $menuItem) { if ($menuItem->isAllowed() && $menuItem->has('controller')) { break; } $menuItem = null; } } if ($menuItem) { $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoRoute($menuItem->toRouteUrl($request), null, true); } } } return $menuItem; }