本文整理汇总了PHP中I2CE::longExecution方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE::longExecution方法的具体用法?PHP I2CE::longExecution怎么用?PHP I2CE::longExecution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE
的用法示例。
在下文中一共展示了I2CE::longExecution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_display_fields
public function get_display_fields()
{
I2CE::longExecution();
$this->unsetPaging();
if (!is_array($data = $this->getResults()) || !array_key_exists('results', $data) || !($results = $data['results'])) {
I2CE::raiseError("No data");
return array();
}
$person_ids = array();
$id = 'primary_form+id';
$uuid = 'primary_form+csd_uuid';
$display_fields = array();
$titles = $this->get_display_field_titles();
while (is_array($row = $results->fetchRow(MDB2_FETCHMODE_ASSOC))) {
I2CE::longExecution();
if (!array_key_exists('primary_form+id', $row) || !($person_id = $row['primary_form+id'])) {
I2CE::raiseError("Bad:" . print_r($row, true));
continue;
}
$data = array();
foreach ($titles as $formfield => $label) {
///this is just to ensure the same order as the display name of the fields
if (!array_key_exists($formfield, $row)) {
continue;
}
$data[$formfield] = $row[$formfield];
}
$display_fields[$person_id] = $data;
}
$results->free();
return $display_fields;
}
示例2: resaveTrainings
protected function resaveTrainings()
{
$user = new I2CE_User();
$ff = I2CE_FormFactory::instance();
$ids = I2CE_FormStorage::search('person_scheduled_training_course');
foreach ($ids as $id) {
I2CE::longExecution();
//to make sure we don't time out
if (!($pstc = $ff->createContainer(array('person_scheduled_training_course', $id))) instanceof iHRIS_Person_Scheduled_Training_Course) {
return false;
//something is wrong
}
$pstc->populate();
//populate will recacluate the average field
$pstc->save($user);
//saves the new calculated average field to the databse
$pstc->cleanup();
//free up memory
}
return true;
}
示例3: doRemap
protected function doRemap($form, $field, $id)
{
$obj = $this->ff->createContainer($id);
if (!$obj instanceof I2CE_List) {
$this->pushError("ID {$id} does not refer to a list");
//needs to be localized
return false;
}
$obj->populate();
$newform = '0';
$newid = '0';
$rField = $obj->getField('remap');
if (!$rField instanceof I2CE_FormField_REMAP || !($newform = $rField->getMappedForm()) || !($newid = $rField->getMappedID())) {
$this->pushError("No remapping data has been set for {$id} [{$newform}|{$newid}]" . get_class($rField));
return false;
}
$where = array('operator' => 'FIELD_LIMIT', 'field' => $field, 'style' => 'equals', 'data' => array('value' => $id));
if (($count = count($remapIDs = I2CE_FormStorage::search($form, false, $where))) < 1) {
$this->pushMessage("No fields found to remap");
return true;
}
$this->pushCount($count);
$exec = array('max_execution_time' => 20 * 60, 'memory_limit' => 256 * 1048576);
$user = new I2CE_User();
$success = true;
foreach ($remapIDs as $i => $remapID) {
I2CE::longExecution($exec);
if (!($remapObj = $this->ff->createContainer($form . '|' . $remapID)) instanceof I2CE_Form) {
$this->pushMessage("Could not create {$form}|{$remapID}", $i + 1);
$success = false;
continue;
}
$remapObj->populate();
if (!($fieldObj = $remapObj->getField($field)) instanceof I2CE_FormField_MAP) {
$this->pushMessage("Field {$field} is not a map field", $i + 1);
$success = false;
$remapObj->cleanup();
continue;
}
$fieldObj->setFromDB($newform . '|' . $newid);
$this->pushMessage("Remapping {$field} in {$form}|{$remapID} to be {$newform}|{$newid}", $i + 1);
if (!$remapObj->save($user)) {
$success = false;
$this->pushMessage("Could not save {$field} in {$form}|{$remapID} to be {$newform}|{$newid}", $i + 1);
} else {
$this->pushMessage("Remapped {$field} in {$form}|{$remapID} to be {$newform}|{$newid}", $i + 1);
}
$remapObj->cleanup();
}
return $success;
}
示例4: loadData
/**
*Loads in the requeted data from the relationship
* @returns boolean True on success
*/
protected function loadData($as_iterator = true)
{
$fields = $this->getFields();
$ordering = $this->getOrdering();
I2CE::longExecution(array("max_execution_time" => 1800));
$this->data = $this->formRelationship->getFormData($this->primObj->getName(), $this->primObj->getId(), $fields, $ordering, $as_iterator);
if ($as_iterator) {
if (!$this->data instanceof I2CE_RelationshipData) {
I2CE::raiseError("No data");
return false;
}
} else {
if (!is_array($this->data)) {
return false;
}
}
return true;
}
示例5: render
//.........这里部分代码省略.........
}
if (!$this->stdConfig->setIfIsSet($relationship, 'relationship')) {
I2CE::raiseError("No relationship set");
return false;
}
try {
$this->rel = new I2CE_FormRelationship($relationship, $this->base_rel_config);
} catch (Exception $e) {
I2CE::raiseError("Could not instatiate relationship {$relationship}");
return false;
}
$this->layoutOptions = array('encoding' => 'ASCII', 'hyphenation_file' => 'hyph_en_US.dic', 'orientation' => 'P', 'size' => 'A4', 'rows' => 1, 'cols' => 1, 'horiz_pad' => 10, 'horiz_pad_border' => 0, 'vert_pad' => 10, 'vert_pad_border' => 0);
if ($this->stdConfig->is_parent('layout_details')) {
I2CE_Util::merge_recursive($this->layoutOptions, $this->stdConfig->getAsArray("layout_details"));
}
if (!in_array($this->layoutOptions['orientation'], array('P', 'L'))) {
$this->layoutOptions['orientation'] = 'P';
}
$paper_sizes = array('A0' => array(841, 1189), 'A1' => array(594, 841), 'A2' => array(420, 594), 'A3' => array(297, 420), 'A4' => array(210, 297), 'A5' => array(148, 210), 'A6' => array(105, 148), 'A7' => array(74, 105), 'A8' => array(52, 74), 'A9' => array(37, 52), 'A10' => array(26, 37), 'B0' => array(1000, 1414), 'B1' => array(707, 1000), 'B2' => array(500, 707), 'B3' => array(353, 500), 'B4' => array(250, 353), 'B5' => array(176, 350), 'B6' => array(125, 176), 'B7' => array(88, 125), 'B8' => array(62, 88), 'B9' => array(44, 62), 'B10' => array(31, 44), 'C0' => array(917, 1297), 'C1' => array(648, 917), 'C2' => array(458, 648), 'C3' => array(324, 458), 'C4' => array(229, 324), 'C5' => array(162, 229), 'C6' => array(114, 162), 'C7' => array(81, 114), 'C8' => array(57, 81), 'C9' => array(40, 57), 'C10' => array(28, 40), 'LETTER' => array(216, 279), 'LEGAL' => array(216, 356), 'JUNIOR_LEGAL' => array(203, 127), 'LEDGER' => array(432, 279), 'TABLOID' => array(279, 432));
$this->layoutOptions['size'] = strtoupper($this->layoutOptions['size']);
if (!in_array($this->layoutOptions['size'], array_keys($paper_sizes))) {
$this->layoutOptions['size'] = 'A4';
}
if ($this->layoutOptions['orientation'] == 'P') {
$this->layoutOptions['paper_size'] = $paper_sizes[$this->layoutOptions['size']];
} else {
$this->layoutOptions['paper_size'] = array_reverse($paper_sizes[$this->layoutOptions['size']]);
}
if (!array_key_exists('border', $this->layoutOptions)) {
if ($this->layoutOptions['rows'] == 1 && $this->layoutOptions['cols'] == 1) {
$this->layoutOptions['border'] = 0;
} else {
$this->layoutOptions['border'] = 1;
}
}
$this->layoutOptions['border'] = (int) $this->layoutOptions['border'];
if ($this->layoutOptions['border'] < 0) {
$this->layoutOptions['border'] = 0;
}
$this->layoutOptions['horiz_pad_border'] = (int) $this->layoutOptions['horiz_pad_border'];
if ($this->layoutOptions['horiz_pad_border'] < 0) {
$this->layoutOptions['horiz_pad_border'] = 0;
}
$this->layoutOptions['vert_pad_border'] = (int) $this->layoutOptions['vert_pad_border'];
if ($this->layoutOptions['vert_pad_border'] < 0) {
$this->layoutOptions['vert_pad_border'] = 0;
}
$this->layoutOptions['horiz_pad'] = (int) $this->layoutOptions['horiz_pad'];
if ($this->layoutOptions['horiz_pad'] < 0) {
$this->layoutOptions['horiz_pad'] = 10;
}
$this->layoutOptions['vert_pad'] = (int) $this->layoutOptions['vert_pad'];
if ($this->layoutOptions['vert_pad'] < 0) {
$this->layoutOptions['vert_pad'] = 10;
}
$this->layoutOptions['rows'] = (int) $this->layoutOptions['rows'];
$this->layoutOptions['cols'] = (int) $this->layoutOptions['cols'];
if ($this->layoutOptions['rows'] < 1) {
I2CE::raiseError("Invalid rows");
return false;
}
if ($this->layoutOptions['cols'] < 1) {
I2CE::raiseError("Invalid cols");
return false;
}
$this->layoutOptions['form_width'] = (int) (($this->layoutOptions['paper_size'][0] - 2 * $this->layoutOptions['horiz_pad'] - $this->layoutOptions['border'] * ($this->layoutOptions['cols'] + 1) - 2 * $this->layoutOptions['horiz_pad_border'] * $this->layoutOptions['cols']) / $this->layoutOptions['cols']);
$this->layoutOptions['form_height'] = (int) (($this->layoutOptions['paper_size'][1] - 2 * $this->layoutOptions['vert_pad'] - $this->layoutOptions['border'] * ($this->layoutOptions['rows'] + 1) - 2 * $this->layoutOptions['vert_pad_border'] * $this->layoutOptions['rows']) / $this->layoutOptions['rows']);
if ($this->layoutOptions['form_width'] < 10) {
I2CE::raiseError("Not enough width");
return false;
}
if ($this->layoutOptions['form_height'] < 10) {
I2CE::raiseError("Not enough height");
return false;
}
$this->content = $this->stdConfig->getAsArray('content');
$forms = array();
foreach ($this->ids as $id) {
if (!is_string($id)) {
continue;
}
$fs = $this->rel->getFormsSatisfyingRelationship($id);
if (!is_array($fs) || count($fs) == 0) {
continue;
}
$forms[$id] = $fs;
}
if (count($forms) == 0) {
I2CE::raiseError("No valid forms");
return false;
}
$this->forms = $forms;
$textProps = array('font' => 'helvetica', 'style' => '', 'size' => 12, 'alignment' => 'L', 'color' => '#000000', 'bg_color' => 'none', 'style' => '');
if ($this->stdConfig->is_parent('text_properties')) {
I2CE_Util::merge_recursive($textProps, $this->stdConfig->getAsArray("text_properties"));
}
$this->validateTextProps($textProps);
I2CE::longExecution();
return $this->_render($textProps);
}
示例6: createAltConfig
protected function createAltConfig($update_from_config)
{
$hash = '2245023265ae4cf87d02c8b6ba991139';
//the hash of the root node
//first test to see if the alt config table is there for some reason.
$db = MDB2::singleton();
$qry = 'SHOW TABLES LIKE "config_alt"';
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot access database")) {
return false;
}
if ($result->numRows() > 0) {
I2CE::raiseError("Alt Config table has already been created");
$qry = "SELECT count(*) as count FROM `config_alt` WHERE `path_hash` = '{$hash}'";
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot access config_alt")) {
return false;
}
if ($row = $result->fetchRow()) {
if ($row->count == 1) {
I2CE::raiseError("Alt config has been created and seeded");
return true;
}
}
}
if ($update_from_config) {
//now see if the tmp alt config table is there and if so drop it.
$qry = 'SHOW TABLES LIKE "config_alt_tmp"';
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot access database")) {
return false;
}
if ($result->numRows() > 0) {
I2CE::raiseError("Temporary Alt Config table has already been created -- Dropping it");
$qry = 'DROP TABLE `config_alt_tmp`';
if (I2CE::pearError($db->query($qry), "Cannot drop temporary alternative config table")) {
return false;
}
}
$create = 'config_alt_tmp';
} else {
$create = 'config_alt';
}
$qrs = array("CREATE TABLE IF NOT EXISTS `{$create}` (\n `path_hash` char(32) NOT NULL,\n `parent` text NOT NULL,\n `name` text NOT NULL,\n `type` tinyint(4) NOT NULL,\n `value` longtext CHARACTER SET utf8 default NULL,\n PRIMARY KEY (`path_hash`),\n KEY (`parent` (130) ),\n KEY `path` ( `parent` ( 130 ), `name` (30) )\n) ENGINE=InnoDB DEFAULT CHARSET=utf8", "INSERT INTO `{$create}` (`path_hash`,`parent`,`name`,`type`,`value`) VALUE ('{$hash}','','',0,NULL)");
foreach ($qrs as $qry) {
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot execute query:\n{$qry}")) {
I2CE::raiseError("Could not initialize temporary alternate config table");
return false;
}
}
if (!$update_from_config) {
return true;
}
$qry = 'SHOW TABLES LIKE "config"';
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot access database")) {
return false;
}
if ($result->numRows() == 0) {
I2CE::raiseError("Attempting to update to alternative config table from existing config table, but the config table does not exist");
return false;
}
I2CE::longExecution();
I2CE::raiseError("Inserting entries into config_alt table from config table");
$qry = "REPLACE INTO config_alt_tmp(path_hash,parent,name,type,value) SELECT \n hash AS path_hash,\n IF ( locate('/',path) > 0 , CONCAT('/',SUBSTR(path,8,length(path) -7 - locate('/', reverse(path)))) , IF (locate(':',path), '/','' ) ) as parent,\n IF ( locate('/',path) > 0 , SUBSTR(path,length(path) - locate('/', reverse(path)) +2 ), IF (locate(':',path),SUBSTR(path,locate(':',path)+1),'') ) as name\n ,type,value\nfrom config WHERE ( locate(':',path) > 0 OR path = 'config' )";
if (I2CE::pearError($db->query($qry), "Cannot update alternative config table from existing table")) {
return false;
}
$qry = "RENAME TABLE `config_alt_tmp` TO `config_alt`";
if (I2CE::pearError($db->query($qry), "Cannot rename temporary alternative config table")) {
return false;
}
return $this->setupMagicDataStorage();
}
示例7: generateTemplate
protected function generateTemplate()
{
I2CE::longExecution(array("max_execution_time" => 1800));
if (!class_exists('I2CE_Odf')) {
I2CE::raiseError("Please turn on the printed forms module");
return false;
}
$odf_config = array('DELIMITER_LEFT' => '{{{', 'DELIMITER_RIGHT' => '}}}', 'ZIP_PROXY' => 'PhpZipProxy');
$odf = new I2CE_Odf($this->template_file, $odf_config);
$segment_style = 'global';
if (array_key_exists('segment_style', $this->args) && is_string($this->args['segment_style'])) {
$segment_style = $this->args['segment_style'];
}
$method = 'generateTemplate_' . $segment_style;
if (!$this->_hasMethod($method)) {
I2CE::raiseError("Invalid method: {$method}");
return false;
}
$this->{$method}($odf);
I2CE::raiseError("Outputing template");
$this->outputTemplate($odf, basename($this->template_file, '.odt'));
}
示例8: generate
public function generate($id, $stream = true)
{
I2CE::longExecution(array("max_execution_time" => 1800));
if (!($doc = $this->get_doc_for_id($id)) instanceof DOMDocument) {
I2CE::raiseError("Could not get document for " . $this->formRelationship->getPrimaryForm() . "|{$id}");
return false;
}
$contents = $doc->saveXML($doc->documentElement);
$transform_src = false;
$transform_file = false;
$trans_is_temp = false;
if (!($this->request_exists('transform') && $this->request('transform') == 0)) {
//allow request varible to turn of transform to check underlying data source easily
if (array_key_exists('transform', $this->args) && is_string($this->args['transform'])) {
$transform_src = $this->args['transform'];
}
if (is_string($transform_src) && strlen($transform_src)) {
if ($transform_src[0] == '@') {
//it's a file. search for it.
$file = substr($transform_src, 1);
if (!($transform_file = I2CE::getFileSearch()->search('XSLTS', $file))) {
I2CE::raiseError("Invalid transform file at {$file} => {$transform_file}\n" . print_r(I2CE::getFileSearch()->getSearchPath('XSLTS'), true));
return false;
}
} else {
if (substr($transform_src, 0, 7) == 'file://') {
$transform_file = substr($transform_src, 7);
} else {
$trans_is_temp = true;
$transform_file = tempnam(sys_get_temp_dir(), 'XSL_REL_');
file_put_contents($transform_file, $transform_src);
}
}
}
}
if ($stream) {
if ($errors = I2CE_Dumper::cleanlyEndOutputBuffers()) {
I2CE::raiseError("Got errors:\n{$errors}");
}
header('Content-Type: text/xml');
flush();
if ($transform_file) {
$temp_file = tempnam(sys_get_temp_dir(), 'XML_REL_SINGLE_');
file_put_contents($temp_file, $contents);
$cmd = $this->get_transform_cmd($contents, $temp_file, $transform_file);
passthru($cmd);
unlink($temp_file);
if ($trans_is_temp) {
unlink($transform_file);
}
} else {
echo $contents;
}
exit(0);
} else {
if ($transform_file) {
$temp_file = tempnam(sys_get_temp_dir(), 'XML_REL_SINGLE_');
file_put_contents($temp_file, $contents);
$cmd = $this->get_transform_cmd($contents, $temp_file, $transform_file);
$trans = shell_exec($cmd);
unlink($temp_file);
if ($trans_is_temp) {
unlink($transform_file);
}
return $trans;
} else {
return $contents;
}
}
}
示例9: allSystemsAreGoGo
/**
* Get the system status. http://www.ursula1000.com/
* @returns string 'gogo' means we are good. 'needs_installation' means we need to initialize. 'needs_upgrade'
*/
public static function allSystemsAreGoGo($site_module_file, $check_time = false)
{
$site_module_file = I2CE_FileSearch::realPath($site_module_file);
$config = self::getConfig();
$site_module = '';
$config->setIfIsSet($site_module, '/config/site/module');
$mod_factory = I2CE_ModuleFactory::instance();
$installed = '';
$config->setIfIsSet($installed, "/config/site/installation");
if ($installed == '') {
return 'needs_install';
}
if (!$site_module) {
self::raiseError("Cannot determine what your site is. This is bad.\n({$site_module_file})", E_USER_ERROR);
return 'no_site';
}
if (substr($installed, 0, 11) == 'in_progress') {
if (array_key_exists('HTTP_HOST', $_SERVER)) {
self::raiseError("Warning: Trying to access the site while update is in progress. Do you know what you are doing?");
} else {
self::raiseError("Warning: Trying to access the site while update is in progress. Run --update=1 --force-restart=1 to restart");
}
return $installed;
} else {
if ($installed == 'done') {
$previous_site_file = '';
if ($config->setIfIsSet($previous_site_file, '/config/data/' . $site_module . '/file')) {
$previous_site_file = I2CE_FileSearch::realPath($previous_site_file);
if ($previous_site_file != $site_module_file) {
I2CE::raiseError("Need reinstall ({$previous_site_file}) != ({$site_module_file}) for site module {$site_module}");
return 'needs_reinstall';
}
}
$mod_factory = I2CE_ModuleFactory::instance();
if (!$mod_factory->isEnabled($site_module)) {
return 'needs_reenable';
}
//$installed == 'done' and the site module/site module file are good. This should be the 'usual state of affairs'
$times = array();
$config->setIfIsSet($times, '/I2CE/update/times', true);
if (!isset($times['stale'])) {
$times['stale'] = 10;
}
if (!$check_time) {
if ($times['stale'] < 0 || !isset($times['last'])) {
$check_time = true;
} else {
if (isset($times['last'])) {
$check_time = time() - $times['last'] > $times['stale'];
}
}
}
if ($check_time) {
I2CE::longExecution(null, false);
//we are due to check the config files/modules for updates
$config->__set("/I2CE/update/times/last", time());
$updates = $mod_factory->getOutOfDateConfigFiles();
$config->__set("/I2CE/update/times/last", time());
if (count($updates['updates']) + count($updates['removals']) > 0) {
return 'needs_upgrade';
}
}
return 'done';
} else {
self::raiseError("Unknown installation status:" . $installed, E_USER_ERROR);
return 'unknown';
}
}
}
示例10: getPDF
/**
* Display the report
* @param DOMNode $contentNode The DOM node we wish to display into
* @param boolean $processResults Defaults to true meaning we run through the results
* @param mixed $controls. If null (default), we display all the report controsl. If string or an array of string, we only display the indicated controls
* @return mixed I2CE_PDF on success, boolean otherwise
*/
public function getPDF($contentNode, $processResults = true, $controls = null)
{
I2CE::longExecution(array("max_execution_time" => 1800));
$this->resultsTable = array();
if ($this->defaultOptions['table']['has_header']) {
$formfields = $this->getDisplayFieldsData();
$headers = array('#');
foreach ($formfields as $formfield => $data) {
if (!$data) {
continue;
}
$headers[$formfield] = $data['header'];
}
$this->resultsTable[] = $headers;
}
$data = $this->getResults();
if (!$this->processResults($data, $contentNode)) {
I2CE::raiseError("Could not get results");
return false;
}
$encoding = new I2CE_Encoding('ASCII');
//make sure we have somethin in our options
$pdf = new I2CE_PDF($encoding, $this->defaultOptions['paper_orientation'], $this->defaultOptions['unit_of_measure'], $this->defaultOptions['paper_size']);
//portrait, we are doing measurements in inches, letter paper
//setup the main page display style
$this->addFont($this->defaultOptions['main']['font'], $pdf);
$pdf->SetTopMargin($this->defaultOptions['main']['top_margin']);
$pdf->SetCompression($this->defaultOptions['compression']);
$pdf->SetLineSpacing($this->defaultOptions['line_spacing']);
//setup the header
$pdf->setPrintHeader($this->defaultOptions['header']['show']);
$pdf->setPrintFooter(false);
$this->addFont($this->defaultOptions['header']['font'], $pdf);
$pdf->setHeaderFont($this->defaultOptions['header']['font']['name'], $this->defaultOptions['header']['font']['style'], $this->defaultOptions['header']['font']['size']);
$title = '';
if ($this->defaultOptions['header']['title_prefix']) {
$title = $this->defaultOptions['header']['title_prefix'] . ': ';
}
$title .= $this->config->display_name;
$text = '';
if ($this->defaultOptions['header']['text_prefix']) {
if ($this->config->description) {
$text = $this->defaultOptions['header']['text_prefix'] . ': ' . $this->config->description;
} else {
$text = $this->defaultOptions['header']['text_prefix'];
}
} else {
if ($this->config->description) {
$text = $this->config->description;
} else {
$text = '';
}
}
$user = new I2CE_User();
$name = $user->firstname . ' ' . $user->lastname;
$time = strftime("%c");
$desc = "This report was printed by {$name} on {$time}.\n";
$limitsDesc = $this->getReportLimitsDescription();
if (strlen($limitsDesc) > 0) {
$desc .= "Report Limited by: " . $limitsDesc . "\n";
}
$pdf->setHeaderData($this->defaultOptions['header']['logo']['file'], $this->defaultOptions['header']['logo']['width'], $title, $text, $desc);
$pdf->setHeaderMargin($this->defaultOptions['header']['margin']);
// load our hyphenation dictionary
$hyphen = new I2CE_Hyphen($encoding);
$hyphen->LoadHyphenDictionary($this->defaultOptions['hyphenation_file']);
$pdf->SetHyphenationDictionary($hyphen);
//setup table style
$pdf->SetTableHeaderFillColor($this->defaultOptions['table']['header']['fill_color']);
$pdf->SetTableHeaderTextColor($this->defaultOptions['table']['header']['text_color']);
$pdf->SetTableDataFillColor($this->defaultOptions['table']['data']['fill_color']);
$pdf->SetTableDataTextColor($this->defaultOptions['table']['data']['text_color']);
$pdf->SetMinTableCellWidth($this->defaultOptions['table']['min_cell_width']);
$pdf->SetTableFramingColor($this->defaultOptions['table']['framing_color']);
$pdf->SetTableColSpacing($this->defaultOptions['table']['column_spacing']);
if (strtolower($this->defaultOptions['table']['width_style']) == 'explicit') {
if (!empty($this->defaultOptions['table']['explicit_widths'])) {
$pdf->SetTableWidths($this->defaultOptions['table']['explicit_widths']);
} else {
//fall back to a safe option
$pdf->SetAutoTableWidthStyle('ALL');
}
} else {
$pdf->SetAutoTableWidthStyle($this->defaultOptions['table']['width_style']);
}
//get on with displaying the report
$this->setFont($this->defaultOptions['main']['font'], $pdf);
$pdf->AddPage();
if ($this->defaultOptions['table']['has_header']) {
if ($this->defaultOptions['table']['use_running_header']) {
$table_header_options = 2;
} else {
$table_header_options = 1;
//.........这里部分代码省略.........
示例11: render
/**
*Abstract method to render the form. Makes sure all ducks are in a row
* @returns boolean true on sucess.
*/
public function render()
{
if (count($this->ids) != 1) {
I2CE::raiseError("Exactly one ID must be specifed (currently)");
return false;
}
if (!is_string($this->std_form) || strlen($this->std_form) == 0) {
I2CE::raiseError("No standard printed form set");
return false;
}
$this->stdConfig = I2CE::getConfig()->traverse('/modules/PrintedForms/forms/' . $this->std_form, false);
if (!$this->stdConfig instanceof I2CE_MagicDataNode) {
I2CE::raiseError("No standard printed form /modules/PrintedForms/forms/" . $this->std_form);
return false;
}
if (!$this->stdConfig->setIfIsSet($relationship, 'relationship')) {
I2CE::raiseError("No relationship set");
return false;
}
try {
$this->rel = new I2CE_FormRelationship($relationship, $this->base_rel_config);
} catch (Exception $e) {
I2CE::raiseError("Could not instatiate relationship {$relationship}");
return false;
}
$template = false;
$template_upload = false;
if ($this->stdConfig->setIfIsSet($template_upload, 'template_upload', true) && array_key_exists('content', $template_upload) && $template_upload['content'] && array_key_exists('name', $template_upload) && $template_upload['name']) {
$name = $template_upload['name'];
$pos = strrpos($name, '.');
if ($pos !== false) {
$name = substr($name, 0, $pos);
}
$this->template_file = tempnam(sys_get_temp_dir(), basename($name . '_')) . '.odt';
file_put_contents($this->template_file, $template_upload['content']);
} else {
if ($this->stdConfig->setIfIsSet($template, 'template')) {
$this->template_file = I2CE::getFileSearch()->search('ODT_TEMPLATES', $template);
if (!$this->template_file) {
I2CE::raiseError("No template file found from {$template}");
return false;
}
} else {
I2CE::raiseError("No template set");
return false;
}
}
$template_contents = new ZipArchive();
if ($template_contents->open($this->template_file) !== TRUE) {
I2CE::raiseError("Could not extract odt file");
return;
}
$this->template_vars = array();
for ($i = 0; $i < $template_contents->numFiles; $i++) {
$stats = $template_contents->statIndex($i);
if ($stats['name'] != 'content.xml') {
continue;
}
$matches = array();
//pull out all the template variables for processing.
preg_match_all('/{{{([0-9a-zA-Z_\\-\\+\\,\\=\\.]+(\\(.*?\\))?)}}}/', $template_contents->getFromIndex($i), $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
if (!is_array($match) || count($match) < 2 || !is_string($match[1]) || strlen($match[1]) == 0) {
continue;
}
$this->template_vars[] = $match[1];
}
$this->template_vars = array_unique($this->template_vars);
}
$this->content = $this->stdConfig->getAsArray('content');
$forms = array();
foreach ($this->ids as $id) {
if (!is_string($id)) {
continue;
}
$fs = $this->rel->getFormsSatisfyingRelationship($id);
if (!is_array($fs) || count($fs) == 0) {
continue;
}
$forms[$id] = $fs;
}
if (count($forms) == 0) {
I2CE::raiseError("No valid forms");
return false;
}
$this->forms = $forms;
$textProps = array();
I2CE::longExecution();
$success = $this->_render($textProps);
return $success;
}
示例12: debug_backtrace
break;
}
}
}
if (!$class_found) {
$debug = debug_backtrace();
$msg = "Cannot find the defintion for class ({$class_name})";
if (array_key_exists(1, $debug) && array_key_exists('line', $debug[1])) {
$msg .= "called from line " . $debug[1]['line'] . ' of file ' . $debug[1]['file'];
}
$msg .= "\nSearch Path is:\n" . print_r(I2CE::getFileSearch()->getSearchPath('CLASSES'), true);
// I2CE::raiseError( $msg, E_USER_NOTICE);
}
}
spl_autoload_register('i2ce_class_autoload');
I2CE::longExecution(array('memory_limit' => 512 * 1048576));
/*****************************************
* make the module list pages
*****************************************/
$module_packages = array();
$wout = array();
$wout['all'] = "__PAGE:iHRIS Module List\nThis is a list of all the modules available in the iHRIS Suite\n";
foreach ($packages as $pkg => $info) {
$wout[$pkg] = '__PAGE:' . $info['name'] . " Module List\n";
$wout[$pkg] .= "This is a list of all modules available in version " . $versions[$pkg] . ' of the package [' . $info['bzr'] . ' ' . $info['name'] . "]\n";
}
$comps = array('atleast' => 'at least ', 'atmost' => 'at most ', 'exactly' => 'exactly ', 'greaterthan' => 'greater than ', 'lessthan' => 'less than ');
ksort($found_modules, SORT_STRING);
$classObjs = array();
$fuzzys = array();
$fuzzys_CLI = array();
示例13: display
/**
* Display the report
* @param DOMNode $contentNode The DOM node we wish to display into
* @param boolean $processResults Defaults to true meaning we run through the results
* @param mixed $controls. If null (default), we display all the report controsl. If string or an array of string, we only display the indicated controls
* @returns boolean. true on sucess
*/
public function display($contentNode, $processResults = true, $controls = null)
{
I2CE::longExecution(array("max_execution_time" => 1800));
$this->saveDefaultView();
$template = $this->defaultOptions['odt_template'];
$template_upload = false;
$template_file = null;
if ($this->config->setIfIsSet($template_upload, "printed_forms/{$template}/template_upload", true) && array_key_exists('content', $template_upload) && $template_upload['content'] && array_key_exists('name', $template_upload) && $template_upload['name']) {
$template_file = $template_upload['name'];
$pos = strrpos($template_file, '.');
if ($pos !== false) {
$name = substr($template_file, 0, $pos);
} else {
$name = $template_file;
}
$template_loc = tempnam(sys_get_temp_dir(), basename($name . '_')) . '.odt';
file_put_contents($template_loc, $template_upload['content']);
} else {
$this->config->setIfIsSet($template_file, "printed_forms/{$template}/template");
$template_loc = I2CE::getFileSearch()->search('ODT_TEMPLATES', $template_file);
if (!$template_loc) {
I2CE::raiseError("No template file found from {$template_file}");
return false;
}
}
$this->header_vars = array();
foreach ($this->getDisplayFieldsData() as $formfield => $data) {
$this->header_vars["++header+{$formfield}"] = $data['header'];
list($formObj, $fieldObj) = $this->getFormFieldObjects($formfield);
$this->image_objs[$formfield] = $fieldObj instanceof I2CE_FormField_IMAGE;
$this->extra[$formfield] = array();
}
$this->limit_vars = $this->getLimitVars();
$odf_config = array('DELIMITER_LEFT' => '{{{', 'DELIMITER_RIGHT' => '}}}', 'ZIP_PROXY' => 'PhpZipProxy');
$this->odf = new I2CE_Odf($template_loc, $odf_config);
try {
$this->odf->setVars('++report_title', $this->config->display_name, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setStyleVars('++report_title', $this->config->display_name, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setVars('++report_description', $this->config->description, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setStyleVars('++report_description', $this->config->description, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
foreach ($this->header_vars as $key => $val) {
try {
$this->odf->setVars($key, $val, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setStyleVars($key, $val, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
}
foreach ($this->limit_vars as $key => $val) {
try {
$this->odf->setVars($key, $val, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setStyleVars($key, $val, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
}
$user = new I2CE_User();
$name = $user->firstname . ' ' . $user->lastname;
try {
$this->odf->setVars('++user_name', $name, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
try {
$this->odf->setStyleVars('++user_name', $name, $this->encoding, $this->charset);
} catch (OdfException $e) {
//It's ok if it's not there so don't do anything.
}
$time = strftime("%c");
try {
//.........这里部分代码省略.........
示例14: createIndexOnLastEntry
/**
* Checks to make sure there is the given index on the last_entry. If it does not exist it adds it.
* @param string $index_name
* @param mixed $fields. Either a string or array of string, the fields we want to make an index on
*
* If the field names need backtics, you are required to provide them
*/
protected function createIndexOnLastEntry($index_name, $fields)
{
if (is_string($fields)) {
$fields = array($fields);
}
if (!is_array($fields) || count($fields) == 0) {
I2CE::raiseError("Invalid fields");
return false;
}
$db = MDB2::singleton();
$qry = "SELECT null FROM information_schema.statistics WHERE\ntable_schema = '{$db->database_name}'\nand table_name = 'last_entry'\nand index_name = '{$index_name}'";
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot execute query:\n{$qry}")) {
return false;
}
if ($result->numRows() > 0) {
//the index has already been created.
return true;
}
//the index has not been created.
I2CE::longExecution();
//it may take a shilw
I2CE::raiseError("Creating index '{$index_name}' on the field(s) " . implode(",", $fields) . " of last_entry. This may take a long time if you have many records.");
$qry = "CREATE INDEX {$index_name} ON last_entry (" . implode(',', $fields) . ")";
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot execute query:\n{$qry}")) {
return false;
}
return true;
}
示例15: 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'];
}
$this->cols = array_keys($headers);
switch ($style) {
case 'xml':
$post = " </reportData>\n</ihrisReport>\n";
array_shift($this->cols);
$pre = $this->getXMLMetaData($headers);
break;
case 'tab':
$post = '';
$pre = $this->processResultRowArray($headers);
break;
case 'csv':
$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);
break;
default:
break;
}
return $out;
//.........这里部分代码省略.........