本文整理汇总了PHP中I2CE_FormStorage::listFields方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE_FormStorage::listFields方法的具体用法?PHP I2CE_FormStorage::listFields怎么用?PHP I2CE_FormStorage::listFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE_FormStorage
的用法示例。
在下文中一共展示了I2CE_FormStorage::listFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableCourses
public static function getAvailableCourses()
{
$status = I2CE_FormStorage::listFields('training_course_status', 'name');
foreach ($status as $i => &$s) {
if (!array_key_exists('name', $s)) {
unset($status[$i]);
continue;
}
$s = $s['name'];
}
$t_filters = array();
I2CE::getConfig()->setIfIsSet($t_filters, '/modules/training-course/filters/availableCourses', true);
//this should be moved to magic data form storage!
$filters = array();
foreach ($t_filters as $val) {
if (($key = array_search($val, $status)) !== false) {
$filters[] = $key;
}
}
$where = array();
if (count($filters) > 0) {
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'training_course_status', 'style' => 'in', 'data' => array('value' => $filters));
}
$courses = I2CE_FormStorage::listFields('training_course', 'name', false, $where);
foreach ($courses as $i => &$c) {
if (!array_key_exists('name', $c)) {
unset($courses[$i]);
continue;
}
$c = $c['name'];
}
return $courses;
}
示例2: showCourses
protected function showCourses()
{
if (!($listNode = $this->template->getElementByID("existing_course_list")) instanceof DOMNode) {
return;
}
if ($this->getUser()->role == "registrar" || $this->getUser()->role == "lecturer" || $this->getUser()->role == "hod" || $this->getUser()->role == "principal" || $this->getUser()->role == "deputy_principal") {
######getting id of the currently logged in lecturer######
$username = $this->getUser()->username;
$where = array("operator" => "FIELD_LIMIT", "field" => "identification_number", "style" => "equals", "data" => array("value" => $username));
$lecturer = I2CE_FormStorage::search("lecturer", false, $where);
foreach ($lecturer as $id) {
$lecturer_id = "lecturer|" . $id;
}
######Getting the current academic year######
$academic_year = iHRIS_AcademicYear::currentAcademicYear();
$where = array("operator" => "FIELD_LIMIT", "field" => "name", "style" => "equals", "data" => array("value" => $academic_year));
$academic_year_id = I2CE_FormStorage::Search("academic_year", false, $where);
$academic_year_id = "academic_year|" . $academic_year_id[0];
######Getting a list of courses assigned to this lecturer######
$where_assign_course = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "lecturer", "style" => "equals", "data" => array("value" => $lecturer_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year_id))));
$assigned_courses = I2CE_FormStorage::listFields("assign_course_trainer", array("training"), false, $where_assign_course);
} else {
$this->userMessage("Login as a training provider to add results");
$this->redirect("manage?action=provider");
return false;
}
######Displaying courses assigned to this lecturer######
if (count($assigned_courses) == 0) {
$this->userMessage("No courses assigned to you,contact the Registrar for further assistance");
$this->redirect("manage?action=provider");
return false;
}
foreach ($assigned_courses as $id => $course) {
$course_id = explode("|", $course["training"]);
$course_id = $course_id[1];
$where = array("operator" => "FIELD_LIMIT", "field" => "id", "style" => "equals", "data" => array("value" => $course_id));
$training_courses = I2CE_FormStorage::ListFields("training", array("name", "code"), false, $where);
foreach ($training_courses as $id => $training_course) {
$course_name = $training_course["name"];
$course_code = $training_course["code"];
$course = $course_code . "-" . $course_name;
$id = "training|" . $id;
$aNode = $this->template->createElement("a", array(href => "add_results?id=" . $id), $course);
$liNode = $this->template->createElement("li");
$this->template->appendNode($aNode, $liNode);
$this->template->appendNode($liNode, $listNode);
}
}
}
示例3: getIds
/**
* Return the record id and the parent id for the person position record
* for the given position.
* @param $position of the form "postion|$id"
* @return array
*/
public static function getIds($position)
{
$where = array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'position', 'style' => 'equals', 'data' => array('value' => $position)), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'end_date', 'style' => 'null', 'data' => array())));
$pers_pos = I2CE_FormStorage::listFields('person_position', array(), true, $where, array('-start_date'), 1);
if (!is_array($pers_pos) || count($pers_pos) !== 1) {
return array();
}
reset($pers_pos);
$id = key($pers_pos);
$pers_pos = $pers_pos[$id];
if (is_array($pers_pos) && array_key_exists('parent', $pers_pos)) {
$parent = $pers_pos['parent'];
} else {
$parent = false;
}
return array('record' => $id, 'parent' => $parent);
}
示例4: validate_form_person
/**
* Perform extra validation for the person form.
* A new person record needs to verify there aren't any existing
* records with the same name.
* @param I2CE_Form $form
*/
public function validate_form_person($form)
{
$search = array();
$surname_ignore = false;
if (isset($form->surname_ignore)) {
$surname_ignore = $form->surname_ignore;
}
if (I2CE_ModuleFactory::instance()->isEnabled('forms-storage') && $form->getId() == '0' && !$surname_ignore && I2CE_Validate::checkString($form->surname) && I2CE_Validate::checkString($form->firstname)) {
$where = array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'surname', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->surname))), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'firstname', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->firstname)))));
$results = I2CE_FormStorage::listFields('person', array('surname', 'firstname'), false, $where, array('surname', 'firstname'));
if (count($results) > 0) {
foreach ($results as $id => &$data) {
$data = implode(', ', $data);
}
$form->setInvalidMessage('surname', 'unique', array("view?id=" => $results));
}
}
}
示例5: validate_form_trainingprovider
/**
* Perform extra validation for the trainingprovider form.
* A new trainingprovider record needs to verify there aren't any existing
* records with the same name.
* @param I2CE_Form $form
*/
public function validate_form_trainingprovider($form)
{
$search = array();
$name_ignore = false;
if (isset($form->name_ignore)) {
$name_ignore = $form->name_ignore;
}
if (I2CE_ModuleFactory::instance()->isEnabled('forms-storage') && $form->getId() == 0 && !$name_ignore && I2CE_Validate::checkString($form->name)) {
$where = array('operator' => 'AND', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'name', 'style' => 'lowerequals', 'data' => array('value' => strtolower($form->name)))));
$results = I2CE_FormStorage::listFields('trainingprovider', array('name'), false, $where, array('name'));
if (count($results) > 0) {
foreach ($results as $id => &$data) {
$data = implode(', ', $data);
}
$form->getField('name')->setInvalid("Duplicate records match this record's name:", array("viewprovider?id=" => $results));
}
}
$value = $form->getField('email')->getValue();
if (I2CE_Validate::checkString($value) && !I2CE_Validate::checkEmail($value)) {
$form->getField('email')->setInvalid('invalid_email');
}
}
示例6: getPersonId
/**
* Gets the id of her person associated to the fiven user
* @param mixed $user I2CE_UserForm or I2CE_USER $user, or null for the logged in user
* @returns string, the person id in the form of "person|XXX" or '|' or failure
*
*/
public static function getPersonId($user = null)
{
if ($user === null) {
$user = new I2CE_User();
}
if ($user instanceof I2CE_User) {
$factory = I2CE_FormFactory::instance();
$user = $factory->createContainer("user|" . $user->username());
}
if (!$user instanceof I2CE_User_Form) {
return '|';
}
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'username', 'style' => 'equals', 'data' => array('value' => $user->getNameId()));
$maps = I2CE_FormStorage::listFields('user_map', array('parent'), true, $where);
if (count($maps) != 1) {
return '|';
}
$map = array_shift($maps);
if (!array_key_exists('parent', $map) || !is_string($map['parent']) || !substr($map['parent'], 0, 7) == 'person|') {
return '|';
}
return $map['parent'];
}
示例7: _searchLowerMatches
/**
* Internal method to search all the ids for forms that are below
* the given matched form id.
* @param string $match The form id to match at the top.
* @param array $fields The getDisplayedFields() for the field object.
* @param array $forms The getSelectableFroms() for the field object.
* @param array $displayed A list of forms that should be included in the results.
* @param int $show_hidden 0=non-hidden, 1=All, 2=hidden only.
* @return array
*/
protected static function _searchLowerMatches($match_form, $match_ids, $fields, $forms, $displayed, $show_hidden)
{
$formfield = array_shift($fields);
if (!is_array($formfield)) {
return array();
}
list($form, $link_field) = $formfield;
$limit = array('operator' => 'FIELD_LIMIT', 'field' => $link_field, 'style' => 'in', 'data' => array('value' => $match_ids));
$limit = I2CE_DataTree::showHiddenLimit($limit, $show_hidden);
$order = I2CE_List::getSortFields($form);
$field_datas = I2CE_FormStorage::listFields($form, 'id', false, $limit, $order);
$matched = array();
foreach (array_keys($field_datas) as $matched_id) {
$matched[] = $form . "|" . $matched_id;
}
if ($displayed[$form]) {
return array_merge($matched, self::_searchLowerMatches($form, $matched, $fields, $forms, $displayed, $show_hidden));
} else {
return self::_searchLowerMatches($form, $matched, $fields, $forms, $displayed, $show_hidden);
}
}
示例8: displayCourses
protected function displayCourses($courses, $div, $text, $limit = false)
{
if (!($div = $this->template->getElementByID($div)) instanceof DOMNode) {
return;
}
$table = $this->template->createElement("table", array("class" => "multiFormTable", "border" => "0", "cellpadding" => "0", "cellspacing" => "0"));
$header = $this->template->createElement("H2", "", "{$text}");
$this->template->appendNode($header, $div);
$tr = $this->template->createElement("tr");
$th = $this->template->createElement("th", array("width" => "40", "align" => "center"), "SN");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", array("width" => "10", "align" => "center"), "Select");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", array("width" => "100", "align" => "center"), "Course Code");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", "", "Course Name");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", "", "Course Type");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", "", "Course Credits");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", "", "Course Semester");
$this->template->appendNode($th, $tr);
$this->template->appendNode($tr, $table);
$counter = 1;
foreach ($courses as $id => $subject) {
$tr = $this->template->createElement("tr");
$td = $this->template->createElement("td", array("align" => "center"), $counter);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", array("align" => "center"));
if ($this->isEnrolled($subject)) {
$checkbox = $this->template->createElement("input", array("type" => "checkbox", "name" => "course[" . $subject . "]", "value" => $subject, "checked" => "checked"));
} else {
if ($limit == true) {
$checkbox = $this->template->createElement("input", array("type" => "checkbox", "name" => "course[" . $subject . "]", "value" => $subject, "disabled" => "true"));
} else {
$checkbox = $this->template->createElement("input", array("type" => "checkbox", "name" => "course[" . $subject . "]", "value" => $subject));
}
}
$this->template->appendNode($checkbox, $td);
$this->template->appendNode($td, $tr);
if ($limit == true) {
$ids = explode("|", $subject);
$id = $ids[1];
}
$where = array("operator" => "FIELD_LIMIT", "field" => "id", "style" => "equals", "data" => array("value" => $id));
$course_descriptions = I2CE_FormStorage::listFields("training", array("name", "code", "course_type", "course_credits", "semester"), false, $where);
$course_type_nameObj = $this->factory->createContainer($course_descriptions[$id]["course_type"]);
$course_type_nameObj->populate();
$course_type_name = $course_type_nameObj->getField("name")->getDBValue();
$td = $this->template->createElement("td", array("align" => "center"), $course_descriptions[$id]["code"]);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", "", $course_descriptions[$id]["name"]);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", array("align" => "center"), $course_type_name);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", array("align" => "center", "width" => 100), $course_descriptions[$id]["course_credits"]);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", array("align" => "center", "width" => 120), self::getSemesterName($course_descriptions[$id]["semester"]));
$this->template->appendNode($td, $tr);
$this->template->appendNode($tr, $table);
$counter++;
}
$this->template->appendNode($table, $div);
}
示例9: slowPopulate
/**
* Method used to populate the cache table in case the form storage mechanism is not DB like
* @param boolean $check_mod. Defaults to true. If false, it skips the mod time check
*/
protected function slowPopulate($check_mod = true)
{
$fields = array();
$mdb2_types = array();
$default_values = array();
foreach ($this->formObj as $field => $fieldObj) {
if (!$fieldObj->isInDB()) {
continue;
}
$fields[] = $field;
$mdb2_types[] = $fieldObj->getMDB2Type();
$default_values[$field] = $fieldObj->getDBValue();
}
$default_values['last_modified'] = '1900-01-01 00:00:00';
$default_values['created'] = '0000-00-00 00:00:00';
$insert_fields = $fields;
$insert_fields[] = 'last_modified';
$insert_fields[] = 'created';
$fields[] = 'last_modified';
$fields[] = 'created';
$insert_fields[] = "id";
$insert_fields[] = 'parent';
$update_fields = array();
foreach ($insert_fields as &$field) {
$field = '`' . $field . '`';
$update_fields[] = "{$field}=values({$field})";
}
unset($field);
$insertQry = 'INSERT INTO ' . $this->table_name . " (" . implode(',', $insert_fields) . " ) " . " VALUES (" . implode(',', array_fill(0, count($insert_fields), '?')) . ")" . " ON DUPLICATE KEY UPDATE " . implode(',', $update_fields);
I2CE::raiseError("Slow populate:\n{$insertQry}");
$db = MDB2::singleton();
$prep = $db->prepare($insertQry, $mdb2_types, MDB2_PREPARE_MANIP);
if (I2CE::pearError($prep, "Error setting up form in the database:")) {
return false;
}
if ($check_mod) {
$mod_time = $this->getLastCachedTime();
} else {
$mod_time = 0;
}
$list = I2CE_FormStorage::listFields($this->form, $fields, true, array(), array(), false, $mod_time);
$count = 0;
foreach ($list as $id => $data) {
$count++;
$t_data = array();
foreach ($fields as $field) {
if (array_key_exists($field, $data)) {
$t_data[] = $data[$field];
} else {
$t_data[] = $default_values[$field];
}
}
$t_data[] = $this->form . "|" . $id;
if (array_key_exists('parent', $data)) {
$t_data[] = $data['parent'];
} else {
$t_data[] = null;
}
$res = $prep->execute($t_data);
if (I2CE::pearError($res, "Error insert into cache table:")) {
return false;
}
}
I2CE::raiseError("Populate {$count} entries for {$this->form}");
return true;
}
示例10: setupParticipants
/**
* Setup the list of all participants for this instance.
*/
protected function setupParticipants()
{
if (!is_array($this->participants)) {
$this->participants = array();
$where_data = array('operator' => 'FIELD_LIMIT', 'field' => 'provider_instance', 'style' => 'equals', 'data' => array('value' => $this->instance->getNameId()));
$participants = I2CE_FormStorage::listFields('person_instance', array('attending', 'parent'), false, $where_data);
foreach ($participants as $p_instance => $i_data) {
$this->participants[$i_data['parent']] = $i_data['attending'];
}
} else {
I2CE::raiseError("setupParticipants was called twice, so nothing was done the second time.");
}
}
示例11: cronjob
/**
* Run the appropriate cron jobs based on the cron type.
* @param string $type
*/
public function cronjob($type)
{
// We need to run any normal hooks and not CLI hooks for this process if run from CLI
$host_changed = false;
if (!array_key_exists('HTTP_HOST', $_SERVER)) {
$host_changed = true;
$_SERVER['HTTP_HOST'] = '';
}
// Find all the Module Access modules that are available so the user can be set.
$report_limits = I2CE_ModuleFactory::callHooks("get_report_module_limit_options");
$limit_modules = array();
foreach ($report_limits as $limit) {
if (array_key_exists('module', $limit)) {
$mod = I2CE_ModuleFactory::instance()->getClass($limit['module']);
$limit_modules[] = array('module' => $mod, 'user' => $mod->getUser());
}
}
$cron_type_where = array('operator' => "FIELD_LIMIT", 'style' => 'equals', 'field' => 'cron_type', 'data' => array('value' => $type));
$reports = I2CE_FormStorage::listFields('cron_report', array('parent', 'report_view'), false, $cron_type_where);
foreach ($reports as $report) {
$view = $report['report_view'];
$user = I2CE_FormFactory::instance()->createContainer($report['parent']);
// Set the user on all access modules to limit results.
foreach ($limit_modules as $module) {
$module['module']->setUser($user->user);
}
$_SESSION['user_name'] = $user->username;
$page = new I2CE_Page_ShowReport(array(), array($view));
$template = $page->getTemplate();
$display = $page->getDesiredDisplays($view);
$use_display = 'Default';
if ($display[0] != 'PieChart') {
$use_display = $display[0];
}
$displayObj = $page->instantiateDisplay($use_display, $view);
$config = I2CE::getConfig()->modules->CustomReports->reportViews->{$view};
$template->loadRootText("<span id='siteContent' />");
$contentNode = $template->getElementById('siteContent');
$attachments = array();
$report_name = $config->display_name;
$report_desc = $config->description;
$report_limit = '';
$generated = strftime('%c');
switch ($use_display) {
case "CrossTab":
if ($displayObj->isExport()) {
$export = $displayObj->generateExport($contentNode, false);
$html = false;
$attachments[] = array('type' => "text/csv; charset=UTF-8", 'data' => $export, 'name' => $this->getFileName($report_name) . ".csv");
break;
}
// If not export then fall through to the Default
// If not export then fall through to the Default
case "Default":
$displayObj->unsetPaging();
$displayObj->display($contentNode);
$report_limit = $displayObj->getReportLimitsDescription();
$css = I2CE::getFileSearch()->search('CSS', 'customReports_display_Default.css');
$report_css = file_get_contents($css);
$report_table = $template->getElementById('report_table');
$report_content = $template->doc->saveHTML($report_table);
$html = <<<EOF
<?xml version="1.0" encoding="utf-8"?>'
<!DOCTYPE html>
<html>
<head>
<title>Automated Report: {$report_name}</title>
<style type="text/css">
{$report_css}
</style>
</head>
<body>
<h1>{$report_name}</h1>
<h2>{$report_desc}</h2>
<h3>{$report_limit}</h3>
<p>Generated on: {$generated}</p>
{$report_content}
</body>
</html>
EOF;
break;
case "PDF":
$pdf = $displayObj->getPDF($contentNode);
$pdf_data = $pdf->Output($report_name, 'S');
$html = false;
$attachments[] = array('type' => 'application/pdf', 'data' => $pdf_data, 'name' => $this->getFileName($report_name) . ".pdf");
break;
case "Export":
$export = $displayObj->generateExport();
$html = false;
$attachments[] = array('type' => $displayObj->getContentType(true), 'data' => $export, 'name' => $displayObj->getFileName());
break;
default:
I2CE::raiseError("Unknown display type used for report display for user cron reports.");
break;
}
//.........这里部分代码省略.........
示例12: action
protected function action()
{
if (!$this->hasPermission("task(can_add_students_results)" or $this->getUser()->role == "admin")) {
$this->setRedirect("noaccess");
return;
}
$this->ff = I2CE_FormFactory::instance();
//update academic year
iHRIS_AcademicYear::ensureAcademicYear();
//retrive the academic year
$current_academic_year = iHRIS_AcademicYear::currentAcademicYear();
$academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year);
$academic_year_id = "academic_year|" . $academic_year_id;
$this->course_id = $this->request("id");
$where_course_id = array("operator" => "AND", "operand" => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'training', 'style' => 'like', 'data' => array('value' => "%" . $this->course_id . "%")), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'academic_year', 'style' => 'equals', 'data' => array('value' => $academic_year_id))));
$parents = I2CE_FormStorage::listFields("enroll_course", array("parent", "training", "academic_year"), false, $where_course_id);
if (!($listNode = $this->template->getElementByID("students_list")) instanceof DOMNode) {
return;
}
if (!($hidden_data = $this->template->getElementByID("hidden_data")) instanceof DOMNode) {
return;
}
if (count($parents) == 0) {
$this->userMessage("No students enrolled for this course!!!");
$this->setRedirect("add_results_select_course");
}
$input = $this->template->createElement("input", array("type" => "hidden", "name" => "course_id", "value" => $this->course_id));
$this->template->appendNode($input, $listNode);
$table = $this->template->createElement("table", array("class" => "multiFormTable", "width" => "100%", "border" => "0", "cellpadding" => "0", "cellspacing" => "0"));
$tr = $this->template->createElement("tr");
$th = $this->template->createElement("th", array("width" => "60%"), "Student Name");
$this->template->appendNode($th, $tr);
$th = $this->template->createElement("th", "", "Registration Number");
$this->template->appendNode($th, $tr);
$this->appendExamTypesHeaders($tr);
$this->template->appendNode($tr, $table);
//retrieving the max mark for each assessment
foreach ($this->exam_types as $exam_type) {
list($form, $id) = array_pad(explode("|", $exam_type, 2), 2, '');
list($form, $course_id) = array_pad(explode("|", $this->course_id, 2), 2, '');
$max_mark = I2CE_FormStorage::lookupField("training", $course_id, array($id), false);
$max_mark = $max_mark[$id];
$input = $this->template->createElement("input", array("type" => "hidden", "name" => $id, "id" => $id, "value" => $max_mark));
$this->template->appendNode($input, $listNode);
}
//fecth lecturer institution to make sure can see students for his/her institution
$username = $this->getUser()->username;
$inst_id = iHRIS_PageFormLecturer::fetch_institution($username);
foreach ($parents as $enroll_id => $parent) {
$reg_details = STS_PageFormPerson::load_current_registration($person_id);
###drop students which are on different institution###
if ($inst_id != $reg_details["training_institution"]) {
continue;
}
$trainings = explode(",", $parent["training"]);
$tr = $this->template->createElement("tr");
$person_id = $parent["parent"];
$reg_num = $this->getRegistrationNumber($person_id);
$input = $this->template->createElement("input", array("type" => "hidden", "name" => "reg_num[" . $reg_num . "]", "value" => $reg_num));
$this->template->appendNode($input, $tr);
list($form, $id) = array_pad(explode("|", $person_id, 2), 2, '');
$field_data = I2CE_FormStorage::lookupField("person", $id, array('firstname', 'surname'), false);
if (is_array($field_data) && array_key_exists('surname', $field_data) && array_key_exists('firstname', $field_data)) {
$fullname = $field_data['firstname'] . ' ' . $field_data['surname'];
$aNode = $this->template->createElement("a", array("href" => "view?id=" . $person_id), $fullname);
$td = $this->template->createElement("td");
$this->template->appendNode($aNode, $td);
$this->template->appendNode($td, $tr);
$td = $this->template->createElement("td", array("id" => $reg_num, "align" => "center"));
$this->template->addTextNode($reg_num, $reg_num, $td);
$this->template->appendNode($td, $tr);
$this->appendExamTypesInput($tr, $reg_num, $person_id, $this->course_id, $parent["academic_year"], $enroll_id);
}
$this->template->appendNode($tr, $table);
}
$tr = $this->template->createElement("tr");
$td = $this->template->createElement("td", array("colspan" => "10", "align" => "right"));
$input = $this->template->createElement("input", array("type" => "submit", "value" => "Save", "onclick" => "return verify()"));
$this->template->appendNode($input, $td);
$this->template->appendNode($td, $tr);
$this->template->appendNode($tr, $table);
$this->template->appendNode($table, $listNode);
}
示例13: getMappedCodeLists
/**
* Gets any code lists that are already mapped in the system
* @param string $form
* @returns boolean
*/
protected function getMappedCodeLists($form, $field)
{
if (array_key_exists($form, $this->mapping_data) && array_key_exists($field, $this->mapping_data[$form])) {
return $this->mapping_data[$form][$field];
}
if (!array_key_exists($form, $this->mapping_data)) {
$this->mapping_data[$form] = array();
}
$options = $this->getStorageOptions($form);
if (!$options instanceof I2CE_MagicDataNode) {
I2CE::raiseError("Invalid SDMX_CrossSectional storage options for {$form}");
//shouldn't happen at this point
return false;
}
$mapData = false;
//do something to populate the mapping data
if ($field == 'parent') {
$mapPath = "parent/map_data";
} else {
$mapPath = "fields/{$field}/map_data";
}
if ($options->is_scalar($mapPath . '/list') && $options->is_scalar($mapPath . '/codelist')) {
$list = $option->{$mapPath}->list;
$codelist = $option->{$mapPath}->codelist;
if ($list && $codelist) {
$mapData = array();
//we have a list and a codelist set so we should attempt to get the mapping data at this point
if (I2CE_FormFactory::instance()->exists($list)) {
$linkForm = 'list_linkto_list_' . I2CE_FormStorage::getStorage($options->{$mapPath}->list);
$options->setIfIsSet($linkForm, $mapPath . '/mapping_form');
$where = array('operator' => 'AND', 'operands' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'list', 'style' => 'like', 'data' => array('value' => $list . '|%')), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'like', 'style' => 'starts_with', 'data' => array('value' => $codelist . '|%'))));
$data = I2CE_FormStorage::listFields($linkForm, array('list', 'links_to'), false, $where);
}
$codelist_len = strlen($codelist) + 1;
foreach ($data as $id => $vals) {
if (!is_array($vals) || !array_key_exists('list', $vals) || !array_key_exists('links_to', $vals) || strlen($vals['links_to'] <= $codelist_len)) {
continue;
}
//chop of the $codelist| from the links to value and store it.
$data[substr($vals['codelist'], $codelist_len)] = $vals['list'];
}
}
}
$this->mapping_data[$form][$field] = $mapData;
return $this->mapping_data[$form][$field];
}
示例14: getCurrentListLimits
/**
* Get the limits to be used for the current list based on any potentially "lower" limits to avoid
* excess choices with nothing below.
* @param array $form_limits
* @param string $list
* @param array $form_fields
* @return array
*/
protected function getCurrentListLimits($form_limits, $list, $form_fields)
{
if (count($form_limits) == 1 && array_key_exists($list, $form_limits)) {
return $form_limits;
}
$ff = I2CE_FormFactory::instance();
//foreach( $form_fields as $form_field ) {
$max_idx = count($form_fields) - 1;
for ($i = 0; $i < $max_idx; $i++) {
$form_field = str_replace('[', '', str_replace(']', '', $form_fields[$i]));
if (strpos($form_field, '+') !== false) {
list($form, $field) = explode('+', $form_field, 2);
} else {
$form = $form_field;
$next_ff = str_replace('[', '', str_replace(']', '', $form_fields[$i + 1]));
if (strpos($next_ff, '+') !== false) {
list($field, $notused) = explode('+', $next_ff, 2);
} else {
$field = $next_ff;
}
}
if ($list == $form) {
break;
}
if (array_key_exists($form, $form_limits)) {
$matched = I2CE_FormStorage::listFields($form, array($field), false, $form_limits[$form]);
$in = array();
foreach ($matched as $match) {
if (array_key_exists($field, $match) && strpos($match[$field], '|') !== false) {
list($mf, $mid) = explode('|', $match[$field], 2);
$in[] = $mid;
}
}
if (count($in) > 0) {
self::addOrCombineFieldLimit($form_limits, $field, "id", $in, "in");
}
}
}
return $form_limits;
}
示例15: add_uuids
public static function add_uuids($form, $field = 'csd_uuid')
{
I2CE::raiseError("ADDING UUIDS to {$form} on {$field}");
try {
//we probably don't need this, but
$cache = new I2CE_CachedForm($form);
$cache->dropTable();
} catch (Exception $e) {
I2CE::raiseError("Could not clear cache");
return false;
}
$ff = I2CE_FormFactory::instance();
$user = new I2CE_User();
$forms = I2CE_FormStorage::listFields($form, array($field));
foreach ($forms as $id => $fields) {
if (is_array($fields) && array_key_exists('csd_uuid', $fields) && $fields['csd_uuid']) {
continue;
}
if (!($form_obj = $ff->createContainer(array($form, $id))) instanceof I2CE_Form) {
I2CE::raiseError("Could not instantiate {$form}|{$id}");
return false;
}
$form_obj->populate();
self::set_uuid_on_form($form_obj);
$form_obj->save($user);
$form_obj->cleanup();
}
try {
//we probably don't need this, but
$cache = new I2CE_CachedForm($form);
$cache->dropTable();
$cache->generateCachedTable();
} catch (Exception $e) {
I2CE::raiseError("Could not clear cache");
return false;
}
return true;
}