phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [18576] new: csv mode for chrono and dico functions


From: Pascal Vilarem
Subject: [Phpgroupware-cvs] [18576] new: csv mode for chrono and dico functions
Date: Sun, 01 Jun 2008 21:21:15 +0000

Revision: 18576
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18576
Author:   maat
Date:     2008-06-01 21:21:13 +0000 (Sun, 01 Jun 2008)

Log Message:
-----------
new: csv mode for chrono and dico functions

Modified Paths:
--------------
    trunk/ged/inc/class.ged_ui.inc.php

Modified: trunk/ged/inc/class.ged_ui.inc.php
===================================================================
--- trunk/ged/inc/class.ged_ui.inc.php  2008-06-01 21:20:18 UTC (rev 18575)
+++ trunk/ged/inc/class.ged_ui.inc.php  2008-06-01 21:21:13 UTC (rev 18576)
@@ -2072,121 +2072,232 @@
        function chrono()
        {
                $project_root=$this->get_var('project_root',array('GET'));
+               $mode=$this->get_var('mode', array('GET', 'POST'));
                
-               $this->set_template_defaults();
-               $this->display_app_header();
-               $this->t->set_file(array('chrono_tpl'=>'chrono.tpl'));
-               $this->t->set_block('chrono_tpl', 'type_block', 
'type_block_handle');
-               $this->t->set_block('type_block', 'chrono_block', 
'chrono_block_handle');
+               $all_versions=null;
+               $all_versions=$this->ged_dm->list_all_versions($project_root);
                
-               // DONE : use the project name instead of root id
-               $this->t->set_var('lang_chrono_title', lang('Chronos for 
project')." ".$this->ged_dm->get_project_name($project_root));
-               
-               $chronos=null;
-               $chronos=$this->ged_dm->list_chronos($project_root);
-               
-               if ( isset($chronos))
+               if ( !is_null($mode) && $mode == "csv")
                {
-                       foreach ( $chronos as $type_id => $type_chronos)
+                       if ($this->browser->is_ie())
                        {
-                               $this->t->set_var('chrono_block_handle', "");
-                               
-                               //DONE : Use the detailed label of type 
-                               $this->t->set_var('doc_type', $type_id);
-                               $row_class="row_off";
-                               foreach ( $type_chronos as $chrono)
+                               ini_set('zlib.output_compression', 'Off');
+                               header('Pragma: private');
+                               header('Cache-control: private, 
must-revalidate');
+                               header("Content-Type: 
application/force-download");
+                               header('Content-Disposition: attachment; 
filename="chrono.csv"', false);
+                               
//$download_size=filesize($version['file_full_path']);
+                               //header('Content-Length: '.$download_size, 
false);
+                               //readfile($version['file_full_path']);
+                               foreach ($chronos as $chrono_type)
                                {
-                                       // DONE : set up the needed template 
variables
-                                       $this->t->set_var('name', 
$chrono['name']);
-                                       $this->t->set_var('date', 
$GLOBALS['phpgw']->common->show_date($chrono['date']));
-                                       $this->t->set_var('author', 
$GLOBALS['phpgw']->common->grab_owner_name($chrono['creator_id']));
-                                       $this->t->set_var('description', 
$chrono['description']);
-                                       $this->t->set_var('version_label', 
$chrono['version_label']);
-                                       $this->t->set_var('reference', 
$chrono['reference']);
-                                       $this->t->set_var('no', $chrono['no']);
-       
-                                       $this->t->set_var('status_image', 
$GLOBALS['phpgw']->common->image('ged', $chrono['status']."-16"));
+                                       foreach($chrono_type as $chrono)
+                                       {
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$chrono['element_id'];
+                                               
$link_data['version_id']=$chrono['version_id'];
+                                               
+                                               
print($chrono['reference'].",".$chrono['name'].",".$chrono['version_label'].
+                                               
",".$GLOBALS['phpgw']->common->grab_owner_name($chrono['creator_id']).
+                                               
",".$chrono['status'].",".$GLOBALS['phpgw']->common->show_date($chrono['date']).
+                                               
",http://".$_SERVER['SERVER_NAME'].$GLOBALS['phpgw']->link('/index.php', 
$link_data)."\n");
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               header('Expires: '.gmdate('D, d M Y H:i:s') . ' 
GMT'); 
+                               header('Last-Modified: '.gmdate('D, d M Y 
H:i:s') . ' GMT', false); 
+                               header('Cache-Control: must-revalidate', false);
+                               header("Content-type: text/csv", false);
+                               header('Content-Disposition: attachment; 
filename="chrono.csv"', false);
+                               
//$download_size=filesize($version['file_full_path']);
+                               //header('Content-Length: '.$download_size, 
false);
+                               //readfile($version['file_full_path']);
+                               foreach ($chronos as $chrono_type)
+                               {
+                                       foreach($chrono_type as $chrono)
+                                       {
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$chrono['element_id'];
+                                               
$link_data['version_id']=$chrono['version_id'];
+                                               
+                                               
print($chrono['reference'].",".$chrono['name'].",".$chrono['version_label'].
+                                               
",".$GLOBALS['phpgw']->common->grab_owner_name($chrono['creator_id']).
+                                               
",".$chrono['status'].",".$GLOBALS['phpgw']->common->show_date($chrono['date']).
+                                               
",http://".$_SERVER['SERVER_NAME'].$GLOBALS['phpgw']->link('/index.php', 
$link_data)."\n");
+                                       }
+                               }
+               }
+               }
+               else
+               {
+                       $this->set_template_defaults();
+                       $this->display_app_header();
+                       $this->t->set_file(array('chrono_tpl'=>'chrono.tpl'));
+                       $this->t->set_block('chrono_tpl', 'type_block', 
'type_block_handle');
+                       $this->t->set_block('type_block', 'chrono_block', 
'chrono_block_handle');
                        
-                                       $link_data=null;
-                                       
$link_data['menuaction']='ged.ged_ui.browse';
-                                       
$link_data['focused_id']=$chrono['element_id'];
-                                       
$link_data['version_id']=$chrono['version_id'];
-                                       $this->t->set_var('browse_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
-       
+                       // DONE : use the project name instead of root id
+                       $this->t->set_var('lang_chrono_title', lang('Chronos 
for project')." ".$this->ged_dm->get_project_name($project_root));
+                       
+                       if ( isset($chronos))
+                       {
+                               foreach ( $chronos as $type_id => $type_chronos)
+                               {
+                                       
$this->t->set_var('chrono_block_handle', "");
                                        
-                                       if ( $row_class=="row_on")
-                                               $row_class="row_off";
-                                       else
-                                               $row_class="row_on";
+                                       //DONE : Use the detailed label of type 
+                                       $this->t->set_var('doc_type', $type_id);
+                                       $row_class="row_off";
+                                       foreach ( $type_chronos as $chrono)
+                                       {
+                                               // DONE : set up the needed 
template variables
+                                               $this->t->set_var('name', 
$chrono['name']);
+                                               $this->t->set_var('date', 
$GLOBALS['phpgw']->common->show_date($chrono['date']));
+                                               $this->t->set_var('author', 
$GLOBALS['phpgw']->common->grab_owner_name($chrono['creator_id']));
+                                               
$this->t->set_var('description', $chrono['description']);
+                                               
$this->t->set_var('version_label', $chrono['version_label']);
+                                               $this->t->set_var('reference', 
$chrono['reference']);
+                                               $this->t->set_var('no', 
$chrono['no']);
+               
+                                               
$this->t->set_var('status_image', $GLOBALS['phpgw']->common->image('ged', 
$chrono['status']."-16"));
+                               
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$chrono['element_id'];
+                                               
$link_data['version_id']=$chrono['version_id'];
+                                               
$this->t->set_var('browse_link', $GLOBALS['phpgw']->link('/index.php', 
$link_data));
+               
                                                
-                                       $this->t->set_var('row_class', 
$row_class);
-                                       
-                                       $this->t->fp('chrono_block_handle', 
'chrono_block', True);
+                                               if ( $row_class=="row_on")
+                                                       $row_class="row_off";
+                                               else
+                                                       $row_class="row_on";
+                                                       
+                                               $this->t->set_var('row_class', 
$row_class);
+                                               
+                                               
$this->t->fp('chrono_block_handle', 'chrono_block', True);
+                                       }
+                                       $this->t->fp('type_block_handle', 
'type_block', True);
                                }
-                               $this->t->fp('type_block_handle', 'type_block', 
True);
                        }
+                       $this->t->pfp('out', 'chrono_tpl');
                }
-               $this->t->pfp('out', 'chrono_tpl');
        }
        
        function dico()
        {
                $project_root=$this->get_var('project_root',array('GET'));
+               $mode=$this->get_var('mode', array('GET', 'POST'));
                
-               $this->set_template_defaults();
-               $this->display_app_header();
-               $this->t->set_file(array('chrono_tpl'=>'chrono.tpl'));
-               $this->t->set_block('chrono_tpl', 'type_block', 
'type_block_handle');
-               $this->t->set_block('type_block', 'chrono_block', 
'chrono_block_handle');
-               
-               // DONE : use the project name instead of root id
-               $this->t->set_var('lang_chrono_title', lang('Documents list for 
project')." ".$this->ged_dm->get_project_name($project_root));
-               
                $all_versions=null;
                $all_versions=$this->ged_dm->list_all_versions($project_root);
                
-               if ( isset($all_versions))
+               if ( !is_null($mode) && $mode == "csv")
                {
-                       foreach ( $all_versions as $type_id => $type_version)
+                       if ($this->browser->is_ie())
                        {
-                               $this->t->set_var('chrono_block_handle', "");
-                               
-                               //DONE : Use the detailed label of type 
-                               $this->t->set_var('doc_type', $type_id);
-                               $row_class="row_off";
-                               foreach ( $type_version as $version)
+                               ini_set('zlib.output_compression', 'Off');
+                               header('Pragma: private');
+                               header('Cache-control: private, 
must-revalidate');
+                               header("Content-Type: 
application/force-download");
+                               header('Content-Disposition: attachment; 
filename="dico.csv"', false);
+                               foreach ($all_versions as $version_type)
                                {
-                                       // DONE : set up the needed template 
variables
-                                       $this->t->set_var('name', 
$version['name']);
-                                       $this->t->set_var('date', 
$GLOBALS['phpgw']->common->show_date($version['date']));
-                                       $this->t->set_var('author', 
$GLOBALS['phpgw']->common->grab_owner_name($version['creator_id']));
-                                       $this->t->set_var('description', 
$version['description']);
-                                       $this->t->set_var('version_label', 
$version['version_label']);
-                                       $this->t->set_var('reference', 
$version['reference']);
-                                       $this->t->set_var('no', $version['no']);
-       
-                                       $this->t->set_var('status_image', 
$GLOBALS['phpgw']->common->image('ged', $version['status']."-16"));
+                                       foreach($version_type as $version)
+                                       {
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$version['element_id'];
+                                               
$link_data['version_id']=$version['version_id'];
+                                               
+                                               
print($version['reference'].",".$version['name'].",".$version['version_label'].
+                                               
",".$GLOBALS['phpgw']->common->grab_owner_name($version['creator_id']).
+                                               
",".$version['status'].",".$GLOBALS['phpgw']->common->show_date($version['date']).
+                                               
",http://".$_SERVER['SERVER_NAME'].$GLOBALS['phpgw']->link('/index.php', 
$link_data)."\n");
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               header('Expires: '.gmdate('D, d M Y H:i:s') . ' 
GMT'); 
+                               header('Last-Modified: '.gmdate('D, d M Y 
H:i:s') . ' GMT', false); 
+                               header('Cache-Control: must-revalidate', false);
+                               header("Content-type: text/csv", false);
+                               header('Content-Disposition: attachment; 
filename="dico.csv"', false);
+                               foreach ($all_versions as $version_type)
+                               {
+                                       foreach($version_type as $version)
+                                       {
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$version['element_id'];
+                                               
$link_data['version_id']=$version['version_id'];
+                                               
+                                               
print($version['reference'].",".$version['name'].",".$version['version_label'].
+                                               
",".$GLOBALS['phpgw']->common->grab_owner_name($version['creator_id']).
+                                               
",".$version['status'].",".$GLOBALS['phpgw']->common->show_date($version['date']).
+                                               
",http://".$_SERVER['SERVER_NAME'].$GLOBALS['phpgw']->link('/index.php', 
$link_data)."\n");
+                                       }
+                               }
+               }
+               }
+               else
+               {
+                       $this->set_template_defaults();
+                       $this->display_app_header();
+                       $this->t->set_file(array('chrono_tpl'=>'chrono.tpl'));
+                       $this->t->set_block('chrono_tpl', 'type_block', 
'type_block_handle');
+                       $this->t->set_block('type_block', 'chrono_block', 
'chrono_block_handle');
                        
-                                       $link_data=null;
-                                       
$link_data['menuaction']='ged.ged_ui.browse';
-                                       
$link_data['focused_id']=$version['element_id'];
-                                       
$link_data['version_id']=$version['version_id'];
-                                       $this->t->set_var('browse_link', 
$GLOBALS['phpgw']->link('/index.php', $link_data));
-       
+                       // DONE : use the project name instead of root id
+                       $this->t->set_var('lang_chrono_title', lang('Documents 
list for project')." ".$this->ged_dm->get_project_name($project_root));
+                                               
+                       if ( isset($all_versions))
+                       {
+                               foreach ( $all_versions as $type_id => 
$type_version)
+                               {
+                                       
$this->t->set_var('chrono_block_handle', "");
                                        
-                                       if ( $row_class=="row_on")
-                                               $row_class="row_off";
-                                       else
-                                               $row_class="row_on";
+                                       //DONE : Use the detailed label of type 
+                                       $this->t->set_var('doc_type', $type_id);
+                                       $row_class="row_off";
+                                       foreach ( $type_version as $version)
+                                       {
+                                               // DONE : set up the needed 
template variables
+                                               $this->t->set_var('name', 
$version['name']);
+                                               $this->t->set_var('date', 
$GLOBALS['phpgw']->common->show_date($version['date']));
+                                               $this->t->set_var('author', 
$GLOBALS['phpgw']->common->grab_owner_name($version['creator_id']));
+                                               
$this->t->set_var('description', $version['description']);
+                                               
$this->t->set_var('version_label', $version['version_label']);
+                                               $this->t->set_var('reference', 
$version['reference']);
+                                               $this->t->set_var('no', 
$version['no']);
+               
+                                               
$this->t->set_var('status_image', $GLOBALS['phpgw']->common->image('ged', 
$version['status']."-16"));
+                               
+                                               $link_data=null;
+                                               
$link_data['menuaction']='ged.ged_ui.browse';
+                                               
$link_data['focused_id']=$version['element_id'];
+                                               
$link_data['version_id']=$version['version_id'];
+                                               
$this->t->set_var('browse_link', $GLOBALS['phpgw']->link('/index.php', 
$link_data));
+               
                                                
-                                       $this->t->set_var('row_class', 
$row_class);
-                                       
-                                       $this->t->fp('chrono_block_handle', 
'chrono_block', True);
+                                               if ( $row_class=="row_on")
+                                                       $row_class="row_off";
+                                               else
+                                                       $row_class="row_on";
+                                                       
+                                               $this->t->set_var('row_class', 
$row_class);
+                                               
+                                               
$this->t->fp('chrono_block_handle', 'chrono_block', True);
+                                       }
+                                       $this->t->fp('type_block_handle', 
'type_block', True);
                                }
-                               $this->t->fp('type_block_handle', 'type_block', 
True);
                        }
+                       $this->t->pfp('out', 'chrono_tpl');
                }
-               $this->t->pfp('out', 'chrono_tpl');
        }
-       
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]