mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
PHRAS-1304_AUTO-COMPLETION_MASTER (#2061)
* PHRAS-1304_AUTO-COMPLETION_MASTER ported from 4.0 * PHRAS-1304_AUTO-COMPLETION_MASTER fix * PHRAS-1304_AUTO-COMPLETION_MASTER fix * PHRAS-1304_AUTO-COMPLETION_MASTER bump php version to 5.5.31 (5.5.21 is obsolete in cicleci) * PHRAS-1304_AUTO-COMPLETION_MASTER bump php version to 5.5.31 : php.ini moved in circelci * PHRAS-1304_AUTO-COMPLETION_MASTER add zmq & date to php for circleci * PHRAS-1304_AUTO-COMPLETION_MASTER add zmq * PHRAS-1304_AUTO-COMPLETION_MASTER bump amqp * PHRAS-1304_AUTO-COMPLETION_MASTER downgrade amqp to 1.2 to test compilation against old librabbit 0.4 (ubuntu) * PHRAS-1304_AUTO-COMPLETION_MASTER add amqp.so to php.ini, (re)bump amqp to 1.6 * PHRAS-1304_AUTO-COMPLETION_MASTER build rabittmq from git * PHRAS-1304_AUTO-COMPLETION_MASTER build rabittmq from git again * PHRAS-1304_AUTO-COMPLETION_MASTER build rabittmq from git again and again * PHRAS-1304_AUTO-COMPLETION_MASTER fix test on media rotation 600*400 -> 400*599 !!! * PHRAS-1304_AUTO-COMPLETION_MASTER restore facebook sdk to 4.0.1 due to mistake * PHRAS-1304_AUTO-COMPLETION_MASTER deleted unwanted file
This commit is contained in:
@@ -32,7 +32,7 @@ class databox_field implements cache_cacheableInterface
|
||||
protected $databox;
|
||||
|
||||
/** DO NOT IMPORT, makes PHPSTORM HANG. PHPExiftool\Driver\TagInterface */
|
||||
protected $tag;
|
||||
private $tag;
|
||||
|
||||
protected $name;
|
||||
protected $indexable;
|
||||
@@ -79,12 +79,12 @@ class databox_field implements cache_cacheableInterface
|
||||
/**
|
||||
* @var databox_Field_DCESAbstract|null
|
||||
*/
|
||||
protected $dces_element;
|
||||
private $dces_element;
|
||||
|
||||
/**
|
||||
* @var ControlProviderInterface|null
|
||||
*/
|
||||
protected $Vocabulary;
|
||||
protected $vocabulary_control;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
@@ -95,8 +95,9 @@ class databox_field implements cache_cacheableInterface
|
||||
* @var bool
|
||||
*/
|
||||
protected $VocabularyRestriction = false;
|
||||
protected $on_error = false;
|
||||
private $on_error = false;
|
||||
protected $original_src;
|
||||
protected $original_dces;
|
||||
protected $aggregable;
|
||||
|
||||
const TYPE_TEXT = "text";
|
||||
@@ -146,13 +147,11 @@ class databox_field implements cache_cacheableInterface
|
||||
$this->id = (int)$row['id'];
|
||||
$this->name = $row['name'];
|
||||
$this->original_src = $row['src'];
|
||||
$this->tag = in_array($row['src'], ['', 'Phraseanet:no-source'], true)
|
||||
? new NoSource($this->name)
|
||||
: self::loadClassFromTagName($row['src'], false);
|
||||
|
||||
if ($row['src'] !== '' && $row['src'] !== $this->tag->getTagname()) {
|
||||
$this->on_error = true;
|
||||
}
|
||||
$this->original_dces = $row['dces_element'];
|
||||
$this->tag = false; // lazy loaded on this->get_tag(), will become an object
|
||||
$this->dces_element = false; // loazy loaded on this->get_dces_element(), will become an object or null
|
||||
$this->on_error = false; // lazy calculated on this->is_on_error()
|
||||
$this->vocabulary_control = false; // lazy loaded
|
||||
|
||||
foreach (['en', 'fr', 'de', 'nl'] as $code) {
|
||||
$this->labels[$code] = $row['label_' . $code];
|
||||
@@ -171,16 +170,9 @@ class databox_field implements cache_cacheableInterface
|
||||
$this->VocabularyType = $row['VocabularyControlType'];
|
||||
$this->VocabularyRestriction = (bool)$row['RestrictToVocabularyControl'];
|
||||
|
||||
if (isset($row['dces_element'])) {
|
||||
$class = self::$knownDCES[$row['dces_element']];
|
||||
$this->dces_element = new $class();
|
||||
}
|
||||
|
||||
$this->separator = self::checkMultiSeparator($row['separator'], $this->multi);
|
||||
|
||||
$this->thumbtitle = $row['thumbtitle'];
|
||||
|
||||
$this->loadVocabulary();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +180,7 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
public function getVocabularyControl()
|
||||
{
|
||||
return $this->Vocabulary;
|
||||
return $this->vocabulary_control;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +188,12 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
public function isVocabularyRestricted()
|
||||
{
|
||||
return $this->VocabularyRestriction;
|
||||
// lazy load
|
||||
if($this->vocabulary_control === false) {
|
||||
$this->loadVocabulary();
|
||||
}
|
||||
|
||||
return $this->vocabulary_control;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +319,7 @@ class databox_field implements cache_cacheableInterface
|
||||
|
||||
$params = [
|
||||
':name' => $this->name,
|
||||
':source' => $this->tag->getTagname(),
|
||||
':source' => $this->get_tag()->getTagname(),
|
||||
':indexable' => $this->indexable ? '1' : '0',
|
||||
':readonly' => $this->readonly ? '1' : '0',
|
||||
':required' => $this->required ? '1' : '0',
|
||||
@@ -335,8 +332,8 @@ class databox_field implements cache_cacheableInterface
|
||||
':tbranch' => $this->tbranch,
|
||||
':position' => $this->position,
|
||||
':thumbtitle' => $this->thumbtitle,
|
||||
':VocabularyControlType' => $this->Vocabulary ? $this->Vocabulary->getType() : null,
|
||||
':RestrictVocab' => $this->Vocabulary ? ($this->VocabularyRestriction ? '1' : '0') : '0',
|
||||
':VocabularyControlType' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null,
|
||||
':RestrictVocab' => $this->getVocabularyControl() ? ($this->VocabularyRestriction ? '1' : '0') : '0',
|
||||
':id' => $this->id,
|
||||
':label_en' => isset($this->labels['en']) ? $this->labels['en'] : null,
|
||||
':label_fr' => isset($this->labels['fr']) ? $this->labels['fr'] : null,
|
||||
@@ -374,7 +371,7 @@ class databox_field implements cache_cacheableInterface
|
||||
$nodes_parent->item(0)->replaceChild($meta, $old_meta);
|
||||
}
|
||||
}
|
||||
$meta->setAttribute('src', $this->tag->getTagname());
|
||||
$meta->setAttribute('src', $this->get_tag()->getTagname());
|
||||
$meta->setAttribute('index', $this->indexable ? '1' : '0');
|
||||
$meta->setAttribute('readonly', $this->readonly ? '1' : '0');
|
||||
$meta->setAttribute('required', $this->required ? '1' : '0');
|
||||
@@ -444,15 +441,16 @@ class databox_field implements cache_cacheableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return databox_field
|
||||
*
|
||||
* @throws Exception_InvalidArgument
|
||||
*/
|
||||
public function set_name($name)
|
||||
{
|
||||
$previous_name = $this->name;
|
||||
|
||||
$name = self::generateName($name);
|
||||
$name = self::generateName($name, $this->app['unicode']);
|
||||
|
||||
if ($name === '') {
|
||||
throw new \Exception_InvalidArgument();
|
||||
@@ -513,6 +511,13 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
public function get_tag()
|
||||
{
|
||||
// lazy loading
|
||||
if ($this->tag === false) {
|
||||
$this->tag = in_array($this->original_src, ['', 'Phraseanet:no-source'], true)
|
||||
? new NoSource($this->name)
|
||||
: self::loadClassFromTagName($this->original_src, false);
|
||||
}
|
||||
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
@@ -521,6 +526,16 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
public function get_dces_element()
|
||||
{
|
||||
// lazy loading
|
||||
if ($this->dces_element === false) {
|
||||
if (array_key_exists($this->original_dces, self::$knownDCES)) {
|
||||
$class = self::$knownDCES[$this->original_dces];
|
||||
$this->dces_element = new $class();
|
||||
} else {
|
||||
$this->dces_element = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->dces_element;
|
||||
}
|
||||
|
||||
@@ -579,12 +594,12 @@ class databox_field implements cache_cacheableInterface
|
||||
/**
|
||||
* Set a vocabulary
|
||||
*
|
||||
* @param ControlProviderInterface $vocabulary
|
||||
* @param ControlProviderInterface $vocabulary_control
|
||||
* @return \databox_field
|
||||
*/
|
||||
public function setVocabularyControl(ControlProviderInterface $vocabulary = null)
|
||||
public function setVocabularyControl(ControlProviderInterface $vocabulary_control = null)
|
||||
{
|
||||
$this->Vocabulary = $vocabulary;
|
||||
$this->vocabulary_control = $vocabulary_control;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -864,7 +879,7 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
public function is_on_error()
|
||||
{
|
||||
return $this->on_error;
|
||||
return $this->original_src !== '' && $this->original_src !== $this->get_tag()->getTagname();
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
@@ -874,7 +889,7 @@ class databox_field implements cache_cacheableInterface
|
||||
'sbas-id' => $this->sbas_id,
|
||||
'labels' => $this->labels,
|
||||
'name' => $this->name,
|
||||
'tag' => $this->tag->getTagname(),
|
||||
'tag' => $this->get_tag()->getTagname(),
|
||||
'business' => $this->Business,
|
||||
'aggregable' => $this->aggregable,
|
||||
'type' => $this->type,
|
||||
@@ -887,8 +902,8 @@ class databox_field implements cache_cacheableInterface
|
||||
'readonly' => $this->readonly,
|
||||
'multi' => $this->multi,
|
||||
'indexable' => $this->indexable,
|
||||
'dces-element' => $this->dces_element ? $this->dces_element->get_label() : null,
|
||||
'vocabulary-type' => $this->Vocabulary ? $this->Vocabulary->getType() : null,
|
||||
'dces-element' => $this->get_dces_element() ? $this->get_dces_element()->get_label() : null,
|
||||
'vocabulary-type' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null,
|
||||
'vocabulary-restricted' => $this->VocabularyRestriction,
|
||||
];
|
||||
}
|
||||
@@ -926,7 +941,7 @@ class databox_field implements cache_cacheableInterface
|
||||
null, 0, 0, 0,
|
||||
1, :sorter, '')";
|
||||
|
||||
$name = self::generateName($name);
|
||||
$name = self::generateName($name, $app['unicode']);
|
||||
|
||||
if ($name === '') {
|
||||
throw new \Exception_InvalidArgument();
|
||||
@@ -942,10 +957,8 @@ class databox_field implements cache_cacheableInterface
|
||||
return $databox->get_meta_structure()->get_element($id);
|
||||
}
|
||||
|
||||
public static function generateName($name)
|
||||
public static function generateName($name, unicode $unicode_processor)
|
||||
{
|
||||
$unicode_processor = new unicode();
|
||||
|
||||
$name = $unicode_processor->remove_nonazAZ09($name, false, false);
|
||||
|
||||
return $unicode_processor->remove_first_digits($name);
|
||||
@@ -959,7 +972,7 @@ class databox_field implements cache_cacheableInterface
|
||||
$vars = [];
|
||||
|
||||
foreach ($this as $key => $value) {
|
||||
if (in_array($key, ['databox', 'app', 'Vocabulary']))
|
||||
if (in_array($key, ['databox', 'app', 'vocabulary_control']))
|
||||
continue;
|
||||
$vars[] = $key;
|
||||
}
|
||||
@@ -1020,7 +1033,7 @@ class databox_field implements cache_cacheableInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$this->Vocabulary = $this->app['vocabularies'][$this->VocabularyType];
|
||||
$this->vocabulary_control = $this->app['vocabularies'][$this->VocabularyType];
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Could not find Vocabulary
|
||||
}
|
||||
|
Reference in New Issue
Block a user