From de903a331cdec25d7aad9b533009cc6f99c1e142 Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Thu, 18 Jan 2018 14:27:17 +0100 Subject: [PATCH] #13 add batch to convert and delete old files --- .gitignore | 4 + core/Controllers/DocserverController.php | 2 +- core/Controllers/StoreController.php | 3 +- core/Models/DatabasePDO.php | 13 + .../Controllers/ProcessConvertController.php | 19 +- .../Controllers/ProcessFulltextController.php | 8 +- .../ProcessManageConvertController.php | 6 +- .../ProcessThumbnailsController.php | 2 +- modules/convert/Test/ProcessConvertTest.php | 24 +- .../convert/Test/ProcessManageConvertTest.php | 286 ++++++- modules/convert/Test/Samples/test.html | 8 + modules/convert/Test/Samples/test.odt | Bin 0 -> 8726 bytes modules/convert/Test/Samples/test.pdf | Bin 0 -> 7945 bytes modules/convert/Test/Samples/test.txt | 1 + modules/convert/batch/LoggerLog4php.php | 7 + modules/convert/batch/batch_tools.php | 20 +- modules/convert/batch/config/config.xml | 44 +- modules/convert/batch/fill_stack.php | 38 +- modules/convert/batch/load_fill_stack.php | 38 +- modules/convert/batch/process_stack.php | 29 +- modules/convert/batch/verif_index.php | 7 + modules/convert/services/ManageConvert.php | 42 - .../services/ManageConvertAbstract.php | 164 ---- modules/convert/services/ProcessConvert.php | 42 - .../services/ProcessConvertAbstract.php | 592 -------------- modules/convert/services/ProcessFulltext.php | 42 - .../services/ProcessFulltextAbstract.php | 740 ------------------ .../convert/services/ProcessThumbnails.php | 42 - .../services/ProcessThumbnailsAbstract.php | 501 ------------ 29 files changed, 394 insertions(+), 2330 deletions(-) create mode 100644 modules/convert/Test/Samples/test.html create mode 100644 modules/convert/Test/Samples/test.odt create mode 100644 modules/convert/Test/Samples/test.pdf create mode 100644 modules/convert/Test/Samples/test.txt delete mode 100644 modules/convert/services/ManageConvert.php delete mode 100644 modules/convert/services/ManageConvertAbstract.php delete mode 100644 modules/convert/services/ProcessConvert.php delete mode 100644 modules/convert/services/ProcessConvertAbstract.php delete mode 100644 modules/convert/services/ProcessFulltext.php delete mode 100644 modules/convert/services/ProcessFulltextAbstract.php delete mode 100644 modules/convert/services/ProcessThumbnails.php delete mode 100644 modules/convert/services/ProcessThumbnailsAbstract.php diff --git a/.gitignore b/.gitignore index 68d9b18a307..1c765e659bf 100755 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ core/Test/build/ apps/maarch_entreprise/tmp/* /nbproject/private/apps/maarch_entreprise/define_custom.php apps/maarch_entreprise/js/angular/main.bundle.js +modules/convert/batch/scripts/launch_fulltext_letterbox.sh +modules/convert/batch/scripts/launch_convert_letterbox.sh +modules/convert/batch/config/config_only_indexes.xml +modules/convert/batch/tmp/ diff --git a/core/Controllers/DocserverController.php b/core/Controllers/DocserverController.php index d8813ff39e4..b011be2edcd 100755 --- a/core/Controllers/DocserverController.php +++ b/core/Controllers/DocserverController.php @@ -107,7 +107,7 @@ class DocserverController umask(0022); chmod($monthPath, 0770); } else { - return ['errors' => '[createPathOnDocServer] Folder alreay exists, workbatch already exist:' . $pathToDS]; + //return ['errors' => '[createPathOnDocServer] Folder alreay exists, workbatch already exist:' . $pathToDS]; } } diff --git a/core/Controllers/StoreController.php b/core/Controllers/StoreController.php index 521ff4424e5..42aa78df6df 100644 --- a/core/Controllers/StoreController.php +++ b/core/Controllers/StoreController.php @@ -99,7 +99,8 @@ class StoreController return ['errors' => '[storeRessourceOnDocserver] FileInfos.tmpDir does not exist']; } if (!file_exists($aArgs['fileInfos']['tmpDir'] . $aArgs['fileInfos']['tmpFileName'])) { - return ['errors' => '[storeRessourceOnDocserver] FileInfos.tmpFileName does not exist']; + return ['errors' => '[storeRessourceOnDocserver] FileInfos.tmpFileName does not exist ' + . $aArgs['fileInfos']['tmpDir'] . $aArgs['fileInfos']['tmpFileName']]; } $aArgs['docserverTypeId'] = empty($aArgs['docserverTypeId']) ? 'DOC' : $aArgs['docserverTypeId']; diff --git a/core/Models/DatabasePDO.php b/core/Models/DatabasePDO.php index 83685fbdeaa..9422820642c 100755 --- a/core/Models/DatabasePDO.php +++ b/core/Models/DatabasePDO.php @@ -35,6 +35,19 @@ class DatabasePDO $path = 'apps/maarch_entreprise/xml/config.xml'; } + if (!file_exists($path)) { + if ( + file_exists($GLOBALS['MaarchDirectory'] + . "custom/{$customId}/apps/maarch_entreprise/xml/config.xml") + ) { + $path = $GLOBALS['MaarchDirectory'] + . "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; + } else { + $path = $GLOBALS['MaarchDirectory'] + . 'apps/maarch_entreprise/xml/config.xml'; + } + } + $server = ''; $port = ''; $name = ''; diff --git a/modules/convert/Controllers/ProcessConvertController.php b/modules/convert/Controllers/ProcessConvertController.php index f5b63b707d4..27276ed007c 100644 --- a/modules/convert/Controllers/ProcessConvertController.php +++ b/modules/convert/Controllers/ProcessConvertController.php @@ -131,7 +131,7 @@ class ProcessConvertController } $res = ResModel::getById(['resId' => $resId, 'resTable' => $args['resTable']]); - + if ($res['res_id'] <> '') { $resourcePath = ResDocserverModel::getSourceResourcePath( [ @@ -182,7 +182,6 @@ class ProcessConvertController 'error' => '', ); } - if ($resultOfConversion['status'] <> '0') { ProcessConvertModel::manageErrorOnDb( ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] @@ -194,7 +193,7 @@ class ProcessConvertController $storeResult = StoreController::storeResourceOnDocServer([ 'collId' => $collId, 'fileInfos' => [ - 'tmpDir' => CoreConfigModel::getTmpPath(), + 'tmpDir' => $tmpDir, 'size' => filesize($fileNameOnTmp), 'format' => 'PDF', 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.pdf', @@ -202,7 +201,6 @@ class ProcessConvertController 'docserverTypeId' => 'CONVERT' ]); - if (empty($storeResult)) { $returnArray = array( 'status' => '1', @@ -216,6 +214,19 @@ class ProcessConvertController return $returnArray; } + if (!empty($storeResult['errors'])) { + $returnArray = array( + 'status' => '1', + 'value' => '', + 'error' => $storeResult['errors'] . ' error for convert:' + . $fileNameOnTmp, + ); + ProcessConvertModel::manageErrorOnDb( + ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] + ); + return $returnArray; + } + $targetDs = DocserverModel::getById(['id' => $storeResult['docserver_id']]); // LogsController::info(['message'=>'avant update', 'code'=>19, ]); diff --git a/modules/convert/Controllers/ProcessFulltextController.php b/modules/convert/Controllers/ProcessFulltextController.php index 3d39152c58e..54a3a3bf514 100644 --- a/modules/convert/Controllers/ProcessFulltextController.php +++ b/modules/convert/Controllers/ProcessFulltextController.php @@ -43,19 +43,19 @@ class ProcessFulltextController public function __construct($pdftotext = 'pdftotext') { - // Storing text in lucpreene index + // Storing text in lucene index set_include_path('apps/maarch_entreprise/tools/' . PATH_SEPARATOR . get_include_path() ); - if(!@include('Zend/Search/Lucene.php')) { + //if(!@include('Zend/Search/Lucene.php')) { set_include_path($GLOBALS['MaarchDirectory'] . 'apps/maarch_entreprise/tools/' . PATH_SEPARATOR . get_include_path() ); require_once("Zend/Search/Lucene.php"); - } + //} $this->pdftotext = $pdftotext; } @@ -256,7 +256,7 @@ class ProcessFulltextController $storeResult = StoreController::storeResourceOnDocServer([ 'collId' => $collId, 'fileInfos' => [ - 'tmpDir' => CoreConfigModel::getTmpPath(), + 'tmpDir' => $tmpDir, 'size' => filesize($fileNameOnTmp), 'format' => 'TXT', 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.txt', diff --git a/modules/convert/Controllers/ProcessManageConvertController.php b/modules/convert/Controllers/ProcessManageConvertController.php index 4d8964681b9..0c0afa889f2 100644 --- a/modules/convert/Controllers/ProcessManageConvertController.php +++ b/modules/convert/Controllers/ProcessManageConvertController.php @@ -188,8 +188,10 @@ class ProcessManageConvertController 'path_to_lucene' => $path_to_lucene ); } - $ProcessConvertService = new ProcessFulltextController(); - $resultOfConversion = $ProcessConvertService->fulltext($params); + $ProcessConvertServiceFulltext = new ProcessFulltextController(); + + $resultOfConversion = $ProcessConvertServiceFulltext->fulltext($params); + if ($resultOfConversion['status'] <> '0') { $returnArray = array( 'status' => '1', diff --git a/modules/convert/Controllers/ProcessThumbnailsController.php b/modules/convert/Controllers/ProcessThumbnailsController.php index c5c9b23b43e..39a4545e0fd 100644 --- a/modules/convert/Controllers/ProcessThumbnailsController.php +++ b/modules/convert/Controllers/ProcessThumbnailsController.php @@ -199,7 +199,7 @@ class ProcessThumbnailsController $storeResult = StoreController::storeResourceOnDocServer([ 'collId' => $collId, 'fileInfos' => [ - 'tmpDir' => CoreConfigModel::getTmpPath(), + 'tmpDir' => $tmpDir, 'size' => filesize($fileNameOnTmp), 'format' => 'PNG', 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.png', diff --git a/modules/convert/Test/ProcessConvertTest.php b/modules/convert/Test/ProcessConvertTest.php index c25c0dcc3e3..301729d109a 100644 --- a/modules/convert/Test/ProcessConvertTest.php +++ b/modules/convert/Test/ProcessConvertTest.php @@ -22,23 +22,13 @@ class ProcessConvertTest extends TestCase ] ); - $path = $_SESSION['config']['tmppath'] . '/test/'; + $samplePath = 'modules/convert/Test/Samples/'; - if (!is_dir($path)) { - mkdir($path); - } - - $fileSource = 'test_source.txt'; - - if (file_exists($path . $fileSource)) { - unlink($path . $fileSource); - } - - $fp = fopen($path . $fileSource, 'a'); - fwrite($fp, 'a unit test for PHP CONVERSION lorem ipsum...'); - fclose($fp); + //SAMPLE TXT + $fileSource = 'test.txt'; + $fileFormat = 'txt'; - $fileContent = file_get_contents($path . $fileSource, FILE_BINARY); + $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); $encodedFile = base64_encode($fileContent); //echo $encodedFile . PHP_EOL;exit; @@ -48,7 +38,7 @@ class ProcessConvertTest extends TestCase $data, array( 'column' => 'subject', - 'value' => 'UNIT TEST from slim', + 'value' => 'UNIT TEST CONVERT from slim', 'type' => 'string', ) ); @@ -85,7 +75,7 @@ class ProcessConvertTest extends TestCase 'data' => $data, 'collId' => 'letterbox_coll', 'table' => 'res_letterbox', - 'fileFormat' => 'txt', + 'fileFormat' => $fileFormat, 'status' => 'new', ]; diff --git a/modules/convert/Test/ProcessManageConvertTest.php b/modules/convert/Test/ProcessManageConvertTest.php index 470e953f990..106657787f8 100644 --- a/modules/convert/Test/ProcessManageConvertTest.php +++ b/modules/convert/Test/ProcessManageConvertTest.php @@ -22,23 +22,205 @@ class ManageProcessConvertTest extends TestCase ] ); - $path = $_SESSION['config']['tmppath'] . '/test/'; + $samplePath = 'modules/convert/Test/Samples/'; - if (!is_dir($path)) { - mkdir($path); - } + //SAMPLE TXT + $fileSource = 'test.txt'; + $fileFormat = 'txt'; - $fileSource = 'test_source.txt'; + $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); + $encodedFile = base64_encode($fileContent); + //echo $encodedFile . PHP_EOL;exit; + + $data = []; + + array_push( + $data, + array( + 'column' => 'subject', + 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'type_id', + 'value' => 110, + 'type' => 'integer', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t1', + 'value' => 'TEST', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t10', + 'value' => 'lgi@maarch.org', + 'type' => 'string', + ) + ); + + $aArgs = [ + 'encodedFile' => $encodedFile, + 'data' => $data, + 'collId' => 'letterbox_coll', + 'table' => 'res_letterbox', + 'fileFormat' => $fileFormat, + 'status' => 'new', + ]; + + $request = \Slim\Http\Request::createFromEnvironment($environment); + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + + $resIdTxt = $responseBody->resId; + + //SAMPLE PDF + $fileSource = 'test.pdf'; + $fileFormat = 'pdf'; + + $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); + $encodedFile = base64_encode($fileContent); + //echo $encodedFile . PHP_EOL;exit; + + $data = []; + + array_push( + $data, + array( + 'column' => 'subject', + 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'type_id', + 'value' => 110, + 'type' => 'integer', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t1', + 'value' => 'TEST', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t10', + 'value' => 'lgi@maarch.org', + 'type' => 'string', + ) + ); + + $aArgs = [ + 'encodedFile' => $encodedFile, + 'data' => $data, + 'collId' => 'letterbox_coll', + 'table' => 'res_letterbox', + 'fileFormat' => $fileFormat, + 'status' => 'new', + ]; + + $request = \Slim\Http\Request::createFromEnvironment($environment); + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + + $resIdPdf = $responseBody->resId; + + //SAMPLE ODT + $fileSource = 'test.odt'; + $fileFormat = 'odt'; + + $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); + $encodedFile = base64_encode($fileContent); + //echo $encodedFile . PHP_EOL;exit; - if (file_exists($path . $fileSource)) { - unlink($path . $fileSource); - } + $data = []; - $fp = fopen($path . $fileSource, 'a'); - fwrite($fp, 'a unit test for PHP CONVERSION lorem ipsum...'); - fclose($fp); + array_push( + $data, + array( + 'column' => 'subject', + 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', + 'type' => 'string', + ) + ); - $fileContent = file_get_contents($path . $fileSource, FILE_BINARY); + array_push( + $data, + array( + 'column' => 'type_id', + 'value' => 110, + 'type' => 'integer', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t1', + 'value' => 'TEST', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'custom_t10', + 'value' => 'lgi@maarch.org', + 'type' => 'string', + ) + ); + + $aArgs = [ + 'encodedFile' => $encodedFile, + 'data' => $data, + 'collId' => 'letterbox_coll', + 'table' => 'res_letterbox', + 'fileFormat' => $fileFormat, + 'status' => 'new', + ]; + + $request = \Slim\Http\Request::createFromEnvironment($environment); + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + + $resIdOdt = $responseBody->resId; + + //SAMPLE HTML + $fileSource = 'test.html'; + $fileFormat = 'html'; + + $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); $encodedFile = base64_encode($fileContent); //echo $encodedFile . PHP_EOL;exit; @@ -48,7 +230,7 @@ class ManageProcessConvertTest extends TestCase $data, array( 'column' => 'subject', - 'value' => 'UNIT TEST from slim', + 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', 'type' => 'string', ) ); @@ -85,7 +267,7 @@ class ManageProcessConvertTest extends TestCase 'data' => $data, 'collId' => 'letterbox_coll', 'table' => 'res_letterbox', - 'fileFormat' => 'txt', + 'fileFormat' => $fileFormat, 'status' => 'new', ]; @@ -96,13 +278,77 @@ class ManageProcessConvertTest extends TestCase $response = $action->create($fullRequest, $response); $responseBody = json_decode((string)$response->getBody()); - $resId = $responseBody->resId; + $resIdHtml = $responseBody->resId; + + /***************************************************************************/ + + //test TXT + $request = \Slim\Http\Request::createFromEnvironment($environment); + $action = new \Convert\Controllers\ProcessManageConvertController(); + + $aArgs = [ + 'collId' => 'letterbox_coll', + 'resTable' => 'res_letterbox', + 'adrTable' => 'adr_letterbox', + 'resId' => $resIdTxt, + 'tmpDir' => $_SESSION['config']['tmppath'], + 'createZendIndex' => true + ]; + + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + $status = $responseBody->status; + + $this->assertEquals('0', $status); + + //test PDF + $request = \Slim\Http\Request::createFromEnvironment($environment); + $action = new \Convert\Controllers\ProcessManageConvertController(); + + $aArgs = [ + 'collId' => 'letterbox_coll', + 'resTable' => 'res_letterbox', + 'adrTable' => 'adr_letterbox', + 'resId' => $resIdPdf, + 'tmpDir' => $_SESSION['config']['tmppath'], + 'createZendIndex' => true + ]; + + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + $status = $responseBody->status; + + $this->assertEquals('0', $status); + + //test ODT + $request = \Slim\Http\Request::createFromEnvironment($environment); + $action = new \Convert\Controllers\ProcessManageConvertController(); + + $aArgs = [ + 'collId' => 'letterbox_coll', + 'resTable' => 'res_letterbox', + 'adrTable' => 'adr_letterbox', + 'resId' => $resIdOdt, + 'tmpDir' => $_SESSION['config']['tmppath'], + 'createZendIndex' => true + ]; + + $response = new \Slim\Http\Response(); + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); + + $response = $action->create($fullRequest, $response); + $responseBody = json_decode((string)$response->getBody()); + $status = $responseBody->status; - if (!defined("_RES_ID_TEST_CONVERT")) { - define("_RES_ID_TEST_CONVERT", $resId); - } + $this->assertEquals('0', $status); - //real test + //test HTML $request = \Slim\Http\Request::createFromEnvironment($environment); $action = new \Convert\Controllers\ProcessManageConvertController(); @@ -110,7 +356,7 @@ class ManageProcessConvertTest extends TestCase 'collId' => 'letterbox_coll', 'resTable' => 'res_letterbox', 'adrTable' => 'adr_letterbox', - 'resId' => _RES_ID_TEST_CONVERT, + 'resId' => $resIdHtml, 'tmpDir' => $_SESSION['config']['tmppath'], 'createZendIndex' => true ]; diff --git a/modules/convert/Test/Samples/test.html b/modules/convert/Test/Samples/test.html new file mode 100644 index 00000000000..974952b211c --- /dev/null +++ b/modules/convert/Test/Samples/test.html @@ -0,0 +1,8 @@ +<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></head> + <!--<body id="validation_page" + onload="javascript:moveTo(0,0);"> + <div id="template_content" style="width:100%;">--> + <body><p style="text-align: center;" data-mce-style="text-align: center;"><span style="font-size: small; text-decoration: underline;" data-mce-style="font-size: small; text-decoration: underline;">ENREGISTREMENT DEMANDE Allo Mairie - DIVERS</span></p><p style="text-align: center;" data-mce-style="text-align: center;"> </p><table style="border: 1pt solid #000000; width: 800px; background-color: #40a497;" data-mce-style="border: 1pt solid #000000; width: 800px; background-color: #40a497;" cellpadding="5" cellspacing="1" border="1"><tbody><tr><td style="width: 200px;" data-mce-style="width: 200px;">DECLARATION DU BESOIN</td><td>DATE: 17-11-2015</td><td>HEURE: 18:01:46</td></tr></tbody></table><table style="border: 1pt solid #000000; width: 800px;" data-mce-style="border: 1pt solid #000000; width: 800px;" cellpadding="5" cellspacing="1" border="1"><tbody><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">OBJET</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> laurent</td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DATE ET HEURE ESTIMEES DU DECLENCHEMENT</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">IMPLANTATION / LOCALISATION</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> montest</td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DESCRIPTION</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">ETENDUE DU PROBLEME</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">NATURE DU DESAGREMENT</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DELAIS DE TRAITEMENT SOUHAITE</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">AUTRES OBSERVATIONS</td><td> </td></tr></tbody></table><p><br data-mce-bogus="1"></p> <!--</div> + </body> + </html>--> + </body></html> \ No newline at end of file diff --git a/modules/convert/Test/Samples/test.odt b/modules/convert/Test/Samples/test.odt new file mode 100644 index 0000000000000000000000000000000000000000..3038c23914d8df78dbda22d8437ab599bf36509b GIT binary patch literal 8726 zcmch6bzGEN*Y?nzf`pWW(%q5*(kUURbjMIbm!widiF64=OLq!LN_R>(LpK87aNg%U zdVD?Sd!Fx)Z_RIhv-iwg*L|<G@4fck>r#<NKqLSFPyql%c}@l04o=L+007|b4f_gU zV_{<ga<elru(PwaFfssH*aF#{fyS)1296evthRP0Kx11YCmRzWh!tew3R3wC8J55< zcorT2xO)@B$kff9Yz%=07S@hzpg)_ec0jXW6(wmbbW(KKU$A6lB-LP_l>h)702Kk& zYQ65<gmti06x5~EHMR9D9Q1W{t!!+pfKC<;J`UCvcD5iF2WuB6drv1j_kakGz{pTf zTd=QNjK6bIh^Jpb@Vj?G!6Bgmq0zo!31QJOVNnTjVE@?Y@RaDc2{B<YA7Vem#V5r@ z$0x)kCM3L#`52m%mztiLo)Z5lJ@ykMtuiYX0?ACz$ScVHm|u{eUsO_FQczn~R9R6` zU0YRGQ_|4TP}ST~*3e(m*w*y9t+u7Rt*-b>T}8|1`k{{cg~8^wFRd+|J>8w{tv$mX z1Cw8e#`{JlM@I%`M|www24|+GyT;cBrdH>7&KBqApbJC0tJ7<nQ0V%?-qy<c!THwF z#p%)B>B-5#+116_>CMdzEG)OTw}{<+AXsFAWhKScU8kYb-AeG{1V}2$@5&9ClmZr* z%`vJv+*<WjmI$EPx3|h)zJzx)+Bobk(P<RK^mx_xKyEn%EPvP*rG=J`?Bz{zhXsD8 z1!<>jHTjtmiO=?yk;>!~p~ktq*soRw><=guc&p^kNVMJ-qkJkas9$p;Acr=S@lD4i z4QU^zPmKOYb}K%2P1fvPw)48GEI)NR1*_;Vv~&Gv)ldz?bSw6<?>P@M5~OA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EAHn+a+i&N7zgYz a|7~tokw=1^L;(Oi*vk&~h(wa#_5KfIfRL5| literal 0 HcmV?d00001 diff --git a/modules/convert/Test/Samples/test.pdf b/modules/convert/Test/Samples/test.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f698ff53d41575b222e6778f87f9e9fd8da4f2b1 GIT binary patch literal 7945 zcmeHMdpuO@*C+SMluP1J*&zvI@43%7V>Ap=#w8@A%w=P0%rG+|l|mN^ailm(Zs}e^ zN|F@npmOP+65Wq3lG43*4?-Qk^S<ZvIluR><})*&y`N{@p6^=E+Rxf+hC9;{gSEn= zXLQ}a+=fPx0SFLrmZE7i(1kCA*<yY)%mc8X3qYn4h@cxl1swo95k~-Bkx?&zOd^s% zC%_*d5U~IjPY$5d(Xfyw69J6<L8Gwv5hYBRE8@ZKY;mXrQE4v{M1%?@00DFt!#qA$ zDiQ-&9Gwn2@&!^@3_1$fQh1OBbY}X~2uyn_mVu>^i3}2x43QZQ_BaS{X9wZ1_EbCr zqSG8n_Eel5o<w0#7+5?3q7aB=29}AZ5*c{1gB_I~06GhKaFjn8z+q+AK_Y;Jm^UAE zfrY`+5P*o2*|J==P%=1QB$5J@foV?!7yw5By;g+5;KKQE5a{EN1#kcsK|mrE!|YHr zD&#JQ!_x>1<OG(;YpDZqN9CQMJ>%3!bAVS5^%S&?&k<5B6^tut*VOM^A~#N5&ZSVf z2aQ7D8xk-Cq(sUVOQXba5E=!cQ8Q*ZxH+Ox-@rwqaHD)S7ES<(I=mPP=n3E{-&q(K z7|0F`{B&7Pv7My8cWs)yNn^`e%ldJ3>gs6qcJ=nQX;Ra*lqPj`zi}FvBuhDYWx47u zrC-LdQwGdX?66=do5z;20qg)+?(AS#0uTqT2LQ82<^-bPkzk>Y@Y;)nQdlUJ0N6oh zd$B0YP88)2AtXd95ugxo0U!$r5B6V1kvKv)hZN0+C87v17g3BQ3}~J&k|N;)K!ZM$ z*)*abE0aEC{1_lQ^2HJ<KqY(wl1#?SHUNH5lpANMr!;gls;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h1bA|*8078{}ew@pV}$zqLd{I~E4 z4gKE!0Tyefh#Mix6wXX~L<FCQ#0^A*aX2i70<kF=0+9-1*hC~<k?=&AN91B*984OB zDHdxq@Aoc6=A4DdOCcc_{w9}%<B`}fiH9NJxdaS>jN@Ub92^Bh<`URE9wmqh6NcrE z;{98k1|5$iT_od!!zusU{u{_r|Fyr71^?Gn0KiWr{|MZlaQ%eqA0hCMh<`@cPq_XO z0{@8kXLS8*aG^$uMx;MwV-$&$gkzNIe_yE&_EU!2DFn)3J5g4y{<WEc^M>4ukG4c! z0xw#4Kv()Nxy(u_SKOpj_vc2h$%TKam=x`qeEX)nqMqEf$nk5(uw_)g@jv!<hHb%; z$bV-Ht+57m7SeENS(3FAoxiiz+<R``!ge()#p_3%pU!?V8|Uz8rNX8ym8%}hsj@tm zZ+4loxyBbI^3EwZZb$21u&QO3`lG2$9tAB6j~rV({cy~YgNF%BR~m{&vEF-pZ-Ygp z?X^nvWmV*iyP?G&y8L;^)#;N1>fJ1wJ+)9ZbM}_28qbMpe)cZIYsE~p(<j`v0>O+` zS|{G<>dlI}T5gCm=YoTO<&A-XtOYjo>V52<EB^nt=lWxx75~@nD)}$XRp^K2D$={; uJg_-id&V{+F*a{wVr<&_#8*d6QZK4%1j?EFDoh#!h*8~CES5CfPyHXEPS%zH literal 0 HcmV?d00001 diff --git a/modules/convert/Test/Samples/test.txt b/modules/convert/Test/Samples/test.txt new file mode 100644 index 00000000000..322dd17d9e0 --- /dev/null +++ b/modules/convert/Test/Samples/test.txt @@ -0,0 +1 @@ +a unit test for PHP CONVERSION lorem ipsum... \ No newline at end of file diff --git a/modules/convert/batch/LoggerLog4php.php b/modules/convert/batch/LoggerLog4php.php index 5859a92f31f..22eb7fab0ec 100644 --- a/modules/convert/batch/LoggerLog4php.php +++ b/modules/convert/batch/LoggerLog4php.php @@ -1,5 +1,12 @@ <?php +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. + * + */ + /** Logger class * * @author Laurent Giovannoni <dev@maarch.org> diff --git a/modules/convert/batch/batch_tools.php b/modules/convert/batch/batch_tools.php index e5abba1c524..8b55200228f 100644 --- a/modules/convert/batch/batch_tools.php +++ b/modules/convert/batch/batch_tools.php @@ -1,22 +1,10 @@ <?php -/* - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. * - * You should have received a copy of the GNU General Public License - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ /** diff --git a/modules/convert/batch/config/config.xml b/modules/convert/batch/config/config.xml index 3416184920d..ea4fbc74759 100644 --- a/modules/convert/batch/config/config.xml +++ b/modules/convert/batch/config/config.xml @@ -2,11 +2,11 @@ <ROOT> <CONFIG> <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/oem_V2/</MaarchDirectory> - <TmpDirectory>/var/www/html/oem_V2/modules/convert/batch/tmp/</TmpDirectory> + <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> + <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> + <StackSizeLimit>1000</StackSizeLimit> <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> @@ -31,7 +31,7 @@ <databaseserver>127.0.0.1</databaseserver> <databaseserverport>5432</databaseserverport> <databasetype>POSTGRESQL</databasetype> - <databasename>sipol_v2</databasename> + <databasename>MaarchCourrier</databasename> <databaseuser>maarch</databaseuser> <databasepassword>maarch</databasepassword> </CONFIG_BASE> @@ -50,44 +50,16 @@ <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> </COLLECTION> <COLLECTION> - <Id>attachments_version_coll</Id> + <Id>version_attachments_coll</Id> <Table>res_version_attachments</Table> <View>res_version_attachments</View> <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_version_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>calendar_coll</Id> - <Table>calendar_event_attachments</Table> - <View>calendar_event_attachments</View> - <Adr>calendar_event_adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/calendar_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>folder_coll</Id> - <Table>res_folder</Table> - <View>res_folder</View> - <Adr>adr_folder</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/folder_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>chrono_coll</Id> - <Table>res_chrono</Table> - <View>res_chrono</View> - <Adr>adr_chrono</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/chrono_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>reprise_coll</Id> - <Table>res_reprise</Table> - <View>res_reprise</View> - <Adr>adr_reprise</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/reprise_coll/</path_to_lucene_index> + <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> </COLLECTION> <LOG4PHP> <enabled>true</enabled> <Log4PhpLogger>loggerTechnique</Log4PhpLogger> <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/oem_V2/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> + <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> </LOG4PHP> -</ROOT> +</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/fill_stack.php b/modules/convert/batch/fill_stack.php index 47ebbe5f654..b7ae35bf5ee 100644 --- a/modules/convert/batch/fill_stack.php +++ b/modules/convert/batch/fill_stack.php @@ -1,22 +1,10 @@ <?php -/* - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. * - * You should have received a copy of the GNU General Public License - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -84,14 +72,22 @@ while ($state <> 'END') { /* Checking if the stack is full */ /**********************************************************************/ case 'CONTROL_STACK' : - $query = "select * from convert_stack " + //ONLY FOR TEST + $query = "truncate table convert_stack"; + $stmt = Bt_doQuery( + $GLOBALS['db'], + $query + ); + + $query = "select count(1) as cpt from convert_stack " . " where coll_id = ? and regex = ?"; $stmt = Bt_doQuery( $GLOBALS['db'], $query, array($GLOBALS['collection'], $GLOBALS['regExResId']) ); - if ($stmt->rowCount() > 0) { + $resultCpt = $stmt->fetchObject(); + if ($resultCpt->cpt > 0) { Bt_exitBatch(107, 'stack is full for collection:' . $GLOBALS['collection'] . ', regex:' . $GLOBALS['regExResId'] @@ -132,8 +128,9 @@ while ($state <> 'END') { ); $stmt = Bt_doQuery($GLOBALS['db'], $query); $resourcesArray = array(); + $stmtCpt = $stmt; - if ($stmt->rowCount() > 0) { + if ($stmtCpt->fetchObject()->res_id > 0) { while ($resoucesRecordset = $stmt->fetchObject()) { array_push( $resourcesArray, @@ -189,7 +186,8 @@ while ($state <> 'END') { $query ); $resourcesArray = array(); - if ($stmt->rowCount() > 0) { + $stmtCpt = $stmt; + if ($stmtCpt->fetchObject()->res_id > 0) { while ($resoucesRecordset = $stmt->fetchObject()) { array_push( $resourcesArray, diff --git a/modules/convert/batch/load_fill_stack.php b/modules/convert/batch/load_fill_stack.php index 559abc01086..3721e3515a0 100644 --- a/modules/convert/batch/load_fill_stack.php +++ b/modules/convert/batch/load_fill_stack.php @@ -1,22 +1,10 @@ <?php -/* - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. * - * You should have received a copy of the GNU General Public License - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -297,6 +285,7 @@ unset($xmlconfig); // Include library try { + Bt_myInclude($GLOBALS['MaarchDirectory'] . 'vendor/autoload.php'); Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_functions.php'); Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db.php'); Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db_pdo.php'); @@ -305,7 +294,7 @@ try { Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docservers_controler.php'); Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/docservers_tools.php'); Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docserver_types_controler.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'modules/convert/services/ManageConvert.php'); + //Bt_myInclude($GLOBALS['MaarchDirectory'] . 'modules/convert/services/ManageConvert.php'); } catch (IncludeFileError $e) { $GLOBALS['logger']->write( 'Problem with the php include path:' @@ -314,24 +303,27 @@ try { exit(111); } if (!is_dir($GLOBALS['tmpDirectoryRoot'])) { - $GLOBALS['logger']->write( - 'Problem with the tmp dir:' . $GLOBALS['tmpDirectory'], 'ERROR', 17 - ); - exit(17); + mkdir($GLOBALS['tmpDirectoryRoot']); + // echo PHP_EOL.'tmpDirectoryRoot '.$GLOBALS['tmpDirectoryRoot'].PHP_EOL; + // $GLOBALS['logger']->write( + // 'Problem with the tmp dir:' . $GLOBALS['tmpDirectoryRoot'], 'ERROR', 17 + // ); + // exit(17); } $coreTools = new core_tools(); $coreTools->load_lang($lang, $GLOBALS['MaarchDirectory'], $MaarchApps); session_start(); $_SESSION['modules_loaded'] = array(); +$_SESSION['user']['UserId'] = 'BOT_CONVERT'; $GLOBALS['func'] = new functions(); $GLOBALS['db'] = new Database($GLOBALS['configFile']); $GLOBALS['db2'] = new Database($GLOBALS['configFile']); $GLOBALS['db3'] = new Database($GLOBALS['configFile']); $GLOBALS['dbLog'] = new Database($GLOBALS['configFile']); $GLOBALS['docserverControler'] = new docservers_controler(); -$GLOBALS['processConvert'] = new Convert_ManageConvert_Service($GLOBALS['openOfficePath']); -$GLOBALS['processIndexes'] = new Convert_ProcessFulltext_Service(); +$GLOBALS['processConvert'] = new \Convert\Controllers\ProcessManageConvertController($GLOBALS['openOfficePath']); +$GLOBALS['processIndexes'] = new \Convert\Controllers\ProcessFulltextController(); $configFileName = basename($GLOBALS['configFile'], '.xml'); $GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . '/' diff --git a/modules/convert/batch/process_stack.php b/modules/convert/batch/process_stack.php index 969d610b8b3..c5d46ecbf45 100644 --- a/modules/convert/batch/process_stack.php +++ b/modules/convert/batch/process_stack.php @@ -1,22 +1,10 @@ <?php -/* - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. * - * You should have received a copy of the GNU General Public License - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -122,7 +110,8 @@ while ($GLOBALS['state'] <> "END") { $query, array($GLOBALS['collection']) ); - if ($stmt->rowCount() == 0) { + $stmtCpt = $stmt; + if ($stmtCpt->fetchObject()->docserver_id == '') { Bt_exitBatch(13, 'Docserver not found'); break; } else { @@ -151,7 +140,8 @@ while ($GLOBALS['state'] <> "END") { $GLOBALS['wb'] ) ); - if ($stmt->rowCount() == 0) { + $stackRecordset = $stmt->fetchObject(); + if (!($stackRecordset->res_id)) { if ($GLOBALS['OnlyIndexes']) { $GLOBALS['processIndexes']->commitZendIndex($GLOBALS['zendIndex']); } @@ -159,7 +149,6 @@ while ($GLOBALS['state'] <> "END") { $GLOBALS['logger']->write('No more records to process', 'INFO'); break; } else { - $stackRecordset = $stmt->fetchObject(); $currentRecordInStack = array(); $currentRecordInStack = $GLOBALS['func']->object2array( $stackRecordset @@ -197,7 +186,7 @@ while ($GLOBALS['state'] <> "END") { 'resId' => $currentRecordInStack['res_id'], 'tmpDir' => $GLOBALS['tmpDirectory'], 'path_to_lucene' => $GLOBALS['path_to_lucene'], - //'zendIndex' => $GLOBALS['zendIndex'] + //'createZendIndex' => false ) ); } diff --git a/modules/convert/batch/verif_index.php b/modules/convert/batch/verif_index.php index 6333e5a4232..203f6be90d0 100644 --- a/modules/convert/batch/verif_index.php +++ b/modules/convert/batch/verif_index.php @@ -1,5 +1,12 @@ <?php +/** + * Copyright Maarch since 2008 under licence GPLv3. + * See LICENCE.txt file at the root folder for more details. + * This file is part of Maarch software. + * + */ + date_default_timezone_set('Europe/Paris'); // load the config and prepare to process diff --git a/modules/convert/services/ManageConvert.php b/modules/convert/services/ManageConvert.php deleted file mode 100644 index 37bde281c5e..00000000000 --- a/modules/convert/services/ManageConvert.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Manage convert class -* -* <ul> -* <li>Services to Manage the convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'modules/convert/services/ManageConvertAbstract.php'; - -class Convert_ManageConvert_Service extends Convert_ManageConvertAbstract_Service { - - -} diff --git a/modules/convert/services/ManageConvertAbstract.php b/modules/convert/services/ManageConvertAbstract.php deleted file mode 100644 index fc0980e5cde..00000000000 --- a/modules/convert/services/ManageConvertAbstract.php +++ /dev/null @@ -1,164 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief Manage convert class -* -* <ul> -* <li>Services to Manage the convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -require_once 'core/services/Abstract.php'; -require_once 'core/class/class_functions.php'; -require_once 'core/class/class_db_pdo.php'; -require_once 'core/class/class_db.php'; -require_once 'core/docservers_tools.php'; -require_once 'core/class/docservers_controler.php'; -require_once 'core/services/ManageDocservers.php'; -require_once 'modules/convert/services/ProcessConvert.php'; -require_once 'modules/convert/services/ProcessThumbnails.php'; -require_once 'modules/convert/services/ProcessFulltext.php'; - -class Convert_ManageConvertAbstract_Service extends Core_Abstract_Service { - - /** - * Ask for conversion in all mode - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @throws Exception Check des valeurs d'entrées - * @return array $returnArray the result - */ - public function convertAll(array $args=[]) - { - $timestart = microtime(true); - // Prés-requis : - $this->checkRequired($args, ['collId','resTable','adrTable','resId',]); - $this->checkNumeric($args, ['resId',]); - $this->checkString($args, ['collId','resTable','adrTable',]); - - // Variabilisation : - $returnArray = array(); - $collId = $args['collId']; - $resTable = $args['resTable']; - $adrTable = $args['adrTable']; - $resId = $args['resId']; - - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - $path_to_lucene = ''; - if (isset($args['path_to_lucene']) && !empty($args['path_to_lucene'])){ - $path_to_lucene = $args['path_to_lucene']; - } - - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene - ); - - //CONV - $ProcessConvertService = new Convert_ProcessConvert_Service(); - $resultOfConversion = $ProcessConvertService->convert($params); - - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'CONV:' . $resultOfConversion['error'], - ); - return $returnArray; - } - - //TNL - $ProcessConvertService = new Convert_ProcessThumbnails_Service(); - $resultOfConversion = $ProcessConvertService->thumbnails($params); - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'TNL:' . $resultOfConversion['error'], - ); - return $returnArray; - } - - //FULLTEXT - if (!empty($args['zendIndex'])) { - $zendIndex = $args['zendIndex']; - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene, - 'zendIndex' => $zendIndex - ); - } else { - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene - ); - } - $ProcessConvertService = new Convert_ProcessFulltext_Service(); - $resultOfConversion = $ProcessConvertService->fulltext($params); - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'TXT:' . $resultOfConversion['error'], - ); - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ManageConvertAbstract_Service::convertAll aucun contenu a indexer dans fulltext'); - return $returnArray; - } - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ManageConvertAbstract_Service::convertAll'); - return $returnArray; - } - -} diff --git a/modules/convert/services/ProcessConvert.php b/modules/convert/services/ProcessConvert.php deleted file mode 100644 index 6cde4c76823..00000000000 --- a/modules/convert/services/ProcessConvert.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process convert class -* -* <ul> -* <li>Services to process the convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'modules/convert/services/ProcessConvertAbstract.php'; - -class Convert_ProcessConvert_Service extends Convert_ProcessConvertAbstract_Service { - - -} diff --git a/modules/convert/services/ProcessConvertAbstract.php b/modules/convert/services/ProcessConvertAbstract.php deleted file mode 100644 index d5c079ed4fd..00000000000 --- a/modules/convert/services/ProcessConvertAbstract.php +++ /dev/null @@ -1,592 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process convert class -* -* <ul> -* <li>Services to process the convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'core/services/Abstract.php'; -require_once 'core/class/class_functions.php'; -require_once 'core/class/class_db_pdo.php'; -require_once 'core/class/class_db.php'; -require_once 'core/docservers_tools.php'; -require_once 'core/class/docservers_controler.php'; -require_once 'core/services/ManageDocservers.php'; - -class Convert_ProcessConvertAbstract_Service extends Core_Abstract_Service { - - protected $libreOfficeExecutable; - - //public function __construct($libreOfficeExecutable = 'cloudooo') - public function __construct($libreOfficeExecutable = 'soffice') - //public function __construct($libreOfficeExecutable = 'unoconv') - { - $this->libreOfficeExecutable = $libreOfficeExecutable; - } - - /** - * Ask for conversion - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function convert(array $args=[]) - { - $timestart = microtime(true); - // Core_Logs_Service::info(['message'=>'debut convert', 'code'=>111, ]); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - $dbConv = new Database($GLOBALS['configFile']); - - //retrieve path of the resource - $stmtConv = $dbConv->query("select * from " . $resTable - . " where res_id = ?", array($resId) - ); - $line = $stmtConv->fetchObject(); - $ManageDocservers = new Core_ManageDocservers_Service(); - if ($line->res_id <> '') { - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $line->res_id, - 'DOC' - ); - } - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'file not exists : ' . $resourcePath, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed', - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //now do the conversion ! - if (strtoupper($line->format) <> 'PDF') { - $resultOfConversion = $this->launchConvert( - $fileNameOnTmp, - 'pdf', - $tmpDir, - pathinfo($resourcePath, PATHINFO_EXTENSION) - ); - } else { - //echo $fileNameOnTmp; - copy($fileNameOnTmp, $fileNameOnTmp . '.pdf'); - $resultOfConversion = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - - if ($resultOfConversion['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultOfConversion; - } - //find the target docserver - $targetDs = $ManageDocservers->findTargetDs($collId); - if (empty($targetDs)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection not found:' . $collId, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the result on docserver - // Core_Logs_Service::info(['message'=>'avant cp ds', 'code'=>1112, ]); - $resultCopyDs = $ManageDocservers->copyResOnDS($fileNameOnTmp . '.pdf', $targetDs); - if ($resultCopyDs['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultCopyDs; - } - // Core_Logs_Service::info(['message'=>'avant update', 'code'=>19, ]); - //update the database - $resultOfUpDb = $this->updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $targetDs, - $resultCopyDs['value']['destinationDir'], - $resultCopyDs['value']['fileDestinationName'] - ); - // Core_Logs_Service::info(['message'=>var_export($resultOfUpDb, true), 'code'=>111111, ]); - // Core_Logs_Service::info(['message'=>$collId, 'code'=>2, ]); - // Core_Logs_Service::info(['message'=>$resTable, 'code'=>3, ]); - // Core_Logs_Service::info(['message'=>$adrTable, 'code'=>4, ]); - // Core_Logs_Service::info(['message'=>$resId, 'code'=>5, ]); - // Core_Logs_Service::info(['message'=>'apres res_id', 'code'=>6, ]); - // Core_Logs_Service::info(['message'=>$targetDs, 'code'=>6, ]); - // Core_Logs_Service::info(['message'=>var_export($resultCopyDs, true), 'code'=>7, ]); - - if ($resultOfUpDb['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.pdf'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessConvertAbstract_Service::convert'); - return $returnArray; - } - - /** - * Launch the conversion - * - * @param string $srcfile source file - * @param string $tgtfmt target format - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - public function launchConvert( - $srcfile, - $tgtfmt, - $tgtdir=false, - $srcfmt=null - ) { - $timestart=microtime(true); - - $processHtml = false; - $executable=''; - - Core_Logs_Service::info(['message'=>'[TIMER] Debut Convert_ProcessConvertAbstract_Service::launchConvert']); - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $processHtml = true; - Core_Logs_Service::info(['message'=>'[TIMER] srcfmt ' . $srcfmt]); - copy($srcfile, str_ireplace('.maarch', '.', $srcfile) . '.html'); - if (file_exists('/usr/bin/mywkhtmltopdf')) { - $command = "mywkhtmltopdf " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.pdf'); - } else { - $envVar = "export DISPLAY=FRPAROEMINT:0.0 ; "; - $command = $envVar . "wkhtmltopdf " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.pdf'); - } - $executable='wkhtmltopdf'; - } else { - $executable='soffice'; - Core_Logs_Service::info(['message'=>'[TIMER] let LO do it ' . $this->libreOfficeExecutable]); - if ($this->libreOfficeExecutable == "cloudooo") { - $serverAddress = "http://192.168.21.40:8011"; - $tokens = array(); - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpc.inc'; - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpcs.inc'; - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpc_wrappers.inc'; - $fileContent = file_get_contents($srcfile, FILE_BINARY); - $encodedContent = base64_encode($fileContent); - $params = array(); - array_push($params, new PhpXmlRpc\Value($encodedContent)); - array_push($params, new PhpXmlRpc\Value($srcfmt)); - array_push($params, new PhpXmlRpc\Value($tgtfmt)); - array_push($params, new PhpXmlRpc\Value(false)); - $v = new PhpXmlRpc\Value($params, "array"); - } elseif ($this->libreOfficeExecutable == "unoconv") { - $tokens = array('"' . $this->libreOfficeExecutable . '"'); - $tokens[] = "-f"; - $tokens[] = $tgtfmt; - $tokens[] = '-o "' . $srcfile . '.' . $tgtfmt . '"'; - $tokens[] = '"' . $srcfile . '"'; - } else { - $tokens = array('"' . $this->libreOfficeExecutable . '"'); - $tokens[] = "--headless"; - $tokens[] = "--convert-to"; - $tokens[] = $tgtfmt; - $tokens[] = '"' . $srcfile . '"'; - if (!$tgtdir) { - $tgtdir = dirname($srcfile); - } - $tokens[] = '--outdir "' . $tgtdir . '"'; - } - - if (!$srcfmt) { - $tokens[] = $srcfmt; - } - - $command = implode(' ', $tokens); - - $output = array(); - $return = null; - $this->errors = array(); - } - //echo $command . '<br />';exit; - if ($this->libreOfficeExecutable == "cloudooo" && !$processHtml) { - Core_Logs_Service::info(['message'=>'[TIMER] commande : cloudooo url ' . $serverAddress]); - Core_Logs_Service::info(['message'=>'[TIMER] Debut Convert_ProcessConvertAbstract_Service::launchConvert__exec']); - $req = new PhpXmlRpc\Request('convertFile', $v); - //Core_Logs_Service::info(['message'=>'[TIMER] commande : cloudooo url ' . $serverAddress]); - Core_Logs_Service::info(['message'=>'[TIMER] Fin Convert_ProcessConvertAbstract_Service::launchConvert__exec']); - $client = new PhpXmlRpc\Client($serverAddress); - $resp = $client->send($req); - if (!$resp->faultCode()) { - $encoder = new PhpXmlRpc\Encoder(); - $value = $encoder->decode($resp->value()); - $theFile = fopen($srcfile . '.' . $tgtfmt, 'w+'); - fwrite($theFile, base64_decode($value)); - fclose($theFile); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - //print "An error occurred: "; - //print "Code: " . htmlspecialchars($resp->faultCode()) - // . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n"; - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => "Code: " . htmlspecialchars($resp->faultCode()) - . " Reason: '" . htmlspecialchars($resp->faultString()), - ); - } - } else { - $timestart_command = microtime(true); - exec("timeout -k 5m 3m " . $command, $output, $return); - Core_Logs_Service::debug(['message'=>'[TIMER] commande : ' . $command]); - Core_Logs_Service::executionTimeLog($timestart_command, '', 'info', '[TIMER] ' . $executable . ' - Convert_ProcessConvertAbstract_Service::launchConvert__exec'); - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - } - } - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $returnArray = array(); - unlink(str_ireplace('.maarch', '.', $srcfile) . '.html'); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - Core_Logs_Service::executionTimeLog($timestart, '', 'info', '[TIMER] Fin Convert_ProcessConvertAbstract_Service::launchConvert'); - return $returnArray; - } - - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @return array $returnArray the result - */ - private function updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $docserver, - $path, - $fileName - ) { - try { - $docserver->path_template = str_replace( - DIRECTORY_SEPARATOR, - '#', - $docserver->path_template - ); - $path = str_replace($docserver->path_template, '', $path); - $dbConv = new Database($GLOBALS['configFile']); - $query = "update convert_stack set status = 'P' where " - . " coll_id = ? and res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $collId, - $resId - ) - ); - - $query = "select * from " . $adrTable - . " where res_id = ? order by adr_priority"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "select docserver_id, path, filename, offset_doc, fingerprint" - . " from " . $resTable . " where res_id = ?"; - $stmt = $dbConv->query($query, array($resId)); - $recordset = $stmt->fetchObject(); - // Core_Logs_Service::info(['message'=>$recordset, 'code'=>8, ]); - $resDocserverId = $recordset->docserver_id; - $resPath = $recordset->path; - $resFilename = $recordset->filename; - $resOffsetDoc = $recordset->offset_doc; - $fingerprintInit = $recordset->fingerprint; - $query = "select adr_priority_number from docservers " - . " where docserver_id = ?"; - $stmt = $dbConv->query($query, array($resDocserverId)); - $recordset = $stmt->fetchObject(); - $query = "insert into " . $adrTable . " (res_id, " - . "docserver_id, path, filename, offset_doc, fingerprint, " - . "adr_priority) values (?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $resDocserverId, - $resPath, - $resFilename, - $resOffsetDoc, - $fingerprintInit, - $recordset->adr_priority_number - ) - ); - } - - $query = "select * from " . $adrTable - . " where res_id = ? and adr_type = 'CONV'"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "insert into " . $adrTable . " (res_id, docserver_id, " - . "path, filename, offset_doc, fingerprint, adr_priority, adr_type) values (" - . "?, ?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - 'CONV' - ) - ); - } else { - $query = "update " . $adrTable . " set docserver_id = ?, " - . " path = ?, filename = ?, offset_doc = ?, fingerprint = ?, adr_priority = ?" - . " where res_id = ? and adr_type = ? "; - $stmt = $dbConv->query( - $query, - array( - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - $resId, - 'CONV' - ) - ); - } - if ($_SESSION['user']['UserId'] <> '') { - $user = $_SESSION['user']['UserId']; - } else { - $user = 'CONVERT_BOT'; - } - $query = "insert into history (table_name, record_id, " - . "event_type, user_id, event_date, info, id_module) values (" - . "?, ?, 'ADD', '" . $user . "', " - . $dbConv->current_datetime() - . ", ?, 'convert')"; - $stmt = $dbConv->query( - $query, - array( - $resTable, - $resId, - "process convert done" - ) - ); - - $queryCpt = "select coalesce(custom_t9, '0') as custom_t9 from " . $resTable - . " where res_id = ?"; - $stmtCpt = $dbConv->query($queryCpt, array($resId)); - $rsCpt = $stmtCpt->fetchObject(); - $cptConvert = $rsCpt->custom_t9 + 1; - - $query = "update " . $resTable - . " set convert_result = '1', is_multi_docservers = 'Y', custom_t9 = '" . $cptConvert . "' where " - . " res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $resId - ) - ); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - return $returnArray; - } - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - private function manageErrorOnDb( - $resTable, - $resId, - $result - ) { - $dbConv = new Database($GLOBALS['configFile']); - $query = "update " . $resTable - . " set convert_result = ? where " - . " res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $result, - $resId - ) - ); - } - - /** - * Test if the record is already processed by convert module - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @return boolean - */ - public function isAlreadyProcessedByConvert( - $resTable, - $resId - ) { - $dbConv = new Database($GLOBALS['configFile']); - $query = "select convert_result from " . $resTable - . " where res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $resId - ) - ); - $rs = $stmt->fetchObject(); - if ( - empty($rs->convert_result) || - $rs->convert_result == '0' - ) { - return false; - } else { - return true; - } - } -} diff --git a/modules/convert/services/ProcessFulltext.php b/modules/convert/services/ProcessFulltext.php deleted file mode 100644 index 8911aab6863..00000000000 --- a/modules/convert/services/ProcessFulltext.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process fulltext class -* -* <ul> -* <li>Services to process the fulltext of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'modules/convert/services/ProcessFulltextAbstract.php'; - -class Convert_ProcessFulltext_Service extends Convert_ProcessFulltextAbstract_Service { - - -} diff --git a/modules/convert/services/ProcessFulltextAbstract.php b/modules/convert/services/ProcessFulltextAbstract.php deleted file mode 100644 index 3a7e7f8cfa2..00000000000 --- a/modules/convert/services/ProcessFulltextAbstract.php +++ /dev/null @@ -1,740 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process fulltext class -* -* <ul> -* <li>Services to process the fulltext of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -require_once 'core/services/Abstract.php'; -require_once 'core/class/class_functions.php'; -require_once 'core/class/class_db_pdo.php'; -require_once 'core/class/class_db.php'; -require_once 'core/docservers_tools.php'; -require_once 'core/class/docservers_controler.php'; -require_once 'core/services/ManageDocservers.php'; - -// Storing text in lucene index -set_include_path('apps/maarch_entreprise/tools/' - . PATH_SEPARATOR . get_include_path() -); - -if(!@include('Zend/Search/Lucene.php')) { - set_include_path($GLOBALS['MaarchDirectory'].'apps/maarch_entreprise/tools/' - . PATH_SEPARATOR . get_include_path() - ); - if(!@include('Zend/Search/Lucene.php')) { - set_include_path('/var/www/oem/apps/maarch_entreprise/tools/' - . PATH_SEPARATOR . get_include_path() - ); - } - require_once("Zend/Search/Lucene.php"); -} - -//include_once('html2text/html2text.php'); - -class Convert_ProcessFulltextAbstract_Service extends Core_Abstract_Service { - - protected $pdftotext; - - public function __construct($pdftotext = 'pdftotext') - { - $this->pdftotext = $pdftotext; - } - - /** - * Ask for fulltext - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function fulltext(array $args=[]) - { - $timestart = microtime(true); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty for fulltext', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - // if (empty($args['batchMode'])) { - // $batchMode = false; - // } else { - // $batchMode = $args['batchMode']; - // } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty for fulltext', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty for fulltext', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty for fulltext', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - if(isset($args['path_to_lucene']) && !empty($args['path_to_lucene'])){ - $indexFileDirectory = $args['path_to_lucene']; - } else { - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == $collId) { - $indexFileDirectory - = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - } - - $dbConv = new Database($GLOBALS['configFile']); - - //retrieve path of the resource - $stmtConv = $dbConv->query("select * from " . $resTable - . " where res_id = ?", array($resId) - ); - $line = $stmtConv->fetchObject(); - $ManageDocservers = new Core_ManageDocservers_Service(); - if ($line->res_id <> '') { - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $line->res_id, - 'CONV' - ); - } - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '2', - 'value' => '', - 'error' => 'file not already converted in pdf for fulltext. path :' - . $resourcePath . ", adrType : CONV, adr_table : " . $adrTable, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed for fulltext. Copy ' . $resourcePath . ' to ' . $fileNameOnTmp, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //now do the fulltext ! - if (!empty($args['zendIndex'])) { - $resultOfConversion = $this->launchFulltext( - $fileNameOnTmp, - $resId, - $indexFileDirectory, - $tmpDir, - $args['zendIndex'] - ); - } else { - $resultOfConversion = $this->launchFulltext( - $fileNameOnTmp, - $resId, - $indexFileDirectory, - $tmpDir - ); - } - - - if ($resultOfConversion['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessFulltextAbstract_Service::fulltext aucunContenuAIndexer'); - return $resultOfConversion; - } - //find the target docserver - $targetDs = $ManageDocservers->findTargetDs($collId, 'FULLTEXT'); - if (empty($targetDs)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection and ds type not found for fulltext:' - . $collId . ' FULLTEXT', - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the result on docserver - $resultCopyDs = $ManageDocservers->copyResOnDS($fileNameOnTmp . '.txt', $targetDs); - if ($resultCopyDs['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultCopyDs; - } - //update the database - $resultOfUpDb = $this->updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $targetDs, - $resultCopyDs['value']['destinationDir'], - $resultCopyDs['value']['fileDestinationName'], - $args['zendIndex'] - ); - if ($resultOfUpDb['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.txt'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessFulltextAbstract_Service::fulltext'); - return $returnArray; - } - - /** - * Launch the fulltext process - * - * @param string $srcfile source file - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - private function launchFulltext( - $srcfile, - $resId, - $indexFileDirectory, - $tgtdir=false, - $zendIndex='' - ) { - if (!empty($zendIndex)) { - $return = $this->prepareIndexFullTextPdf( - $srcfile, - $tgtdir, - $indexFileDirectory, - $resId, - $zendIndex - ); - } else { - $return = $this->prepareIndexFullTextPdf( - $srcfile, - $tgtdir, - $indexFileDirectory, - $resId - ); - } - - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - return $returnArray; - } - } - - /** - * Read a txt file - * @param $file string path of the file to read - * @return string contents of the file - */ - private function readFileF($file) - { - $result = ""; - if (is_file($file)) { - $fp = fopen($file, "r"); - $result = fread($fp, filesize($file)); - fclose($fp); - } - return $result; - } - - private function prepareIndexFullTextPdf($pathToFile, $tmpDir, $indexFileDirectory, $resId, $zendIndex) - { - $timestart = microtime(true); - if (is_file($pathToFile)) { - $tmpFile = $tmpDir . basename($pathToFile) . ".txt"; - // if ($_ENV['osname'] == "WINDOWS") { - // $resultExtraction = exec(escapeshellarg($_ENV['maarch_tools_path'] . "pdftotext" - // . DIRECTORY_SEPARATOR . $_ENV['pdftotext']) . " " - // . escapeshellarg($pathToFile) . " " . escapeshellarg($tmpFile) - // ); - // } elseif ($_ENV['osname'] == "UNIX") { - // $resultExtraction = exec("pdftotext -enc UTF-8 " . escapeshellarg($pathToFile) - // . " " . escapeshellarg($tmpFile) - // ); - $timestart_fulltext = microtime(true); - $resultExtraction = exec("pdftotext " . escapeshellarg($pathToFile) - . " " . escapeshellarg($tmpFile) - ); - Core_Logs_Service::executionTimeLog($timestart_fulltext, '', 'debug', '[TIMER] Convert_ProcessFulltextAbstract_Service::prepareIndexFullTextPdf__exec'); - //} - // echo "pdftotext " . escapeshellarg($pathToFile) - // . " " . escapeshellarg($tmpFile) . '<br/><br/><br/>'; - $fileContent = trim($this->readFileF($tmpFile)); - //echo $fileContent . '<br />'; - //exit; - //echo $tmpFile . '<br />'; - //echo $indexFileDirectory . '<br />'; - //echo $resId . '<br />'; - if (!empty($zendIndex)) { - $result = $this->launchIndexFullTextWithZendIndex( - $fileContent, - $indexFileDirectory, - $resId, - $zendIndex - ); - } else { - // TODO : will be done only by the batch convert in OnlyIndexes mode - //$result = $this->launchIndexFullText($fileContent, $indexFileDirectory, $resId); - $result = 0; - } - - } else { - $result = 'file not found ' . $pathToFile; - } - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessFulltextAbstract_Service::prepareIndexFullTextPdf'); - return $result; - } - - /** - * Return zend index object for batch mode - * @param $indexFileDirectory string directory of the lucene index - * @return zend index object - */ - public function createZendIndexObject($tempIndexFileDirectory, $numberOfIndexes = 1000) - { - //echo 'createZendIndexObject : ' . $numberOfIndexes . PHP_EOL; - $func = new functions(); - $indexFileDirectory = (string) $tempIndexFileDirectory; - // with version 1.12, we need a string, not an XML element - - if (!is_dir($indexFileDirectory)) { - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - if ($func->isDirEmpty($indexFileDirectory)) { - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - $index = Zend_Search_Lucene::open($indexFileDirectory); - } - } - $index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3); - // we set the lucene format to 2.3 - Zend_Search_Lucene_Analysis_Analyzer::setDefault( - new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive() - ); - - //$index->MaxBufferedDocs(); - $index->setMaxBufferedDocs($numberOfIndexes); - - return $index; - } - - /** - * Commit the zend index at the end of the batch - * @return nothing - */ - public function commitZendIndex($index) - { - //echo 'the commit' . PHP_EOL; - $index->commit(); - } - - /** - * Retrieve the text of a pdftext and launch the lucene engine - * @param $pathToFile string path of the file to index - * @param $indexFileDirectory string directory of the lucene index - * @param $id integer id of the document to index - * @return integer user exit code is stored in fulltext_result column of the - * document in "res_x" - */ - private function launchIndexFullText($fileContent, $tempIndexFileDirectory, $Id) - { - // $IndexFileDirectory is replace by tempIndexFileDirectory - $func = new functions(); - $fileContent = $func->normalize($fileContent); - $fileContent = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileContent); - $indexFileDirectory = (string) $tempIndexFileDirectory; - // with version 1.12, we need a string, not an XML element - $result = -1; - if (strlen($fileContent) > 2) { - if (!is_dir($indexFileDirectory)) { - //$_ENV['logger']->write($indexFileDirectory . " not exists !", "ERROR", 2); - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - if ($func->isDirEmpty($indexFileDirectory)) { - //$_ENV['logger']->write($indexFileDirectory . " empty !"); - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - $index = Zend_Search_Lucene::open($indexFileDirectory); - } - } - $index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3); - // we set the lucene format to 2.3 - Zend_Search_Lucene_Analysis_Analyzer::setDefault( - new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive() - ); - // we need utf8 for accents - $term = new Zend_Search_Lucene_Index_Term($Id, 'Id'); - foreach ($index->termDocs($term) as $id) { - $index->delete($id); - } - //echo $fileContent; - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::UnIndexed('Id', (integer) $Id)); - $doc->addField(Zend_Search_Lucene_Field::UnStored( - 'contents', $fileContent) - ); - //$func->show_array($doc); - $index->addDocument($doc); - $index->commit(); - //$func->show_array($index); - //$index->optimize(); - $result = 0; - } else { - $result = 1; - } - return $result; - } - - /** - * Retrieve the text of a pdftext and launch the lucene engine - * @param $pathToFile string path of the file to index - * @param $indexFileDirectory string directory of the lucene index - * @param $id integer id of the document to index - * @return integer user exit code is stored in fulltext_result column of the - * document in "res_x" - */ - private function launchIndexFullTextWithZendIndex($fileContent, $tempIndexFileDirectory, $Id, $index) - { - //echo 'launchIndexFullTextWithZendIndex' . PHP_EOL; - // $IndexFileDirectory is replace by tempIndexFileDirectory - $func = new functions(); - $fileContent = $func->normalize($fileContent); - $fileContent = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileContent); - - // with version 1.12, we need a string, not an XML element - $result = -1; - if (strlen($fileContent) > 2) { - try { - // we need utf8 for accents - $term = new Zend_Search_Lucene_Index_Term($Id, 'Id'); - foreach ($index->termDocs($term) as $id) { - $index->delete($id); - } - //echo $fileContent; - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::UnIndexed('Id', (integer) $Id)); - $doc->addField(Zend_Search_Lucene_Field::UnStored( - 'contents', $fileContent) - ); - //$func->show_array($doc); - $index->addDocument($doc); - //$index->commit(); - //$func->show_array($index); - //$index->optimize(); - $result = 0; - } catch (Exception $e) { - $result = $e->getMessage(); - } - - } else if (strlen($fileContent) >= 0){ - $result = 0; - } - return $result; - } - - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @return array $returnArray the result - */ - private function updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $docserver, - $path, - $fileName, - $zendIndex = '' - ) { - try { - $docserver->path_template = str_replace( - DIRECTORY_SEPARATOR, - '#', - $docserver->path_template - ); - $path = str_replace($docserver->path_template, '', $path); - $dbConv = new Database($GLOBALS['configFile']); - $query = "update convert_stack set status = 'P' where " - . " coll_id = ? and res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $collId, - $resId - ) - ); - - $query = "select * from " . $adrTable - . " where res_id = ? order by adr_priority"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "select docserver_id, path, filename, offset_doc, fingerprint" - . " from " . $resTable . " where res_id = ?"; - $stmt = $dbConv->query($query, array($resId)); - $recordset = $stmt->fetchObject(); - $resDocserverId = $recordset->docserver_id; - $resPath = $recordset->path; - $resFilename = $recordset->filename; - $resOffsetDoc = $recordset->offset_doc; - $fingerprintInit = $recordset->fingerprint; - $query = "select adr_priority_number from docservers " - . " where docserver_id = ?"; - $stmt = $dbConv->query($query, array($resDocserverId)); - $recordset = $stmt->fetchObject(); - $query = "insert into " . $adrTable . " (res_id, " - . "docserver_id, path, filename, offset_doc, fingerprint, " - . "adr_priority) values (?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $resDocserverId, - $resPath, - $resFilename, - $resOffsetDoc, - $fingerprintInit, - $recordset->adr_priority_number - ) - ); - } - - $query = "select * from " . $adrTable - . " where res_id = ? and adr_type = 'TXT'"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "insert into " . $adrTable . " (res_id, docserver_id, " - . "path, filename, offset_doc, fingerprint, adr_priority, adr_type) values (" - . "?, ?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - 'TXT' - ) - ); - } else { - $query = "update " . $adrTable . " set docserver_id = ?, " - . " path = ?, filename = ?, offset_doc = ?, fingerprint = ?, adr_priority = ?" - . " where res_id = ? and adr_type = ? "; - $stmt = $dbConv->query( - $query, - array( - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - $resId, - 'TXT' - ) - ); - } - if ($_SESSION['user']['UserId'] <> '') { - $user = $_SESSION['user']['UserId']; - } else { - $user = 'CONVERT_BOT'; - } - $query = "insert into history (table_name, record_id, " - . "event_type, user_id, event_date, info, id_module) values (" - . "?, ?, 'ADD', '" . $user . "', " - . $dbConv->current_datetime() - . ", ?, 'convert')"; - $stmt = $dbConv->query( - $query, - array( - $resTable, - $resId, - "process fulltext done" - ) - ); - - $queryCpt = "select coalesce(custom_t15, '0') as custom_t15 from " . $resTable - . " where res_id = ?"; - $stmtCpt = $dbConv->query($queryCpt, array($resId)); - $rsCpt = $stmtCpt->fetchObject(); - $cptFullText = $rsCpt->custom_t15 + 1; - - if (!empty($zendIndex)) { - $query = "update " . $resTable - . " set fulltext_result = '1', is_multi_docservers = 'Y', custom_t15 = '" . $cptFullText . "' where " - . " res_id = ?"; - } else { - $query = "update " . $resTable - . " set fulltext_result = '0', is_multi_docservers = 'Y', custom_t15 = '" . $cptFullText . "' where " - . " res_id = ?"; - } - $stmt = $dbConv->query( - $query, - array( - $resId - ) - ); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - return $returnArray; - } - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - private function manageErrorOnDb( - $resTable, - $resId, - $result - ) { - $dbConv = new Database($GLOBALS['configFile']); - - $queryCpt = "select coalesce(custom_t15, '0') as custom_t15 from " . $resTable - . " where res_id = ?"; - $stmtCpt = $dbConv->query($queryCpt, array($resId)); - $rsCpt = $stmtCpt->fetchObject(); - $cptFullText = $rsCpt->custom_t15 + 1; - - $query = "update " . $resTable - . " set fulltext_result = ?, custom_t15 = '" . $cptFullText . "' where " - . " res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $result, - $resId - ) - ); - } - - public static function optimizeLuceneIndex(array $args=[]){ - $timestart = microtime(true); - // Prés-requis : - self::checkRequired($args, ['collId']); - self::checkString($args, ['collId']); - - $collId = $args['collId']; - - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == $collId) { - $path_to_lucene = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - - if(!empty($path_to_lucene)){ - exec('php '.$_SESSION['config']['corepath'].'modules/convert/optimizeLuceneIndex.php '.$path_to_lucene.' '.$_SESSION['config']['corepath'].' > /dev/null 2>&1 &'); - } - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessFulltextAbstract_Service::optimizeLuceneIndex'); - return true; - } - -} diff --git a/modules/convert/services/ProcessThumbnails.php b/modules/convert/services/ProcessThumbnails.php deleted file mode 100644 index 17f4b754bd7..00000000000 --- a/modules/convert/services/ProcessThumbnails.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process thumbnails class -* -* <ul> -* <li>Services to process the thumbnails of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'modules/convert/services/ProcessThumbnailsAbstract.php'; - -class Convert_ProcessThumbnails_Service extends Convert_ProcessThumbnailsAbstract_Service { - - -} diff --git a/modules/convert/services/ProcessThumbnailsAbstract.php b/modules/convert/services/ProcessThumbnailsAbstract.php deleted file mode 100644 index 0ac20cf65c4..00000000000 --- a/modules/convert/services/ProcessThumbnailsAbstract.php +++ /dev/null @@ -1,501 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process thumbnails class -* -* <ul> -* <li>Services to process the thumbnails of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - -require_once 'core/services/Abstract.php'; -require_once 'core/class/class_functions.php'; -require_once 'core/class/class_db_pdo.php'; -require_once 'core/class/class_db.php'; -require_once 'core/docservers_tools.php'; -require_once 'core/class/docservers_controler.php'; -require_once 'core/services/ManageDocservers.php'; - -class Convert_ProcessThumbnailsAbstract_Service extends Core_Abstract_Service { - - protected $tnlExecutable; - - public function __construct($tnlExecutable = 'convert') - { - $this->tnlExecutable = $tnlExecutable; - } - - /** - * Ask for thumbnails - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function thumbnails(array $args=[]) - { - $timestart = microtime(true); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty for thumbnails', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty for thumbnails', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty for thumbnails', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty for thumbnails', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - $dbConv = new Database($GLOBALS['configFile']); - - //retrieve path of the resource - $stmtConv = $dbConv->query("select * from " . $resTable - . " where res_id = ?", array($resId) - ); - $line = $stmtConv->fetchObject(); - $ManageDocservers = new Core_ManageDocservers_Service(); - if ($args['fileSource'] <> '' && file_exists($args['fileSource'])) { - $resourcePath = $args['fileSource']; - } else { - if ($line->res_id <> '') { - $adrType = 'CONV'; - if ( - strtoupper($line->format) == 'HTML' || - strtoupper($line->format) == 'MAARCH' - ) { - $adrType = 'DOC'; - } - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $line->res_id, - $adrType - ); - } - } - - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'file not already converted in pdf for thumbnails. Path : ' - . $resourcePath . ", adrType : " . $adrType, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed for thumbnails. Copy ' . $resourcePath . ' to ' . $fileNameOnTmp, - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //now do the thumbnails ! - $resultOfConversion = $this->launchThumbnails( - $fileNameOnTmp, - $tmpDir, - pathinfo($resourcePath, PATHINFO_EXTENSION) - ); - if ($resultOfConversion['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultOfConversion; - } - //find the target docserver - $targetDs = $ManageDocservers->findTargetDs($collId, 'TNL'); - if (empty($targetDs)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection and ds type not found for thumbnails:' - . $collId . ' TNL', - ); - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $returnArray; - } - //copy the result on docserver - $resultCopyDs = $ManageDocservers->copyResOnDS($fileNameOnTmp . '.png', $targetDs); - if ($resultCopyDs['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultCopyDs; - } - //update the database - $resultOfUpDb = $this->updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $targetDs, - $resultCopyDs['value']['destinationDir'], - $resultCopyDs['value']['fileDestinationName'] - ); - if ($resultOfUpDb['status'] <> '0') { - $this->manageErrorOnDb($resTable, $resId, '-1'); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.png'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - Core_Logs_Service::executionTimeLog($timestart, '', 'info', '[TIMER] Convert_ProcessThumbnailsAbstract_Service::thumbnails'); - return $returnArray; - } - - /** - * Launch the thumbnails process - * - * @param string $srcfile source file - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - private function launchThumbnails( - $srcfile, - $tgtdir=false, - $srcfmt - ) { - $timestart = microtime(true); - if (!$tgtdir) { - $tgtdir = dirname($srcfile); - } - - $output = array(); - $return = null; - $this->errors = array(); - - //wkhtmltoimage must be installed with compiled sources - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - copy($srcfile, str_ireplace('.maarch', '.', $srcfile) . '.html'); - if (file_exists('/usr/bin/mywkhtmltoimage')) { - $command = "mywkhtmltoimage --width 164 --height 105 --quality 100 --zoom 0.2 " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.png'); - } else { - $envVar = "export DISPLAY=FRPAROEMINT:0.0 ; "; - $command = $envVar . "wkhtmltoimage --width 164 --height 105 --quality 100 --zoom 0.2 " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.png'); - } - } else { - $command = "convert -thumbnail 200x300 -background white -alpha remove " - . escapeshellarg($srcfile) . "[0] " - . escapeshellarg($tgtdir . basename($srcfile) . '.png'); - } - //echo $command . PHP_EOL;exit; - $timestart_command = microtime(true); - exec($command, $output, $return); - Core_Logs_Service::debug(['message'=>'[TIMER] Commande : ' . $command]); - Core_Logs_Service::executionTimeLog($timestart_command, '', 'debug', '[TIMER] Convert_ProcessThumbnailsAbstract_Service::launchThumbnails__exec'); - - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - } - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $returnArray = array(); - unlink(str_ireplace('.maarch', '.', $srcfile) . '.html'); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - Core_Logs_Service::executionTimeLog($timestart, '', 'debug', '[TIMER] Convert_ProcessThumbnailsAbstract_Service::launchThumbnails'); - return $returnArray; - } - - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @return array $returnArray the result - */ - private function updateDatabase( - $collId, - $resTable, - $adrTable, - $resId, - $docserver, - $path, - $fileName - ) { - try { - $docserver->path_template = str_replace( - DIRECTORY_SEPARATOR, - '#', - $docserver->path_template - ); - $path = str_replace($docserver->path_template, '', $path); - $dbConv = new Database($GLOBALS['configFile']); - $query = "update convert_stack set status = 'P' where " - . " coll_id = ? and res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $collId, - $resId - ) - ); - - $query = "select * from " . $adrTable - . " where res_id = ? order by adr_priority"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "select docserver_id, path, filename, offset_doc, fingerprint" - . " from " . $resTable . " where res_id = ?"; - $stmt = $dbConv->query($query, array($resId)); - $recordset = $stmt->fetchObject(); - $resDocserverId = $recordset->docserver_id; - $resPath = $recordset->path; - $resFilename = $recordset->filename; - $resOffsetDoc = $recordset->offset_doc; - $fingerprintInit = $recordset->fingerprint; - $query = "select adr_priority_number from docservers " - . " where docserver_id = ?"; - $stmt = $dbConv->query($query, array($resDocserverId)); - $recordset = $stmt->fetchObject(); - $query = "insert into " . $adrTable . " (res_id, " - . "docserver_id, path, filename, offset_doc, fingerprint, " - . "adr_priority) values (?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $resDocserverId, - $resPath, - $resFilename, - $resOffsetDoc, - $fingerprintInit, - $recordset->adr_priority_number - ) - ); - } - - $query = "select * from " . $adrTable - . " where res_id = ? and adr_type = 'TNL'"; - $stmt = $dbConv->query($query, array($resId)); - if ($stmt->rowCount() == 0) { - $query = "insert into " . $adrTable . " (res_id, docserver_id, " - . "path, filename, offset_doc, fingerprint, adr_priority, adr_type) values (" - . "?, ?, ?, ?, ?, ?, ?, ?)"; - $stmt = $dbConv->query( - $query, - array( - $resId, - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - 'TNL' - ) - ); - } else { - $query = "update " . $adrTable . " set docserver_id = ?, " - . " path = ?, filename = ?, offset_doc = ?, fingerprint = ?, adr_priority = ?" - . " where res_id = ? and adr_type = ? "; - $stmt = $dbConv->query( - $query, - array( - $docserver->docserver_id, - $path, - $fileName, - $offsetDoc, - $fingerprint, - $docserver->adr_priority_number, - $resId, - 'TNL' - ) - ); - } - if ($_SESSION['user']['UserId'] <> '') { - $user = $_SESSION['user']['UserId']; - } else { - $user = 'CONVERT_BOT'; - } - $query = "insert into history (table_name, record_id, " - . "event_type, user_id, event_date, info, id_module) values (" - . "?, ?, 'ADD', '" . $user . "', " - . $dbConv->current_datetime() - . ", ?, 'convert')"; - $stmt = $dbConv->query( - $query, - array( - $resTable, - $resId, - "process thumbnails done" - ) - ); - - $query = "update " . $resTable - . " set tnl_result = '1', is_multi_docservers = 'Y' where " - . " res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $resId - ) - ); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - return $returnArray; - } - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - private function manageErrorOnDb( - $resTable, - $resId, - $result - ) { - $dbConv = new Database($GLOBALS['configFile']); - $query = "update " . $resTable - . " set tnl_result = ? where " - . " res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $result, - $resId - ) - ); - } - - /** - * Test if the record is already processed by convert module - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @return boolean - */ - public function isAlreadyProcessedByhumbnails( - $resTable, - $resId - ) { - $dbConv = new Database($GLOBALS['configFile']); - $query = "select tnl_result from " . $resTable - . " where res_id = ?"; - $stmt = $dbConv->query( - $query, - array( - $resId - ) - ); - $rs = $stmt->fetchObject(); - if ( - empty($rs->tnl_result) || - $rs->tnl_result == '0' - ) { - return false; - } else { - return true; - } - } -} -- GitLab