/**
  * Copied from parent, but insert chart instead of table after commented out part
  *
  * @param \Zend_View_Abstract $view
  * @return type
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $snippets = array();
     $data = $this->getModel()->load();
     // Find the first token with answers
     foreach ($data as $tokenData) {
         $token = $this->loader->getTracker()->getToken($tokenData)->refresh();
         $tokenAnswers = $token->getRawAnswers();
         if (!empty($tokenAnswers)) {
             break;
         }
     }
     // Some spacing with previous elements
     $snippets[] = \MUtil_Html::create()->p(\MUtil_Html::raw(' '), array('style' => 'clear:both;'));
     $config = $this->getConfig($token);
     // Fallback to all score elements in one chart when no config found
     if (!is_array($config)) {
         $config = array();
         foreach ($tokenAnswers as $key => $value) {
             if (substr(strtolower($key), 0, 5) == 'score') {
                 $config[0]['question_code'][] = $key;
             }
         }
     }
     // Set the default options
     $defaultOptions = array('data' => $data, 'showHeaders' => false, 'showButtons' => false);
     // Add all configured charts
     foreach ($config as $chartOptions) {
         $chartOptions = $chartOptions + $defaultOptions;
         $snippets[] = $this->loader->getSnippetLoader($this)->getSnippet('Survey_Display_BarChartSnippet', $chartOptions);
     }
     // Clear the floats
     $snippets[] = \MUtil_Html::create()->p(array('class' => 'chartfooter'));
     return $snippets;
 }
 /**
  * Adds columns from the model to the bridge that creates the browse table.
  *
  * Adds a button column to the model, if such a button exists in the model.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  * @rturn void
  */
 protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $model->setIfExists('gr2o_opened', 'tableDisplay', 'small');
     $model->setIfExists('grs_email', 'formatFunction', array('MUtil_Html_AElement', 'ifmail'));
     if ($menuItem = $this->findAllowedMenuItem('show')) {
         $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge));
     }
     // Newline placeholder
     $br = \MUtil_Html::create('br');
     // Display separator and phone sign only if phone exist.
     $phonesep = $bridge->itemIf($bridge->grs_phone_1, \MUtil_Html::raw('☏ '));
     $citysep = $bridge->itemIf($bridge->grs_zipcode, \MUtil_Html::raw('  '));
     if ($this->currentUser->hasPrivilege('pr.respondent.multiorg')) {
         $bridge->addMultiSort('gr2o_patient_nr', $br, 'gor_name');
         //, \MUtil_Html::raw(' '), 'gr2o_opened');
     } else {
         $bridge->addMultiSort('gr2o_patient_nr', $br, 'gr2o_opened');
     }
     $bridge->addMultiSort('name', $br, 'grs_email');
     $bridge->addMultiSort('grs_address_1', $br, 'grs_zipcode', $citysep, 'grs_city');
     $bridge->addMultiSort('grs_birthday', $br, $phonesep, 'grs_phone_1');
     if ($menuItem = $this->findAllowedMenuItem('edit')) {
         $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge));
     }
 }
 /**
  * Set column usage to use for the browser.
  *
  * Must be an array of arrays containing the input for TableBridge->setMultisort()
  *
  * @return array or false
  */
 public function getBrowseColumns()
 {
     // Newline placeholder
     $br = \MUtil_Html::create('br');
     $sp = \MUtil_Html::raw(' ');
     $columns[10] = array('glo_name', $br, 'glo_organizations');
     $columns[20] = array('glo_url', $br, 'glo_url_route');
     $columns[30] = array('glo_address_1', $br, 'glo_zipcode', \MUtil_Html::raw('  '), 'glo_city');
     $columns[40] = array(\MUtil_Html::raw('☏ '), 'glo_phone_1', $br, 'glo_filter', $sp, 'glo_match_to');
     return $columns;
 }
 /**
  * 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)
 {
     $bridge->gr2o_id_organization;
     if ($menuItem = $this->menu->find(array('controller' => 'appointment', 'action' => 'show', 'allowed' => true))) {
         $appButton = $menuItem->toActionLink($this->request, $bridge, $this->_('Show appointment'));
     } else {
         $appButton = null;
     }
     if ($menuItem = $this->menu->find(array('controller' => 'respondent', 'action' => 'show', 'allowed' => true))) {
         $respButton = $menuItem->toActionLink($this->request, $bridge, $this->_('Show respondent'));
     } else {
         $respButton = null;
     }
     $br = \MUtil_Html::create('br');
     $sp = \MUtil_Html::raw(' ');
     $table = $bridge->getTable();
     $table->appendAttrib('class', 'calendar');
     $table->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
     // Row with dates and patient data
     $table->tr(array('onlyWhenChanged' => true, 'class' => 'date'));
     $bridge->addSortable('date_only', $this->_('Date'), array('class' => 'date'))->colspan = 4;
     // Row with dates and patient data
     $bridge->tr(array('onlyWhenChanged' => true, 'class' => 'time middleAlign'));
     $td = $bridge->addSortable('gap_admission_time');
     $td->append(' ');
     $td->img()->src = 'stopwatch.png';
     $td->title = $bridge->date_only;
     // Add title, to make sure row displays when time is same as time for previous day
     $bridge->addSortable('gor_name');
     $bridge->addSortable('glo_name')->colspan = 2;
     $bridge->tr()->class = array('odd', $bridge->row_class);
     $bridge->addColumn($appButton)->class = 'middleAlign';
     $bridge->addMultiSort('gr2o_patient_nr', $sp, 'gap_subject', $br, 'name');
     // $bridge->addColumn(array($bridge->gr2o_patient_nr, $br, $bridge->name));
     $bridge->addMultiSort(array($this->_('With')), array(' '), 'gas_name', $br, 'gaa_name', array(' '), 'gapr_name');
     // $bridge->addColumn(array($bridge->gaa_name, $br, $bridge->gapr_name));
     $bridge->addColumn($respButton)->class = 'middleAlign rightAlign';
     unset($table[\MUtil_Html_TableElement::THEAD]);
 }
 /**
  * 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)
 {
     if ($model->has('row_class')) {
         $bridge->getTable()->tbody()->getFirst(true)->appendAttrib('class', $bridge->row_class);
     }
     if ($this->showMenu) {
         $showMenuItems = $this->getShowMenuItems();
         foreach ($showMenuItems as $menuItem) {
             $bridge->addItemLink($menuItem->toActionLinkLower($this->request, $bridge));
         }
     }
     // Newline placeholder
     $br = \MUtil_Html::create('br');
     $by = \MUtil_Html::raw($this->_(' / '));
     $sp = \MUtil_Html::raw(' ');
     // make sure search results are highlighted
     $this->applyTextMarker();
     $bridge->addMultiSort('grco_created', $br, 'gr2o_patient_nr', $sp, 'respondent_name', $br, 'grco_address', $br, 'gtr_track_name');
     $bridge->addMultiSort('grco_id_token', $br, 'assigned_by', $br, 'grco_sender', $br, 'gsu_survey_name');
     $bridge->addMultiSort('status', $by, 'filler', $br, 'grco_topic');
     if ($this->showMenu) {
         $items = $this->findMenuItems('track', 'show');
         $links = array();
         $params = array('gto_id_token' => $bridge->gto_id_token, \Gems_Model::ID_TYPE => 'token');
         $title = \MUtil_Html::create('strong', $this->_('+'));
         foreach ($items as $item) {
             if ($item instanceof \Gems_Menu_SubMenuItem) {
                 $bridge->addItemLink($item->toActionLinkLower($this->request, $params, $title));
             }
         }
     }
     $bridge->getTable()->appendAttrib('class', 'compliance');
     $tbody = $bridge->tbody();
     $td = $tbody[0][0];
     $td->appendAttrib('class', \MUtil_Lazy::method($this->util->getTokenData(), 'getStatusClass', $bridge->getLazy('status')));
 }
Пример #6
0
 /**
  * Returns all registered track engines classes for use in drop down lists.
  *
  * @param boolean $extended When true return a longer name.
  * @param boolean $userCreatableOnly Return only the classes that can be created by the user interface
  * @return array Of classname => description
  */
 public function getTrackEngineList($extended = false, $userCreatableOnly = false)
 {
     $results = array();
     $dummyTrackData['gtr_id_track'] = 0;
     foreach ($this->getTrackEngineClasses() as $className => $cls) {
         if (!$userCreatableOnly || $cls->isUserCreatable()) {
             if ($extended) {
                 $results[$className] = \MUtil_Html::raw(sprintf('<strong>%s</strong> %s', $cls->getName(), $cls->getDescription()));
             } else {
                 $results[$className] = $cls->getName();
             }
         }
     }
     return $results;
 }
 /**
  * Add first columns (group) from the model to the bridge that creates the browse table.
  *
  * You can actually add more than one column in this function, but just call all four functions
  * with the default columns in each
  *
  * 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 addBrowseColumn4(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $br = \MUtil_Html::create('br');
     // Display separator and phone sign only if phone exist.
     $phonesep = \MUtil_Html::raw('&#9743; ');
     // $bridge->itemIf($bridge->grs_phone_1, \MUtil_Html::raw('&#9743; '));
     $bridge->addMultiSort('grs_birthday', $br, $phonesep, 'grs_phone_1');
 }
 /**
  * As this is a common cell setting, this function allows you to overrule it.
  *
  * @param \MUtil_Model_Bridge_TableBridge $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function addRespondentCell(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $bridge->addMultiSort('gr2o_patient_nr', \MUtil_Html::raw('; '), 'respondent_name');
 }
 /**
  * Set column usage to use for the browser.
  *
  * Must be an array of arrays containing the input for TableBridge->setMultisort()
  *
  * @return array or false
  */
 public function getBrowseColumns()
 {
     $br = \MUtil_Html::create('br');
     $output[10] = array('gsu_survey_name', $br, 'gsu_survey_description');
     $output[20] = array('gsu_surveyor_active', \MUtil_Html::raw($this->_(' [')), 'gso_source_name', \MUtil_Html::raw($this->_(']')), $br, 'gsu_status_show', $br, 'gsu_insertable');
     $output[30] = array('gsu_active', \MUtil_Html::raw(' '), 'track_count', $br, 'gsu_id_primary_group');
     $output[40] = array('gsu_code', $br, 'gsu_export_code');
     return $output;
 }
