protected function loadList() { if (is_array($this->list_values)) { return; } $this->list_values = array(); $path = "meta/list"; if (!$this->optionsHasPath($path) || !is_string($list_form = $this->getOptionsByPath($path)) || !is_array($list_values = I2CE_List::listOptions($list_form))) { return; } foreach ($list_values as $data) { if (!is_array($data) || !array_key_exists('value', $data) || !array_key_exists('display', $data)) { continue; } $this->list_values[$data['value']] = $data['display']; } }
public function evaluateStudents($node, $template) { $list = $this->getEnrolledStudents(); $template->addHeaderLink("mootools-core.js"); $template->addHeaderLink("mootools-more.js"); $template->addHeaderLink("editstudent.js"); $evals = I2CE_List::listOptions('training_course_evaluation'); foreach ($evals as $id => $data) { if (!is_array($data) || !array_key_exists('value', $data) || !array_key_exists('display', $data)) { unset($evals[$i]); } } foreach ($list as $id => $sdata) { $studentNode = $template->appendFileByNode('evaluate_students.html', 'div', $node); if (!$studentNode instanceof DOMNode) { return false; } $studId = 'student_' . $id; $studentNode->setAttribute('id', $studId); $template->setDisplayDataImmediate('id', 'id=' . $id, $studentNode); $template->setDisplayDataImmediate('firstname', $sdata['firstname'], $studentNode); $template->setDisplayDataImmediate('surname', $sdata['surname'], $studentNode); if (!($evalNode = $template->getElementByName('evaluation', 0, $studentNode)) instanceof DOMElement) { continue; } list($f, $fid) = array_pad(explode("|", $sdata['person_scheduled_training_course'], 2), 2, ''); $eval = I2CE_FormStorage::lookupField('person_scheduled_training_course', $fid, array('training_course_evaluation'), ''); foreach ($evals as $data) { $id = $data['value']; $disp = $data['display']; $attrs = array('value' => $id); if ($eval == $id) { $attrs['selected'] = 'selected'; } $evalNode->appendChild($template->createElement('option', $attrs, $disp)); } $js = "changeStudentEvaluation(this,'" . addslashes($sdata['person_scheduled_training_course']) . "');"; $evalNode->setAttribute('onchange', $js); } }
protected function actionSelectMapped() { $this->template->addFile("lists_type_mapped.html"); $this->addAlphabet(); $add_node = $this->template->getElementById('mapped'); if (!$add_node instanceof DOMNode) { I2CE::raiseError("Don't know where to add mapped field options"); } else { $select_template = "lists_type_mapped_" . $this->type . "_" . $this->select_field->getName() . ".html"; $select_template = $this->template->findTemplate($select_template, false); if (!$select_template) { $select_template = "lists_type_mapped_default.html"; } $node = $this->template->appendFileById($select_template, "span", "mapped"); $form_node = $this->template->getElementById('select_form_field_node'); if ($form_node instanceof DOMElement) { $form_node->setAttribute('show_i2ce_hidden', $this->showHidden()); $this->select_field->processDOMEditable($node, $this->template, $form_node); $add_node->appendChild($node); } else { I2CE::raiseError("could not find 'select_form_field_node' in " . $select_template); } } $this->template->appendFileById("lists_type_header.html", "th", "lists_header"); $keys = explode('[', $this->select_field->getHTMLName()); foreach ($keys as &$key) { if (strlen($key) > 0 && substr($key, -1) == ']') { $key = substr($key, 0, -1); } } unset($key); if (!$this->select_field->isSetValue() && !$this->request_exists($keys)) { return true; //don't show any options until a value has been selected } #select_field may be not set. that's ok. listOptions does error checking $list = I2CE_List::listOptions($this->type, $this->showHidden(), $this->select_field); if ($this->get_exists('letter')) { $list = array_filter($list, "self::filter_by_" . $this->get('letter')); } if ($this->request_exists('display') && $this->_hasMethod('actionDisplayList_' . $this->request('display'))) { $method = 'actionDisplayList_' . $this->request('display'); return $this->{$method}($list); } else { if (count($list) > 0) { return $this->paginateList($list); } else { return true; } } }
protected function action_select_field($listConfig) { if (!($obj = $this->getPrimary()) instanceof I2CE_List) { I2CE::raiseError("No primary list"); return false; } if (!($select_field = $this->getSelectField($listConfig)) instanceof I2CE_FormField_MAPPED) { I2CE::raiseError("select field is not map"); return false; } if (!($node = $this->template->addFile("auto_lists_type_mapped.html")) instanceof DOMNode) { return false; } $this->template->setDisplayData('field', $select_field->getName(), $node); $this->template->setDisplayData('field_name', $select_field->getHeader(), $node); $this->template->setDisplayData("type_name", $obj->getDisplayName()); if (($formNode = $this->template->getElementByTagName('form', 0, $node)) instanceof DOMElement) { $formNode->setAttribute('action', 'auto_list'); } $add_node = $this->template->getElementById('mapped'); if (!$add_node instanceof DOMNode) { I2CE::raiseError("Don't know where to add mapped field options"); } else { $select_template = "lists_type_mapped_" . $this->getPrimaryFormName() . "_" . $select_field->getName() . ".html"; $select_template = $this->template->findTemplate($select_template, false); if (!$select_template) { $select_template = "lists_type_mapped_default.html"; } $node = $this->template->appendFileById($select_template, "span", "mapped"); $form_node = $this->template->getElementById('select_form_field_node'); if ($form_node instanceof DOMElement) { $form_node->setAttribute('show_i2ce_hidden', $this->showHidden()); $select_field->processDOMEditable($node, $this->template, $form_node); $add_node->appendChild($node); } else { I2CE::raiseError("could not find 'select_form_field_node' in " . $select_template); } } $this->template->appendFileById("lists_type_header.html", "th", "lists_header"); $keys = explode('[', $htmlname = $select_field->getHTMLName()); foreach ($keys as &$key) { if (strlen($key) > 0 && substr($key, -1) == ']') { $key = substr($key, 0, -1); } } unset($key); $link_data = array($htmlname => $this->request($keys)); $this->setTemplateVars($listConfig, $link_data); if (!$select_field->isSetValue() && !$this->request_exists($keys)) { return true; //don't show any options until a value has been selected } //select_field may be not set. that's ok. listOptions does error checking $list = I2CE_List::listOptions($this->getPrimaryFormName(), $this->showHidden(), $select_field); if ($this->request_exists('letter')) { $list = array_filter($list, "self::filter_by_" . $this->request('letter')); } if (count($list) > 0) { if (!($list = $this->paginateList($list))) { return false; } } return $this->actionDisplayList_row($list, $listConfig); }