mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
IUpdate databox fields and status
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
@@ -22,9 +25,9 @@ class databox_cgu
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function askAgreement()
|
public static function askAgreement(Application $app)
|
||||||
{
|
{
|
||||||
$terms = self::getUnvalidated();
|
$terms = self::getUnvalidated($app);
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
@@ -45,26 +48,25 @@ class databox_cgu
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getUnvalidated($home = false)
|
private static function getUnvalidated(Application $app, $home = false)
|
||||||
{
|
{
|
||||||
$terms = array();
|
$terms = array();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$session = $appbox->get_session();
|
|
||||||
|
|
||||||
if ( ! $home) {
|
if ( ! $home) {
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = $app['phraseanet.user'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
try {
|
try {
|
||||||
$cgus = $databox->get_cgus();
|
$cgus = $databox->get_cgus();
|
||||||
|
|
||||||
if ( ! isset($cgus[Session_Handler::get_locale()]))
|
if ( ! isset($cgus[$app['locale']]))
|
||||||
throw new Exception('No CGus for this locale');
|
throw new Exception('No CGus for this locale');
|
||||||
$name = $databox->get_viewname();
|
$name = $databox->get_viewname();
|
||||||
|
|
||||||
$update = $cgus[Session_Handler::get_locale()]['updated_on'];
|
$update = $cgus[$app['locale']]['updated_on'];
|
||||||
$value = $cgus[Session_Handler::get_locale()]['value'];
|
$value = $cgus[$app['locale']]['value'];
|
||||||
$userValidation = true;
|
$userValidation = true;
|
||||||
|
|
||||||
if ( ! $home) {
|
if ( ! $home) {
|
||||||
@@ -84,9 +86,9 @@ class databox_cgu
|
|||||||
return $terms;
|
return $terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getHome()
|
public static function getHome($app)
|
||||||
{
|
{
|
||||||
$terms = self::getUnvalidated(true);
|
$terms = self::getUnvalidated($app, true);
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
|
@@ -9,7 +9,12 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \Alchemy\Phrasea\Vocabulary;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Vocabulary;
|
||||||
|
use Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface;
|
||||||
|
use Alchemy\Phrasea\Metadata\Tag\Nosource;
|
||||||
|
use PHPExiftool\Driver\TagInterface;
|
||||||
|
use PHPExiftool\Driver\TagFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -154,8 +159,9 @@ class databox_field implements cache_cacheableInterface
|
|||||||
* @param <type> $id
|
* @param <type> $id
|
||||||
* @return databox_field
|
* @return databox_field
|
||||||
*/
|
*/
|
||||||
protected function __construct(databox &$databox, $id)
|
protected function __construct(Application $app, databox &$databox, $id)
|
||||||
{
|
{
|
||||||
|
$this->app = $app;
|
||||||
$this->set_databox($databox);
|
$this->set_databox($databox);
|
||||||
$this->sbas_id = $databox->get_sbas_id();
|
$this->sbas_id = $databox->get_sbas_id();
|
||||||
|
|
||||||
@@ -191,7 +197,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$this->tbranch = $row['tbranch'];
|
$this->tbranch = $row['tbranch'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->Vocabulary = Vocabulary\Controller::get($row['VocabularyControlType']);
|
$this->Vocabulary = Vocabulary\Controller::get($this->app, $row['VocabularyControlType']);
|
||||||
$this->VocabularyRestriction = ! ! $row['RestrictToVocabularyControl'];
|
$this->VocabularyRestriction = ! ! $row['RestrictToVocabularyControl'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
@@ -242,7 +248,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \databox_field
|
* @return \databox_field
|
||||||
*/
|
*/
|
||||||
public static function get_instance(databox &$databox, $id)
|
public static function get_instance(Application $app, databox &$databox, $id)
|
||||||
{
|
{
|
||||||
$cache_key = 'field_' . $id;
|
$cache_key = 'field_' . $id;
|
||||||
$instance_id = $databox->get_sbas_id() . '_' . $id;
|
$instance_id = $databox->get_sbas_id() . '_' . $id;
|
||||||
@@ -250,7 +256,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
try {
|
try {
|
||||||
self::$_instance[$instance_id] = $databox->get_data_from_cache($cache_key);
|
self::$_instance[$instance_id] = $databox->get_data_from_cache($cache_key);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
self::$_instance[$instance_id] = new self($databox, $id);
|
self::$_instance[$instance_id] = new self($app, $databox, $id);
|
||||||
$databox->set_data_to_cache(self::$_instance[$instance_id], $cache_key);
|
$databox->set_data_to_cache(self::$_instance[$instance_id], $cache_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,7 +293,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
caption_field::delete_all_metadatas($this);
|
caption_field::delete_all_metadatas($this->app, $this);
|
||||||
|
|
||||||
$connbas = $this->get_connection();
|
$connbas = $this->get_connection();
|
||||||
$sql = 'DELETE FROM metadatas_structure WHERE id = :id';
|
$sql = 'DELETE FROM metadatas_structure WHERE id = :id';
|
||||||
@@ -461,16 +467,16 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$tag = new $classname();
|
$tag = new $classname();
|
||||||
} else {
|
} else {
|
||||||
$tag = \PHPExiftool\Driver\TagFactory::getFromRDFTagname($tagName);
|
$tag = TagFactory::getFromRDFTagname($tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_tag(\PHPExiftool\Driver\Tag $tag = null)
|
public function set_tag(TagInterface $tag = null)
|
||||||
{
|
{
|
||||||
if ($tag === null) {
|
if ($tag === null) {
|
||||||
$tag = new \Alchemy\Phrasea\Metadata\Tag\Nosource();
|
$tag = new Nosource();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tag = $tag;
|
$this->tag = $tag;
|
||||||
@@ -531,10 +537,10 @@ class databox_field implements cache_cacheableInterface
|
|||||||
/**
|
/**
|
||||||
* Set a vocabulary
|
* Set a vocabulary
|
||||||
*
|
*
|
||||||
* @param Vocabulary\ControlProvider\ControlProviderInterface $vocabulary
|
* @param ControlProviderInterface $vocabulary
|
||||||
* @return \databox_field
|
* @return \databox_field
|
||||||
*/
|
*/
|
||||||
public function setVocabularyControl(Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null)
|
public function setVocabularyControl(ControlProviderInterface $vocabulary = null)
|
||||||
{
|
{
|
||||||
$this->Vocabulary = $vocabulary;
|
$this->Vocabulary = $vocabulary;
|
||||||
|
|
||||||
@@ -787,7 +793,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this->on_error;
|
return $this->on_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(databox $databox, $name, $multi)
|
public static function create(Application $app, databox $databox, $name, $multi)
|
||||||
{
|
{
|
||||||
$sorter = 0;
|
$sorter = 0;
|
||||||
|
|
||||||
@@ -823,7 +829,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
|
$databox->delete_data_from_cache(databox::CACHE_META_STRUCT);
|
||||||
|
|
||||||
return self::get_instance($databox, $id);
|
return self::get_instance($app, $databox, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateName($name)
|
public static function generateName($name)
|
||||||
@@ -857,9 +863,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
$this->set_databox($this->app['phraseanet.appbox']->get_databox($this->sbas_id));
|
||||||
$databox = $appbox->get_databox($this->sbas_id);
|
|
||||||
$this->set_databox($databox);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
use MediaAlchemyst\Specification\Image as ImageSpecification;
|
use MediaAlchemyst\Specification\Image as ImageSpecification;
|
||||||
|
use MediaAlchemyst\Alchemyst;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||||
@@ -57,16 +59,14 @@ class databox_status
|
|||||||
* @param int $sbas_id
|
* @param int $sbas_id
|
||||||
* @return status
|
* @return status
|
||||||
*/
|
*/
|
||||||
private function __construct($sbas_id)
|
private function __construct(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->status = array();
|
$this->status = array();
|
||||||
|
|
||||||
$path = $url = false;
|
$path = $url = false;
|
||||||
|
|
||||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
$sbas_params = phrasea::sbas_params($app);
|
||||||
$sbas_params = phrasea::sbas_params();
|
$registry = $app['phraseanet.registry'];
|
||||||
$registry = registry::get_instance();
|
|
||||||
|
|
||||||
if ( ! isset($sbas_params[$sbas_id])) {
|
if ( ! isset($sbas_params[$sbas_id])) {
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +75,7 @@ class databox_status
|
|||||||
$path = $this->path = $registry->get('GV_RootPath') . "config/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
$path = $this->path = $registry->get('GV_RootPath') . "config/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
||||||
$url = $this->url = "/custom/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
$url = $this->url = "/custom/status/" . urlencode($sbas_params[$sbas_id]["host"]) . "-" . urlencode($sbas_params[$sbas_id]["port"]) . "-" . urlencode($sbas_params[$sbas_id]["dbname"]);
|
||||||
|
|
||||||
$databox = $appbox->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$xmlpref = $databox->get_structure();
|
$xmlpref = $databox->get_structure();
|
||||||
$sxe = simplexml_load_string($xmlpref);
|
$sxe = simplexml_load_string($xmlpref);
|
||||||
|
|
||||||
@@ -111,24 +111,22 @@ class databox_status
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getStatus($sbas_id)
|
public static function getStatus(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( ! isset(self::$_status[$sbas_id]))
|
if ( ! isset(self::$_status[$sbas_id]))
|
||||||
self::$_status[$sbas_id] = new databox_status($sbas_id);
|
self::$_status[$sbas_id] = new databox_status($app, $sbas_id);
|
||||||
|
|
||||||
return self::$_status[$sbas_id]->status;
|
return self::$_status[$sbas_id]->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDisplayStatus()
|
public static function getDisplayStatus(Application $app)
|
||||||
{
|
{
|
||||||
if (self::$_statuses) {
|
if (self::$_statuses) {
|
||||||
return self::$_statuses;
|
return self::$_statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$user = $app['phraseanet.user'];
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
|
||||||
|
|
||||||
$sbas_ids = $user->ACL()->get_granted_sbas();
|
$sbas_ids = $user->ACL()->get_granted_sbas();
|
||||||
|
|
||||||
@@ -147,11 +145,9 @@ class databox_status
|
|||||||
return self::$_statuses;
|
return self::$_statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSearchStatus()
|
public static function getSearchStatus(Application $app)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$user = $app['phraseanet.user'];
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
|
||||||
|
|
||||||
$statuses = array();
|
$statuses = array();
|
||||||
|
|
||||||
@@ -227,41 +223,30 @@ class databox_status
|
|||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPath($sbas_id)
|
public static function getPath(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
if ( ! isset(self::$_status[$sbas_id])) {
|
if ( ! isset(self::$_status[$sbas_id])) {
|
||||||
self::$_status[$sbas_id] = new databox_status($sbas_id);
|
self::$_status[$sbas_id] = new databox_status($app, $sbas_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_status[$sbas_id]->path;
|
return self::$_status[$sbas_id]->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUrl($sbas_id)
|
public static function getUrl(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
if ( ! isset(self::$_status[$sbas_id])) {
|
if ( ! isset(self::$_status[$sbas_id])) {
|
||||||
self::$_status[$sbas_id] = new databox_status($sbas_id);
|
self::$_status[$sbas_id] = new databox_status($app, $sbas_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_status[$sbas_id]->url;
|
return self::$_status[$sbas_id]->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteStatus(Filesystem $filesystem, $sbas_id, $bit)
|
public static function deleteStatus(Application $app, \databox $databox, $bit)
|
||||||
{
|
{
|
||||||
$core = \bootstrap::getCore();
|
$status = self::getStatus($app, $sbas_id);
|
||||||
$appbox = \appbox::get_instance($core);
|
|
||||||
|
|
||||||
$user = $core->getAuthenticatedUser();
|
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = self::getStatus($sbas_id);
|
|
||||||
|
|
||||||
if (isset($status[$bit])) {
|
if (isset($status[$bit])) {
|
||||||
$connbas = connection::getPDOConnection($sbas_id);
|
$connbas = connection::getPDOConnection($app, $sbas_id);
|
||||||
|
|
||||||
$databox = $appbox->get_databox((int) $sbas_id);
|
|
||||||
|
|
||||||
$doc = $databox->get_dom_structure();
|
$doc = $databox->get_dom_structure();
|
||||||
if ($doc) {
|
if ($doc) {
|
||||||
@@ -284,11 +269,11 @@ class databox_status
|
|||||||
$databox->saveStructure($doc);
|
$databox->saveStructure($doc);
|
||||||
|
|
||||||
if (null !== $status[$bit]['img_off']) {
|
if (null !== $status[$bit]['img_off']) {
|
||||||
$filesystem->remove($status[$bit]['path_off']);
|
$app['filesystem']->remove($status[$bit]['path_off']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $status[$bit]['img_on']) {
|
if (null !== $status[$bit]['img_on']) {
|
||||||
$filesystem->remove($status[$bit]['path_on']);
|
$app['filesystem']->remove($status[$bit]['path_on']);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset(self::$_status[$sbas_id]->status[$bit]);
|
unset(self::$_status[$sbas_id]->status[$bit]);
|
||||||
@@ -300,21 +285,11 @@ class databox_status
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updateStatus($sbas_id, $bit, $properties)
|
public static function updateStatus(Application $app, $sbas_id, $bit, $properties)
|
||||||
{
|
{
|
||||||
$core = \bootstrap::getCore();
|
self::getStatus($app, $sbas_id);
|
||||||
|
|
||||||
$user = $core->getAuthenticatedUser();
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::getStatus($sbas_id);
|
|
||||||
|
|
||||||
$appbox = \appbox::get_instance($core);
|
|
||||||
|
|
||||||
$databox = $appbox->get_databox((int) $sbas_id);
|
|
||||||
|
|
||||||
$doc = $databox->get_dom_structure($sbas_id);
|
$doc = $databox->get_dom_structure($sbas_id);
|
||||||
if ($doc) {
|
if ($doc) {
|
||||||
@@ -383,17 +358,9 @@ class databox_status
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteIcon(Filesystem $filesystem, $sbas_id, $bit, $switch)
|
public static function deleteIcon(Application $app, $sbas_id, $bit, $switch)
|
||||||
{
|
{
|
||||||
$core = \bootstrap::getCore();
|
$status = self::getStatus($app, $sbas_id);
|
||||||
|
|
||||||
$user = $core->getAuthenticatedUser();
|
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = self::getStatus($sbas_id);
|
|
||||||
|
|
||||||
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
||||||
|
|
||||||
@@ -403,7 +370,7 @@ class databox_status
|
|||||||
|
|
||||||
if ($status[$bit]['img_' . $switch]) {
|
if ($status[$bit]['img_' . $switch]) {
|
||||||
if (isset($status[$bit]['path_' . $switch])) {
|
if (isset($status[$bit]['path_' . $switch])) {
|
||||||
$filesystem->remove($status[$bit]['path_' . $switch]);
|
$app['filesystem']->remove($status[$bit]['path_' . $switch]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$status[$bit]['img_' . $switch] = false;
|
$status[$bit]['img_' . $switch] = false;
|
||||||
@@ -413,15 +380,9 @@ class databox_status
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updateIcon(Filesystem $filesystem, $sbas_id, $bit, $switch, UploadedFile $file)
|
public static function updateIcon(Application $app, $sbas_id, $bit, $switch, UploadedFile $file)
|
||||||
{
|
{
|
||||||
$core = \bootstrap::getCore();
|
$registry = $app['phraseanet.registry'];
|
||||||
$user = $core->getAuthenticatedUser();
|
|
||||||
$registry = $core->getRegistry();
|
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
|
||||||
throw new Exception_Forbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
$switch = in_array($switch, array('on', 'off')) ? $switch : false;
|
||||||
|
|
||||||
@@ -429,8 +390,8 @@ class databox_status
|
|||||||
throw new Exception_InvalidArgument();
|
throw new Exception_InvalidArgument();
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = self::getUrl($sbas_id);
|
$url = self::getUrl($app, $sbas_id);
|
||||||
$path = self::getPath($sbas_id);
|
$path = self::getPath($app, $sbas_id);
|
||||||
|
|
||||||
if ($file->getSize() >= 65535) {
|
if ($file->getSize() >= 65535) {
|
||||||
throw new Exception_Upload_FileTooBig();
|
throw new Exception_Upload_FileTooBig();
|
||||||
@@ -440,7 +401,7 @@ class databox_status
|
|||||||
throw new Exception_Upload_Error();
|
throw new Exception_Upload_Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::deleteIcon($filesystem, $sbas_id, $bit, $switch);
|
self::deleteIcon($app, $sbas_id, $bit, $switch);
|
||||||
|
|
||||||
$name = "-stat_" . $bit . "_" . ($switch == 'on' ? '1' : '0') . ".gif";
|
$name = "-stat_" . $bit . "_" . ($switch == 'on' ? '1' : '0') . ".gif";
|
||||||
|
|
||||||
@@ -453,7 +414,7 @@ class databox_status
|
|||||||
|
|
||||||
$custom_path = $registry->get('GV_RootPath') . 'www/custom/status/';
|
$custom_path = $registry->get('GV_RootPath') . 'www/custom/status/';
|
||||||
|
|
||||||
$filesystem->mkdir($custom_path, 0750);
|
$app['filesystem']->mkdir($custom_path, 0750);
|
||||||
|
|
||||||
//resize status icon 16x16px
|
//resize status icon 16x16px
|
||||||
$imageSpec = new ImageSpecification();
|
$imageSpec = new ImageSpecification();
|
||||||
@@ -464,7 +425,7 @@ class databox_status
|
|||||||
$destPath = sprintf("%s%s", $custom_path, basename($path . $name));
|
$destPath = sprintf("%s%s", $custom_path, basename($path . $name));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$core['media-alchemyst']
|
$app['media-alchemyst']
|
||||||
->open($filePath)
|
->open($filePath)
|
||||||
->turninto($destPath, $imageSpec)
|
->turninto($destPath, $imageSpec)
|
||||||
->close();
|
->close();
|
||||||
@@ -478,17 +439,17 @@ class databox_status
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function operation_and($stat1, $stat2)
|
public static function operation_and(Application $app, $stat1, $stat2)
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection($app);
|
||||||
|
|
||||||
$status = '0';
|
$status = '0';
|
||||||
|
|
||||||
if (substr($stat1, 0, 2) === '0x') {
|
if (substr($stat1, 0, 2) === '0x') {
|
||||||
$stat1 = self::hex2bin(substr($stat1, 2));
|
$stat1 = self::hex2bin($app, substr($stat1, 2));
|
||||||
}
|
}
|
||||||
if (substr($stat2, 0, 2) === '0x') {
|
if (substr($stat2, 0, 2) === '0x') {
|
||||||
$stat2 = self::hex2bin(substr($stat2, 2));
|
$stat2 = self::hex2bin($app, substr($stat2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'select bin(0b' . trim($stat1) . ' & 0b' . trim($stat2) . ') as result';
|
$sql = 'select bin(0b' . trim($stat1) . ' & 0b' . trim($stat2) . ') as result';
|
||||||
@@ -505,17 +466,17 @@ class databox_status
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function operation_and_not($stat1, $stat2)
|
public static function operation_and_not(Application $app, $stat1, $stat2)
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection($app);
|
||||||
|
|
||||||
$status = '0';
|
$status = '0';
|
||||||
|
|
||||||
if (substr($stat1, 0, 2) === '0x') {
|
if (substr($stat1, 0, 2) === '0x') {
|
||||||
$stat1 = self::hex2bin(substr($stat1, 2));
|
$stat1 = self::hex2bin($app, substr($stat1, 2));
|
||||||
}
|
}
|
||||||
if (substr($stat2, 0, 2) === '0x') {
|
if (substr($stat2, 0, 2) === '0x') {
|
||||||
$stat2 = self::hex2bin(substr($stat2, 2));
|
$stat2 = self::hex2bin($app, substr($stat2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result';
|
$sql = 'select bin(0b' . trim($stat1) . ' & ~0b' . trim($stat2) . ') as result';
|
||||||
@@ -532,17 +493,17 @@ class databox_status
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function operation_or($stat1, $stat2)
|
public static function operation_or(Application $app, $stat1, $stat2)
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection($app);
|
||||||
|
|
||||||
$status = '0';
|
$status = '0';
|
||||||
|
|
||||||
if (substr($stat1, 0, 2) === '0x') {
|
if (substr($stat1, 0, 2) === '0x') {
|
||||||
$stat1 = self::hex2bin(substr($stat1, 2));
|
$stat1 = self::hex2bin($app, substr($stat1, 2));
|
||||||
}
|
}
|
||||||
if (substr($stat2, 0, 2) === '0x') {
|
if (substr($stat2, 0, 2) === '0x') {
|
||||||
$stat2 = self::hex2bin(substr($stat2, 2));
|
$stat2 = self::hex2bin($app, substr($stat2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result';
|
$sql = 'select bin(0b' . trim($stat1) . ' | 0b' . trim($stat2) . ') as result';
|
||||||
@@ -559,7 +520,7 @@ class databox_status
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function dec2bin($status)
|
public static function dec2bin(Application $app, $status)
|
||||||
{
|
{
|
||||||
$status = (string) $status;
|
$status = (string) $status;
|
||||||
|
|
||||||
@@ -567,7 +528,7 @@ class databox_status
|
|||||||
throw new \Exception('Non-decimal value');
|
throw new \Exception('Non-decimal value');
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection($app);
|
||||||
|
|
||||||
$sql = 'select bin(' . $status . ') as result';
|
$sql = 'select bin(' . $status . ') as result';
|
||||||
|
|
||||||
@@ -585,7 +546,7 @@ class databox_status
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function hex2bin($status)
|
public static function hex2bin(Application $app, $status)
|
||||||
{
|
{
|
||||||
$status = (string) $status;
|
$status = (string) $status;
|
||||||
if (substr($status, 0, 2) === '0x') {
|
if (substr($status, 0, 2) === '0x') {
|
||||||
@@ -596,7 +557,7 @@ class databox_status
|
|||||||
throw new \Exception('Non-hexadecimal value');
|
throw new \Exception('Non-hexadecimal value');
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection($app);
|
||||||
|
|
||||||
$sql = 'select BIN( CAST( 0x' . trim($status) . ' AS UNSIGNED ) ) as result';
|
$sql = 'select BIN( CAST( 0x' . trim($status) . ' AS UNSIGNED ) ) as result';
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class databox_subdefsStructure implements IteratorAggregate
|
class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -31,6 +31,16 @@ class databox_subdefsStructure implements IteratorAggregate
|
|||||||
return new ArrayIterator($this->AvSubdefs);
|
return new ArrayIterator($this->AvSubdefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
$n = 0;
|
||||||
|
foreach($this->AvSubdefs as $subdefs) {
|
||||||
|
$n += count($subdefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $n;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param databox $databox
|
* @param databox $databox
|
||||||
|
Reference in New Issue
Block a user