protected $in;\r
protected $uncompressed;\r
protected $log;\r
- protected $log_pointer;\r
+ protected $common_log_pointer;\r
+ protected $pages_log_pointers;\r
protected $infos;\r
protected $cropped;\r
protected $uncropped;\r
\r
public function init()\r
{\r
- $this->out = WS_DOCS. '/' . $this->document_id . '/';\r
- $this->log = $this->out . 'log.txt';\r
+ $this->out = WS_DOCS . '/' . $this->document_id . '/';\r
+ $this->log = $this->out . '/logs/';\r
$this->in = $this->out . 'original.pdf';\r
$this->uncompressed = $this->out . 'uncompressed.pdf';\r
$this->infos = $this->out . 'infos.txt';\r
if (!file_exists($this->out)) {\r
mkdir($this->out, 0755, true);\r
+ mkdir($this->out . '/logs/');\r
}\r
$this->cropped = $this->out . 'crop.pdf';\r
$this->uncropped = $this->out . 'uncrop.pdf';\r
- $this->log_pointer = fopen($this->log, 'a');\r
+ $this->common_log_pointer = fopen($this->log . '/commons.log', 'a');\r
+ $this->pages_log_pointers = array();\r
}\r
\r
public function copyOriginal($tmp_file)\r
\r
public function makeMiniShot($page)\r
{\r
- $this->makeShotFixedWidth($page, 'p', 100, 90, 4, 'GS');\r
+ $this->makeShotFixedWidth($page, 'p', 200, 90, 4, 'GS');\r
}\r
\r
public function makeRealShot($page)\r
\r
$gs->setArg(null, $in);\r
$gs->execute();\r
- $this->addToLog($gs);\r
+ $this->addToLog($gs,true,$page);\r
}\r
\r
protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)\r
$pdftoppm->setArg(null, $in);\r
$pdftoppm->setArg(null, $this->out . 'ppm');\r
$pdftoppm->execute();\r
- $this->addToLog($pdftoppm);\r
+ $this->addToLog($pdftoppm,true,$page);\r
\r
$startpage = is_null($page)?1:$page;\r
\r
$pnmtojpeg->setManualArg($ppmfile);\r
$pnmtojpeg->execute();\r
\r
- $this->addToLog($pnmtojpeg, false);\r
+ $this->addToLog($pnmtojpeg, false,$i);\r
unlink($ppmfile);\r
}\r
}\r
}\r
// On teste si le fichier est écrit et qu'il a été généré par le premier niveau\r
if ($method < self::POLY2BITMAP && $written) {\r
- $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects);\r
+ $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects,$page);\r
}\r
\r
if (!$written || $overflow || $overflowObjects) {\r
}\r
}\r
\r
- protected function checkObjectsNumber($file, $maxObjects)\r
+ protected function checkObjectsNumber($file, $maxObjects,$page)\r
{\r
$swfdump = new cubeCommandLine('swfdump', null, true);\r
$swfdump->setPath(CONVERTER_PATH);\r
$pdf2swf->setArg('output', $this->out . 'p%.swf');\r
$pdf2swf->execute();\r
\r
- $this->addToLog($pdf2swf, true);\r
+ $this->addToLog($pdf2swf, true,$page);\r
} else {\r
$this->pdf2swfBarbare($page, $resolution, $quality, $method);\r
}\r
$swfcombine->setArg(null, ROOT . '/swf/as3Container.swf');\r
$swfcombine->setManualArg('content=' . $swffile);\r
$swfcombine->execute();\r
- $this->addToLog($swfcombine);\r
+ $this->addToLog($swfcombine,true,$page);\r
}\r
\r
protected function pdf2swfBarbare($page, $resolution = 150, $quality = 85, $method = 4)\r
$jpeg2swf->execute();\r
$this->addToLog($jpeg2swf);\r
// Suppression du jpeg\r
- @unlink($this->out . '/barbare' . $page . '.jpg') ;\r
+ @unlink($this->out . '/barbare' . $page . '.jpg',true,$page) ;\r
\r
return '';\r
}\r
\r
- public function addToLog($cl, $output = true)\r
+ public function addToLog($cl, $output = true, $page = null)\r
{\r
if ($cl instanceof cubeCommandLine) {\r
$c = '--- Exécuté en ' . $cl->execTime . " s\n" . $cl->commande . "\n\n";\r
$c = '--- ' . "\n\n";\r
$c .= $cl . "\n\n";\r
}\r
- fwrite($this->log_pointer, $c);\r
+\r
+ if (is_null($page)) {\r
+ $pointer = $this->common_log_pointer;\r
+ } else {\r
+ if (isset($this->pages_log_pointers[$page])) {\r
+ $pointer = $this->pages_log_pointers;\r
+ } else {\r
+ $pointer = fopen($this->log . '/p' . $page . '.log', 'a');\r
+ $this->pages_log_pointers[$page] = $pointer;\r
+ }\r
+ }\r
+\r
+ fwrite($pointer, $c);\r
}\r
\r
public function __destruct()\r
{\r
- if (isset($this->log_pointer) && is_resource($this->log_pointer)) {\r
- fclose($this->log_pointer);\r
+ if (isset($this->common_log_pointer) && is_resource($this->common_log_pointer)) {\r
+ fclose($this->common_log_pointer);\r
+ }\r
+\r
+ foreach($this->pages_log_pointers as $p) {\r
+ if (!is_null($p) && is_resource($p)) {\r
+ fclose($p);\r
+ }\r
}\r
}\r
}\r