]> git.llucax.com Git - mecon/meconlib.git/blob - lib/MLIB/Graph/external/jpgraph/src/utils/jpdocgen/jpgendbdriver.php
Se agrega un ejemplo sobre la utilizacion de los PDF con la nueva clase
[mecon/meconlib.git] / lib / MLIB / Graph / external / jpgraph / src / utils / jpdocgen / jpgendbdriver.php
1 <?php
2 //==============================================================================
3 // Name:        JPGENDBDRIVER.PHP
4 // Description: Driver for scanning project files to update the DB
5 // Created:     2002-06-06 22:50 
6 // Author:              johanp@aditus.nu
7 // Version:     $Id: jpgendbdriver.php,v 1.10 2002/09/02 14:26:27 aditus Exp $
8 //
9 // License:     QPL 1.0
10 // Copyright (C) 2002 Johan Persson
11 //
12 //==============================================================================
13
14 include 'de_utils.php';
15 include 'jpgendb.php';
16
17 class ScanProjFiles {
18         var $iProjname;
19         var $iDBUtils;
20         var $iDB;
21         
22         function ScanProjFiles($aDBUtils) {
23                 $this->iDBUtils = $aDBUtils;
24                 $this->iDB = $aDBUtils->iDBServer;
25         }
26         
27         function Run($aProjname,$aForceUpdate=false) {
28                 $this->iProjname = $aProjname;
29                 
30                 HTMLGenerator::CloseWinButton();
31                 
32                 echo "<b>Scanning files for project '$aProjname'</b><br>";
33                                 
34                 // Find full filename of all project files in the project
35                 $proj = $this->iDBUtils->GetProject($aProjname);
36                 $projidx = $proj['fld_key'];
37                 
38                 echo "<i>($proj[fld_projdir])</i><p>\n";
39                 
40                 $q = "SELECT * FROM tbl_projfiles WHERE fld_projidx=$projidx";
41                 $res = $this->iDB->Query($q);
42                 $n = $res->NumRows();
43                 $ptimer = new JpgTimer();
44                 while( $n-- > 0 ) {
45                         $r = $res->Fetch();
46                         $fname = $proj['fld_projdir'].'/'.$r['fld_name'];
47                         $modtime=@filemtime($fname);
48                         if( $modtime == false ) {
49                                 die("Can't access file: $fname");
50                         }
51                         
52                         $dbtime = strtotime($r['fld_dbupdtime']);
53                         if( $aForceUpdate || $modtime > $dbtime ) {
54                             
55                                 echo "Parsing '".basename($fname)."'...\n";flush();
56                                 $dbdriver = new DBDriver($aProjname,$fname,$this->iDB);
57                                 $ptimer->Push();
58                                 $dbdriver->Run();
59                                 $t = round($ptimer->Pop()/1000,2);
60                                 $q = "UPDATE tbl_projfiles SET fld_dbupdtime=now() WHERE fld_key=".$r['fld_key'];
61                                 $this->iDB->Query($q);
62                                 echo "[in $t s]<br>\n";
63                         }
64                         else {
65                                 echo "DB is up to date for '".basename($fname)."'<br>\n";
66                         }
67                 }
68                 echo "<p><h3>Done.</h3>";
69                 HTMLGenerator::CloseWinButton();
70         }
71 }
72
73 class DbGenDriver extends DocEditDriver {
74         function Run($aForceUpdate=false) {
75                 if( !empty($this->iProjidx) && $this->iProjidx > 0 ) {
76                         $scan = new ScanProjFiles($this->iDBUtils);
77                         $projname = $this->iDBUtils->GetProjNameForKey($this->iProjidx);//$regen_projidx);
78                         $scan->Run($projname,$aForceUpdate);
79                 }
80                 else echo "No project index";
81         }
82 }
83
84 $force    = @$HTTP_GET_VARS['force'] ;
85
86 if( isset($force) && $force=='true' )
87         $force=1;
88 else
89         $force=0;
90
91 $driver = new DbGenDriver();
92 $driver->Run($force);
93 $driver->Close();
94 ?>