mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00

Conflicts: .gitignore .travis.yml Vagrantfile lib/Alchemy/Phrasea/Controller/Datafiles.php lib/Alchemy/Phrasea/Controller/Setup.php lib/Alchemy/Phrasea/Helper/DatabaseHelper.php lib/classes/connection/pdo.php lib/classes/task/period/subdef.php lib/classes/task/period/writemeta.php locale/de_DE/LC_MESSAGES/phraseanet.mo locale/de_DE/LC_MESSAGES/phraseanet.po locale/en_GB/LC_MESSAGES/phraseanet.mo locale/en_GB/LC_MESSAGES/phraseanet.po locale/fr_FR/LC_MESSAGES/phraseanet.mo locale/fr_FR/LC_MESSAGES/phraseanet.po locale/nl_NL/LC_MESSAGES/phraseanet.mo locale/nl_NL/LC_MESSAGES/phraseanet.po locale/phraseanet.pot templates/web/setup/step2.html.twig vagrant/vms/phraseanet-php54-nginx/puphpet/config.yaml vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/setup vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup vagrant/vms/phraseanet-php54-nginx/puphpet/shell/important-notices.txt vagrant/vms/phraseanet-php54-nginx/puphpet/shell/self-promotion.txt
112 lines
3.4 KiB
PHP
112 lines
3.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\TaskManager\Job;
|
|
|
|
use Alchemy\Phrasea\TaskManager\Editor\SubdefsEditor;
|
|
use MediaAlchemyst\Transmuter\Image2Image;
|
|
|
|
class SubdefsJob extends AbstractJob
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->translator->trans('task::subdef:creation des sous definitions');
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getJobId()
|
|
{
|
|
return 'Subdefs';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getDescription()
|
|
{
|
|
return $this->translator->trans("task::subdef:creation des sous definitions des documents d'origine");
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getEditor()
|
|
{
|
|
return new SubdefsEditor($this->translator);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function doJob(JobData $data)
|
|
{
|
|
$app = $data->getApplication();
|
|
$settings = simplexml_load_string($data->getTask()->getSettings());
|
|
$thumbnailExtraction = (Boolean) (string) $settings->embedded;
|
|
|
|
Image2Image::$lookForEmbeddedPreview = $thumbnailExtraction;
|
|
|
|
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
|
|
if (!$this->isStarted()) {
|
|
break;
|
|
}
|
|
$conn = $databox->get_connection();
|
|
|
|
$sql = 'SELECT coll_id, record_id
|
|
FROM record
|
|
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
|
|
ORDER BY record_id DESC LIMIT 0, 30';
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
$stmt->closeCursor();
|
|
|
|
foreach ($rs as $row) {
|
|
if (!$this->isStarted()) {
|
|
break;
|
|
}
|
|
$this->log('info', sprintf("Generate subdefs for : sbasid=%s / databox=%s / recordid=%s ", $databox->get_sbas_id(), $databox->get_dbname() , $row['record_id']));
|
|
|
|
try {
|
|
$record = $databox->get_record($row['record_id']);
|
|
$app['subdef.generator']->generateSubdefs($record);
|
|
} catch (\Exception $e) {
|
|
$this->log('warning', sprintf("Generate subdefs failed for : sbasid=%s / databox=%s / recordid=%s : %s", $databox->get_sbas_id(), $databox->get_dbname() , $row['record_id'], $e->getMessage()));
|
|
}
|
|
|
|
$sql = 'UPDATE record
|
|
SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW()
|
|
WHERE record_id=:record_id';
|
|
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute([':record_id' => $row['record_id']]);
|
|
$stmt->closeCursor();
|
|
|
|
// rewrite metadata
|
|
$sql = 'UPDATE record
|
|
SET status=(status & ~0x03),
|
|
jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ')
|
|
WHERE record_id=:record_id';
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute([':record_id' => $row['record_id']]);
|
|
$stmt->closeCursor();
|
|
|
|
unset($record);
|
|
}
|
|
}
|
|
}
|
|
}
|