/** * 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)); } }
/** * 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; }
public function testDiv() { $div = MUtil_Html::div('bar', array('id' => 'foo')); $this->assertInstanceOf('MUtil_Html_HtmlElement', $div); $this->assertEquals('div', $div->getTagName()); $this->assertEquals('foo', $div->getAttrib('id')); }
public function render(\Zend_View_Abstract $view) { // \MUtil_Echo::r(sprintf('Rendering snippet %s.', get_class($this))); // // TODO: Change snippet workings. // All forms are processed twice if hasHtmlOutput() is called here. This is // a problem when downloading files. // However: not being able to call hasHtmlOutput() twice is not part of the original plan // so I gotta rework the forms. :( // if (!$this->hasHtmlOutput() && $this->getRedirectRoute()) { $this->redirectRoute(); } else { $html = $this->getHtmlOutput($view); if ($html) { if ($html instanceof \MUtil_Html_HtmlInterface) { if ($html instanceof \MUtil_Html_HtmlElement) { $this->applyHtmlAttributes($html); } return $html->render($view); } else { return \MUtil_Html::renderAny($view, $html); } } } }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ public function createModel($detailed, $action) { $rcLib = $this->util->getReceptionCodeLibrary(); $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \MUtil_Model_TableModel('gems__reception_codes'); $model->copyKeys(); // The user can edit the keys. $model->set('grc_id_reception_code', 'label', $this->_('Code'), 'size', '10'); $model->set('grc_description', 'label', $this->_('Description'), 'size', '30'); $model->set('grc_success', 'label', $this->_('Is success code'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code is a success code.')); $model->set('grc_active', 'label', $this->_('Active'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('Only active codes can be selected.')); if ($detailed) { $model->set('desc1', 'elementClass', 'Html', 'label', ' ', 'value', \MUtil_Html::create('h4', $this->_('Can be assigned to'))); } $model->set('grc_for_respondents', 'label', $this->_('Respondents'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code can be assigned to a respondent.')); $model->set('grc_for_tracks', 'label', $this->_('Tracks'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('This reception code can be assigned to a track.')); $model->set('grc_for_surveys', 'label', $this->_('Tokens'), 'multiOptions', $rcLib->getSurveyApplicationValues(), 'description', $this->_('This reception code can be assigned to a token.')); if ($detailed) { $model->set('desc2', 'elementClass', 'Html', 'label', ' ', 'value', \MUtil_Html::create('h4', $this->_('Additional actions'))); } $model->set('grc_redo_survey', 'label', $this->_('Redo survey'), 'multiOptions', $rcLib->getRedoValues(), 'description', $this->_('Redo a survey on this reception code.')); $model->set('grc_overwrite_answers', 'label', $this->_('Overwrite existing consents'), 'multiOptions', $yesNo, 'elementClass', 'CheckBox', 'description', $this->_('Remove the consent from already answered surveys.')); if ($detailed) { $model->set('grc_id_reception_code', 'validator', $model->createUniqueValidator('grc_id_reception_code')); $model->set('grc_description', 'validator', $model->createUniqueValidator('grc_description')); } if ($this->project->multiLocale) { $model->set('grc_description', 'description', 'ENGLISH please! Use translation file to translate.'); } \Gems_Model::setChangeFieldsByPrefix($model, 'grc'); return $model; }
/** * 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) { $url = $view->url(array('action' => 'export')); $container = \MUtil_Html::div(array('id' => 'export-container')); $button = $container->button(array($this->_('Export'), 'id' => 'modelExport')); return $container; }
/** * 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 */ public function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $model->set('gr2o_patient_nr', 'label', $this->_('Respondent')); $model->set('gto_round_description', 'label', $this->_('Round / Details')); $model->set('gto_valid_from', 'label', $this->_('Valid from')); $model->set('gto_valid_until', 'label', $this->_('Valid until')); $model->set('gto_mail_sent_date', 'label', $this->_('Contact date')); $model->set('respondent_name', 'label', $this->_('Name')); $HTML = \MUtil_Html::create(); $bridge->setDefaultRowClass(\MUtil_Html_TableElement::createAlternateRowClass('even', 'even', 'odd', 'odd')); $bridge->addColumn($this->getTokenLinks($bridge), ' ')->rowspan = 2; // Space needed because TableElement does not look at rowspans $bridge->addSortable('gto_valid_from'); $bridge->addSortable('gto_valid_until'); $bridge->addMultiSort('gr2o_patient_nr', $HTML->raw('; '), 'respondent_name'); $bridge->addMultiSort('ggp_name', array($this->getActionLinks($bridge))); $bridge->tr(); $bridge->addSortable('gto_mail_sent_date'); $bridge->addSortable('gto_completion_time'); if ($this->escort instanceof \Gems_Project_Tracks_SingleTrackInterface) { $bridge->addMultiSort('gto_round_description', $HTML->raw('; '), 'gsu_survey_name'); } else { $model->set('gr2t_track_info', 'tableDisplay', 'smallData'); $model->set('gto_round_description', 'tableDisplay', 'smallData'); $bridge->addMultiSort('gtr_track_name', 'gr2t_track_info', $bridge->gtr_track_name->if($HTML->raw(' » ')), 'gsu_survey_name', 'gto_round_description'); } $bridge->addSortable('assigned_by'); }
/** * Place to set the data to display * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @return void */ protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge) { $HTML = \MUtil_Html::create(); $bridge->caption($this->getCaption()); $br = $HTML->br(); $address[] = $bridge->grs_address_1; $address[] = $br; if ($this->model->has('grs_address_2')) { $address[] = $bridge->grs_address_2; $address[] = $bridge->itemIf('grs_address_2', $br); } $address[] = $bridge->grs_zipcode; $address[] = $bridge->itemIf('grs_zipcode', new \MUtil_Html_Raw(' ')); $address[] = $bridge->grs_city; // ROW 0 $label = $this->model->get('gr2o_patient_nr', 'label'); // Try to read label from model... if (empty($label)) { $label = $this->_('Respondent nr: '); // ...but have a fall-back } $bridge->addItem($bridge->gr2o_patient_nr, $label); $bridge->addItem($HTML->spaced($bridge->itemIf('grs_last_name', array($bridge->grs_last_name, ',')), $bridge->grs_gender, $bridge->grs_first_name, $bridge->grs_surname_prefix), $this->_('Respondent')); // ROW 1 $bridge->addItem('grs_birthday'); $bridge->addItem('grs_phone_1'); // ROW 2 $bridge->addItem('grs_email'); $bridge->addItem($address, $this->_('Address')); }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); if ($elements) { $elements[] = null; // break into separate spans } if ($this->periodSelector) { $dates = array('_gto_valid_from gto_valid_until' => $this->_('Is valid during'), '-gto_valid_from gto_valid_until' => $this->_('Is valid within'), 'gto_valid_from' => $this->_('Valid from'), 'gto_valid_until' => $this->_('Valid until'), 'gto_mail_sent_date' => $this->_('E-Mailed on'), 'gto_completion_time' => $this->_('Completion date')); $this->_addPeriodSelectors($elements, $dates); $elements[] = null; // break into separate spans } $allowedOrgs = $this->getOrganizationList($data); $orgWhere = "(INSTR(gtr_organizations, '|" . implode("|') > 0 OR INSTR(gtr_organizations, '|", array_keys($allowedOrgs)) . "|') > 0)"; $elements[] = $this->_('Select:'); $elements[] = \MUtil_Html::create('br'); // Add track selection if ($this->multiTracks) { $elements[] = $this->_createSelectElement('gto_id_track', $this->getAllTrackTypes($orgWhere, $data), $this->_('(all tracks)')); } $elements[] = $this->_createSelectElement('gto_round_description', $this->getAllTrackRounds($orgWhere, $data), $this->_('(all rounds)')); $elements[] = $this->_createSelectElement('gto_id_survey', $this->getAllSurveys($orgWhere, $data), $this->_('(all surveys)')); $options = array('all' => $this->_('(all actions)'), 'open' => $this->_('Open'), 'notmailed' => $this->_('Not emailed'), 'tomail' => $this->_('To email'), 'toremind' => $this->_('Needs reminder'), 'hasnomail' => $this->_('Missing email'), 'toanswer' => $this->_('Yet to Answer'), 'answered' => $this->_('Answered'), 'missed' => $this->_('Missed'), 'removed' => $this->_('Removed')); $elements[] = $this->_createSelectElement('main_filter', $options); $elements[] = $this->_createSelectElement('gsu_id_primary_group', $this->getAllGroups($orgWhere, $data), $this->_('(all fillers)')); // Select organisation if (count($allowedOrgs) > 1) { $elements[] = $this->_createSelectElement('gto_id_organization', $allowedOrgs, $this->_('(all organizations)')); } $elements[] = $this->_createSelectElement('gr2t_created_by', $this->getAllCreators($allowedOrgs, $data), $this->_('(all staff)')); return $elements; }
public function getHtmlOutput(\Zend_View_Abstract $view) { parent::getHtmlOutput($view); $respondentModel = $this->model; $respondentData = $this->data; $respondentId = $this->respondentId; $html = $this->getHtmlSequence(); if (empty($this->data)) { $html->p()->b(sprintf($this->_('Unknown respondent %s'), $respondentId)); return $html; } $bridge = $respondentModel->getBridgeFor('itemTable', array('class' => 'browser table')); $bridge->setRepeater(\MUtil_Lazy::repeat(array($respondentData))); $bridge->th($this->_('Respondent information'), array('colspan' => 4)); $bridge->setColumnCount(2); foreach ($respondentModel->getItemsOrdered() as $name) { if ($label = $respondentModel->get($name, 'label')) { $bridge->addItem($name, $label); } } $tableContainer = \MUtil_Html::create()->div(array('class' => 'table-container')); $tableContainer[] = $bridge->getTable(); $html->h2($this->_('Respondent information') . ': ' . $respondentId); $html[] = $tableContainer; $html->hr(); return $html; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); $user = $this->loader->getCurrentUser(); if ($user->hasPrivilege('pr.respondent.select-on-track')) { $tracks = $this->searchData['__active_tracks']; $masks['show_all'] = $this->_('(all)'); $masks['show_without_track'] = $this->_('(no track)'); if (count($tracks) > 1) { $masks['show_with_track'] = $this->_('(with track)'); } if (count($tracks) > 1) { $elements[] = $this->_createSelectElement('gr2t_id_track', $masks + $tracks); } else { $element = $this->_createRadioElement('gr2t_id_track', $masks + $tracks); $element->setSeparator(' '); $elements[] = $element; } $lineBreak = true; } else { $lineBreak = false; } if ($user->hasPrivilege('pr.respondent.show-deleted')) { $elements[] = $this->_createCheckboxElement('grc_success', $this->_('Show active')); } if ($this->model->isMultiOrganization()) { $element = $this->_createSelectElement(\MUtil_Model::REQUEST_ID2, $user->getRespondentOrganizations(), $this->_('(all organizations)')); if ($lineBreak) { $element->setLabel($this->_('Organization'))->setAttrib('onchange', 'this.form.submit();'); $elements[] = \MUtil_Html::create('br'); } $elements[] = $element; } return $elements; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); $elements[] = new \Zend_Form_Element_Hidden(\MUtil_Model::REQUEST_ID); $elements[] = $this->_createSelectElement('gtf_field_type', $this->model, $this->_('(all types)')); $elements[] = \MUtil_Html::create('br'); return $elements; }
protected function _showTable($caption, $data, $nested = false) { $tableContainer = \MUtil_Html::create()->div(array('class' => 'table-container')); $table = \MUtil_Html_TableElement::createArray($data, $caption, $nested); $table->class = 'browser table'; $tableContainer[] = $table; $this->html[] = $tableContainer; }
/** * 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->gr2t_id_respondent_track; // Data needed for edit button $bridge->gr2o_id_organization; // Data needed for edit button $HTML = \MUtil_Html::create(); // Get the buttons $respMenu = $this->menu->findAllowedController('respondent', 'show'); if ($respMenu) { $respondentButton = $respMenu->toActionLink($this->request, $bridge, $this->_('Show respondent')); $respondentButton->appendAttrib('class', 'rightFloat'); } else { $respondentButton = null; } $trackMenu = $this->menu->findAllowedController('respondent', 'show-track'); if ($trackMenu) { $trackButton = $trackMenu->toActionLink($this->request, $bridge, $this->_('Show track')); $trackButton->appendAttrib('class', 'rightFloat'); } else { $trackButton = null; } // Row with dates and patient data $bridge->tr(array('onlyWhenChanged' => true, 'class' => 'even')); $bridge->addSortable('gr2o_patient_nr'); $bridge->addSortable('respondent_name')->colspan = 2; if ($this->multiTracks) { $bridge->addSortable('grs_birthday'); $bridge->addMultiSort('grs_city', array($respondentButton)); $model->set('gr2t_track_info', 'tableDisplay', 'smallData'); // Row with track info $bridge->tr(array('onlyWhenChanged' => true, 'class' => 'even')); $td = $bridge->addMultiSort('gtr_track_name', 'gr2t_track_info'); $td->class = 'indentLeft'; $td->colspan = 4; $td->renderWithoutContent = false; // Do not display this cell and thus this row if there is not content $td = $bridge->addMultiSort('progress', array($trackButton)); $td->renderWithoutContent = false; // Do not display this cell and thus this row if there is not content } else { $bridge->addSortable('grs_birthday'); $bridge->addMultiSort('progress', array($respondentButton)); } $bridge->tr(array('class' => array('odd', $bridge->row_class), 'title' => $bridge->gto_comment)); $bridge->addColumn($this->createShowTokenButton($bridge))->class = 'rightAlign'; $bridge->addSortable('gto_valid_from'); $bridge->addSortable('gto_valid_until'); $model->set('gto_round_description', 'tableDisplay', 'smallData'); $bridge->addMultiSort('gsu_survey_name', 'gto_round_description')->colspan = 2; $bridge->tr(array('class' => array('odd', $bridge->row_class), 'title' => $bridge->gto_comment)); $bridge->addColumn(); $bridge->addSortable('gto_mail_sent_date'); $bridge->addSortable('gto_completion_time'); $bridge->addSortable('gto_id_token'); $bridge->addMultiSort('ggp_name', array($this->createActionButtons($bridge))); }
/** * Place to set the data to display * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @return void */ protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge) { $bridge->setColumnCount(1); $HTML = \MUtil_Html::create(); $bridge->tdh($this->getCaption(), array('colspan' => 2)); // Caption for tracks $trackLabel = $this->_('Assigned tracks'); if ($menuItem = $this->findMenuItem('track', 'index')) { $href = $menuItem->toHRefAttribute($this->request, $bridge); $bridge->tdh(array('class' => 'linked'))->a($href, $trackLabel); } else { $bridge->tdh($trackLabel, array('class' => 'linked')); } $bridge->tr(); // ROW 1 $bridge->addItem($bridge->gr2o_patient_nr, $this->_('Respondent nr: ')); $rowspan = 10; // Column for tracks $tracksModel = $this->model->getRespondentTracksModel(); $tracksData = \MUtil_Lazy::repeat($tracksModel->load(array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr, 'gr2o_id_organization' => $this->repeater->gr2o_id_organization), array('gr2t_created' => SORT_DESC))); $tracksList = $HTML->div($tracksData, array('class' => 'tracksList')); $tracksList->setOnEmpty($this->_('No tracks')); if ($menuItem = $this->findMenuItem('track', 'show-track')) { $href = $menuItem->toHRefAttribute($tracksData, array('gr2o_patient_nr' => $this->repeater->gr2o_patient_nr)); $tracksTarget = $tracksList->p()->a($href); } else { $tracksTarget = $tracksList->p(); } $tracksTarget->strong($tracksData->gtr_track_name); $tracksTarget[] = ' '; $tracksTarget->em($tracksData->gr2t_track_info, array('renderWithoutContent' => false)); $tracksTarget[] = ' '; $tracksTarget[] = \MUtil_Lazy::call($this->util->getTranslated()->formatDate, $tracksData->gr2t_created); $bridge->td($tracksList, array('rowspan' => $rowspan, 'class' => 'linked tracksList')); // OTHER ROWS $bridge->addItem($HTML->spaced($bridge->itemIf('grs_last_name', array($bridge->grs_last_name, ',')), $bridge->grs_first_name, $bridge->grs_surname_prefix), $this->_('Respondent')); $bridge->addItem('grs_gender'); $bridge->addItem('grs_birthday'); $bridge->addItem('grs_email'); $bridge->addItem('gr2o_created'); $bridge->addItem('gr2o_created_by'); if ($this->onclick) { // TODO: can we not use $repeater? $href = array('location.href=\'', $this->onclick, '\';'); foreach ($bridge->tbody() as $tr) { foreach ($tr as $td) { if (strpos($td->class, 'linked') === false) { $td->onclick = $href; } else { $td->onclick = 'event.cancelBubble=true;'; } } } $bridge->tbody()->onclick = '// Dummy for CSS'; } }
/** * 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 (!$this->columns) { $br = \MUtil_Html::create('br'); $this->columns[10] = array('gla_created', $br, 'gls_name'); $this->columns[20] = array('gla_message'); $this->columns[30] = array('staff_name', $br, 'gla_role'); $this->columns[40] = array('respondent_name', $br, 'gla_organization'); } parent::addBrowseTableColumns($bridge, $model); }
/** * 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; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); $groups = $this->util->getDbLookup()->getGroups(); $elements[] = $this->_createSelectElement('gsu_id_primary_group', $groups, $this->_('(all groups)')); $states = array('act' => $this->_('Active'), 'sok' => $this->_('OK in source, not active'), 'nok' => $this->_('Blocked in source')); $elements[] = $this->_createSelectElement('status', $states, $this->_('(every state)')); $elements[] = \MUtil_Html::create('br'); $yesNo = $this->util->getTranslated()->getYesNo(); $elements[] = $this->_createSelectElement('gsu_insertable', $yesNo, $this->_('(any insertable)')); return $elements; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { // Search text $elements = parent::getAutoSearchElements($data); $this->_addPeriodSelectors($elements, array('grco_created' => $this->_('Date sent'))); $br = \MUtil_Html::create()->br(); $elements[] = null; $dbLookup = $this->util->getDbLookup(); $elements[] = $this->_createSelectElement('gto_id_track', $this->getRespondentTrackNames(), $this->_('(select a track)')); $elements[] = $this->_createSelectElement('gto_id_survey', $this->getRespondentSurveyNames(), $this->_('(select a survey)')); $elements[] = $this->_createSelectElement('status', $this->util->getTokenData()->getEveryStatus(), $this->_('(select a status)')); return $elements; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { // Search text $elements = parent::getAutoSearchElements($data); $this->_addPeriodSelectors($elements, array('grco_created' => $this->_('Date sent'))); $br = \MUtil_Html::create()->br(); $elements[] = null; $dbLookup = $this->util->getDbLookup(); $elements[] = $this->_createSelectElement('gto_id_track', $this->util->getTrackData()->getAllTracks(), $this->_('(select a track)')); $elements[] = $this->_createSelectElement('gto_id_survey', $this->util->getTrackData()->getAllSurveys(), $this->_('(all surveys)')); $elements[] = $this->_createSelectElement('grco_organization', $this->loader->getCurrentUser()->getRespondentOrganizations(), $this->_('(all organizations)')); return $elements; }
/** * Renders the element 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 */ public function render(\Zend_View_Abstract $view) { $results = array(); $renderer = \MUtil_Html::getRenderer(); foreach ($this->_array as $item) { $result = $renderer->renderAny($view, $item); if (null !== $result && strlen($result)) { $results[] = $result; } } if ($results) { return implode('', $results); } }
/** * Overloading: allow rendering specific decorators * * Call renderDecoratorName() to render a specific decorator. * * @param string $method * @param array $args * @return \MUtil_Html_HtmlElement or at least something that implements the \MUtil_Html_HtmlInterface interface * @throws \Zend_Form_Exception for invalid decorator or invalid method call */ public function __call($method, $args) { if ('render' == substr($method, 0, 6)) { return parent::__call($method, $args); } $elem = \MUtil_Html::createArray($method, $args); $value = $this->getValue(); if (!$value instanceof \MUtil_Html_ElementInterface) { $value = new \MUtil_Html_Sequence(); } $value->append($elem); $this->setValue($value); return $elem; }
/** * * @param \MUtil_Model_Bridge_TableBridge $bridge */ protected function addTokenLinks(\MUtil_Model_Bridge_TableBridge $bridge) { $title = \MUtil_Html::create()->strong($this->_('+')); $showLinks[] = $this->createMenuLink($bridge, 'track', 'show', $title); // Remove nulls $showLinks = array_filter($showLinks); if ($showLinks) { foreach ($showLinks as $showLink) { if ($showLink) { $showLink->title = array($this->_('Token'), $bridge->gto_id_token->strtoupper()); } } } $bridge->addItemLink($showLinks); }
/** * 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) { $data = $this->getModel()->loadFirst(); if ($data && isset($data['relpath'])) { $nameForUser = $data['relpath']; } else { $nameForUser = $this->request->getParam(\MUtil_Model::REQUEST_ID, $this->_('unknown')); } if (!($data && file_exists($data['fullpath']))) { $this->addMessage(sprintf($this->_('The file "%s" does not exist on the server.'), $nameForUser)); return \MUtil_Html::create('pInfo', sprintf($this->_('The file "%s" could not be imported.'), $nameForUser)); } // \MUtil_Echo::track($data); return $this->_('Token'); }
/** * For backward compatibility, allow \MUtil_Html calls to set or append to the title * * @param type $method * @param type $args * @return \Gems_Form_TabSubForm */ public function __call($method, $args) { if ('render' == substr($method, 0, 6)) { return parent::__call($method, $args); } $elem = \MUtil_Html::createArray($method, $args); $value = $this->getAttrib('title'); $value .= $elem->render($this->getView()); $this->setAttrib('title', $value); //As the decorator might have been added already, update it also $decorator = $this->getDecorator('TabPane'); $options = $decorator->getOption('jQueryParams'); $options['title'] = strip_tags($value); $decorator->setOption('jQueryParams', $options); return $this; }
public function displayDate($date) { if (!$date instanceof \Zend_Date) { return $date; } $div = \MUtil_Html::create('div'); $div->class = 'calendar'; if (0 < $date->getYear()->getTimestamp()) { $div->span(ucfirst($date->toString(\Zend_Date::WEEKDAY . ' ' . \Zend_Date::DAY_SHORT . ' ' . \Zend_Date::MONTH_NAME . ' ' . \Zend_Date::YEAR)))->class = 'date'; } // $div->strong($date->toString()); // $div->br(); $td = $div->span($date->toString(\Zend_Date::TIME_SHORT)); $td->class = 'time middleAlign'; $td->append(' '); $td->img()->src = 'stopwatch.png'; return $div; }
/** * Returns a text element for autosearch. Can be overruled. * * The form / html elements to search on. Elements can be grouped by inserting null's between them. * That creates a distinct group of elements * * @param array $data The $form field values (can be usefull, but no need to set them) * @return array Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks. */ protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); if ($elements) { $br = \MUtil_Html::create('br'); $elements[] = $this->_createSelectElement('gtr_track_class', $this->model, $this->_('(all track engines)')); $elements[] = $br; $optionsA = $this->util->getTranslated()->getYesNo(); $elementA = $this->_createSelectElement('gtr_active', $optionsA, $this->_('(both)')); $elementA->setLabel($this->model->get('gtr_active', 'label')); $elements[] = $elementA; $user = $this->loader->getCurrentUser(); $optionsO = $user->getRespondentOrganizations(); $elementO = $this->_createSelectElement('org', $optionsO, $this->_('(all organizations)')); $elements[] = $elementO; } return $elements; }
/** * 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) { // \MUtil_Model::$verbose = true; // // Initiate data retrieval for stuff needed by links $bridge->gr2o_patient_nr; $bridge->gr2o_id_organization; $bridge->gr2t_id_respondent_track; $HTML = \MUtil_Html::create(); $roundDescription[] = $HTML->if($bridge->gto_round_description, $HTML->small(' [', $bridge->gto_round_description, ']')); $roundDescription[] = $HTML->small(' [', $bridge->createSortLink('gto_round_description'), ']'); $roundIcon[] = \MUtil_Lazy::iif($bridge->gto_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gto_icon_file, 'class' => 'icon')), \MUtil_Lazy::iif($bridge->gro_icon_file, \MUtil_Html::create('img', array('src' => $bridge->gro_icon_file, 'class' => 'icon')))); if ($menuItem = $this->findMenuItem('track', 'show-track')) { $href = $menuItem->toHRefAttribute($this->request, $bridge); $track1 = $HTML->if($bridge->gtr_track_name, $HTML->a($href, $bridge->gtr_track_name)); } else { $track1 = $bridge->gtr_track_name; } $track[] = array($track1, $HTML->if($bridge->gr2t_track_info, $HTML->small(' [', $bridge->gr2t_track_info, ']'))); $track[] = array($bridge->createSortLink('gtr_track_name'), $HTML->small(' [', $bridge->createSortLink('gr2t_track_info'), ']')); $bridge->addMultiSort($track); $bridge->addMultiSort('gsu_survey_name', $roundDescription, $roundIcon); $bridge->addSortable('ggp_name'); $bridge->addSortable('calc_used_date', null, $HTML->if($bridge->is_completed, 'disabled date', 'enabled date')); $bridge->addSortable('gto_changed'); $bridge->addSortable('assigned_by', $this->_('Assigned by')); $project = \GemsEscort::getInstance()->project; // If we are allowed to see the result of the survey, show them $user = $this->loader->getCurrentUser(); if ($user->hasPrivilege('pr.respondent.result')) { $bridge->addSortable('gto_result', $this->_('Score'), 'date'); } $bridge->useRowHref = false; $actionLinks[] = $this->createMenuLink($bridge, 'track', 'answer'); $actionLinks[] = array($bridge->ggp_staff_members->if($this->createMenuLink($bridge, 'ask', 'take'), $bridge->calc_id_token->strtoupper()), 'class' => $bridge->ggp_staff_members->if(null, $bridge->calc_id_token->if('token'))); // calc_id_token is empty when the survey has been completed // Remove nulls $actionLinks = array_filter($actionLinks); if ($actionLinks) { $bridge->addItemLink($actionLinks); } $this->addTokenLinks($bridge); }
public function getHtmlOutput(\Zend_View_Abstract $view) { $post = $this->request->getPost(); $export = $this->loader->getExport(); $exportTypes = $export->getExportClasses(); if (isset($post['type'])) { $currentType = $post['type']; } else { reset($exportTypes); $currentType = key($exportTypes); } if (\MUtil_Bootstrap::enabled()) { $form = new \Gems_Form(array('id' => 'exportOptionsForm', 'class' => 'form-horizontal')); } else { $form = new \Gems_Form_TableForm(); } $url = $view->url() . '/step/batch'; $form->setAction($url); $elements = array(); $elements['type'] = $form->createElement('select', 'type', array('label' => $this->_('Export to'), 'multiOptions' => $exportTypes, 'class' => 'autosubmit')); $form->addElements($elements); $exportClass = $export->getExport($currentType); $exportName = $exportClass->getName(); $exportFormElements['firstCheck'] = $form->createElement('hidden', $currentType); $exportFormElements = $exportClass->getFormElements($form, $data); if ($exportFormElements) { $form->addElements($exportFormElements); } if (!isset($post[$currentType])) { $post[$exportName] = $exportClass->getDefaultFormValues(); } $element = $form->createElement('submit', 'export_submit', array('label' => $this->_('Export'))); $form->addElement($element); if ($post) { $form->populate($post); } $container = \MUtil_Html::div(array('id' => 'export-form')); $container->append($form); $form->setAttrib('id', 'autosubmit'); $form->setAutoSubmit(\MUtil_Html::attrib('href', array('action' => $this->request->getActionName(), 'RouteReset' => true)), 'export-form', true); return $container; }
/** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed * parameter was added, because the most common use of action is a split between detailed * and summarized actions. * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return \MUtil_Model_ModelAbstract */ public function createModel($detailed, $action) { $model = new \MUtil_Model_FolderModel(GEMS_ROOT_DIR . '/var/logs', null, $this->recursive); if ($this->recursive) { $model->set('relpath', 'label', $this->_('File (local)'), 'maxlength', 255, 'size', 40, 'validators', array('File_Path', 'File_IsRelativePath')); $model->set('filename', 'elementClass', 'Exhibitor'); } if ($detailed || !$this->recursive) { $model->set('filename', 'label', $this->_('Filename'), 'size', 30, 'maxlength', 255); } if ($detailed) { $model->set('path', 'label', $this->_('Path'), 'elementClass', 'Exhibitor'); $model->set('fullpath', 'label', $this->_('Full name'), 'elementClass', 'Exhibitor'); $model->set('extension', 'label', $this->_('Type'), 'elementClass', 'Exhibitor'); $model->set('content', 'label', $this->_('Content'), 'formatFunction', array(\MUtil_Html::create(), 'pre'), 'elementClass', 'TextArea'); } $model->set('size', 'label', $this->_('Size'), 'formatFunction', array('MUtil_File', 'getByteSized'), 'elementClass', 'Exhibitor'); $model->set('changed', 'label', $this->_('Changed on'), 'dateFormat', $this->util->getTranslated()->dateTimeFormatString, 'elementClass', 'Exhibitor'); return $model; }