function setControlExporter(&$ctrl) { // set the exporter of Control $ctrl // do something like $ctrl->_exporter =& new ControlExporter; Amber::showError('Error', 'Abstract function called: Exporter::setControlExporter, type: ' . $this->type); die; }
/** * * @access public * @param Config * */ function setConfig(&$cfgObj) { if (is_object($cfgObj) && is_a($cfgObj, 'AmberConfig')) { $this->_globalConfig = $cfgObj; } else { die(Amber::showError('Error', 'Given parameter is not an instance of AmberConfig', true)); } }
/** * @access public * @param string * @param string * @param AmberObjectRaw */ function saveObject($type, $name, &$obj) { $types = array_keys($this->objectTypes); if (!in_array($type, $types)) { Amber::showError('ObjectManager', 'Requested saving of unsupported object type: "' . $type . '"'); die; } $this->objectLoader->save($type, $name, $obj); }
/** * Create association between an exporter type string and the class which * will be responsible to handle output. * * @static * @access public * @param string Exporter type string * @param string Name of the class which must be instantiated for this type of exporter */ function register($type, $className) { $instance =& ExporterFactory::getInstance(); if (array_key_exists($type, $instance->_classList)) { Amber::showError('Error', 'Duplicate exporter type: "' . $type . '"'); die; } $instance->_classList[$type] = $className; }
/** * * @access public * @param integer handle of object to return * @return mixed * */ function &getObject($handle) { $me =& ObjectHandler::getInstance(); if (!isset($me->_list[$handle])) { Amber::showError('ObjectHandler::getObject()', 'Invalid handle: [' . $handle . ']'); return null; } return $me->_list[$handle]; }
/** * @access public * @param string * @param string */ function register($type, $className) { $instance =& AggregateFactory::getInstance(); if (!class_exists($className)) { Amber::showError('Warning', 'Missing declaration for class "' . $className . '", aggregate type = ' . $type); return false; } $instance->_classList[$type] = $className; }
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); }
function get($str) { $path = split('/', $str); if ($path[0] == 'db') { $conf =& $this->database; } else { if ($path[0] == 'sys') { $conf =& $this->sys_objects; } else { Amber::showError('AmberConfig::get()', 'Invalid root: "' . $path[0] . '"'); } } unset($path[0]); foreach ($path as $p) { if (!isset($conf[$p])) { //Amber::showError('AmberConfig::get()', 'No such element: "' . $p . '"'); return ''; } $conf =& $conf[$p]; } return $conf; }
function pageLayout(&$report) { $this->noAutoPage = $report->noAutoPage; $this->noMargins = $report->noMargins; $this->noHeadFoot = $report->noHeadFoot; $this->unit = 1 / 20; $this->reportWidth = $report->Width; if ($report->Orientation == 'portrait') { $this->paperWidth = $report->PaperWidth; $this->paperHeight = $report->PaperHeight; } else { $this->paperWidth = $report->PaperHeight; $this->paperHeight = $report->PaperWidth; } if ($this->noMargins) { $this->rightMargin = 0; $this->leftMargin = 0; $this->topMargin = 0; $this->bottomMargin = 0; $this->paperWidth = $this->paperWidth - $report->LeftMargin - $report->RightMargin; $this->paperHeight = $this->paperHeight - $report->TopMargin - $report->BottomMargin; } else { $this->rightMargin = $report->RightMargin; $this->leftMargin = $report->LeftMargin; $this->topMargin = $report->TopMargin; $this->bottomMargin = $report->BottomMargin; } if ($this->noHeadFoot) { $this->pageHeaderHeight = 0; $this->pageFooterHeight = 0; } else { $this->pageHeaderHeight = $report->PageHeader->Height; $this->pageFooterHeight = $report->PageFooter->Height; } if ($this->noAutoPage) { $this->printWidth = $this->reportWidth; $this->pagesHorizontal = 1; } else { $this->printWidth = $this->paperWidth - $this->leftMargin - $this->rightMargin; //width of printable area of page (w/o morgins) if ($this->printWidth <= 0) { $msg = 'paper width: ' . (int) $this->paperWidth . '; left margin:' . (int) $this->leftMargin . '; right margin: ' . (int) $this->rightMargin . ';'; die(Amber::showError('Error: Width of printable area too small', $msg, true)); } $this->pagesHorizontal = floor($this->reportWidth / $this->printWidth) + 1; // No of pages needed to print report $this->printHeight = $this->paperHeight - $this->topMargin - $this->bottomMargin - $this->pageHeaderHeight - $this->pageFooterHeight; //height of printable area of page (w/o margins) } $this->pageNo = -1; }
/** * * @access public * @param Report * @param array XML data * */ function load(&$parent, $data) { $this->_parent =& $parent; $this->Name = $data['Name']; $this->Height = empty($data['Height']) ? 0 : $data['Height']; $this->ForceNewPage = empty($data['ForceNewPage']) ? 0 : $data['ForceNewPage']; if (isset($data['Visible'])) { $this->Visible = $data['Visible']; } if (isset($data['BackColor'])) { $this->BackColor = MSColor($data['BackColor']); } if (isset($data['CanGrow'])) { $this->CanGrow = $data['CanGrow']; } if (isset($data['CanShrink'])) { $this->CanShrink = $data['CanShrink']; } if (isset($data['KeepTogether'])) { $this->KeepTogether = $data['KeepTogether']; } if (isset($data['EventProcPrefix'])) { $this->EventProcPrefix = $data['EventProcPrefix']; } else { $this->EventProcPrefix = $data['Name']; } $s = $data['EventProcPrefix'] . '_Format'; if (method_exists($this->_parent->_Code, $s)) { $this->_OnFormatFunc = $s; } else { $this->_OnFormatFunc = 'allSections_Format'; // null-OnFormat } $s = $data['EventProcPrefix'] . '_Print'; if (method_exists($this->_parent->_Code, $s)) { $this->_OnPrintFunc = $s; } else { $this->_OnPrintFunc = 'allSections_Print'; // null-OnPrint } if (!empty($data['Controls'])) { foreach ($data['Controls'] as $c) { $ctl =& ControlFactory::create($c['ControlType'], $c, $parent->hReport); if ($ctl == false) { Amber::showError('Warning', 'Skipping unsupported control type: ' . htmlentities($c['ControlType'])); } else { $this->Controls[] =& $ctl; $parent->Controls[$ctl->Name] =& $ctl; $parent->ControlValues[$ctl->Name] =& $ctl->Value; $ctl->_SectionSlip =& $parent->SectionSlip; } } } }
/** * @access public * @abstract * @param string */ function run($type) { Amber::showError('Error', 'Virtual method AmberObject::run() not overridden'); }
/** * * @access private * @param string name of XML file to load * @return array parsed XML data * */ function &getArray($fileName) { if (empty($this->_cacheDir)) { // This should never happen! $this->_cacheDir = '.'; } $cacheFileName = $this->_cacheDir . '/' . md5($fileName); //$cacheFileName = $this->_cacheDir . '/' . basename($fileName); if (!file_exists($fileName)) { Amber::showError('Error', 'XML file not found: ' . htmlspecialchars($fileName)); die; } if ($this->_cacheEnabled == true) { if (filemtime($fileName) > @filemtime($cacheFileName)) { $res =& $this->_makeXMLTree(file_get_contents($fileName)); $fp = @fopen($cacheFileName, 'w'); if ($fp != false) { fwrite($fp, serialize($res)); fclose($fp); } } else { $res =& unserialize(file_get_contents($cacheFileName)); } } else { $res =& $this->_makeXMLTree(file_get_contents($fileName)); } return $res; }
/** * @access public * @param string type name (sum, avg, count etc.) * @param string section name * @return Object */ function &createAggregate($type, $sectionName) { if (isset($this->Sections[$sectionName])) { return $this->Sections[$sectionName]->createAggregate($type); } else { Amber::showError('Error', 'Section "' . $sectionName . "\" not found. Valid section names are:\n" . implode(', ', array_keys($this->Sections))); } }
require_once 'header.inc'; ?> <table align="center" style="width: 450px; border: #b08454 1px dashed;"> <tr> <td> <form action="examples/index.php" method="get" target="_blank"> <fieldset> <div> <?php require_once 'Amber/Amber.php'; $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 <b>Install Tool</b> to set up the database connection.'); } else { $cfg = new AmberConfig(); $cfg->fromXML($cfgFileName); $amber =& Amber::getInstance($cfg); $mgr =& $amber->getObjectManager(); $list = $mgr->getList('report'); echo '<label for="repName">Report:</label> <select name="rep" id="repName">'; foreach ($list as $idx => $entry) { echo '<option value="' . $entry . '">' . $entry . '</option>'; } echo '</select>'; } ?> </div>
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); }
$repName = 'GLS'; } if (isset($_GET['export'])) { $type = $_GET['export']; } 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') {
/** * @static * @access public * @param string */ function evaluate($name, &$code) { ob_start(); $result = eval(' ?' . '>' . $code . '<' . '?php '); $message = ob_get_contents(); ob_end_clean(); if ($result === false) { Amber::showError('Unable to evaluate ' . $name, $message); die; } }
/** * @access protected * @param string * @param AmberObjectRaw */ function saveModule($name, &$obj) { $modPath = $this->_basePath . '/modules/'; if (!is_dir($modPath)) { Amber::showError('ObjectLoaderFile::saveModule()', 'Directory does not exist: ' . $modPath); die; } $fileNameCode = $modPath . $name . '.php'; $fp = fopen($fileNameCode, 'w'); fwrite($fp, $obj->code); }