function &sysDb() { $amber =& Amber::getInstance($this->_globalConfig); if (!is_object($amber)) { return false; } return $amber->sysDb(); }
/** * @ignore */ function doImport(&$config) { $installerPath = __AMBER_BASE__ . '/install/'; $amber =& Amber::getInstance($config); // Create tx_amber_sys_objects $sysDb =& Amber::sysDb(); $sql = file_get_contents($installerPath . '/tx_amber_sys_objects.sql'); if ($sql == false) { echo formatMessage('Unable to open tx_amber_sys_objects.sql'); return false; } $sysDb->Execute($sql); if ($sysDb->ErrorNo() != 0) { echo formatMessage('Importing tx_amber_sys_objects.sql failed:<p />' . $sysDb->ErrorMsg()); } // Create table which hold sample data $db =& Amber::currentDb(); $sql = @file_get_contents($installerPath . '/sample_data.sql'); if ($sql == false) { echo formatMessage('Unable to open sample_data.sql'); return false; } $db->Execute($sql); if ($db->ErrorNo() != 0) { echo formatMessage('Importing sample_data.sql failed:<p />' . $db->ErrorMsg()); } }
function &setAmberConfig() { $cfgFileName = '../conf/localconf.xml'; if (!file_exists($cfgFileName)) { Amber::showError('Error: localconf.xml does not exist', 'Amber needs to be configured before you can use it. <br>Use the <a href="../Amber/install/index.php" target="_blank">install tool</a> to set up the database connection.'); } $cfg = new AmberConfig(); $cfg->fromXML($cfgFileName); setlocale(LC_CTYPE, 'de_DE', 'de_DE@euro'); setlocale(LC_TIME, 'de_DE', 'de_DE@euro'); // needed for date, time setlocale(LC_MONETARY, 'de_DE', 'de_DE@euro'); // needed for numbers return Amber::getInstance($cfg); }
/** * @static * @access public * @param string * @param string * @param bool If set to true the output will be returned as string, otherwise it will be echoed */ function showError($title, $text, $ret = false) { $amber =& Amber::getInstance(); $callb = $amber->_errorCallback; if (isset($callb)) { if (is_array($callb) && count($callb) == 2) { $object =& $callb[0]; $method = $callb[1]; if (method_exists($object, $method)) { return call_user_method($method, $object, $title, $text, $ret); } } else { if (is_string($callb) && function_exists($callb)) { return call_user_func($callb, $title, $text, $ret); } } } $id = 'AmberError' . mt_rand(); $btId = 'AmberBacktrace' . mt_rand(); $out = '<div id="' . $id . '" style="margin: 20px; border: solid 2px #ff0000; background-color: yellow; padding: 20px; z-index: 99999; position: relative; margin-top: 10px;">'; $out .= '<p align="center"><b>' . $title . '</b></p>'; $out .= '<p align="center">' . $text . '</p>'; $out .= '<p align="center"><input type="button" value="Backtrace" onclick="document.getElementById(\'' . $btId . '\').style.display = \'\';" style="width: 80px;" />'; $out .= ' <input type="button" value="Close" onclick="document.getElementById(\'' . $id . '\').style.display = \'none\';" style="width: 80px;" /></p>'; $out .= '<p />'; if (function_exists('debug_backtrace')) { $trace = debug_backtrace(); $out .= '<div id="' . $btId . '" align="center" style="display:none;">' . Amber::dump(next($trace), true) . '</div>'; } $out .= '</div>'; if ($ret == true) { return $out; } else { echo $out; } }
} else { $type = 'html'; // for a list of possible values see ExporterFactory.php and corresponding include files } $mode = 'normal'; if (isset($_GET['mode'])) { $mode = $_GET['mode']; // 'design' or 'normal' } $cfgFileName = '../Amber/conf/localconf.xml'; if (!file_exists($cfgFileName)) { Amber::showError('Error: localconf.xml does not exist', 'Amber needs to be configured before you can use it. <br>Use the <a href="../Amber/install/index.php" target="_blank">install tool</a> to set up the database connection.'); die; } $cfg = new AmberConfig(); $cfg->fromXML($cfgFileName); setlocale(LC_CTYPE, 'de_DE', 'de_DE@euro'); setlocale(LC_TIME, 'de_DE', 'de_DE@euro'); // needed for date, time setlocale(LC_MONETARY, 'de_DE', 'de_DE@euro'); // needed for numbers //setlocale (LC_ALL, 'de_DE', 'de_DE@euro'); if (isset($_GET['filter'])) { $filter = $_GET['filter']; } $amber =& Amber::getInstance($cfg); if ($mode == 'normal') { $amber->OpenReport($repName, AC_NORMAL, $filter, $type); } else { $amber->OpenReport($repName, AC_DESIGN, $filter, $type); }
function printNormal() { if (!$this->SourceObject) { $this->_exporter->printNormal($this, ''); return $this->stdHeight(); } // Convert SourceObject to name and type $source = explode('.', $this->SourceObject); $type = $source[0]; $name = $source[1]; // Try to load report $amber =& Amber::getInstance(); $rep =& ObjectHandler::getObject($this->_hReport); $mgr =& $amber->getObjectManager(); $this->_subReport =& $mgr->loadReport($name); if (!$this->_subReport) { $this->_exporter->printNormal($this, ''); return $this->stdHeight(); } // Construct filter if ($this->LinkChildFields != null && $this->LinkMasterFields != null) { $linkChild = explode(';', $this->LinkChildFields); $linkMaster = explode(';', $this->LinkMasterFields); foreach ($linkChild as $idx => $lchild) { $lmaster = $linkMaster[$idx]; if (!array_key_exists($lmaster, $rep->Cols)) { Amber::showError('Error', 'LinkMasterField "' . htmlspecialchars($lmaster) . '" does not exist.'); die; } $value = $rep->Cols[$lmaster]; // FIXME: // - filter value has to be handled according to it's type // We need to have the recordset instead of a plain array here if ($value === null) { $reportFilterArray[] = '(' . $lchild . ' is null)'; } else { $reportFilterArray[] = '(' . $lchild . '=' . $rep->Cols[$lmaster] . ')'; } } $this->_subReport->Filter = implode(' AND ', $reportFilterArray); } $this->_subReport->setSubReport(true); $this->_subReport->run($rep->exporterType); // Adjust control height before passing it to the exporter $originalHeight = $this->Height; $requestedHeight = $this->Height; $subReportHeight = $this->_subReport->getTotalHeight(); if ($this->CanShrink) { if ($subReportHeight == 0) { // No output at all return 0; } // Shrink if ($this->Height > $subReportHeight) { $requestedHeight = $subReportHeight; } } // Grow if ($this->CanGrow && $this->Height < $subReportHeight) { $requestedHeight = $subReportHeight; } $this->Height = $requestedHeight; $this->_exporter->printNormal($this, $this->_subReport->subReportBuff); // Reset control height $this->Height = $originalHeight; return $this->stdHeight($requestedHeight); }