本文整理汇总了PHP中I2CE_FormStorage::listDisplayFields方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE_FormStorage::listDisplayFields方法的具体用法?PHP I2CE_FormStorage::listDisplayFields怎么用?PHP I2CE_FormStorage::listDisplayFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE_FormStorage
的用法示例。
在下文中一共展示了I2CE_FormStorage::listDisplayFields方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayValues
public function displayValues($content_node, $transient_options, $action)
{
$mainNode = $this->template->appendFileByNode('service_directory_selector.html', 'div', $content_node);
if (!$mainNode instanceof DOMNode) {
return false;
}
$directories = array('provider', 'service', 'facility', 'organization');
foreach ($directories as $directory) {
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'is_' . $directory, 'style' => 'true');
if (!($selectNode = $this->template->getElementByName($directory, 0, $mainNode)) instanceof DOMElement) {
continue;
}
$avail_dirs = I2CE_FormStorage::listDisplayFields('csd_info_manager', array('name'), false, $where);
$selected = $this->getField($directory);
foreach ($avail_dirs as $id => $data) {
if (!is_array($data) || !array_key_exists('name', $data)) {
continue;
}
$id = 'csd_info_manager|' . $id;
if ($id != $selected) {
$selectNode->appendChild($this->template->createElement('option', array('value' => $id), $data['name']));
} else {
$selectNode->appendChild($this->template->createElement('option', array('value' => $id, 'selected' => 'selected'), $data['name']));
}
}
}
$this->renameInputs($directories, $mainNode);
return true;
}
示例2: generate
public function generate($node)
{
if (!$node instanceof DOMNode || !$this->primaryObject instanceof I2CE_Form || I2CE_PermissionParser::taskExists($this->options['task']) && !$this->page->hasPermission("task(" . $this->options['task'] . ")", $node) || !($linkedNode = $this->template->appendFileByNode($this->options['template'], 'div', $node)) instanceof DOMNode || !($tbodyNode = $this->template->getElementByName('child_fields', 0, $node)) instanceof DOMNode) {
return false;
}
$added = 0;
if (count($this->options['action_links']) > 0 && ($ulNode = $this->template->getElementByName('child_links', 0, $linkedNode)) instanceof DOMNode) {
$added = $this->addLinks('li', $this->options['action_links'], $ulNode);
}
if ($added == 0 && ($containerNode = $this->template->getElementByName('child_actions', 0, $linkedNode)) instanceof DOMNode) {
$this->template->removeNode($containerNode);
}
$this->template->setDisplayDataImmediate('child_title', $this->options['title'], $linkedNode);
$dispDatas = array();
$arg_walker = array();
if ($this->options['printf'] && is_array($this->options['printf_args'])) {
foreach ($this->options['printf_args'] as $i => &$arg) {
$t_arg = explode(":", $arg);
if (count($t_arg) > 1) {
$arg_walker[$i] = $t_arg;
$arg = $t_arg[0];
}
}
unset($arg);
$dispDatas = I2CE_FormStorage::listDisplayFields($this->options['form'], $this->options['printf_args'], $this->primaryObject->getNameId(), $this->options['where'], $this->options['orders'], $this->options['limit']);
$ids = array_keys($dispDatas);
} else {
$ids = I2CE_FormStorage::search($this->options['form'], $this->primaryObject->getNameId(), $this->options['where'], $this->options['orders'], $this->options['limit']);
}
if (count($ids) == 0) {
return false;
}
foreach ($ids as $id) {
$text = $this->options['title'];
//default text for child in case printf wasn't set.
if (array_key_exists($id, $dispDatas) && is_array($dispDatas)) {
$dispFields = $dispDatas[$id];
foreach ($this->options['printf_args'] as $i => $arg) {
$dispData[$i] = $dispFields[$arg];
}
foreach ($arg_walker as $i => $fields) {
$val = $dispData[$i];
$count = 0;
foreach ($fields as $field) {
$count++;
if ($count == 1) {
continue;
}
list($wform, $wid) = array_pad(explode('|', $val, 2), 2, '');
$val = I2CE_FormStorage::lookupField($wform, $wid, array($field), '');
}
$dispData[$i] = $val;
}
$text = @vsprintf($this->options['printf'], $dispData);
}
$this->generateAjaxLink($id, $text, $tbodyNode);
}
}
示例3: action
/**
* Perform any actions for the page
*
* @returns boolean. true on sucess
*/
public function action()
{
parent::action();
if (count($this->request_remainder) != 1) {
$this->userMessage("Cannot view archived report");
$this->setRedirect("CustomReports/view/reportViews");
return false;
}
reset($this->request_remainder);
$this->reportView = (string) current($this->request_remainder);
if (isset($config->reportViews->{$this}->reportView->limit_view_to) && $config->reportViews->{$this}->reportView->limit_view_to) {
if (!$this->hasPermission(' task(custom_reports_admin) or ' . $config->reportViews->{$this}->reportView->limit_view_to)) {
$this->userMessage("You do not have permission to view this report");
$this->setRedirect("CustomReports/view/reportViews");
return false;
}
}
if ($this->request_exists('id')) {
$id = $this->request('id');
$link = I2CE_FormField_BINARY_FILE::getFieldLink($id, 'report');
$this->redirect($link);
return true;
} else {
$node = $this->template->addFile("archiveReports_menu.html");
if (!$node instanceof DOMNode) {
return false;
}
$dn = $this->reportView;
I2CE::getConfig()->setIfIsSet($dn, "/modules/CustomReports/reportViews/{$this->reportView}/display_name");
$this->template->setDisplayDataImmediate('reportView_name', $dn, $node);
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'report_view', 'style' => 'equals', 'data' => array('value' => $this->reportView));
$list = I2CE_FormStorage::listDisplayFields('archived_report', I2CE_List::getDisplayFields('archived_report'), false, $where, I2CE_List::getSortFields('archived_report'));
$disp_string = I2CE_List::getDisplayString('archived_report');
foreach ($list as &$val) {
$val = vsprintf($disp_string, $val);
}
return $this->paginateList($list);
}
}
示例4: actionRecent
/**
* Display the recent changes list for the given form.
* @return boolean
*/
protected function actionRecent()
{
$form = array_shift($this->request_remainder);
$form_config = I2CE::getConfig()->traverse("/modules/forms/forms");
if (!$form_config->is_parent($form) || !I2CE::getConfig()->is_parent("/modules/RecentForm/forms/{$form}")) {
return $this->actionMenu();
}
$page_size = 25;
$days = "today";
$user = false;
if (count($this->request_remainder) > 0) {
$days = array_shift($this->request_remainder);
}
$user_list = false;
if (count($this->request_remainder) > 0) {
$user_list = array_shift($this->request_remainder);
$user = explode(',', $user_list);
foreach ($user as $key => $uid) {
if ($uid == "me") {
$uobj = new I2CE_User();
$user[$key] = $uobj->getId();
}
}
$user = array_filter($user, "is_numeric");
if (count($user) == 0) {
$user = false;
} elseif (count($user) == 1) {
$user = array_pop($user);
}
}
switch ($days) {
case "yesterday":
$mod_time = mktime(0, 0, 0, date("n"), date("j") - 1);
break;
case "week":
$mod_time = mktime(0, 0, 0, date("n"), date("j") - 7);
break;
default:
$mod_time = mktime(0, 0, 0);
break;
}
$form_name = $form;
$form_config->setIfIsSet($form_name, "{$form}/display");
$user_link = "";
if ($user_list) {
$user_link = "/" . $user_list;
}
$this->template->setDisplayDataImmediate("display_form_name", ": " . $form_name);
$header = $this->template->appendFileById("recent_display.html", "div", "recent_forms");
$this->template->setDisplayDataImmediate("recent_name", $form_name, $header);
$this->template->setDisplayDataImmediate("recent_date", date("d M Y", $mod_time), $header);
$this->template->setDisplayDataImmediate("recent_today_link", array("href" => "recent/{$form}/today" . $user_link), $header);
$this->template->setDisplayDataImmediate("recent_yesterday_link", array("href" => "recent/{$form}/yesterday" . $user_link), $header);
$this->template->setDisplayDataImmediate("recent_week_link", array("href" => "recent/{$form}/week" . $user_link), $header);
$this->template->setDisplayDataImmediate("recent_me_link", array("href" => "recent/{$form}/{$days}/me"), $header);
$this->template->setDisplayDataImmediate("recent_all_link", array("href" => "recent/{$form}/{$days}"), $header);
$recent_form_config = I2CE::getConfig()->traverse("/modules/RecentForm/forms/{$form}", true);
$fields = $recent_form_config->fields->getAsArray();
ksort($fields);
if (!is_array($fields)) {
$fields = array();
}
$display = implode(" ", array_fill(0, count($fields), "%s"));
$recent_form_config->setIfIsSet($display, "display");
$link = "recent";
$recent_form_config->setIfIsSet($link, "link");
$parent = false;
$recent_form_config->setIfIsSet($parent, "parent");
if ($parent) {
$parent = true;
}
$order = $fields;
array_unshift($order, "-last_modified");
if ($this->request_exists("page")) {
$limit_start = ((int) $this->request("page") - 1) * $page_size;
} else {
$limit_start = 0;
}
$results = I2CE_FormStorage::listDisplayFields($form, $fields, $parent, array(), $order, array($limit_start, $page_size), $mod_time, false, $user);
$num_found = I2CE_FormStorage::getLastListCount($form);
$this->template->setDisplayDataImmediate("recent_found", $num_found, $header);
foreach ($results as $id => $data) {
$record = $this->template->appendFileById("recent_display_form.html", "li", "recent_list");
if ($parent) {
$this->template->setDisplayDataImmediate("form_link", array("href" => $link . $data['parent']), $record);
} else {
$this->template->setDisplayDataImmediate("form_link", array("href" => $link . $form . "|" . $id), $record);
}
$extra_display = I2CE_ModuleFactory::callHooks("recent_form_{$form}_display", $data);
array_unshift($extra_display, vsprintf($display, $data));
$this->template->setDisplayDataImmediate("record_display", implode(' ', $extra_display), $record);
}
if ($this->module == "I2CE") {
$url = $this->page . "/" . $form . "/" . $days;
} else {
$url = $this->module . "/" . $this->page . "/" . $form . "/" . $days;
//.........这里部分代码省略.........
示例5: prepostScores
public function prepostScores($node, $template)
{
//this really should be a fuzzy method in the training exam module
// if (! (I2CE_ModuleFactory::instance()->isEnabled('training-exam'))) {
// return false;
// }
if (!($main_node = $template->appendFileByNode('training_course_prepost_base.html', 'div', $node)) instanceof DOMNode) {
return false;
}
if (!($list_node = $template->getElementById('student_exams', $main_node)) instanceof DOMNode) {
return false;
}
$template->addHeaderLink("editstudent.js");
$list = $this->getEnrolledStudents();
$exam_ids = array('pretest', 'final');
$exams = I2CE_FormStorage::listDisplayFields('training_course_exam_type', array('name'), false, array(), array('name'));
foreach ($exam_ids as $e_id => $exam_id) {
if (!in_array($exam_id, array_keys($exams))) {
I2CE::raiseError("Exam {$exam_id} not found in " . implode(",", array_keys($exams)));
unset($exam_ids[$e_id]);
}
}
$passing_score = '';
$passing_scores = I2CE_FormStorage::lookupField('training_course', $this->getField('training_course')->getMappedID(), array('passing_score'), false);
if (count($passing_scores) == 1) {
$passing_score = current($passing_scores);
if (!is_numeric($passing_score) || $passing_score < 0 || $passing_score > 100) {
$passing_score = '';
}
}
if ($passing_score) {
$examsNode = $template->appendFileByNode('exam_summary_prepost.html', 'div', $list_node);
} else {
$examsNode = $template->appendFileByNode('exam_summary_prepost_no_score.html', 'div', $list_node);
}
if (!$examsNode instanceof DOMNode || !($sumNode = $template->getElementByName('exam_student_list', 0, $examsNode))) {
I2CE::raiseError("Couldnt get exam_student_list");
return false;
}
foreach ($exam_ids as $examid) {
$data = $exams[$examid];
if (!is_array($data) || !array_key_exists('name', $data) || !$data['name']) {
continue;
}
$template->setDisplayData('passing_score', $passing_score, $examsNode);
$sumNode->setAttribute('id', 'exam_results_' . $examid);
$template->setDisplayData('exam_type_' . $examid, $data['name'], $examsNode);
}
$ff = I2CE_FormFactory::instance();
$do_date = false;
if (($tcField = $this->getField('training_course')) instanceof I2CE_FormField_MAP && ($tcObj = $tcField->getMappedFormObject()) instanceof iHRIS_TrainingCourse && ($doCert = $tcObj->getField('has_certification_date')) instanceof I2CE_FormField_YESNO && $doCert->getValue()) {
$do_date = true;
}
if ($do_date) {
$template->setDisplayDataImmediate('has_certification_date', 1, $examsNode);
} else {
$template->setDisplayDataImmediate('has_certification_date', 0, $examsNode);
}
foreach ($list as $id => $data) {
$studentNode = $template->appendFileByNode('students_prepost.html', 'div', $list_node);
if (!$studentNode instanceof DOMNode) {
continue;
}
$studId = 'student_' . $id;
$studentNode->setAttribute('id', $studId);
$template->setDisplayDataImmediate('id', 'id=' . $id, $studentNode);
$template->setDisplayDataImmediate('firstname', $data['firstname'], $studentNode);
$template->setDisplayDataImmediate('surname', $data['surname'], $studentNode);
foreach ($exam_ids as $examid) {
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'training_course_exam_type', 'style' => 'equals', 'data' => array('value' => 'training_course_exam_type|' . $examid));
$score = null;
$scores = I2CE_FormStorage::listFields('training_course_exam', array('score'), $data['person_scheduled_training_course'], $where);
$exam_id = '0';
if (count($scores) == 1) {
$exam_id = 'training_course_exam|' . key($scores);
$s_data = current($scores);
if (is_array($s_data) && array_key_exists('score', $s_data)) {
$score = $s_data['score'];
}
}
if (!($finalNode = $template->getElementByName('student_exam_' . $examid, 0, $studentNode)) instanceof DOMNode) {
continue;
}
$template->setDisplayDataImmediate('student_exam_' . $examid, $score, $finalNode);
if ($passing_score) {
if ($score >= $passing_score) {
$finalNode->setAttribute('style', 'color:green');
} else {
$finalNode->setAttribute('style', 'color:red');
}
}
}
if (!$do_date) {
continue;
}
//now handle certifacation date
if (!($pstcObj = $ff->createContainer($data['person_scheduled_training_course'])) instanceof iHRIS_Person_Scheduled_Training_Course || !($certField = $pstcObj->getField('certification_date')) instanceof I2CE_FormField_DATE_YMD || !($certNode = $template->getElementByName('certification_date', 0, $studentNode)) instanceof DOMElement) {
//echo get_class($pstcObj); echo get_class($certField); echo get_class($certNode);
continue;
}
//.........这里部分代码省略.........
示例6: generate
public function generate($node)
{
if ($this->options['task'] && I2CE_PermissionParser::taskExists($this->options['task']) && !$this->page->hasPermission("task(" . $this->options['task'] . ")", $node) || !($linkedNode = $this->template->appendFileByNode($this->options['template'], 'div', $node)) instanceof DOMNode || !($pageDispNode = $this->template->getElementByName('pager_display', 0, $linkedNode)) instanceof DOMNode || !($pageResultsNode = $this->template->getElementByName('pager_results', 0, $linkedNode)) instanceof DOMNode || !($tbodyNode = $this->template->getElementByName('link_fields', 0, $node)) instanceof DOMNode) {
return;
}
$arg_walker = array();
$printf_args = $this->options['printf_args'];
foreach ($printf_args as $i => &$arg) {
$t_arg = explode(":", $arg);
if (count($t_arg) > 1) {
$arg_walker[$i] = $t_arg;
$arg = $t_arg[0];
}
}
unset($arg);
$dispData = I2CE_FormStorage::listDisplayFields($this->options['form'], $printf_args, false, $this->options['where'], $this->options['orders'], $this->options['limit']);
if (count($dispData) == 0) {
return;
}
$pageDispNode->setAttribute('id', 'linked_' . $this->options['form'] . '_pager_display');
$pageResultsNode->setAttribute('id', 'linked_' . $this->options['form'] . '_results');
$dispData = $this->paginateList($dispData, array('form' => $this->options['form']), 'linked_' . $this->options['form']);
$this->template->setDisplayDataImmediate('link_title', $this->options['title']);
foreach ($dispData as $id => $r_dispData) {
$dispData = array();
foreach ($printf_args as $i => $arg) {
$dispData[$i] = $r_dispData[$arg];
}
foreach ($arg_walker as $i => $fields) {
$val = $dispData[$i];
$count = 0;
foreach ($fields as $field) {
$count++;
if ($count == 1) {
continue;
}
list($wform, $wid) = array_pad(explode('|', $val, 2), 2, '');
$val = I2CE_FormStorage::lookupField($wform, $wid, array($field), '');
}
$dispData[$i] = $val;
}
$text = @vsprintf($this->options['printf'], $dispData);
//form = person_position
$linkid = $this->options['form'] . '|' . $id;
foreach ($this->options['link_field'] as $lfield) {
list($lform, $lid) = array_pad(explode('|', $linkid, 2), 2, '');
$linkid = I2CE_FormStorage::lookupField($lform, $lid, array($lfield), '');
}
$attrs = array('href' => $this->options['link'] . $linkid);
$tbodyNode->appendChild($trNode = $this->template->createElement('tr', array('colspan' => 2)));
$trNode->appendChild($tdNode = $this->template->createElement('td', array('colspan' => 2)));
$tdNode->appendChild($this->template->createElement('a', $attrs, $text));
}
}
示例7: generateListData
public function generateListData($lang = 'en-US')
{
I2CE_Locales::setPreferredLocale(strtr($lang, '-', '_'));
$display_style = 'default';
I2CE::getConfig()->setIfIsSet($display_style, "/modules/SVS/lists/" . $this->oid . "/meta/display_style");
$code_style = 'code';
I2CE::getConfig()->setIfIsSet($code_style, "/modules/SVS/lists/" . $this->oid . "/meta/code_style");
$code_system_style = false;
I2CE::getConfig()->setIfIsSet($code_system_style, "/modules/SVS/lists/" . $this->oid . "/meta/code_system_style");
$meta = $this->getMeta();
$code_system = $meta['Source'];
I2CE::getConfig()->setIfIsSet($code_system, "/modules/SVS/lists/" . $this->oid . "/meta/code_system");
$where = I2CE::getConfig()->getAsArray("/modules/SVS/lists/" . $this->oid . "/where");
if (!is_array($where)) {
$where = array();
}
$inc_hidden = false;
I2CE::getConfig()->setIfIsSet($inc_hidden, "/modules/SVS/lists/" . $this->oid . "/hidden");
//include hidden
if (!$inc_hidden) {
$nohidden = array('operator' => 'OR', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'i2ce_hidden', 'style' => 'no', 'data' => array()), array('operator' => 'FIELD_LIMIT', 'field' => 'i2ce_hidden', 'style' => 'null', 'data' => array())));
if (count($where) > 0) {
$where = array('operator' => 'AND', 'operand' => array(0 => $where, 1 => $nohidden));
} else {
$where = $nohidden;
}
}
$styles = array('displayName' => $display_style, 'code' => $code_style);
if ($code_system_style) {
$styles['codeSystem'] = $code_system_style;
}
$all_fields = array();
$disp_strings = array();
$disp_fields = array();
foreach ($styles as $out => $style) {
if ($style == 'id') {
continue;
}
$disp_strings[$out] = I2CE_List::getDisplayString($this->list, $style);
$disp_fields[$out] = I2CE_List::getDisplayFields($this->list, $style);
ksort($disp_fields[$out]);
$all_fields = array_merge($all_fields, $disp_fields[$out]);
}
$all_fields = array_unique($all_fields);
$field_data = I2CE_FormStorage::listDisplayFields($this->list, $all_fields, false, $where, array());
$data = array();
foreach ($field_data as $id => $fields) {
$data[$id] = array();
foreach ($styles as $out => $style) {
if ($style == 'id') {
$data[$id][$out] = $id;
} else {
$values = array();
foreach ($disp_fields[$out] as $field) {
if (array_key_exists($field, $fields)) {
$val = $fields[$field];
} else {
$val = '';
}
$values[] = $val;
}
$data[$id][$out] = @vsprintf($disp_strings[$out], $values);
}
}
if (!in_array('codeSystem', $styles)) {
$data[$id]['codeSystem'] = $code_system;
}
}
return $data;
}
示例8: getFormDataJoiningByID_fields
/**
* Get the forms ids for joining on a given field of a named child form's with the named parent form on a given field
* @param string $childFormName the name of the child form in the relationship
* @param string $parentForm
* @param string $parentId
* @param array $joinData The array containg the join data
* @param array $where
* @param array $limit
* @param array $fields keys are relationship formnames, values are array of fields we want returned
* @param array $ordering keys are relationship formnames, values are array of fields we want ordered by
* @return mixed. An array of form ids
*/
public function getFormDataJoiningByID_fields($childFormName, $parentForm, $parentId, $joinData, $where, $limit, $fields, $ordering)
{
if (!is_array($joinData)) {
I2CE::raiseError("Join data specified for parent_form/{$childFormName}");
return array();
}
foreach (array('parent', 'child') as $field) {
if (!array_key_exists($field, $joinData) || !is_string($joinData[$field]) || strlen($joinData[$field]) == 0) {
I2CE::raiseError("Join {$field} field not specified for parent_form/{$childFormName}");
return array();
}
}
$form = $this->getForm($childFormName);
$pfield = $joinData['parent'];
$cfield = $joinData['child'];
$pData = I2CE_FormStorage::lookupField($parentForm, $parentId, array($pField), '');
list($pForm, $pId) = array_pad(explode("|", $pData, 2), 2, '');
//this will give the linked form and id
if (!array_key_exists($childFormName, $fields) || !is_array($fields[$childFormName])) {
$fields[$childFormName] = array();
}
if (!array_key_exists($childFormName, $ordering)) {
$ordering[$childFormName] = array();
}
$sub_where = array('operator' => 'FIELD_LIMIT', 'field' => $cfield, 'style' => 'equals', 'data' => array('value' => $pForm . '|' . $pId));
if (count($where) > 0) {
$where = array('operator' => 'AND', 'operand' => array($sub_where, $where));
} else {
$where = $sub_where;
}
if ($this->use_disp_fields) {
return I2CE_FormStorage::listFields($form, $fields[$childFormName], false, $where, $ordering[$childFormName], $limit, -1, $this->use_cache);
} else {
return I2CE_FormStorage::listDisplayFields($form, $fields[$childFormName], false, $where, $ordering[$childFormName], $limit, -1, $this->use_cache);
}
//return " JOIN $refChildForm AS `$childFormName` ON `$childFormName`.`{$joinData['child']}` = `parent_form`.`{$joinData['parent']}` " ;
}
示例9: action_menu
/**
* Perform menu action
*
* @param array $ids of string
* @returns boolean. true on success
*/
protected function action_menu($ids)
{
reset($ids);
list($form, $junk) = explode('|', current($ids), 2);
$form = trim($form);
$valid = I2CE_Module_PrintedForms::getValidPrintedForms($form);
$mf = I2CE_ModuleFactory::instance();
if (count($valid) == 0 || !$this->hasPermission("task(printed_forms_all_generate)")) {
$this->template->setDisplayDataImmediate('has_valid_forms', 0);
} else {
$archive = $mf->isEnabled('BinField') && $this->hasPermission("task(printed_forms_create_all_archives)");
$this->template->setDisplayDataImmediate('has_valid_forms', 1);
$append_node = $this->template->getElementById('printed_forms_list');
if (!$append_node instanceof DOMNode) {
I2CE::raiseError("Could no find printed_forms_list");
return false;
}
$add_node = $this->template->loadFile('printed_forms_menu_each.html', 'li');
if (!$add_node instanceof DOMElement) {
I2CE::raiseError("Bad 'printed_forms_menu_each.html'");
return true;
} else {
foreach ($valid as $pf => $data) {
$node = $add_node->cloneNode(true);
$this->template->appendNode($node, $append_node);
$link = "PrintedForms/print/{$pf}?" . http_build_query(array('ids' => $ids));
$archive_form = false;
if ($archive && $data['archive']) {
$archive_link = "PrintedForms/archive/{$pf}?" . http_build_query(array('ids' => $ids));
} else {
$archive_link = '';
}
$this->template->setDisplayDataImmediate('standard_form_display_name', $data['displayName'], $node);
$this->template->setDisplayDataImmediate('standard_form_link', $link, $node);
$this->template->setDisplayDataImmediate('standard_form_archive_link', $archive_link, $node);
}
}
}
$archive = $mf->isEnabled('BinField') && $this->hasPermission("task(printed_forms_view_all_archives)");
if (count($ids) != 1 || !$archive || !$this->hasPermission("task(printed_forms_view_all_archives)")) {
$this->template->setDisplayDataImmediate('show_archive', 0);
return true;
}
$this->template->setDisplayDataImmediate('show_archive', 1);
$archives = I2CE_Module_PrintedForms::getValidArchivedForms($form);
reset($ids);
$id = current($ids);
$ff = I2CE_FormFactory::instance();
$docData = I2CE_FormStorage::listDisplayFields('generated_doc', array('date', 'description'), $id, array(), array('date'));
//gets the generated docs which have this id as a parent
$where = array('operator' => 'FIELD_LIMIT', 'field' => 'primary_form', 'style' => 'equals', 'data' => array('value' => $id));
$docDataPrim = I2CE_FormStorage::listDisplayFields('generated_doc', array('date', 'description'), false, $where, array('date'));
//gets the generated docs which have this id as a parent
$docData = $docData + $docDataPrim;
if (count($docData) == 0) {
$this->template->setDisplayData('has_archives', 0);
return true;
}
$this->template->setDisplayData('has_archives', 1);
$append_node = $this->template->getElementById('printed_forms_archive');
if (!$append_node instanceof DOMNode) {
I2CE::raiseError("Could no find printed_forms_archive");
return false;
}
$add_node = $this->template->loadFile('printed_forms_menu_archive_each.html', 'li');
if (!$add_node instanceof DOMElement) {
I2CE::raiseError("Bad 'printed_forms_menu_archive each.html'");
return true;
}
foreach ($docData as $id => $data) {
$node = $add_node->cloneNode(true);
$this->template->appendNode($node, $append_node);
$link = I2CE_FormField_BINARY_FILE::getFieldLink("generated_doc|" . $id, 'document');
$this->template->setDisplayDataImmediate('view_archive_link', $link, $node);
$this->template->setDisplayData('gen_date', $data['date'], $node);
$this->template->setDisplayData('gen_desc', $data['description'], $node);
}
return true;
}
示例10: show_linked
protected function show_linked($obj, $data, $node)
{
$task = false;
if (!array_key_exists('task', $data) && I2CE_PermissionParser::taskExists($task)) {
$data['task'] = $task;
}
if ($task && I2CE_PermissionParser::taskExists($task) && !$this->hasPermission("task({$task})", $containerNode)) {
return;
}
$ff = I2CE_FormFactory::instance();
if (!is_array($data) || !array_key_exists('form', $data) || !($form = $data['form']) || !($formObj = $ff->createContainer($form)) instanceof I2CE_Form) {
return false;
}
$printf = false;
$printf_args = array();
$orders = null;
$link = false;
$mapped_field = $obj->getName();
if ($formObj instanceof I2CE_List) {
$style = 'default';
if (array_key_exists('style', $data) && is_scalar($data['style']) && $data['style']) {
$style = $data['style'];
}
$printf_args = I2CE_List::getDisplayFields($form, $style);
$printf = I2CE_List::getDisplayString($form, $style);
$orders = I2CE_List::getSortFields($form);
$link = "auto_list?form={$form}&id=";
}
if (array_key_exists('link', $data) && is_scalar($data['link']) && $data['link']) {
$link = $data['link'];
}
if (array_key_exists('field', $data) && is_scalar($data['field']) && $data['field']) {
$mapped_field = $data['field'];
}
if (array_key_exists('orders', $data)) {
$orders = $data['orders'];
}
if (array_key_exists('printf', $data) && is_scalar($data['printf']) && $data['printf']) {
$printf = $data['printf'];
}
if (array_key_exists('printf_args', $data) && is_array($data['printf_args']) && count($data['printf_args']) > 0) {
$printf_args = $data['printf_args'];
}
$link_field = array();
if (array_key_exists('link_field', $data) && is_scalar($data['link_field']) && $data['link_field']) {
$link_field = explode(':', $data['link_field']);
}
if (!$printf || count($printf_args) == 0 || !$link) {
return;
}
$where = array('operator' => 'FIELD_LIMIT', 'field' => $mapped_field, 'style' => 'equals', 'data' => array('value' => $obj->getNameId()));
if (array_key_exists('where', $data) && is_array($data['where'])) {
$where = array('operator' => 'AND', 'operand' => array(0 => $data['where'], 1 => $where));
}
$limit = false;
if (array_key_exists('limit', $data)) {
$limit = $data['limit'];
}
$title = $formObj->getDisplayName();
if (array_key_exists('title', $data) && is_scalar($data['title']) && $data['title']) {
$title = $data['title'];
}
$arg_walker = array();
foreach ($printf_args as $i => &$arg) {
$t_arg = explode(":", $arg);
if (count($t_arg) > 1) {
$arg_walker[$i] = $t_arg;
$arg = $t_arg[0];
}
}
unset($arg);
if (count($dispDatas = I2CE_FormStorage::listDisplayFields($form, $printf_args, false, $where, $orders, $limit)) == 0) {
return false;
}
$linkedNode = $this->template->appendFileByNode('auto_view_linked.html', 'div', $node);
if (($pageDispNode = $this->template->getElementByName('pager_display', 0, $linkedNode)) instanceof DOMNode && ($pageResultsNode = $this->template->getElementByName('pager_results', 0, $linkedNode)) instanceof DOMNode) {
$pageDispNode->setAttribute('id', 'linked_' . $form . '_pager_display');
$pageResultsNode->setAttribute('id', 'linked_' . $form . '_results');
if (!($dispDatas = $this->paginateList($dispDatas, 'linked_' . $form))) {
return false;
}
}
$this->template->setDisplayDataImmediate('link_title', $title);
if (!($tbodyNode = $this->template->getElementByName('link_fields', 0, $node)) instanceof DOMNode) {
return false;
}
foreach ($dispDatas as $id => $r_dispData) {
$dispData = array();
foreach ($printf_args as $i => $arg) {
$dispData[$i] = $r_dispData[$arg];
}
foreach ($arg_walker as $i => $fields) {
$val = $dispData[$i];
$count = 0;
foreach ($fields as $field) {
$count++;
if ($count == 1) {
continue;
}
list($wform, $wid) = array_pad(explode('|', $val, 2), 2, '');
//.........这里部分代码省略.........
示例11: buildDataTree
//.........这里部分代码省略.........
//indexed by "$form|$id" with values (by reference) the arrays at which contains the 'children' sub-array for $form|$id node
$parent_links = array();
//indexed by "$form|$id" with values "$pform|$pid" which is the form/id that "$form|$id" is linked against
$display_string = array();
foreach ($fields as $formfield) {
list($form, $link_field) = $formfield;
if (array_key_exists("{$form}+{$link_field}", $limits)) {
$limit = $limits["{$form}+{$link_field}"];
} elseif (array_key_exists($form, $limits)) {
$limit = $limits[$form];
} else {
$limit = array();
}
//if we dont show the hidden list memmber we need to include the limit where i2ce_disabled is false
$limit = self::showHiddenLimit($limit, $show_hidden);
$disp_fields = I2CE_List::getDisplayFields($form);
//start0: $form = country, $fields = (name)
//next0: $form = cssc_region, $fields = (name, cssc_country)
//next0: $form = district $fields = (name, cssc_region)
//next0: $form = county $field = (name,distrcit)
//end0: $form = villate $field = (name,county)
//start1: $form = country, $fields = (name)
//next1: $form = region, $fields = (name, country)
//next1: $form = district $fields = (name, region)
//etc.
if (array_key_exists($form, $orders)) {
$order = $orders[$form];
} else {
$order = I2CE_List::getSortFields($form);
}
if ($link_field) {
$field_datas = I2CE_FormStorage::listFields($form, $link_field, false, $limit, $order, false, -1, $use_cache);
} else {
$field_datas = I2CE_FormStorage::listFields($form, 'id', false, $limit, $order, false, -1, $use_cache);
}
$display_datas = I2CE_FormStorage::listDisplayFields($form, $disp_fields, false, $limit, $order, false, -1, $use_cache);
$link_id = false;
$last_link = false;
$selectable = in_array($form, $forms);
foreach ($field_datas as $id => $field_data) {
$formid = $form . '|' . $id;
if (!$link_field) {
//this should only be the case for the top form
$parent =& $data;
} else {
//we are not at the top.
$link = $field_data[$link_field];
unset($field_data[$link_field]);
if ($last_link != $link) {
if (!array_key_exists($link, $phonebook)) {
//don't know where to put this as a child of the previous one so skip it
continue;
}
$last_link = $link;
if (!array_key_exists('children', $phonebook[$link])) {
$phonebook[$link]['children'] = array();
}
$parent =& $phonebook[$link]['children'];
//example: $diplayed == array(country=>true, region=>false, district=>true, county=>true village => true)
//we have $form = district, $formid = district|30, $parent_link= region|40
end($displayed);
$disp_form = key($displayed);
while ($disp_form !== false && $disp_form !== $form) {
prev($displayed);
$disp_form = key($displayed);
}
//we end here either before the beginning of the array or where $disp_form == $form.
prev($displayed);
//we are now at the one before the $form. if the current form was district, we are now at region
$parent_link = $link;
} else {
if (!array_key_exists($link, $phonebook) || !$phonebook[$link]) {
//don't know where to put this as a child of the previous one so skip it
continue;
}
}
$parent_links[$formid] = $link;
}
//we know where to add this node. now lets add it
//$display = implode(' ', $field_data);
if (!array_key_exists($id, $display_datas)) {
continue;
}
if (!array_key_exists($form, $display_string)) {
$display_string[$form] = I2CE_List::getDisplayString($form);
}
$display = vsprintf($display_string[$form], $display_datas[$id]);
//$display = implode(' ', $display_datas[$id]);
$child_data = array('display' => $display, 'show' => $displayed[$form]);
if ($selectable) {
$child_data['value'] = $formid;
}
$parent[] = $child_data;
end($parent);
$phonebook[$formid] =& $parent[key($parent)];
}
}
self::removeNotShownNodes($data);
return $data;
}