mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fix CS
This commit is contained in:
@@ -17,22 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Contributor extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Contributor';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Contributor';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity responsible for making contributions
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity responsible for making contributions
|
||||
to the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#contributor';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#contributor';
|
||||
|
||||
}
|
||||
|
@@ -17,23 +17,25 @@
|
||||
*/
|
||||
class databox_Field_DCES_Coverage extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Coverage';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Coverage';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The spatial or temporal topic of the resource,
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The spatial or temporal topic of the resource,
|
||||
the spatial applicability of the resource,
|
||||
or the jurisdiction under which the resource
|
||||
is relevant.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#coverage';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#coverage';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Creator extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Creator';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Creator';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity primarily responsible
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity primarily responsible
|
||||
for making the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#creator';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#creator';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Date extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Date';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Date';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A point or period of time associated with an event
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A point or period of time associated with an event
|
||||
in the lifecycle of the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#date';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#date';
|
||||
|
||||
}
|
||||
|
@@ -17,20 +17,22 @@
|
||||
*/
|
||||
class databox_Field_DCES_Description extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Description';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An account of the resource.';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#description';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Description';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An account of the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#description';
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Format extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Format';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Format';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The file format, physical medium,
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The file format, physical medium,
|
||||
or dimensions of the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#format';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#format';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Identifier extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Identifier';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Identifier';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An unambiguous reference to the resource
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An unambiguous reference to the resource
|
||||
within a given context.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#identifier';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#identifier';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Language extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Language';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Language';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A language of the resource.
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A language of the resource.
|
||||
(see [RFC4646] http://www.ietf.org/rfc/rfc4646.txt)';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#language';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#language';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Publisher extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Publisher';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Publisher';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity responsible for making the resource
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'An entity responsible for making the resource
|
||||
available.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#publisher';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#publisher';
|
||||
|
||||
}
|
||||
|
@@ -17,20 +17,22 @@
|
||||
*/
|
||||
class databox_Field_DCES_Relation extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Relation';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A related resource.';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#relation';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Relation';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A related resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#relation';
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Rights extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Rights';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Rights';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'Information about rights held
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'Information about rights held
|
||||
in and over the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#rights';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#rights';
|
||||
|
||||
}
|
||||
|
@@ -17,21 +17,23 @@
|
||||
*/
|
||||
class databox_Field_DCES_Source extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Source';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Source';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A related resource from which
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A related resource from which
|
||||
the described resource is derived.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#source';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#source';
|
||||
|
||||
}
|
||||
|
@@ -17,20 +17,22 @@
|
||||
*/
|
||||
class databox_Field_DCES_Subject extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Subject';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The topic of the resource.';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#subject';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Subject';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The topic of the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#subject';
|
||||
}
|
||||
|
@@ -17,20 +17,22 @@
|
||||
*/
|
||||
class databox_Field_DCES_Title extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Title';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A name given to the resource.';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#title';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Title';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'A name given to the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#title';
|
||||
}
|
||||
|
@@ -17,20 +17,22 @@
|
||||
*/
|
||||
class databox_Field_DCES_Type extends databox_Field_DCESAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Type';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The nature or genre of the resource.';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#type';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'Type';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $definition = 'The nature or genre of the resource.';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $URI = 'http://dublincore.org/documents/dces/#type';
|
||||
}
|
||||
|
@@ -17,104 +17,94 @@
|
||||
*/
|
||||
class databox_cgu
|
||||
{
|
||||
public function __construct(databox $databox, $locale)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function askAgreement()
|
||||
{
|
||||
$terms = self::getUnvalidated();
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($terms as $name => $term)
|
||||
public function __construct(databox $databox, $locale)
|
||||
{
|
||||
if (trim($term['terms']) == '')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$out .= '<div style="display:none;" class="cgu-dialog" title="' . str_replace('"', '"', sprintf(_('cgus:: CGUs de la base %s'), $name)) . '">';
|
||||
return $this;
|
||||
}
|
||||
|
||||
$out .= '<blockquote>' . $term['terms'] . '</blockquote>';
|
||||
$out .= '<div>' . _('cgus:: Pour continuer a utiliser lapplication, vous devez accepter les conditions precedentes') . '
|
||||
public static function askAgreement()
|
||||
{
|
||||
$terms = self::getUnvalidated();
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($terms as $name => $term) {
|
||||
if (trim($term['terms']) == '') {
|
||||
continue;
|
||||
}
|
||||
$out .= '<div style="display:none;" class="cgu-dialog" title="' . str_replace('"', '"', sprintf(_('cgus:: CGUs de la base %s'), $name)) . '">';
|
||||
|
||||
$out .= '<blockquote>' . $term['terms'] . '</blockquote>';
|
||||
$out .= '<div>' . _('cgus:: Pour continuer a utiliser lapplication, vous devez accepter les conditions precedentes') . '
|
||||
<input id="terms_of_use_' . $term['sbas_id'] . '" type="button" date="' . $term['date'] . '" class="cgus-accept" value="' . _('cgus :: accepter') . '"/>
|
||||
<input id="sbas_' . $term['sbas_id'] . '" type="button" class="cgus-cancel" value="' . _('cgus :: refuser') . '"/>
|
||||
</div>';
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
private static function getUnvalidated($home=false)
|
||||
{
|
||||
$terms = array();
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$session = $appbox->get_session();
|
||||
|
||||
if(!$home)
|
||||
{
|
||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||
}
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
try
|
||||
{
|
||||
$cgus = $databox->get_cgus();
|
||||
|
||||
if (!isset($cgus[Session_Handler::get_locale()]))
|
||||
throw new Exception('No CGus for this locale');
|
||||
$name = $databox->get_viewname();
|
||||
|
||||
$update = $cgus[Session_Handler::get_locale()]['updated_on'];
|
||||
$value = $cgus[Session_Handler::get_locale()]['value'];
|
||||
$userValidation = true;
|
||||
|
||||
if (!$home)
|
||||
{
|
||||
if(!$user->ACL()->has_access_to_sbas($databox->get_sbas_id()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$userValidation = ($user->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== '');
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
if ($userValidation)
|
||||
$terms[$name] = array('sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
return $terms;
|
||||
}
|
||||
|
||||
public static function getHome()
|
||||
{
|
||||
$terms = self::getUnvalidated(true);
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($terms as $name => $term)
|
||||
private static function getUnvalidated($home = false)
|
||||
{
|
||||
if (trim($term['terms']) == '')
|
||||
continue;
|
||||
$terms = array();
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$session = $appbox->get_session();
|
||||
|
||||
if ($out != '')
|
||||
$out .= '<hr/>';
|
||||
if ( ! $home) {
|
||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||
}
|
||||
|
||||
$out .= '<div><h1 style="text-align:center;">' . str_replace('"', '"', sprintf(_('cgus:: CGUs de la base %s'), $name)) . '</h1>';
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
try {
|
||||
$cgus = $databox->get_cgus();
|
||||
|
||||
$out .= '<blockquote>' . $term['terms'] . '</blockquote>';
|
||||
if ( ! isset($cgus[Session_Handler::get_locale()]))
|
||||
throw new Exception('No CGus for this locale');
|
||||
$name = $databox->get_viewname();
|
||||
|
||||
$out .= '</div>';
|
||||
$update = $cgus[Session_Handler::get_locale()]['updated_on'];
|
||||
$value = $cgus[Session_Handler::get_locale()]['value'];
|
||||
$userValidation = true;
|
||||
|
||||
if ( ! $home) {
|
||||
if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) {
|
||||
continue;
|
||||
}
|
||||
$userValidation = ($user->getPrefs('terms_of_use_' . $databox->get_sbas_id()) !== $update && trim($value) !== '');
|
||||
}
|
||||
|
||||
if ($userValidation)
|
||||
$terms[$name] = array('sbas_id' => $databox->get_sbas_id(), 'terms' => $value, 'date' => $update);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $terms;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
public static function getHome()
|
||||
{
|
||||
$terms = self::getUnvalidated(true);
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($terms as $name => $term) {
|
||||
if (trim($term['terms']) == '')
|
||||
continue;
|
||||
|
||||
if ($out != '')
|
||||
$out .= '<hr/>';
|
||||
|
||||
$out .= '<div><h1 style="text-align:center;">' . str_replace('"', '"', sprintf(_('cgus:: CGUs de la base %s'), $name)) . '</h1>';
|
||||
|
||||
$out .= '<blockquote>' . $term['terms'] . '</blockquote>';
|
||||
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
@@ -17,109 +17,105 @@
|
||||
*/
|
||||
class databox_descriptionStructure implements IteratorAggregate
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $elements = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $elements = array();
|
||||
/**
|
||||
* Cache array for the get element by name function
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $cache_name_id = array();
|
||||
/**
|
||||
* Cache array for the get element by name function
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $cache_name_id = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return databox_field
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox_field $field
|
||||
* @return databox_descriptionStructure
|
||||
*/
|
||||
public function add_element(databox_field $field)
|
||||
{
|
||||
$this->elements[$field->get_id()] = $field;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox_field $field
|
||||
* @return databox_descriptionStructure
|
||||
*/
|
||||
public function remove_element(databox_field $field)
|
||||
{
|
||||
if (isset($this->elements[$field->get_id()]))
|
||||
unset($this->elements[$field->get_id()]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_elements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $id
|
||||
* @return databox_field
|
||||
*/
|
||||
public function get_element($id)
|
||||
{
|
||||
if (!isset($this->elements[$id]))
|
||||
throw new Exception_Databox_FieldNotFound ();
|
||||
|
||||
return $this->elements[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @return databox_field
|
||||
*/
|
||||
public function get_element_by_name($name)
|
||||
{
|
||||
$name = databox_field::generateName($name);
|
||||
|
||||
if (isset($this->cache_name_id[$name]))
|
||||
|
||||
return $this->elements[$this->cache_name_id[$name]];
|
||||
|
||||
foreach ($this->elements as $id => $meta)
|
||||
/**
|
||||
*
|
||||
* @return databox_field
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
if ($meta->get_name() === $name)
|
||||
{
|
||||
$this->cache_name_id[$name] = $id;
|
||||
|
||||
return $meta;
|
||||
}
|
||||
return new ArrayIterator($this->elements);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param databox_field $field
|
||||
* @return databox_descriptionStructure
|
||||
*/
|
||||
public function add_element(databox_field $field)
|
||||
{
|
||||
$this->elements[$field->get_id()] = $field;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $id
|
||||
* @return boolean
|
||||
*/
|
||||
public function isset_element($id)
|
||||
{
|
||||
return isset($this->elements[$id]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox_field $field
|
||||
* @return databox_descriptionStructure
|
||||
*/
|
||||
public function remove_element(databox_field $field)
|
||||
{
|
||||
if (isset($this->elements[$field->get_id()]))
|
||||
unset($this->elements[$field->get_id()]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_elements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $id
|
||||
* @return databox_field
|
||||
*/
|
||||
public function get_element($id)
|
||||
{
|
||||
if ( ! isset($this->elements[$id]))
|
||||
throw new Exception_Databox_FieldNotFound ();
|
||||
|
||||
return $this->elements[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @return databox_field
|
||||
*/
|
||||
public function get_element_by_name($name)
|
||||
{
|
||||
$name = databox_field::generateName($name);
|
||||
|
||||
if (isset($this->cache_name_id[$name]))
|
||||
return $this->elements[$this->cache_name_id[$name]];
|
||||
|
||||
foreach ($this->elements as $id => $meta) {
|
||||
if ($meta->get_name() === $name) {
|
||||
$this->cache_name_id[$name] = $id;
|
||||
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $id
|
||||
* @return boolean
|
||||
*/
|
||||
public function isset_element($id)
|
||||
{
|
||||
return isset($this->elements[$id]);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -18,78 +18,73 @@
|
||||
class databox_fieldUnknown extends databox_field
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox $databox
|
||||
* @param int $id
|
||||
* @return databox_fieldUnknown
|
||||
*/
|
||||
public function __construct(databox $databox, $id)
|
||||
{
|
||||
$this->set_databox($databox);
|
||||
$this->sbas_id = $databox->get_sbas_id();
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox $databox
|
||||
* @param int $id
|
||||
* @return databox_fieldUnknown
|
||||
*/
|
||||
public static function get_instance(databox &$databox, $id)
|
||||
{
|
||||
$cache_key = 'field_' . $id;
|
||||
$instance_id = $databox->get_sbas_id() . '_' . $id;
|
||||
if (!isset(self::$_instance[$instance_id]) || (self::$_instance[$instance_id] instanceof self) === false)
|
||||
/**
|
||||
*
|
||||
* @param databox $databox
|
||||
* @param int $id
|
||||
* @return databox_fieldUnknown
|
||||
*/
|
||||
public function __construct(databox $databox, $id)
|
||||
{
|
||||
try
|
||||
{
|
||||
self::$_instance[$instance_id] = $databox->get_data_from_cache($cache_key);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
self::$_instance[$instance_id] = new self($databox, $id);
|
||||
$databox->set_data_to_cache(self::$_instance[$instance_id], $cache_key);
|
||||
}
|
||||
$this->set_databox($databox);
|
||||
$this->sbas_id = $databox->get_sbas_id();
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return self::$_instance[$instance_id];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param databox $databox
|
||||
* @param int $id
|
||||
* @return databox_fieldUnknown
|
||||
*/
|
||||
public static function get_instance(databox &$databox, $id)
|
||||
{
|
||||
$cache_key = 'field_' . $id;
|
||||
$instance_id = $databox->get_sbas_id() . '_' . $id;
|
||||
if ( ! isset(self::$_instance[$instance_id]) || (self::$_instance[$instance_id] instanceof self) === false) {
|
||||
try {
|
||||
self::$_instance[$instance_id] = $databox->get_data_from_cache($cache_key);
|
||||
} catch (Exception $e) {
|
||||
self::$_instance[$instance_id] = new self($databox, $id);
|
||||
$databox->set_data_to_cache(self::$_instance[$instance_id], $cache_key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metadata_source()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return self::$_instance[$instance_id];
|
||||
}
|
||||
|
||||
public function get_metadata_namespace()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metadata_source()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metadata_tagname()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
public function get_metadata_namespace()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true because the field is unknown
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_on_error()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_metadata_tagname()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true because the field is unknown
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_on_error()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,6 @@ use Alchemy\Phrasea\Media\Type\Type as SubdefType;
|
||||
*/
|
||||
class databox_subdef
|
||||
{
|
||||
|
||||
/**
|
||||
* The class type of the subdef
|
||||
* Is null or one of the CLASS_* constants
|
||||
@@ -42,16 +41,16 @@ class databox_subdef
|
||||
protected $write_meta;
|
||||
protected $downloadable;
|
||||
protected static $mediaTypeToSubdefTypes = array(
|
||||
SubdefType::TYPE_AUDIO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO),
|
||||
SubdefType::TYPE_DOCUMENT => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER),
|
||||
SubdefType::TYPE_FLASH => array(SubdefSpecs::TYPE_IMAGE),
|
||||
SubdefType::TYPE_IMAGE => array(SubdefSpecs::TYPE_IMAGE),
|
||||
SubdefType::TYPE_VIDEO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION),
|
||||
SubdefType::TYPE_AUDIO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO),
|
||||
SubdefType::TYPE_DOCUMENT => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER),
|
||||
SubdefType::TYPE_FLASH => array(SubdefSpecs::TYPE_IMAGE),
|
||||
SubdefType::TYPE_IMAGE => array(SubdefSpecs::TYPE_IMAGE),
|
||||
SubdefType::TYPE_VIDEO => array(SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION),
|
||||
);
|
||||
|
||||
const CLASS_THUMBNAIL = 'thumbnail';
|
||||
const CLASS_PREVIEW = 'preview';
|
||||
const CLASS_DOCUMENT = 'document';
|
||||
const CLASS_PREVIEW = 'preview';
|
||||
const CLASS_DOCUMENT = 'document';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -70,18 +69,15 @@ class databox_subdef
|
||||
|
||||
$this->write_meta = p4field::isyes((string) $sd->meta);
|
||||
|
||||
foreach ($sd->label as $label)
|
||||
{
|
||||
foreach ($sd->label as $label) {
|
||||
$lang = trim((string) $label->attributes()->lang);
|
||||
|
||||
if ($lang)
|
||||
{
|
||||
if ($lang) {
|
||||
$this->labels[$lang] = (string) $label;
|
||||
}
|
||||
}
|
||||
|
||||
switch ((string) $sd->mediatype)
|
||||
{
|
||||
switch ((string) $sd->mediatype) {
|
||||
default:
|
||||
case SubdefSpecs::TYPE_IMAGE:
|
||||
$this->subdef_type = $this->buildImageSubdef($sd);
|
||||
@@ -107,20 +103,16 @@ class databox_subdef
|
||||
{
|
||||
$image = new Image();
|
||||
|
||||
if ($sd->size)
|
||||
{
|
||||
if ($sd->size) {
|
||||
$image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size);
|
||||
}
|
||||
if ($sd->quality)
|
||||
{
|
||||
if ($sd->quality) {
|
||||
$image->setOptionValue(Image::OPTION_QUALITY, (int) $sd->quality);
|
||||
}
|
||||
if ($sd->strip)
|
||||
{
|
||||
if ($sd->strip) {
|
||||
$image->setOptionValue(Image::OPTION_STRIP, p4field::isyes($sd->strip));
|
||||
}
|
||||
if ($sd->dpi)
|
||||
{
|
||||
if ($sd->dpi) {
|
||||
$image->setOptionValue(Image::OPTION_RESOLUTION, (int) $sd->dpi);
|
||||
}
|
||||
|
||||
@@ -141,12 +133,10 @@ class databox_subdef
|
||||
{
|
||||
$gif = new Gif();
|
||||
|
||||
if ($sd->size)
|
||||
{
|
||||
if ($sd->size) {
|
||||
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
|
||||
}
|
||||
if ($sd->delay)
|
||||
{
|
||||
if ($sd->delay) {
|
||||
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
|
||||
}
|
||||
|
||||
@@ -157,24 +147,19 @@ class databox_subdef
|
||||
{
|
||||
$video = new Video();
|
||||
|
||||
if ($sd->size)
|
||||
{
|
||||
if ($sd->size) {
|
||||
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
|
||||
}
|
||||
if ($sd->a_codec)
|
||||
{
|
||||
if ($sd->a_codec) {
|
||||
$video->setOptionValue(Video::OPTION_ACODEC, (string) $sd->acodec);
|
||||
}
|
||||
if ($sd->v_codec)
|
||||
{
|
||||
if ($sd->v_codec) {
|
||||
$video->setOptionValue(Video::OPTION_VCODEC, (string) $sd->vcodec);
|
||||
}
|
||||
if ($sd->fps)
|
||||
{
|
||||
if ($sd->fps) {
|
||||
$video->setOptionValue(Video::OPTION_FRAMERATE, (int) $sd->fps);
|
||||
}
|
||||
if ($sd->bitrate)
|
||||
{
|
||||
if ($sd->bitrate) {
|
||||
$video->setOptionValue(Video::OPTION_BITRATE, (int) $sd->bitrate);
|
||||
}
|
||||
|
||||
@@ -244,18 +229,12 @@ class databox_subdef
|
||||
{
|
||||
$subdefTypes = array();
|
||||
|
||||
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()]))
|
||||
{
|
||||
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType)
|
||||
{
|
||||
if ($subdefType == $this->subdef_type->getType())
|
||||
{
|
||||
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
|
||||
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
|
||||
if ($subdefType == $this->subdef_type->getType()) {
|
||||
$mediatype_obj = $this->subdef_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($subdefType)
|
||||
{
|
||||
} else {
|
||||
switch ($subdefType) {
|
||||
case SubdefSpecs::TYPE_ANIMATION:
|
||||
$mediatype_obj = new Gif();
|
||||
break;
|
||||
@@ -316,5 +295,4 @@ class databox_subdef
|
||||
{
|
||||
return $this->subdef_type->getOptions();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
class databox_subdefsStructure implements IteratorAggregate
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
@@ -51,10 +50,8 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
{
|
||||
$searchGroup = strtolower($searchGroup);
|
||||
|
||||
foreach ($this->AvSubdefs as $groupname => $subdefgroup)
|
||||
{
|
||||
if ($searchGroup == $groupname)
|
||||
{
|
||||
foreach ($this->AvSubdefs as $groupname => $subdefgroup) {
|
||||
if ($searchGroup == $groupname) {
|
||||
return $subdefgroup;
|
||||
}
|
||||
}
|
||||
@@ -71,36 +68,31 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
$sx_struct = $this->databox->get_sxml_structure();
|
||||
|
||||
$this->AvSubdefs = array(
|
||||
'image' => array(),
|
||||
'video' => array(),
|
||||
'audio' => array(),
|
||||
'document' => array(),
|
||||
'flash' => array()
|
||||
'image' => array(),
|
||||
'video' => array(),
|
||||
'audio' => array(),
|
||||
'document' => array(),
|
||||
'flash' => array()
|
||||
);
|
||||
|
||||
if ( ! $sx_struct)
|
||||
{
|
||||
if ( ! $sx_struct) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$subdefgroup = $sx_struct->subdefs[0];
|
||||
|
||||
|
||||
foreach ($subdefgroup as $k => $subdefs)
|
||||
{
|
||||
foreach ($subdefgroup as $k => $subdefs) {
|
||||
$subdefgroup_name = strtolower($subdefs->attributes()->name);
|
||||
|
||||
if ( ! isset($AvSubdefs[$subdefgroup_name]))
|
||||
{
|
||||
if ( ! isset($AvSubdefs[$subdefgroup_name])) {
|
||||
$AvSubdefs[$subdefgroup_name] = array();
|
||||
}
|
||||
|
||||
foreach ($subdefs as $sd)
|
||||
{
|
||||
foreach ($subdefs as $sd) {
|
||||
$subdef_name = strtolower($sd->attributes()->name);
|
||||
|
||||
switch ($subdefgroup_name)
|
||||
{
|
||||
switch ($subdefgroup_name) {
|
||||
case 'audio':
|
||||
$type = new \Alchemy\Phrasea\Media\Type\Audio();
|
||||
break;
|
||||
@@ -137,8 +129,7 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
*/
|
||||
public function get_subdef($subdef_type, $subdef_name)
|
||||
{
|
||||
if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name]))
|
||||
{
|
||||
if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name])) {
|
||||
return $this->AvSubdefs[$subdef_type][$subdef_name];
|
||||
}
|
||||
throw new Exception_Databox_SubdefNotFound();
|
||||
@@ -154,16 +145,15 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
{
|
||||
|
||||
$dom_struct = $this->databox->get_dom_structure();
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
$nodes = $dom_xp->query(
|
||||
'//record/subdefs/'
|
||||
. 'subdefgroup[@name="' . $group . '"]/'
|
||||
. 'subdef[@name="' . $name . '"]'
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
$nodes = $dom_xp->query(
|
||||
'//record/subdefs/'
|
||||
. 'subdefgroup[@name="' . $group . '"]/'
|
||||
. 'subdef[@name="' . $name . '"]'
|
||||
);
|
||||
|
||||
if ($nodes->length > 0)
|
||||
{
|
||||
$node = $nodes->item(0);
|
||||
if ($nodes->length > 0) {
|
||||
$node = $nodes->item(0);
|
||||
$parent = $node->parentNode;
|
||||
$parent->removeChild($node);
|
||||
}
|
||||
@@ -192,17 +182,14 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
$subdef->setAttribute('name', mb_strtolower($name));
|
||||
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
||||
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
||||
$groups = $dom_xp->query($query);
|
||||
|
||||
if ($groups->length == 0)
|
||||
{
|
||||
if ($groups->length == 0) {
|
||||
$group = $dom_struct->createElement('subdefgroup');
|
||||
$group->setAttribute('name', $groupname);
|
||||
$dom_xp->query('/record/subdefs')->item(0)->appendChild($group);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$group = $groups->item(0);
|
||||
}
|
||||
|
||||
@@ -233,8 +220,7 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
$subdef->setAttribute('name', mb_strtolower($name));
|
||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||
|
||||
foreach ($options as $option => $value)
|
||||
{
|
||||
foreach ($options as $option => $value) {
|
||||
$child = $dom_struct->createElement($option);
|
||||
$child->appendChild($dom_struct->createTextNode($value));
|
||||
$subdef->appendChild($child);
|
||||
@@ -243,37 +229,29 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
|
||||
$nodes = $dom_xp->query('//record/subdefs/'
|
||||
. 'subdefgroup[@name="' . $group . '"]');
|
||||
if ($nodes->length > 0)
|
||||
{
|
||||
. 'subdefgroup[@name="' . $group . '"]');
|
||||
if ($nodes->length > 0) {
|
||||
$dom_group = $nodes->item(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$dom_group = $dom_struct->createElement('subdefgroup');
|
||||
$dom_group->setAttribute('name', $group);
|
||||
|
||||
$nodes = $dom_xp->query('//record/subdefs');
|
||||
if ($nodes->length > 0)
|
||||
{
|
||||
if ($nodes->length > 0) {
|
||||
$nodes->item(0)->appendChild($dom_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
throw new Exception('Unable to find /record/subdefs xquery');
|
||||
}
|
||||
}
|
||||
|
||||
$nodes = $dom_xp->query(
|
||||
'//record/subdefs/'
|
||||
. 'subdefgroup[@name="' . $group . '"]/'
|
||||
. 'subdef[@name="' . $name . '"]'
|
||||
'//record/subdefs/'
|
||||
. 'subdefgroup[@name="' . $group . '"]/'
|
||||
. 'subdef[@name="' . $name . '"]'
|
||||
);
|
||||
|
||||
if ($nodes->length > 0)
|
||||
{
|
||||
for ($i = 0; $i < $nodes->length; $i ++ )
|
||||
{
|
||||
if ($nodes->length > 0) {
|
||||
for ($i = 0; $i < $nodes->length; $i ++ ) {
|
||||
$dom_group->removeChild($nodes->item($i));
|
||||
}
|
||||
}
|
||||
@@ -286,5 +264,4 @@ class databox_subdefsStructure implements IteratorAggregate
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user