summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bfa25c)
raw | patch | inline | side by side (parent: 3bfa25c)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 25 Aug 2009 11:51:16 +0000 (11:51 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 25 Aug 2009 11:51:16 +0000 (11:51 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14126 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_listing.inc | patch | blob | history | |
gosa-core/include/exporter/class_cvsExporter.inc | patch | blob | history | |
gosa-core/include/exporter/class_pdfExporter.inc | [new file with mode: 0644] | patch | blob |
gosa-core/include/php_setup.inc | patch | blob | history |
index 89f383f668555e5be929cc5901d9f9962ac0f4c7..9d9835b2b38bb74e34e181017466108b345115e3 100644 (file)
var $snapshotHandler= null;
var $exporter= array();
var $exportColumns= array();
- var $showExporter= false;
function listing($filename)
foreach($class_mapping as $class => $dummy) {
if (preg_match('/Exporter$/', $class)) {
$info= call_user_func(array($class, "getInfo"));
- $this->exporter= array_merge($this->exporter, $info);
+ if ($info != null) {
+ $this->exporter= array_merge($this->exporter, $info);
+ }
}
}
}
$result.= "</table></div>";
- // Open export window?
- if ($this->showExporter) {
- $result.= "<SCRIPT TYPE='text/javascript'>window.open('getbin.php', '"._("GOsa - export list")."');</SCRIPT>";
- $this->showExporter= false;
- }
-
$smarty= get_smarty();
$smarty->assign("FILTER", $this->filter->render());
$smarty->assign("SIZELIMIT", print_sizelimit_warning());
}
// Filter POST with "act" attributes -> posted from action menu
- if (isset($_POST['act']) && $_POST['act'] != '') {
+ if (isset($_POST['exec_act']) && $_POST['act'] != '') {
if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
$exporter= $this->exporter[$_POST['act']];
- $instance= new $exporter['class']($this->plainHeader, $this->entries, $this->exportColumns);
+ $userinfo= ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S');
+ $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $this->entries, $this->exportColumns);
$type= call_user_func(array($exporter['class'], "getInfo"));
$type= $type[$_POST['act']];
- session::set('binarytype', $type['mime']);
- session::set('binaryfile', $type['filename']);
- session::set('binary', $instance->query());
- $this->showExporter= true;
+ send_binary_content($instance->query(), $type['filename'], $type= $type['mime']);
}
}
// Load shortcut
$actions= &$this->xmlData['actionmenu']['action'];
- $result= "<input type='hidden' name='act' id='actionmenu' value=''>".
+ $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
"<ul class='level1' id='root'><li><a href='#'>Aktionen <img ".
"border=0 class='center' src='images/lists/sort-down.png'></a>";
// Copy entry
if($copy){
- $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"copy\";mainform.submit();'><img src='images/lists/copy.png' alt='' border='0' class='center'> "._("Copy")."</a></li>";
+ $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"copy\";document.getElementById(\"exec_act\").click();'><img src='images/lists/copy.png' alt='' border='0' class='center'> "._("Copy")."</a></li>";
$separator= "";
}
// Cut entry
if($cut){
- $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"cut\";mainform.submit();'><img src='images/lists/cut.png' alt='' border='0' class='center'> "._("Cut")."</a></li>";
+ $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"cut\";document.getElementById(\"exec_act\").click();'><img src='images/lists/cut.png' alt='' border='0' class='center'> "._("Cut")."</a></li>";
$separator= "";
}
}
// Draw entries that allow pasting entries
if($paste){
if($this->copyPasteHandler->entries_queued()){
- $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"paste\";mainform.submit();'><img src='images/lists/paste.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
+ $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"paste\";document.getElementById(\"exec_act\").click();'><img src='images/lists/paste.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
}else{
$result.= "<li$separator><a href='#'><img src='images/lists/paste-grey.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
}
// Draw icons according to the restore flag
if($restore){
- $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"restore\";mainform.submit();'><img src='images/lists/restore.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
+ $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"restore\";document.getElementById(\"exec_act\").click();'><img src='images/lists/restore.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
}else{
$result.= "<li$separator><a href='#'><img src='images/lists/restore_grey.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
}
// Export CVS as build in exporter
foreach ($this->exporter as $action => $exporter) {
- $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"$action\";mainform.submit();'><img border='0' class='center' src='".$exporter['image']."'> ".$exporter['label']."</a></li>";
+ $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"$action\";document.getElementById(\"exec_act\").click();'><img border='0' class='center' src='".$exporter['image']."'> ".$exporter['label']."</a></li>";
}
// Finalize list
$events= DaemonEvent::get_event_types_by_category($this->categories);
if(isset($events['BY_CLASS']) && count($events['BY_CLASS'])){
foreach($events['BY_CLASS'] as $name => $event){
- $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value=\"$name\";mainform.submit();'>".$event['MenuImage']." ".$event['s_Menu_Name']."</a></li>";
+ $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value=\"$name\";document.getElementById(\"exec_act\").click();'>".$event['MenuImage']." ".$event['s_Menu_Name']."</a></li>";
$separator= "";
}
}
diff --git a/gosa-core/include/exporter/class_cvsExporter.inc b/gosa-core/include/exporter/class_cvsExporter.inc
index 110014f8baeb689d4ea2c576c3f43ca235605c5f..5c7b07657cea62f4959b93fb6e07d22cea50ef7f 100644 (file)
{
var $result;
- function csvExporter($header, $entries, $columns= array()) {
+ function csvExporter($headline, $header, $entries, $columns= array()) {
// If no preset, render all columns
if (!count($columns)) {
foreach ($header as $index => $dummy) {
$this->result= "#";
foreach ($columns as $index) {
if (isset($header[$index])){
- $this->result.= $header[$index].";";
+ $this->result.= trim($header[$index]).";";
} else {
$this->result.= ";";
}
foreach ($entries as $row) {
foreach ($columns as $index) {
if (isset($row["_sort$index"])){
- $this->result.= $row["_sort$index"].";";
+ $this->result.= trim($row["_sort$index"]).";";
} else {
$this->result.= ";";
}
static function getInfo()
{
- return array("exportCVS" => array( "label" => _("CSV"), "image" => "plugins/lists/exportCSV.png", "class"=> "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" ));
+ return array("exportCVS" => array( "label" => _("CSV"), "image" => "images/lists/csv.png", "class"=> "csvExporter", "mime" => "text/x-csv", "filename" => "export.csv" ));
}
}
diff --git a/gosa-core/include/exporter/class_pdfExporter.inc b/gosa-core/include/exporter/class_pdfExporter.inc
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+
+// Try to load PDF library
+define('FPDF_FONTPATH', '/usr/share/php/fpdf/font/');
+include('fpdf/fpdf.php');
+
+class pdfExporter
+{
+ var $result;
+
+ function pdfExporter($headline, $header, $entries, $columns= array()) {
+ // If no preset, render all columns
+ if (!count($columns)) {
+ foreach ($header as $index => $dummy) {
+ $columns[]= $index;
+ }
+ }
+
+ // Create new PDF
+ $this->result=new FPDF('L', 'mm', 'A4');
+ $this->result->SetFont('Helvetica', '', 10);
+ $this->result->AddPage();
+
+ // Analyze for width
+ $width= $this->calcWidth($header, $entries, $columns);
+
+ // Render head
+ $this->result->SetFont('','B');
+ $this->result->Cell(0,0,utf8_decode($headline),0,0,'L');
+ $this->result->Ln(5);
+
+ // Generate header
+ $this->result->SetFillColor(240,240,240);
+ $this->result->SetTextColor(0);
+ $this->result->SetDrawColor(0,0,0);
+ $this->result->SetLineWidth(.3);
+ $this->result->SetFont('','B');
+
+ foreach ($columns as $order => $index) {
+ if (isset($header[$index])){
+ $this->result->Cell($width[$order], 7, utf8_decode($header[$index]), 1, 0, 'C', 1);
+ } else {
+ $this->result->Cell($width[$order], 7, '', 1, 0, 'C', 1);
+ }
+ }
+ $this->result->Ln();
+
+ // Append entries
+ $this->result->SetFillColor(224,235,255);
+ $this->result->SetTextColor(0);
+ $this->result->SetFont('');
+
+ $fill= false;
+ foreach ($entries as $row) {
+ foreach ($columns as $order => $index) {
+
+ if (isset($row["_sort$index"])){
+ $this->result->Cell($width[$order], 6, utf8_decode($row["_sort$index"]), 'LR', 0, 'L', $fill);
+ } else {
+ $this->result->Cell($width[$order], 6, '', 'LR', 0, 'L', $fill);
+ }
+ }
+
+ $this->result->Ln();
+ $fill= !$fill;
+ }
+ $this->result->Cell(array_sum($width), 0, '', 'T');
+ }
+
+
+ function calcWidth($header, $entries, $columns)
+ {
+ $width= array();
+
+ // Locate longest value for each column
+ foreach ($columns as $order => $index) {
+ $max= 0;
+
+ if (isset($header[$index])){
+ $len= $this->result->GetStringWidth($header[$index]);
+ if ($len > $max) {
+ $max= $len;
+ }
+ }
+
+ foreach ($entries as $row) {
+ if (isset($row["_sort$index"])){
+ $len= $this->result->GetStringWidth($row["_sort$index"]);
+ if ($len > $max) {
+ $max= $len;
+ }
+ }
+ }
+
+ $width[]= $max;
+ }
+
+ // Scale to page width
+ $printWidth= 280;
+ $scale= $printWidth / array_sum($width);
+ foreach ($width as $index => $w) {
+ $width[$index]= (int)($width[$index] * $scale);
+ }
+
+ return $width;
+ }
+
+
+ function query()
+ {
+ return $this->result->Output("", "S");
+ }
+
+
+ static function getInfo()
+ {
+ // Check if class defined
+ $classes= get_declared_classes();
+ if(in_array('FPDF', $classes)) {
+ return array("exportPDF" => array( "label" => _("PDF"), "image" => "images/lists/pdf.png", "class"=> "pdfExporter", "mime" => "application/pdf", "filename" => "export.pdf" ));
+ } else {
+ return null;
+ }
+
+ }
+
+}
+
+?>
index 6566da07f23bf6ca10880b25945d1c2a9a827fdd..2732905613aba9c873865be5fe039bda5cee9543 100644 (file)
ini_set("track_vars",1);
ini_set("display_errors",1);
ini_set("report_memleaks",1);
-ini_set("include_path",".:$BASE_DIR/include:$BASE_DIR/include/utils/excel");
+ini_set("include_path",".:$BASE_DIR/include:$BASE_DIR/include/utils/excel:/usr/share/php");
/* Do smarty setup */
require("smarty/Smarty.class.php");