Allow thumbnail extraction configuration

This commit is contained in:
Romain Neutron
2013-08-07 15:49:48 +02:00
parent b62589fdea
commit b55c8ec61d

View File

@@ -10,6 +10,8 @@
use Alchemy\Phrasea\Core\Configuration\Configuration; use Alchemy\Phrasea\Core\Configuration\Configuration;
use MediaAlchemyst\Transmuter\Image2Image;
class task_period_subdef extends task_databoxAbstract class task_period_subdef extends task_databoxAbstract
{ {
const MINMEGS = 20; const MINMEGS = 20;
@@ -32,6 +34,8 @@ class task_period_subdef extends task_databoxAbstract
*/ */
protected $record_buffer_size; protected $record_buffer_size;
protected $thumbnailExtraction;
/** /**
* Return about text * Return about text
* *
@@ -54,6 +58,13 @@ class task_period_subdef extends task_databoxAbstract
return(_('task::subdef:creation des sous definitions')); return(_('task::subdef:creation des sous definitions'));
} }
protected function loadSettings(SimpleXMLElement $sx_task_settings)
{
$this->thumbnailExtraction = (Boolean) trim($sx_task_settings->embedded);
parent::loadSettings($sx_task_settings);
}
/** /**
* must return the xml (text) version of the form * must return the xml (text) version of the form
* *
@@ -64,14 +75,14 @@ class task_period_subdef extends task_databoxAbstract
{ {
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm2 = $request->get_parms('period', 'flush', 'maxrecs', 'maxmegs'); $parm2 = $request->get_parms('period', 'flush', 'maxrecs', 'maxmegs', 'embedded');
$dom = new DOMDocument(); $dom = new DOMDocument();
$dom->preserveWhiteSpace = false; $dom->preserveWhiteSpace = false;
$dom->formatOutput = true; $dom->formatOutput = true;
if (@$dom->loadXML($oldxml)) { if (@$dom->loadXML($oldxml)) {
$xmlchanged = false; $xmlchanged = false;
foreach (array('str:period', 'str:flush', 'str:maxrecs', 'str:maxmegs') as $pname) { foreach (array('str:period', 'str:flush', 'str:maxrecs', 'str:maxmegs', 'boo:embedded') as $pname) {
$ptype = substr($pname, 0, 3); $ptype = substr($pname, 0, 3);
$pname = substr($pname, 4); $pname = substr($pname, 4);
$pvalue = $parm2[$pname]; $pvalue = $parm2[$pname];
@@ -137,6 +148,7 @@ class task_period_subdef extends task_databoxAbstract
<?php echo $form ?>.flush.value = "<?php echo p4string::MakeString($sxml->flush, "js", '"') ?>"; <?php echo $form ?>.flush.value = "<?php echo p4string::MakeString($sxml->flush, "js", '"') ?>";
<?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>"; <?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>";
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>"; <?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
<?php echo $form ?>.embedded.value = <?php echo (Boolean) trim($sxml->embedded); ?>;
</script> </script>
<?php <?php
@@ -168,6 +180,7 @@ class task_period_subdef extends task_databoxAbstract
flush.value = xml.find("flush").text(); flush.value = xml.find("flush").text();
maxrecs.value = xml.find("maxrecs").text(); maxrecs.value = xml.find("maxrecs").text();
maxmegs.value = xml.find("maxmegs").text(); maxmegs.value = xml.find("maxmegs").text();
embedded.checked = !!parseInt(xml.find("embedded").text());
} }
} }
} }
@@ -235,6 +248,12 @@ class task_period_subdef extends task_databoxAbstract
<span class="help-inline">Mo</span> <span class="help-inline">Mo</span>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label"><?php echo _('Try to extract embedded thumbnails') ?></label>
<div class="controls">
<input class="formElem input-mini" type="checkbox" name="embedded" value="1">
</div>
</div>
</form> </form>
<?php <?php
@@ -243,6 +262,8 @@ class task_period_subdef extends task_databoxAbstract
public function retrieveSbasContent(databox $databox) public function retrieveSbasContent(databox $databox)
{ {
Image2Image::$lookForEmbeddedPreview = $this->thumbnailExtraction;
$connbas = $databox->get_connection(); $connbas = $databox->get_connection();
$sql = 'SELECT coll_id, record_id $sql = 'SELECT coll_id, record_id
@@ -347,6 +368,7 @@ class task_period_subdef extends task_databoxAbstract
<flush>%s</flush> <flush>%s</flush>
<maxrecs>%s</maxrecs> <maxrecs>%s</maxrecs>
<maxmegs>%s</maxmegs> <maxmegs>%s</maxmegs>
<embedded>0</embedded>
</tasksettings>', </tasksettings>',
min(max($period, self::MINPERIOD), self::MAXPERIOD), min(max($period, self::MINPERIOD), self::MAXPERIOD),
min(max($flush, self::MINFLUSH), self::MAXFLUSH), min(max($flush, self::MINFLUSH), self::MAXFLUSH),