/** * Return true when then $source does NOT contain all items in the parameterFilter * * @param \Gems_Menu_ParameterCollector $source * @param boolean $raiseConditions * @param mixed $condition * @return boolean */ private function _applyParameterFilter(\Gems_Menu_ParameterCollector $source, $raiseConditions, &$condition) { if ($this->_parameterFilter) { foreach ($this->_parameterFilter as $name => $testValue) { $paramValue = $source->getMenuParameter($name); if ($paramValue instanceof \MUtil_Lazy_LazyInterface) { if ($raiseConditions) { $paramValue = \MUtil_Lazy::rise($paramValue); } else { if (is_array($testValue)) { $newCondition = new \MUtil_Lazy_Call('in_array', array($paramValue, $testValue)); } else { $newCondition = \MUtil_Lazy::comp($testValue, '==', $paramValue); } if ($condition instanceof \MUtil_Lazy_LazyInterface) { if ($condition instanceof \MUtil_Lazy_LazyAnd) { $condition->add($newCondition); } else { $condition = new \MUtil_Lazy_LazyAnd($condition, $newCondition); } } else { $condition = $newCondition; } continue; } } if (is_array($testValue)) { if (!in_array($paramValue, $testValue)) { if (\Gems_Menu::$verbose) { // Mutil_Echo::backtrace(); \MUtil_Echo::r($name . ' => ' . print_r($testValue, true) . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); } return true; } } else { if ($testValue !== $paramValue) { if (\Gems_Menu::$verbose) { // Mutil_Echo::backtrace(); \MUtil_Echo::r($name . ' => ' . $testValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); } return true; } } } } }
/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // Signal the bridge that we need these values $bridge->gr2t_id_respondent_track; $bridge->gr2t_id_respondent_track; $bridge->gr2o_patient_nr; $bridge->can_edit; $controller = $this->request->getControllerName(); $menuList = $this->menu->getMenuList(); $menuList->addByController($controller, 'show-track')->addByController($controller, 'edit-track')->addParameterSources($bridge)->setLowerCase()->showDisabled(); $bridge->setOnEmpty($this->_('No other assignments of this track.')); // If we have a track Id and is not excluded: mark it! if ($this->respondentTrackId && !$this->excludeCurrent) { $bridge->tr()->appendAttrib('class', \MUtil_Lazy::iff(\MUtil_Lazy::comp($bridge->gr2t_id_respondent_track, '==', $this->respondentTrackId), 'currentRow', null)); } // Add show-track button if allowed, otherwise show, again if allowed $bridge->addItemLink($menuList->getActionLink($controller, 'show-track')); parent::addBrowseTableColumns($bridge, $model); // Add edit-track button if allowed (and not current $bridge->addItemLink($menuList->getActionLink($controller, 'edit-track')); }
/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if ($this->showSelected) { $selectedClass = \MUtil_Lazy::iff(\MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); } else { $selectedClass = null; } $bridge->th($this->_('Status')); $td = $bridge->tdh(\MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); $td->appendAttrib('class', $selectedClass); $bridge->th($this->_('Question')); if ($model->has('grr_name') && $model->has('gtf_field_name')) { $td = $bridge->tdh(\MUtil_Lazy::iif($bridge->grr_name, array($bridge->grr_name, $br)), \MUtil_Lazy::iif($bridge->gtf_field_name, array($bridge->gtf_field_name, $br)), $bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)); } else { $td = $bridge->tdh($bridge->gto_round_description, \MUtil_Lazy::iif($bridge->gto_round_description, $br), \MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)); } $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); // Apply filter on the answers displayed $answerNames = $model->getItemsOrdered(); if ($this->answerFilter instanceof \Gems_Tracker_Snippets_AnswerNameFilterInterface) { $answerNames = $this->answerFilter->filterAnswers($bridge, $model, $answerNames); } foreach ($answerNames as $name) { $label = $model->get($name, 'label'); if (null !== $label) { // Was strlen($label), but this ruled out empty sub-questions $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); $td = $bridge->td($bridge->{$name}); $td->appendAttrib('class', 'answer'); $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); } } $bridge->th($this->_('Token')); $tokenUpper = $bridge->gto_id_token->strtoupper(); if ($this->showTakeButton && ($menuItem = $this->menu->find(array('controller' => 'ask', 'action' => 'take', 'allowed' => true)))) { $source = new \Gems_Menu_ParameterSource(); $source->setTokenId($bridge->gto_id_token); $source->offsetSet('can_be_taken', $bridge->can_be_taken); $link = $menuItem->toActionLink($source); if ($link) { $link->title = array($this->_('Token'), $tokenUpper); } $td = $bridge->tdh($bridge->can_be_taken->if($link, $tokenUpper)); } else { $td = $bridge->tdh($tokenUpper); } $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); }
/** * Returns a sequence of frist, previous, range, next and last conditional links. * * The condition is them being valid links, otherwise they are returned as span * elements. * * Note: This sequence is not added automatically to this object, you will have to * position it manually. * * @param string $first Label for goto first page link * @param string $previous Label for goto previous page link * @param string $next Label for goto next page link * @param string $last Label for goto last page link * @param string $glue In between links glue * @param mixed $args \MUtil_Ra::args extra arguments applied to all links * @return \MUtil_Html_Sequence */ public function pageLinks($first = '<<', $previous = '<', $next = '>', $last = '>>', $glue = ' ', $args = null) { $argDefaults = array('first' => '<<', 'previous' => '<', 'next' => '>', 'last' => '>>', 'glue' => ' '); $argNames = array_keys($argDefaults); $args = \MUtil_Ra::args(func_get_args(), $argNames, $argDefaults); foreach ($argNames as $name) { ${$name} = $args[$name]; unset($args[$name]); } $div = \MUtil_Html::create()->sequence(array('glue' => $glue)); if ($first) { // Can be null or array() $div[] = $this->firstPage((array) $first + $args); } if ($previous) { // Can be null or array() $div[] = $this->previousPage((array) $previous + $args); } $div[] = $this->rangePages($glue, $args); if ($next) { // Can be null or array() $div[] = $this->nextPage((array) $next + $args); } if ($last) { // Can be null or array() $div[] = $this->lastPage((array) $last + $args); } return \MUtil_Lazy::iff(\MUtil_Lazy::comp($this->pages->pageCount, '>', 1), $div); }
/** * Returns a sequence of frist, previous, range, next and last conditional links. * * The condition is them being valid links, otherwise they are returned as span * elements. * * Note: This sequence is not added automatically to this object, you will have to * position it manually. * * @param string $first Label for goto first page link * @param string $previous Label for goto previous page link * @param string $next Label for goto next page link * @param string $last Label for goto last page link * @param string $glue In between links glue * @param mixed $args \MUtil_Ra::args extra arguments applied to all links * @return \MUtil_Html_Sequence */ public function pageLinks($first = '<<', $previous = '<', $next = '>', $last = '>>', $glue = ' ', $args = null) { $argDefaults = array('first' => '<<', 'previous' => '<', 'next' => '>', 'last' => '>>', 'glue' => ' '); $argNames = array_keys($argDefaults); $args = \MUtil_Ra::args(func_get_args(), $argNames, $argDefaults); foreach ($argNames as $name) { ${$name} = $args[$name]; unset($args[$name]); } $container = \MUtil_Html::create()->ul(array('class' => 'pagination pagination-sm pull-left')); if ($first) { // Can be null or array() $container[] = $this->firstPage((array) $first + $args); } if ($previous) { // Can be null or array() $container[] = $this->previousPage((array) $previous + $args); } $this->range = true; $container[] = $this->rangePages('', $args); $this->range = false; if ($next) { // Can be null or array() $container[] = $this->nextPage((array) $next + $args); } if ($last) { // Can be null or array() $container[] = $this->lastPage((array) $last + $args); } return \MUtil_Lazy::iff(\MUtil_Lazy::comp($this->pages->pageCount, '>', 1), $container); }