本文整理汇总了PHP中I2CE::raiseMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE::raiseMessage方法的具体用法?PHP I2CE::raiseMessage怎么用?PHP I2CE::raiseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE
的用法示例。
在下文中一共展示了I2CE::raiseMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Check for duplicates and save the user alert
* @param I2CE_User $user
* @param boolean $transact
* @return boolean
*/
public function save($user, $transact = true)
{
if ($this->getId() === '0') {
$find_duplicates = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'message', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->message))), array('operator' => 'FIELD_LIMIT', 'field' => 'time_ack', 'style' => 'null'), array('operator' => 'FIELD_LIMIT', 'field' => 'alert_type', 'style' => 'equals', 'data' => array('value' => $this->alert_type))));
if ($this->link == '') {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'null');
} else {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'equals', 'data' => array('value' => $this->link));
}
if ($this->link_text == '') {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'null');
} else {
$find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->link_text)));
}
$found = I2CE_FormStorage::search('user_alert', $this->getParent(), $find_duplicates, array("-time_sent"), 1);
if ($found) {
I2CE::raiseMessage("found duplicates so increasing repeats. {$found}");
$duplicate = I2CE_FormFactory::instance()->createContainer("user_alert|" . $found);
$duplicate->populate();
$duplicate->repeated++;
return $duplicate->save($user, $transact);
}
}
return parent::save($user, $transact);
}
示例2: _generateCache
protected function _generateCache()
{
if (!($last_tmp_table = $this->setupQueries())) {
I2CE::raiseError("Could not process form tree for report {$this->report}");
return false;
}
$counter = count($this->populate_queries);
$md5_key = 'no_md5';
foreach ($this->populate_queries[$counter] as &$query) {
if (is_array($query)) {
$query = $query[$md5_key];
}
}
unset($query);
if (array_key_exists('update_set_md5', $this->populate_queries[$counter])) {
unset($this->populate_queries[$counter]['update_set_md5']);
}
$replace = false;
while ($counter && array_key_exists($counter, $this->populate_queries)) {
if ($counter > 1) {
$md5_key = 'no_md5';
if (array_key_exists('insert_limit', $this->populate_queries[$counter]) || array_key_exists('insert_nolimit', $this->populate_queries[$counter])) {
$md5_key = 'md5';
} else {
if (array_key_exists('update_set_md5', $this->populate_queries[$counter - 1])) {
unset($this->populate_queries[$counter - 1]['update_set_md5']);
}
}
foreach ($this->populate_queries[$counter - 1] as &$query) {
if (is_array($query)) {
$query = $query[$md5_key];
}
}
unset($query);
if (array_key_exists('update', $this->populate_queries[$counter])) {
$this->populate_queries[$counter - 1]['create'] = $this->populate_queries[$counter]['create'];
$this->populate_queries[$counter - 1]['drop'] = $this->populate_queries[$counter]['drop'];
//$this->populate_queries[$counter-1]['drop_prev'] = $this->populate_queries[$counter]['drop_prev'];
unset($this->populate_queries[$counter]['create']);
unset($this->populate_queries[$counter]['drop']);
unset($this->populate_queries[$counter]['insert_copy']);
//unset( $this->populate_queries[$counter]['drop_prev'] );
if (!$replace) {
$replace = '[' . $counter . ']`';
}
$find = '[' . ($counter - 1) . ']`';
foreach ($this->populate_queries[$counter - 1] as $type => &$query) {
if ($type != 'drop_prev') {
$query = str_replace($find, $replace, $query);
}
}
unset($query);
} else {
$replace = false;
}
}
$counter--;
}
foreach ($this->populate_queries as $qry_list) {
foreach ($qry_list as $type => $qry) {
/*
if ( $type == 'drop_prev' ) {
I2CE::raiseMessage( "Skipping $qry" );
continue;
}
*/
I2CE::raiseError("Doing {$type}: {$qry}");
$start_time = time();
$res = $this->db->exec($qry);
$end_time = time();
if (I2CE::pearError($res, "Unable to populate cached report")) {
return false;
}
if (substr(ltrim($qry), 0, 6) == 'INSERT' || substr(ltrim($qry), 0, 6) == 'UPDATE') {
I2CE::raiseMessage("Inserted {$res} rows");
}
I2CE::raiseMessage("Query took " . ($end_time - $start_time) . " seconds.");
}
}
// we move over the tmp_table to table.
if (!$this->dropTable(false)) {
return false;
}
if (I2CE::pearError($this->db->exec("RENAME TABLE {$last_tmp_table} TO {$this->table}"), "Could not rename temp table")) {
return false;
}
return true;
}
示例3: import
protected function import($file, $ignore_ids = false)
{
$reader = new XMLReader();
$reader->open($file, null, 1 << 19);
$save_ids = array();
$count = 0;
$exec = array('max_execution_time' => 20 * 60, 'memory_limit' => 256 * 1048576);
$importer = new I2CE_FormRelationship_Importer();
if (array_key_exists('HTTP_HOST', $_SERVER)) {
$importer->setMessageCallback(array($this, 'pushMessage'));
}
$defaults = array('ignoreids' => $ignore_ids ? '1' : '0', 'nomatching' => '', 'invalid' => '');
$next = false;
while ($next || $reader->read()) {
$next = false;
if ($reader->nodeType != XMLReader::ELEMENT) {
continue;
}
switch ($reader->name) {
case 'relationshipCollection':
foreach ($defaults as $key => $val) {
if (($v = $reader->getAttribute($key)) !== null) {
$defaults[$key] = $v;
}
}
while ($reader->read()) {
//skip to a relationship sub-element
if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'relationship') {
break;
}
}
//break; - purposefully do not break as we want to get process any relationship under a relationshipCollection
//break; - purposefully do not break as we want to get process any relationship under a relationshipCollection
case 'relationship':
I2CE::longExecution($exec);
$node = $reader->expand();
$doc = new DOMDocument();
$i_node = $doc->importNode($node, true);
foreach ($defaults as $k => $v) {
$i_node->setAttribute($k, $v);
}
$new_ids = $importer->loadFromXML($i_node);
$save_ids = array_merge($save_ids, $new_ids);
if (array_key_exists('HTTP_HOST', $_SERVER) && count($new_ids) > 0) {
$this->pushMessage("Imported records with ids:\n" . implode(",", $new_ids));
}
$count++;
$reader->next();
$next = true;
break;
default:
if (array_key_exists('HTTP_HOST', $_SERVER)) {
$this->pushError("Unrecognized data type: " . $reader->name);
}
break;
}
}
$summary = "Import Summary: (processed {$count} relationships)\n";
foreach ($save_ids as $save_id => $msg) {
$summary .= str_replace("\n", "\n - ", $msg) . "\n";
}
I2CE::raiseMessage($summary);
$this->pushMessage($summary);
return true;
}
示例4: _readRow
/**
* read the entire row and parse for data
* @param string $row. If not an excel worksheet row, issue a message and return false
* @returns array
*/
protected function _readRow($row)
{
if (!$row instanceof PHPExcel_Worksheet_Row) {
I2CE::raiseMessage("Invalid row object" . get_class($row));
return false;
}
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$data = array();
foreach ($cellIterator as $cell) {
$data[] = $cell->getValue();
}
return $data;
}
示例5: action
/**
* Perform the main actions of the page.
* @return boolean
*/
protected function action()
{
if (!parent::action()) {
return false;
}
if (!$this->hasPermission("role(admin)")) {
$this->userMessage("You do not have permission to view this page.");
return false;
}
$pos_mech = I2CE_FormStorage::getStorageMechanism("position");
$pers_pos_mech = I2CE_FormStorage::getStorageMechanism("person_position");
if (!$pos_mech instanceof I2CE_FormStorage_entry || !$pers_pos_mech instanceof I2CE_FormStorage_entry) {
I2CE::raiseMessage("Invalid storage type for position and person position forms. " . get_class($pos_mech) . get_class($pers_pos_mech));
$this->template->addFile("mass_delete_by_search_error_invalid.html");
return true;
}
$people = $this->post('people');
if (!is_array($people) || count($people) < 1) {
$this->template->addFile("mass_delete_by_search_empty.html");
} else {
$step = 'choose';
if ($this->post_exists('step')) {
$step = $this->post('step');
}
if ($step == "delete") {
if ($this->post('yes') != 'yes') {
$this->template->appendFileById("mass_delete_by_search_error_yes.html", "p", "error");
$step = "confirm";
}
$userAccess = new I2CE_UserAccess_Mechanism();
if (!$this->post_exists('admin_pass') || !$userAccess->userHasPassword('i2ce_admin', $this->post('admin_pass'))) {
$this->template->appendFileById("mass_delete_by_search_error_password.html", "p", "error");
$step = "confirm";
}
}
switch ($step) {
case "choose":
$this->template->addFile("mass_delete_by_search_form.html");
$msgNode = $this->template->addFile("mass_delete_by_search_confirm_message.html");
foreach ($people as $person) {
$persObj = I2CE_FormFactory::instance()->createContainer($person);
$persObj->populate();
$persNode = $this->template->appendFileById("mass_delete_by_search_each.html", "li", "search_list");
$this->template->setDisplayDataImmediate("people[]", array('value' => $person, 'id' => "check_{$person}"), $persNode);
$this->template->setDisplayDataImmediate("person_name", $persObj->surname . ', ' . $persObj->firstname, $persNode);
$label = $this->template->query("label[@name='search_label']", $persNode);
if ($label->length == 1) {
$label->item(0)->setAttribute("for", "check_{$person}");
}
}
break;
case "confirm":
$list = $this->getDeleteList($people);
if ($list === null) {
$this->template->addFile("mass_delete_by_search_error_notfound.html");
} elseif (count($list) < 1) {
I2CE::raiseMessage("Invalid return data from getDeleteList!");
$this->template->addFile("mass_delete_by_search_error_unkonwn.html");
} else {
$formNode = $this->template->addFile("mass_delete_by_search_form.html");
$this->template->setDisplayDataImmediate("step", "delete");
$addNode = $this->template->addFile("mass_delete_by_search_authenticate_form.html");
$would_delete = I2CE_FormStorage_entry::massDelete($list, array());
$msgNode = $this->template->addFile("mass_delete_by_search_delete_count.html");
$this->template->setDisplayDataImmediate("delete_count", $would_delete, $msgNode);
foreach ($people as $person) {
$persObj = I2CE_FormFactory::instance()->createContainer($person);
$persObj->populate();
$persNode = $this->template->appendFileById("mass_delete_by_search_each_final.html", "li", "search_list");
$this->template->setDisplayDataImmediate("people[]", $person, $persNode);
$this->template->setDisplayDataImmediate("person_name", $persObj->surname . ', ' . $persObj->firstname, $persNode);
}
}
break;
case "delete":
$list = $this->getDeleteList($people);
if ($list === null) {
$this->template->addFile("mass_delete_by_search_error_notfound.html");
} elseif (count($list) < 1) {
I2CE::raiseMessage("Invalid return data from getDeleteList!");
$this->template->addFile("mass_delete_by_search_error_unkonwn.html");
} else {
$formNode = $this->template->addFile("mass_delete_by_search_form.html");
$this->template->setDisplayDataImmediate("step", "delete");
$addNode = $this->template->addFile("mass_delete_by_search_authenticate_form.html");
I2CE_ModuleFactory::callHooks("pre_mass_delete_person", $people, $this->post());
if (($deleted = I2CE_FormStorage_entry::massDelete($list, array(), false)) !== false) {
$node = $this->template->addFile("mass_delete_by_search_success.html");
$this->template->setDisplayDataImmediate("delete_count", $deleted, $node);
if (I2CE_ModuleFactory::instance()->isEnabled("CachedForms")) {
$forms = I2CE_FormFactory::instance()->getNames();
$success = array();
$failure = array();
foreach ($forms as $form) {
try {
$cachedForm = new I2CE_CachedForm($form);
//.........这里部分代码省略.........
示例6: export_results
protected function export_results()
{
if (!($flow = $this->request('flow'))) {
I2CE::raiseError("Bad flow");
$this->error("Invalid Flow");
return false;
}
$this->instantiateDisplay('Default', $this->view);
if (!$this->display_obj instanceof I2CE_CustomReport_Display_mHero) {
I2CE::raiseError("Bad display");
$this->error("Invalid Display");
return false;
}
I2CE::longExecution();
$titles = $this->get_display_field_titles();
I2CE::raiseError("TITLES=" . print_r($titles, true));
$labels = $this->rapidpro->get_flow_field_labels($flow);
$headers = array();
if (array_key_exists('HTTP_USER_AGENT', $_SERVER) && preg_match('/\\s+MSIE\\s+\\d\\.\\d;/', $_SERVER['HTTP_USER_AGENT'])) {
$headers[] = "application/vnd.ms-excel";
} else {
$headers[] = "text/csv; charset=UTF-8";
}
$filename = 'mHero-' . '-' . $this->slug . '-export-' . date('Y') . '-' . date('m') . '-' . date('d') . '.csv';
$headers[] = "Content-disposition: attachment; filename=\"{$filename}\"";
$out = fopen("php://output", 'w');
$keys = array('entityID' => 'Health Worker Registry Entity ID', 'iHRIS_link' => 'iHRIS Source Record');
$keys = array_merge($keys, $labels);
$keys = array_merge($keys, $titles);
I2CE::raiseError("KEYS=" . print_r($keys, true));
$csd_uuids = $this->display_obj->get_csd_uuids();
$person_ids = array_flip($csd_uuids);
$assigning_authority = $this->host . '/' . $this->slug;
$contacts = $this->rapidpro->getOtherIDs($this->csd_host, $csd_uuids, $assigning_authority);
$contact_list = array();
foreach ($contacts as $entityID => $contact) {
if (!is_array($contact) || !array_key_exists('otherID', $contact) || !is_array($contact['otherID']) || count($contact['otherID']) != 1 || !reset($contact['otherID']) || !is_array($otherID = current($contact['otherID'])) || !array_key_exists('value', $otherID) || !($rapidpro_id = $otherID['value'])) {
continue;
}
$contact_list[$rapidpro_id] = $entityID;
}
I2CE::raiseError(print_r($contacts, true));
I2CE::raiseError(print_r($contact_list, true));
$runs = $this->rapidpro->getFlowValues($flow);
//would be better if we could put the streaming function as a callback after each hit on rapidpro
$results = array();
foreach ($runs as $run) {
I2CE::raiseMessage($run['contact']);
if (!is_array($run) || !array_key_exists('contact', $run) || !($rapidpro_id = $run['contact']) || !array_key_exists($rapidpro_id, $contact_list) || !($entityID = $contact_list[$rapidpro_id]) || !array_key_exists('values', $run) || !is_array($run['values'])) {
continue;
}
$values = array();
foreach ($run['values'] as $val_set) {
if (!is_array($val_set) || !array_key_exists('label', $val_set) || !($label = $val_set['label']) || !array_key_exists('text', $val_set)) {
continue;
}
$values[$label] = $val_set['text'];
}
$results[$entityID] = $values;
}
I2CE::raiseError(print_r($results, true));
if ($errors = I2CE_Dumper::cleanlyEndOutputBuffers()) {
I2CE::raiseError("Got errors:\n{$errors}");
}
I2CE::longExecution();
foreach ($headers as $header) {
header($header);
}
fputcsv($out, $keys);
foreach ($results as $entityID => $values) {
if (!array_key_exists($entityID, $person_ids) || !($person_id = $person_ids[$entityID])) {
continue;
}
$iHRIS_link = I2CE::getAccessedBaseURL() . 'view?id=' . $person_id;
$fields = array('entityID' => $entityID, 'iHRIS_link' => $iHRIS_link);
foreach ($labels as $label) {
if (!array_key_exists($label, $values)) {
$fields[] = '';
} else {
$fields[] = $values[$label];
}
}
$fields = array_merge($fields, $this->get_display_fields($person_id));
foreach ($titles as $title => $label) {
if (!array_key_exists($title, $fields) || !is_scalar($val = $fields[$title])) {
$fields[$title] = '';
} else {
$fields[$title] = $val;
}
}
fputcsv($out, $fields);
flush();
}
fclose($out);
exit(0);
}
示例7: action
/**
* Perform the action for this page.
*/
protected function action()
{
if ($this->get_exists('delete') && $this->get('delete') == 1) {
$parent_id = $this->getPrimary()->getParent();
$form_id = $this->getPrimary()->getNameId();
$child_forms = $this->getPrimary()->getChildForms();
if (count($child_forms) > 0) {
I2CE::raiseMessage("Tried to delete a child form {$form_id} when there are possible child forms.");
$message = "This form can not be deleted.";
I2CE::getConfig()->setIfIsSet($message, "/modules/forms/page_feedback_messages/person_child_delete_not_allowed");
} else {
$allowable = false;
I2CE::getConfig()->setIfIsSet($allowable, "/modules/Person/deleteable_children/" . $this->form_name);
I2CE::raiseMessage("deleting {$form_id} under {$parent_id} requested by user " . $this->getUser()->getId());
if ($allowable) {
if ($this->checkActionPermission('delete')) {
if ($this->getPrimary()->delete()) {
$message = "The requested form has been deleted.";
I2CE::getConfig()->setIfIsSet($message, "/modules/forms/page_feedback_messages/person_child_delete_success");
} else {
$message = "An error occurred deleting this form.";
I2CE::getConfig()->setIfIsSet($message, "/modules/forms/page_feedback_messages/person_child_delete_fail");
}
} else {
$message = "You do not have permission to delete this form.";
I2CE::getConfig()->setIfIsSet($message, "/modules/forms/page_feedback_messages/person_child_delete_not_permitted");
}
} else {
$message = "This form can not be deleted.";
I2CE::getConfig()->setIfIsSet($message, "/modules/forms/page_feedback_messages/person_child_delete_not_allowed");
}
}
$this->userMessage($message);
$this->setRedirect("view?id=" . $parent_id);
return true;
}
return parent::action();
}
示例8: loadHTMLTemplates
protected function loadHTMLTemplates()
{
parent::loadHTMLTemplates();
/* need to set new_person_position and then person here to make sure defaults are OK.
Otherwise need form_person_base.html and button_confirm.html to be different */
$this->template->setForm($this->new_person_position);
$this->template->setForm($this->person);
$forms = array('current_person_position' => $this->new_person_position, 'current_person_position' => $this->current_person_position, 'new_position' => $this->new_position, 'current_position' => $this->current_position, 'new_salary' => $this->new_salary, 'current_salary' => $this->current_salary);
foreach ($forms as $class => $form) {
if (!$form instanceof I2CE_Form) {
I2CE::raiseMessage("{$class} isn't available");
continue;
}
foreach ($this->template->query("//*[@class='form:{$class}']") as $node) {
$this->template->setForm($form, $node);
}
}
foreach (array('id', 'parent') as $key) {
if ($this->request_exists($key) && $this->request($key)) {
$this->template->setDisplayData($key, $this->request($key));
}
}
}
示例9: validate_formfield
/**
* Hooked Function to check if a field is unique or unique restricted to a certain field
* @param I2CE_FormField $field_obj
* @returns boolean
*/
public function validate_formfield($field_obj)
{
if (!$field_obj->hasOption('unique') || !$field_obj->getOption('unique') || !$field_obj->isValid() || !$field_obj->issetValue() || $field_obj->getDBValue() == "") {
return;
}
$where = array('operator' => 'FIELD_LIMIT', 'style' => 'equals', 'field' => $field_obj->getName(), 'data' => array('value' => $field_obj->getDBValue()));
$form_obj = $field_obj->getContainer();
if (!$form_obj instanceof I2CE_Form) {
I2CE::raiseError(get_class($form_obj));
return;
}
$names = array();
$search_parent = false;
if ($field_obj->hasOption('unique_field')) {
$unique = $field_obj->getOption('unique_field');
if (strpos($unique, ':') !== false) {
//the value is a mapped thing. this is handled by hooked mehtod defined in I2CE_Module_List
return;
}
$unique_fields = explode(',', $unique);
$unique_where = array($where);
foreach ($unique_fields as $unique_field) {
if ($unique_field == "parent") {
$search_parent = $form_obj->getParent();
if ($search_parent == "") {
// If there is no parent then we can't validate
// by parent so ignore this
return;
}
continue;
}
if (!($unique_field_obj = $form_obj->getField($unique_field)) instanceof I2CE_FormField) {
I2CE::raiseError("Invalid field {$unique_field}");
return;
}
if ($unique_field_obj->hasHeader('default')) {
$names[] = $unique_field_obj->getHeader('default');
} else {
$names[] = $unique_field_obj->getName();
}
if ($unique_field_obj->isValid()) {
$unique_where[] = array('operator' => 'FIELD_LIMIT', 'style' => 'equals', 'field' => $unique_field_obj->getName(), 'data' => array('value' => $unique_field_obj->getDBValue()));
} else {
$unique_where[] = array('operator' => 'OR', 'operand' => array(0 => array('operator' => 'FIELD_LIMIT', 'style' => 'equals', 'field' => $unique_field_obj->getName(), 'data' => array('value' => $unique_field_obj->getDBValue())), 1 => array('operator' => 'FIELD_LIMIT', 'style' => 'null', 'field' => $unique_field_obj->getName())));
}
}
if (count($unique_where) > 1) {
//we added somehitng
$where = array('operator' => 'AND', 'operand' => $unique_where);
}
}
$found = I2CE_FormStorage::search($form_obj->getName(), $search_parent, $where, array(), 1);
if ($found !== false && '' . $found != '' . $form_obj->getId()) {
I2CE::raiseMessage("found is {$found} and id is " . $form_obj->getId() . " and names are " . print_r($names, true));
if (count($names) > 1) {
$field_obj->setInvalidMessage('unique_fields', null, ' ' . implode(', ', $names));
//$field_obj->setInvalid("This must be unique and another record has this value for the given value of the fields " .implode(',',$names) );
} else {
if (count($names) == 1) {
$field_obj->setInvalidMessage('unique_field', null, ' ' . implode(', ', $names));
//$field_obj->setInvalid("This must be unique and another record has this value for the given value of the field " .implode(',',$names) );
} else {
$field_obj->setInvalidMessage('unique');
//$field_obj->setInvalid("This must be unique and another record has this value." );
}
}
}
}
示例10: set_uuid_on_form
public static function set_uuid_on_form($form, $field = 'csd_uuid')
{
if (!$form instanceof I2CE_Form) {
I2CE::raiseError("Bad form");
return;
}
if ($form->getID() == '0' || $form->getID() == '') {
return;
}
if (!($field_obj = $form->getField($field)) instanceof I2CE_FormField) {
I2CE::raiseError("{$field} does not exist on " . $form->getNameID());
return;
}
if (!($field_obj->getDBValue() == '')) {
return;
}
if ($id = self::generate_uuid($form)) {
I2CE::raiseMessage("Setting csd uuid for " . $form->getNameID());
$field_obj->setFromDB($id);
}
}
示例11: generateExport
/**
* Generate the the exported report
* @returns string
*/
public function generateExport()
{
I2CE::longExecution(array("max_execution_time" => 1800));
$style = $this->getStyle();
$formfields = $this->getDisplayFieldsData();
$headers = array('#');
foreach ($formfields as $formfield => $data) {
if (!$data) {
continue;
}
$headers[$formfield] = $data['header'];
}
I2CE::raiseMessage($style);
$this->cols = array_keys($headers);
switch ($style) {
case 'xml':
$post = " </reportData>\n</ihrisReport>\n";
array_shift($this->cols);
$pre = $this->getXMLMetaData($headers);
break;
case 'xls_2004_xml':
$post = " </Table>\n <WorksheetOptions xmlns='urn:schemas-microsoft-com:office:excel'>\n <PageLayoutZoom>0</PageLayoutZoom>\n <Selected/>\n <Panes>\n <Pane>\n <Number>3</Number>\n <ActiveRow>1</ActiveRow>\n </Pane>\n </Panes>\n <ProtectObjects>False</ProtectObjects>\n <ProtectScenarios>False</ProtectScenarios>\n </WorksheetOptions>\n </Worksheet>\n</Workbook>\n";
$pre = $this->get_XLS_2004_XML_MetaData($headers);
break;
case 'tab':
$post = '';
$pre = "" . $this->processResultRowArray($headers);
break;
case 'csvxls':
$post = '';
$pre = "" . $this->processResultRowArray($headers);
break;
case 'rawjson':
$post = '}';
unset($headers[0]);
$pre = '{"headers":' . json_encode($headers) . ',"data":';
break;
case 'json':
$post = ']';
unset($headers[0]);
$pre = '[' . json_encode(array_values($headers));
break;
default:
//html snippet
$name = addslashes(str_replace(array(' ', "\n", "\t"), array('_', ' ', '_'), $this->config->display_name));
$pre = "<table id='" . addslashes($this->view) . " name='{$name}'>\n";
$post = '</table>';
$pre .= $this->processResultRowArray($headers);
break;
}
$data = $this->getResults();
$out = $this->processResults($data, $resultsNode = null);
$out = $pre . $out . $post;
if ($style == 'xml' && $this->transform) {
$xmlDoc = new DOMDocument();
if (!@$xmlDoc->loadXML($out)) {
I2CE::raiseError("Could not load source document");
return $out;
}
$xslDoc = new DOMDocument();
if (!array_key_exists('xslts', $this->defaultOptions) || !is_array($this->defaultOptions['xslts']) || !@$xslDoc->loadXML($this->defaultOptions['xslts'][$this->transform]['definition'])) {
I2CE::raiseError("Could not load transform");
return false;
}
$proc = new XSLTProcessor();
if (!@$proc->importStylesheet($xslDoc)) {
I2CE::raiseError("Could not import style sheet");
return false;
}
if (($out = @$proc->transformToXML($xmlDoc)) === false) {
I2CE::raiseError("Could not transform accoring to xsl");
return false;
}
}
switch ($this->compression) {
case 'bz2':
return bzcompress($out);
case 'gz':
return gzencode($out, 9);
case 'zip':
if (!@class_exists('ZipArchive', false)) {
I2CE::raiseError("zip not present");
$this->compression = false;
break;
}
$zip = new ZipArchive();
$temp_file = tempnam(sys_get_temp_dir(), 'EXPORT_ZIP');
if ($zip->open($temp_file) !== true) {
I2CE::raiseError("Could not ceaete zip on {$temp_file}");
$this->compression = false;
break;
}
$filename = $this->getFileName(null, false);
$zip->addFromString($filename, $out);
$zip->close();
$out = file_get_contents($temp_file);
//.........这里部分代码省略.........
示例12: setupEntryHistory
/**
* Return the entry history for this person as an array
* @param integer $userid The user id
* @param string $username The user name
* @param integer $days The number of days to include
* @return array
*/
protected static function setupEntryHistory($userid, $username, $days = 5)
{
if (!is_array(self::$entries)) {
self::$entries = array();
}
if (array_key_exists($userid, self::$entries)) {
return self::$entries[$userid];
} else {
self::$entries[$userid] = array('has_person' => false, 'has_forms' => false, 'dates' => array());
if (!self::setupDB()) {
return false;
}
$result = self::$prepared['entry_history']->execute(array($username, $days - 1, $username, $username));
if (I2CE::pearError($result, "Error getting entry history: ")) {
unset(self::$entries[$userid]);
return false;
}
$records = array();
$tally = array();
$forms = array();
$person = array();
$parents = array();
while ($row = $result->fetchRow()) {
$tally[$row->date][] = $row->record;
$records[$row->record] = 1;
$forms[$row->record] = $row->form;
if ($row->parent_id == '0|0') {
continue;
}
list($pform, $pid) = explode('|', $row->parent_id);
if ($pform == 'person') {
$person[$row->record] = $pid;
} else {
if (!array_key_exists($pid, $parents)) {
$parents[$pid] = array();
}
$parents[$pid][] = $row->record;
}
}
$result->free();
if (count($records) == 0) {
return true;
}
$loop_check = 0;
while (count($parents) > 0) {
if ($loop_check++ > 50) {
I2CE::raiseError("Too many loops for the entry history for {$userid} ({$days} days)");
return false;
}
$parent_query = "SELECT id,parent_form,parent_id FROM record WHERE id IN ( " . implode(',', array_keys($parents)) . " )";
$result = self::$db->query($parent_query);
if ($result->numRows() == 0) {
$parents = array();
} else {
while ($row = $result->fetchRow()) {
if (!$row->parent_form || !$row->parent_id) {
unset($parents[$row->id]);
continue;
}
if ($row->parent_form == 'person') {
foreach ($parents[$row->id] as $record) {
$person[$record] = $row->parent_id;
}
unset($parents[$row->id]);
} else {
if (!array_key_exists($row->parent_id, $parents)) {
$parents[$row->parent_id] = array();
}
foreach ($parents[$row->id] as $record) {
$parents[$row->parent_id][] = $record;
}
unset($parents[$row->id]);
}
}
}
}
foreach ($tally as $date => $records) {
if (!array_key_exists($date, self::$entries[$userid]['dates'])) {
self::$entries[$userid]['dates'][$date] = array('forms' => array(), 'person' => array());
}
foreach ($records as $record) {
if (!array_key_exists($record, $forms)) {
I2CE::raiseMessage("{$record} not in forms array.");
continue;
}
if (!array_key_exists($forms[$record], self::$entries[$userid]['dates'][$date]['forms'])) {
self::$entries[$userid]['dates'][$date]['forms'][$forms[$record]] = 0;
}
self::$entries[$userid]['has_forms'] = true;
self::$entries[$userid]['dates'][$date]['forms'][$forms[$record]]++;
if (array_key_exists($record, $person)) {
if (!array_key_exists($person[$record], self::$entries[$userid]['dates'][$date]['person'])) {
self::$entries[$userid]['dates'][$date]['person'][$person[$record]] = 0;
//.........这里部分代码省略.........
示例13: prepareDeleteStatement
/**
* Prepare the delete statements for records and entries.
*
* @param $delete_type The type of delete statement to prepare.
* @return boolean
*/
protected function prepareDeleteStatement($delete_type)
{
if (!array_key_exists('delete', self::$prepared) || !is_array(self::$prepared['delete'])) {
self::$prepared['delete'] = array();
}
if (!isset(self::$prepared['delete'][$delete_type])) {
switch ($delete_type) {
case "record":
self::$prepared['delete'][$delete_type] = $this->db->prepare("DELETE FROM record WHERE id = ?", array('integer'), MDB2_PREPARE_MANIP);
break;
case "entry":
case "last_entry":
self::$prepared['delete'][$delete_type] = $this->db->prepare("DELETE FROM {$delete_type} WHERE record = ?", array('integer'), MDB2_PREPARE_MANIP);
break;
default:
I2CE::raiseMessage("Unable to prepare delete statement for {$delete_type}.");
return false;
}
if (I2CE::pearError(self::$prepared['delete'][$delete_type], "Error preparing delete statement {$delete_type}:")) {
return false;
}
}
return true;
}
示例14: save
public function save($do_check, $user)
{
$bin_file = $this->getStorageFile();
if ($this->temp_file && file_exists($this->temp_file)) {
//I2CE::raiseMessage("copying from ".$this->temp_file." to $bin_file");
if (!rename($this->temp_file, $bin_file)) {
I2CE::raiseError("Failed to open {$bin_file} for binary files!");
return false;
}
} else {
if (strlen($this->value) > 0 && $this->value != 'from_file') {
I2CE::raiseMessage("writing from value to {$bin_file}");
$cH = fopen($bin_file, 'w');
if (!$cH) {
I2CE::raiseError("Failed to open {$bin_file} for binary files!");
return false;
}
fwrite($cH, $this->value);
fclose($cH);
} else {
I2CE::raiseMessage("No data so not creating: {$bin_file}");
}
}
return parent::save($do_check, $user);
}
示例15: setupMappedValues
/**
* Stores the array of mapped value for a formfield in {@var $formfield}
* @parmam boolean $isReportForm Defaults to true. If true we a sending a report form field
* If false, we are working with a form field.
* @param string $reportformfield
*/
protected function setupMappedValues($reportformfield, $isReportForm = true)
{
if ($isReportForm === true) {
$isReportForm = $this->config->report;
}
list($mergekey, $mergereport, $reportformfield) = array_pad(explode(':', $reportformfield, 3), -3, '');
if ($mergereport) {
$isReportForm = $mergereport;
}
if (is_string($isReportForm)) {
$this->mapReportFormField($reportformfield, $isReportForm);
$formfield = $this->fieldMaps[$isReportForm][$reportformfield];
if (!$this->isMapped($reportformfield, $isReportForm)) {
return;
}
} else {
$formfield = $reportformfield;
}
if ($formfield === false) {
return;
}
if (array_key_exists($formfield, $this->mappedValues)) {
//we have already gotten the mapped values
return;
}
//we need to get the mapped values
list($formObj, $fieldObj) = $this->getFormFieldObjects($reportformfield, $isReportForm);
if (!$formObj instanceof I2CE_Form) {
//we are dealing with a funcion field which is not mapped so return
return;
}
$mappedValues = array();
if ($fieldObj instanceof I2CE_FormField) {
$mappedValues = $fieldObj->getMapOptions();
}
if (!is_array($mappedValues)) {
//just to be sure
$mappedValues = array();
}
//$this->mappedValues[$formfield] = $mappedValues;
$this->mappedValues[$formfield] = array();
if (count($mappedValues) > 100) {
I2CE::raiseMessage("A large amount of values are returned from the setupMappedValues function for CustomReport display for {$reportformfield}. This should be modified to display a text value instead of the mapped value by joining the appropriate form in the relationship.");
}
foreach ($mappedValues as $record) {
$this->mappedValues[$formfield][$record['value']] = $record['display'];
}
}