Пример #10
0
 /**
  * Function to allow overloading  of tag rendering only
  *
  * Renders the element tag with it's content into a html string
  *
  * The $view is used to correctly encode and escape the output
  *
  * @param \Zend_View_Abstract $view
  * @return string Correctly encoded and escaped html output
  */
 protected function renderElement(\Zend_View_Abstract $view)
 {
     $this->_currentContent = array();
     // If the label was assigned an element lazy,
     // now is the time to get it's value.
     foreach ($this->_content as $key => $value) {
         if ($value instanceof \MUtil_Lazy_LazyInterface) {
             $value = \MUtil_Lazy::rise($value);
         }
         if ($value instanceof \Zend_Form_Element) {
             if ($value instanceof \Zend_Form_Element_Hidden) {
                 return null;
             }
             // Only a label when a label decorator exists, but we do not use that decorator
             $decorator = $value->getDecorator('Label');
             if ($decorator) {
                 if (false === $decorator->getOption('escape')) {
                     $label = \MUtil_Html::raw($value->getLabel());
                 } else {
                     $label = $value->getLabel();
                 }
                 $class = $this->class ? \MUtil_Html::renderAny($view, $this->class) . ' ' : '';
                 if ($value->isRequired()) {
                     $class .= $this->getRequiredClass();
                     $this->_currentContent[$key] = array($this->getRequiredPrefix(), $label, $this->getRequiredPostfix());
                 } else {
                     $class .= $this->getOptionalClass();
                     $this->_currentContent[$key] = array($this->getOptionalPrefix(), $label, $this->getOptionalPostfix());
                 }
                 parent::__set('class', $class);
                 // Bypass existing property for drawing
                 if ($id = $value->getId()) {
                     parent::__set('for', $id);
                     // Always overrule
                 } else {
                     parent::__unset('for');
                 }
             }
         } elseif ($value instanceof \Zend_Form_DisplayGroup) {
             return null;
         } else {
             $this->_currentContent[$key] = $value;
         }
     }
     return parent::renderElement($view);
 }
 public static function oneLine($line)
 {
     if (strlen($line) > 2) {
         if ($p = strpos($line, '<', 1)) {
             $line = substr($line, 0, $p);
         }
         if ($p = strpos($line, "\n", 1)) {
             $line = substr($line, 0, $p);
         }
     }
     return \MUtil_Html::raw(trim($line));
 }
 /**
  * Set column usage to use for the browser.
  *
  * Must be an array of arrays containing the input for TableBridge->setMultisort()
  *
  * @return array or false
  */
 public function getBrowseColumns()
 {
     $model = $this->getModel();
     $model->setIfExists('gr2o_opened', 'tableDisplay', 'small');
     $model->setIfExists('grs_email', 'formatFunction', array('MUtil_Html_AElement', 'ifmail'));
     // Newline placeholder
     $br = \MUtil_Html::create('br');
     // Display separator and phone sign only if phone exist.
     $phonesep = \MUtil_Html::raw('&#9743; ');
     // $bridge->itemIf($bridge->grs_phone_1, \MUtil_Html::raw('&#9743; '));
     $citysep = \MUtil_Html::raw('&nbsp;&nbsp;');
     // $bridge->itemIf($bridge->grs_zipcode, \MUtil_Html::raw('&nbsp;&nbsp;'));
     $filter = $this->getSearchFilter(true);
     if (isset($filter[\MUtil_Model::REQUEST_ID2])) {
         $column2 = 'gr2o_opened';
     } else {
         $column2 = 'gr2o_id_organization';
     }
     if (isset($filter['grc_success']) && !$filter['grc_success']) {
         $model->set('grc_description', 'label', $this->_('Rejection code'));
         $column2 = 'grc_description';
     }
     $columns[10] = array('gr2o_patient_nr', $br, $column2);
     $columns[20] = array('name', $br, 'grs_email');
     $columns[30] = array('grs_address_1', $br, 'grs_zipcode', $citysep, 'grs_city');
     $columns[40] = array('grs_birthday', $br, $phonesep, 'grs_phone_1');
     return $columns;
 }
 /**
  * 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;
 }
 /**
  * Returns the source choices in an array.
  *
  * @param boolean $validAfter True if it concerns _valid_after_ dates
  * @param boolean $firstRound List for first round
  * @param boolean $detailed   Return extended info
  * @return array source_name => label
  */
 protected function getSourceList($validAfter, $firstRound, $detailed = true)
 {
     if (!($validAfter || $this->project->isValidUntilRequired())) {
         $results[self::NO_TABLE] = array($this->_('Does not expire'));
     }
     if (!($validAfter && $firstRound)) {
         $results[self::ANSWER_TABLE] = array($this->_('Answers'), $this->_('Use an answer from a survey.'));
     }
     if ($this->_fieldsDefinition->hasAppointmentFields()) {
         $results[self::APPOINTMENT_TABLE] = array($this->_('Appointment'), $this->_('Use an appointment linked to this track.'));
     }
     if (!($validAfter && $firstRound)) {
         $results[self::TOKEN_TABLE] = array($this->_('Token'), $this->_('Use a standard token date.'));
     }
     $results[self::RESPONDENT_TRACK_TABLE] = array($this->_('Track'), $this->_('Use a track level date.'));
     if ($detailed) {
         foreach ($results as $key => $value) {
             if (is_array($value)) {
                 $results[$key] = \MUtil_Html::raw(sprintf('<strong>%s</strong> %s', reset($value), next($value)));
             }
         }
     } else {
         foreach ($results as $key => $value) {
             if (is_array($value)) {
                 $results[$key] = reset($value);
             }
         }
     }
     return $results;
 }
 /**
  * Applies the fieldmap data to the model
  *
  * @param \MUtil_Model_ModelAbstract $model
  */
 public function applyToModel(\MUtil_Model_ModelAbstract $model)
 {
     $map = $this->_getMap();
     $oldfld = null;
     $parent = null;
     foreach ($map as $name => $field) {
         $tmpres = array();
         $tmpres['thClass'] = \Gems_Tracker_SurveyModel::CLASS_MAIN_QUESTION;
         $tmpres['group'] = $field['gid'];
         $tmpres['type'] = $this->_getType($field);
         $tmpres['survey_question'] = true;
         if ($tmpres['type'] === \MUtil_Model::TYPE_DATE) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd';
             $tmpres['dateFormat'] = 'dd MMMM yyyy';
             // $tmpres['formatFunction']
         }
         if ($tmpres['type'] === \MUtil_Model::TYPE_DATETIME) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd HH:mm:ss';
             $tmpres['dateFormat'] = 'dd MMMM yyyy HH:mm';
             // $tmpres['formatFunction']
         }
         if ($tmpres['type'] === \MUtil_Model::TYPE_TIME) {
             $tmpres['storageFormat'] = 'yyyy-MM-dd HH:mm:ss';
             $tmpres['dateFormat'] = 'HH:mm:ss';
             // $tmpres['formatFunction']
         }
         // \MUtil_Echo::track($field);
         $oldQuestion = isset($oldfld['question']) ? $oldfld['question'] : null;
         if (isset($field['question']) && (!isset($oldfld) || $oldQuestion !== $field['question'])) {
             $tmpres['label'] = \MUtil_Html::raw($this->removeMarkup($field['question']));
         }
         if (isset($field['help']) && $field['help']) {
             $tmpres['description'] = \MUtil_Html::raw($this->removeMarkup($field['help']));
         }
         // Juggle the labels for sub-questions etc..
         if (isset($field['sq_question'])) {
             if (isset($tmpres['label'])) {
                 // Add non answered question for grouping and make it the current parent
                 //$parent = '_' . $name . '_';
                 $parent = $field['title'];
                 $model->set($parent, $tmpres);
                 $model->set($parent, 'type', \MUtil_Model::TYPE_NOVALUE);
             }
             if (isset($field['sq_question1'])) {
                 $tmpres['label'] = \MUtil_Html::raw(sprintf($this->translate->_('%s: %s'), $this->removeMarkup($field['sq_question']), $this->removeMarkup($field['sq_question1'])));
             } else {
                 $tmpres['label'] = \MUtil_Html::raw($this->removeMarkup($field['sq_question']));
             }
             $tmpres['thClass'] = \Gems_Tracker_SurveyModel::CLASS_SUB_QUESTION;
         }
         if ($options = $this->_getMultiOptions($field)) {
             $tmpres['multiOptions'] = $options;
         }
         // Code does not have to be unique. So if a title is used
         // twice we only use it for the first result.
         if (isset($field['code']) && !$model->has($field['code'])) {
             $name = $field['code'];
         }
         // Parent storage
         if (\Gems_Tracker_SurveyModel::CLASS_MAIN_QUESTION === $tmpres['thClass']) {
             $parent = $name;
         } elseif ($parent) {
             // Add the name of the parent item
             $tmpres['parent_question'] = $parent;
         }
         $model->set($name, $tmpres);
         $oldfld = $field;
     }
 }
 public function showAnswers($answers)
 {
     if ($answers) {
         if (is_array($answers)) {
             if (count($answers) == 1) {
                 return reset($answers);
             }
             if (count($answers) > $this->showAnswersLimit) {
                 $border_limit = intval($this->showAnswersLimit / 2);
                 $newAnswers = array_slice($answers, 0, $border_limit);
                 $newAnswers[] = $this->showAnswersRemoved;
                 $newAnswers = array_merge($newAnswers, array_slice($answers, -$border_limit));
                 $answers = $newAnswers;
             }
             return \MUtil_Html::raw($this->showAnswersSepStart . implode($this->showAnswersSeparator, $answers) . $this->showAnswersSepEnd);
         } else {
             return \MUtil_Html::raw($this->showAnswerTypeStart . $answers . $this->showAnswerTypeEnd);
         }
     } else {
         return \MUtil_Html::raw($this->showAnswersNoneStart . $this->showAnswersNone . $this->showAnswersNoneEnd);
     }
 }
 /**
  * Called after the check that all required registry values
  * have been set correctly has run.
  *
  * @return void
  */
 public function afterRegistry()
 {
     parent::afterRegistry();
     $model = $this->getModel();
     $br = \MUtil_Html::create('br');
     $sp = \MUtil_Html::raw(' ');
     $this->columns[10] = array('gro_id_order');
     $this->columns[20] = array('gro_id_survey');
     $this->columns[30] = array('gro_round_description');
     $this->columns[40] = array('gro_icon_file');
     $this->columns[45] = array('ggp_name');
     $this->columns[50] = array('gro_valid_after_field', $sp, 'gro_valid_after_source', $sp, 'gro_valid_after_id');
     $this->columns[60] = array('gro_valid_for_field', $sp, 'gro_valid_for_source', $sp, 'gro_valid_for_id');
     $this->columns[70] = array('gro_active');
     if ($label = $model->get('gro_changed_event', 'label')) {
         $this->columns[80] = array('gro_changed_event');
     }
     if ($label = $model->get('gro_changed_event', 'label')) {
         $this->columns[90] = array('gro_display_event');
     }
     $this->columns[100] = array('gro_code');
     $this->columns[110] = array('organizations');
 }
 /**
  * Strip all the tags, but keep the escaped characters
  *
  * @param string $value
  * @return \MUtil_Html_Raw
  */
 public static function formatDescription($value)
 {
     return \MUtil_Html::raw(strip_tags($value));
 }
 /**
  * Adds elements from the model to the bridge that creates the form.
  *
  * Overrule this function to add different elements to the browse table, without
  * having to recode the core table building code.
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $bridge->addHidden('grl_id_role');
     $bridge->addText('grl_name');
     $bridge->addText('grl_description');
     $roles = $this->acl->getRoles();
     if ($roles) {
         $possibleParents = array_combine($roles, $roles);
     } else {
         $possibleParents = array();
     }
     if (isset($this->formData['grl_parents']) && $this->formData['grl_parents']) {
         $this->formData['grl_parents'] = array_combine($this->formData['grl_parents'], $this->formData['grl_parents']);
     } else {
         $this->formData['grl_parents'] = array();
     }
     // Don't allow master, nologin or itself as parents
     unset($possibleParents['master']);
     unset($possibleParents['nologin']);
     $disabled = array();
     if (isset($this->formData['grl_name'])) {
         foreach ($possibleParents as $parent) {
             if ($this->acl->hasRole($this->formData['grl_name']) && $this->acl->inheritsRole($parent, $this->formData['grl_name'])) {
                 $disabled[] = $parent;
                 $possibleParents[$parent] .= ' ' . \MUtil_Html::create('small', $this->_('child of current role'), $this->view);
                 unset($this->formData['grl_parents'][$parent]);
             } else {
                 foreach ($this->formData['grl_parents'] as $p2) {
                     if ($this->acl->hasRole($p2) && $this->acl->inheritsRole($p2, $parent)) {
                         $disabled[] = $parent;
                         $possibleParents[$parent] .= ' ' . \MUtil_Html::create('small', \MUtil_Html::raw(sprintf($this->_('inherited from %s'), \MUtil_Html::create('em', $p2, $this->view))), $this->view);
                         $this->formData['grl_parents'][$parent] = $parent;
                     }
                 }
             }
         }
         $disabled[] = $this->formData['grl_name'];
         if (isset($possibleParents[$this->formData['grl_name']])) {
             $possibleParents[$this->formData['grl_name']] .= ' ' . \MUtil_Html::create('small', $this->_('this role'), $this->view);
         }
     }
     // Add this for validator to allow empty list
     $possibleParents[''] = '';
     $bridge->addMultiCheckbox('grl_parents', 'multiOptions', $possibleParents, 'disable', $disabled, 'escape', false, 'required', false, 'onchange', 'this.form.submit();');
     $allPrivileges = $this->usedPrivileges;
     $rolePrivileges = $this->acl->getRolePrivileges();
     if (isset($this->formData['grl_parents']) && $this->formData['grl_parents']) {
         $inherited = $this->getInheritedPrivileges($this->formData['grl_parents']);
         $privileges = array_diff_key($allPrivileges, $inherited);
         $inheritedPrivileges = array_intersect_key($allPrivileges, $inherited);
     } else {
         $privileges = $allPrivileges;
         $inheritedPrivileges = false;
     }
     $checkbox = $bridge->addMultiCheckbox('grl_privileges', 'multiOptions', $privileges, 'required', false);
     $checkbox->setAttrib('escape', false);
     //Don't use escaping, so the line breaks work
     if ($inheritedPrivileges) {
         $checkbox = $bridge->addMultiCheckbox('inherited', 'label', $this->_('Inherited'), 'multiOptions', $inheritedPrivileges, 'required', false, 'disabled', 'disabled');
         $checkbox->setAttrib('escape', false);
         //Don't use escaping, so the line breaks work
         $checkbox->setValue(array_keys($inheritedPrivileges));
         //To check the boxes
     }
 }
Пример #20
0
 /**
  * Function called if specified in the Project.ini layoutPrepare section before
  * the layout is drawn, but after the rest of the program has run it's course.
  *
  * @return mixed If null nothing is set, otherwise the name of
  * the function is used as \Zend_View variable name.
  */
 protected function _layoutCrumbs(array $args = null)
 {
     // Must be called after _layoutNavigation()
     if ($this->menu && $this->menu->isVisible()) {
         $path = $this->menu->getActivePath($this->request);
         $last = array_pop($path);
         // Only display when there is a path of more than one step or always is on
         if ($path || isset($args['always']) && $args['always']) {
             // Never needed from now on
             unset($args['always']);
             if (isset($args['tag'])) {
                 $tag = $args['tag'];
                 unset($args['tag']);
             } else {
                 $tag = 'div';
             }
             $source = array($this->menu->getParameterSource(), $this->request);
             if ($this->useBootstrap && !isset($args['tag'])) {
                 $div = \MUtil_Html::create('ol', $args + array('id' => 'crumbs', 'class' => 'breadcrumb'));
                 foreach ($path as $menuItem) {
                     $div->li()->a($menuItem->toHRefAttribute($source), $menuItem->get('label'));
                 }
                 if ($last) {
                     $div->li(array('class' => 'active'))->append($last->get('label'));
                 }
             } else {
                 $div = \MUtil_Html::create($tag, $args + array('id' => 'crumbs'));
                 $content = $div->seq();
                 $content->setGlue(\MUtil_Html::raw($this->_(' > ')));
                 // Add request to existing menu parameter sources
                 foreach ($path as $menuItem) {
                     $content->a($menuItem->toHRefAttribute($source), $menuItem->get('label'));
                 }
                 if ($last) {
                     $content->append($last->get('label'));
                 }
             }
             return $div;
         }
     }
 }