"
diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.class.php b/lib/classes/eventsmanager/notify/ordernotdelivered.class.php
index 537d32ecdb..a1e737983e 100644
--- a/lib/classes/eventsmanager/notify/ordernotdelivered.class.php
+++ b/lib/classes/eventsmanager/notify/ordernotdelivered.class.php
@@ -24,10 +24,10 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
*/
public $events = array('__ORDER_NOT_DELIVERED__');
- function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
+ function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Commande');
- parent::__construct($appbox, $registry, $broker);
+ parent::__construct($appbox, $core, $broker);
return $this;
}
diff --git a/lib/classes/eventsmanager/notify/push.class.php b/lib/classes/eventsmanager/notify/push.class.php
index a999072086..533e767005 100644
--- a/lib/classes/eventsmanager/notify/push.class.php
+++ b/lib/classes/eventsmanager/notify/push.class.php
@@ -30,7 +30,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
*/
public function icon_url()
{
- return '/skins/prod/000000/images/pushdoc_history.gif';
+ return '/skins/icons/push16.png';
}
/**
diff --git a/lib/classes/eventsmanager/notify/register.class.php b/lib/classes/eventsmanager/notify/register.class.php
index 4a0b6844fe..a92e9dd502 100644
--- a/lib/classes/eventsmanager/notify/register.class.php
+++ b/lib/classes/eventsmanager/notify/register.class.php
@@ -289,8 +289,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
{
$bool = false;
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ $session = $this->appbox->get_session();
if (!$session->is_authenticated() || !login::register_enabled())
return false;
diff --git a/lib/classes/eventsmanager/notify/validate.class.php b/lib/classes/eventsmanager/notify/validate.class.php
index 2de351364e..550086d281 100644
--- a/lib/classes/eventsmanager/notify/validate.class.php
+++ b/lib/classes/eventsmanager/notify/validate.class.php
@@ -28,10 +28,10 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
*
* @return notify_validate
*/
- function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
+ function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
- parent::__construct($appbox, $registry, $broker);
+ parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -42,7 +42,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
*/
public function icon_url()
{
- return '/skins/prod/000000/images/pushdoc_history.gif';
+ return '/skins/icons/push16.png';
}
/**
@@ -140,9 +140,12 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
try
{
- $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
- $basket_name = (trim($basket->get_name()) != '' ?
- $basket->get_name() : _('Une selection'));
+ $em = $this->core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
+
+ $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser(), false);
+
+ $basket_name = trim($basket->getName()) ?: _('Une selection');
}
catch (Exception $e)
{
diff --git a/lib/classes/eventsmanager/notify/validationdone.class.php b/lib/classes/eventsmanager/notify/validationdone.class.php
index adda77f692..2d10376233 100644
--- a/lib/classes/eventsmanager/notify/validationdone.class.php
+++ b/lib/classes/eventsmanager/notify/validationdone.class.php
@@ -28,10 +28,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*
* @return notify_validationdone
*/
- function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
+ function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
- parent::__construct($appbox, $registry, $broker);
+ parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -42,7 +42,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*/
public function icon_url()
{
- return '/skins/prod/000000/images/pushdoc_history.gif';
+ return '/skins/icons/push16.png';
}
/**
@@ -139,11 +139,14 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
return array();
}
- $sender = User_Adapter::getInstance($from, $this->appbox)->get_display_name();
+ $sender = $registered_user->get_display_name();
try
{
- $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
+ $em = $this->core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
+
+ $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser(), false);
}
catch (Exception $e)
{
@@ -156,7 +159,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$sender,
'
'
+ . $basket->getName() . ''
)
, 'class' => ''
);
@@ -193,7 +196,10 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{
try
{
- $basket = basket_adapter::getInstance($this->appbox, $ssel_id,$this->appbox->get_session()->get_usr_id());
+ $em = $this->core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
+
+ $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser(), false);
}
catch (Exception $e)
{
@@ -203,7 +209,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$subject = sprintf(
_('push::mail:: Rapport de validation de %1$s pour %2$s'),
$from['name'],
- $basket->get_name()
+ $basket->getName()
);
$body = "
" . sprintf(
@@ -224,8 +230,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{
$bool = false;
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ $session = $this->appbox->get_session();
if (!$session->is_authenticated())
return false;
diff --git a/lib/classes/eventsmanager/notify/validationreminder.class.php b/lib/classes/eventsmanager/notify/validationreminder.class.php
index 934b87eccc..13622a8500 100644
--- a/lib/classes/eventsmanager/notify/validationreminder.class.php
+++ b/lib/classes/eventsmanager/notify/validationreminder.class.php
@@ -28,10 +28,10 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
*
* @return notify_validationreminder
*/
- function __construct(appbox &$appbox, registryInterface &$registry, eventsmanager_broker &$broker)
+ function __construct(appbox &$appbox, \Alchemy\Phrasea\Core $core, eventsmanager_broker &$broker)
{
$this->group = _('Validation');
- parent::__construct($appbox, $registry, $broker);
+ parent::__construct($appbox, $core, $broker);
return $this;
}
@@ -42,7 +42,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
*/
public function icon_url()
{
- return '/skins/prod/000000/images/pushdoc_history.gif';
+ return '/skins/icons/push16.png';
}
/**
@@ -156,9 +156,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
try
{
- $basket = basket_adapter::getInstance($this->appbox, $ssel_id, $this->appbox->get_session()->get_usr_id());
- $basket_name = (trim($basket->get_name()) != '' ?
- $basket->get_name() : _('Une selection'));
+ $em = $this->core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
+
+ $basket = $repository->findUserBasket($ssel_id, $this->core->getAuthenticatedUser(), false);
+
+ $basket_name = trim($basket->getName()) ? : _('Une selection');
}
catch (Exception $e)
{
diff --git a/lib/classes/eventsmanager/notifyAbstract.class.php b/lib/classes/eventsmanager/notifyAbstract.class.php
index 8ab041a712..88bf6c0336 100644
--- a/lib/classes/eventsmanager/notifyAbstract.class.php
+++ b/lib/classes/eventsmanager/notifyAbstract.class.php
@@ -26,7 +26,7 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
protected function get_prefs($class, $usr_id)
{
- $user = User_Adapter::getInstance($usr_id, appbox::get_instance());
+ $user = User_Adapter::getInstance($usr_id, appbox::get_instance(\bootstrap::getCore()));
return $user->getPrefs('notification_' . $class);
}
diff --git a/lib/classes/gatekeeper.class.php b/lib/classes/gatekeeper.class.php
index 240310e931..eb997d6836 100644
--- a/lib/classes/gatekeeper.class.php
+++ b/lib/classes/gatekeeper.class.php
@@ -41,15 +41,16 @@ class gatekeeper
* @var gatekeeper
*/
protected static $_instance;
+ protected $Core;
/**
*
* @return gatekeeper
*/
- public static function getInstance()
+ public static function getInstance(\Alchemy\Phrasea\Core $Core)
{
if (!(self::$_instance instanceof self))
- self::$_instance = new self();
+ self::$_instance = new self($Core);
return self::$_instance;
}
@@ -58,8 +59,10 @@ class gatekeeper
*
* @return gatekeeper
*/
- function __construct()
+ function __construct(\Alchemy\Phrasea\Core $Core)
{
+ $this->Core = $Core;
+
return $this;
}
@@ -71,8 +74,8 @@ class gatekeeper
*/
function check_directory()
{
- $request = http_request::getInstance();
- $appbox = appbox::get_instance();
+ $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
+ $appbox = appbox::get_instance($this->Core);
$session = $appbox->get_session();
if (http_request::is_command_line())
@@ -100,7 +103,7 @@ class gatekeeper
try
{
$cookie = Session_Handler::get_cookie('persistent');
- $auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
+ $auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
$session->restore($auth->get_user(), $auth->get_ses_id());
}
catch (Exception $e)
@@ -116,12 +119,19 @@ class gatekeeper
case 'prod':
case 'client':
$this->give_guest_access();
- phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
+ if ($request->isXmlHttpRequest())
+ {
+ phrasea::headers(404);
+ }
+ else
+ {
+ phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
+ }
break;
case 'thesaurus2':
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
- || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
- || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
+ || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
+ || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
return;
phrasea::redirect('/login/?redirect=/thesaurus2');
@@ -230,7 +240,7 @@ class gatekeeper
*/
protected function give_guest_access()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance($this->Core);
$request = http_request::getInstance();
$session = $appbox->get_session();
@@ -246,10 +256,10 @@ class gatekeeper
catch (Exception $e)
{
$url = '/login/?redirect=' . $parm['redirect']
- . '&error=' . urlencode($e->getMessage());
+ . '&error=' . urlencode($e->getMessage());
phrasea::redirect($url);
}
- phrasea::redirect('/' . $this->_directory . '/index.php');
+ phrasea::redirect('/' . $this->_directory . '/');
}
return $this;
@@ -262,10 +272,10 @@ class gatekeeper
*/
protected function token_access()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance($this->Core);
$request = new http_request();
$session = $appbox->get_session();
- $parm = $request->get_parms('LOG');
+ $parm = $request->get_parms('LOG');
if (is_null($parm["LOG"]))
@@ -287,7 +297,19 @@ class gatekeeper
{
$datas = random::helloToken($parm['LOG']);
- return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
+ switch ($datas['type'])
+ {
+ default:
+ return $this;
+ break;
+ case \random::TYPE_FEED_ENTRY:
+ return phrasea::redirect("/lightbox/feeds/entry/" . $datas['datas'] . "/");
+ break;
+ case \random::TYPE_VALIDATE:
+ case \random::TYPE_VIEW:
+ return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
+ break;
+ }
}
catch (Exception_NotFound $e)
{
@@ -305,7 +327,7 @@ class gatekeeper
*/
public function require_session()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance($this->Core);
$session = $appbox->get_session();
if ($session->is_authenticated())
{
diff --git a/lib/classes/geonames.class.php b/lib/classes/geonames.class.php
index 4d4859eba7..bd3d494677 100644
--- a/lib/classes/geonames.class.php
+++ b/lib/classes/geonames.class.php
@@ -3,12 +3,18 @@
class geonames
{
+ protected static $NamesFromId = array();
+ protected static $CountryFromId = array();
+ protected static $CountryCodeFromId = array();
+ protected static $GeonameFromIp = array();
+ protected static $Searches = array();
+
public function name_from_id($geonameid)
{
$registry = registry::get_instance();
- $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
- . 'get_name.php?geonameid='
- . $geonameid;
+ $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
+ . 'get_name.php?geonameid='
+ . $geonameid;
$ret = '';
@@ -35,9 +41,9 @@ class geonames
}
$registry = registry::get_instance();
- $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
- . 'get_name.php?geonameid='
- . $geonameid;
+ $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
+ . 'get_name.php?geonameid='
+ . $geonameid;
$ret = '';
$xml = http_query::getUrl($url);
@@ -57,9 +63,9 @@ class geonames
public function get_country_code($geonameid)
{
$registry = registry::get_instance();
- $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
- . 'get_name.php?geonameid='
- . $geonameid;
+ $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
+ . 'get_name.php?geonameid='
+ . $geonameid;
$ret = '';
@@ -85,7 +91,7 @@ class geonames
protected static function highlight($title, $length)
{
return '
' . mb_substr($title, 0, $length) . ' '
- . mb_substr($title, $length);
+ . mb_substr($title, $length);
}
public function find_city($cityName)
@@ -98,9 +104,9 @@ class geonames
return $output;
$registry = registry::get_instance();
- $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
- . 'find_city.php?city='
- . urlencode($cityName) . '&maxResult=30';
+ $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
+ . 'find_city.php?city='
+ . urlencode($cityName) . '&maxResult=30';
$sxe = simplexml_load_string(http_query::getUrl($url));
@@ -113,17 +119,17 @@ class geonames
$country_highlight = (string) $geoname->country;
if (trim($geoname->country_match) !== '')
{
- $length = mb_strlen($geoname->country_match);
+ $length = mb_strlen($geoname->country_match);
$country_highlight = self::highlight($geoname->country, $length);
}
$output[] = array(
- 'title_highlighted' => $title_highlight
- , 'title' => (string) $geoname->title
- , 'country_highlighted' => $country_highlight
- , 'country' => (string) $geoname->country
- , 'geoname_id' => (int) $geoname->geonameid
- , 'region' => (string) $geoname->region
+ 'title_highlighted' => $title_highlight
+ , 'title' => (string) $geoname->title
+ , 'country_highlighted' => $country_highlight
+ , 'country' => (string) $geoname->country
+ , 'geoname_id' => (int) $geoname->geonameid
+ , 'region' => (string) $geoname->region
);
}
@@ -139,18 +145,18 @@ class geonames
return $this->cache_ips[$ip];
$output = array(
- 'city' => '',
- 'country_code' => '',
- 'country' => '',
- 'fips' => '',
- 'longitude' => '',
- 'latitude' => ''
+ 'city' => '',
+ 'country_code' => '',
+ 'country' => '',
+ 'fips' => '',
+ 'longitude' => '',
+ 'latitude' => ''
);
$registry = registry::get_instance();
- $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
- . 'geoip.php?ip='
- . urlencode($ip);
+ $url = $registry->get('GV_i18n_service', 'http://localization.webservice.alchemyasp.com/')
+ . 'geoip.php?ip='
+ . urlencode($ip);
$xml = http_query::getUrl($url);
if ($xml)
@@ -158,12 +164,12 @@ class geonames
$sxe = simplexml_load_string($xml);
if ($sxe && $sxe->geoname)
{
- $output['city'] = (string) $sxe->geoname->city;
+ $output['city'] = (string) $sxe->geoname->city;
$output['country_code'] = (string) $sxe->geoname->country_code;
- $output['country'] = (string) $sxe->geoname->country;
- $output['fips'] = (string) $sxe->geoname->fips;
- $output['longitude'] = (string) $sxe->geoname->longitude;
- $output['latitude'] = (string) $sxe->geoname->latitude;
+ $output['country'] = (string) $sxe->geoname->country;
+ $output['fips'] = (string) $sxe->geoname->fips;
+ $output['longitude'] = (string) $sxe->geoname->longitude;
+ $output['latitude'] = (string) $sxe->geoname->latitude;
}
}
$this->cache_ips[$ip] = $output;
diff --git a/lib/classes/http/query.class.php b/lib/classes/http/query.class.php
index 9e10148024..86f6a8a9e1 100644
--- a/lib/classes/http/query.class.php
+++ b/lib/classes/http/query.class.php
@@ -25,26 +25,41 @@ class http_query
*/
public static function getHttpCodeFromUrl($url)
{
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
- curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_HEADER, true);
+ if (!is_scalar($url))
- curl_exec($ch);
- $result = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ return null;
- curl_close($ch);
+ if (trim($url) === '')
- return $result;
+ return null;
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
+ curl_setopt($ch, CURLOPT_NOBODY, true);
+ curl_setopt($ch, CURLOPT_HEADER, true);
+
+ curl_exec($ch);
+ $result = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+ curl_close($ch);
+
+ return $result;
}
public static function getHttpHeaders($url)
{
+ if (!is_scalar($url))
+
+ return null;
+
+ if (trim($url) === '')
+
+ return null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -69,24 +84,32 @@ class http_query
* @param array $post_data
* @return string
*/
- public static function getUrl($url, $post_data=false)
+ public static function getUrl($url, $post_data = false)
{
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
- curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+ if (!is_scalar($url))
- if ($post_data)
- {
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
- }
+ return null;
- $result = (curl_exec($ch));
- curl_close($ch);
+ if (trim($url) === '')
+
+ return null;
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+
+ if ($post_data)
+ {
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+ }
+
+ $result = (curl_exec($ch));
+ curl_close($ch);
return $result;
}
diff --git a/lib/classes/lazaret.class.php b/lib/classes/lazaret.class.php
index ac278f38cf..c5b1accb97 100644
--- a/lib/classes/lazaret.class.php
+++ b/lib/classes/lazaret.class.php
@@ -25,7 +25,7 @@ class lazaret extends set_abstract
*/
function __construct()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
$conn = $appbox->get_connection();
diff --git a/lib/classes/lazaretFile.class.php b/lib/classes/lazaretFile.class.php
index 6df683398c..f2b1f36cb4 100644
--- a/lib/classes/lazaretFile.class.php
+++ b/lib/classes/lazaretFile.class.php
@@ -147,7 +147,7 @@ class lazaretFile
public static function move_uploaded_to_lazaret(
system_file $system_file, $base_id, $filename, $errors='', $status=false)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
$conn = $appbox->get_connection();
diff --git a/lib/classes/liste.class.php b/lib/classes/liste.class.php
index 284ba47d76..bdcc2459c9 100644
--- a/lib/classes/liste.class.php
+++ b/lib/classes/liste.class.php
@@ -5,7 +5,7 @@ class liste
public static function filter($lst)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
if (!is_array($lst))
diff --git a/lib/classes/login.class.php b/lib/classes/login.class.php
index fe81eceb27..93b0444d80 100644
--- a/lib/classes/login.class.php
+++ b/lib/classes/login.class.php
@@ -29,33 +29,6 @@ class login
return false;
}
- public function get_language_selector(registryInterface $registry)
- {
- $lngSelect = '
';
- $currentLanguage = $registry->get('GV_default_lng');
- $avLanguages = User_Adapter::detectlanguage($registry);
- foreach ($avLanguages as $lng => $languages)
- foreach ($languages as $locale => $language)
- {
- if ($language['selected'] === true)
- $currentLanguage = $locale;
- $lngSelect .= '' . $language['name'] . ' ';
- }
- $lngSelect .= ' ';
-
- return $lngSelect;
- }
-
- public function get_password_link()
- {
-// $findpwd = '';
-// if(GV_find_password )
-// {
- $findpwd = '
' . _('login:: Forgot your password') . ' ';
-// }
- return $findpwd;
- }
-
public function get_register_link()
{
$demandLinkBox = '';
@@ -74,7 +47,7 @@ class login
if (phrasea::guest_allowed())
{
- $inviteBox = '
' . _('login:: guest Access') . ' ';
+ $inviteBox = '
' . _('login:: guest Access') . ' ';
}
return $inviteBox;
diff --git a/lib/classes/mail.class.php b/lib/classes/mail.class.php
index ac1137ac7f..631a60a8bc 100644
--- a/lib/classes/mail.class.php
+++ b/lib/classes/mail.class.php
@@ -127,7 +127,7 @@ class mail
{
$registry = registry::get_instance();
$date = new DateTime('1 day');
- $token = random::getUrlToken('email', $usr_id, $date, $email);
+ $token = random::getUrlToken(\random::TYPE_EMAIL, $usr_id, $date, $email);
$url = $registry->get('GV_ServerName') . 'login/reset-email.php?token=' . $token;
@@ -143,6 +143,8 @@ class mail
public static function mail_confirm_registered($email)
{
+ $registry = \registry::get_instance();
+
$subject = _('login::register: sujet email : confirmation de votre adresse email');
$body = "
" . _('login::register: merci d\'avoir confirme votre adresse email') . "
\n";
@@ -172,7 +174,7 @@ class mail
{
$registry = registry::get_instance();
$expire = new DateTime('+3 days');
- $token = random::getUrlToken('password', $usr_id, $expire, $email);
+ $token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expire, $email);
$subject = _('login::register: sujet email : confirmation de votre adresse email');
@@ -206,12 +208,15 @@ class mail
$body = eregi_replace("[\]", '', $body);
- $body .= "
\n"._('Si le lien n\'est pas cliquable, copiez-collez le dans votre navigateur.')."
\n";
$body .= "
\n\n\n\n";
+ $body .= '
'._('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.').'
';
+ $body .= "
\n";
$body .= '
' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "
\n";
$body .= '
\n";
$body = '' . $body . '';
+ $body = str_replace('https://', 'http://', $body);
+
try
{
$mail->CharSet = 'utf-8';
@@ -256,7 +261,7 @@ class mail
$mail->ConfirmReadingTo = $reading_confirm_to;
}
- $mail->MsgHTML(strip_tags($body, '
'));
+ $mail->MsgHTML(strip_tags($body, ' '));
foreach ($files as $f)
{
diff --git a/lib/classes/module/Admin.php b/lib/classes/module/Admin.php
deleted file mode 100644
index 8e960d684f..0000000000
--- a/lib/classes/module/Admin.php
+++ /dev/null
@@ -1,37 +0,0 @@
-mount('/publications', new Controller_Admin_Publications());
- $app->mount('/users', new Controller_Admin_Users());
- $app->mount('/fields', new Controller_Admin_Fields());
- $app->mount('/tests/connection', new Controller_Utils_ConnectionTest());
- $app->mount('/tests/pathurl', new Controller_Utils_PathFileTest());
-
- $app->error(function(\Exception $e)
- {
- return $e->getMessage();
- });
-
- return $app;
- });
diff --git a/lib/classes/module/Lightbox.php b/lib/classes/module/Lightbox.php
deleted file mode 100644
index 8d90286f57..0000000000
--- a/lib/classes/module/Lightbox.php
+++ /dev/null
@@ -1,457 +0,0 @@
-get_session();
-
- $app = new Silex\Application();
-
- $app->get('/', function () use ($session, $appbox)
- {
- User_Adapter::updateClientInfos((6));
- $basket_collection = new basketCollection($appbox, $session->get_usr_id());
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br'));
- $browser = Browser::getInstance();
-
- $template = 'lightbox/index.twig';
- if (!$browser->isNewGeneration() && !$browser->isMobile())
- $template = 'lightbox/IE6/index.twig';
-
- $output = $twig->render($template, array(
- 'baskets_collection' => $basket_collection,
- 'module_name' => 'Lightbox',
- 'module' => 'lightbox'
- )
- );
- $response = new Response($output);
- $response->setCharset('UTF-8');
-
- return $response;
- }
- );
-
- $app->get('/ajax/NOTE_FORM/{sselcont_id}/', function($sselcont_id) use ($session, $appbox)
- {
- $browser = Browser::getInstance();
- if (!$browser->isMobile())
-
- return new Response('');
-
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br'));
- $basket_element = basket_element_adapter::getInstance($sselcont_id);
- $template = '/lightbox/note_form.twig';
- $output = $twig->render($template, array('basket_element' => $basket_element, 'module_name' => ''));
-
- return new Response($output);
- }
- )->assert('sselcont_id', '\d+');
-
- $app->get('/ajax/LOAD_BASKET_ELEMENT/{sselcont_id}/', function($sselcont_id)
- {
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br', 'formatoctet' => 'p4string::format_octets'));
-
- $browser = Browser::getInstance();
-
- if ($browser->isMobile())
- {
- $basket_element = basket_element_adapter::getInstance($sselcont_id);
-
- $output = $twig->render('lightbox/basket_element.twig', array(
- 'basket_element' => $basket_element,
- 'module_name' => $basket_element->get_record()->get_title()
- )
- );
-
- return new Response($output);
- }
- else
- {
- $template_options = 'lightbox/sc_options_box.twig';
- $template_agreement = 'lightbox/agreement_box.twig';
- $template_selector = 'lightbox/selector_box.twig';
- $template_note = 'lightbox/sc_note.twig';
- $template_preview = 'common/preview.html';
- $template_caption = 'common/caption.html';
-
- if (!$browser->isNewGeneration())
- {
- $template_options = 'lightbox/IE6/sc_options_box.twig';
- $template_agreement = 'lightbox/IE6/agreement_box.twig';
- }
- $appbox = appbox::get_instance();
- $usr_id = $appbox->get_session()->get_usr_id();
-
- $basket_element = basket_element_adapter::getInstance($sselcont_id);
- $basket = basket_adapter::getInstance($appbox, $basket_element->get_ssel_id(), $usr_id);
-
- $ret = array();
- $ret['number'] = $basket_element->get_record()->get_number();
- $ret['title'] = $basket_element->get_record()->get_title();
-
- $ret['preview'] = $twig->render($template_preview, array('record' => $basket_element->get_record(), 'not_wrapped' => true));
- $ret['options_html'] = $twig->render($template_options, array('basket_element' => $basket_element));
- $ret['agreement_html'] = $twig->render($template_agreement, array('basket' => $basket, 'basket_element' => $basket_element));
- $ret['selector_html'] = $twig->render($template_selector, array('basket_element' => $basket_element));
- $ret['note_html'] = $twig->render($template_note, array('basket_element' => $basket_element));
- $ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $basket_element->get_record()));
- $output = p4string::jsonencode($ret);
-
- return new Response($output, 200, array('Content-Type' => 'application/json'));
- }
- }
- )->assert('sselcont_id', '\d+');
-
-
-
-
- $app->get('/ajax/LOAD_FEED_ITEM/{entry_id}/{item_id}/', function($entry_id, $item_id)
- {
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br', 'formatoctet' => 'p4string::format_octets'));
-
- $appbox = appbox::get_instance();
- $entry = Feed_Entry_Adapter::load_from_id($appbox, $entry_id);
- $item = new Feed_Entry_Item($appbox, $entry, $item_id);
-
- $browser = Browser::getInstance();
-
- if ($browser->isMobile())
- {
- $output = $twig->render('lightbox/feed_element.twig', array(
- 'feed_element' => $item,
- 'module_name' => $item->get_record()->get_title()
- )
- );
-
- return new Response($output);
- }
- else
- {
- $template_options = 'lightbox/sc_options_box.twig';
- $template_preview = 'common/preview.html';
- $template_caption = 'common/caption.html';
-
- if (!$browser->isNewGeneration())
- {
- $template_options = 'lightbox/IE6/sc_options_box.twig';
- }
- $usr_id = $appbox->get_session()->get_usr_id();
-
- $ret = array();
- $ret['number'] = $item->get_record()->get_number();
- $ret['title'] = $item->get_record()->get_title();
-
- $ret['preview'] = $twig->render($template_preview, array('record' => $item->get_record(), 'not_wrapped' => true));
- $ret['options_html'] = $twig->render($template_options, array('basket_element' => $item));
- $ret['caption'] = $twig->render($template_caption, array('view' => 'preview', 'record' => $item->get_record()));
-
-
- $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = '';
-
-
- $output = p4string::jsonencode($ret);
-
- return new Response($output, 200, array('Content-type' => 'application/json'));
- }
- }
- )->assert('entry_id', '\d+')->assert('item_id', '\d+');
-
- $app->get('/validate/{ssel_id}/', function ($ssel_id) use ($session, $appbox)
- {
-
- User_Adapter::updateClientInfos((6));
-
- $browser = Browser::getInstance();
-
- $basket_collection = new basketCollection($appbox, $session->get_usr_id());
- $basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id());
-
- if ($basket->is_valid())
- {
- if($basket->get_first_element() instanceof basket_element_adapter)
- $basket->get_first_element()->load_users_infos();
- }
-
- $twig = new supertwig();
-
- $twig->addFilter(array('nl2br' => 'nl2br'));
-
- $template = 'lightbox/validate.twig';
-
- if (!$browser->isNewGeneration() && !$browser->isMobile())
- $template = 'lightbox/IE6/validate.twig';
-
- $response = new Response($twig->render($template, array(
- 'baskets_collection' => $basket_collection,
- 'basket' => $basket,
- 'local_title' => strip_tags($basket->get_name()),
- 'module' => 'lightbox',
- 'module_name' => _('admin::monitor: module validation')
- )
- ));
- $response->setCharset('UTF-8');
-
- return $response;
- }
- )->assert('ssel_id', '\d+');
-
- $app->get('/compare/{ssel_id}/', function ($ssel_id) use ($session, $appbox)
- {
-
- User_Adapter::updateClientInfos((6));
-
- $browser = Browser::getInstance();
-
- $basket_collection = new basketCollection($appbox, $session->get_usr_id());
- $basket = basket_adapter::getInstance($appbox, $ssel_id, $session->get_usr_id());
-
- if ($basket->is_valid())
- {
- $basket->get_first_element()->load_users_infos();
- }
-
- $twig = new supertwig();
-
- $twig->addFilter(array('nl2br' => 'nl2br'));
-
- $template = 'lightbox/validate.twig';
-
- if (!$browser->isNewGeneration() && !$browser->isMobile())
- $template = 'lightbox/IE6/validate.twig';
-
- $response = new Response($twig->render($template, array(
- 'baskets_collection' => $basket_collection,
- 'basket' => $basket,
- 'local_title' => strip_tags($basket->get_name()),
- 'module' => 'lightbox',
- 'module_name' => _('admin::monitor: module validation')
- )
- ));
- $response->setCharset('UTF-8');
-
- return $response;
- }
- )->assert('ssel_id', '\d+');
-
-
-
- $app->get('/feeds/entry/{entry_id}/', function ($entry_id) use ($session, $appbox)
- {
-
- User_Adapter::updateClientInfos((6));
-
- $browser = Browser::getInstance();
-
- $feed_entry = Feed_Entry_Adapter::load_from_id($appbox, $entry_id);
-
- $twig = new supertwig();
-
- $twig->addFilter(array('nl2br' => 'nl2br'));
-
- $template = 'lightbox/feed.twig';
-
- if (!$browser->isNewGeneration() && !$browser->isMobile())
- $template = 'lightbox/IE6/feed.twig';
-
- $output = $twig->render($template, array(
- 'feed_entry' => $feed_entry,
- 'first_item' => array_shift($feed_entry->get_content()),
- 'local_title' => $feed_entry->get_title(),
- 'module' => 'lightbox',
- 'module_name' => _('admin::monitor: module validation')
- )
- );
- $response = new Response($output, 200);
- $response->setCharset('UTF-8');
-
- return $response;
- }
- )->assert('entry_id', '\d+');
-
- $app->get('/ajax/LOAD_REPORT/{ssel_id}/', function($ssel_id) use ($appbox, $app)
- {
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br'));
-
- $browser = Browser::getInstance();
-
- $template = 'lightbox/basket_content_report.twig';
-
- $basket = basket_adapter::getInstance($appbox, $ssel_id, $appbox->get_session()->get_usr_id());
-
- $response = new Response($twig->render($template, array('basket' => $basket)));
- $response->setCharset('UTF-8');
-
- return $response;
- }
- )->assert('ssel_id', '\d+');
-
- $app->post('/ajax/SET_NOTE/{sselcont_id}/', function ($sselcont_id) use ($app)
- {
- $output = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees'));
- try
- {
- $request = $app['request'];
- $note = $request->get('note');
-
- $basket_element = basket_element_adapter::getInstance($sselcont_id);
- $basket_element->set_note($note);
- $twig = new supertwig();
- $twig->addFilter(array('nl2br' => 'nl2br'));
-
- $browser = Browser::getInstance();
-
- if ($browser->isMobile())
- {
- $datas = $twig->render('lightbox/sc_note.twig', array('basket_element' => $basket_element));
-
- $output = array('error' => false, 'datas' => $datas);
- }
- else
- {
- $template = 'lightbox/sc_note.twig';
-
- $datas = $twig->render($template, array('basket_element' => $basket_element));
-
- $output = array('error' => false, 'datas' => $datas);
- }
- }
- catch (Exception $e)
- {
- return new Response('Bad Request : ' . $e->getMessage() . $e->getFile() . $e->getLine(), 400);
- }
-
- $output = p4string::jsonencode($output);
-
- return new Response($output, 200, array('Content-Type' => 'application/json'));
- }
- )->assert('sselcont_id', '\d+');
-
- $app->post('/ajax/SET_ELEMENT_AGREEMENT/{sselcont_id}/', function($sselcont_id) use ($app)
- {
- $request = $app['request'];
- $agreement = (int) $request->get('agreement');
-
- $ret = array(
- 'error' => true,
- 'releasable' => false,
- 'datas' => _('Erreur lors de la mise a jour des donnes ')
- );
- try
- {
- $appbox = appbox::get_instance();
-
- $basket_element = basket_element_adapter::getInstance($sselcont_id);
- $basket_element->set_agreement($agreement);
- $basket = basket_adapter::getInstance($appbox, $basket_element->get_ssel_id(), $appbox->get_session()->get_usr_id());
-
- $ret = array(
- 'error' => false
- , 'datas' => ''
- , 'releasable' => $basket->is_releasable() ? _('Do you want to send your report ?') : false
- );
- }
- catch (Exception $e)
- {
- return new Response('Bad Request', 400);
- }
- $output = p4string::jsonencode($ret);
-
- return new Response($output, 200, array('Content-Type' => 'application/json'));
- }
- )->assert('sselcont_id', '\d+');
-
-
- $app->post('/ajax/SET_RELEASE/{ssel_id}/', function($ssel_id) use ($session, $appbox)
- {
- $basket = basket_adapter::getInstance($appbox, $ssel_id, $appbox->get_session()->get_usr_id());
-
- $datas = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees'));
- try
- {
- $appbox->get_connection()->beginTransaction();
- $basket->set_released();
- $datas = array('error' => false, 'datas' => _('Envoie avec succes'));
- $appbox->get_connection()->commit();
- }
- catch (Exception $e)
- {
- $appbox->get_connection()->rollBack();
-
- return new Response('Bad Request', 400);
- }
- $output = p4string::jsonencode($datas);
-
- $response = new Response($output, 200, array('Content-Type' => 'application/json'));
- $response->setCharset('UTF-8');
-
- return $response;
- }
- )->assert('ssel_id', '\d+');
-
-
-
- $app->error(function($e)
- {
- $twig = new supertwig();
- $registry = registry::get_instance();
-
- $template = 'lightbox/error.twig';
-
- if ($registry->get('GV_debug'))
- {
- $options = array(
- 'module' => 'validation',
- 'module_name' => _('admin::monitor: module validation'),
- 'error' => sprintf(
- '%s in %s on line %s '
- , $e->getMessage()
- , $e->getFile()
- , $e->getLine()
- )
- );
- }
- else
- {
- $options = array(
- 'module' => 'validation',
- 'module_name' => _('admin::monitor: module validation'),
- 'error' => ''
- );
- }
- $output = $twig->render($template, $options);
- $response = new Response($output, 404);
- $response->setCharset('UTF-8');
-
- return $response;
- });
-
- return $app;
- }
-);
diff --git a/lib/classes/module/Overview.php b/lib/classes/module/Overview.php
deleted file mode 100644
index 6d07c54019..0000000000
--- a/lib/classes/module/Overview.php
+++ /dev/null
@@ -1,227 +0,0 @@
-get_session();
-
- $app = new Silex\Application();
-
-
- $deliver_content = function(Session_Handler $session, record_adapter $record, $subdef, $watermark, $stamp, $app)
- {
-
- $file = $record->get_subdef($subdef);
- if ($file->get_baseurl() !== '')
- {
- return $app->redirect($file->get_url());
- }
-
- $pathIn = $pathOut = $file->get_pathfile();
-
- if ($watermark === true && $file->get_type() === media_subdef::TYPE_IMAGE)
- {
- $pathOut = recordutils_image::watermark($record->get_base_id(), $record->get_record_id());
- }
- elseif ($stamp === true && $file->get_type() === media_subdef::TYPE_IMAGE)
- {
- $pathOut = recordutils_image::stamp($record->get_base_id(), $record->get_record_id());
- }
-
-
- $log_id = null;
- try
- {
- $registry = registry::get_instance();
- $logger = $session->get_logger($record->get_databox());
- $log_id = $logger->get_id();
-
- $referrer = 'NO REFERRER';
-
- if (isset($_SERVER['HTTP_REFERER']))
- $referrer = $_SERVER['HTTP_REFERER'];
-
- $record->log_view($log_id, $referrer, $registry->get('GV_sit'));
- }
- catch (Exception $e)
- {
-
- }
-
- return set_export::stream_file($pathOut, $file->get_file(), $file->get_mime(), 'attachment');
- };
-
- $app->get('/datafiles/{sbas_id}/{record_id}/{subdef}/', function($sbas_id, $record_id, $subdef) use ($app, $session, $deliver_content)
- {
-
- $databox = databox::get_instance((int) $sbas_id);
- $record = new record_adapter($sbas_id, $record_id);
-
- $record->get_type();
-
- if (!$session->is_authenticated())
- throw new Exception_Session_NotAuthenticated();
-
- $user = User_Adapter::getInstance($session->get_usr_id(), appbox::get_instance());
-
- if (!$user->ACL()->has_access_to_subdef($record, $subdef))
- throw new Exception_UnauthorizedAction();
-
- $stamp = false;
- $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
-
- if ($watermark)
- {
- $subdef_class = $databox
- ->get_subdef_structure()
- ->get_subdef($record->get_type(), $subdef)
- ->get_class();
-
- if ($subdef_class == databox_subdefAbstract::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record))
- {
- $watermark = false;
- }
- elseif ($subdef_class == databox_subdefAbstract::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record))
- {
- $watermark = false;
- }
- }
-
- if ($watermark)
- {
- if (basket_element_adapter::is_in_validation_session($record, $user))
- {
- $watermark = false;
- }
- elseif (basket_element_adapter::has_been_received($record, $user))
- {
- $watermark = false;
- }
- }
-
- return $deliver_content($session, $record, $subdef, $watermark, $stamp, $app);
- })->assert('sbas_id', '\d+')->assert('record_id', '\d+');
-
-
- $app->get('/permalink/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/'
- , function($label, $sbas_id, $record_id, $key, $subdef)
- {
-
- $databox = databox::get_instance((int) $sbas_id);
- $record = media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef);
- if (!($record instanceof record_adapter))
- throw new Exception('bad luck');
- $twig = new supertwig();
- $twig->addFilter(array('formatoctet' => 'p4string::format_octets'));
-
- return $twig->render('overview.twig', array('subdef_name' => $subdef, 'module_name' => 'overview', 'module' => 'overview', 'view' => 'overview', 'record' => $record));
- })->assert('sbas_id', '\d+')->assert('record_id', '\d+');
-
-
- $app->get('/permalink/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/'
- , function($label, $sbas_id, $record_id, $key, $subdef) use ($app, $session, $deliver_content)
- {
- $databox = databox::get_instance((int) $sbas_id);
- $record = media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef);
- if (!($record instanceof record_adapter))
- throw new Exception('bad luck');
-
- $watermark = $stamp = false;
-
- if ($session->is_authenticated())
- {
- $user = User_Adapter::getInstance($session->get_usr_id(), appbox::get_instance());
-
- $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
-
- if ($watermark)
- {
- if (basket_element_adapter::is_in_validation_session($record, $user))
- {
- $watermark = false;
- }
- elseif (basket_element_adapter::has_been_received($record, $user))
- {
- $watermark = false;
- }
- }
-
- return $deliver_content($session, $record, $subdef, $watermark, $stamp, $app);
- }
- else
- {
- $collection = collection::get_from_base_id($record->get_base_id());
- switch ($collection->get_pub_wm())
- {
- default:
- case 'none':
- $watermark = false;
- break;
- case 'stamp':
- $stamp = true;
- break;
- case 'wm':
- $watermark = false;
- break;
- }
- }
-
- return $deliver_content($session, $record, $subdef, $watermark, $stamp, $app);
- }
- )
- ->assert('sbas_id', '\d+')->assert('record_id', '\d+');
-
-
- $app->error(function (\Exception $e)
- {
- if ($e instanceof Exception_Session_NotAuthenticated)
- {
- $code = 403;
- $message = 'Forbidden';
- }
- elseif ($e instanceof Exception_NotAllowed)
- {
- $code = 403;
- $message = 'Forbidden';
- }
- elseif ($e instanceof Exception_NotFound)
- {
- $code = 404;
- $message = 'Not Found';
- }
- else
- {
- $code = 404;
- $message = 'Not Found';
- }
-
- return new Response($message, $code);
- });
-
-
-
-
- return $app;
- }
-);
diff --git a/lib/classes/module/Prod.php b/lib/classes/module/Prod.php
deleted file mode 100644
index 4cef7878a3..0000000000
--- a/lib/classes/module/Prod.php
+++ /dev/null
@@ -1,80 +0,0 @@
-mount('/records/edit', new Controller_Prod_Records_Edit());
- $app->mount('/records/movecollection', new Controller_Prod_Records_MoveCollection());
- $app->mount('/bridge/', new Controller_Prod_Records_Bridge());
- $app->mount('/feeds', new Controller_Prod_Records_Feed());
- $app->mount('/tooltip', new Controller_Prod_Records_Tooltip());
-
- $app->error(function (\Exception $e, $code) use ($app, $twig)
- {
- if ($e instanceof Bridge_Exception)
- {
- $request = $app['request'];
-
- $params = array(
- 'message' => $e->getMessage()
- , 'file' => $e->getFile()
- , 'line' => $e->getLine()
- , 'r_method' => $request->getMethod()
- , 'r_action' => $request->getRequestUri()
- , 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all())
- );
-
- if ($e instanceof Bridge_Exception_ApiConnectorNotConfigured)
- {
- $params = array_merge($params, array('account' => $app['current_account']));
-
- return new response($twig->render('/prod/actions/Bridge/notconfigured.twig', $params), 200);
- }
- elseif ($e instanceof Bridge_Exception_ApiConnectorNotConnected)
- {
- $params = array_merge($params, array('account' => $app['current_account']));
-
- return new response($twig->render('/prod/actions/Bridge/disconnected.twig', $params), 200);
- }
- elseif ($e instanceof Bridge_Exception_ApiConnectorAccessTokenFailed)
- {
- $params = array_merge($params, array('account' => $app['current_account']));
-
- return new response($twig->render('/prod/actions/Bridge/disconnected.twig', $params), 200);
- }
- elseif ($e instanceof Bridge_Exception_ApiDisabled)
- {
- $params = array_merge($params, array('api' => $e->get_api()));
-
- return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
- }
-
- return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
- }
- });
-
-
- return $app;
- });
diff --git a/lib/classes/module/Root.php b/lib/classes/module/Root.php
deleted file mode 100644
index 17c30348aa..0000000000
--- a/lib/classes/module/Root.php
+++ /dev/null
@@ -1,79 +0,0 @@
-redirect("/setup/")->send();
- }
-
- $app->get('/', function() use ($app)
- {
- $browser = Browser::getInstance();
- if ($browser->isMobile())
-
- return $app->redirect("/login/?redirect=/lightbox");
- elseif ($browser->isNewGeneration())
-
- return $app->redirect("/login/?redirect=/prod");
- else
-
- return $app->redirect("/login/?redirect=/client");
- });
-
- $app->get('robots.txt', function() use ($app)
- {
- require dirname(__FILE__) . "/../lib/bootstrap.php";
- $appbox = appbox::get_instance();
-
- $registry = $appbox->get_registry();
-
- if ($registry->get('GV_allow_search_engine') === true)
- {
- $buffer = "User-Agent: *\n"
- . "Allow: /\n";
- }
- else
- {
- $buffer = "User-Agent: *\n"
- . "Disallow: /\n";
- }
-
- $response = new Response($buffer, 200, array('Content-Type: text/plain'));
- $response->setCharset('UTF-8');
-
- return $response;
- });
-
- $app->mount('/feeds/', new Controller_RSSFeeds());
-
- /**
- * Mount all aps
- */
-
- return $app;
- }
-);
diff --git a/lib/classes/module/Setup.php b/lib/classes/module/Setup.php
deleted file mode 100644
index b35443710e..0000000000
--- a/lib/classes/module/Setup.php
+++ /dev/null
@@ -1,83 +0,0 @@
-before(function($a) use ($app)
- {
- if (setup::is_installed())
- {
- $appbox = appbox::get_instance();
-
- if (!$appbox->need_major_upgrade())
- throw new Exception_Setup_PhraseaAlreadyInstalled();
-
- $app['upgrade'] = true;
- }
- else
- {
- $app['install'] = true;
- }
-
- return;
- });
-
-
- $app->get('/', function() use ($app)
- {
- if ($app['install'] === true)
-
- return $app->redirect('/setup/installer/');
- if ($app['upgrade'] === true)
-
- return $app->redirect('/setup/upgrader/');
- });
-
-
- $app->mount('/installer/', new Controller_Setup_Installer());
- $app->mount('/upgrader/', new Controller_Setup_Upgrader());
- $app->mount('/test', new Controller_Utils_PathFileTest());
- $app->mount('/connection_test', new Controller_Utils_ConnectionTest());
-
- $app->error(function($e) use ($app)
- {
- if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled)
-
- return $app->redirect('/login');
-
- return new Response(
- sprintf(
- 'Error %s @%s:%s'
- , $e->getFile()
- , $e->getLine()
- , $e->getMessage()
- )
- , 500
- );
- });
-
- return $app;
- });
diff --git a/lib/classes/module/admin.class.php b/lib/classes/module/admin.class.php
index a84bc63058..d8c71da1fe 100644
--- a/lib/classes/module/admin.class.php
+++ b/lib/classes/module/admin.class.php
@@ -20,7 +20,7 @@ class module_admin
function getTree($position=false)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$usr_id = $session->get_usr_id();
@@ -76,7 +76,9 @@ class module_admin
, 'off_databoxes' => $off_databoxes
);
- $twig = new supertwig();
+
+ $core = \bootstrap::getCore();
+ $twig = $core->getTwig();
return $twig->render('admin/tree.html.twig', $params);
diff --git a/lib/classes/module/api/V1.php b/lib/classes/module/api/V1.php
deleted file mode 100644
index be3a7fbb68..0000000000
--- a/lib/classes/module/api/V1.php
+++ /dev/null
@@ -1,750 +0,0 @@
-protect(function ($result)
- {
- $response = new Response(
- $result->format()
- , $result->get_http_code()
- , array('Content-Type' => $result->get_content_type())
- );
- $response->setCharset('UTF-8');
-
- return $response;
- });
-
-/**
- * Api Service
- * @var Closure
- */
-$app['api'] = function () use ($app)
- {
- return new API_V1_adapter(false, $app["appbox"]);
- };
-
-
-
-$parseRoute = function ($route, Response $response)
- {
- $ressource = $general = $aspect = $action = null;
- $exploded_route = explode('/', p4string::delFirstSlash((p4string::delEndSlash($route))));
- if (sizeof($exploded_route) > 0 && $response->isOk())
- {
- $ressource = $exploded_route[0];
-
- if (sizeof($exploded_route) == 2 && (int) $exploded_route[1] == 0)
- {
- $general = $exploded_route[1];
- }
- else
- {
- switch ($ressource)
- {
- case API_V1_Log::DATABOXES_RESSOURCE :
- if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
- $aspect = $exploded_route[2];
- break;
- case API_V1_Log::RECORDS_RESSOURCE :
- if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 4)
- {
- if (!isset($exploded_route[3]))
- $aspect = "record";
- elseif (preg_match("/^set/", $exploded_route[3]))
- $action = $exploded_route[3];
- else
- $aspect = $exploded_route[3];
- }
- break;
- case API_V1_Log::BASKETS_RESSOURCE :
- if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
- {
- if (preg_match("/^set/", $exploded_route[2]) || preg_match("/^delete/", $exploded_route[2]))
- $action = $exploded_route[2];
- else
- $aspect = $exploded_route[2];
- }
- break;
- case API_V1_Log::FEEDS_RESSOURCE :
- if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
- $aspect = $exploded_route[2];
- break;
- }
- }
- }
-
- return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
- };
-
-
-
-/**
- * oAuth verification process
- */
-$app->before(function($request) use ($app)
- {
- $session = $app["appbox"]->get_session();
- $oauth2_adapter = new API_OAuth2_Adapter($app["appbox"]);
- $oauth2_adapter->verifyAccessToken();
-
- $app['p4user'] = User_Adapter::getInstance($oauth2_adapter->get_usr_id(), $app["appbox"]);
- $app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
-
- if ($session->is_authenticated())
-
- return;
- if ($oauth2_adapter->has_ses_id())
- {
- try
- {
- $session->restore($app['p4user'], $oauth2_adapter->get_ses_id());
-
- return;
- }
- catch (\Exception $e)
- {
-
- }
- }
- $auth = new Session_Authentication_None($app['p4user']);
- $session->authenticate($auth);
- $oauth2_adapter->remember_this_ses_id($session->get_ses_id());
-
- return;
- });
-
-
-/**
- * oAUth log process
- */
-$app->after(function (Request $request, Response $response) use ($app, $parseRoute)
- {
- $account = $app['token']->get_account();
- $pathInfo = $request->getPathInfo();
- $route = $parseRoute($pathInfo, $response);
- $log = API_V1_Log::create(
- $app["appbox"],
- $account,
- $request->getMethod() . " " . $pathInfo,
- $response->getStatusCode(),
- $response->headers->get('content-type'),
- $route['ressource'],
- $route['general'],
- $route['aspect'],
- $route['action']);
- });
-
-/**
- * Method Not Allowed Closure
- */
-$bad_request_exception = function()
- {
- throw new API_V1_exception_badrequest();
- };
-
-/**
- * *******************************************************************
- * Route : /databoxes/list/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- *
- */
-$route = '/databoxes/list/';
-$app->get(
- $route, function() use ($app)
- {
- return $app['response']($app['api']->get_databoxes($app['request']));
- }
-);
-
-/**
- * *******************************************************************
- *
- * Route /databoxes/DATABOX_ID/collections/FORMAT/
- *
- * Method : GET
- *
- * Parameters ;
- * DATABOX_ID : required INT
- */
-$route = '/databoxes/{databox_id}/collections/';
-$app->get(
- $route, function($databox_id) use ($app)
- {
- $result = $app['api']->get_databox_collections($app['request'], $databox_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+');
-
-$app->get('/databoxes/{any_id}/collections/', $bad_request_exception);
-
-
-/**
- * *******************************************************************
- * Route /databoxes/DATABOX_ID/status/FORMAT/
- *
- * Method : GET
- *
- * Parameters ;
- * DATABOX_ID : required INT
- *
- */
-$route = '/databoxes/{databox_id}/status/';
-$app->get(
- $route, function($databox_id) use ($app)
- {
- $result = $app['api']->get_databox_status($app['request'], $databox_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+');
-
-$app->get('/databoxes/{any_id}/status/', $bad_request_exception);
-
-/**
- * Route /databoxes/DATABOX_ID/metadatas/FORMAT/
- *
- * Method : GET
- *
- * Parameters ;
- * DATABOX_ID : required INT
- */
-$route = '/databoxes/{databox_id}/metadatas/';
-$app->get(
- $route, function($databox_id) use ($app)
- {
- $result = $app['api']->get_databox_metadatas($app['request'], $databox_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+');
-
-$app->get('/databoxes/{any_id}/metadatas/', $bad_request_exception);
-
-/**
- * Route /databoxes/DATABOX_ID/termsOfUse/FORMAT/
- *
- * Method : GET
- *
- * Parameters ;
- * DATABOX_ID : required INT
- */
-$route = '/databoxes/{databox_id}/termsOfUse/';
-$app->get(
- $route, function($databox_id) use ($app)
- {
- $result = $app['api']->get_databox_terms($app['request'], $databox_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+');
-
-$app->get('/databoxes/{any_id}/termsOfUse/', $bad_request_exception);
-
-
-
-
-
-/**
- * Route : /records/search/FORMAT/
- *
- * Method : GET or POST
- *
- * Parameters :
- * bases[] : array
- * status[] : array
- * fields[] : array
- * record_type : boolean
- * media_type : string
- *
- * Response :
- * Array of record objects
- *
- */
-$route = '/records/search/';
-$app->post(
- $route, function() use ($app)
- {
- $result = $app['api']->search_records($app['request']);
-
- return $app['response']($result);
- }
-);
-
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/metadatas/';
-$app->get(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->get_record_metadatas($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->get('/records/{any_id}/{anyother_id}/metadatas/', $bad_request_exception);
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/status/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/status/';
-$app->get(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->get_record_status($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->get('/records/{any_id}/{anyother_id}/status/', $bad_request_exception);
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/related/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/related/';
-$app->get(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->get_record_related($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->get('/records/{any_id}/{anyother_id}/related/', $bad_request_exception);
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/embed/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/embed/';
-$app->get(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->get_record_embed($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->get('/records/{any_id}/{anyother_id}/embed/', $bad_request_exception);
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/setmetadatas/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/setmetadatas/';
-$app->post(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->set_record_metadatas($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->post('/records/{any_id}/{anyother_id}/setmetadatas/', $bad_request_exception);
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/setstatus/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/setstatus/';
-$app->post(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->set_record_status($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-
-$app->post('/records/{any_id}/{anyother_id}/setstatus/', $bad_request_exception);
-
-
-/**
- * Route : /records/DATABOX_ID/RECORD_ID/setcollection/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- * DATABOX_ID : required INT
- * RECORD_ID : required INT
- *
- */
-$route = '/records/{databox_id}/{record_id}/setcollection/';
-$app->post(
- $route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->set_record_collection($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- }
-)->assert('databox_id', '\d+')->assert('record_id', '\d+');
-$app->post('/records/{wrong_databox_id}/{wrong_record_id}/setcollection/', $bad_request_exception);
-
-
-$route = '/records/{databox_id}/{record_id}/';
-$app->get($route, function($databox_id, $record_id) use ($app)
- {
- $result = $app['api']->get_record($app['request'], $databox_id, $record_id);
-
- return $app['response']($result);
- })->assert('databox_id', '\d+')->assert('record_id', '\d+');
-$app->get('/records/{any_id}/{anyother_id}/', $bad_request_exception);
-
-/**
- * Route : /baskets/list/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- *
- */
-$route = '/baskets/list/';
-$app->get(
- $route, function() use ($app)
- {
- $result = $app['api']->search_baskets($app['request']);
-
- return $app['response']($result);
- }
-);
-
-
-/**
- * Route : /baskets/add/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- *
- */
-$route = '/baskets/add/';
-$app->post(
- $route, function() use ($app)
- {
- $result = $app['api']->create_basket($app['request']);
-
- return $app['response']($result);
- }
-);
-
-
-
-/**
- * Route : /baskets/BASKET_ID/content/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * BASKET_ID : required INT
- *
- */
-$route = '/baskets/{basket_id}/content/';
-$app->get(
- $route, function($basket_id) use ($app)
- {
- $result = $app['api']->get_basket($app['request'], $basket_id);
-
- return $app['response']($result);
- }
-)->assert('basket_id', '\d+');
-$app->get('/baskets/{wrong_basket_id}/content/', $bad_request_exception);
-
-
-/**
- * Route : /baskets/BASKET_ID/settitle/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * BASKET_ID : required INT
- *
- */
-$route = '/baskets/{basket_id}/setname/';
-$app->post(
- $route, function($basket_id) use ($app)
- {
- $result = $app['api']->set_basket_title($app['request'], $basket_id);
-
- return $app['response']($result);
- }
-)->assert('basket_id', '\d+');
-$app->post('/baskets/{wrong_basket_id}/setname/', $bad_request_exception);
-
-
-/**
- * Route : /baskets/BASKET_ID/setdescription/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- * BASKET_ID : required INT
- *
- */
-$route = '/baskets/{basket_id}/setdescription/';
-$app->post(
- $route, function($basket_id) use ($app)
- {
- $result = $app['api']->set_basket_description($app['request'], $basket_id);
-
- return $app['response']($result);
- }
-)->assert('basket_id', '\d+');
-$app->post('/baskets/{wrong_basket_id}/setdescription/', $bad_request_exception);
-
-/**
- * Route : /baskets/BASKET_ID/delete/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- * BASKET_ID : required INT
- *
- */
-$route = '/baskets/{basket_id}/delete/';
-$app->post(
- $route, function($basket_id) use ($app)
- {
- $result = $app['api']->delete_basket($app['request'], $basket_id);
-
- return $app['response']($result);
- }
-)->assert('basket_id', '\d+');
-$app->post('/baskets/{wrong_basket_id}/delete/', $bad_request_exception);
-
-
-/**
- * Route : /feeds/list/FORMAT/
- *
- * Method : POST
- *
- * Parameters :
- *
- */
-// public function search_publications(\Symfony\Component\HttpFoundation\Request $app['request']);
-
-
-$route = '/feeds/list/';
-$app->get(
- $route, function() use ($app)
- {
- $result = $app['api']->search_publications($app['request'], $app['p4user']);
-
- return $app['response']($result);
- }
-);
-
-/**
- * Route : /feeds/PUBLICATION_ID/content/FORMAT/
- *
- * Method : GET
- *
- * Parameters :
- * PUBLICATION_ID : required INT
- *
- */
-// public function get_publication(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
-
-$route = '/feeds/{feed_id}/content/';
-$app->get(
- $route, function($feed_id) use ($app)
- {
- $result = $app['api']->get_publication($app['request'], $feed_id, $app['p4user']);
-
- return $app['response']($result);
- }
-)->assert('feed_id', '\d+');
-$app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
-
-/**
- * *******************************************************************
- *
- * Route Errors
- *
- */
-$app->error(function (\Exception $e) use ($app)
- {
-
- if ($e instanceof API_V1_exception_methodnotallowed)
- $code = API_V1_result::ERROR_METHODNOTALLOWED;
- elseif ($e instanceof Exception\MethodNotAllowedHttpException)
- $code = API_V1_result::ERROR_METHODNOTALLOWED;
- elseif ($e instanceof API_V1_exception_badrequest)
- $code = API_V1_result::ERROR_BAD_REQUEST;
- elseif ($e instanceof API_V1_exception_forbidden)
- $code = API_V1_result::ERROR_FORBIDDEN;
- elseif ($e instanceof API_V1_exception_unauthorized)
- $code = API_V1_result::ERROR_UNAUTHORIZED;
- elseif ($e instanceof API_V1_exception_internalservererror)
- $code = API_V1_result::ERROR_INTERNALSERVERERROR;
-// elseif ($e instanceof API_V1_exception_notfound)
-// $code = API_V1_result::ERROR_NOTFOUND;
- elseif ($e instanceof Exception_NotFound)
- $code = API_V1_result::ERROR_NOTFOUND;
- elseif ($e instanceof Exception\NotFoundHttpException)
- $code = API_V1_result::ERROR_NOTFOUND;
- else
- $code = API_V1_result::ERROR_INTERNALSERVERERROR;
-
- $result = $app['api']->get_error_message($app['request'], $code);
-
- return $app['response']($result);
- });
-//// public function get_version();
-////
-////
-//// /**
-//// * Route : /records/DATABOX_ID/RECORD_ID/addtobasket/FORMAT/
-//// *
-//// * Method : POST
-//// *
-//// * Parameters :
-//// * DATABOX_ID : required INT
-//// * RECORD_ID : required INT
-//// *
-//// */
-//// public function add_record_tobasket(\Symfony\Component\HttpFoundation\Request $app['request'], $databox_id, $record_id);
-////
-////
-//// /**
-//// * Route : /feeds/PUBLICATION_ID/remove/FORMAT/
-//// *
-//// * Method : GET
-//// *
-//// * Parameters :
-//// * PUBLICATION_ID : required INT
-//// *
-//// */
-//// public function remove_publications(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
-////
-////
-//// /**
-//// * Route : /users/search/FORMAT/
-//// *
-//// * Method : POST-GET
-//// *
-//// * Parameters :
-//// *
-//// */
-//// public function search_users(\Symfony\Component\HttpFoundation\Request $app['request']);
-////
-//// /**
-//// * Route : /users/USER_ID/access/FORMAT/
-//// *
-//// * Method : GET
-//// *
-//// * Parameters :
-//// * USER_ID : required INT
-//// *
-//// */
-//// public function get_user_acces(\Symfony\Component\HttpFoundation\Request $app['request'], $usr_id);
-////
-//// /**
-//// * Route : /users/add/FORMAT/
-//// *
-//// * Method : POST
-//// *
-//// * Parameters :
-//// *
-//// */
-//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
-return $app;
-
-});
diff --git a/lib/classes/module/console/aboutAuthors.class.php b/lib/classes/module/console/aboutAuthors.class.php
index 50e9698a6d..212e090a37 100644
--- a/lib/classes/module/console/aboutAuthors.class.php
+++ b/lib/classes/module/console/aboutAuthors.class.php
@@ -37,9 +37,9 @@ class module_console_aboutAuthors extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- $output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../AUTHORS'));
+ $output->writeln(file_get_contents(__DIR__ . '/../../../../AUTHORS'));
- return;
+ return 0;
}
}
diff --git a/lib/classes/module/console/aboutLicense.class.php b/lib/classes/module/console/aboutLicense.class.php
index 246140dbbc..57df72cc13 100644
--- a/lib/classes/module/console/aboutLicense.class.php
+++ b/lib/classes/module/console/aboutLicense.class.php
@@ -37,9 +37,9 @@ class module_console_aboutLicense extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- $output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../LICENSE'));
+ $output->writeln(file_get_contents(__DIR__ . '/../../../../LICENSE'));
- return;
+ return 0;
}
}
diff --git a/lib/classes/module/console/checkExtension.class.php b/lib/classes/module/console/checkExtension.class.php
new file mode 100644
index 0000000000..35fcfd9117
--- /dev/null
+++ b/lib/classes/module/console/checkExtension.class.php
@@ -0,0 +1,248 @@
+setDescription('Delete a documentation field from a Databox');
+
+ $this->addOption('usr_id', 'u', InputOption::VALUE_OPTIONAL, 'Usr_id to use. If no user, get the first available');
+
+ $this->addOption('query', '', InputOption::VALUE_OPTIONAL, 'The query', 'last');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ if (!extension_loaded('phrasea2'))
+ printf("Missing Extension php-phrasea");
+
+ $appbox = \appbox::get_instance();
+ $registry = $appbox->get_registry();
+
+ $usr_id = $input->getOption('usr_id');
+
+ try
+ {
+ $TestUser = \User_Adapter::getInstance($usr_id, $appbox);
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Wrong user ! ");
+
+ return 1;
+ }
+
+ $output->writeln(
+ sprintf(
+ "\nWill do the check with user %s (%s)\n"
+ , $TestUser->get_display_name()
+ , $TestUser->get_email()
+ )
+ );
+
+ $output->writeln("PHRASEA FUNCTIONS");
+
+ foreach (get_extension_funcs("phrasea2") as $function)
+ {
+ $output->writeln("$function ");
+ }
+
+ require (__DIR__ . '/../../../../config/connexion.inc');
+
+
+ $output->writeln("\n-- phrasea_conn --");
+
+ if (phrasea_conn($hostname, $port, $user, $password, $dbname) !== true)
+ {
+ $output->writeln("Failed ! got no connection");
+
+ return 1;
+ }
+ else
+ {
+ $output->writeln("Succes ! got connection");
+ }
+
+ $output->writeln("");
+
+ $output->writeln("\n-- phrasea_info --");
+
+ foreach (phrasea_info() as $key => $value)
+ {
+ $output->writeln("\t$key => $value");
+ }
+
+
+ $output->writeln("");
+
+ $output->writeln("\n-- phrasea_create_session --");
+
+ $sessid = phrasea_create_session((string) $TestUser->get_id());
+
+ if (ctype_digit((string) $sessid))
+ {
+ $output->writeln("Succes ! got session id $sessid");
+ }
+ else
+ {
+ $output->writeln("Failed ! got no session id");
+
+ return 1;
+ }
+
+ $output->writeln("\n-- phrasea_open_session --");
+
+ $ph_session = phrasea_open_session($sessid, $usr_id);
+
+ if ($ph_session)
+ {
+ $output->writeln("Succes ! got session ");
+ }
+ else
+ {
+ $output->writeln("Failed ! got no session ");
+
+ return 1;
+ }
+
+ $output->writeln("\n-- phrasea_clear_cache --");
+
+ $ret = phrasea_clear_cache($sessid);
+
+ if ($sessid)
+ {
+ $output->writeln("Succes ! got session ");
+ }
+ else
+ {
+ $output->writeln("Failed ! got no session ");
+
+ return 1;
+ }
+
+ $tbases = array();
+
+ foreach ($ph_session["bases"] as $phbase)
+ {
+ $tcoll = array();
+ foreach ($phbase["collections"] as $coll)
+ {
+ $tcoll[] = 0 + $coll["base_id"];
+ }
+ if (sizeof($tcoll) > 0)
+ {
+ $kbase = "S" . $phbase["sbas_id"];
+ $tbases[$kbase] = array();
+ $tbases[$kbase]["sbas_id"] = $phbase["sbas_id"];
+ $tbases[$kbase]["searchcoll"] = $tcoll;
+ $tbases[$kbase]["mask_xor"] = $tbases[$kbase]["mask_and"] = 0;
+
+ $qp = new searchEngine_adapter_phrasea_queryParser();
+ $treeq = $qp->parsequery($input->getOption('query'));
+ $arrayq = $qp->makequery($treeq);
+
+ $tbases[$kbase]["arrayq"] = $arrayq;
+ }
+ }
+
+
+ $output->writeln("\n-- phrasea_query --");
+
+ $nbanswers = 0;
+ foreach ($tbases as $kb => $base)
+ {
+ $tbases[$kb]["results"] = NULL;
+
+ $ret = phrasea_query2(
+ $ph_session["session_id"]
+ , $base["sbas_id"]
+ , $base["searchcoll"]
+ , $base["arrayq"]
+ , $registry->get('GV_sit')
+ , $usr_id
+ , FALSE
+ , PHRASEA_MULTIDOC_DOCONLY
+ );
+
+
+ if ($ret)
+ {
+ $output->writeln("Succes ! got result on sbas_id " . $base["sbas_id"]);
+ }
+ else
+ {
+ $output->writeln("Failed ! No results on sbas_id " . $base["sbas_id"]);
+
+ return 1;
+ }
+
+ $tbases[$kb]["results"] = $ret;
+
+ $nbanswers += $tbases[$kb]["results"]["nbanswers"];
+ }
+
+
+ $output->writeln("Got a total of $nbanswers answers");
+
+ $output->writeln("\n-- phrasea_fetch_results --");
+
+ $rs = phrasea_fetch_results($sessid, $usr_id, 1, true, '[[em]]', '[[/em]]');
+
+ if ($rs)
+ {
+ $output->writeln("Succes ! got result ");
+ }
+ else
+ {
+ $output->writeln("Failed ! got no result ");
+
+ return 1;
+ }
+
+ $output->writeln("\n-- phrasea_close_session --");
+
+ $rs = phrasea_close_session($sessid);
+
+ if ($rs)
+ {
+ $output->writeln("Succes ! closed ! ");
+ }
+ else
+ {
+ $output->writeln("Failed ! not closed ");
+
+ return 1;
+ }
+
+ return 0;
+ }
+
+}
diff --git a/lib/classes/module/console/fieldsDelete.class.php b/lib/classes/module/console/fieldsDelete.class.php
new file mode 100644
index 0000000000..b94f70c366
--- /dev/null
+++ b/lib/classes/module/console/fieldsDelete.class.php
@@ -0,0 +1,98 @@
+setDescription('Delete a documentation field from a Databox');
+
+ $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
+
+ $this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ if (!$input->getOption('sbas_id'))
+ throw new \Exception('Missing argument sbas_id');
+
+ if (!$input->getOption('meta_struct_id'))
+ throw new \Exception('Missing argument meta_struct_id');
+
+ try
+ {
+ $databox = \databox::get_instance((int) $input->getOption('sbas_id'));
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Invalid databox id ");
+
+ return 1;
+ }
+
+ try
+ {
+ $field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Invalid meta struct id ");
+
+ return 1;
+ }
+
+
+ $dialog = $this->getHelperSet()->get('dialog');
+ $continue = mb_strtolower(
+ $dialog->ask(
+ $output
+ , "About to delete " . $field->get_name() . " (y/N) "
+ , 'n'
+ )
+ );
+
+ if($continue != 'y')
+ {
+ $output->writeln("Request canceled by user");
+
+ return 1;
+ }
+
+ $output->writeln("Deleting ... ");
+
+ $field->delete();
+
+ $output->writeln("Done with success !");
+
+ return 0;
+ }
+
+}
diff --git a/lib/classes/module/console/fieldsList.class.php b/lib/classes/module/console/fieldsList.class.php
new file mode 100644
index 0000000000..b1a5e14be5
--- /dev/null
+++ b/lib/classes/module/console/fieldsList.class.php
@@ -0,0 +1,70 @@
+setDescription('List all databox fields');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+
+ foreach ($appbox->get_databoxes() as $databox)
+ {
+ /* @var $databox \databox */
+ $output->writeln(
+ sprintf(
+ "\n ---------------- \nOn databox %s (sbas_id %d) :\n"
+ , $databox->get_viewname()
+ , $databox->get_sbas_id()
+ )
+ );
+
+ foreach ($databox->get_meta_structure()->get_elements() as $field)
+ {
+ $output->writeln(
+ sprintf(
+ " %2d - %s (%s) %s"
+ , $field->get_id()
+ , $field->get_name()
+ , $field->get_type()
+ , ($field->is_multi() ? 'multi ' : '')
+ )
+ );
+ }
+ }
+
+ return 0;
+ }
+
+}
diff --git a/lib/classes/module/console/fieldsMerge.class.php b/lib/classes/module/console/fieldsMerge.class.php
new file mode 100644
index 0000000000..d3042a4732
--- /dev/null
+++ b/lib/classes/module/console/fieldsMerge.class.php
@@ -0,0 +1,284 @@
+setDescription('Merge databox structure fields');
+
+ $this->addOption(
+ 'source'
+ , 'f'
+ , InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
+ , 'Metadata structure ids for source'
+ , array()
+ );
+
+ $this->addOption(
+ 'destination'
+ , 'd'
+ , InputOption::VALUE_REQUIRED
+ , 'Metadata structure id destination'
+ );
+
+ $this->addOption(
+ 'sbas_id'
+ , 's'
+ , InputOption::VALUE_REQUIRED
+ , 'Databox sbas_id'
+ );
+
+ $this->addOption(
+ 'separator'
+ , ''
+ , InputOption::VALUE_OPTIONAL
+ , 'Separator for concatenation (if destination is monovalued)'
+ , ';'
+ );
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+ $output->writeln("");
+
+ if (!$input->getOption('sbas_id'))
+ throw new \Exception('Missing argument sbas_id');
+
+ try
+ {
+ $databox = \databox::get_instance((int) $input->getOption('sbas_id'));
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Invalid databox id ");
+
+ return 1;
+ }
+
+ $sources = array();
+
+ foreach ($input->getOption('source') as $source_id)
+ {
+ $sources[] = $databox->get_meta_structure()->get_element($source_id);
+ }
+
+ if (count($sources) === 0)
+ throw new \Exception('No sources to proceed');
+
+ if (!$input->getOption('destination'))
+ throw new \Exception('Missing argument destination');
+
+ $separator = ' ' . $input->getOption('separator') . ' ';
+
+ $destination = $databox->get_meta_structure()->get_element($input->getOption('destination'));
+
+ $types = $multis = array();
+
+ foreach ($sources as $source)
+ {
+ array_push($types, $source->get_type());
+ array_push($multis, $source->is_multi());
+ }
+
+ $types = array_unique($types);
+ $multis = array_unique($multis);
+
+ if (count(array_unique($types)) > 1)
+ {
+ $output->writeln(
+ sprintf("Warning, trying to merge inconsistent types : %s \n"
+ , implode(', ', $types)
+ )
+ );
+ }
+
+ if (count(array_unique($multis)) > 1)
+ {
+ $output->writeln(
+ sprintf(
+ "Warning, trying to merge mono and multi values fields\n"
+ )
+ );
+ }
+
+ $field_names = array();
+ foreach ($sources as $source)
+ {
+ $field_names[] = $source->get_name();
+ }
+
+ if (count($multis) == 1)
+ {
+ if ($multis[0] === false && !$destination->is_multi())
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge mono valued fields in a "
+ . "monovalued field , fields will be "
+ . "concatenated in the following order : %s"
+ , implode($separator, $field_names)
+ )
+ );
+ $this->displayHelpConcatenation($output);
+ }
+ elseif ($multis[0] === true && !$destination->is_multi())
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge multi valued fields in a "
+ . "monovalued field , fields will be "
+ . "concatenated in the following order : %s"
+ , implode(' ', $field_names)
+ )
+ );
+ $this->displayHelpConcatenation($output);
+ }
+ elseif ($multis[0] === false && $destination->is_multi())
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge mono valued fields in a "
+ . "multivalued field "
+ )
+ );
+ }
+ elseif ($multis[0] === true && $destination->is_multi())
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge multi valued fields in a "
+ . "multivalued field "
+ )
+ );
+ }
+ }
+ elseif ($destination->is_multi())
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge mixed valued fields in a "
+ . "multivalued field"
+ )
+ );
+ }
+ else
+ {
+ $output->writeln(
+ sprintf(
+ "You are going to merge mixed valued fields in a "
+ . "monovalued field , fields will be "
+ . "concatenated in the following order : %s"
+ , implode($separator, $field_names)
+ )
+ );
+ $this->displayHelpConcatenation($output);
+ }
+
+ $start = 0;
+ $quantity = 100;
+
+ do
+ {
+ $sql = 'SELECT record_id FROM record
+ ORDER BY record_id LIMIT ' . $start . ', ' . $quantity;
+ $stmt = $databox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ foreach ($results as $row)
+ {
+ $record = $databox->get_record($row['record_id']);
+
+ $datas = array();
+
+ foreach ($sources as $source)
+ {
+ try
+ {
+ $value = $record->get_caption()->get_field($source->get_name())->get_value();
+ }
+ catch (\Exception $e)
+ {
+ $value = array();
+ }
+ if (!is_array($value))
+ {
+ $value = array($value);
+ }
+
+ $datas = array_merge($datas, $value);
+ }
+
+ $datas = array_unique($datas);
+
+ if (!$destination->is_multi())
+ {
+ $datas = array(implode($separator, $datas));
+ }
+
+ try
+ {
+ $record->get_caption()->get_field($destination->get_name())->set_value($datas);
+ }
+ catch (\Exception $e)
+ {
+ $record->set_metadatas(
+ array(
+ array(
+ 'meta_struct_id' => $destination->get_id()
+ , 'meta_id' => null
+ , 'value' => $datas
+ )
+ )
+ , true
+ );
+ }
+ unset($record);
+ }
+
+ $start += $quantity;
+ }
+ while (count($results) > 0);
+
+ return 0;
+ }
+
+ protected function displayHelpConcatenation(OutputInterface $output)
+ {
+
+ $output->writeln("\nYou can choose the concatenation order in the "
+ . "commandline (first option is first value) and set a separator "
+ . "with the --separator option)");
+
+ return $this;
+ }
+
+}
diff --git a/lib/classes/module/console/fieldsRename.class.php b/lib/classes/module/console/fieldsRename.class.php
new file mode 100644
index 0000000000..adc1a691f3
--- /dev/null
+++ b/lib/classes/module/console/fieldsRename.class.php
@@ -0,0 +1,106 @@
+setDescription('Rename a documentation field from a Databox');
+
+ $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
+
+ $this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
+
+ $this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'The new name');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+
+ if (!$input->getOption('sbas_id'))
+ throw new \Exception('Missing argument sbas_id');
+
+ if (!$input->getOption('meta_struct_id'))
+ throw new \Exception('Missing argument meta_struct_id');
+
+ if (!$input->getOption('name'))
+ throw new \Exception('Missing argument name');
+
+ $new_name = $input->getOption('name');
+
+ try
+ {
+ $databox = \databox::get_instance((int) $input->getOption('sbas_id'));
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Invalid databox id ");
+
+ return 1;
+ }
+
+ try
+ {
+ $field = $databox->get_meta_structure()->get_element((int) $input->getArgument('meta_struct_id'));
+ }
+ catch (\Exception $e)
+ {
+ $output->writeln("Invalid meta struct id ");
+
+ return 1;
+ }
+
+
+ $dialog = $this->getHelperSet()->get('dialog');
+ $continue = mb_strtolower(
+ $dialog->ask(
+ $output
+ , "About to rename " . $field->get_name() . " into ".$new_name." (y/N) "
+ , 'n'
+ )
+ );
+
+ if($continue != 'y')
+ {
+ $output->writeln("Request canceled by user");
+
+ return 1;
+ }
+
+ $output->writeln("Renaming ... ");
+
+ $field->set_name($new_name);
+ $field->save();
+
+ $output->writeln("Done with success !");
+
+ return 0;
+ }
+
+}
diff --git a/lib/classes/module/console/fileEnsureDevSetting.class.php b/lib/classes/module/console/fileEnsureDevSetting.class.php
new file mode 100644
index 0000000000..01e8cf8056
--- /dev/null
+++ b/lib/classes/module/console/fileEnsureDevSetting.class.php
@@ -0,0 +1,922 @@
+setDescription('Ensure development settings');
+
+ $this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
+ $this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+ $specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+
+ $environnement = $input->getArgument('conf');
+
+ $this->configuration = \Alchemy\Phrasea\Core\Configuration::build($specifications, $environnement);
+
+ if (!$this->configuration->isInstalled())
+ {
+ $output->writeln(sprintf("\nPhraseanet is not installed\n"));
+ }
+
+ $this->checkParse($output);
+ $output->writeln(sprintf("Will Ensure Production Settings on %s ", $this->configuration->getEnvironnement()));
+
+ $this->runTests($output);
+
+ $retval = $this->errors;
+ if ($input->getOption('strict'))
+ {
+ $retval += $this->alerts;
+ }
+
+ if ($retval > 0)
+ {
+ $output->writeln("\nSome errors found in your conf ");
+ }
+ else
+ {
+ $output->writeln("\nYour dev settings are setted correctly ! Enjoy ");
+ }
+ $output->writeln('End');
+
+ return $retval;
+ }
+
+ private function runTests(OutputInterface $output)
+ {
+ foreach ($this->testSuite as $test)
+ {
+ $display = "";
+ switch ($test)
+ {
+ case 'checkPhraseanetScope' :
+ $display = "Phraseanet Configuration";
+ break;
+ case 'checkDatabaseScope' :
+ $display = "Database";
+ break;
+ case 'checkTeamplateEngineService' :
+ $display = "Template Engine";
+ break;
+ case 'checkOrmService' :
+ $display = "ORM";
+ break;
+ case 'checkCacheService' :
+ $display = "Cache";
+ break;
+ case 'checkOpcodeCacheService' :
+ $display = "Opcode";
+ break;
+ default:
+ throw new \Exception('Unknown test');
+ break;
+ }
+
+ $output->writeln(sprintf("\n||| %s", mb_strtoupper($display)));
+
+ call_user_func(array($this, $test), $output);
+ }
+ }
+
+ private function checkParse(OutputInterface $output)
+ {
+
+ if (!$this->configuration->getConfigurations())
+ {
+ throw new \Exception("Unable to load configurations\n");
+ }
+ if (!$this->configuration->getConnexions())
+ {
+ throw new \Exception("Unable to load connexions\n");
+ }
+ if (!$this->configuration->getServices())
+ {
+ throw new \Exception("Unable to load services\n");
+ }
+
+ return;
+ }
+
+ private function checkCacheService(OutputInterface $output)
+ {
+ $cache = $this->configuration->getCache();
+
+
+ if ($this->probeCacheService($output, $cache))
+ {
+ if ($this->recommendedCacheService($output, $cache, true))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'Cache server recommended ';
+ $this->alerts++;
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", 'MainCache', $work_message);
+
+
+ $this->printConf($output, "\t" . 'service', $cache, false, $verification);
+ $this->verifyCacheOptions($output, $cache);
+ }
+
+ private function checkOpcodeCacheService(OutputInterface $output)
+ {
+ $cache = $this->configuration->getOpcodeCache();
+
+
+ if ($this->probeCacheService($output, $cache))
+ {
+ if ($this->recommendedCacheService($output, $cache, false))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'No cache required ';
+ $this->errors++;
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", 'OpcodeCache', $work_message);
+
+
+ $this->printConf($output, "\t" . 'service', $cache, false, $verification);
+ $this->verifyCacheOptions($output, $cache);
+ }
+
+ private function checkPhraseanetScope(OutputInterface $output)
+ {
+ $required = array('servername', 'maintenance', 'debug', 'display_errors', 'database');
+
+ $phraseanet = $this->configuration->getPhraseanet();
+
+ foreach ($phraseanet->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ case 'servername':
+ $url = $value;
+ $required = array_diff($required, array($conf));
+
+ $parseUrl = parse_url($url);
+
+ if (empty($url))
+ {
+ $message = "should not be empty ";
+ $this->errors++;
+ }
+ elseif ($url == 'http://sub.domain.tld/')
+ {
+ $this->alerts++;
+ $message = "may be wrong ";
+ }
+ elseif (!filter_var($url, FILTER_VALIDATE_URL))
+ {
+ $message = "not valid ";
+ $this->errors++;
+ }
+ else
+ {
+ $message = "OK ";
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'maintenance':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== false)
+ {
+ $message = 'Should be true ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'debug':
+ case 'display_errors':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== true)
+ {
+ $message = 'Should be true ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'database':
+ $required = array_diff($required, array($conf));
+ try
+ {
+ $service = $this->configuration->getConnexion($value);
+ if ($this->verifyDatabaseConnexion($service))
+ {
+ $message = 'OK ';
+ }
+ else
+ {
+ $message = 'Connection not available ';
+ $this->errors++;
+ }
+ }
+ catch (\Exception $e)
+ {
+ $message = 'Unknown connection ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ private function checkDatabaseScope(OutputInterface $output)
+ {
+ $connexionName = $this->configuration->getPhraseanet()->get('database');
+ $connexion = $this->configuration->getConnexion($connexionName);
+
+ try
+ {
+ if ($this->verifyDatabaseConnexion($connexion))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+ }
+ catch (\Exception $e)
+ {
+
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify connection %s : %s", $connexionName, $work_message));
+
+ $required = array('driver');
+
+ if (!$connexion->has('driver'))
+ {
+ $output->writeln("\nConnection has no driver ");
+ $this->errors++;
+ }
+ elseif ($connexion->get('driver') == 'pdo_mysql')
+ {
+ $required = array('driver', 'dbname', 'charset', 'password', 'user', 'port', 'host');
+ }
+ elseif ($connexion->get('driver') == 'pdo_sqlite')
+ {
+ $required = array('driver', 'path', 'charset');
+ }
+ else
+ {
+ $output->writeln("\nYour driver is not managed ");
+ $this->errors++;
+ }
+
+ foreach ($connexion->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ case 'charset':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+ if ($value !== 'UTF8')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'path':
+ $required = array_diff($required, array($conf));
+ $message = is_writable(dirname($value)) ? 'OK ' : 'Not writeable ';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'dbname':
+ case 'user':
+ case 'host':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'port':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!ctype_digit($value))
+ {
+ $message = 'Should be ctype_digit ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'password':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $value = '***********';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'driver':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== 'pdo_mysql')
+ {
+ $message = 'MySQL recommended ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ protected function verifyDatabaseConnexion(\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $connexion)
+ {
+ try
+ {
+ $config = new \Doctrine\DBAL\Configuration();
+ $conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
+
+ return true;
+ }
+ catch (\Exception $e)
+ {
+
+ }
+
+ return false;
+ }
+
+ private function checkTeamplateEngineService(OutputInterface $output)
+ {
+ $templateEngineName = $this->configuration->getTemplating();
+ $configuration = $this->configuration->getService($templateEngineName);
+
+ try
+ {
+ Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
+ $work_message = 'Works ! ';
+ }
+ catch (\Exception $e)
+ {
+ $work_message = 'Failed - could not load template engine ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify Template engine %s : %s", $templateEngineName, $work_message));
+
+ if (!$configuration->has('type'))
+ {
+ $output->writeln("\nConfiguration has no type ");
+ $this->errors++;
+ }
+ elseif ($configuration->get('type') == 'TemplateEngine\\Twig')
+ {
+ $required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
+ }
+ else
+ {
+ $output->writeln("\nYour type is not managed ");
+ $this->errors++;
+ }
+
+
+
+ foreach ($configuration->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'type':
+ $message = 'OK ';
+
+ if ($value !== 'TemplateEngine\\Twig')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'options':
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, 'unknown', false, 'Not recognized ');
+ break;
+ }
+ }
+
+ foreach ($configuration->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'debug';
+ case 'strict_variables';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== true)
+ {
+ $message = 'Should be false ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ case 'autoescape';
+ case 'optimizer';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== true)
+ {
+ $message = 'Should be true ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ case 'charset';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== 'utf-8')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t" . $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ private function checkOrmService(OutputInterface $output)
+ {
+ $ormName = $this->configuration->getOrm();
+ $configuration = $this->configuration->getService($ormName);
+
+ try
+ {
+ $service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
+ $work_message = 'Works ! ';
+ }
+ catch (\Exception $e)
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify ORM engine %s : %s", $ormName, $work_message));
+
+
+
+ if (!$configuration->has('type'))
+ {
+ $output->writeln("\nConfiguration has no type ");
+ $this->errors++;
+ }
+ elseif ($configuration->get('type') == 'Orm\\Doctrine')
+ {
+ $required = array('debug', 'dbal', 'cache');
+ }
+ else
+ {
+ $output->writeln("\nYour type is not managed ");
+ $this->errors++;
+ }
+
+
+
+ foreach ($configuration->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'type':
+ $message = $value == 'Orm\\Doctrine' ? 'OK ' : 'Not recognized ';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'options':
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, 'unknown', false, 'Not recognized ');
+ break;
+ }
+ }
+
+
+ foreach ($configuration->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'log':
+ $message = 'OK ';
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'cache':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be Array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+
+ $required_caches = array('query', 'result', 'metadata');
+ foreach ($value as $name => $cache_type)
+ {
+ $required_caches = array_diff($required_caches, array($name));
+
+ foreach ($cache_type as $key_cache => $value_cache)
+ {
+ switch ($key_cache)
+ {
+ case 'service':
+ if ($this->probeCacheService($output, $value_cache))
+ {
+ $server = $name === 'result';
+ if ($this->recommendedCacheService($output, $value_cache, $server))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $this->errors++;
+ $work_message = 'No cache required ';
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", $name, $work_message);
+
+
+ $this->printConf($output, "\t" . $key_cache, $value_cache, false, $verification);
+ $this->verifyCacheOptions($output, $value_cache);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t" . $key_cache, $value_cache, false, 'Not recognized ');
+ break;
+ }
+ if (!isset($cache_type['service']))
+ {
+ $output->writeln('Miss service for %s ', $cache_type);
+ $this->errors++;
+ }
+ }
+ }
+
+ if (count($required_caches) > 0)
+ {
+ $output->writeln(sprintf('Miss required caches %s ', implode(', ', $required_caches)));
+ $this->errors++;
+ }
+ break;
+ case 'debug':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== true)
+ {
+ $message = 'Should be true ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'dbal':
+ $required = array_diff($required, array($conf));
+ try
+ {
+ $connexion = $this->configuration->getConnexion($value);
+ $this->verifyDatabaseConnexion($connexion);
+ $message = 'OK ';
+ }
+ catch (\Exception $e)
+ {
+ $message = 'Failed ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ protected function verifyCacheOptions(OutputInterface $output, $ServiceName)
+ {
+ try
+ {
+ $conf = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $conf
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ $required_options = array();
+
+ switch ($Service->getType())
+ {
+ default:
+ break;
+ case 'memcache':
+ $required_options = array('host', 'port');
+ break;
+ }
+
+ if ($required_options)
+ {
+ foreach ($conf->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'host';
+ $required_options = array_diff($required_options, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t\t" . $conf, $value, false, $message);
+ break;
+ case 'port';
+ $required_options = array_diff($required_options, array($conf));
+ $message = 'OK ';
+
+ if (!ctype_digit($value))
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, "\t\t" . $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t\t" . $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+ }
+
+ if (count($required_options) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required_options)));
+ $this->errors++;
+ }
+ }
+
+ protected function probeCacheService(OutputInterface $output, $ServiceName)
+ {
+ try
+ {
+ $originalConfiguration = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $originalConfiguration
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ if ($Service->getDriver()->isServer())
+ {
+ switch ($Service->getType())
+ {
+ default:
+ return false;
+ break;
+ case 'memcache':
+ if (!@memcache_connect($Service->getHost(), $Service->getPort()))
+ {
+ return false;
+ }
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ protected function recommendedCacheService(OutputInterface $output, $ServiceName, $server)
+ {
+ try
+ {
+ $originalConfiguration = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $originalConfiguration
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ return $Service->getType() === 'array';
+ }
+
+ private function printConf($output, $scope, $value, $scopage = false, $message = '')
+ {
+ if (is_array($value))
+ {
+ foreach ($value as $key => $val)
+ {
+ if ($scopage)
+ $key = $scope . ":" . $key;
+ $this->printConf($output, $key, $val, $scopage, '');
+ }
+ }
+ elseif (is_bool($value))
+ {
+ if ($value === false)
+ {
+ $value = 'false';
+ }
+ elseif ($value === true)
+ {
+ $value = 'true';
+ }
+ $output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
+ }
+ elseif (!empty($value))
+ {
+ $output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
+ }
+ }
+
+}
diff --git a/lib/classes/module/console/fileEnsureProductionSetting.class.php b/lib/classes/module/console/fileEnsureProductionSetting.class.php
new file mode 100644
index 0000000000..3716bb6972
--- /dev/null
+++ b/lib/classes/module/console/fileEnsureProductionSetting.class.php
@@ -0,0 +1,934 @@
+setDescription('Ensure production settings');
+
+ $this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
+ $this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+ $specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+
+ $environnement = $input->getArgument('conf');
+
+ $this->configuration = \Alchemy\Phrasea\Core\Configuration::build($specifications, $environnement);
+
+ if (!$this->configuration->isInstalled())
+ {
+ $output->writeln(sprintf("\nPhraseanet is not installed\n"));
+ }
+
+ $this->checkParse($output);
+ $output->writeln(sprintf("Will Ensure Production Settings on %s ", $this->configuration->getEnvironnement()));
+
+ $this->runTests($output);
+
+ $retval = $this->errors;
+ if ($input->getOption('strict'))
+ {
+ $retval += $this->alerts;
+ }
+
+ if ($retval > 0)
+ {
+ $output->writeln("\nSome errors found in your conf ");
+ }
+ else
+ {
+ $output->writeln("\nYour production settings are setted correctly ! Enjoy ");
+ }
+ $output->writeln('End');
+
+ return $retval;
+ }
+
+ private function runTests(OutputInterface $output)
+ {
+ foreach ($this->testSuite as $test)
+ {
+ $display = "";
+ switch ($test)
+ {
+ case 'checkPhraseanetScope' :
+ $display = "Phraseanet Configuration";
+ break;
+ case 'checkDatabaseScope' :
+ $display = "Database";
+ break;
+ case 'checkTeamplateEngineService' :
+ $display = "Template Engine";
+ break;
+ case 'checkOrmService' :
+ $display = "ORM";
+ break;
+ case 'checkCacheService' :
+ $display = "Cache";
+ break;
+ case 'checkOpcodeCacheService' :
+ $display = "Opcode";
+ break;
+ default:
+ throw new \Exception('Unknown test');
+ break;
+ }
+
+ $output->writeln(sprintf("\n||| %s", mb_strtoupper($display)));
+
+ call_user_func(array($this, $test), $output);
+ }
+ }
+
+ private function checkParse(OutputInterface $output)
+ {
+
+ if (!$this->configuration->getConfigurations())
+ {
+ throw new \Exception("Unable to load configurations\n");
+ }
+ if (!$this->configuration->getConnexions())
+ {
+ throw new \Exception("Unable to load connexions\n");
+ }
+ if (!$this->configuration->getServices())
+ {
+ throw new \Exception("Unable to load services\n");
+ }
+
+ return;
+ }
+
+ private function checkCacheService(OutputInterface $output)
+ {
+ $cache = $this->configuration->getCache();
+
+
+ if ($this->probeCacheService($output, $cache))
+ {
+ if ($this->recommendedCacheService($output, $cache, true))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'Cache server recommended ';
+ $this->alerts++;
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", 'MainCache', $work_message);
+
+
+ $this->printConf($output, "\t" . 'service', $cache, false, $verification);
+ $this->verifyCacheOptions($output, $cache);
+ }
+
+ private function checkOpcodeCacheService(OutputInterface $output)
+ {
+ $cache = $this->configuration->getOpcodeCache();
+
+
+ if ($this->probeCacheService($output, $cache))
+ {
+ if ($this->recommendedCacheService($output, $cache, false))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'Opcode recommended ';
+ $this->alerts++;
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", 'OpcodeCache', $work_message);
+
+
+ $this->printConf($output, "\t" . 'service', $cache, false, $verification);
+ $this->verifyCacheOptions($output, $cache);
+ }
+
+ private function checkPhraseanetScope(OutputInterface $output)
+ {
+ $required = array('servername', 'maintenance', 'debug', 'display_errors', 'database');
+
+ $phraseanet = $this->configuration->getPhraseanet();
+
+ foreach ($phraseanet->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ case 'servername':
+ $url = $value;
+ $required = array_diff($required, array($conf));
+
+ $parseUrl = parse_url($url);
+
+ if (empty($url))
+ {
+ $message = "should not be empty ";
+ $this->errors++;
+ }
+ elseif ($url == 'http://sub.domain.tld/')
+ {
+ $this->alerts++;
+ $message = "may be wrong ";
+ }
+ elseif (!filter_var($url, FILTER_VALIDATE_URL))
+ {
+ $message = "not valid ";
+ $this->errors++;
+ }
+ elseif ($parseUrl["scheme"] !== "https")
+ {
+ $this->alerts++;
+ $message = "should be https ";
+ }
+ else
+ {
+ $message = "OK ";
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'maintenance':
+ case 'debug':
+ case 'display_errors':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== false)
+ {
+ $message = 'Should be false ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'database':
+ $required = array_diff($required, array($conf));
+ try
+ {
+ $service = $this->configuration->getConnexion($value);
+ if ($this->verifyDatabaseConnexion($service))
+ {
+ $message = 'OK ';
+ }
+ else
+ {
+ $message = 'Connection not available ';
+ $this->errors++;
+ }
+ }
+ catch (\Exception $e)
+ {
+ $message = 'Unknown connection ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ private function checkDatabaseScope(OutputInterface $output)
+ {
+ $connexionName = $this->configuration->getPhraseanet()->get('database');
+ $connexion = $this->configuration->getConnexion($connexionName);
+
+ try
+ {
+ if ($this->verifyDatabaseConnexion($connexion))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+ }
+ catch (\Exception $e)
+ {
+
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify connection %s : %s", $connexionName, $work_message));
+
+ $required = array('driver');
+
+ if (!$connexion->has('driver'))
+ {
+ $output->writeln("\nConnection has no driver ");
+ $this->errors++;
+ }
+ elseif ($connexion->get('driver') == 'pdo_mysql')
+ {
+ $required = array('driver', 'dbname', 'charset', 'password', 'user', 'port', 'host');
+ }
+ elseif ($connexion->get('driver') == 'pdo_sqlite')
+ {
+ $required = array('driver', 'path', 'charset');
+ }
+ else
+ {
+ $output->writeln("\nYour driver is not managed ");
+ $this->errors++;
+ }
+
+ foreach ($connexion->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ case 'charset':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+ if ($value !== 'UTF8')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'path':
+ $required = array_diff($required, array($conf));
+ $message = is_writable(dirname($value)) ? 'OK ' : 'Not writeable ';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'dbname':
+ case 'user':
+ case 'host':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'port':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!ctype_digit($value))
+ {
+ $message = 'Should be ctype_digit ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'password':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $value = '***********';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'driver':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== 'pdo_mysql')
+ {
+ $message = 'MySQL recommended ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ protected function verifyDatabaseConnexion(\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $connexion)
+ {
+ try
+ {
+ $config = new \Doctrine\DBAL\Configuration();
+ $conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
+
+ return true;
+ }
+ catch (\Exception $e)
+ {
+
+ }
+
+ return false;
+ }
+
+ private function checkTeamplateEngineService(OutputInterface $output)
+ {
+ $templateEngineName = $this->configuration->getTemplating();
+ $configuration = $this->configuration->getService($templateEngineName);
+
+ try
+ {
+ Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
+ $work_message = 'Works ! ';
+ }
+ catch (\Exception $e)
+ {
+ $work_message = 'Failed - could not load template engine ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify Template engine %s : %s", $templateEngineName, $work_message));
+
+ if (!$configuration->has('type'))
+ {
+ $output->writeln("\nConfiguration has no type ");
+ $this->errors++;
+ }
+ elseif ($configuration->get('type') == 'TemplateEngine\\Twig')
+ {
+ $required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
+ }
+ else
+ {
+ $output->writeln("\nYour type is not managed ");
+ $this->errors++;
+ }
+
+
+
+ foreach ($configuration->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'type':
+ $message = 'OK ';
+
+ if($value !== 'TemplateEngine\\Twig')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'options':
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, 'unknown', false, 'Not recognized ');
+ break;
+ }
+ }
+
+ foreach ($configuration->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'debug';
+ case 'strict_variables';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== false)
+ {
+ $message = 'Should be false ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ case 'autoescape';
+ case 'optimizer';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== true)
+ {
+ $message = 'Should be true ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ case 'charset';
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== 'utf-8')
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, "\t" . $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t" . $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ private function checkOrmService(OutputInterface $output)
+ {
+ $ormName = $this->configuration->getOrm();
+ $configuration = $this->configuration->getService($ormName);
+
+ try
+ {
+ $service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
+ $work_message = 'Works ! ';
+ }
+ catch (\Exception $e)
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $output->writeln(sprintf("\t--> Verify ORM engine %s : %s", $ormName, $work_message));
+
+
+
+ if (!$configuration->has('type'))
+ {
+ $output->writeln("\nConfiguration has no type ");
+ $this->errors++;
+ }
+ elseif ($configuration->get('type') == 'Orm\\Doctrine')
+ {
+ $required = array('debug', 'dbal', 'cache');
+ }
+ else
+ {
+ $output->writeln("\nYour type is not managed ");
+ $this->errors++;
+ }
+
+
+
+ foreach ($configuration->all() as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'type':
+ $message = $value == 'Orm\\Doctrine' ? 'OK ' : 'Not recognized ';
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'options':
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, 'unknown', false, 'Not recognized ');
+ break;
+ }
+ }
+
+
+ foreach ($configuration->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'log':
+ $message = 'OK ';
+
+ if ($value !== false)
+ {
+ $message = 'Should be deactivated ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'cache':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if (!is_array($value))
+ {
+ $message = 'Should be Array ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, 'array()', false, $message);
+
+ $required_caches = array('query', 'result', 'metadata');
+ foreach ($value as $name => $cache_type)
+ {
+ $required_caches = array_diff($required_caches, array($name));
+
+ foreach ($cache_type as $key_cache => $value_cache)
+ {
+ switch ($key_cache)
+ {
+ case 'service':
+ if ($this->probeCacheService($output, $value_cache))
+ {
+ $server = $name === 'result';
+ if ($this->recommendedCacheService($output, $value_cache, $server))
+ {
+ $work_message = 'Works ! ';
+ }
+ else
+ {
+ $this->alerts++;
+ if ($server)
+ {
+ $work_message = 'Cache server recommended ';
+ }
+ else
+ {
+ $work_message = 'Opcode cache recommended ';
+ }
+ }
+ }
+ else
+ {
+ $work_message = 'Failed - could not connect ! ';
+ $this->errors++;
+ }
+
+ $verification = sprintf("\t--> Verify %s : %s", $name, $work_message);
+
+
+ $this->printConf($output, "\t" . $key_cache, $value_cache, false, $verification);
+ $this->verifyCacheOptions($output, $value_cache);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t" . $key_cache, $value_cache, false, 'Not recognized ');
+ break;
+ }
+ if (!isset($cache_type['service']))
+ {
+ $output->writeln('Miss service for %s ', $cache_type);
+ $this->errors++;
+ }
+ }
+ }
+
+ if (count($required_caches) > 0)
+ {
+ $output->writeln(sprintf('Miss required caches %s ', implode(', ', $required_caches)));
+ $this->errors++;
+ }
+ break;
+ case 'debug':
+ $required = array_diff($required, array($conf));
+ $message = 'OK ';
+
+ if ($value !== false)
+ {
+ $message = 'Should be false ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ case 'dbal':
+ $required = array_diff($required, array($conf));
+ try
+ {
+ $connexion = $this->configuration->getConnexion($value);
+ $this->verifyDatabaseConnexion($connexion);
+ $message = 'OK ';
+ }
+ catch (\Exception $e)
+ {
+ $message = 'Failed ';
+ $this->errors++;
+ }
+ $this->printConf($output, $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+
+ if (count($required) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required)));
+ $this->errors++;
+ }
+
+ return;
+ }
+
+ protected function verifyCacheOptions(OutputInterface $output, $ServiceName)
+ {
+ try
+ {
+ $conf = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $conf
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ $required_options = array();
+
+ switch ($Service->getType())
+ {
+ default:
+ break;
+ case 'memcache':
+ $required_options = array('host', 'port');
+ break;
+ }
+
+ if ($required_options)
+ {
+ foreach ($conf->get('options') as $conf => $value)
+ {
+ switch ($conf)
+ {
+ case 'host';
+ $required_options = array_diff($required_options, array($conf));
+ $message = 'OK ';
+
+ if (!is_scalar($value))
+ {
+ $message = 'Should be scalar ';
+ $this->errors++;
+ }
+
+ $this->printConf($output, "\t\t" . $conf, $value, false, $message);
+ break;
+ case 'port';
+ $required_options = array_diff($required_options, array($conf));
+ $message = 'OK ';
+
+ if (!ctype_digit($value))
+ {
+ $message = 'Not recognized ';
+ $this->alerts++;
+ }
+
+ $this->printConf($output, "\t\t" . $conf, $value, false, $message);
+ break;
+ default:
+ $this->alerts++;
+ $this->printConf($output, "\t\t" . $conf, $value, false, 'Not recognized ');
+ break;
+ }
+ }
+ }
+
+ if (count($required_options) > 0)
+ {
+ $output->writeln(sprintf('Miss required keys %s ', implode(', ', $required_options)));
+ $this->errors++;
+ }
+ }
+
+ protected function probeCacheService(OutputInterface $output, $ServiceName)
+ {
+ try
+ {
+ $originalConfiguration = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $originalConfiguration
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ if ($Service->getDriver()->isServer())
+ {
+ switch ($Service->getType())
+ {
+ default:
+ return false;
+ break;
+ case 'memcache':
+ if (!@memcache_connect($Service->getHost(), $Service->getPort()))
+ {
+ return false;
+ }
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ protected function recommendedCacheService(OutputInterface $output, $ServiceName, $server)
+ {
+ try
+ {
+ $originalConfiguration = $this->configuration->getService($ServiceName);
+
+ $Service = Core\Service\Builder::create(
+ \bootstrap::getCore(), $originalConfiguration
+ );
+ }
+ catch (\Exception $e)
+ {
+ return false;
+ }
+
+ if ($Service->getType() === 'array')
+ {
+ return false;
+ }
+
+ return $server === $Service->getDriver()->isServer();
+ }
+
+ private function printConf($output, $scope, $value, $scopage = false, $message = '')
+ {
+ if (is_array($value))
+ {
+ foreach ($value as $key => $val)
+ {
+ if ($scopage)
+ $key = $scope . ":" . $key;
+ $this->printConf($output, $key, $val, $scopage, '');
+ }
+ }
+ elseif (is_bool($value))
+ {
+ if ($value === false)
+ {
+ $value = 'false';
+ }
+ elseif ($value === true)
+ {
+ $value = 'true';
+ }
+ $output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
+ }
+ elseif (!empty($value))
+ {
+ $output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
+ }
+ }
+
+}
diff --git a/lib/classes/module/console/schedulerStart.class.php b/lib/classes/module/console/schedulerStart.class.php
index 8dd81c9ca4..39616efa37 100644
--- a/lib/classes/module/console/schedulerStart.class.php
+++ b/lib/classes/module/console/schedulerStart.class.php
@@ -1,4 +1,5 @@
writeln('Phraseanet is not set up');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
$scheduler = new task_Scheduler();
$scheduler->run($zinput, $output); //, !$input->getOption('nolog'), !$input->getOption('notasklog'));
- return;
+ try
+ {
+ $scheduler = new task_Scheduler();
+ $scheduler->run($output, true);
+ }
+ catch (\Exception $e)
+ {
+ return 1;
+ }
}
}
diff --git a/lib/classes/module/console/schedulerState.class.php b/lib/classes/module/console/schedulerState.class.php
index 4861e02224..c0508144fd 100644
--- a/lib/classes/module/console/schedulerState.class.php
+++ b/lib/classes/module/console/schedulerState.class.php
@@ -24,6 +24,7 @@ use Symfony\Component\Console\Command\Command;
class module_console_schedulerState extends Command
{
+
public function __construct($name = null)
{
parent::__construct($name);
@@ -35,26 +36,39 @@ class module_console_schedulerState extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- if(!setup::is_installed())
+ if (!setup::is_installed())
{
- throw new RuntimeException('Phraseanet is not set up');
+ $output->writeln('Phraseanet is not set up');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
- $appbox = appbox::get_instance();
- $task_manager = new task_manager($appbox);
+ try
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $task_manager = new task_manager($appbox);
+ $state = $task_manager->get_scheduler_state();
+ if ($state['schedstatus'] == 'started')
+ {
+ $output->writeln(sprintf(
+ 'Scheduler is %s on pid %d'
+ , $state['schedstatus']
+ , $state['schedpid']
+ ));
+ }
+ else
+ {
+ $output->writeln(sprintf('Scheduler is %s', $state['schedstatus']));
+ }
- $state = $task_manager->get_scheduler_state();
-
- if ($state['schedstatus'] == 'started')
- $output->writeln(sprintf(
- 'Scheduler is %s on pid %d'
- , $state['schedstatus']
- , $state['schedpid']
- ));
- else
- $output->writeln(sprintf('Scheduler is %s', $state['schedstatus']));
+ return 0;
+ }
+ catch(\Exception $e)
+ {
+ return 1;
+ }
return;
}
diff --git a/lib/classes/module/console/schedulerStop.class.php b/lib/classes/module/console/schedulerStop.class.php
index b806770dd1..8e9c9408c7 100644
--- a/lib/classes/module/console/schedulerStop.class.php
+++ b/lib/classes/module/console/schedulerStop.class.php
@@ -33,19 +33,30 @@ class module_console_schedulerStop extends Command
return $this;
}
+
public function execute(InputInterface $input, OutputInterface $output)
{
- if(!setup::is_installed())
+ if (!setup::is_installed())
{
- throw new RuntimeException('Phraseanet is not set up');
+ $output->writeln('Phraseanet is not set up');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
- $appbox = appbox::get_instance();
- $task_manager = new task_manager($appbox);
+ try
+ {
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $task_manager = new task_manager($appbox);
+ $task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP);
- $task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP);
+ return 0;
+ }
+ catch (\Exception $e)
+ {
+ return 1;
+ }
return;
}
diff --git a/lib/classes/module/console/sphinxGenerateSuggestion.class.php b/lib/classes/module/console/sphinxGenerateSuggestion.class.php
new file mode 100644
index 0000000000..40133e3559
--- /dev/null
+++ b/lib/classes/module/console/sphinxGenerateSuggestion.class.php
@@ -0,0 +1,162 @@
+setDescription('Generate suggestions for Sphinx Search Engine');
+
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+ define('FREQ_THRESHOLD', 10);
+ define('SUGGEST_DEBUG', 0);
+
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $registry = $appbox->get_registry();
+
+ $params = phrasea::sbas_params();
+
+ foreach ($params as $sbas_id => $p)
+ {
+ $index = crc32(
+ str_replace(
+ array('.', '%')
+ , '_'
+ , sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname'])
+ )
+ );
+
+ $tmp_file = $registry->get('GV_RootPath') . 'tmp/dict' . $index . '.txt';
+
+ $databox = databox::get_instance($sbas_id);
+
+ $output->writeln("process Databox " . $databox->get_viewname() . " / $index\n");
+
+ if(!is_executable("/usr/local/bin/indexer"))
+ {
+ $output->writeln("'/usr/local/bin/indexer' is not executable ");
+
+ return 1;
+ }
+
+ if(!file_exists($tmp_file))
+ {
+ $output->writeln(" file '".$tmp_file."' does not exist ");
+
+ return 1;
+ }
+
+ $cmd = '/usr/local/bin/indexer metadatas' . $index . ' --buildstops ' . $tmp_file . ' 1000000 --buildfreqs';
+ exec($cmd);
+
+ try
+ {
+ $connbas = connection::getPDOConnection($sbas_id);
+ }
+ catch (Exception $e)
+ {
+ continue;
+ }
+
+ $sql = 'TRUNCATE suggest';
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $sql = $this->BuildDictionarySQL($output, file_get_contents($tmp_file));
+
+ if (trim($sql) !== '')
+ {
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ }
+
+ unlink($tmp_file);
+ }
+
+ return 0;
+ }
+
+ protected function BuildTrigrams($keyword)
+ {
+ $t = "__" . $keyword . "__";
+
+ $trigrams = "";
+ for ($i = 0; $i < strlen($t) - 2; $i++)
+ $trigrams .= substr($t, $i, 3) . " ";
+
+ return $trigrams;
+ }
+
+ protected function BuildDictionarySQL(OutputInterface $output, $in)
+ {
+ $out = '';
+
+ $n = 0;
+ $lines = explode("\n", $in);
+ foreach ($lines as $line)
+ {
+ if (trim($line) === '')
+ continue;
+ list ( $keyword, $freq ) = explode(" ", trim($line));
+
+ if ($freq < FREQ_THRESHOLD || strstr($keyword, "_") !== false || strstr($keyword, "'") !== false)
+ continue;
+
+ if (ctype_digit($keyword))
+ {
+ continue;
+ }
+ if (mb_strlen($keyword) < 3)
+ {
+ continue;
+ }
+
+ $trigrams = $this->BuildTrigrams($keyword);
+
+ if ($n++)
+ $out .= ",\n";
+ $out .= "( $n, '$keyword', '$trigrams', $freq )";
+ }
+
+ if (trim($out) !== '')
+ {
+ $out = "INSERT INTO suggest VALUES " . $out . ";";
+ }
+
+ $output->writeln(sprintf("Generated %d suggestions", $n));
+
+ return $out;
+ }
+
+}
diff --git a/lib/classes/module/console/systemBackupDB.class.php b/lib/classes/module/console/systemBackupDB.class.php
index f477da44c3..5f437c8369 100644
--- a/lib/classes/module/console/systemBackupDB.class.php
+++ b/lib/classes/module/console/systemBackupDB.class.php
@@ -31,7 +31,7 @@ class module_console_systemBackupDB extends Command
$dir = sprintf(
'%s/config/'
- , dirname(dirname(dirname(dirname(dirname(__FILE__)))))
+ , dirname(dirname(dirname(dirname(__DIR__))))
);
$this->setDescription('Backup Phraseanet Databases');
@@ -45,23 +45,27 @@ class module_console_systemBackupDB extends Command
{
if (!setup::is_installed())
{
- throw new RuntimeException('Phraseanet is not set up');
+ $output->writeln('Argument must be an Id.');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
$output->write('Phraseanet is going to be backup...', true);
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
- $this->dump_base($appbox, $input, $output);
+ $ok = true;
+
+ $ok = $this->dump_base($appbox, $input, $output) && $ok;
foreach ($appbox->get_databoxes() as $databox)
{
- $this->dump_base($databox, $input, $output);
+ $ok = $this->dump_base($databox, $input, $output) && $ok;
}
- return;
+ return (int) !$ok;
}
protected function dump_base(base $base, InputInterface $input, OutputInterface $output)
@@ -91,11 +95,19 @@ class module_console_systemBackupDB extends Command
system($command);
if (file_exists($filename) && filesize($filename) > 0)
+ {
$output->writeln('OK');
+
+ return true;
+ }
else
+ {
$output->writeln('Failed ');
- return;
+ return false;
+ }
+
+
}
}
diff --git a/lib/classes/module/console/systemClearCache.class.php b/lib/classes/module/console/systemClearCache.class.php
index 262f20fb83..ebb853dcd0 100644
--- a/lib/classes/module/console/systemClearCache.class.php
+++ b/lib/classes/module/console/systemClearCache.class.php
@@ -44,10 +44,10 @@ class module_console_systemClearCache extends Command
->exclude('.git')
->exclude('.svn')
->in(array(
- dirname(__FILE__) . '/../../../../tmp/cache_minify/'
- , dirname(__FILE__) . '/../../../../tmp/cache_twig/'
- ))
- ;
+ __DIR__ . '/../../../../tmp/cache_minify/'
+ , __DIR__ . '/../../../../tmp/cache_twig/'
+ ));
+
$count = 1;
foreach ($finder as $file)
{
@@ -59,12 +59,12 @@ class module_console_systemClearCache extends Command
$finder
->directories()
->in(array(
- dirname(__FILE__) . '/../../../../tmp/cache_minify'
- , dirname(__FILE__) . '/../../../../tmp/cache_twig'
+ __DIR__ . '/../../../../tmp/cache_minify'
+ , __DIR__ . '/../../../../tmp/cache_twig'
))
->exclude('.git')
- ->exclude('.svn')
- ;
+ ->exclude('.svn');
+
foreach ($finder as $file)
{
$dirs[$file->getPathname()] = $file->getPathname();
@@ -83,17 +83,13 @@ class module_console_systemClearCache extends Command
if(setup::is_installed())
{
- $registry = registry::get_instance();
- $cache = cache_adapter::get_instance($registry);
- if($cache->ping())
- {
- $cache->flush();
- }
+ $Core = \bootstrap::getCore();
+ $Core['CacheService']->flushAll();
}
$output->write('Finished !', true);
- return;
+ return 0;
}
}
diff --git a/lib/classes/module/console/systemConfigCheck.class.php b/lib/classes/module/console/systemConfigCheck.class.php
index ea69682c97..8242dd7e59 100644
--- a/lib/classes/module/console/systemConfigCheck.class.php
+++ b/lib/classes/module/console/systemConfigCheck.class.php
@@ -42,15 +42,17 @@ class module_console_systemConfigCheck extends Command
$output->writeln('YOU MUST ENABLE GETTEXT SUPPORT TO USE PHRASEANET ');
$output->writeln('Canceled');
- return;
+ return 1;
}
+ $ok = true;
+
if (setup::is_installed())
{
$registry = registry::get_instance();
$output->writeln(_('*** CHECK BINARY CONFIGURATION ***'));
- $this->processConstraints(setup::check_binaries($registry), $output);
+ $ok = $this->processConstraints(setup::check_binaries($registry), $output) && $ok;
$output->writeln("");
}
else
@@ -58,51 +60,67 @@ class module_console_systemConfigCheck extends Command
$registry = new Setup_Registry();
}
+
+
$output->writeln(_('*** FILESYSTEM CONFIGURATION ***'));
- $this->processConstraints(setup::check_writability($registry), $output);
+ $ok = $this->processConstraints(setup::check_writability($registry), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK CACHE OPCODE ***'));
- $this->processConstraints(setup::check_cache_opcode(), $output);
+ $ok = $this->processConstraints(setup::check_cache_opcode(), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK CACHE SERVER ***'));
- $this->processConstraints(setup::check_cache_server(), $output);
+ $ok = $this->processConstraints(setup::check_cache_server(), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK PHP CONFIGURATION ***'));
- $this->processConstraints(setup::check_php_configuration(), $output);
+ $ok = $this->processConstraints(setup::check_php_configuration(), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK PHP EXTENSIONS ***'));
- $this->processConstraints(setup::check_php_extension(), $output);
+ $ok = $this->processConstraints(setup::check_php_extension(), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK PHRASEA ***'));
- $this->processConstraints(setup::check_phrasea(), $output);
+ $ok = $this->processConstraints(setup::check_phrasea(), $output) && $ok;
$output->writeln("");
$output->writeln(_('*** CHECK SYSTEM LOCALES ***'));
- $this->processConstraints(setup::check_system_locales(), $output);
+ $ok = $this->processConstraints(setup::check_system_locales(), $output) && $ok;
$output->writeln("");
$output->write('Finished !', true);
- return;
+ return (int)!$ok;
}
protected function processConstraints(Setup_ConstraintsIterator $constraints, OutputInterface &$output)
{
+ $hasError = false;
foreach ($constraints as $constraint)
{
- $this->processConstraint($constraint, $output);
+ if (!$hasError && !$this->processConstraint($constraint, $output))
+ {
+ $hasError = true;
+ }
}
+
+ return !$hasError;
}
protected function processConstraint(Setup_Constraint $constraint, OutputInterface &$output)
{
+ $ok = true;
if ($constraint->is_ok())
+ {
$output->writeln("\t\t" . $constraint->get_message() . ' ');
+ }
elseif ($constraint->is_blocker())
+ {
$output->writeln("\t!!!\t" . $constraint->get_message() . ' ');
+ $ok = false;
+ }
else
+ {
$output->writeln("\t/!\\\t" . $constraint->get_message() . ' ');
+ }
- return;
+ return $ok;
}
}
diff --git a/lib/classes/module/console/systemExport.class.php b/lib/classes/module/console/systemExport.class.php
new file mode 100644
index 0000000000..55c611388f
--- /dev/null
+++ b/lib/classes/module/console/systemExport.class.php
@@ -0,0 +1,311 @@
+setDescription('Export all phraseanet records to a directory');
+
+ /**
+ * To implement
+ */
+// $this->addOption('useoriginalname', 'o', InputOption::VALUE_OPTIONAL
+// , 'Use original name for dest files', false);
+
+ /**
+ * To implement
+ */
+// $this->addOption('excludefield', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
+// , 'Exclude field from XML', array());
+
+ /**
+ * To implement
+ */
+// $this->addOption('excludestatus', '', InputOption::VALUE_OPTIONAL
+// , 'Exclude Status', false);
+
+ $this->addOption('docperdir', 'd', InputOption::VALUE_OPTIONAL
+ , 'Maximum number of files per dir', 100);
+
+ $this->addOption('caption', 'c', InputOption::VALUE_OPTIONAL
+ , 'Export Caption (XML)', false);
+
+ $this->addOption('limit', 'l', InputOption::VALUE_OPTIONAL
+ , 'Limit files quantity (for test purposes)', false);
+
+ $this->addOption('base_id', 'b', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
+ , 'Restrict on base_ids', array());
+
+ $this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
+ , 'Restrict on sbas_ids', array());
+
+ $this->addArgument('directory', InputOption::VALUE_REQUIRED
+ , 'The directory where to export');
+
+ $this->addOption('sanitize', '', InputOption::VALUE_REQUIRED
+ , 'Sanitize filenames. Set to 0 to disable', true);
+
+ return $this;
+ }
+
+ public function execute(InputInterface $input, OutputInterface $output)
+ {
+ $docPerDir = max(1, (int) $input->getOption('docperdir'));
+
+ /**
+ *
+ * To implement
+ *
+ $useOriginalName = !!$input->getOption('useoriginalname');
+ $excludeFields = $input->getOption('excludefield');
+ $exportStatus = !$input->getOption('excludestatus');
+ *
+ */
+
+ $Caption = $input->getOption('caption');
+
+ $limit = ctype_digit($input->getOption('limit')) ? max(0, (int) $input->getOption('limit')) : false;
+
+ $restrictBaseIds = $input->getOption('base_id');
+
+ $restrictSbasIds = $input->getOption('sbas_id');
+
+ $sanitize = $input->getOption('sanitize');
+
+
+ $export_directory = $input->getArgument('directory');
+
+ if (!$export_directory)
+ {
+ throw new Exception('Missing directory argument');
+ }
+
+ $export_directory = realpath(substr($export_directory, 0, 1) === '/' ? $export_directory : getcwd() . '/' . $export_directory . '/');
+
+ if (!$export_directory)
+ {
+ throw new Exception('Export directory does not exists or is not accessible');
+ }
+
+ if (!is_writable($export_directory))
+ {
+ throw new Exception('Export directory is not writable');
+ }
+
+ /**
+ * Sanitize
+ */
+ foreach ($restrictBaseIds as $key => $base_id)
+ {
+ $restrictBaseIds[$key] = (int) $base_id;
+ }
+ foreach ($restrictSbasIds as $key => $sbas_id)
+ {
+ $restrictSbasIds[$key] = (int) $sbas_id;
+ }
+
+
+ if (count($restrictSbasIds) > 0)
+ {
+ $output->writeln("Export datas from selected sbas_ids");
+ }
+ elseif (count($restrictBaseIds) > 0)
+ {
+ $output->writeln("Export datas from selected base_ids");
+ }
+
+ $appbox = \appbox::get_instance();
+
+ $total = $errors = 0;
+
+ $unicode = new \unicode();
+
+ foreach ($appbox->get_databoxes() as $databox)
+ {
+ $output->writeln(sprintf("Processing %s ", $databox->get_viewname()));
+
+ if (count($restrictSbasIds) > 0 && !in_array($databox->get_sbas_id(), $restrictSbasIds))
+ {
+ $output->writeln(sprintf("Databox not selected, bypassing ..."));
+ continue;
+ }
+
+ $go = true;
+ $coll_ids = array();
+
+ if (count($restrictBaseIds) > 0)
+ {
+ $go = false;
+ foreach ($databox->get_collections() as $collection)
+ {
+ if (in_array($collection->get_base_id(), $restrictBaseIds))
+ {
+
+ $go = true;
+ $coll_ids[] = $collection->get_coll_id();
+ }
+ }
+ }
+
+ if (!$go)
+ {
+ $output->writeln(sprintf("Collections not selected, bypassing ..."));
+ continue;
+ }
+
+ $local_export = $export_directory
+ . '/' . $unicode->remove_nonazAZ09($databox->get_viewname(), true, true)
+ . '/';
+
+ system_file::mkdir($local_export);
+
+ $sql = 'SELECT record_id FROM record WHERE parent_record_id = 0 ';
+
+ if (count($coll_ids) > 0)
+ {
+ $sql .= ' AND coll_id IN (' . implode(', ', $coll_ids) . ') ';
+ }
+
+ $sql .= ' ORDER BY record_id ASC ';
+
+ if ($limit)
+ {
+ $sql .= ' LIMIT 0, ' . $limit;
+ }
+
+ $stmt = $databox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+
+ $done = 0;
+ $current_total = count($rs);
+ $total += $current_total;
+ $l = strlen((string) $current_total) + 1;
+
+ $dir_format = 'datas%' . strlen((string) ceil($current_total / $docPerDir)) . 'd';
+
+ $dir_increment = 0;
+ foreach ($rs as $row)
+ {
+ $record = $databox->get_record($row['record_id']);
+ if (($done % $docPerDir) === 0)
+ {
+ $dir_increment++;
+ $in_dir_files = array();
+ $current_dir = $local_export . sprintf($dir_format, $dir_increment) . '/';
+ system_file::mkdir($current_dir);
+ }
+
+ if ($sanitize)
+ {
+ $filename = $unicode->remove_nonazAZ09($record->get_original_name(), true, true, true);
+ }
+ else
+ {
+ $filename = $record->get_original_name();
+ }
+
+ $this->generateDefinitiveFilename($in_dir_files, $filename);
+
+ $output_file = $current_dir . $filename;
+
+ if (!$this->processRecords($record, $output_file, $Caption))
+ {
+ $errors++;
+ }
+
+ $done++;
+
+ $output->write(sprintf("\r#%" . $l . "d record remaining", $current_total - $done));
+ }
+ $output->writeln(" | " . $current_total . " records done\n");
+ }
+
+ $output->writeln("$total records done, $errors errors occured");
+
+ return 0;
+ }
+
+ protected function generateDefinitiveFilename(array &$existing, &$filename)
+ {
+ $definitive_filename = $filename;
+ $suffix = 2;
+ while (array_key_exists($definitive_filename, $existing))
+ {
+ $pathinfo = pathinfo($filename);
+
+ $definitive_filename = $pathinfo['filename'] . '_' . $suffix .
+ (isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : '');
+ $suffix++;
+ }
+
+ $existing[$filename] = $filename;
+ $filename = $definitive_filename;
+
+ return;
+ }
+
+ protected function processRecords(\record_adapter $record, $outfile, $caption)
+ {
+
+ try
+ {
+ $file = new system_file($record->get_subdef('document')->get_pathfile());
+ }
+ catch (\Exception_Media_SubdefNotFound $e)
+ {
+ return false;
+ }
+
+ copy($file->getPathname(), $outfile);
+
+ $dest_file = new system_file($outfile);
+
+ touch(
+ $dest_file->getPathname()
+ , $record->get_creation_date()->format('U')
+ , $record->get_modification_date()->format('U')
+ );
+
+ switch (strtolower($caption))
+ {
+ case 'xml':
+ $pathinfo = pathinfo($dest_file->getPathname());
+ $xml_file = dirname($outfile) . '/' . $pathinfo['filename'] . '.xml';
+ file_put_contents($xml_file, $record->get_xml());
+ break;
+ default:
+ break;
+ }
+
+ return true;
+ }
+
+}
diff --git a/lib/classes/module/console/systemMailCheck.class.php b/lib/classes/module/console/systemMailCheck.class.php
index 60449227d4..80fbc28dff 100644
--- a/lib/classes/module/console/systemMailCheck.class.php
+++ b/lib/classes/module/console/systemMailCheck.class.php
@@ -43,7 +43,7 @@ class module_console_systemMailCheck extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$output->writeln("Processing...");
@@ -65,7 +65,7 @@ class module_console_systemMailCheck extends Command
$output->write('Finished !', true);
- return;
+ return 0;
}
protected function manage_group($email, $users, $output, $appbox)
diff --git a/lib/classes/module/console/systemTemplateGenerator.class.php b/lib/classes/module/console/systemTemplateGenerator.class.php
index 5ca41ac1ba..fcd5442011 100644
--- a/lib/classes/module/console/systemTemplateGenerator.class.php
+++ b/lib/classes/module/console/systemTemplateGenerator.class.php
@@ -36,16 +36,16 @@ class module_console_systemTemplateGenerator extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php';
- require_once dirname(__FILE__) . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
+ require_once __DIR__ . '/../../../../lib/vendor/Twig/lib/Twig/Autoloader.php';
+ require_once __DIR__ . '/../../../../lib/vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
Twig_Autoloader::register();
Twig_Extensions_Autoloader::register();
- $tplDir = dirname(__FILE__) . '/../../../../templates/';
- $tmpDir = dirname(__FILE__) . '/../../../../tmp/cache_twig/';
+ $tplDir = __DIR__ . '/../../../../templates/';
+ $tmpDir = __DIR__ . '/../../../../tmp/cache_twig/';
$loader = new Twig_Loader_Filesystem($tplDir);
$twig = new Twig_Environment($loader, array(
@@ -54,7 +54,9 @@ class module_console_systemTemplateGenerator extends Command
));
$twig->addExtension(new Twig_Extensions_Extension_I18n());
-
+ /**
+ * @todo clean all duplicate filters
+ */
$twig->addFilter('serialize', new Twig_Filter_Function('serialize'));
$twig->addFilter('sbas_names', new Twig_Filter_Function('phrasea::sbas_names'));
$twig->addFilter('sbas_name', new Twig_Filter_Function('phrasea::sbas_names'));
@@ -78,9 +80,11 @@ class module_console_systemTemplateGenerator extends Command
$twig->addFilter('key_exists', new Twig_Filter_Function('array_key_exists'));
$twig->addFilter('array_keys', new Twig_Filter_Function('array_keys'));
$twig->addFilter('round', new Twig_Filter_Function('round'));
+ $twig->addFilter('get_class', new Twig_Filter_Function('get_class'));
$twig->addFilter('formatdate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('getPrettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('prettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
+ $twig->addFilter('prettyString', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('formatoctet', new Twig_Filter_Function('p4string::format_octet'));
$twig->addFilter('getDate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('geoname_name_from_id', new Twig_Filter_Function('geonames::name_from_id'));
@@ -118,7 +122,7 @@ class module_console_systemTemplateGenerator extends Command
$output->writeln("");
- return;
+ return $n_error;
}
}
diff --git a/lib/classes/module/console/systemUpgrade.class.php b/lib/classes/module/console/systemUpgrade.class.php
index 553ddd32ea..9c8b24fa95 100644
--- a/lib/classes/module/console/systemUpgrade.class.php
+++ b/lib/classes/module/console/systemUpgrade.class.php
@@ -1,4 +1,5 @@
writeln('This version of Phraseanet requires a config/config.yml, config/connexion.yml, config/service.yml');
+ $output->writeln('Would you like it to be created based on your settings ?');
+
+ $dialog = $this->getHelperSet()->get('dialog');
+ do
{
-
- $output->writeln('This version of Phraseanet requires a config/config.inc');
- $output->writeln('Would you like it to be created based on your settings ?');
-
- $dialog = $this->getHelperSet()->get('dialog');
- do
- {
- $continue = mb_strtolower($dialog->ask($output, '' . _('Create automatically') . ' (Y/n) ', 'y'));
- }
- while (!in_array($continue, array('y', 'n')));
-
- if ($continue == 'y')
- {
- require __DIR__ . "/../../../../config/_GV.php";
-
- $datas = 'ask($output, '' . _('Create automatically') . ' (Y/n) ', 'y'));
}
+ while (!in_array($continue, array('y', 'n')));
+ if ($continue == 'y')
+ {
+ try
+ {
+ $connexionInc = new \SplFileObject(__DIR__ . '/../../../../config/connexion.inc');
+ $configInc = new \SplFileObject(__DIR__ . '/../../../../config/config.inc');
+
+ $Core->getConfiguration()->upgradeFromOldConf($configInc, $connexionInc);
+ }
+ catch (\Exception $e)
+ {
+
+ }
+ }
+ else
+ {
+ throw new RuntimeException('Phraseanet is not set up');
+ }
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
$output->write('Phraseanet is going to be upgraded', true);
$dialog = $this->getHelperSet()->get('dialog');
@@ -92,8 +87,9 @@ class module_console_systemUpgrade extends Command
{
try
{
+ $Core = \bootstrap::getCore();
$output->write('Upgrading... ', true);
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance($Core);
if (count(User_Adapter::get_wrong_email_users($appbox)) > 0)
{
@@ -101,10 +97,11 @@ class module_console_systemUpgrade extends Command
}
$upgrader = new Setup_Upgrade($appbox);
- $advices = $appbox->forceUpgrade($upgrader);
+ $advices = $appbox->forceUpgrade($upgrader);
}
- catch (Exception $e)
+ catch (\Exception $e)
{
+
$output->writeln(sprintf('An error occured while upgrading : %s ', $e->getMessage()));
}
}
diff --git a/lib/classes/module/console/tasklist.class.php b/lib/classes/module/console/tasklist.class.php
index 58fd108ed0..4ec9646b9a 100644
--- a/lib/classes/module/console/tasklist.class.php
+++ b/lib/classes/module/console/tasklist.class.php
@@ -37,34 +37,45 @@ class module_console_tasklist extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- if(!setup::is_installed())
+ if (!setup::is_installed())
{
- throw new RuntimeException('Phraseanet is not set up');
+ $output->writeln('Phraseanet is not set up');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
- $appbox = appbox::get_instance();
- $task_manager = new task_manager($appbox);
- $tasks = $task_manager->get_tasks();
-
- if(count($tasks) === 0)
- $output->writeln ('No tasks on your install !');
-
- foreach($tasks as $task)
+ try
{
- $this->print_task($task, $output);
- }
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $task_manager = new task_manager($appbox);
+ $tasks = $task_manager->get_tasks();
- return $this;
+ if (count($tasks) === 0)
+ {
+ $output->writeln('No tasks on your install !');
+ }
+
+ foreach ($tasks as $task)
+ {
+ $this->print_task($task, $output);
+ }
+
+ return 0;
+ }
+ catch (\Exception $e)
+ {
+ return 1;
+ }
}
-
protected function print_task(task_abstract $task, OutputInterface &$output)
{
- $message = $task->get_task_id()."\t".($task->get_status() )."\t".$task->get_title();
+ $message = $task->get_task_id() . "\t" . ($task->get_status() ) . "\t" . $task->get_title();
$output->writeln($message);
return $this;
}
+
}
diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php
index 31714db34a..346127624d 100644
--- a/lib/classes/module/console/taskrun.class.php
+++ b/lib/classes/module/console/taskrun.class.php
@@ -67,12 +67,14 @@ class module_console_taskrun extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
- if(!setup::is_installed())
+ if (!setup::is_installed())
{
- throw new RuntimeException('Phraseanet is not set up');
+ $output->writeln('Phraseanet is not set up');
+
+ return 1;
}
- require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
+ require_once __DIR__ . '/../../../../lib/bootstrap.php';
$task_id = (int) $input->getArgument('task_id');
@@ -104,8 +106,10 @@ class module_console_taskrun extends Command
$this->task->log(sprintf("%s [%d] taskrun : returned from 'run()', get_status()=%s \n", __FILE__, __LINE__, $this->task->get_status()));
- return $this;
- }
+ if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL)
+ {
+ $runner = task_abstract::RUNNER_MANUAL;
+ }
public function tick_handler()
{
@@ -131,4 +135,4 @@ $this->task->log(sprintf("%s [%d] taskrun : returned from 'run()', get_status()=
}
}
-
\ No newline at end of file
+
diff --git a/lib/classes/module/prod.class.php b/lib/classes/module/prod.class.php
deleted file mode 100644
index 6d010026b2..0000000000
--- a/lib/classes/module/prod.class.php
+++ /dev/null
@@ -1,172 +0,0 @@
- array(),
- 'dates' => array(),
- 'fields' => array()
- );
-
- $bases = $fields = $dates = array();
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
- $searchSet = $user->getPrefs('search');
-
- foreach ($user->ACL()->get_granted_sbas() as $databox)
- {
- $sbas_id = $databox->get_sbas_id();
-
- $bases[$sbas_id] = array(
- 'thesaurus' => (trim($databox->get_thesaurus()) != ""),
- 'cterms' => false,
- 'collections' => array(),
- 'sbas_id' => $sbas_id
- );
-
- foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll)
- {
- $selected = ($searchSet &&
- isset($searchSet->bases) &&
- isset($searchSet->bases->$sbas_id)) ? (in_array($coll->get_base_id(), $searchSet->bases->$sbas_id)) : true;
- $bases[$sbas_id]['collections'][] =
- array(
- 'selected' => $selected,
- 'base_id' => $coll->get_base_id()
- );
- }
-
- $meta_struct = $databox->get_meta_structure();
- foreach ($meta_struct as $meta)
- {
- if (!$meta->is_indexable())
- continue;
- $id = $meta->get_id();
- $name = $meta->get_name();
- if ($meta->get_type() == 'date')
- {
- if (isset($dates[$name]))
- $dates[$name]['sbas'][] = $sbas_id;
- else
- $dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name);
- }
-
- if (isset($fields[$name]))
- {
- $fields[$name]['sbas'][] = $sbas_id;
- }
- else
- {
- $fields[$name] = array(
- 'sbas' => array($sbas_id)
- , 'fieldname' => $name
- , 'type' => $meta->get_type()
- , 'id' => $id
- );
- }
- }
-
- if (!$bases[$sbas_id]['thesaurus'])
- continue;
- if (!$user->ACL()->has_right_on_sbas($sbas_id, 'bas_modif_th'))
- continue;
-
- if (simplexml_load_string($databox->get_cterms()))
- {
- $bases[$sbas_id]['cterms'] = true;
- }
- }
-
- $search_datas['fields'] = $fields;
- $search_datas['dates'] = $dates;
- $search_datas['bases'] = $bases;
-
- return $search_datas;
- }
-
- function getLanguage($lng = false)
- {
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
- $lng = $lng ? $lng : Session_Handler::get_locale();
- $registry = $appbox->get_registry();
-
- $out = array();
- $out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.');
- $out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?');
- $out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique');
- $out['serverName'] = $registry->get('GV_ServerName');
- $out['serverTimeout'] = _('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible');
- $out['serverDisconnected'] = _('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier');
- $out['hideMessage'] = _('phraseanet::Ne plus afficher ce message');
- $out['confirmGroup'] = _('Supprimer egalement les documents rattaches a ces regroupements');
- $out['confirmDelete'] = _('reponses:: Ces enregistrements vont etre definitivement supprimes et ne pourront etre recuperes. Etes vous sur ?');
- $out['cancel'] = _('boutton::annuler');
- $out['deleteTitle'] = _('boutton::supprimer');
- $out['edit_hetero'] = _('prod::editing valeurs heterogenes, choisir \'remplacer\', \'ajouter\' ou \'annuler\'');
- $out['confirm_abandon'] = _('prod::editing::annulation: abandonner les modification ?');
- $out['loading'] = _('phraseanet::chargement');
- $out['valider'] = _('boutton::valider');
- $out['annuler'] = _('boutton::annuler');
- $out['rechercher'] = _('boutton::rechercher');
- $out['renewRss'] = _('boutton::renouveller');
- $out['candeletesome'] = _('Vous n\'avez pas les droits pour supprimer certains documents');
- $out['candeletedocuments'] = _('Vous n\'avez pas les droits pour supprimer ces documents');
- $out['needTitle'] = _('Vous devez donner un titre');
- $out['newPreset'] = _('Nouveau modele');
- $out['fermer'] = _('boutton::fermer');
- $out['feed_require_fields'] = _('Vous n\'avez pas rempli tous les champ requis');
- $out['feed_require_feed'] = _('Vous n\'avez pas selectionne de fil de publication');
- $out['removeTitle'] = _('panier::Supression d\'un element d\'un reportage');
- $out['confirmRemoveReg'] = _('panier::Attention, vous etes sur le point de supprimer un element du reportage. Merci de confirmer votre action.');
- $out['advsearch_title'] = _('phraseanet::recherche avancee');
- $out['bask_rename'] = _('panier:: renommer le panier');
- $out['reg_wrong_sbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
- $out['error'] = _('phraseanet:: Erreur');
- $out['warningDenyCgus'] = _('cgus :: Attention, si vous refuser les CGUs de cette base, vous n\'y aures plus acces');
- $out['cgusRelog'] = _('cgus :: Vous devez vous reauthentifier pour que vos parametres soient pris en compte.');
- $out['editDelMulti'] = _('edit:: Supprimer %s du champ dans les records selectionnes');
- $out['editAddMulti'] = _('edit:: Ajouter %s au champ courrant pour les records selectionnes');
- $out['editDelSimple'] = _('edit:: Supprimer %s du champ courrant');
- $out['editAddSimple'] = _('edit:: Ajouter %s au champ courrant');
- $out['cantDeletePublicOne'] = _('panier:: vous ne pouvez pas supprimer un panier public');
- $out['wrongsbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
- $out['max_record_selected'] = _('Vous ne pouvez pas selectionner plus de 400 enregistrements');
- $out['confirmRedirectAuth'] = _('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez');
- $out['error_test_publi'] = _('Erreur : soit les parametres sont incorrects, soit le serveur distant ne repond pas');
- $out['test_publi_ok'] = _('Les parametres sont corrects, le serveur distant est operationnel');
- $out['some_not_published'] = _('Certaines publications n\'ont pu etre effectuees, verifiez vos parametres');
- $out['error_not_published'] = _('Aucune publication effectuee, verifiez vos parametres');
- $out['warning_delete_publi'] = _('Attention, en supprimant ce preregalge, vous ne pourrez plus modifier ou supprimer de publications prealablement effectues avec celui-ci');
- $out['some_required_fields'] = _('edit::certains documents possedent des champs requis non remplis. Merci de les remplir pour valider votre editing');
- $out['nodocselected'] = _('Aucun document selectionne');
-
- return p4string::jsonencode($out);
- }
-
-}
diff --git a/lib/classes/module/report.class.php b/lib/classes/module/report.class.php
index d052c83597..bcf132578b 100644
--- a/lib/classes/module/report.class.php
+++ b/lib/classes/module/report.class.php
@@ -245,7 +245,7 @@ class module_report
*/
public function __construct($d1, $d2, $sbas_id, $collist)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$this->dmin = $d1;
$this->dmax = $d2;
diff --git a/lib/classes/module/report/activity.class.php b/lib/classes/module/report/activity.class.php
index 6411fc531d..ccfb27d58c 100644
--- a/lib/classes/module/report/activity.class.php
+++ b/lib/classes/module/report/activity.class.php
@@ -341,7 +341,7 @@ class module_report_activity extends module_report
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $login = User_Adapter::getInstance($usr, appbox::get_instance())->get_display_name();
+ $login = User_Adapter::getInstance($usr, appbox::get_instance(\bootstrap::getCore()))->get_display_name();
$this->setChamp($rs);
($config) ? $this->setConfigColumn($config) :
@@ -453,7 +453,6 @@ class module_report_activity extends module_report
$this->result[$i]['total'] += 1;
$total['tot_dl'] += 1;
-
}
$nb_row = $i + 1;
@@ -479,7 +478,7 @@ class module_report_activity extends module_report
* @param string $on choose the field on what you want the result
* @return array
*/
- public function getConnexionBase($tab = false, $on= "")
+ public function getConnexionBase($tab = false, $on = "")
{
//default group on user column
if (empty($on))
@@ -577,7 +576,7 @@ class module_report_activity extends module_report
* @param array $tab config for the html table
* @return array
*/
- public function getDetailDownload($tab = false, $on="")
+ public function getDetailDownload($tab = false, $on = "")
{
empty($on) ? $on = "user" : ""; //by default always report on user
@@ -638,19 +637,37 @@ class module_report_activity extends module_report
foreach ($rs as $row)
{
$user = $row[$on];
- if (($save_user != $user) && !is_null($user))
+ if (($save_user != $user) && !is_null($user) && !empty($user))
+ {
+ if ($i >= 0)
+ {
+ if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0 || ($this->result[$i]['poiddoc'] + $this->result[$i]['poidprev']) == 0)
+ {
+ unset($this->result[$i]);
+ }
+
+ if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev']))
+ {
+ $this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
+ $this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
+ }
+ }
+
+
$i++;
+
+ $this->result[$i]['nbprev'] = 0;
+ $this->result[$i]['poidprev'] = 0;
+ $this->result[$i]['nbdoc'] = 0;
+ $this->result[$i]['poiddoc'] = 0;
+ }
+
//doc info
if ($row['final'] == 'document' &&
!is_null($user) && !is_null($row['usrid']))
{
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
- $this->result[$i]['poiddoc'] = (!is_null($row['poid']) ?
- p4string::format_octets($row['poid']) : 0);
- if (!isset($this->result[$i]['nbprev']))
- $this->result[$i]['nbprev'] = 0;
- if (!isset($this->result[$i]['poidprev']))
- $this->result[$i]['poidprev'] = 0;
+ $this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['user'] = empty($row[$on]) ?
"" . _('report:: non-renseigne') . " " : $row[$on];
$total['nbdoc'] += $this->result[$i]['nbdoc'];
@@ -658,26 +675,25 @@ class module_report_activity extends module_report
$this->result[$i]['usrid'] = $row['usrid'];
}
//preview info
- if ($row['final'] == 'preview' &&
+ if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
!is_null($user) &&
!is_null($row['usrid']))
{
- if (!isset($this->result[$i]['nbdoc']))
- $this->result[$i]['nbdoc'] = 0;
- if (!isset($this->result[$i]['poiddoc']))
- $this->result[$i]['poiddoc'] = 0;
- $this->result[$i]['nbprev'] = (!is_null($row['nb']) ? $row['nb'] : 0);
- $this->result[$i]['poidprev'] = (!is_null($row['poid']) ?
- p4string::format_octets($row['poid']) : 0);
+
+ $this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
+ $this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
+
$this->result[$i]['user'] = empty($row[$on]) ?
"" . _('report:: non-renseigne') . " " : $row[$on];
- $total['nbprev'] += $this->result[$i]['nbprev'];
+ $total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['usrid'] = $row['usrid'];
}
+
$save_user = $user;
}
+ unset($this->result[$i]);
$nb_row = $i + 1;
$this->total = $nb_row;
@@ -739,7 +755,7 @@ class module_report_activity extends module_report
$this->setChamp($rs);
$this->initDefaultConfigColumn($this->champ);
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$i = 0;
foreach ($rs as $row)
diff --git a/lib/classes/module/report/add.class.php b/lib/classes/module/report/add.class.php
index 1ddc94fee2..2f8c27828e 100644
--- a/lib/classes/module/report/add.class.php
+++ b/lib/classes/module/report/add.class.php
@@ -77,7 +77,7 @@ class module_report_add extends module_report
$ret = array();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($rs as $row)
{
diff --git a/lib/classes/module/report/dashboard/feed.class.php b/lib/classes/module/report/dashboard/feed.class.php
index 5d244a262f..c2d4a5cd90 100644
--- a/lib/classes/module/report/dashboard/feed.class.php
+++ b/lib/classes/module/report/dashboard/feed.class.php
@@ -66,7 +66,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
*/
public static function getInstance($sbasid, $sbas_coll, $dmin, $dmax)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$cache_id = 'feed_' . md5($sbasid . '_' . $sbas_coll . '_' . $dmin . '_' . $dmax);
try
diff --git a/lib/classes/module/report/edit.class.php b/lib/classes/module/report/edit.class.php
index ef6b61c4f8..7cbf7fe768 100644
--- a/lib/classes/module/report/edit.class.php
+++ b/lib/classes/module/report/edit.class.php
@@ -47,7 +47,7 @@ class module_report_edit extends module_report
public function __construct($arg1, $arg2, $sbas_id, $collist)
{
parent::__construct($arg1, $arg2, $sbas_id, $collist);
- $this->title = _('report:: document ajoute');
+ $this->title = _('report:: edited documents');
}
/**
@@ -76,7 +76,7 @@ class module_report_edit extends module_report
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$ret = array();
foreach ($rs as $row)
diff --git a/lib/classes/module/report/push.class.php b/lib/classes/module/report/push.class.php
index 527104e93d..55a1429c87 100644
--- a/lib/classes/module/report/push.class.php
+++ b/lib/classes/module/report/push.class.php
@@ -47,7 +47,7 @@ class module_report_push extends module_report
public function __construct($arg1, $arg2, $sbas_id, $collist)
{
parent::__construct($arg1, $arg2, $sbas_id, $collist);
- $this->title = _('report:: document ajoute');
+ $this->title = _('report:: pushed documents');
}
/**
diff --git a/lib/classes/module/report/sqldownload.class.php b/lib/classes/module/report/sqldownload.class.php
index bc54ddccf4..ad65a5f641 100644
--- a/lib/classes/module/report/sqldownload.class.php
+++ b/lib/classes/module/report/sqldownload.class.php
@@ -70,7 +70,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
$this->sql .= $this->filter->getOrderFilter() ? : '';
-// var_dump(str_replace(array_keys($this->params), array_values($this->params), $this->sql), $this->sql, $this->params);
$stmt = $this->connbas->prepare($this->sql);
$stmt->execute($this->params);
$this->total_row = $stmt->rowCount();
diff --git a/lib/classes/module/report/validate.class.php b/lib/classes/module/report/validate.class.php
index 59e417bf40..39927d4af7 100644
--- a/lib/classes/module/report/validate.class.php
+++ b/lib/classes/module/report/validate.class.php
@@ -47,7 +47,7 @@ class module_report_validate extends module_report
public function __construct($arg1, $arg2, $sbas_id, $collist)
{
parent::__construct($arg1, $arg2, $sbas_id, $collist);
- $this->title = _('report:: document ajoute');
+ $this->title = _('report:: validated documents');
}
/**
diff --git a/lib/classes/p4file.class.php b/lib/classes/p4file.class.php
index ec485570ed..0f6ba525b7 100644
--- a/lib/classes/p4file.class.php
+++ b/lib/classes/p4file.class.php
@@ -65,7 +65,7 @@ class p4file
public static function archiveFile(system_file &$system_file, $base_id, $delete=true, $name=false)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
diff --git a/lib/classes/patch/320aa.class.php b/lib/classes/patch/320aa.class.php
index a3b28f1fe6..5468abc4d5 100644
--- a/lib/classes/patch/320aa.class.php
+++ b/lib/classes/patch/320aa.class.php
@@ -54,9 +54,9 @@ class patch_320aa implements patchInterface
function apply(base &$appbox)
{
- if(is_file(dirname(__FILE__) . '/../../../config/_GV.php'))
- require dirname(__FILE__) . '/../../../config/_GV.php';
- require dirname(__FILE__) . '/../../../lib/conf.d/_GV_template.inc';
+ if(is_file(__DIR__ . '/../../../config/_GV.php'))
+ require __DIR__ . '/../../../config/_GV.php';
+ require __DIR__ . '/../../../lib/conf.d/_GV_template.inc';
define('GV_STATIC_URL', '');
define('GV_sphinx', false);
diff --git a/lib/classes/patch/320g.class.php b/lib/classes/patch/320h.class.php
similarity index 88%
rename from lib/classes/patch/320g.class.php
rename to lib/classes/patch/320h.class.php
index 9b730317e8..1d4866eabf 100644
--- a/lib/classes/patch/320g.class.php
+++ b/lib/classes/patch/320h.class.php
@@ -15,7 +15,7 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
-class patch_320g implements patchInterface
+class patch_320h implements patchInterface
{
/**
@@ -54,7 +54,7 @@ class patch_320g implements patchInterface
function apply(base &$appbox)
{
- $sql = 'INSERT INTO bridge_site (id, `type`) VALUES (null, "dailymotion")';
+ $sql = 'DELETE FROM basusr WHERE actif = "0"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
diff --git a/lib/classes/patch/360.class.php b/lib/classes/patch/360.class.php
new file mode 100644
index 0000000000..186e1427c5
--- /dev/null
+++ b/lib/classes/patch/360.class.php
@@ -0,0 +1,276 @@
+release;
+ }
+
+ public function require_all_upgrades()
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return Array
+ */
+ function concern()
+ {
+ return $this->concern;
+ }
+
+ function apply(base &$appbox)
+ {
+ $tables = array('StoryWZ', 'ValidationDatas', 'ValidationParticipants', 'ValidationSessions', 'BasketElements', 'Baskets');
+
+ foreach ($tables as $table)
+ {
+ $sql = 'DELETE FROM ' . $table;
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ }
+
+
+ $stories = array();
+
+ $sql = 'SELECT sbas_id, rid as record_id, usr_id
+ FROM ssel
+ WHERE temporaryType = "1"';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $rs_s = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ $current = array();
+
+ foreach ($rs_s as $row_story)
+ {
+ $serial = $row_story['sbas_id'] . '_' . $row_story['usr_id'] . '_' . $row_story['record_id'];
+
+ if (isset($current[$serial]))
+ {
+ $stories[] = $row_story;
+ }
+
+ $current[$serial] = $serial;
+ }
+
+ $sql = 'DELETE FROM ssel
+ WHERE temporaryType="1" AND record_id = :record_id
+ AND usr_id = :usr_id AND sbas_id = :sbas_id';
+ $stmt = $appbox->get_connection()->prepare($sql);
+
+ foreach ($stories as $row)
+ {
+ $params = array(
+ ':usr_id' => $row['usr_id'],
+ ':sbas_id' => $row['sbas_id'],
+ ':record_id' => $row['record_id']
+ );
+ $stmt->execute($params);
+ }
+
+ $stmt->closeCursor();
+
+ $sql = 'INSERT INTO StoryWZ
+ (
+ SELECT null as id, sbas_id, rid as record_id, usr_id, date as created
+ FROM ssel
+ WHERE temporaryType = "1"
+ )';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $sql = 'INSERT INTO Baskets
+ (
+ SELECT ssel_id as id, name, descript as description, usr_id, 1 as is_read
+ , pushFrom as pusher_id,
+ 0 as archived, date as created, updater as updated
+ FROM ssel
+ WHERE temporaryType = "0"
+ )';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+
+ $sql = 'SELECT ssel_id FROM ssel WHERE temporaryType = "0"';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ $sselcont_ids = array();
+
+ foreach ($rs as $row)
+ {
+ $sql = 'SELECT c.sselcont_id, c.record_id, b.sbas_id
+ FROM sselcont c, bas b, ssel s
+ WHERE s.temporaryType = "0" AND b.base_id = c.base_id
+ AND c.ssel_id = :ssel_id AND s.ssel_id = c.ssel_id';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute(array(':ssel_id' => $row['ssel_id']));
+ $rs_be = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+ $current = array();
+
+ foreach ($rs_be as $row_sselcont)
+ {
+ $serial = $row_sselcont['sbas_id'] . '_' . $row_sselcont['record_id'];
+
+ if (isset($current[$serial]))
+ {
+ $sselcont_ids[] = $row_sselcont['sselcont_id'];
+ }
+
+ $current[$serial] = $serial;
+ }
+ }
+
+ $sql = 'DELETE FROM sselcont WHERE sselcont_id = :sselcont_id';
+ $stmt = $appbox->get_connection()->prepare($sql);
+
+ foreach ($sselcont_ids as $sselcont_id)
+ {
+ $stmt->execute(array(':sselcont_id' => $sselcont_id));
+ }
+
+ $stmt->closeCursor();
+
+ $sql = 'INSERT INTO BasketElements
+ (
+ SELECT sselcont_id as id, c.ssel_id as basket_id, record_id, b.sbas_id, c.ord,
+ s.date as created, s.updater as updated
+ FROM sselcont c, ssel s, bas b
+ WHERE temporaryType = "0" AND b.base_id = c.base_id AND s.ssel_id = c.ssel_id
+ )';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $sql = 'UPDATE Baskets SET pusher_id = NULL WHERE pusher_id = 0';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+
+ $sql = 'INSERT INTO ValidationSessions
+ (
+ SELECT null as id, v.ssel_id as basket_id ,created_on as created
+ ,updated_on as updated ,expires_on as expires
+ ,v.usr_id as initiator_id
+ FROM ssel s, validate v
+ WHERE v.ssel_id = s.ssel_id AND v.usr_id = s.usr_id
+ )';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $sql = 'INSERT INTO ValidationParticipants
+ (
+ SELECT v.id as id, v.usr_id
+ , 1 AS is_aware, confirmed as is_confirmed, 1 as can_agree
+ , can_see_others, last_reminder AS reminded
+ , vs.`id` AS ValidationSession_id
+ FROM validate v, ssel s, ValidationSessions vs
+ WHERE s.ssel_id = v.ssel_id AND vs.basket_id = v.ssel_id
+ )';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+
+ $sql = 'SELECT usr_id, basket_id, p.id as participant_id
+ FROM ValidationParticipants p, ValidationSessions s
+ WHERE p.ValidationSession_Id = s.id';
+
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
+
+
+ $sql = 'INSERT INTO ValidationDatas (
+ SELECT d.id , :participant_id as participant_id, d.sselcont_id, d.agreement,
+ d.note, d.updated_on as updated
+ FROM validate v, validate_datas d, sselcont c
+ WHERE c.sselcont_id = d.sselcont_id AND v.id = d.validate_id
+ AND v.usr_id = :usr_id AND v.ssel_id = :basket_id
+ )';
+ $stmt = $appbox->get_connection()->prepare($sql);
+ foreach ($rs as $row)
+ {
+ $params = array(
+ ':participant_id' => $row['participant_id'],
+ ':basket_id' => $row['basket_id'],
+ ':usr_id' => $row['usr_id'],
+ );
+ $stmt->execute($params);
+ }
+
+ $stmt->closeCursor();
+
+ $sql = 'UPDATE ValidationDatas
+ SET agreement = NULL where agreement = "0"';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ $sql = 'UPDATE ValidationDatas
+ SET agreement = "0" where agreement = "-1"';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ return true;
+ }
+
+}
diff --git a/lib/classes/patch/3602.class.php b/lib/classes/patch/3602.class.php
new file mode 100644
index 0000000000..150b5d47b6
--- /dev/null
+++ b/lib/classes/patch/3602.class.php
@@ -0,0 +1,73 @@
+release;
+ }
+
+ public function require_all_upgrades()
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return Array
+ */
+ function concern()
+ {
+ return $this->concern;
+ }
+
+ function apply(base &$databox)
+ {
+ try
+ {
+ $sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
+
+ $stmt = $databox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+ }
+ catch(\PDOException $e)
+ {
+
+ }
+
+ return true;
+ }
+
+}
diff --git a/lib/classes/patch/3603.class.php b/lib/classes/patch/3603.class.php
new file mode 100644
index 0000000000..5565454fa6
--- /dev/null
+++ b/lib/classes/patch/3603.class.php
@@ -0,0 +1,68 @@
+release;
+ }
+
+ public function require_all_upgrades()
+ {
+ return true;
+ }
+
+ /**
+ *
+ * @return Array
+ */
+ function concern()
+ {
+ return $this->concern;
+ }
+
+ function apply(base &$appbox)
+ {
+
+ $sql = 'UPDATE usr SET usr_mail = NULL
+ WHERE usr_mail IS NOT NULL AND usr_login LIKE "(#deleted%"';
+
+ $stmt = $appbox->get_connection()->prepare($sql);
+ $stmt->execute();
+ $stmt->closeCursor();
+
+ return true;
+ }
+
+}
diff --git a/lib/classes/phrasea.class.php b/lib/classes/phrasea.class.php
index 985784b7d2..cfc2856d13 100644
--- a/lib/classes/phrasea.class.php
+++ b/lib/classes/phrasea.class.php
@@ -103,9 +103,19 @@ class phrasea
return $retval;
}
- public static function start()
+ public static function start(\Alchemy\Phrasea\Core $Core)
{
- require (dirname(__FILE__) . '/../../config/connexion.inc');
+ $configuration = $Core->getConfiguration();
+
+ $choosenConnexion = $configuration->getPhraseanet()->get('database');
+
+ $connexion = $configuration->getConnexion($choosenConnexion);
+
+ $hostname = $connexion->get('host');
+ $port = $connexion->get('port');
+ $user = $connexion->get('user');
+ $password = $connexion->get('password');
+ $dbname = $connexion->get('dbname');
if (!extension_loaded('phrasea2'))
printf("Missing Extension php-phrasea");
@@ -117,7 +127,7 @@ class phrasea
function getHome($type='PUBLI', $context='prod')
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
@@ -215,7 +225,7 @@ class phrasea
public static function clear_sbas_params()
{
self::$_sbas_params = null;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$appbox->delete_data_from_cache(self::CACHE_SBAS_PARAMS);
return true;
@@ -227,7 +237,7 @@ class phrasea
return self::$_sbas_params;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
try
{
self::$_sbas_params = $appbox->get_data_from_cache(self::CACHE_SBAS_PARAMS);
@@ -263,18 +273,12 @@ class phrasea
if (!$usr_id)
return false;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$user = User_Adapter::getInstance($usr_id, $appbox);
return count($user->ACL()->get_granted_base()) > 0;
}
- public static function load_events()
- {
- $events = eventsmanager_broker::getInstance(appbox::get_instance());
- $events->start();
- }
-
public static function use_i18n($locale, $textdomain = 'phraseanet')
{
$codeset = "UTF-8";
@@ -283,7 +287,7 @@ class phrasea
putenv('LANGUAGE=' . $locale . '.' . $codeset);
bind_textdomain_codeset($textdomain, 'UTF-8');
- bindtextdomain($textdomain, dirname(__FILE__) . '/../../locale/');
+ bindtextdomain($textdomain, __DIR__ . '/../../locale/');
setlocale(LC_ALL
, $locale . '.UTF-8'
, $locale . '.UTF8'
@@ -321,7 +325,7 @@ class phrasea
{
if (!self::$_bas2sbas)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
try
{
self::$_bas2sbas = $appbox->get_data_from_cache(self::CACHE_SBAS_FROM_BAS);
@@ -371,7 +375,7 @@ class phrasea
public static function reset_baseDatas()
{
self::$_coll2bas = self::$_bas2coll = self::$_bas_names = self::$_bas2sbas = null;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$appbox->delete_data_from_cache(
array(
self::CACHE_BAS_2_COLL
@@ -387,7 +391,7 @@ class phrasea
public static function reset_sbasDatas()
{
self::$_sbas_names = self::$_sbas_params = self::$_bas2sbas = null;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$appbox->delete_data_from_cache(
array(
self::CACHE_SBAS_NAMES
@@ -423,7 +427,7 @@ class phrasea
{
if (!self::$_sbas_names)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
try
{
self::$_sbas_names = $appbox->get_data_from_cache(self::CACHE_SBAS_NAMES);
@@ -452,7 +456,7 @@ class phrasea
{
if (!self::$_bas_names)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
try
{
self::$_bas_names = $appbox->get_data_from_cache(self::CACHE_BAS_NAMES);
@@ -492,12 +496,14 @@ class phrasea
$request = http_request::getInstance();
if ($request->is_ajax())
{
- exit(sprintf('error %d : Content unavailable', (int) $code));
+ $Response = new \Symfony\Component\HttpFoundation\Response(sprintf('error %d : Content unavailable', (int) $code), $code);
+ $Response->send();
+ exit();
}
else
{
$request->set_code($code);
- include(dirname(__FILE__) . '/../../www/include/error.php');
+ include(__DIR__ . '/../../www/include/error.php');
}
die();
break;
diff --git a/lib/classes/queries.class.php b/lib/classes/queries.class.php
index 0b63629061..9dd906eb5b 100644
--- a/lib/classes/queries.class.php
+++ b/lib/classes/queries.class.php
@@ -20,7 +20,7 @@ class queries
public static function tree_topics()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -71,7 +71,7 @@ class queries
public static function topics_exists()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -88,7 +88,7 @@ class queries
public static function dropdown_topics()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -221,7 +221,7 @@ class queries
public static function history()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$conn = $appbox->get_connection();
diff --git a/lib/classes/random.class.php b/lib/classes/random.class.php
index 24a615b66f..5a73b0fb31 100644
--- a/lib/classes/random.class.php
+++ b/lib/classes/random.class.php
@@ -11,18 +11,28 @@
class random
{
+
/**
*
*/
- const NUMBERS = "0123456789";
+
+ const NUMBERS = "0123456789";
/**
*
*/
- const LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ const LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
*
*/
const LETTERS_AND_NUMBERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ const TYPE_FEED_ENTRY = 'FEED_ENTRY';
+ const TYPE_PASSWORD = 'password';
+ const TYPE_DOWNLOAD = 'download';
+ const TYPE_MAIL_DOWNLOAD = 'mail-download';
+ const TYPE_EMAIL = 'email';
+ const TYPE_VIEW = 'view';
+ const TYPE_VALIDATE = 'validate';
+ const TYPE_RSS = 'rss';
/**
*
@@ -34,15 +44,15 @@ class random
{
$conn = connection::getPDOConnection();
- $date = new DateTime();
- $date = phraseadate::format_mysql($date);
+ $date = new DateTime();
+ $date = phraseadate::format_mysql($date);
$registry = registry::get_instance();
- $sql = 'SELECT * FROM tokens WHERE expire_on < :date
+ $sql = 'SELECT * FROM tokens WHERE expire_on < :date
AND datas IS NOT NULL AND (type="download" OR type="email")';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date));
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
@@ -57,7 +67,7 @@ class random
}
}
- $sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")';
+ $sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date));
$stmt->closeCursor();
@@ -85,8 +95,8 @@ class random
$password = "";
if (!in_array($possible, array(self::LETTERS_AND_NUMBERS, self::LETTERS, self::NUMBERS)))
- $possible = self::LETTERS_AND_NUMBERS;
- $i = 0;
+ $possible = self::LETTERS_AND_NUMBERS;
+ $i = 0;
$possible_length = strlen($possible);
while ($i < $length)
{
@@ -106,18 +116,32 @@ class random
* @param mixed content $datas
* @return boolean
*/
- public static function getUrlToken($type, $usr, DateTime $end_date = null, $datas='')
+ public static function getUrlToken($type, $usr, DateTime $end_date = null, $datas = '')
{
self::cleanTokens();
- $conn = connection::getPDOConnection();
- $token = $test = false;
+ $conn = connection::getPDOConnection();
+ $token = $test = false;
- if (!in_array($type, array('password', 'download', 'mail-download', 'email', 'view', 'validate', 'rss')))
- throw new Exception_InvalidArgument();
+ switch ($type)
+ {
+ case self::TYPE_DOWNLOAD:
+ case self::TYPE_PASSWORD:
+ case self::TYPE_MAIL_DOWNLOAD:
+ case self::TYPE_EMAIL:
+ case self::TYPE_VALIDATE:
+ case self::TYPE_VIEW:
+ case self::TYPE_RSS:
+ case self::TYPE_FEED_ENTRY:
+
+ break;
+ default:
+ throw new Exception_InvalidArgument();
+ break;
+ }
$n = 1;
- $sql = 'SELECT id FROM tokens WHERE value = :test ';
+ $sql = 'SELECT id FROM tokens WHERE value = :test ';
$stmt = $conn->prepare($sql);
while ($n < 100)
{
@@ -134,16 +158,16 @@ class random
if ($token)
{
- $sql = 'INSERT INTO tokens (id, value, type, usr_id, created_on, expire_on, datas)
+ $sql = 'INSERT INTO tokens (id, value, type, usr_id, created_on, expire_on, datas)
VALUES (null, :token, :type, :usr, NOW(), :end_date, :datas)';
$stmt = $conn->prepare($sql);
$params = array(
- ':token' => $token
- , ':type' => $type
- , ':usr' => ($usr ? $usr : '-1')
- , ':end_date' => ($end_date instanceof DateTime ? phraseadate::format_mysql($end_date) : null)
- , ':datas' => ((trim($datas) != '') ? $datas : null)
+ ':token' => $token
+ , ':type' => $type
+ , ':usr' => ($usr ? $usr : '-1')
+ , ':end_date' => ($end_date instanceof DateTime ? phraseadate::format_mysql($end_date) : null)
+ , ':datas' => ((trim($datas) != '') ? $datas : null)
);
$stmt->execute($params);
$stmt->closeCursor();
@@ -159,7 +183,7 @@ class random
try
{
$conn = connection::getPDOConnection();
- $sql = 'DELETE FROM tokens WHERE value = :token';
+ $sql = 'DELETE FROM tokens WHERE value = :token';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':token' => $token));
$stmt->closeCursor();
@@ -202,12 +226,12 @@ class random
self::cleanTokens();
$conn = connection::getPDOConnection();
- $sql = 'SELECT * FROM tokens
+ $sql = 'SELECT * FROM tokens
WHERE value = :token
AND (expire_on > NOW() OR expire_on IS NULL)';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':token' => $token));
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php
index 5583384643..69678b155b 100644
--- a/lib/classes/record/Interface.class.php
+++ b/lib/classes/record/Interface.class.php
@@ -95,8 +95,6 @@ interface record_Interface
public function set_binary_status($status);
- public function get_reg_name();
-
public function get_hd_file();
public function delete();
diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php
index 8eba74d921..bd8d3323d1 100644
--- a/lib/classes/record/adapter.class.php
+++ b/lib/classes/record/adapter.class.php
@@ -369,7 +369,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{
$dstatus = databox_status::getDisplayStatus();
$sbas_id = $this->get_sbas_id();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
@@ -476,23 +476,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function move_to_collection(collection &$collection, appbox &$appbox)
{
- $sql = 'UPDATE sselcont
- SET base_id = :base_id
- WHERE record_id = :record_id
- AND base_id IN (SELECT base_id FROM bas WHERE sbas_id = :sbas_id)';
-
- $params = array(
- ':base_id' => $collection->get_base_id(),
- ':record_id' => $this->get_record_id(),
- ':sbas_id' => $this->get_sbas_id()
- );
-
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute($params);
- $stmt->closeCursor();
-
- basket_adapter::revoke_baskets_record($this, $appbox);
-
$sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
$params = array(
@@ -524,6 +507,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{
return null;
}
+
try
{
return $this->get_subdef('thumbnailGIF');
@@ -613,15 +597,21 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_subdef($name)
{
$name = strtolower($name);
+
if (!in_array($name, $this->get_available_subdefs()))
+ {
throw new Exception_Media_SubdefNotFound ();
+ }
if (isset($this->subdefs[$name]))
-
+ {
return $this->subdefs[$name];
+ }
if (!$this->subdefs)
+ {
$this->subdefs = array();
+ }
$substitute = ($name !== 'document');
@@ -757,11 +747,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ($data)
{
if (isset($this->technical_datas[$data]))
-
+ {
return $this->technical_datas[$data];
+ }
else
-
+ {
return false;
+ }
}
return $this->technical_datas;
@@ -801,16 +793,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($caption->get_fields() as $field)
{
- if ($field->is_multi())
- $values = $field->get_value();
- else
- $values = array($field->get_value());
+ $values = $field->get_values();
foreach ($values as $value)
{
$elem = $dom_doc->createElement($field->get_name());
- $elem->appendChild($dom_doc->createTextNode($value));
- $elem->setAttribute('meta_id', $field->get_meta_id());
+ $elem->appendChild($dom_doc->createTextNode($value->getValue()));
+ $elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem);
}
@@ -846,21 +835,39 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{
$this->original_name = $original_name;
- foreach ($this->get_caption()->get_fields() as $field)
+ foreach ($this->get_databox()->get_meta_structure()->get_elements() as $data_field)
{
- if ($field->get_databox_field()->get_source() != metadata_description_PHRASEANET_tffilename::get_source())
+ if ($data_field->get_metadata_source() != metadata_description_PHRASEANET_tffilename::get_source())
{
continue;
}
- $this->set_metadatas(
- array(
- 'meta_struct_id' => $field->get_meta_struct_id()
- , 'meta_id' => get_meta_id
- , 'value' => array($original_name)
- )
- , true
+ /**
+ * Replacing original name in multi values is non sense
+ */
+ if (!$data_field->is_multi())
+ {
+ continue;
+ }
+
+ try
+ {
+ $field = $this->get_caption()->get_field($data_field->get_name())->get_meta_id();
+ $value = array_pop($field->get_values());
+ $meta_id = $value->getId();
+ }
+ catch (\Exception $e)
+ {
+ $meta_id = null;
+ }
+
+ $metas = array(
+ 'meta_struct_id' => $field->get_meta_struct_id()
+ , 'meta_id' => $meta_id
+ , 'value' => $original_name
);
+
+ $this->set_metadatas($metas, true);
}
$sql = 'UPDATE record
@@ -886,11 +893,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
{
- $sbas_id = $this->get_sbas_id();
- $record_id = $this->get_record_id();
-
$title = '';
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$fields = $this->get_databox()->get_meta_structure();
@@ -1067,7 +1071,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try
{
- $appbox = \appbox::get_instance();
+ $appbox = \appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$connbas = connection::getPDOConnection($this->get_sbas_id());
@@ -1185,29 +1189,55 @@ class record_adapter implements record_Interface, cache_cacheableInterface
}
}
- if (!is_array($params['value']))
- throw new Exception();
+ if (!is_scalar($params['value']))
+ {
+ throw new Exception('Metadata value should be scalar');
+ }
$databox_field = databox_field::get_instance($databox, $params['meta_struct_id']);
+ $caption_field = new caption_field($databox_field, $this);
+
+ $vocab = $vocab_id = null;
+
+ if (isset($params['vocabularyId']) && $databox_field->getVocabularyControl())
+ {
+ try
+ {
+ $vocab = $databox_field->getVocabularyControl();
+ $vocab_id = $params['vocabularyId'];
+ $vocab->validate($vocab_id);
+ }
+ catch (\Exception $e)
+ {
+ $vocab = $vocab_id = null;
+ }
+ }
+
+
if (trim($params['meta_id']) !== '')
{
- $tmp_val = trim(implode('', $params['value']));
- $caption_field = new caption_field($databox_field, $this, $params['meta_id']);
+ $tmp_val = trim($params['value']);
+
+ $caption_field_value = $caption_field->get_value($params['meta_id']);
if ($tmp_val === '')
{
- $caption_field->delete();
- unset($caption_field);
+ $caption_field_value->delete();
+ unset($caption_field_value);
}
else
{
- $caption_field->set_value($params['value']);
+ $caption_field_value->set_value($params['value']);
+ if ($vocab && $vocab_id)
+ {
+ $caption_field_value->setVocab($vocab, $vocab_id);
+ }
}
}
else
{
- $caption_field = caption_field::create($databox_field, $this, $params['value']);
+ $caption_field_value = caption_Field_Value::create($databox_field, $this, $params['value'], $vocab, $vocab_id);
}
$this->caption_record = null;
@@ -1226,7 +1256,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($metadatas as $param)
{
if (!is_array($param))
- throw new Exception_InvalidArgument();
+ {
+ throw new Exception_InvalidArgument('Invalid metadatas argument');
+ }
$db_field = \databox_field::get_instance($this->get_databox(), $param['meta_struct_id']);
@@ -1351,41 +1383,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this;
}
- /**
- *
- * @return string
- */
- public function get_reg_name()
- {
- if (!$this->is_grouping())
-
- return false;
-
- $balisename = '';
-
- $struct = $this->databox->get_structure();
-
- if ($sxe = simplexml_load_string($struct))
- {
- $z = $sxe->xpath('/record/description');
- if ($z && is_array($z))
- {
- foreach ($z[0] as $ki => $vi)
- {
- if ($vi['regname'] == '1')
- {
- $balisename = $ki;
- break;
- }
- }
- }
- }
- $regname = '';
- if ($sxe = simplexml_load_string($this->get_xml()))
- $regname = (string) $sxe->description->$balisename;
-
- return $regname;
- }
/**
*
@@ -1447,7 +1444,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$log_id = $session->get_logger($databox)->get_id();
@@ -1502,8 +1499,48 @@ class record_adapter implements record_Interface, cache_cacheableInterface
, ':value' => $value
));
}
+
$stmt->closeCursor();
+ foreach ($record->get_databox()->get_meta_structure()->get_elements() as $data_field)
+ {
+ if ($data_field->get_metadata_source() != metadata_description_PHRASEANET_tfrecordid::get_source())
+ {
+
+ continue;
+ }
+
+ /**
+ * Replacing record_id in multi values is non sense
+ */
+ if (!$data_field->is_multi())
+ {
+ continue;
+ }
+
+ try
+ {
+ $field = $record->get_caption()->get_field($data_field->get_name())->get_meta_id();
+ $value = array_pop($field->get_values());
+ $meta_id = $value->getId();
+ }
+ catch (\Exception $e)
+ {
+ $meta_id = null;
+ }
+
+ $metas = array(
+ array(
+ 'meta_struct_id' => $data_field->get_id()
+ , 'meta_id' => $meta_id
+ , 'value' => array($record->get_record_id())
+ )
+ );
+
+ $record->set_metadatas($metas, true);
+ }
+
+
return $record;
}
@@ -1568,7 +1605,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{
$connbas = $this->get_databox()->get_connection();
$sbas_id = $this->get_databox()->get_sbas_id();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$conn = $appbox->get_connection();
@@ -1673,21 +1710,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor();
- $sql = 'SELECT s.ssel_id, c.sselcont_id, s.usr_id
- FROM sselcont c, ssel s
- WHERE c.base_id = :base_id AND c.record_id = :record_id
- AND s.ssel_id = c.ssel_id';
- $stmt = $conn->prepare($sql);
- $stmt->execute(array(':record_id' => $this->get_record_id(), ':base_id' => $this->get_base_id()));
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $em = bootstrap::getCore()->getEntityManager();
- foreach ($rs as $row)
+ $repository = $em->getRepository('\Entities\BasketElement');
+
+ /* @var $repository \Repositories\BasketElementRepository */
+ foreach ($repository->findElementsByRecord($this) as $basket_element)
{
- $basket = basket_adapter::getInstance($appbox, $row['ssel_id'], $row['usr_id']);
- $basket->remove_from_ssel($row['sselcont_id']);
+ $em->remove($basket_element);
}
- $stmt->closeCursor();
+ $em->flush();
foreach ($ftodel as $f)
@unlink($f);
@@ -1807,8 +1840,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_data_from_cache($option = null)
{
- \cache_databox::refresh($this->get_sbas_id());
-
$databox = $this->get_databox();
return $databox->get_data_from_cache($this->get_cache_key($option));
@@ -1895,38 +1926,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_container_baskets()
{
- if ($this->container_basket)
+ $Core = bootstrap::getCore();
+ $em = $Core->getEntityManager();
- return $this->container_basket;
+ $repo = $em->getRepository('\Entities\Basket');
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ /* @var $$repo \Repositories\BasketRepository */
- $baskets = array();
- $sql = 'SELECT s.ssel_id FROM ssel s, sselcont c
- WHERE s.ssel_id = c.ssel_id
- AND c.base_id = :base_id AND record_id = :record_id
- AND usr_id = :usr_id AND temporaryType="0"';
-
- $params = array(
- ':base_id' => $this->get_base_id()
- , ':record_id' => $this->get_record_id()
- , ':usr_id' => $session->get_usr_id()
- );
-
- $stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute($params);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
-
- foreach ($rs as $row)
- {
- $baskets[$row['ssel_id']] = basket_adapter::getInstance($appbox, $row['ssel_id'], $session->get_usr_id());
- }
-
- $this->container_basket = $baskets;
-
- return $this->container_basket;
+ return $repo->findContainingRecordForUser($this, $Core->getAuthenticatedUser());
}
/**
@@ -1968,7 +1975,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (!$this->is_grouping())
throw new Exception('This record is not a grouping');
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$sql = 'SELECT record_id
FROM regroup g
@@ -2011,7 +2018,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_grouping_parents()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$sql = 'SELECT r.record_id
FROM regroup g
@@ -2047,4 +2054,87 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $set;
}
+ public function hasChild(\record_adapter $record)
+ {
+ return $this->get_children()->offsetExists($record->get_serialize_key());
+ }
+
+ public function appendChild(\record_adapter $record)
+ {
+ if (!$this->is_grouping())
+ throw new \Exception('Only stories can append children');
+
+ $connbas = $this->get_databox()->get_connection();
+
+ $ord = 0;
+
+ $sql = "SELECT (max(ord)+1) as ord
+ FROM regroup WHERE rid_parent = :parent_record_id";
+
+ $stmt = $connbas->prepare($sql);
+
+ $stmt->execute(array(':parent_record_id' => $this->get_record_id()));
+
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ $stmt->closeCursor();
+
+ if ($row)
+ {
+ $ord = is_null($row["ord"]) ? 0 : $row["ord"];
+ }
+
+ $sql = 'INSERT INTO regroup (id, rid_parent, rid_child, dateadd, ord)
+ VALUES (null, :parent_record_id, :record_id, NOW(), :ord)';
+
+ $params = array(
+ ':parent_record_id' => $this->get_record_id()
+ , ':record_id' => $record->get_record_id()
+ , ':ord' => $ord
+ );
+
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute($params);
+
+ $stmt->closeCursor();
+
+ $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute(array(':record_id' => $this->get_record_id()));
+ $stmt->closeCursor();
+
+ $this->delete_data_from_cache();
+
+ return $this;
+ }
+
+ public function removeChild(\record_adapter $record)
+ {
+ if (!$this->is_grouping())
+ throw new \Exception('Only stories can append children');
+
+ $connbas = $this->get_databox()->get_connection();
+
+ $sql = "DELETE FROM regroup WHERE rid_parent = :parent_record_id
+ AND rid_child = :record_id";
+
+ $params = array(
+ ':parent_record_id' => $this->get_record_id()
+ , ':record_id' => $record->get_record_id()
+ );
+
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute($params);
+ $stmt->closeCursor();
+
+ $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
+ $stmt = $connbas->prepare($sql);
+ $stmt->execute(array(':record_id' => $this->get_record_id()));
+ $stmt->closeCursor();
+
+ $this->delete_data_from_cache();
+
+ return $this;
+ }
+
}
diff --git a/lib/classes/record/exportElement.class.php b/lib/classes/record/exportElement.class.php
index 37aa9be27a..874b4e59bf 100644
--- a/lib/classes/record/exportElement.class.php
+++ b/lib/classes/record/exportElement.class.php
@@ -73,7 +73,7 @@ class record_exportElement extends record_adapter
$this->downloadable = $downloadable = array();
$this->orderable = $orderable = array();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$sd = $this->get_subdefs();
diff --git a/lib/classes/record/orderElement.class.php b/lib/classes/record/orderElement.class.php
index a65004a7cf..bc9623e842 100644
--- a/lib/classes/record/orderElement.class.php
+++ b/lib/classes/record/orderElement.class.php
@@ -56,7 +56,7 @@ class record_orderElement extends record_adapter
{
if ($this->order_master_id)
{
- $user = User_Adapter::getInstance($this->order_master_id, appbox::get_instance());
+ $user = User_Adapter::getInstance($this->order_master_id, appbox::get_instance(\bootstrap::getCore()));
return $user->get_display_name();
}
diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php
index 3d025bac91..f16e35c5ef 100644
--- a/lib/classes/record/preview.class.php
+++ b/lib/classes/record/preview.class.php
@@ -86,16 +86,17 @@ class record_preview extends record_adapter
* @param boolean $reload_train
* @return record_preview
*/
- public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine =null, $query='')
+ public function __construct($env, $pos, $contId, $reload_train, searchEngine_adapter $search_engine = null, $query = '')
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $Core = bootstrap::getCore();
$number = null;
$this->env = $env;
switch ($env)
{
case "RESULT":
- $results = $search_engine->query_per_offset($query, (int) ($pos), 1);
+ $results = $search_engine->query_per_offset($query, (int) ($pos), 1);
$mypreview = array();
if ($results->get_datas()->is_empty())
@@ -104,22 +105,22 @@ class record_preview extends record_adapter
}
foreach ($results->get_datas() as $record)
{
- $number = $pos;
- $sbas_id = $record->get_sbas_id();
+ $number = $pos;
+ $sbas_id = $record->get_sbas_id();
$record_id = $record->get_record_id();
break;
}
break;
case "REG":
- $contId = explode('_', $contId);
- $sbas_id = $contId[0];
+ $contId = explode('_', $contId);
+ $sbas_id = $contId[0];
$record_id = $contId[1];
$this->container = new record_adapter($sbas_id, $record_id);
if ($pos == 0)
{
$number = 0;
- $title = _('preview:: regroupement ');
+ $title = _('preview:: regroupement ');
}
else
{
@@ -127,52 +128,57 @@ class record_preview extends record_adapter
$children = $this->container->get_children();
foreach ($children as $child)
{
- $sbas_id = $child->get_sbas_id();
+ $sbas_id = $child->get_sbas_id();
$record_id = $child->get_record_id();
if ($child->get_number() == $pos)
break;
}
- $number = $pos;
+ $number = $pos;
$this->total = $children->get_count();
}
break;
case "BASK":
- $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id());
+ $em = $Core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
- $this->container = $basket;
- $this->total = count($basket->get_elements());
+ /* @var $repository \Repositories\BasketRepository */
+ $Basket = $repository->findUserBasket($contId, $Core->getAuthenticatedUser(), false);
+
+ /* @var $Basket \Entities\Basket */
+ $this->container = $Basket;
+ $this->total = $Basket->getElements()->count();
$i = 0;
$first = true;
- foreach ($basket->get_elements() as $element)
+ foreach ($Basket->getElements() as $element)
{
+ /* @var $element \Entities\BasketElement */
$i++;
if ($first)
{
- $sbas_id = $element->get_record()->get_sbas_id();
- $record_id = $element->get_record()->get_record_id();
- $this->name = $basket->get_name();
- $number = $element->get_order();
+ $sbas_id = $element->getRecord()->get_sbas_id();
+ $record_id = $element->getRecord()->get_record_id();
+ $this->name = $Basket->getName();
+ $number = $element->getOrd();
}
- $first = false;
+ $first = false;
- if ($element->get_order() == $pos)
+ if ($element->getOrd() == $pos)
{
- $sbas_id = $element->get_record()->get_sbas_id();
- $record_id = $element->get_record()->get_record_id();
- $this->name = $basket->get_name();
- $number = $element->get_order();
+ $sbas_id = $element->getRecord()->get_sbas_id();
+ $record_id = $element->getRecord()->get_record_id();
+ $this->name = $Basket->getName();
+ $number = $element->getOrd();
}
}
break;
case "FEED":
$entry = Feed_Entry_Adapter::load_from_id($appbox, $contId);
-// $basket = basket_adapter::getInstance($appbox, $contId, $appbox->get_session()->get_usr_id());
$this->container = $entry;
$this->total = count($entry->get_content());
- $i = 0;
+ $i = 0;
$first = true;
foreach ($entry->get_content() as $element)
@@ -180,19 +186,19 @@ class record_preview extends record_adapter
$i++;
if ($first)
{
- $sbas_id = $element->get_record()->get_sbas_id();
+ $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
$this->name = $entry->get_title();
- $number = $element->get_ord();
+ $number = $element->get_ord();
}
- $first = false;
+ $first = false;
if ($element->get_ord() == $pos)
{
- $sbas_id = $element->get_record()->get_sbas_id();
+ $sbas_id = $element->get_record()->get_sbas_id();
$record_id = $element->get_record()->get_record_id();
$this->name = $entry->get_title();
- $number = $element->get_ord();
+ $number = $element->get_ord();
}
}
break;
@@ -202,7 +208,7 @@ class record_preview extends record_adapter
return $this;
}
- public function get_train($pos = 0, $query='', searchEngine_adapter $search_engine=null)
+ public function get_train($pos = 0, $query = '', searchEngine_adapter $search_engine = null)
{
if ($this->train)
@@ -212,14 +218,14 @@ class record_preview extends record_adapter
{
case 'RESULT':
$perPage = 56;
- $index = ($pos - 3) < 0 ? 0 : ($pos - 3);
- $page = (int) ceil($pos / $perPage);
+ $index = ($pos - 3) < 0 ? 0 : ($pos - 3);
+ $page = (int) ceil($pos / $perPage);
$results = $search_engine->query_per_offset($query, $index, $perPage);
$this->train = $results->get_datas();
break;
case 'BASK':
- $this->train = $this->container->get_elements();
+ $this->train = $this->container->getElements();
break;
case 'REG':
$this->train = $this->container->get_children();
@@ -265,7 +271,7 @@ class record_preview extends record_adapter
*
* @return String
*/
- public function get_title($highlight = '', searchEngine_adapter $search_engine=null)
+ public function get_title($highlight = '', searchEngine_adapter $search_engine = null)
{
if ($this->title)
@@ -278,15 +284,15 @@ class record_preview extends record_adapter
case "RESULT":
$this->title .= sprintf(
- _('preview:: resultat numero %s '), '' . ($this->number + 1)
- . ' : '
+ _('preview:: resultat numero %s '), '' . ($this->number + 1)
+ . ' : '
);
$this->title .= parent::get_title($highlight, $search_engine);
break;
case "BASK":
$this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine)
- . ' (' . $this->get_number() . '/' . $this->total . ') ';
+ . ' (' . $this->get_number() . '/' . $this->total . ') ';
break;
case "REG":
$title = parent::get_title();
@@ -297,7 +303,7 @@ class record_preview extends record_adapter
else
{
$this->title .= sprintf(
- _('%s %d/%d '), $title, $this->get_number() . '/' . $this->total
+ '%s %s', $title, $this->get_number() . '/' . $this->total
);
}
break;
@@ -325,21 +331,22 @@ class record_preview extends record_adapter
public function get_short_history()
{
if (!is_null($this->short_history))
-
+ {
return $this->short_history;
+ }
$tab = array();
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
$registry = $appbox->get_registry();
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$report = $user->ACL()->has_right_on_base($this->get_base_id(), 'canreport');
$connsbas = connection::getPDOConnection($this->get_sbas_id());
- $sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site
+ $sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site
FROM log_docs d, log l
WHERE d.log_id = l.id
AND d.record_id = :record_id ';
@@ -349,14 +356,14 @@ class record_preview extends record_adapter
{
$sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")';
$params[':usr_id'] = $session->get_usr_id();
- $params[':site'] = $registry->get('GV_sit');
+ $params[':site'] = $registry->get('GV_sit');
}
$sql .= 'ORDER BY d.date, usrid DESC';
$stmt = $connsbas->prepare($sql);
$stmt->execute($params);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
@@ -390,20 +397,20 @@ class record_preview extends record_adapter
}
$tab[$hour][$site][$action][$row['usr_id']] =
- array(
- 'final' => array()
- , 'comment' => array()
- , 'user' => $user
+ array(
+ 'final' => array()
+ , 'comment' => array()
+ , 'user' => $user
);
}
if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final']))
$tab[$hour][$site][$action][$row['usr_id']]['final'][] =
- $row['final'];
+ $row['final'];
if (!in_array($row['comment'], $tab[$hour][$site][$action][$row['usr_id']]['comment']))
$tab[$hour][$site][$action][$row['usr_id']]['comment'][] =
- $row['comment'];
+ $row['comment'];
}
$this->short_history = array_reverse($tab);
@@ -418,14 +425,16 @@ class record_preview extends record_adapter
public function get_view_popularity()
{
if (!is_null($this->view_popularity))
-
+ {
return $this->view_popularity;
- $appbox = appbox::get_instance();
+ }
+
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
- $report = $user->ACL()->has_right_on_base(
- $this->get_base_id(), 'canreport');
+ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $report = $user->ACL()->has_right_on_base(
+ $this->get_base_id(), 'canreport');
$registry = $appbox->get_registry();
if (!$report && !$registry->get('GV_google_api'))
@@ -436,16 +445,16 @@ class record_preview extends record_adapter
}
$views = $dwnls = array();
- $top = 1;
- $day = 30;
- $min = 0;
+ $top = 1;
+ $day = 30;
+ $min = 0;
$average = 0;
while ($day >= 0)
{
- $datetime = new DateTime('-' . $day . ' days');
- $date = date_format($datetime, 'Y-m-d');
+ $datetime = new DateTime('-' . $day . ' days');
+ $date = date_format($datetime, 'Y-m-d');
$views[$date] = $dwnls[$date] = 0;
$day--;
}
@@ -458,14 +467,14 @@ class record_preview extends record_adapter
GROUP BY datee ORDER BY datee ASC';
$connsbas = connection::getPDOConnection($this->get_sbas_id());
- $stmt = $connsbas->prepare($sql);
+ $stmt = $connsbas->prepare($sql);
$stmt->execute(
- array(
- ':record_id' => $this->get_record_id(),
- ':site' => $registry->get('GV_sit')
- )
+ array(
+ ':record_id' => $this->get_record_id(),
+ ':site' => $registry->get('GV_sit')
+ )
);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
@@ -473,8 +482,8 @@ class record_preview extends record_adapter
if (isset($views[$row['datee']]))
{
$views[$row['datee']] = (int) $row['views'];
- $top = max((int) $row['views'], $top);
- $min = isset($min) ? min($row['views'], $min) : $row['views'];
+ $top = max((int) $row['views'], $top);
+ $min = isset($min) ? min($row['views'], $min) : $row['views'];
$average += $row['views'];
}
}
@@ -482,26 +491,26 @@ class record_preview extends record_adapter
$topScale = round($top * 1.2);
$average = $average / 30;
- $max = round(($top) * 100 / ($topScale));
- $min = round($min * 100 / ($topScale));
+ $max = round(($top) * 100 / ($topScale));
+ $min = round($min * 100 / ($topScale));
$average = round($average * 100 / ($topScale));
- $width = 350;
+ $width = 350;
$height = 150;
- $url = 'http://chart.apis.google.com/chart?' .
- 'chs=' . $width . 'x' . $height .
- '&chd=t:' . implode(',', $views) .
- '&cht=lc' .
- '&chf=bg,s,00000000' .
- '&chxt=x,y,r' .
- '&chds=0,' . $topScale .
- '&chls=2.0&chxtc=2,-350' .
- '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
- . date_format(new DateTime('-15 days'), 'd M') . '|'
- . date_format(new DateTime(), 'd M') . '|1:|0|'
- . round($top / 2, 2) . '|' . $top
- . '|2:|min|average|max' .
- '&chxp=2,' . $min . ',' . $average . ',' . $max;
+ $url = 'http://chart.apis.google.com/chart?' .
+ 'chs=' . $width . 'x' . $height .
+ '&chd=t:' . implode(',', $views) .
+ '&cht=lc' .
+ '&chf=bg,s,00000000' .
+ '&chxt=x,y,r' .
+ '&chds=0,' . $topScale .
+ '&chls=2.0&chxtc=2,-350' .
+ '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
+ . date_format(new DateTime('-15 days'), 'd M') . '|'
+ . date_format(new DateTime(), 'd M') . '|1:|0|'
+ . round($top / 2, 2) . '|' . $top
+ . '|2:|min|average|max' .
+ '&chxp=2,' . $min . ',' . $average . ',' . $max;
$this->view_popularity = new media_adapter($url, $width, $height);
@@ -516,14 +525,16 @@ class record_preview extends record_adapter
public function get_refferer_popularity()
{
if (!is_null($this->refferer_popularity))
-
+ {
return $this->refferer_popularity;
- $appbox = appbox::get_instance();
+ }
+
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
- $report = $user->ACL()->has_right_on_base(
- $this->get_base_id(), 'canreport');
+ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $report = $user->ACL()->has_right_on_base(
+ $this->get_base_id(), 'canreport');
$registry = $appbox->get_registry();
if (!$report && !$registry->get('GV_google_api'))
@@ -543,7 +554,7 @@ class record_preview extends record_adapter
$stmt = $connsbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id()));
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$referrers = array();
@@ -571,24 +582,24 @@ class record_preview extends record_adapter
if (strpos($row['referrer'], $registry->get('GV_ServerName') . 'permalink/') !== false)
{
if (strpos($row['referrer'], '/view/') !== false)
- $row['referrer'] = _('report::presentation page preview');
+ $row['referrer'] = _('report::presentation page preview');
else
- $row['referrer'] = _('report::acces direct');
+ $row['referrer'] = _('report::acces direct');
}
if (!isset($referrers[$row['referrer']]))
$referrers[$row['referrer']] = 0;
$referrers[$row['referrer']] += (int) $row['views'];
}
- $width = 550;
+ $width = 550;
$height = 100;
$url = 'http://chart.apis.google.com/chart?'
- . 'cht=p3&chf=bg,s,00000000&chd=t:'
- . implode(',', $referrers)
- . '&chs=' . $width . 'x' . $height
- . '&chl='
- . urlencode(implode('|', array_keys($referrers))) . '';
+ . 'cht=p3&chf=bg,s,00000000&chd=t:'
+ . implode(',', $referrers)
+ . '&chs=' . $width . 'x' . $height
+ . '&chl='
+ . urlencode(implode('|', array_keys($referrers))) . '';
$this->refferer_popularity = new media_adapter($url, $width, $height);
@@ -603,15 +614,17 @@ class record_preview extends record_adapter
{
if (!is_null($this->download_popularity))
-
+ {
return $this->download_popularity;
- $appbox = appbox::get_instance();
+ }
+
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$registry = $appbox->get_registry();
- $report = $user->ACL()->has_right_on_base(
- $this->get_base_id(), 'canreport');
+ $report = $user->ACL()->has_right_on_base(
+ $this->get_base_id(), 'canreport');
$ret = false;
if (!$report && !$registry->get('GV_google_api'))
@@ -622,16 +635,16 @@ class record_preview extends record_adapter
}
$views = $dwnls = array();
- $top = 1;
- $day = 30;
- $min = 0;
+ $top = 1;
+ $day = 30;
+ $min = 0;
$average = 0;
while ($day >= 0)
{
- $datetime = new DateTime('-' . $day . ' days');
- $date = date_format($datetime, 'Y-m-d');
+ $datetime = new DateTime('-' . $day . ' days');
+ $date = date_format($datetime, 'Y-m-d');
$views[$date] = $dwnls[$date] = 0;
$day--;
}
@@ -646,14 +659,14 @@ class record_preview extends record_adapter
GROUP BY datee ORDER BY datee ASC';
$connsbas = connection::getPDOConnection($this->get_sbas_id());
- $stmt = $connsbas->prepare($sql);
+ $stmt = $connsbas->prepare($sql);
$stmt->execute(
- array(
- ':record_id' => $this->get_record_id(),
- ':site' => $registry->get('GV_sit')
- )
+ array(
+ ':record_id' => $this->get_record_id(),
+ ':site' => $registry->get('GV_sit')
+ )
);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$top = 10;
@@ -663,23 +676,23 @@ class record_preview extends record_adapter
if (isset($dwnls[$row['datee']]))
{
$dwnls[$row['datee']] = (int) $row['dwnl'];
- $top = max(((int) $row['dwnl'] + 10), $top);
+ $top = max(((int) $row['dwnl'] + 10), $top);
}
}
- $width = 250;
+ $width = 250;
$height = 150;
- $url = 'http://chart.apis.google.com/chart?' .
- 'chs=' . $width . 'x' . $height .
- '&chd=t:' . implode(',', $dwnls) .
- '&cht=lc' .
- '&chf=bg,s,00000000' .
- '&chxt=x,y' .
- '&chds=0,' . $top .
- '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
- . date_format(new DateTime('-15 days'), 'd M') . '|'
- . date_format(new DateTime(), 'd M') . '|1:|0|'
- . round($top / 2) . '|' . $top . '';
+ $url = 'http://chart.apis.google.com/chart?' .
+ 'chs=' . $width . 'x' . $height .
+ '&chd=t:' . implode(',', $dwnls) .
+ '&cht=lc' .
+ '&chf=bg,s,00000000' .
+ '&chxt=x,y' .
+ '&chds=0,' . $top .
+ '&chxl=0:|' . date_format(new DateTime('-30 days'), 'd M') . '|'
+ . date_format(new DateTime('-15 days'), 'd M') . '|'
+ . date_format(new DateTime(), 'd M') . '|1:|0|'
+ . round($top / 2) . '|' . $top . '';
$ret = new media_adapter($url, $width, $height);
$this->download_popularity = $ret;
diff --git a/lib/classes/recordutils/image.class.php b/lib/classes/recordutils/image.class.php
index dd526b3c15..92bc2fb577 100644
--- a/lib/classes/recordutils/image.class.php
+++ b/lib/classes/recordutils/image.class.php
@@ -392,7 +392,7 @@ class recordutils_image extends recordutils
*/
public static function watermark($bas, $rec, $hd=false)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$sbas_id = phrasea::sbasFromBas($bas);
diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php
index 71c2b8eed8..27691800ac 100644
--- a/lib/classes/registry.class.php
+++ b/lib/classes/registry.class.php
@@ -20,9 +20,10 @@ class registry implements registryInterface
/**
*
- * @var cache_opcode_adapter
+ * @var \Alchemy\Phrasea\Cache\Cache
*/
protected $cache;
+
/**
*
* @var registry
@@ -41,27 +42,32 @@ class registry implements registryInterface
*/
public static function get_instance()
{
- $prefix = crc32(dirname(__FILE__));
if (!self::$_instance instanceof self)
- self::$_instance = new self(new cache_opcode_adapter($prefix));
+ {
+ self::$_instance = new self();
+ }
return self::$_instance;
}
/**
*
- * @param cache_opcode_interface $cache
+ * @param \Alchemy\Phrasea\Cache\Cache $cache
* @return registry
*/
- protected function __construct(cache_opcode_interface $cache)
+ protected function __construct()
{
- $this->cache = $cache;
+ $this->cache = new Alchemy\Phrasea\Cache\ArrayCache();
- require dirname(__FILE__) . '/../../config/config.inc';
- $this->cache->set('GV_RootPath', dirname(dirname(dirname(__FILE__))) . '/');
- $this->cache->set('GV_ServerName', p4string::addEndSlash($servername));
- $this->cache->set('GV_debug', !!$debug);
- $this->cache->set('GV_maintenance', !!$maintenance);
+ $configuration = \Alchemy\Phrasea\Core\Configuration::build();
+
+ $this->cache->save('GV_RootPath', dirname(dirname(__DIR__)) . '/');
+ if ($configuration->isInstalled())
+ {
+ $this->cache->save('GV_ServerName', $configuration->getPhraseanet()->get('servername'));
+ $this->cache->save('GV_debug', $configuration->isDebug());
+ $this->cache->save('GV_maintenance', $configuration->isMaintained());
+ }
return $this;
}
@@ -72,7 +78,7 @@ class registry implements registryInterface
*/
protected function load()
{
- if ($this->cache->get('registry_loaded') !== true)
+ if ($this->cache->fetch('registry_loaded') !== true)
{
$rs = array();
$loaded = false;
@@ -110,10 +116,10 @@ class registry implements registryInterface
break;
}
- $this->cache->set($row['key'], $value);
+ $this->cache->save($row['key'], $value);
}
if ($loaded === true)
- $this->cache->set('registry_loaded', true);
+ $this->cache->save('registry_loaded', true);
}
@@ -127,15 +133,15 @@ class registry implements registryInterface
*/
public function get($key, $defaultvalue = null)
{
- if (!$this->cache->is_set($key))
+ if (!$this->cache->contains($key))
$this->load();
- if(!$this->cache->is_set($key) && !is_null($defaultvalue))
+ if (!$this->cache->contains($key) && !is_null($defaultvalue))
return $defaultvalue;
else
- return $this->cache->get($key);
+ return $this->cache->fetch($key);
}
/**
@@ -144,17 +150,9 @@ class registry implements registryInterface
* @param mixed $value
* @return registry
*/
- public function set($key, $value, $type = 'string')
+ public function set($key, $value, $type)
{
$this->load();
- $delete_cache = false;
- if ($key === 'GV_cache_server_type')
- {
- $current_cache = $this->get('GV_cache_server_type');
- if ($current_cache !== $value)
- $delete_cache = true;
- }
-
switch ($type)
{
@@ -186,13 +184,7 @@ class registry implements registryInterface
$stmt->execute(array(':key' => $key, ':value' => $sql_value, ':type' => $type));
$stmt->closeCursor();
- $this->cache->set($key, $value);
-
- if ($delete_cache === true)
- {
- $cache = cache_adapter::get_instance($this);
- $cache->flush();
- }
+ $this->cache->save($key, $value);
return $this;
}
@@ -206,7 +198,7 @@ class registry implements registryInterface
{
$this->load();
- return $this->cache->is_set($key);
+ return $this->cache->contains($key);
}
/**
@@ -224,7 +216,7 @@ class registry implements registryInterface
$stmt->execute(array(':key' => $key));
$stmt->closeCursor();
- $this->cache->un_set($key);
+ $this->cache->delete($key);
return $this;
}
diff --git a/lib/classes/registryInterface.class.php b/lib/classes/registryInterface.class.php
index a51833fefb..3b0dfecc8e 100644
--- a/lib/classes/registryInterface.class.php
+++ b/lib/classes/registryInterface.class.php
@@ -19,7 +19,7 @@ interface registryInterface
{
public function get($key, $defaultvalue = null);
- public function set($key, $value);
+ public function set($key, $value, $type);
public function is_set($key);
diff --git a/lib/classes/searchEngine/adapter/phrasea/engine.class.php b/lib/classes/searchEngine/adapter/phrasea/engine.class.php
index b8ae74692e..55983f3d75 100644
--- a/lib/classes/searchEngine/adapter/phrasea/engine.class.php
+++ b/lib/classes/searchEngine/adapter/phrasea/engine.class.php
@@ -247,7 +247,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$query .= ' AND recordtype=' . $this->opt_record_type;
}
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$sql = 'SELECT query, query_time FROM cache WHERE session_id = :ses_id';
@@ -325,7 +325,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/
public function reset_cache()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
phrasea_clear_cache($session->get_ses_id());
$this->reseted = true;
@@ -375,7 +375,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/
protected function query()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -472,7 +472,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/
protected function singleParse($sbas)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$this->qp[$sbas] = new searchEngine_adapter_phrasea_queryParser(Session_Handler::get_locale());
$this->qp[$sbas]->debug = false;
@@ -504,7 +504,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$qry .= trim($query);
}
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
@@ -620,7 +620,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{
$ret = array();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$res = phrasea_fetch_results(
$session->get_ses_id(), ($record->get_number() + 1), 1, true, "[[em]]", "[[/em]]"
@@ -631,7 +631,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
return array();
$rs = $res['results'];
$res = array_shift($rs);
- if (!$res['xml'])
+ if (! isset($res['xml']))
return array();
$sxe = simplexml_load_string($res['xml']);
@@ -645,7 +645,8 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('', ' '), (string) $value);
}
- $val = implode(' '.$field['separator'].' ', $val);
+ $separator = $field['separator'] ? $field['separator'][0] : '';
+ $val = implode(' '.$separator.' ', $val);
}
else
{
diff --git a/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php b/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
index 09351847ac..2bfcd61aa7 100644
--- a/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
+++ b/lib/classes/searchEngine/adapter/phrasea/queryParser.class.php
@@ -19,73 +19,75 @@ class searchEngine_adapter_phrasea_queryParser
{
var $ops = array(
- "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
- "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
- "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
- "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
- "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
- "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
- "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
- "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
- "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
- "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
- "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
- "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
- "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false),
- "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false)
+ "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
+ "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false),
+ "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
+ "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false),
+ "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
+ "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false),
+ "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
+ "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true),
+ "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
+ "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true),
+ "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
+ "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true),
+ "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false),
+ "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false)
);
- var $opk = array(
- "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false),
- ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false),
- "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false),
- ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false),
- "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false),
- "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false),
- ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false)
+ var $opk = array(
+ "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false),
+ ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false),
+ "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false),
+ ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false),
+ "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false),
+ "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false),
+ ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false)
);
- var $spw = array(
- "all" => array(
- "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
- ),
- "last" => array(
- "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
- ),
- // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
- // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
- "tout" => array(
- "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
- ),
- "derniers" => array(
- "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
- )
+ var $spw = array(
+ "all" => array(
+ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
+ ),
+ "last" => array(
+ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
+ ),
+ // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
+ // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true),
+ "tout" => array(
+ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false
+ ),
+ "derniers" => array(
+ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true
+ )
);
var $quoted_defaultop = array(
- "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0
+ "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0
);
var $defaultop = array(
- "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL
+ "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL
);
var $defaultlast = 12;
var $phq;
- var $errmsg = "";
+ var $errmsg = "";
+
/**
*
* @var boolean
*/
- var $debug = false;
+ var $debug = false;
+
/**
* un tableau qui contiendra des propositions de thesaurus
* pour les termes de l'arbre simple
*
* @var array
*/
- var $proposals = Array("QRY" => "", "BASES" => array());
+ var $proposals = Array("QRY" => "", "BASES" => array());
+
/**
* Current language for thesaurus
* @var
*/
var $lng = null;
-
protected $unicode;
function __construct($lng = "???")
@@ -117,7 +119,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- $this->proposals = Array("QRY" => "", "BASES" => array());
+ $this->proposals = Array("QRY" => "", "BASES" => array());
$this->phq = $this->mb_trim($phq, 'UTF-8');
if ($this->phq != "")
@@ -178,7 +180,6 @@ class searchEngine_adapter_phrasea_queryParser
function astable(&$tree)
{
$this->calc_complexity($tree);
- // var_dump($tree);
$txt = "";
$this->astable2($txt, $tree);
$txt = "\n";
@@ -199,7 +200,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- function astable2(&$out, &$tree, $depth=0)
+ function astable2(&$out, &$tree, $depth = 0)
{
switch ($tree["CLASS"])
{
@@ -228,7 +229,7 @@ class searchEngine_adapter_phrasea_queryParser
break;
case "OPS":
case "OPK":
- $op = $tree["VALUE"];
+ $op = $tree["VALUE"];
if (isset($tree["PNUM"]))
$op .= "[" . $tree["PNUM"] . "]";
$out .= "\t$op \n";
@@ -246,7 +247,7 @@ class searchEngine_adapter_phrasea_queryParser
print(" \n");
}
- function dumpDiv2(&$tree, $depth=0)
+ function dumpDiv2(&$tree, $depth = 0)
{
switch ($tree["CLASS"])
{
@@ -355,7 +356,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- function priority_opk(&$tree, $depth=0)
+ function priority_opk(&$tree, $depth = 0)
{
if (!$tree)
@@ -363,10 +364,10 @@ class searchEngine_adapter_phrasea_queryParser
if ($tree["CLASS"] == "OPK" && ($tree["LB"]["CLASS"] == "OPS" || $tree["LB"]["CLASS"] == "OPK"))
{
// on a un truc du genre ((a ou b) < 5), on le transforme en (a ou (b < 5))
- $t = $tree["LB"];
+ $t = $tree["LB"];
$tree["LB"] = $t["RB"];
- $t["RB"] = $tree;
- $tree = $t;
+ $t["RB"] = $tree;
+ $tree = $t;
}
if (isset($tree["LB"]))
$this->priority_opk($tree["LB"], $depth + 1);
@@ -374,7 +375,7 @@ class searchEngine_adapter_phrasea_queryParser
$this->priority_opk($tree["RB"], $depth + 1);
}
- function distrib_opk(&$tree, $depth=0)
+ function distrib_opk(&$tree, $depth = 0)
{
if (!$tree)
@@ -382,18 +383,18 @@ class searchEngine_adapter_phrasea_queryParser
if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS"))
{
// on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6))
- $tmp = array("CLASS" => $tree["CLASS"],
- "NODETYPE" => $tree["NODETYPE"],
- "VALUE" => $tree["VALUE"],
- "PNUM" => $tree["PNUM"],
- "LB" => $tree["LB"],
- "RB" => $tree["RB"]["RB"],
- "DEPTH" => $tree["LB"]["DEPTH"]);
- $t = $tree["RB"];
+ $tmp = array("CLASS" => $tree["CLASS"],
+ "NODETYPE" => $tree["NODETYPE"],
+ "VALUE" => $tree["VALUE"],
+ "PNUM" => $tree["PNUM"],
+ "LB" => $tree["LB"],
+ "RB" => $tree["RB"]["RB"],
+ "DEPTH" => $tree["LB"]["DEPTH"]);
+ $t = $tree["RB"];
$tree["RB"] = $t["LB"];
- $t["LB"] = $tree;
- $t["RB"] = $tmp;
- $tree = $t;
+ $t["LB"] = $tree;
+ $t["RB"] = $tmp;
+ $tree = $t;
}
if (isset($tree["LB"]))
$this->distrib_opk($tree["LB"], $depth + 1);
@@ -461,7 +462,6 @@ class searchEngine_adapter_phrasea_queryParser
$copy = $tree;
$this->_extendThesaurusOnTerms($tree, $copy, $useFullText, $useThesaurus, $keepfuzzy, 0, "");
- // var_dump($tree);
$this->proposals["QRY"] = "" . $this->_queryAsHTML($tree) . " ";
return($copy);
@@ -474,7 +474,7 @@ class searchEngine_adapter_phrasea_queryParser
if (!$useThesaurus)
return; // full-text only : inchangé
- if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
+ if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE"))
{
if (isset($tree["CONTEXT"]))
$copy = $this->_extendToThesaurus_Simple($tree, false, $keepfuzzy, $path);
@@ -488,10 +488,10 @@ class searchEngine_adapter_phrasea_queryParser
// on a 'field:value' , on traite 'value'
$tree["RB"]["PATH"] = $copy["RB"]["PATH"] = $path . "R";
if (isset($tree["RB"]["CONTEXT"]))
- $copy["CONTEXT"] = $tree["CONTEXT"] = $tree["RB"]["CONTEXT"];
+ $copy["CONTEXT"] = $tree["CONTEXT"] = $tree["RB"]["CONTEXT"];
else
if (!$keepfuzzy)
- $copy["CONTEXT"] = $tree["CONTEXT"] = "*";
+ $copy["CONTEXT"] = $tree["CONTEXT"] = "*";
$copy["RB"]["SREF"] = &$tree["RB"];
}
@@ -522,7 +522,7 @@ class searchEngine_adapter_phrasea_queryParser
function _extendToThesaurus_Simple(&$simple, $keepFullText, $keepfuzzy, $path)
{
$simple["PATH"] = $path;
- $context = null;
+ $context = null;
if (isset($simple["CONTEXT"]))
{
$context = $simple["CONTEXT"];
@@ -531,34 +531,34 @@ class searchEngine_adapter_phrasea_queryParser
if ($keepFullText)
{
// on fait un OU entre la recherche ft et une recherche th
- $tmp = array("CLASS" => "OPS",
- "NODETYPE" => PHRASEA_OP_OR,
- "VALUE" => "OR",
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"],
- "LB" => $simple,
- "RB" => array("CLASS" => "OPK",
- "NODETYPE" => PHRASEA_OP_COLON,
- "VALUE" => ":",
- // "CONTEXT"=>$context,
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"] + 1,
- "LB" => array("CLASS" => "SIMPLE",
- "NODETYPE" => PHRASEA_KEYLIST,
- "VALUE" => array("*"),
- "DEPTH" => $simple["DEPTH"] + 2
- ),
- "RB" => $simple
- )
+ $tmp = array("CLASS" => "OPS",
+ "NODETYPE" => PHRASEA_OP_OR,
+ "VALUE" => "OR",
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"],
+ "LB" => $simple,
+ "RB" => array("CLASS" => "OPK",
+ "NODETYPE" => PHRASEA_OP_COLON,
+ "VALUE" => ":",
+ // "CONTEXT"=>$context,
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"] + 1,
+ "LB" => array("CLASS" => "SIMPLE",
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "VALUE" => array("*"),
+ "DEPTH" => $simple["DEPTH"] + 2
+ ),
+ "RB" => $simple
+ )
);
// on vire le contexte du coté fulltext
unset($tmp["LB"]["CONTEXT"]);
// ajoute le contexte si nécéssaire
if ($context !== null)
- $tmp["RB"]["CONTEXT"] = $context;
+ $tmp["RB"]["CONTEXT"] = $context;
else
if (!$keepfuzzy)
- $tmp["RB"]["CONTEXT"] = "*";
+ $tmp["RB"]["CONTEXT"] = "*";
// corrige les profondeurs des 2 copies du 'simple' d'origine
$tmp["LB"]["DEPTH"] += 1;
$tmp["RB"]["RB"]["DEPTH"] += 2;
@@ -569,25 +569,25 @@ class searchEngine_adapter_phrasea_queryParser
else
{
// on remplace le ft par du th
- $tmp = array("CLASS" => "OPK",
- "NODETYPE" => PHRASEA_OP_COLON,
- "VALUE" => ":",
- // "CONTEXT"=>$context,
- "PNUM" => null,
- "DEPTH" => $simple["DEPTH"] + 1,
- "LB" => array("CLASS" => "SIMPLE",
- "NODETYPE" => PHRASEA_KEYLIST,
- "VALUE" => array("*"),
- "DEPTH" => $simple["DEPTH"] + 1
- ),
- "RB" => $simple
+ $tmp = array("CLASS" => "OPK",
+ "NODETYPE" => PHRASEA_OP_COLON,
+ "VALUE" => ":",
+ // "CONTEXT"=>$context,
+ "PNUM" => null,
+ "DEPTH" => $simple["DEPTH"] + 1,
+ "LB" => array("CLASS" => "SIMPLE",
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "VALUE" => array("*"),
+ "DEPTH" => $simple["DEPTH"] + 1
+ ),
+ "RB" => $simple
);
// ajoute le contexte si nécéssaire
if ($context !== null)
- $tmp["CONTEXT"] = $context;
+ $tmp["CONTEXT"] = $context;
else
if (!$keepfuzzy)
- $tmp["CONTEXT"] = "*";
+ $tmp["CONTEXT"] = "*";
// corrige la profondeur de la copie du 'simple' d'origine
$tmp["RB"]["DEPTH"] += 1;
// note une référence vers le terme d'origine
@@ -598,13 +598,13 @@ class searchEngine_adapter_phrasea_queryParser
return($tmp);
}
- function thesaurus2(&$tree, $bid, $name, &$domthe, $searchsynonyms=true, $depth=0)
+ function thesaurus2(&$tree, $bid, $name, &$domthe, $searchsynonyms = true, $depth = 0)
{
if ($this->debug)
print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n");
if ($depth == 0)
- $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
+ $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array());
if (!$tree)
@@ -625,18 +625,18 @@ class searchEngine_adapter_phrasea_queryParser
return($ambigus);
}
- function propAsHTML(&$node, &$html, $path, $depth=0)
+ function propAsHTML(&$node, &$html, $path, $depth = 0)
{
global $parm;
if ($depth > 0)
{
$tsy = array();
$lngfound = "?";
- for ($n = $node->firstChild; $n; $n = $n->nextSibling)
+ for ($n = $node->firstChild; $n; $n = $n->nextSibling)
{
if ($n->nodeName == "sy")
{
- $lng = $n->getAttribute("lng");
+ $lng = $n->getAttribute("lng");
if (!array_key_exists($lng, $tsy))
$tsy[$lng] = array();
$zsy = array("v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"));
@@ -644,7 +644,7 @@ class searchEngine_adapter_phrasea_queryParser
if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng))
{
$lngfound = $lng;
- $syfound = $zsy;
+ $syfound = $zsy;
}
else
{
@@ -653,7 +653,7 @@ class searchEngine_adapter_phrasea_queryParser
$tsy[$lng][] = $zsy;
}
}
- $alt = "";
+ $alt = "";
foreach ($tsy as $lng => $tsy2)
{
foreach ($tsy2 as $sy)
@@ -664,8 +664,8 @@ class searchEngine_adapter_phrasea_queryParser
}
$thtml = $syfound["v"];
- $kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
- $wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";
+ $kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
+ $wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";
if ($node->getAttribute("term"))
{
@@ -684,29 +684,27 @@ class searchEngine_adapter_phrasea_queryParser
if ($n->nodeType == XML_ELEMENT_NODE && $n->getAttribute("marked")) // only 'te' marked
{
$lngfound = '?';
- $syfound = '?';
- for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling)
+ $syfound = '?';
+ for ($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling)
{
if ($n2->nodeName == 'sy')
{
$lng = $n2->getAttribute('lng');
if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng))
{
- $lngfound = $lng;
- $syfound = $n2->getAttribute('w');
+ $lngfound = $lng;
+ $syfound = $n2->getAttribute('w');
}
}
}
$n->removeAttribute("marked");
- for ($i = 0; array_key_exists($syfound . $i, $tsort) && $i < 9999; $i++)
+ for ($i = 0; array_key_exists($syfound . $i, $tsort) && $i < 9999; $i++)
;
$tsort[$syfound . $i] = $n;
}
}
ksort($tsort);
-// var_dump($tsort);
-
foreach ($tsort as $n)
{
$this->propAsHTML($n, $html, $path, $depth + 1);
@@ -716,13 +714,11 @@ class searchEngine_adapter_phrasea_queryParser
$html .= $tab . " \n";
}
- function _queryAsHTML($tree, $depth=0)
+ function _queryAsHTML($tree, $depth = 0)
{
- // printf("astext : ");
- // var_dump($tree);
if ($depth == 0)
{
- $ambiguites = array("n" => 0, "refs" => array());
+ $ambiguites = array("n" => 0, "refs" => array());
}
switch ($tree["CLASS"])
{
@@ -734,7 +730,7 @@ class searchEngine_adapter_phrasea_queryParser
$path = $tree["PATH"];
if (isset($tree["CONTEXT"]))
$w .= ' [' . $tree["CONTEXT"] . ']';
- $txt = '
"' . $w . '" ';
+ $txt = '
"' . $w . '" ';
}
else
{
@@ -771,68 +767,6 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- /*
- function _queryAsHTML($tree, $mouseCallback="void", $depth=0)
- {
- // printf("astext : ");
- // var_dump($tree);
- if($depth==0)
- {
- $ambiguites = array("n"=>0, "refs"=>array());
- }
- switch($tree["CLASS"])
- {
- case "SIMPLE":
- case "QSIMPLE":
- $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"];
- $tab = "\n" . str_repeat("\t", $depth);
- if(isset($tree["PATH"]))
- {
- $path = $tree["PATH"];
- if(isset($tree["CONTEXT"]))
- $w .= " [" . $tree["CONTEXT"] . "]";
- $txt = $tab . "
";
- $txt .= $tab . "\t\"" . $w . "";
- // $txt .= $tab . "\t \"";
- $txt .= "\"";
- $txt .= $tab . " \n";
- }
- else
- {
- if(isset($tree["CONTEXT"]))
- $w .= "[" . $tree["CONTEXT"] . "]";
- if($tree["CLASS"] == "QSIMPLE")
- $txt = $tab . "\"" . $w . "\"\n";
- else
- $txt = $tab . "" . $w . "\n";
- }
-
- return($txt);
- break;
- case "PHRASEA_KW_ALL":
- return($tree["VALUE"][0]);
- break;
- case "PHRASEA_KW_LAST":
- if($tree["PNUM"]!==null)
-
- return("" . $tree["VALUE"][0] . "[" . $tree["PNUM"] . "]");
- else
-
- return($tree["VALUE"][0]);
- break;
- case "OPS":
- case "OPK":
- if(isset($tree["PNUM"]))
-
- return("(" . $this->_queryAsHTML($tree["LB"], $mouseCallback, $depth+1) . " " . $tree["VALUE"] . "[" . $tree["PNUM"] . "] " . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")");
- else
-
- return("(" . $this->_queryAsHTML($tree["LB"], $mouseCallback, $depth+1) . " " . $tree["VALUE"] . " " . $this->_queryAsHTML($tree["RB"], $mouseCallback, $depth+1) . ")");
- break;
- }
- }
- */
-
function setTids(&$tree, $bid, &$domthe, $searchsynonyms)
{
if ($this->debug)
@@ -841,8 +775,8 @@ class searchEngine_adapter_phrasea_queryParser
// $this->proposals["BASES"]["b$bid"] = array("BID"=>$bid, "TERMS"=>array());
$ambigus = 0;
- if (is_array($w = $tree["RB"]["VALUE"]))
- $t = $w = implode(" ", $w);
+ if (is_array($w = $tree["RB"]["VALUE"]))
+ $t = $w = implode(" ", $w);
if (isset($tree["CONTEXT"]))
{
@@ -873,7 +807,7 @@ class searchEngine_adapter_phrasea_queryParser
if ($this->debug)
printf("searching thesaurus with xpath='%s'
\n", $x);
- $dxp = new DOMXPath($domthe);
+ $dxp = new DOMXPath($domthe);
$nodes = $dxp->query($x);
if (!isset($tree["RB"]["SREF"]["TIDS"]))
@@ -897,7 +831,7 @@ class searchEngine_adapter_phrasea_queryParser
$this->addtoTIDS($tree["RB"], $bid, $node);
}
}
- $path = $tree["RB"]["SREF"]["PATH"];
+ $path = $tree["RB"]["SREF"]["PATH"];
$prophtml = "";
$this->propAsHTML($domthe->documentElement, $prophtml, $path);
$this->proposals["BASES"]["b$bid"]["TERMS"][$path]["HTML"] = $prophtml;
@@ -1007,12 +941,12 @@ class searchEngine_adapter_phrasea_queryParser
function addtoTIDS(&$extendednode, $bid, $DOMnode) // ajoute un tid en évitant les doublons
{
- $id = $DOMnode->getAttribute("id");
+ $id = $DOMnode->getAttribute("id");
$pid = $DOMnode->parentNode->getAttribute("id");
$lng = $DOMnode->getAttribute("lng");
- $w = $DOMnode->getAttribute("w");
- $k = $DOMnode->getAttribute("k");
- $p = $DOMnode->parentNode->getAttribute("v"); // le terme général (pére) du terme recherché : utile pour la levée d'ambiguité
+ $w = $DOMnode->getAttribute("w");
+ $k = $DOMnode->getAttribute("k");
+ $p = $DOMnode->parentNode->getAttribute("v"); // le terme général (pére) du terme recherché : utile pour la levée d'ambiguité
$path = $extendednode["SREF"]["PATH"];
if ($this->debug)
@@ -1042,7 +976,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
if (!$found)
- $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p);
+ $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p);
// on liste les propositions de thésaurus pour ce node (dans l'arbre simple)
if (!isset($this->proposals["BASES"]["b$bid"]["TERMS"][$path]))
@@ -1060,7 +994,7 @@ class searchEngine_adapter_phrasea_queryParser
// on marque le terme principal
$DOMnode->parentNode->setAttribute("term", "1");
// on commence par marquer les fils directs. rappel:$DOMnode pointe sur un sy
- for ($node = $DOMnode->parentNode->firstChild; $node; $node = $node->nextSibling)
+ for ($node = $DOMnode->parentNode->firstChild; $node; $node = $node->nextSibling)
{
if ($node->nodeName == "te")
{
@@ -1073,30 +1007,27 @@ class searchEngine_adapter_phrasea_queryParser
$id = $node->getAttribute("id");
if (!$id)
break; // on a dépassé la racine du thésaurus
- $node->setAttribute("marked", "1");
-// printf("<%s id='%s'
\n", $node->nodeName, $node->getAttribute("id"));
+ $node->setAttribute("marked", "1");
}
}
- function astext_ambigu($tree, &$ambiguites, $mouseCallback="void", $depth=0)
+ function astext_ambigu($tree, &$ambiguites, $mouseCallback = "void", $depth = 0)
{
- // printf("astext : ");
- // var_dump($tree);
if ($depth == 0)
{
- $ambiguites = array("n" => 0, "refs" => array());
+ $ambiguites = array("n" => 0, "refs" => array());
}
switch ($tree["CLASS"])
{
case "SIMPLE":
case "QSIMPLE":
- $prelink = $postlink = "";
- $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"];
- $tab = "\n" . str_repeat("\t", $depth);
+ $prelink = $postlink = "";
+ $w = is_array($tree["VALUE"]) ? implode(" ", $tree["VALUE"]) : $tree["VALUE"];
+ $tab = "\n" . str_repeat("\t", $depth);
if (isset($tree["TIDS"]) && count($tree["TIDS"]) > 1)
{
- $ambiguites["refs"][$n = $ambiguites["n"]] = &$tree;
- $txt = $tab . "
";
+ $ambiguites["refs"][$n = $ambiguites["n"]] = &$tree;
+ $txt = $tab . "";
$txt .= $tab . "\t\"" . $w . "";
$txt .= $tab . "\t \"";
$txt .= $tab . " \n";
@@ -1137,7 +1068,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- function get_ambigu(&$tree, $mouseCallback="void", $depth=0)
+ function get_ambigu(&$tree, $mouseCallback = "void", $depth = 0)
{
if (!$tree)
@@ -1155,14 +1086,14 @@ class searchEngine_adapter_phrasea_queryParser
if ($depth == 0)
{
$t_ambiguites = array();
- $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback));
+ $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback));
$t_ambiguites["query"] = $r;
return($t_ambiguites);
}
}
- function set_default(&$tree, &$emptyw, $depth=0)
+ function set_default(&$tree, &$emptyw, $depth = 0)
{
if (!$tree)
@@ -1202,7 +1133,7 @@ class searchEngine_adapter_phrasea_queryParser
}
if (is_array($tree["RB"]["VALUE"]))
{
- $lw = "";
+ $lw = "";
foreach ($tree["RB"]["VALUE"] as $w)
$lw .= ( $lw == "" ? "" : " ") . $w;
$tree["RB"]["VALUE"] = $lw;
@@ -1225,8 +1156,8 @@ class searchEngine_adapter_phrasea_queryParser
if (is_array($tree["VALUE"]))
{
$treetmp = null;
- $pnum = 0;
- for ($i = 0; $i < count($tree["VALUE"]); $i++)
+ $pnum = 0;
+ for ($i = 0; $i < count($tree["VALUE"]); $i++)
{
// gestion mot vide
if (isset($emptyw[$tree["VALUE"][$i]]) || $tree["VALUE"][$i] == "?" || $tree["VALUE"][$i] == "*")
@@ -1238,35 +1169,35 @@ class searchEngine_adapter_phrasea_queryParser
{
if ($treetmp == null)
{
- $treetmp = array("CLASS" => $tree["CLASS"],
- "NODETYPE" => $tree["NODETYPE"],
- "VALUE" => $tree["VALUE"][$i],
- "PNUM" => $tree["PNUM"],
- "DEPTH" => $tree["DEPTH"]);
- $pnum = 0;
+ $treetmp = array("CLASS" => $tree["CLASS"],
+ "NODETYPE" => $tree["NODETYPE"],
+ "VALUE" => $tree["VALUE"][$i],
+ "PNUM" => $tree["PNUM"],
+ "DEPTH" => $tree["DEPTH"]);
+ $pnum = 0;
}
else
{
- $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop;
- $treetmp = array("CLASS" => "OPS",
- "VALUE" => $dop["VALUE"],
- "NODETYPE" => $dop["NODETYPE"],
- "PNUM" => $pnum, // peut-être écrasé par defaultop
- "DEPTH" => $depth,
- "LB" => $treetmp,
- "RB" => array("CLASS" => $tree["CLASS"],
- "NODETYPE" => $tree["NODETYPE"],
- "VALUE" => $tree["VALUE"][$i],
- "PNUM" => $tree["PNUM"],
- "DEPTH" => $tree["DEPTH"])
+ $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop;
+ $treetmp = array("CLASS" => "OPS",
+ "VALUE" => $dop["VALUE"],
+ "NODETYPE" => $dop["NODETYPE"],
+ "PNUM" => $pnum, // peut-être écrasé par defaultop
+ "DEPTH" => $depth,
+ "LB" => $treetmp,
+ "RB" => array("CLASS" => $tree["CLASS"],
+ "NODETYPE" => $tree["NODETYPE"],
+ "VALUE" => $tree["VALUE"][$i],
+ "PNUM" => $tree["PNUM"],
+ "DEPTH" => $tree["DEPTH"])
);
if (array_key_exists("PNUM", $dop))
$treetmp["PNUM"] = $dop["PNUM"];
- $pnum = 0;
+ $pnum = 0;
}
}
}
- $tree = $treetmp;
+ $tree = $treetmp;
}
}
}
@@ -1281,18 +1212,16 @@ class searchEngine_adapter_phrasea_queryParser
while ($n > 0);
}
- function factor_or2(&$tree, $depth=0)
+ function factor_or2(&$tree, $depth = 0)
{
- // printf("factor_or depth=%s sur ", $depth);
- // var_dump($tree);
$nmodif = 0;
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
{
if ($tree["NODETYPE"] == PHRASEA_OP_OR && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE") && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE"))
{
- $tree["CLASS"] = "SIMPLE";
+ $tree["CLASS"] = "SIMPLE";
$tree["NODETYPE"] = PHRASEA_KEYLIST;
- $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]);
+ $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]);
if (is_array($tree["RB"]["VALUE"]))
{
foreach ($tree["RB"]["VALUE"] as $v)
@@ -1302,11 +1231,8 @@ class searchEngine_adapter_phrasea_queryParser
$tree["VALUE"][] = $tree["RB"]["VALUE"];
unset($tree["LB"]);
unset($tree["RB"]);
- // unset($tree["NODETYPE"]);
unset($tree["PNUM"]);
$nmodif++;
- // printf("donne ");
- // var_dump($tree);
}
else
{
@@ -1314,13 +1240,12 @@ class searchEngine_adapter_phrasea_queryParser
$nmodif += $this->factor_or2($tree["RB"], $depth + 1);
}
}
- // printf(" return %s ", $nmodif);
+
return($nmodif);
}
- function setNumValue(&$tree, SimpleXMLElement $sxml_struct, $depth=0)
+ function setNumValue(&$tree, SimpleXMLElement $sxml_struct, $depth = 0)
{
- // var_dump($tree);
if ($tree["CLASS"] == "OPK")
{
if (isset($tree["RB"]) && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE") && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE"))
@@ -1371,50 +1296,43 @@ class searchEngine_adapter_phrasea_queryParser
## creation branche gauche avec ">="
// print("changeNodeEquals2\n");
// print("creation branche gauche ( '>=' ) \n");
- $newTreeLB = array("CLASS" => "OPK",
- "VALUE" => ">=",
- "NODETYPE" => PHRASEA_OP_GEQT,
- "PNUM" => NULL,
- "DEPTH" => 0,
- "LB" => $oneBranch["LB"],
- "RB" => array("CLASS" => "SIMPLE",
- "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false),
- "NODETYPE" => PHRASEA_KEYLIST,
- "PNUM" => NULL,
- "DEPTH" => 0)
+ $newTreeLB = array("CLASS" => "OPK",
+ "VALUE" => ">=",
+ "NODETYPE" => PHRASEA_OP_GEQT,
+ "PNUM" => NULL,
+ "DEPTH" => 0,
+ "LB" => $oneBranch["LB"],
+ "RB" => array("CLASS" => "SIMPLE",
+ "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false),
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "PNUM" => NULL,
+ "DEPTH" => 0)
);
-// var_dump($newTreeLB);
-// print("fin creation branche gauche ( '>=' ) \n");
- ## fin creation branche gauche ( ">=" )
- ## creation branche droite avec "<="
-// print("creation branche droite avec '<=' \n");
- $newTreeRB = array("CLASS" => "OPK",
- "VALUE" => "<=",
- "NODETYPE" => PHRASEA_OP_LEQT,
- "PNUM" => NULL,
- "DEPTH" => 0,
- "LB" => $oneBranch["LB"],
- "RB" => array("CLASS" => "SIMPLE",
- "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true),
- "NODETYPE" => PHRASEA_KEYLIST,
- "PNUM" => NULL,
- "DEPTH" => 0)
+
+ $newTreeRB = array("CLASS" => "OPK",
+ "VALUE" => "<=",
+ "NODETYPE" => PHRASEA_OP_LEQT,
+ "PNUM" => NULL,
+ "DEPTH" => 0,
+ "LB" => $oneBranch["LB"],
+ "RB" => array("CLASS" => "SIMPLE",
+ "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true),
+ "NODETYPE" => PHRASEA_KEYLIST,
+ "PNUM" => NULL,
+ "DEPTH" => 0)
);
-// var_dump($newTreeRB);
// print("fin creation branche droite avec '<=' \n");
## fin creation branche droite ( "<=" )
- $tree = array("CLASS" => "OPS",
- "VALUE" => "et",
- "NODETYPE" => PHRASEA_OP_AND,
- "PNUM" => NULL,
- "DEPTH" => 0,
- "LB" => $newTreeLB,
- "RB" => $newTreeRB);
+ $tree = array("CLASS" => "OPS",
+ "VALUE" => "et",
+ "NODETYPE" => PHRASEA_OP_AND,
+ "PNUM" => NULL,
+ "DEPTH" => 0,
+ "LB" => $newTreeLB,
+ "RB" => $newTreeRB);
- // et on le retourne
-// var_dump($tree);
return $tree;
}
@@ -1422,23 +1340,23 @@ class searchEngine_adapter_phrasea_queryParser
{
if (strtoupper($type) == strtoupper("Date"))
{
- $dateEnIso = $this->isoDate($branch["VALUE"]);
+ $dateEnIso = $this->isoDate($branch["VALUE"]);
$branch["VALUE"] = $dateEnIso;
}
}
- function isoDate($onedate, $max=false)
+ function isoDate($onedate, $max = false)
{
$v_y = "1900";
$v_m = "01";
$v_d = "01";
- $v_h = $v_minutes = $v_s = "00";
+ $v_h = $v_minutes = $v_s = "00";
if ($max)
{
- $v_h = $v_minutes = $v_s = "99";
+ $v_h = $v_minutes = $v_s = "99";
}
- $tmp = $onedate;
+ $tmp = $onedate;
if (!is_array($tmp))
$tmp = explode(" ", $tmp);
@@ -1519,31 +1437,31 @@ class searchEngine_adapter_phrasea_queryParser
{
case 14 :
// date iso YYYYMMDDHHMMSS
- $v_y = substr($tmp[0], 0, 4);
- $v_m = substr($tmp[0], 4, 2);
- $v_d = substr($tmp[0], 6, 2);
- $v_h = substr($tmp[0], 8, 2);
+ $v_y = substr($tmp[0], 0, 4);
+ $v_m = substr($tmp[0], 4, 2);
+ $v_d = substr($tmp[0], 6, 2);
+ $v_h = substr($tmp[0], 8, 2);
$v_minutes = substr($tmp[0], 10, 2);
- $v_s = substr($tmp[0], 12, 2);
+ $v_s = substr($tmp[0], 12, 2);
break;
case 8 :
// date iso YYYYMMDD
- $v_y = substr($tmp[0], 0, 4);
- $v_m = substr($tmp[0], 4, 2);
- $v_d = substr($tmp[0], 6, 2);
+ $v_y = substr($tmp[0], 0, 4);
+ $v_m = substr($tmp[0], 4, 2);
+ $v_d = substr($tmp[0], 6, 2);
break;
case 6 :
// date iso YYYYMM
- $v_y = substr($tmp[0], 0, 4);
- $v_m = substr($tmp[0], 4, 2);
+ $v_y = substr($tmp[0], 0, 4);
+ $v_m = substr($tmp[0], 4, 2);
if ($max)
- $v_d = "99";
+ $v_d = "99";
else
- $v_d = "00";
+ $v_d = "00";
break;
case 4 :
// date iso YYYY
- $v_y = $tmp[0];
+ $v_y = $tmp[0];
if ($max)
$v_m = "99";
@@ -1582,11 +1500,9 @@ class searchEngine_adapter_phrasea_queryParser
return("" . $v_y . $v_m . $v_d . $v_h . $v_minutes . $v_s);
}
- function distrib_in(&$tree, $depth=0)
+ function distrib_in(&$tree, $depth = 0)
{
$opdistrib = array(PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER); // ces opérateurs sont 'distribuables' autour d'un 'IN'
- // printf("distrib_in depth=%s sur ", $depth);
- // var_dump($tree);
if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK")
{
@@ -1606,25 +1522,24 @@ class searchEngine_adapter_phrasea_queryParser
$m_o = $tree["NODETYPE"];
$m_n = $tree["PNUM"];
- $tree["CLASS"] = $tree["LB"]["CLASS"];
+ $tree["CLASS"] = $tree["LB"]["CLASS"];
$tree["NODETYPE"] = $tree["LB"]["NODETYPE"];
- $tree["VALUE"] = $tree["LB"]["VALUE"];
- $tree["PNUM"] = $tree["LB"]["PNUM"];
+ $tree["VALUE"] = $tree["LB"]["VALUE"];
+ $tree["PNUM"] = $tree["LB"]["PNUM"];
- $tree["LB"]["CLASS"] = $m_t;
+ $tree["LB"]["CLASS"] = $m_t;
$tree["LB"]["NODETYPE"] = $m_o;
- $tree["LB"]["VALUE"] = $m_v;
- $tree["LB"]["PNUM"] = $m_n;
+ $tree["LB"]["VALUE"] = $m_v;
+ $tree["LB"]["PNUM"] = $m_n;
- $tree["RB"] = array("CLASS" => $m_t,
- "NODETYPE" => $m_o,
- "VALUE" => $m_v,
- "PNUM" => $m_n,
- "LB" => $tree["LB"]["RB"],
- "RB" => $tree["RB"]);
+ $tree["RB"] = array("CLASS" => $m_t,
+ "NODETYPE" => $m_o,
+ "VALUE" => $m_v,
+ "PNUM" => $m_n,
+ "LB" => $tree["LB"]["RB"],
+ "RB" => $tree["RB"]);
$tree["LB"]["RB"] = $tree["RB"]["RB"];
- // var_dump($tree);
// return;
}
@@ -1639,22 +1554,22 @@ class searchEngine_adapter_phrasea_queryParser
$m_o = $tree["NODETYPE"];
$m_n = $tree["PNUM"];
- $tree["CLASS"] = $tree["RB"]["CLASS"];
+ $tree["CLASS"] = $tree["RB"]["CLASS"];
$tree["NODETYPE"] = $tree["RB"]["NODETYPE"];
- $tree["VALUE"] = $tree["RB"]["VALUE"];
- $tree["PNUM"] = $tree["RB"]["PNUM"];
+ $tree["VALUE"] = $tree["RB"]["VALUE"];
+ $tree["PNUM"] = $tree["RB"]["PNUM"];
- $tree["RB"]["CLASS"] = $m_t;
+ $tree["RB"]["CLASS"] = $m_t;
$tree["RB"]["NODETYPE"] = $m_o;
- $tree["RB"]["VALUE"] = $m_v;
- $tree["RB"]["PNUM"] = $m_n;
+ $tree["RB"]["VALUE"] = $m_v;
+ $tree["RB"]["PNUM"] = $m_n;
- $tree["LB"] = array("CLASS" => $m_t,
- "NODETYPE" => $m_o,
- "VALUE" => $m_v,
- "PNUM" => $m_n,
- "LB" => $tree["LB"],
- "RB" => $tree["RB"]["LB"]);
+ $tree["LB"] = array("CLASS" => $m_t,
+ "NODETYPE" => $m_o,
+ "VALUE" => $m_v,
+ "PNUM" => $m_n,
+ "LB" => $tree["LB"],
+ "RB" => $tree["RB"]["LB"]);
$tree["RB"]["LB"] = $tree["LB"]["LB"];
}
@@ -1711,7 +1626,7 @@ class searchEngine_adapter_phrasea_queryParser
{
// printf("\n\n");
$tree = null;
- while ($t = $this->nexttoken($inquote))
+ while ($t = $this->nexttoken($inquote))
{
if ($this->debug)
printf("got token %s of class %s\n", $t["VALUE"], $t["CLASS"]);
@@ -1759,18 +1674,18 @@ class searchEngine_adapter_phrasea_queryParser
{
$tree["RB"] = $this->maketree($depth + 1);
if (!$tree["RB"])
- $tree = null;
+ $tree = null;
}
else
{
// ici on applique l'opérateur par défaut
- $tree = array("CLASS" => "OPS",
- "VALUE" => $this->defaultop["VALUE"],
- "NODETYPE" => $this->defaultop["NODETYPE"],
- "PNUM" => $this->defaultop["PNUM"],
- "DEPTH" => $depth,
- "LB" => $tree,
- "RB" => $this->maketree($depth + 1));
+ $tree = array("CLASS" => "OPS",
+ "VALUE" => $this->defaultop["VALUE"],
+ "NODETYPE" => $this->defaultop["NODETYPE"],
+ "PNUM" => $this->defaultop["PNUM"],
+ "DEPTH" => $depth,
+ "LB" => $tree,
+ "RB" => $this->maketree($depth + 1));
}
}
if (!$tree)
@@ -1816,18 +1731,18 @@ class searchEngine_adapter_phrasea_queryParser
{
$tree["RB"] = $this->maketree($depth + 1, true);
if (!$tree["RB"])
- $tree = null;
+ $tree = null;
}
else
{
// ici on applique l'opérateur par défaut
- $tree = array("CLASS" => "OPS",
- "VALUE" => $this->defaultop["VALUE"],
- "NODETYPE" => $this->defaultop["NODETYPE"],
- "PNUM" => $this->defaultop["PNUM"],
- "DEPTH" => $depth,
- "LB" => $tree,
- "RB" => $this->maketree($depth + 1, true));
+ $tree = array("CLASS" => "OPS",
+ "VALUE" => $this->defaultop["VALUE"],
+ "NODETYPE" => $this->defaultop["NODETYPE"],
+ "PNUM" => $this->defaultop["PNUM"],
+ "DEPTH" => $depth,
+ "LB" => $tree,
+ "RB" => $this->maketree($depth + 1, true));
}
}
if (!$tree)
@@ -1879,7 +1794,6 @@ class searchEngine_adapter_phrasea_queryParser
// if($this->debug)
// {
// printf("addtotree({tree}, \$t='%s', \$depth=%d, inquote=%s)\n", $t["VALUE"], $depth, $inquote?"true":"false");
-// var_dump($tree);
// }
if ($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE")
{
@@ -1940,7 +1854,7 @@ class searchEngine_adapter_phrasea_queryParser
return(null);
}
- return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null));
+ return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null));
break;
case "TOK_WORD":
if ($t["CLASS"] == "TOK_WORD" && isset($this->ops[$t["VALUE"]]) && !$inquote)
@@ -1978,17 +1892,17 @@ class searchEngine_adapter_phrasea_queryParser
}
}
- return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null));
+ return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null));
}
else
{
// ce mot n'est pas un opérateur
- $pnum = null;
+ $pnum = null;
$nodetype = PHRASEA_KEYLIST;
if ($t["CLASS"] == "TOK_WORD" && isset($this->spw[$t["VALUE"]]) && !$inquote)
{
// mais c'est un mot 'spécial' de phrasea ('last', 'all')
- $type = $this->spw[$t["VALUE"]]["CLASS"];
+ $type = $this->spw[$t["VALUE"]]["CLASS"];
$nodetype = $this->spw[$t["VALUE"]]["NODETYPE"];
if ($this->spw[$t["VALUE"]]["CANNUM"])
{
@@ -2016,9 +1930,9 @@ class searchEngine_adapter_phrasea_queryParser
function addsimple($t, $type, $nodetype, $pnum, $tree, $depth)
{
- $nok = 0;
+ $nok = 0;
$registry = registry::get_instance();
- $w = $t["VALUE"];
+ $w = $t["VALUE"];
if ($w != "?" && $w != "*") // on laisse passer les 'isolés' pour les traiter plus tard comme des mots vides
{
for ($i = 0; $i < strlen($w); $i++)
@@ -2042,7 +1956,7 @@ class searchEngine_adapter_phrasea_queryParser
}
if (!$tree)
{
- return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth));
+ return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth));
}
switch ($tree["CLASS"])
{
@@ -2052,17 +1966,17 @@ class searchEngine_adapter_phrasea_queryParser
$tree["VALUE"][] = $t["VALUE"];
else
{
- $tree = array("CLASS" => "OPS",
- "VALUE" => "et",
- "NODETYPE" => PHRASEA_OP_AND,
- "PNUM" => null,
- "DEPTH" => $depth,
- "LB" => $tree,
- "RB" => array("CLASS" => $type,
- "NODETYPE" => $nodetype,
- "VALUE" => array($t["VALUE"]),
- "PNUM" => $pnum,
- "DEPTH" => $depth));
+ $tree = array("CLASS" => "OPS",
+ "VALUE" => "et",
+ "NODETYPE" => PHRASEA_OP_AND,
+ "PNUM" => null,
+ "DEPTH" => $depth,
+ "LB" => $tree,
+ "RB" => array("CLASS" => $type,
+ "NODETYPE" => $nodetype,
+ "VALUE" => array($t["VALUE"]),
+ "PNUM" => $pnum,
+ "DEPTH" => $depth));
}
return($tree);
@@ -2070,7 +1984,7 @@ class searchEngine_adapter_phrasea_queryParser
case "OPK":
if ($tree["RB"] == null)
{
- $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth);
+ $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth);
return($tree);
}
@@ -2084,43 +1998,43 @@ class searchEngine_adapter_phrasea_queryParser
}
if (($tree["RB"]["CLASS"] == "PHRASEA_KW_LAST" || $tree["RB"]["CLASS"] == "PHRASEA_KW_ALL") && $tree["RB"]["DEPTH"] == $depth)
{
- $tree["RB"] = array("CLASS" => "OPS",
- "VALUE" => "et",
- "NODETYPE" => PHRASEA_OP_AND,
- "PNUM" => null,
- "DEPTH" => $depth,
- "LB" => $tree["RB"],
- "RB" => array("CLASS" => $type,
- "NODETYPE" => $nodetype,
- "VALUE" => array($t["VALUE"]),
- "PNUM" => $pnum,
- "DEPTH" => $depth));
+ $tree["RB"] = array("CLASS" => "OPS",
+ "VALUE" => "et",
+ "NODETYPE" => PHRASEA_OP_AND,
+ "PNUM" => null,
+ "DEPTH" => $depth,
+ "LB" => $tree["RB"],
+ "RB" => array("CLASS" => $type,
+ "NODETYPE" => $nodetype,
+ "VALUE" => array($t["VALUE"]),
+ "PNUM" => $pnum,
+ "DEPTH" => $depth));
return($tree);
}
- return(array("CLASS" => "OPS",
- "VALUE" => $this->defaultop["VALUE"],
- "NODETYPE" => $this->defaultop["NODETYPE"],
- "PNUM" => $this->defaultop["PNUM"],
- "DEPTH" => $depth,
- "LB" => $tree,
- "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)
- ));
+ return(array("CLASS" => "OPS",
+ "VALUE" => $this->defaultop["VALUE"],
+ "NODETYPE" => $this->defaultop["NODETYPE"],
+ "PNUM" => $this->defaultop["PNUM"],
+ "DEPTH" => $depth,
+ "LB" => $tree,
+ "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)
+ ));
}
case "PHRASEA_KW_LAST":
case "PHRASEA_KW_ALL":
- return(array("CLASS" => "OPS",
- "VALUE" => "et",
- "NODETYPE" => PHRASEA_OP_AND,
- "PNUM" => null,
- "DEPTH" => $depth,
- "LB" => $tree,
- "RB" => array("CLASS" => $type,
- "NODETYPE" => $nodetype,
- "VALUE" => array($t["VALUE"]),
- "PNUM" => $pnum,
- "DEPTH" => $depth)));
+ return(array("CLASS" => "OPS",
+ "VALUE" => "et",
+ "NODETYPE" => PHRASEA_OP_AND,
+ "PNUM" => null,
+ "DEPTH" => $depth,
+ "LB" => $tree,
+ "RB" => array("CLASS" => $type,
+ "NODETYPE" => $nodetype,
+ "VALUE" => array($t["VALUE"]),
+ "PNUM" => $pnum,
+ "DEPTH" => $depth)));
}
}
@@ -2129,7 +2043,7 @@ class searchEngine_adapter_phrasea_queryParser
$this->phq = $s . " " . $this->phq;
}
- function nexttoken($inquote=false)
+ function nexttoken($inquote = false)
{
if ($this->phq == "")
@@ -2144,7 +2058,7 @@ class searchEngine_adapter_phrasea_queryParser
return(array("CLASS" => "TOK_VOID", "VALUE" => $c));
}
- $c2 = $c . substr($this->phq, 1, 1);
+ $c2 = $c . substr($this->phq, 1, 1);
if ($c2 == "<=" || $c2 == ">=" || $c2 == "<>")
{
$this->phq = $this->mb_ltrim(mb_substr($this->phq, 2, 99999, 'UTF-8'), 'UTF-8');
@@ -2241,10 +2155,10 @@ class searchEngine_adapter_phrasea_queryParser
return(array("CLASS" => "TOK_QUOTE", "VALUE" => "\""));
break;
default:
- $l = mb_strlen($this->phq, 'UTF-8');
- $t = "";
+ $l = mb_strlen($this->phq, 'UTF-8');
+ $t = "";
$c_utf8 = "";
- for ($i = 0; $i < $l; $i++)
+ for ($i = 0; $i < $l; $i++)
{
if (!$this->unicode->has_indexer_bad_char(($c_utf8 = mb_substr($this->phq, $i, 1, 'UTF-8'))))
{
diff --git a/lib/classes/searchEngine/adapter/sphinx/engine.class.php b/lib/classes/searchEngine/adapter/sphinx/engine.class.php
index 048236b7d9..d2e32aefa4 100644
--- a/lib/classes/searchEngine/adapter/sphinx/engine.class.php
+++ b/lib/classes/searchEngine/adapter/sphinx/engine.class.php
@@ -1,6 +1,6 @@
= 0);
assert(is_int($perPage));
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$page = ceil($offset / $perPage) + 1;
@@ -511,7 +511,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
if (!$this->current_index)
$this->current_index = '*';
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$supposed_qry = mb_strtolower($this->query);
$pieces = explode(" ", str_replace(array("all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-"), ' ', $supposed_qry));
@@ -689,7 +689,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
*/
public function build_excerpt($query, array $fields, record_adapter $record)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$selected_sbas_id = $record->get_sbas_id();
diff --git a/lib/classes/searchEngine/results.class.php b/lib/classes/searchEngine/results.class.php
index 7b10634586..55046d1788 100644
--- a/lib/classes/searchEngine/results.class.php
+++ b/lib/classes/searchEngine/results.class.php
@@ -121,7 +121,7 @@ class searchEngine_results
*/
public function get_suggestions()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
return $this->engine->get_suggestions($session);
diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php
index f98c3519f5..ee1290786b 100644
--- a/lib/classes/set/export.class.php
+++ b/lib/classes/set/export.class.php
@@ -34,27 +34,42 @@ class set_export extends set_abstract
* @param int $sstid
* @return set_export
*/
- public function __construct($lst, $sstid)
+ public function __construct($lst, $sstid, $storyWZid = null)
{
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ $Core = bootstrap::getCore();
+
+ $appbox = appbox::get_instance($Core);
+ $session = $appbox->get_session();
$registry = $appbox->get_registry();
-
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $user = $Core->getAuthenticatedUser();
$download_list = array();
$remain_hd = array();
+ if ($storyWZid)
+ {
+ $repository = $Core->getEntityManager()->getRepository('\\Entities\\StoryWZ');
+
+ $storyWZ = $repository->findByUserAndId($user, $storyWZid);
+
+ $lst = $storyWZ->getRecord()->get_serialize_key();
+ }
+
if ($sstid != "")
{
- $basket = basket_adapter::getInstance($appbox, $sstid, $user->get_id());
+ $em = $Core->getEntityManager();
+ $repository = $em->getRepository('\Entities\Basket');
- foreach ($basket->get_elements() as $basket_element)
+ /* @var $repository \Repositories\BasketRepository */
+ $Basket = $repository->findUserBasket($sstid, $user, false);
+
+ foreach ($Basket->getElements() as $basket_element)
{
- $base_id = $basket_element->get_record()->get_base_id();
- $record_id = $basket_element->get_record()->get_record_id();
+ /* @var $basket_element \Entities\BasketElement */
+ $base_id = $basket_element->getRecord()->get_base_id();
+ $record_id = $basket_element->getRecord()->get_record_id();
if (!isset($remain_hd[$base_id]))
{
@@ -69,11 +84,11 @@ class set_export extends set_abstract
}
$current_element = $download_list[] =
- new record_exportElement(
- $basket_element->get_record()->get_sbas_id(),
- $record_id,
- $basket->get_name() . '/',
- $remain_hd[$base_id]
+ new record_exportElement(
+ $basket_element->getRecord()->get_sbas_id(),
+ $record_id,
+ $Basket->getName() . '/',
+ $remain_hd[$base_id]
);
$remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -82,7 +97,7 @@ class set_export extends set_abstract
else
{
$tmp_lst = explode(';', $lst);
- $n = 1;
+ $n = 1;
foreach ($tmp_lst as $basrec)
{
$basrec = explode('_', $basrec);
@@ -100,11 +115,9 @@ class set_export extends set_abstract
if ($record->is_grouping())
{
- $regfield = basket_adapter::getRegFields($basrec[0], $record->get_caption());
-
foreach ($record->get_children() as $child_basrec)
{
- $base_id = $child_basrec->get_base_id();
+ $base_id = $child_basrec->get_base_id();
$record_id = $child_basrec->get_record_id();
if (!isset($remain_hd[$base_id]))
@@ -112,7 +125,7 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id))
{
$remain_hd[$base_id] =
- $user->ACL()->remaining_download($base_id);
+ $user->ACL()->remaining_download($base_id);
}
else
{
@@ -121,11 +134,11 @@ class set_export extends set_abstract
}
$current_element = $download_list[] =
- new record_exportElement(
- $child_basrec->get_sbas_id(),
- $record_id,
- $regfield['regname'] . '_' . $n . '/',
- $remain_hd[$base_id]
+ new record_exportElement(
+ $child_basrec->get_sbas_id(),
+ $record_id,
+ $record->get_title() . '_' . $n . '/',
+ $remain_hd[$base_id]
);
$remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -133,7 +146,7 @@ class set_export extends set_abstract
}
else
{
- $base_id = $record->get_base_id();
+ $base_id = $record->get_base_id();
$record_id = $record->get_record_id();
if (!isset($remain_hd[$base_id]))
@@ -141,7 +154,7 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id))
{
$remain_hd[$base_id] =
- $user->ACL()->remaining_download($base_id);
+ $user->ACL()->remaining_download($base_id);
}
else
{
@@ -149,13 +162,13 @@ class set_export extends set_abstract
}
}
- $current_element =
- $download_list[$basrec[0] . '_' . $basrec[1]] =
- new record_exportElement(
- $record->get_sbas_id(),
- $record_id,
- '',
- $remain_hd[$base_id]
+ $current_element =
+ $download_list[$basrec[0] . '_' . $basrec[1]] =
+ new record_exportElement(
+ $record->get_sbas_id(),
+ $record_id,
+ '',
+ $remain_hd[$base_id]
);
$remain_hd[$base_id] = $current_element->get_remain_hd();
@@ -180,10 +193,10 @@ class set_export extends set_abstract
if (!isset($display_download[$name]))
{
$display_download[$name] = array(
- 'size' => 0,
- 'total' => 0,
- 'available' => 0,
- 'refused' => array()
+ 'size' => 0,
+ 'total' => 0,
+ 'available' => 0,
+ 'refused' => array()
);
}
@@ -195,12 +208,12 @@ class set_export extends set_abstract
$display_download[$name]['label'] = $properties['label'];
$this->total_download++;
$display_download[$name]['size'] +=
- $download_element->get_size($name);
+ $download_element->get_size($name);
}
else
{
$display_download[$name]['refused'][] =
- $download_element->get_thumbnail();
+ $download_element->get_thumbnail();
}
}
foreach ($download_element->get_orderable() as $name => $properties)
@@ -208,9 +221,9 @@ class set_export extends set_abstract
if (!isset($display_orderable[$name]))
{
$display_orderable[$name] = array(
- 'total' => 0,
- 'available' => 0,
- 'refused' => array()
+ 'total' => 0,
+ 'available' => 0,
+ 'refused' => array()
);
}
@@ -224,7 +237,7 @@ class set_export extends set_abstract
else
{
$display_orderable[$name]['refused'][] =
- $download_element->get_thumbnail();
+ $download_element->get_thumbnail();
}
}
}
@@ -237,10 +250,10 @@ class set_export extends set_abstract
$display_ftp = array();
$hasadminright = $user->ACL()->has_right('addrecord')
- || $user->ACL()->has_right('deleterecord')
- || $user->ACL()->has_right('modifyrecord')
- || $user->ACL()->has_right('coll_manage')
- || $user->ACL()->has_right('coll_modify_struct');
+ || $user->ACL()->has_right('deleterecord')
+ || $user->ACL()->has_right('modifyrecord')
+ || $user->ACL()->has_right('coll_manage')
+ || $user->ACL()->has_right('coll_modify_struct');
$this->ftp_datas = array();
@@ -253,7 +266,7 @@ class set_export extends set_abstract
if ($hasadminright)
{
- $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
+ $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
usr.pwdFTP,usr.destFTP,prefixFTPfolder,usr.passifFTP,
usr.retryFTP,usr.usr_mail
FROM (usr INNER JOIN basusr
@@ -269,7 +282,7 @@ class set_export extends set_abstract
}
elseif ($registry->get('GV_ftp_for_user'))
{
- $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
+ $sql = "SELECT usr.usr_id,usr_login,usr.addrFTP,usr.loginFTP,usr.sslFTP,
usr.pwdFTP,usr.destFTP,prefixFTPfolder,
usr.passifFTP,usr.retryFTP,usr.usr_mail
FROM (usr INNER JOIN basusr
@@ -285,43 +298,43 @@ class set_export extends set_abstract
}
$datas[] = array(
- 'name' => _('export::ftp: reglages manuels'),
- 'usr_id' => '0',
- 'addrFTP' => '',
- 'loginFTP' => '',
- 'pwdFTP' => '',
- 'ssl' => '0',
- 'destFTP' => '',
- 'prefixFTPfolder' => 'Export_' . date("Y-m-d_H.i.s"),
- 'passifFTP' => false,
- 'retryFTP' => 5,
- 'mailFTP' => '',
- 'sendermail' => $user->get_email()
+ 'name' => _('export::ftp: reglages manuels'),
+ 'usr_id' => '0',
+ 'addrFTP' => '',
+ 'loginFTP' => '',
+ 'pwdFTP' => '',
+ 'ssl' => '0',
+ 'destFTP' => '',
+ 'prefixFTPfolder' => 'Export_' . date("Y-m-d_H.i.s"),
+ 'passifFTP' => false,
+ 'retryFTP' => 5,
+ 'mailFTP' => '',
+ 'sendermail' => $user->get_email()
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row)
{
$datas[] = array(
- 'name' => $row["usr_login"],
- 'usr_id' => $row['usr_id'],
- 'addrFTP' => $row['addrFTP'],
- 'loginFTP' => $row['loginFTP'],
- 'pwdFTP' => $row['pwdFTP'],
- 'ssl' => $row['sslFTP'],
- 'destFTP' => $row['destFTP'],
- 'prefixFTPfolder' =>
- (strlen(trim($row['prefixFTPfolder'])) > 0 ?
- trim($row['prefixFTPfolder']) :
- 'Export_' . date("Y-m-d_H.i.s")),
- 'passifFTP' => ($row['passifFTP'] > 0),
- 'retryFTP' => $row['retryFTP'],
- 'mailFTP' => $row['usr_mail'],
- 'sendermail' => $user->get_email()
+ 'name' => $row["usr_login"],
+ 'usr_id' => $row['usr_id'],
+ 'addrFTP' => $row['addrFTP'],
+ 'loginFTP' => $row['loginFTP'],
+ 'pwdFTP' => $row['pwdFTP'],
+ 'ssl' => $row['sslFTP'],
+ 'destFTP' => $row['destFTP'],
+ 'prefixFTPfolder' =>
+ (strlen(trim($row['prefixFTPfolder'])) > 0 ?
+ trim($row['prefixFTPfolder']) :
+ 'Export_' . date("Y-m-d_H.i.s")),
+ 'passifFTP' => ($row['passifFTP'] > 0),
+ 'retryFTP' => $row['retryFTP'],
+ 'mailFTP' => $row['usr_mail'],
+ 'sendermail' => $user->get_email()
);
}
@@ -411,8 +424,8 @@ class set_export extends set_abstract
{
throw new Exception('No subdefs given');
}
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
+ $session = $appbox->get_session();
$registry = $appbox->get_registry();
$unicode = new unicode();
@@ -431,11 +444,11 @@ class set_export extends set_abstract
$id = count($files);
$files[$id] = array(
- 'base_id' => $download_element->get_base_id(),
- 'record_id' => $download_element->get_record_id(),
- 'original_name' => '',
- 'export_name' => '',
- 'subdefs' => array()
+ 'base_id' => $download_element->get_base_id(),
+ 'record_id' => $download_element->get_record_id(),
+ 'original_name' => '',
+ 'export_name' => '',
+ 'subdefs' => array()
);
$sbas_id = phrasea::sbasFromBas($download_element->get_base_id());
@@ -445,12 +458,12 @@ class set_export extends set_abstract
$desc = $download_element->get_xml();
$files[$id]['original_name'] =
- $files[$id]['export_name'] =
- $download_element->get_original_name();
+ $files[$id]['export_name'] =
+ $download_element->get_original_name();
$files[$id]['original_name'] =
- trim($files[$id]['original_name']) != '' ?
- $files[$id]['original_name'] : $id;
+ trim($files[$id]['original_name']) != '' ?
+ $files[$id]['original_name'] : $id;
$infos = pathinfo($files[$id]['original_name']);
@@ -462,7 +475,7 @@ class set_export extends set_abstract
$title = strip_tags($download_element->get_title());
$files[$id]['export_name'] = $unicode->remove_nonazAZ09($title, true);
- $rename_done = true;
+ $rename_done = true;
}
else
{
@@ -470,7 +483,7 @@ class set_export extends set_abstract
}
$sizeMaxAjout = 0;
- $sizeMaxExt = 0;
+ $sizeMaxExt = 0;
$sd = $download_element->get_subdefs();
@@ -486,7 +499,7 @@ class set_export extends set_abstract
}
set_time_limit(100);
- $subdef_export = $subdef_alive = false;
+ $subdef_export = $subdef_alive = false;
$n_files++;
@@ -497,32 +510,32 @@ class set_export extends set_abstract
case 'caption':
case 'caption-yaml':
$subdef_export = true;
- $subdef_alive = true;
+ $subdef_alive = true;
break;
case 'thumbnail':
- $tmp_pathfile = array(
- 'path' => $sd[$name]->get_path()
- , 'file' => $sd[$name]->get_file()
+ $tmp_pathfile = array(
+ 'path' => $sd[$name]->get_path()
+ , 'file' => $sd[$name]->get_file()
);
$subdef_export = true;
- $subdef_alive = true;
+ $subdef_alive = true;
break;
case 'document':
$subdef_export = true;
- $path = recordutils_image::stamp(
- $download_element->get_base_id()
- , $download_element->get_record_id()
- , true
+ $path = recordutils_image::stamp(
+ $download_element->get_base_id()
+ , $download_element->get_record_id()
+ , true
);
- $tmp_pathfile = array(
- 'path' => $sd[$name]->get_path()
- , 'file' => $sd[$name]->get_file()
+ $tmp_pathfile = array(
+ 'path' => $sd[$name]->get_path()
+ , 'file' => $sd[$name]->get_file()
);
if (file_exists($path))
{
$tmp_pathfile = array(
- 'path' => dirname($path)
- , 'file' => basename($path)
+ 'path' => dirname($path)
+ , 'file' => basename($path)
);
$subdef_alive = true;
}
@@ -532,24 +545,22 @@ class set_export extends set_abstract
$subdef_export = true;
$tmp_pathfile = array(
- 'path' => $sd[$name]->get_path()
- , 'file' => $sd[$name]->get_file()
+ 'path' => $sd[$name]->get_path()
+ , 'file' => $sd[$name]->get_file()
);
- if (!$user->ACL()->has_right_on_base(
- $download_element->get_base_id()
- , "nowatermark"
- )
- && $sd[$name]->get_type() == media_subdef::TYPE_IMAGE)
+ if (!$user->ACL()->has_right_on_base($download_element->get_base_id(), "nowatermark")
+ && !$user->ACL()->has_preview_grant($download_element)
+ && $sd[$name]->get_type() == media_subdef::TYPE_IMAGE)
{
$path = recordutils_image::watermark(
- $download_element->get_base_id()
- , $download_element->get_record_id()
+ $download_element->get_base_id()
+ , $download_element->get_record_id()
);
if (file_exists($path))
{
$tmp_pathfile = array(
- 'path' => dirname($path)
- , 'file' => basename($path)
+ 'path' => dirname($path)
+ , 'file' => basename($path)
);
$subdef_alive = true;
}
@@ -568,44 +579,44 @@ class set_export extends set_abstract
case 'caption':
if ($name == 'caption-yaml')
{
- $suffix = '_captionyaml';
+ $suffix = '_captionyaml';
$extension = 'yml';
- $mime = 'text/x-yaml';
+ $mime = 'text/x-yaml';
}
else
{
- $suffix = '_caption';
+ $suffix = '_caption';
$extension = 'xml';
- $mime = 'text/xml';
+ $mime = 'text/xml';
}
- $files[$id]["subdefs"][$name]["ajout"] = $suffix;
+ $files[$id]["subdefs"][$name]["ajout"] = $suffix;
$files[$id]["subdefs"][$name]["exportExt"] = $extension;
- $files[$id]["subdefs"][$name]["label"] = $properties['label'];
- $files[$id]["subdefs"][$name]["path"] = null;
- $files[$id]["subdefs"][$name]["file"] = null;
- $files[$id]["subdefs"][$name]["size"] = 0;
- $files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory();
- $files[$id]["subdefs"][$name]["mime"] = $mime;
+ $files[$id]["subdefs"][$name]["label"] = $properties['label'];
+ $files[$id]["subdefs"][$name]["path"] = null;
+ $files[$id]["subdefs"][$name]["file"] = null;
+ $files[$id]["subdefs"][$name]["size"] = 0;
+ $files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory();
+ $files[$id]["subdefs"][$name]["mime"] = $mime;
break;
case 'document':
case 'preview':
case 'thumbnail':
$infos = pathinfo(p4string::addEndSlash($tmp_pathfile["path"]) .
- $tmp_pathfile["file"]);
+ $tmp_pathfile["file"]);
- $files[$id]["subdefs"][$name]["ajout"] =
- $properties['class'] == 'document' ? '' : "_" . $name;
- $files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
- $files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
- $files[$id]["subdefs"][$name]["label"] = $properties['label'];
- $files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size();
- $files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime();
- $files[$id]["subdefs"][$name]["folder"] =
- $download_element->get_directory();
+ $files[$id]["subdefs"][$name]["ajout"] =
+ $properties['class'] == 'document' ? '' : "_" . $name;
+ $files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
+ $files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
+ $files[$id]["subdefs"][$name]["label"] = $properties['label'];
+ $files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size();
+ $files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime();
+ $files[$id]["subdefs"][$name]["folder"] =
+ $download_element->get_directory();
$files[$id]["subdefs"][$name]["exportExt"] =
- isset($infos['extension']) ? $infos['extension'] : '';
+ isset($infos['extension']) ? $infos['extension'] : '';
$size += $sd[$name]->get_size();
@@ -613,12 +624,12 @@ class set_export extends set_abstract
}
$longueurAjoutCourant =
- mb_strlen($files[$id]["subdefs"][$name]["ajout"]);
- $sizeMaxAjout = max($longueurAjoutCourant, $sizeMaxAjout);
+ mb_strlen($files[$id]["subdefs"][$name]["ajout"]);
+ $sizeMaxAjout = max($longueurAjoutCourant, $sizeMaxAjout);
$longueurExtCourant =
- mb_strlen($files[$id]["subdefs"][$name]["exportExt"]);
- $sizeMaxExt = max($longueurExtCourant, $sizeMaxExt);
+ mb_strlen($files[$id]["subdefs"][$name]["exportExt"]);
+ $sizeMaxExt = max($longueurExtCourant, $sizeMaxExt);
}
}
@@ -628,34 +639,34 @@ class set_export extends set_abstract
$start_length = mb_strlen($name);
if ($start_length > $max_length)
- $name = mb_substr($name, 0, $max_length);
+ $name = mb_substr($name, 0, $max_length);
$n = 1;
while (in_array(mb_strtolower($name), $file_names))
{
$n++;
- $suffix = "-" . $n; // pour diese si besoin
- $max_length = 31 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix);
- $name = mb_strtolower($files[$id]["export_name"]);
+ $suffix = "-" . $n; // pour diese si besoin
+ $max_length = 31 - $sizeMaxExt - $sizeMaxAjout - mb_strlen($suffix);
+ $name = mb_strtolower($files[$id]["export_name"]);
if ($start_length > $max_length)
- $name = mb_substr($name, 0, $max_length) . $suffix;
+ $name = mb_substr($name, 0, $max_length) . $suffix;
else
- $name = $name . $suffix;
+ $name = $name . $suffix;
}
- $file_names[] = mb_strtolower($name);
+ $file_names[] = mb_strtolower($name);
$files[$id]["export_name"] = $name;
- $files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"]);
+ $files[$id]["export_name"] = $unicode->remove_nonazAZ09($files[$id]["export_name"]);
$files[$id]["original_name"] = $unicode->remove_nonazAZ09($files[$id]["original_name"]);
- $i = 0;
- $name = utf8_decode($files[$id]["export_name"]);
- $tmp_name = "";
+ $i = 0;
+ $name = utf8_decode($files[$id]["export_name"]);
+ $tmp_name = "";
$good_keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
- 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '-', '_', '.', '#');
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '-', '_', '.', '#');
while (isset($name[$i]))
{
@@ -673,19 +684,19 @@ class set_export extends set_abstract
if (in_array('caption', $subdefs))
{
$caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/'
- . time() . $session->get_usr_id()
- . $session->get_ses_id() . '/';
+ . time() . $session->get_usr_id()
+ . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir);
$desc = self::get_caption(
- $download_element->get_base_id()
- , $download_element->get_record_id()
+ $download_element->get_base_id()
+ , $download_element->get_record_id()
);
$file = $files[$id]["export_name"]
- . $files[$id]["subdefs"]['caption']["ajout"] . '.'
- . $files[$id]["subdefs"]['caption']["exportExt"];
+ . $files[$id]["subdefs"]['caption']["ajout"] . '.'
+ . $files[$id]["subdefs"]['caption']["exportExt"];
$path = $caption_dir;
@@ -701,22 +712,22 @@ class set_export extends set_abstract
if (in_array('caption-yaml', $subdefs))
{
$caption_dir = $registry->get('GV_RootPath') . 'tmp/desc_tmp/'
- . time() . $session->get_usr_id()
- . $session->get_ses_id() . '/';
+ . time() . $session->get_usr_id()
+ . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir);
$desc = self::get_caption(
- $download_element->get_base_id()
- , $download_element->get_record_id()
- , true
- , 'yaml'
+ $download_element->get_base_id()
+ , $download_element->get_record_id()
+ , true
+ , 'yaml'
);
$file = $files[$id]["export_name"]
- . $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.'
- . $files[$id]["subdefs"]['caption-yaml']["exportExt"];
+ . $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.'
+ . $files[$id]["subdefs"]['caption-yaml']["exportExt"];
$path = $caption_dir;
@@ -732,10 +743,10 @@ class set_export extends set_abstract
}
$this->list = array(
- 'files' => $files,
- 'names' => $file_names,
- 'size' => $size,
- 'count' => $n_files
+ 'files' => $files,
+ 'names' => $file_names,
+ 'size' => $size,
+ 'count' => $n_files
);
@@ -758,9 +769,9 @@ class set_export extends set_abstract
return false;
}
if (isset($list['complete']) && $list['complete'] === true)
-
+ {
return;
-
+ }
$files = $list['files'];
@@ -770,13 +781,13 @@ class set_export extends set_abstract
random::updateToken($token, serialize($list));
$str_in = array("à", "á", "â", "ã", "ä", "å", "ç", "è", "é", "ê",
- "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô",
- "õ", "ö", "ù", "ú", "û", "ü", "ý", "ÿ");
+ "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô",
+ "õ", "ö", "ù", "ú", "û", "ü", "ý", "ÿ");
$str_out = array("a", "a", "a", "a", "a", "a", "c", "e", "e", "e",
- "e", "i", "i", "i", "i", "o", "n", "o", "o", "o",
- "o", "o", "u", "u", "u", "u", "y", "y");
+ "e", "i", "i", "i", "i", "o", "n", "o", "o", "o",
+ "o", "o", "u", "u", "u", "u", "y", "y");
- $caption_dirs = $unlinks = array();
+ $caption_dirs = $unlinks = array();
foreach ($files as $record)
{
@@ -788,9 +799,9 @@ class set_export extends set_abstract
if (is_file($path))
{
$name = $obj["folder"]
- . $record["export_name"]
- . $obj["ajout"]
- . '.' . $obj["exportExt"];
+ . $record["export_name"]
+ . $obj["ajout"]
+ . '.' . $obj["exportExt"];
$name = str_replace($str_in, $str_out, $name);
@@ -800,7 +811,7 @@ class set_export extends set_abstract
{
if (!in_array(dirname($path), $caption_dirs))
$caption_dirs[] = dirname($path);
- $unlinks[] = $path;
+ $unlinks[] = $path;
}
}
}
@@ -843,7 +854,7 @@ class set_export extends set_abstract
$dom->encoding = 'UTF-8';
$dom_record = $dom->createElement('record');
- $dom_desc = $dom->createElement('description');
+ $dom_desc = $dom->createElement('description');
$dom_record->appendChild($dom_desc);
$dom->appendChild($dom_record);
@@ -851,19 +862,19 @@ class set_export extends set_abstract
$restrict = array();
$sbas_id = phrasea::sbasFromBas($bas);
- $record = new record_adapter($sbas_id, $rec);
- $desc = $record->get_xml();
- $appbox = appbox::get_instance();
+ $record = new record_adapter($sbas_id, $rec);
+ $desc = $record->get_xml();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$databox = databox::get_instance($sbas_id);
- $struct = $databox->get_structure();
+ $struct = $databox->get_structure();
$rights = true;
if ($check_rights && $session->is_authenticated())
{
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
+ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$rights = $user->ACL()->has_right_on_base($bas, 'canmodifrecord');
if ($rights == false)
@@ -876,7 +887,7 @@ class set_export extends set_abstract
foreach ($z[0] as $ki => $vi)
{
if (isset($vi["export"])
- && ($vi["export"] == "0" || $vi["export"] == "off"))
+ && ($vi["export"] == "0" || $vi["export"] == "off"))
$restrict[$ki] = true;
}
}
@@ -886,36 +897,39 @@ class set_export extends set_abstract
$buffer = array();
- if ($sxe = simplexml_load_string($desc))
+ foreach ($record->get_caption()->get_fields() as $field)
{
- $z = $sxe->xpath('/record/description');
- if ($z && is_array($z))
+ if (($rights || !isset($restrict[$field->get_name()])))
{
- foreach ($z[0] as $ki => $vi)
+ switch ($format)
{
- if (($rights || !isset($restrict[$ki])))
- {
+ case 'yaml':
+ case 'yml':
+ $vi = $field->get_values();
- switch ($format)
+ if ($field->is_multi())
{
- case 'yaml':
- case 'yml':
-
- $vi = trim($vi);
- if (ctype_digit($vi))
- $vi = (int) $vi;
-
- $buffer[trim($ki)] = $vi;
- break;
- case 'xml':
- default:
- $dom_el = $dom->createElement($ki);
- $dom_el->appendChild($dom->createTextNode(trim($vi)));
- $dom_desc->appendChild($dom_el);
- break;
+ $buffer[$field->get_name()] = array();
+ foreach ($vi as $value)
+ {
+ $val = $value->getValue();
+ $buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val;
+ }
}
- }
+ else
+ {
+ $value = array_pop($vi);
+ $val = $value->getValue();
+ $buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
+ }
+ break;
+ case 'xml':
+ default:
+ $dom_el = $dom->createElement($field->get_name());
+ $dom_el->appendChild($dom->createTextNode($field->get_serialized_values()));
+ $dom_desc->appendChild($dom_el);
+ break;
}
}
}
@@ -951,31 +965,37 @@ class set_export extends set_abstract
public static function stream_file(
$file, $exportname, $mime, $disposition = 'attachment')
{
- require_once dirname(__FILE__) . "/../../../lib/vendor/Silex/autoload.php";
+ require_once __DIR__ . "/../../../lib/vendor/Silex/autoload.php";
$registry = registry::get_instance();
$disposition = in_array($disposition, array('inline', 'attachment')) ?
- $disposition : 'attachment';
+ $disposition : 'attachment';
$response = new Symfony\Component\HttpFoundation\Response();
if (is_file($file))
{
+ $testPath = function($file, $registry)
+ {
+ return strpos($file, $registry->get('GV_RootPath') . 'tmp/download/') !== false
+ || strpos($file, $registry->get('GV_RootPath') . 'tmp/lazaret/') !== false
+ || strpos($file, $registry->get('GV_X_Accel_Redirect')) !== false;
+ };
- if ($registry->get('GV_modxsendfile') && strpos($file, $registry->get('GV_X_Accel_Redirect')) !== false)
+ if ($registry->get('GV_modxsendfile') && $testPath($file, $registry))
{
$file_xaccel = str_replace(
- array(
+ array(
$registry->get('GV_X_Accel_Redirect'),
$registry->get('GV_RootPath') . 'tmp/download/',
$registry->get('GV_RootPath') . 'tmp/lazaret/'
- )
- , array(
- '/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/',
- '/download/',
- '/lazaret/'
- )
- , $file
+ )
+ , array(
+ '/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/',
+ '/download/',
+ '/lazaret/'
+ )
+ , $file
);
$response->headers->set('X-Sendfile', $file);
$response->headers->set('X-Accel-Redirect', $file_xaccel);
@@ -1036,7 +1056,7 @@ class set_export extends set_abstract
header("Content-Length: " . strlen($data));
header("Cache-Control: max-age=3600, must-revalidate ");
header("Content-Disposition: " . $disposition
- . "; filename=" . $exportname . ";");
+ . "; filename=" . $exportname . ";");
echo $data;
@@ -1054,24 +1074,24 @@ class set_export extends set_abstract
public static function log_download(Array $list, $type, $anonymous = false, $comment = '')
{
//download
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
- $user = false;
+ $user = false;
if ($anonymous)
{
}
else
{
- $user = User_Adapter::getInstance($session->get_usr_id(), appbox::get_instance());
+ $user = User_Adapter::getInstance($session->get_usr_id(), appbox::get_instance(\bootstrap::getCore()));
}
$tmplog = array();
$files = $list['files'];
$event_names = array(
- 'mail-export' => Session_Logger::EVENT_EXPORTMAIL,
- 'download' => Session_Logger::EVENT_EXPORTDOWNLOAD
+ 'mail-export' => Session_Logger::EVENT_EXPORTMAIL,
+ 'download' => Session_Logger::EVENT_EXPORTDOWNLOAD
);
$event_name = isset($event_names[$type]) ? $event_names[$type] : Session_Logger::EVENT_EXPORTDOWNLOAD;
@@ -1080,18 +1100,18 @@ class set_export extends set_abstract
{
foreach ($record["subdefs"] as $o => $obj)
{
- $sbas_id = phrasea::sbasFromBas($record['base_id']);
+ $sbas_id = phrasea::sbasFromBas($record['base_id']);
$record_object = new record_adapter($sbas_id, $record['record_id']);
$session->get_logger($record_object->get_databox())
- ->log($record_object, $event_name, $o, $comment);
+ ->log($record_object, $event_name, $o, $comment);
if ($o != "caption")
{
- $log["rid"] = $record_object->get_record_id();
- $log["subdef"] = $o;
- $log["poids"] = $obj["size"];
- $log["shortXml"] = $record_object->get_xml();
+ $log["rid"] = $record_object->get_record_id();
+ $log["subdef"] = $o;
+ $log["poids"] = $obj["size"];
+ $log["shortXml"] = $record_object->get_xml();
$tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document')
$user->ACL()->remove_remaining($record_object->get_base_id());
@@ -1102,9 +1122,9 @@ class set_export extends set_abstract
}
$export_types = array(
- 'download' => 0,
- 'mail-export' => 2,
- 'ftp' => 4
+ 'download' => 0,
+ 'mail-export' => 2,
+ 'ftp' => 4
);
$list_base = array_unique(array_keys($tmplog));
@@ -1122,9 +1142,9 @@ class set_export extends set_abstract
if ($user->ACL()->is_restricted_download($base_id))
{
$params = array(
- ':remain_dl' => $user->ACL()->remaining_download($base_id)
- , ':base_id' => $base_id
- , ':usr_id' => $user->get_id()
+ ':remain_dl' => $user->ACL()->remaining_download($base_id)
+ , ':base_id' => $base_id
+ , ':usr_id' => $user->get_id()
);
$stmt->execute($params);
diff --git a/lib/classes/set/exportftp.class.php b/lib/classes/set/exportftp.class.php
index e613cd5e83..9a5ec79342 100644
--- a/lib/classes/set/exportftp.class.php
+++ b/lib/classes/set/exportftp.class.php
@@ -33,7 +33,7 @@ class set_exportftp extends set_export
*/
public function export_ftp($usr_to, $host, $login, $password, $ssl, $retry, $passif, $destfolder, $makedirectory, $logfile)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user_f = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$conn = $appbox->get_connection();
diff --git a/lib/classes/set/exportorder.class.php b/lib/classes/set/exportorder.class.php
index 9094fa70c0..ca7470eb42 100644
--- a/lib/classes/set/exportorder.class.php
+++ b/lib/classes/set/exportorder.class.php
@@ -27,6 +27,8 @@ class set_exportorder extends set_export
*/
public function order_available_elements($from_usr_id, $usage, $deadline)
{
+ $Core = bootstrap::getCore();
+
$lst = $this->get_orderable_lst();
$conn = connection::getPDOConnection();
@@ -89,7 +91,7 @@ class set_exportorder extends set_export
return false;
}
- $evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance());
+ $evt_mngr = eventsmanager_broker::getInstance(appbox::get_instance($Core), $Core);
$params = array(
'order_id' => $order_id,
@@ -130,7 +132,7 @@ class set_exportorder extends set_export
*/
public static function set_order_admins($admins, $base_id)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection();
$conn->beginTransaction();
try
diff --git a/lib/classes/set/order.class.php b/lib/classes/set/order.class.php
index 1c7f93104d..9f0926010e 100644
--- a/lib/classes/set/order.class.php
+++ b/lib/classes/set/order.class.php
@@ -66,7 +66,7 @@ class set_order extends set_abstract
*/
public function __construct($id)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$conn = $appbox->get_connection();
@@ -202,7 +202,7 @@ class set_order extends set_abstract
*/
public function send_elements(Array $elements_ids, $force)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$conn = $appbox->get_connection();
$pusher = User_Adapter::getInstance($session->get_usr_id(), $appbox);
@@ -219,19 +219,41 @@ class set_order extends set_abstract
}
}
- try
- {
- $basket = basket_adapter::getInstance($appbox, $this->ssel_id, $session->get_usr_id());
- }
- catch (Exception $e)
- {
- $basket = basket_adapter::create($appbox, sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')), $this->user, '', $pusher);
+ $core = \bootstrap::getCore();
- $this->ssel_id = $basket->get_ssel_id();
+ $em = $core->getEntityManager();
+
+ $Basket = null;
+ /* @var $repository \Repositories\BasketRepository */
+ if($this->ssel_id)
+ {
+ $repository = $em->getRepository('\Entities\Basket');
+
+ try
+ {
+ $Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
+ }
+ catch(\Exception $e)
+ {
+ $Basket = null;
+ }
+ }
+
+ if(!$Basket)
+ {
+ $Basket = new \Entities\Basket();
+ $Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
+ $Basket->setOwner($this->user);
+ $Basket->setPusher($core->getAuthenticatedUser());
+
+ $em->persist($Basket);
+ $em->flush();
+
+ $this->ssel_id = $Basket->getId();
$sql = 'UPDATE `order` SET ssel_id = :ssel_id WHERE id = :order_id';
$stmt = $conn->prepare($sql);
- $stmt->execute(array(':ssel_id' => $basket->get_ssel_id(), ':order_id' => $this->id));
+ $stmt->execute(array(':ssel_id' => $Basket->getId(), ':order_id' => $this->id));
$stmt->closeCursor();
}
@@ -254,20 +276,27 @@ class set_order extends set_abstract
{
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
$record = new record_adapter($sbas_id, $basrec['record_id']);
- $ret = $basket->push_element($record, false, false);
- if ($ret['error'] === false)
- {
- $params = array(
- ':usr_id' => $session->get_usr_id()
- , ':order_id' => $this->id
- , ':order_element_id' => $order_element_id
- );
- $stmt->execute($params);
+ $BasketElement = new \Entities\BasketElement();
+ $BasketElement->setRecord($record);
+ $BasketElement->setBasket($Basket);
+
+ $Basket->addBasketElement($BasketElement);
+
+ $em->persist($BasketElement);
+
+
+ $params = array(
+ ':usr_id' => $session->get_usr_id()
+ , ':order_id' => $this->id
+ , ':order_element_id' => $order_element_id
+ );
+
+ $stmt->execute($params);
+
+ $n++;
+ $this->user->ACL()->grant_hd_on($record, $pusher, 'order');
- $n++;
- $this->user->ACL()->grant_hd_on($record, $pusher, 'order');
- }
unset($record);
}
catch (Exception $e)
@@ -275,11 +304,13 @@ class set_order extends set_abstract
}
}
+
+ $em->flush();
$stmt->closeCursor();
if ($n > 0)
{
- $evt_mngr = eventsmanager_broker::getInstance($appbox);
+ $evt_mngr = eventsmanager_broker::getInstance($appbox, $core);
$params = array(
'ssel_id' => $this->ssel_id,
@@ -301,7 +332,8 @@ class set_order extends set_abstract
*/
public function deny_elements(Array $elements_ids)
{
- $appbox = appbox::get_instance();
+ $Core = bootstrap::getCore();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$conn = $appbox->get_connection();
@@ -328,7 +360,7 @@ class set_order extends set_abstract
if ($n > 0)
{
- $evt_mngr = eventsmanager_broker::getInstance($appbox);
+ $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$params = array(
'from' => $session->get_usr_id(),
diff --git a/lib/classes/set/ordermanager.class.php b/lib/classes/set/ordermanager.class.php
index 14b9f6714c..d135fcab26 100644
--- a/lib/classes/set/ordermanager.class.php
+++ b/lib/classes/set/ordermanager.class.php
@@ -37,7 +37,7 @@ class set_ordermanager extends set_abstract
*/
public function __construct($sort = false, $page = 1)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$conn = $appbox->get_connection();
diff --git a/lib/classes/set/selection.class.php b/lib/classes/set/selection.class.php
index ce5a6ae235..77b24f04a6 100644
--- a/lib/classes/set/selection.class.php
+++ b/lib/classes/set/selection.class.php
@@ -31,21 +31,14 @@ class set_selection extends set_abstract
/**
*
- * @param basket_adapter $basket
- * @param boolean $flatten_if_grouping
+ * @param \Entities\Basket $basket
* @return set_selection
*/
- public function load_basket(basket_adapter $basket, $flatten_if_grouping = true)
+ public function load_basket(\Entities\Basket $Basket)
{
- if ($basket->is_grouping() && !$flatten_if_grouping)
+ foreach ($Basket->getElements() as $basket_element)
{
- $record = new record_adapter($basket->get_sbas_id(), $basket->get_record_id(), count($this->elements));
- $this->add_element($record);
- }
- else
- {
- foreach ($basket->get_elements() as $basket_element)
- $this->add_element($basket_element->get_record());
+ $this->add_element($basket_element->getRecord());
}
return $this;
@@ -58,7 +51,7 @@ class set_selection extends set_abstract
*/
public function grep_authorized(Array $rights = array(), Array $sbas_rights = array())
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php
index f906ed0f67..097e6375f3 100644
--- a/lib/classes/setup.class.php
+++ b/lib/classes/setup.class.php
@@ -43,6 +43,8 @@ class setup
, "xml"
, "zip"
, "zlib"
+ , "intl"
+ , "twig"
);
protected static $PHP_CONF = array(
'output_buffering' => '4096' //INI_ALL
@@ -68,13 +70,20 @@ class setup
public static function is_installed()
{
- return file_exists(dirname(__FILE__) . "/../../config/connexion.inc")
- && file_exists(dirname(__FILE__) . "/../../config/config.inc");
+ $appConf = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+
+ return $appConf->isSetup();
}
- function create_global_values(registryInterface &$registry, $datas=array())
+ public static function needUpgradeConfigurationFile()
{
- require(dirname(__FILE__) . "/../../lib/conf.d/_GV_template.inc");
+ return (is_file(__DIR__ . "/../../config/connexion.inc")
+ && is_file(__DIR__ . "/../../config/config.inc"));
+ }
+
+ function create_global_values(registryInterface &$registry, $datas = array())
+ {
+ require(__DIR__ . "/../../lib/conf.d/_GV_template.inc");
if ($registry->is_set('GV_timezone'))
@@ -257,12 +266,12 @@ class setup
{
if (system_server::get_platform() == 'WINDOWS')
{
- $exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool.exe';
- $indexer = dirname(dirname(dirname(__FILE__))) . '/bin/phraseanet_indexer.exe';
+ $exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool.exe';
+ $indexer = dirname(dirname(__DIR__)) . '/bin/phraseanet_indexer.exe';
}
else
{
- $exiftool = dirname(dirname(__FILE__)) . '/vendor/exiftool/exiftool';
+ $exiftool = dirname(__DIR__) . '/vendor/exiftool/exiftool';
$indexer = null;
}
@@ -418,7 +427,7 @@ class setup
public static function check_phrasea()
{
$constraints = array();
- if(function_exists('phrasea_info'))
+ if (function_exists('phrasea_info'))
{
foreach (phrasea_info() as $name => $value)
{
@@ -426,7 +435,7 @@ class setup
{
default:
$result = true;
- $message = $name.' = '.$value;
+ $message = $name . ' = ' . $value;
break;
case 'temp_writable':
$result = $value == '1';
@@ -438,7 +447,7 @@ class setup
case 'version':
$result = version_compare($value, '1.18.0.3', '>=');
if ($result)
- $message = sprintf ('Phrasea version %s is ok', $value);
+ $message = sprintf('Phrasea version %s is ok', $value);
else
$message = sprintf('Phrasea version %s is NOT ok', $value);
break;
@@ -453,7 +462,7 @@ class setup
public static function check_writability(registryInterface $registry)
{
- $root = p4string::addEndSlash(realpath(dirname(__FILE__) . '/../../'));
+ $root = p4string::addEndSlash(realpath(__DIR__ . '/../../'));
$pathes = array(
$root . 'config',
@@ -551,10 +560,18 @@ class setup
{
if (extension_loaded($ext) !== true)
{
- $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), false, sprintf('%s missing', $ext), true);
+ $blocker = true;
+ if("twig" === $ext)
+ {
+ $blocker = false;
+ }
+
+ $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), false, sprintf('%s missing', $ext), $blocker);
}
else
- $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), true, sprintf('%s loaded', $ext), true);
+ {
+ $constraints[] = new Setup_Constraint(sprintf('Extension %s', $ext), true, sprintf('%s loaded', $ext));
+ }
}
return new Setup_ConstraintsIterator($constraints);
@@ -562,7 +579,7 @@ class setup
public static function check_cache_server()
{
- $availables_caches = array('memcache', 'memcached', 'redis');
+ $availables_caches = array('memcache', 'redis');
$constraints = array();
foreach ($availables_caches as $ext)
@@ -580,36 +597,26 @@ class setup
function check_cache_memcache()
{
+ $Core = \bootstrap::getCore();
echo '' . _('setup:: Serveur Memcached') . ' ';
echo '';
$registry = registry::get_instance();
- if ($registry->get('GV_cache_server_type') !== 'nocache')
+ if ($Core->getCache()->isServer())
{
- $cache = cache_adapter::get_instance(registry::get_instance());
+ $stats = $Core->getCache()->getStats();
- if ($cache->ping())
- {
- $stats = $cache->getStats();
+ echo '' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . ' ';
+ echo "";
- foreach ($stats as $name => $stat)
- {
- echo 'Statistics given by `' . $name . '` ';
- echo '' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . ' ';
- echo "";
- foreach ($stat as $key => $value)
- {
- echo "" . $key . " " . $value . " ";
- }
- echo "
";
- }
- }
- else
+ foreach ($stats as $name => $stat)
{
- echo '' . sprintf(_('Le serveur memcached ne repond pas, vous devriez desactiver le cache')) . ' ';
+ echo "" . $name . " " . $stat . " ";
}
+
+ echo "
";
}
else
{
@@ -634,9 +641,9 @@ class setup
}
if ($found > 1)
- $constraints[] = new Setup_Constraint('Multiple opcode caches', false, 'Many opcode cache load is forbidden', true);
+ $constraints[] = new Setup_Constraint('Multiple opcode caches', false, _('Many opcode cache load is forbidden'), true);
if ($found === 0)
- $constraints[] = new Setup_Constraint('No opcode cache', false, 'No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.', false);
+ $constraints[] = new Setup_Constraint('No opcode cache', false, _('No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.'), false);
return new Setup_ConstraintsIterator($constraints);
}
@@ -752,33 +759,14 @@ class setup
return $current;
}
- public static function write_config($servername)
+ public static function rollback(connection_pdo $conn, connection_pdo $connbas = null)
{
- $datas = "appbox;
$databox = $structure->databox;
@@ -814,12 +802,13 @@ class setup
}
}
}
- $connexion = dirname(__FILE__) . "/../../config/connexion.inc";
- if (file_exists($connexion))
- unlink($connexion);
+ $appConf = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
+
+ $appConf->delete();
return;
}
}
+
diff --git a/lib/classes/sphinx/configuration.class.php b/lib/classes/sphinx/configuration.class.php
index b2d1278466..cbd3b40972 100644
--- a/lib/classes/sphinx/configuration.class.php
+++ b/lib/classes/sphinx/configuration.class.php
@@ -37,7 +37,7 @@ class sphinx_configuration
public function get_available_charsets()
{
$available_charsets = array();
- $dir = dirname(__FILE__) . '/charsetTable/';
+ $dir = __DIR__ . '/charsetTable/';
echo $dir;
$registry = registry::get_instance();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
@@ -67,15 +67,17 @@ class sphinx_configuration
$defaults = array(
'sbas' => self::OPT_ALL_SBAS
- , 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
+ , 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
, 'enable_star' => self::OPT_ENABLE_STAR_ON
- , 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
+ , 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
, 'min_infix_len' => self::OPT_MIN_INFIX_LEN
, 'charset_tables' => array()
);
$options = array_merge($defaults, $options);
+ $options['charset_tables'] = array_unique($options['charset_tables']);
+
$lb = phrasea::sbas_params();
$conf = '';
@@ -439,7 +441,7 @@ class sphinx_configuration
path = /var/sphinx/datas/docs_realtime_' . $serialized . '
-' . $charset_abstract . '
+ ' . $charset_abstract . '
rt_field = value
# rt_field = meta_struct_id
@@ -593,6 +595,9 @@ searchd
# optional, default is 256
#
max_filters = 512
+
+ compat_sphinxql_magics = 0
+
}
';
diff --git a/lib/classes/sphinxrt.class.php b/lib/classes/sphinxrt.class.php
index a8c5b354ce..2a15d0313d 100644
--- a/lib/classes/sphinxrt.class.php
+++ b/lib/classes/sphinxrt.class.php
@@ -81,7 +81,7 @@ class sphinxrt
if ($rt_id)
{
$this->connection->beginTransaction();
- $sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
+ $sql = "DELETE FROM " . $rt_id . " WHERE id = " . (int) $id . "";
$stmt = $this->connection->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
@@ -106,7 +106,7 @@ class sphinxrt
$cl->SetConnectTimeout(1);
- $status = strrev($status);
+ $status = strrev($status);
$new_stat = array();
for ($i = 4; $i < strlen($status); $i++)
{
@@ -122,20 +122,18 @@ class sphinxrt
return $this;
}
- public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, Array $content, DateTime $created)
+ public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created)
{
- $crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
- $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
+ $crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
+ $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
- $crc_type = crc32($type);
+ $crc_type = crc32($type);
$this->connection->beginTransaction();
-// foreach ($content as $value)
-// {
- $sql = "REPLACE INTO " . $rt_id . " VALUES (
+ $sql = "REPLACE INTO " . $rt_id . " VALUES (
'" . (int) $meta_id . "'
- ,'" . str_replace("'", "\'", implode(' ', $content)) . "'
+ ,'" . str_replace("'", "\'", $content) . "'
,'" . (int) $tag_id . "'
," . (int) $record_id . "
," . (int) $sbas_id . "
@@ -149,7 +147,6 @@ class sphinxrt
," . (int) $created->format('U') . " )";
$stmt = $this->connection->prepare($sql);
$stmt->execute();
-// }
$stmt->closeCursor();
@@ -160,9 +157,9 @@ class sphinxrt
public function replace_in_documents($rt_id, $record_id, $value, $sbas_id, $coll_id, $grouping, $type, DateTime $created)
{
- $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
+ $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
$crc_sbas_record = crc32($sbas_id . '_' . $record_id);
- $crc_type = crc32($type);
+ $crc_type = crc32($type);
$this->connection->beginTransaction();
diff --git a/lib/classes/supertwig.class.php b/lib/classes/supertwig.class.php
deleted file mode 100644
index 3f127dacfd..0000000000
--- a/lib/classes/supertwig.class.php
+++ /dev/null
@@ -1,267 +0,0 @@
- $extensions
- * @param $options
- * @return supertwig
- */
- public function __construct($extensions = array(), $options = array())
- {
- $browser = Browser::getInstance();
- $this->load_default_vars();
- $registry = registry::get_instance();
-
- if (($browser->isTablet()))
- {
- $this->ld_path = array(
- $registry->get('GV_RootPath') . 'config/templates/mobile',
- $registry->get('GV_RootPath') . 'templates/mobile'
- );
- }
- elseif ($browser->isMobile())
- {
- $this->ld_path = array(
- $registry->get('GV_RootPath') . 'config/templates/mobile',
- $registry->get('GV_RootPath') . 'templates/mobile'
- );
- }
- else
- {
- $this->ld_path = array(
- $registry->get('GV_RootPath') . 'config/templates/web',
- $registry->get('GV_RootPath') . 'templates/web'
- );
- }
-
-
- $default_extensions = array('I18n' => true, 'Optimizer' => true);
-
- if ($registry->get('GV_debug'))
- {
- $default_options = array(
- 'debug' => true,
- 'strict_variables' => false,
- 'trim_blocks' => true,
- 'charset' => 'utf-8',
- 'auto_reload' => true
- );
- $default_extensions['Debug'] = true;
- }
- else
- {
- $default_options = array(
- 'cache' => $registry->get('GV_RootPath') . 'tmp/cache_twig',
- 'debug' => false,
- 'strict_variables' => false,
- 'trim_blocks' => true,
- 'charset' => 'utf-8'
- );
- }
-
- $options = array_merge($default_options, $options);
- $extensions = array_merge($default_extensions, $extensions);
-
- try
- {
- $this->set_options($options);
- $this->init_twig();
- $this->set_extensions($extensions);
- $this->addFilter(array('round' => 'round'));
- }
- catch (Exception $e)
- {
-
- }
-
- return $this;
- }
-
- /**
- *
- * @param array $filters
- * @return supertwig
- */
- public function addFilter(Array $filters)
- {
- foreach ($filters as $name => $function)
- {
- $this->twig_object->addFilter($name, new Twig_Filter_Function($function));
- }
-
- return $this;
- }
-
- /**
- *
- * @param string $path
- * @param string $var
- * @return string
- */
- public function render($path, $var)
- {
- $template = $this->twig_object->loadTemplate($path);
-
- $var = array_merge($this->default_vars, $var);
-
- return $template->render($var);
- }
-
- /**
- *
- * @param string $path
- * @param string $var
- * @return void
- */
- public function display($path, $var)
- {
- $template = $this->twig_object->loadTemplate($path);
-
- $var = array_merge($this->default_vars, $var);
-
- return $template->display($var);
- }
-
- /**
- *
- * @param array $options
- * @return supertwig
- */
- protected function set_options(Array $options)
- {
- foreach ($options as $key => $value)
- {
- $this->options[$key] = $value;
- }
-
- return $this;
- }
-
- /**
- *
- * @return supertwig
- */
- protected function init_twig()
- {
- $loader = new Twig_Loader_Filesystem($this->ld_path);
-
- if (sizeof($this->options) > 0)
- $this->twig_object = new Twig_Environment($loader, $this->options);
- else
- $this->twig_object = new Twig_Environment($loader);
-
- return $this;
- }
-
- /**
- *
- * @param array $extensions
- * @return supertwig
- */
- protected function set_extensions(Array $extensions)
- {
- $twig_lib = array('core', 'escaper', 'optimizer', 'sandbox');
- foreach ($extensions as $name => $boolean)
- {
- $name = strtolower($name);
- $boolean = !!$boolean;
- $this->extensions[$name] = $boolean;
-
- if ($boolean)
- {
- if (in_array($name, $twig_lib))
- $extension_classname = 'Twig_Extension_' . ucfirst($name);
- else
- $extension_classname = 'Twig_Extensions_Extension_' . ucfirst($name);
-
- $this->twig_object->addExtension(new $extension_classname());
- }
- else
- {
- $this->twig_object->removeExtension($name);
- }
- }
-
- return $this;
- }
-
- /**
- *
- * @return supertwig
- */
- protected function load_default_vars()
- {
- if (!$this->default_vars)
- {
- $appbox = appbox::get_instance();
- $session = $appbox->get_session();
- $browser = Browser::getInstance();
- $registry = $appbox->get_registry();
- $request = new http_request();
-
- $user = false;
- if ($session->is_authenticated())
- {
- $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
- }
-
- $this->default_vars = array(
- 'session' => $session,
- 'version_number' => GV_version,
- 'version_name' => GV_version_name,
- 'browser' => $browser,
- 'request' => $request,
- 'display_chrome_frame' => $registry->is_set('GV_display_gcf') ? $registry->get('GV_display_gcf') : true,
- 'user' => $user,
- 'current_date' => new DateTime(),
- 'home_title' => $registry->get('GV_homeTitle'),
- 'meta_description' => $registry->get('GV_metaDescription'),
- 'meta_keywords' => $registry->get('GV_metaKeywords'),
- 'maintenance' => $registry->get('GV_maintenance'),
- 'registry' => $registry
- );
- }
-
- return $this;
- }
-
-}
-
diff --git a/lib/classes/system/file.class.php b/lib/classes/system/file.class.php
index d5e3024fce..dbd4369f6d 100644
--- a/lib/classes/system/file.class.php
+++ b/lib/classes/system/file.class.php
@@ -1130,12 +1130,15 @@ class system_file extends SplFileObject
$tmpval[] = $val;
}
- $ret[$meta->get_id()] = array(
+ foreach ($tmpval as $val)
+ {
+ $ret[] = array(
'meta_struct_id' => $meta->get_id(),
'meta_id' => null,
- 'value' => $tmpval
+ 'value' => $val
);
}
+ }
$statBit = null;
@@ -1205,16 +1208,19 @@ class system_file extends SplFileObject
$fv = array($fv);
}
- if (isset($metadatas[$meta->get_id()]) && $meta->is_multi() === true)
- {
- $fv = array_unique(array_merge($metadatas[$meta->get_id()], $fv));
- }
+// if (isset($metadatas[$meta->get_id()]) && $meta->is_multi() === true)
+// {
+// $fv = array_unique(array_merge($metadatas[$meta->get_id()], $fv));
+// }
- $metadatas[$meta->get_id()] = array(
- 'meta_struct_id' => $meta->get_id(),
- 'meta_id' => null,
- 'value' => $fv
- );
+ foreach($fv as $value)
+ {
+ $metadatas[] = array(
+ 'meta_struct_id' => $meta->get_id(),
+ 'meta_id' => null,
+ 'value' => $value
+ );
+ }
unset($meta);
}
diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php
index 516ba7ee19..b70dfe0258 100644
--- a/lib/classes/task/Scheduler.class.php
+++ b/lib/classes/task/Scheduler.class.php
@@ -638,4 +638,4 @@ class task_Scheduler
$this->log("Scheduler2 has quit.\n");
}
-}
\ No newline at end of file
+}
diff --git a/lib/classes/task/appboxAbstract.class.php b/lib/classes/task/appboxAbstract.class.php
index 80344bea4c..0496f397ff 100644
--- a/lib/classes/task/appboxAbstract.class.php
+++ b/lib/classes/task/appboxAbstract.class.php
@@ -66,7 +66,7 @@ abstract class task_appboxAbstract extends task_abstract
if (!$this->running)
break;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
try
{
$this->load_settings(simplexml_load_string($row['settings']));
@@ -153,12 +153,6 @@ abstract class task_appboxAbstract extends task_abstract
->check_records_done()
->check_task_status();
- if ($conn instanceof PDO)
- {
- $conn->close();
- unset($conn);
- }
-
if ($rowstodo > 0)
$this->setProgress(0, 0);
diff --git a/lib/classes/task/period/apibridge.class.php b/lib/classes/task/period/apibridge.class.php
index 998cd15f9d..10517c335e 100644
--- a/lib/classes/task/period/apibridge.class.php
+++ b/lib/classes/task/period/apibridge.class.php
@@ -145,6 +145,7 @@ class task_period_apibridge extends task_appboxAbstract
*/
protected function update_element(Bridge_Element &$element)
{
+ $Core = bootstrap::getCore();
$account = $element->get_account();
$connector_status = $account->get_api()->get_element_status($element);
@@ -176,7 +177,7 @@ class task_period_apibridge extends task_appboxAbstract
, 'sbas_id' => $element->get_record()->get_sbas_id()
, 'record_id' => $element->get_record()->get_record_id()
);
- $events_mngr = eventsmanager_broker::getInstance(appbox::get_instance());
+ $events_mngr = eventsmanager_broker::getInstance(appbox::get_instance(\bootstrap::getCore()), $Core);
$events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break;
diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php
index dd2b26a53c..c48f898cc7 100644
--- a/lib/classes/task/period/archive.class.php
+++ b/lib/classes/task/period/archive.class.php
@@ -223,7 +223,7 @@ class task_period_archive extends task_abstract
*/
public function printInterfaceHTML()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
ob_start();
?>
@@ -828,12 +828,14 @@ class task_period_archive extends task_abstract
{
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
+
return;
elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile))
+
return;
}
}
-
+
while(($file = $listFolder->read()) !== NULL)
{
// on gere le magicfile
diff --git a/lib/classes/task/period/batchupload.class.php b/lib/classes/task/period/batchupload.class.php
index 1086a14e6e..7b788a2427 100644
--- a/lib/classes/task/period/batchupload.class.php
+++ b/lib/classes/task/period/batchupload.class.php
@@ -54,7 +54,7 @@ class task_period_batchupload extends task_appboxAbstract
protected function process_one_content(appbox $appbox, Array $row)
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$conn = $appbox->get_connection();
$session = $appbox->get_session();
diff --git a/lib/classes/task/period/emptyColl.class.php b/lib/classes/task/period/emptyColl.class.php
index c31398f1ba..300a497e47 100644
--- a/lib/classes/task/period/emptyColl.class.php
+++ b/lib/classes/task/period/emptyColl.class.php
@@ -57,7 +57,7 @@ class task_period_emptyColl extends task_appboxAbstract
$collection = collection::get_from_base_id($this->base_id);
$this->total_records = $collection->get_record_amount();
$collection->empty_collection(200);
- $this->records_done += $this->total_records;
+ $this->records_done +=$this->total_records;
$this->setProgress($this->records_done, $this->total_records);
if ($this->total_records == 0)
diff --git a/lib/classes/task/period/outofdate.class.php b/lib/classes/task/period/outofdate.class.php
index 3019531f86..f269f12a90 100644
--- a/lib/classes/task/period/outofdate.class.php
+++ b/lib/classes/task/period/outofdate.class.php
@@ -291,7 +291,6 @@ class task_period_outofdate extends task_abstract
, async:false
, success:function(data)
{
- // console.log(data);
var html = "... ";
for(i in data.date_fields)
html += "\n" + data.date_fields[i] + " ";
@@ -401,7 +400,7 @@ class task_period_outofdate extends task_abstract
{
global $usr_id;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
ob_start();
@@ -627,9 +626,7 @@ class task_period_outofdate extends task_abstract
$duration = time() - $duration;
if($duration < $period)
{
- $conn->close();
sleep($period - $duration);
- unset($conn);
$conn = connection::getPDOConnection();
}
break;
diff --git a/lib/classes/task/period/upgradetov31.class.php b/lib/classes/task/period/upgradetov31.class.php
index 9b66a7cb39..9734f1b4b5 100644
--- a/lib/classes/task/period/upgradetov31.class.php
+++ b/lib/classes/task/period/upgradetov31.class.php
@@ -43,7 +43,7 @@ class task_period_upgradetov31 extends task_abstract
{
printf("taskid %s starting." . PHP_EOL, $this->get_task_id());
// task can't be stopped here
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection();
$registry = $appbox->get_registry();
$running = true;
@@ -58,7 +58,7 @@ class task_period_upgradetov31 extends task_abstract
$todo = $this->how_many_left();
$done = 0;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$ret = 'stopped';
$this->setProgress($done, $todo);
@@ -156,7 +156,7 @@ class task_period_upgradetov31 extends task_abstract
private function how_many_left()
{
$todo = 0;
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
diff --git a/lib/classes/task/period/upgradetov32.class.php b/lib/classes/task/period/upgradetov32.class.php
index c3d1138b6c..337d39ad25 100644
--- a/lib/classes/task/period/upgradetov32.class.php
+++ b/lib/classes/task/period/upgradetov32.class.php
@@ -61,8 +61,8 @@ class task_period_upgradetov32 extends task_abstract
printf("taskid %s starting." . PHP_EOL, $this->get_task_id());
$registry = registry::get_instance();
- $registry->set('GV_cache_server_type', 'nocache');
- $registry->set('GV_sphinx', false);
+// $registry->set('GV_cache_server_type', 'nocache', \registry::TYPE_STRING);
+ $registry->set('GV_sphinx', false, \registry::TYPE_BOOLEAN);
if (!$this->sbas_id)
{
diff --git a/lib/classes/task/period/workflow01.class.php b/lib/classes/task/period/workflow01.class.php
index 94a550b673..a48d8083de 100644
--- a/lib/classes/task/period/workflow01.class.php
+++ b/lib/classes/task/period/workflow01.class.php
@@ -308,7 +308,7 @@ class task_period_workflow01 extends task_databoxAbstract
public function printInterfaceHTML()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
ob_start();
@@ -475,7 +475,7 @@ class task_period_workflow01 extends task_databoxAbstract
{
$request = http_request::getInstance();
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
diff --git a/lib/classes/task/period/writemeta.class.php b/lib/classes/task/period/writemeta.class.php
index 726aa92278..da8d749502 100644
--- a/lib/classes/task/period/writemeta.class.php
+++ b/lib/classes/task/period/writemeta.class.php
@@ -183,7 +183,7 @@ class task_period_writemeta extends task_databoxAbstract
public function printInterfaceHTML()
{
- $appbox = appbox::get_instance();
+ $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$sbas_ids = User_Adapter::getInstance($session->get_usr_id(), $appbox)
->ACL()->get_granted_sbas(array('bas_manage'));
@@ -310,9 +310,9 @@ class task_period_writemeta extends task_databoxAbstract
if ($record->get_uuid())
{
- $subCMD .= '-XMP-exif:ImageUniqueID=';
+ $subCMD .= ' -XMP-exif:ImageUniqueID=';
$subCMD .= escapeshellarg($record->get_uuid());
- $subCMD .= '-IPTC:UniqueDocumentID=';
+ $subCMD .= ' -IPTC:UniqueDocumentID=';
$subCMD .= escapeshellarg($record->get_uuid());
}
@@ -325,24 +325,24 @@ class task_period_writemeta extends task_databoxAbstract
$multi = $meta->is_multi();
$type = $meta->get_type();
- $datas = $field->get_value();
+ $datas = $field->get_values();
if ($multi)
{
- $datas = $field->get_value();
foreach ($datas as $value)
{
- $value = $this->format_value($type, $value);
+ $value = $this->format_value($type, $value->getValue());
- $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
+ $subCMD .= ' -'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
$subCMD .= escapeshellarg($value).' ';
}
}
else
{
- $datas = $this->format_value($type, $datas);
+ $value = array_pop($datas);
+ $datas = $this->format_value($type, $value->getValue());
- $subCMD .= '-'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
+ $subCMD .= ' -'.$meta->get_metadata_namespace().':'.$meta->get_metadata_tagname().'=';
$subCMD .= escapeshellarg($datas).' ';
}
}
@@ -354,7 +354,7 @@ class task_period_writemeta extends task_databoxAbstract
$cmd = 'start /B /LOW ';
$cmd .= ( $registry->get('GV_exiftool') . ' -m -overwrite_original ');
if ($name != 'document' || $this->clear_doc)
- $cmd .= '-all:all= ';
+ $cmd .= ' -all:all= ';
$cmd .= ' -codedcharacterset=utf8 ';
diff --git a/lib/classes/unicode.class.php b/lib/classes/unicode.class.php
index 0838b5ea9a..274d7f5b9d 100644
--- a/lib/classes/unicode.class.php
+++ b/lib/classes/unicode.class.php
@@ -1391,7 +1391,7 @@ class unicode
return $no_diacritics;
}
- public function remove_nonazAZ09($string, $keep_underscores = true, $keep_minus = true)
+ public function remove_nonazAZ09($string, $keep_underscores = true, $keep_minus = true, $keep_dot = false)
{
$regexp = '/[a-zA-Z0-9';
if ($keep_minus === true)
@@ -1402,6 +1402,11 @@ class unicode
{
$regexp .= '_';
}
+ if ($keep_dot === true)
+ {
+ $regexp .= '\.';
+ }
+
$regexp .= ']{1}/';
$string = $this->remove_diacritics($string);
diff --git a/lib/conf.d/Doctrine/Entities.Basket.dcm.yml b/lib/conf.d/Doctrine/Entities.Basket.dcm.yml
new file mode 100644
index 0000000000..3d0ec3323b
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.Basket.dcm.yml
@@ -0,0 +1,46 @@
+Entities\Basket:
+ type: entity
+ repositoryClass: Repositories\BasketRepository
+ table: Baskets
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ name:
+ type: string
+ length: 128
+ description:
+ type: text
+ nullable: true
+ usr_id:
+ type: integer
+ is_read:
+ type: boolean
+ pusher_id:
+ type: integer
+ nullable: true
+ archived:
+ type: boolean
+ default: false
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ oneToOne:
+ validation:
+ targetEntity: ValidationSession
+ mappedBy: basket
+ cascade: ["ALL"]
+ oneToMany:
+ elements:
+ targetEntity: BasketElement
+ mappedBy: basket
+ cascade: ["ALL"]
diff --git a/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml b/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml
new file mode 100644
index 0000000000..a37e116d87
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml
@@ -0,0 +1,45 @@
+Entities\BasketElement:
+ type: entity
+ repositoryClass: Repositories\BasketElementRepository
+ table: BasketElements
+ uniqueConstraints:
+ unique_recordcle:
+ columns: basket_id,sbas_id,record_id
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+
+ fields:
+ record_id:
+ type: integer
+ sbas_id:
+ type: integer
+ ord:
+ type: integer
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ manyToOne:
+ basket:
+ targetEntity: Basket
+ inversedBy: elements
+ joinColumn:
+ name: basket_id
+ referencedColumnName: id
+ cascade: ["persist"]
+ oneToMany:
+ validation_datas:
+ targetEntity: ValidationData
+ mappedBy: basket_element
+ cascade: ["ALL"]
+ lifecycleCallbacks:
+ prePersist: [ setLastInBasket ]
diff --git a/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml b/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml
new file mode 100644
index 0000000000..fd82c27ebc
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml
@@ -0,0 +1,29 @@
+Entities\StoryWZ:
+ type: entity
+ repositoryClass: Repositories\StoryWZRepository
+ table: StoryWZ
+ uniqueConstraints:
+ user_story:
+ columns: usr_id,sbas_id,record_id
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ sbas_id:
+ type: integer
+ record_id:
+ type: integer
+ usr_id:
+ type: integer
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+
+
+
+
+
diff --git a/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml
new file mode 100644
index 0000000000..6eb3597d9e
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml
@@ -0,0 +1,33 @@
+Entities\UsrList:
+ type: entity
+ repositoryClass: Repositories\UsrListRepository
+ table: UsrLists
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ name:
+ type: string
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ oneToMany:
+ owners:
+ targetEntity: UsrListOwner
+ mappedBy: list
+ cascade: ["ALL"]
+ entries:
+ targetEntity: UsrListEntry
+ mappedBy: list
+ cascade: ["ALL"]
+
+
diff --git a/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml
new file mode 100644
index 0000000000..952bb9498b
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml
@@ -0,0 +1,35 @@
+Entities\UsrListEntry:
+ type: entity
+ repositoryClass: Repositories\UsrListEntryRepository
+ table: UsrListsContent
+ uniqueConstraints:
+ unique_usr_per_list:
+ columns: usr_id,list_id
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ usr_id:
+ type: integer
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ manyToOne:
+ list:
+ targetEntity: UsrList
+ inversedBy: users
+ joinColumn:
+ name: list_id
+ referencedColumnName: id
+ cascade: ["persist"]
+
+
diff --git a/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml
new file mode 100644
index 0000000000..9fb72bc084
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml
@@ -0,0 +1,38 @@
+Entities\UsrListOwner:
+ type: entity
+ repositoryClass: Repositories\UsrListOwnerRepository
+ table: UsrListOwners
+ uniqueConstraints:
+ unique_owner:
+ columns: usr_id,id
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ usr_id:
+ type: integer
+ role:
+ type: string
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ manyToOne:
+ list:
+ targetEntity: UsrList
+ inversedBy: owners
+ joinColumn:
+ name: list_id
+ referencedColumnName: id
+ cascade: ["persist"]
+
+
+
diff --git a/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml
new file mode 100644
index 0000000000..0133e0da2d
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml
@@ -0,0 +1,35 @@
+Entities\ValidationData:
+ type: entity
+ table: ValidationDatas
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ agreement:
+ type: boolean
+ nullable: true
+ note:
+ type: text
+ nullable: true
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ manyToOne:
+ participant:
+ targetEntity: ValidationParticipant
+ inversedBy: datas
+ joinColumn:
+ name: participant_id
+ referencedColumnName: id
+ cascade: ["persist"]
+ basket_element:
+ targetEntity: BasketElement
+ inversedBy: validation_datas
+ joinColumn:
+ name: basket_element_id
+ referencedColumnName: id
+ cascade: ["persist"]
diff --git a/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml
new file mode 100644
index 0000000000..0d458c6e9d
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml
@@ -0,0 +1,36 @@
+Entities\ValidationParticipant:
+ type: entity
+ repositoryClass: Repositories\ValidationParticipantRepository
+ table: ValidationParticipants
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ usr_id:
+ type: integer
+ is_aware:
+ type: boolean
+ is_confirmed:
+ type: boolean
+ can_agree:
+ type: boolean
+ can_see_others:
+ type: boolean
+ reminded:
+ type: datetime
+ nullable: true;
+ oneToMany:
+ datas:
+ targetEntity: ValidationData
+ mappedBy: participant
+ cascade: ["ALL"]
+ manyToOne:
+ session:
+ targetEntity: ValidationSession
+ inversedBy: participants
+ joinColumn:
+ name: ValidationSession_id
+ referencedColumnName: id
+ cascade: ["persist"]
diff --git a/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml
new file mode 100644
index 0000000000..1c3c901c27
--- /dev/null
+++ b/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml
@@ -0,0 +1,41 @@
+Entities\ValidationSession:
+ type: entity
+ table: ValidationSessions
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ fields:
+ initiator_id:
+ type: integer
+ created:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: create
+ updated:
+ type: datetime
+ gedmo:
+ timestampable:
+ on: update
+ expires:
+ type: datetime
+ nullable: true
+ oneToOne:
+ basket:
+ targetEntity: Basket
+ inversedBy: validation
+ joinColumn:
+ name: basket_id
+ referencedColumnName: id
+ cascade: ["persist"]
+ oneToMany:
+ participants:
+ targetEntity: ValidationParticipant
+ mappedBy: session
+ cascade: ["ALL"]
+
+
+
+
diff --git a/lib/conf.d/PhraseaFixture/AbstractWZ.php b/lib/conf.d/PhraseaFixture/AbstractWZ.php
new file mode 100644
index 0000000000..8c80f2d384
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/AbstractWZ.php
@@ -0,0 +1,50 @@
+user;
+ }
+
+ public function setUser(\User_Adapter $user)
+ {
+ $this->user = $user;
+ }
+
+
+ public function getRecord()
+ {
+ return $this->record;
+ }
+
+ public function setRecord(\record_adapter $record)
+ {
+ $this->record = $record;
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php b/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php
new file mode 100644
index 0000000000..3e42b13034
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php
@@ -0,0 +1,56 @@
+setName('test ' . $i);
+ $basket->setDescription('description');
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new basket');
+ }
+
+ $basket->setOwner($this->user);
+
+ $manager->persist($basket);
+
+ $this->baskets[] = $basket;
+ }
+ $this->addReference('five-basket', $basket);
+ $manager->flush();
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php
new file mode 100644
index 0000000000..fc9ea7083c
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php
@@ -0,0 +1,54 @@
+setName('test');
+ $basket->setDescription('description');
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new basket');
+ }
+
+ $basket->setOwner($this->user);
+
+ $manager->persist($basket);
+ $manager->flush();
+
+ $this->basket = $basket;
+
+ $this->addReference('one-basket', $basket);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php
new file mode 100644
index 0000000000..6ab35c431c
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php
@@ -0,0 +1,138 @@
+participants[] = $user;
+ }
+
+ public function addBasketElement(\record_adapter $record)
+ {
+ $this->basketElements[] = $record;
+ }
+
+ public function load($manager)
+ {
+ $basket = new \Entities\Basket();
+
+ $basket->setName('test');
+
+ $basket->setDescription('description');
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new basket');
+ }
+
+ $basket->setOwner($this->user);
+
+ $this->addElementToBasket($manager, $basket);
+
+ $validationSession = new \Entities\ValidationSession();
+
+ $validationSession->setBasket($basket);
+
+ $validationSession->setDescription('Une description au hasard');
+
+ $validationSession->setName('Un nom de validation');
+
+ $expires = new \DateTime();
+ $expires->modify('+1 week');
+
+ $validationSession->setExpires($expires);
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new validation Session');
+ }
+
+ $validationSession->setInitiator($this->user);
+
+ $this->addParticipantsToSession($manager, $validationSession);
+
+ $this->basket = $basket;
+ }
+
+ private function addParticipantsToSession(\Doctrine\ORM\EntityManager $manager, \Entities\ValidationSession $validationSession)
+ {
+ if (0 === count($this->participants))
+ {
+ throw new \LogicException('Add new participants to validation session');
+ }
+
+ foreach ($this->participants as $participant)
+ {
+ $validationParticipant = new \Entities\ValidationParticipant();
+
+ $validationParticipant->setUser($participant);
+
+ $validationParticipant->setSession($validationSession);
+
+ $manager->persist($validationParticipant);
+ }
+
+ $manager->flush();
+ }
+
+ private function addElementToBasket(\Doctrine\ORM\EntityManager $manager, \Entities\Basket $basket)
+ {
+ if (0 === count($this->basketElements))
+ {
+ throw new \LogicException('Add new elements to basket');
+ }
+
+ foreach ($this->basketElements as $record)
+ {
+ $basketElement = new \Entities\BasketElement();
+
+ $basketElement->setRecord($record);
+
+ $basketElement->setBasket($basket);
+
+ $manager->persist($basketElement);
+ }
+
+ $manager->flush();
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/Story/LoadOneStory.php b/lib/conf.d/PhraseaFixture/Story/LoadOneStory.php
new file mode 100644
index 0000000000..2a29f6b1de
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/Story/LoadOneStory.php
@@ -0,0 +1,57 @@
+record)
+ {
+ throw new \LogicException('Fill a record to store a new story');
+ }
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new story');
+ }
+
+ $story->setRecord($this->record);
+ $story->setUser($this->user);
+
+ $manager->persist($story);
+ $manager->flush();
+
+ $this->story = $story;
+
+ $this->addReference('one-story', $story);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php b/lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php
new file mode 100644
index 0000000000..29f360d934
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php
@@ -0,0 +1,45 @@
+user;
+ }
+
+ public function setUser(\User_Adapter $user)
+ {
+ $this->user = $user;
+ }
+
+ public function getList()
+ {
+ return $this->list;
+ }
+
+ public function setList(\Entities\UsrList $list)
+ {
+ $this->list = $list;
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/UsrLists/UsrList.php b/lib/conf.d/PhraseaFixture/UsrLists/UsrList.php
new file mode 100644
index 0000000000..14a23a824a
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/UsrLists/UsrList.php
@@ -0,0 +1,53 @@
+getReference('one-listowner');
+
+ $list->setName('new list');
+ $list->addUsrListOwner($owner);
+
+ /* @var $owner \Entities\UsrListOwner */
+ $owner->setList($list);
+
+ $manager->persist($list);
+ $manager->merge($owner);
+ $manager->flush();
+
+ $this->list = $list;
+
+ $this->addReference('one-list', $list);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php b/lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php
new file mode 100644
index 0000000000..7d5e00e823
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php
@@ -0,0 +1,64 @@
+user)
+ {
+ throw new \LogicException('Fill a user to store a new basket');
+ }
+
+ $list = $this->getReference('one-list');
+
+ $entry->setUser($this->user);
+ $entry->setList($list);
+
+ /* @var $list \Entities\UsrList */
+ $list->addUsrListEntry($entry);
+
+ $manager->persist($entry);
+ $manager->flush();
+
+ $this->entry = $entry;
+
+ $this->addReference('one-entry', $entry);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php b/lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php
new file mode 100644
index 0000000000..7da0fa90c9
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php
@@ -0,0 +1,51 @@
+setRole(\Entities\UsrListOwner::ROLE_ADMIN);
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new basket');
+ }
+
+ $owner->setUser($this->user);
+
+ $manager->persist($owner);
+ $manager->flush();
+
+ $this->owner = $owner;
+
+ $this->addReference('one-listowner', $owner);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php
new file mode 100644
index 0000000000..fb03a0d1ff
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php
@@ -0,0 +1,54 @@
+user)
+ {
+ throw new \LogicException('Fill a user to store a new validation Session');
+ }
+ $validationParticipant->setParticipant($this->user);
+
+ $validationParticipant->setSession(
+ $this->getReference('one-validation-session')
+ );
+
+ $manager->persist($validationParticipant);
+ $manager->flush();
+
+ $this->validationParticipant = $validationParticipant;
+
+ $this->addReference('one-validation-participant', $validationParticipant);
+ }
+
+}
diff --git a/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php
new file mode 100644
index 0000000000..e730e949da
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php
@@ -0,0 +1,66 @@
+user)
+ {
+ throw new \LogicException('Fill a user to store a new validation Session');
+ }
+ $validationParticipant->setUser($this->user);
+
+ if (null === $this->session)
+ {
+ throw new \LogicException('Attach a session to the current participant');
+ }
+ $validationParticipant->setSession($this->session);
+
+ $manager->persist($validationParticipant);
+ $manager->flush();
+
+ $this->validationParticipant = $validationParticipant;
+ }
+
+ public function setSession(\Entities\ValidationSession $session)
+ {
+ $this->session = $session;
+ }
+
+
+}
diff --git a/lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php b/lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php
new file mode 100644
index 0000000000..b25457ef4d
--- /dev/null
+++ b/lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php
@@ -0,0 +1,61 @@
+setBasket(
+ $this->getReference('one-basket') // load the one-basket stored reference
+ );
+
+ $validationSession->setDescription('Une description au hasard');
+ $validationSession->setName('Un nom de validation');
+
+ $expires = new \DateTime();
+ $expires->modify('+1 week');
+ $validationSession->setExpires($expires);
+
+ if (null === $this->user)
+ {
+ throw new \LogicException('Fill a user to store a new validation Session');
+ }
+ $validationSession->setInitiator($this->user);
+
+ $manager->persist($validationSession);
+ $manager->flush();
+
+ $this->validationSession = $validationSession;
+
+ $this->addReference('one-validation-session', $validationSession);
+ }
+
+}
diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc
index 12e93999c3..f2e4a8a24c 100644
--- a/lib/conf.d/_GV_template.inc
+++ b/lib/conf.d/_GV_template.inc
@@ -10,8 +10,10 @@ $GV_sit = md5(time() . '--' . mt_rand(1000000, 9999999));
include_once dirname(__FILE__) . "/../../lib/classes/User/Interface.class.php";
include_once dirname(__FILE__) . "/../../lib/classes/User/Adapter.class.php";
-$lngs = User_Adapter::avLanguages();
+
+$lngs = User_Adapter::avLanguages();
$avLanguages = array();
+
foreach ($lngs as $lng => $locales)
{
foreach ($locales as $loc => $locname)
@@ -19,29 +21,49 @@ foreach ($lngs as $lng => $locales)
$avLanguages[$loc] = $locname['name'];
}
}
- $eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance());
+$Core = \bootstrap::getCore();
+
+$extractDateFields = function(\Alchemy\Phrasea\Core $Core) {
+ $date_sort_fields = array(''=>'');
+ if ($Core->getConfiguration()->isInstalled())
+ {
+ $ProdHelper = new Alchemy\Phrasea\Helper\Prod($Core, Symfony\Component\HttpFoundation\Request::createFromGlobals());
+ $datas = $ProdHelper->get_search_datas();
+ foreach ($datas['dates'] as $date)
+ {
+ $date_sort_fields[$date['fieldname']] = $date['fieldname'];
+ }
+ }
+
+ return $date_sort_fields;
+};
+
+$date_sort_fields = $extractDateFields($Core);
+
+
+$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance($Core), $Core);
$PHP_CONF = array(
- 'output_buffering' => '4096' //INI_ALL
- , 'memory_limit' => '1024M' //INI_ALL
- , 'error_reporting' => '6143' //INI_ALL
- , 'default_charset' => 'UTF-8' //INI_ALL
- , 'session.use_cookies' => '1' //INI_ALL
- , 'session.use_only_cookies' => '1' //INI_ALL
- , 'session.auto_start' => '0' //INI_ALL
- , 'session.hash_function' => '1' //INI_ALL
- , 'session.hash_bits_per_character' => '6' //INI_ALL
- , 'allow_url_fopen' => 'on' //INI_ALL
- , 'display_errors' => 'off' //INI_ALL
- , 'display_startup_errors' => 'off' //INI_ALL
- , 'log_errors' => 'off' //INI_ALL
+ 'output_buffering' => '4096' //INI_ALL
+ , 'memory_limit' => '1024M' //INI_ALL
+ , 'error_reporting' => '6143' //INI_ALL
+ , 'default_charset' => 'UTF-8' //INI_ALL
+ , 'session.use_cookies' => '1' //INI_ALL
+ , 'session.use_only_cookies' => '1' //INI_ALL
+ , 'session.auto_start' => '0' //INI_ALL
+ , 'session.hash_function' => '1' //INI_ALL
+ , 'session.hash_bits_per_character' => '6' //INI_ALL
+ , 'allow_url_fopen' => 'on' //INI_ALL
+ , 'display_errors' => 'off' //INI_ALL
+ , 'display_startup_errors' => 'off' //INI_ALL
+ , 'log_errors' => 'off' //INI_ALL
);
-$PHP_REQ = array(
- 'safe_mode' => 'off'
- , 'file_uploads' => '1'
- , 'magic_quotes_runtime' => 'off' //INI_ALL
- , 'magic_quotes_gpc' => 'off' //INI_PER_DIR -- just for check
+$PHP_REQ = array(
+ 'safe_mode' => 'off'
+ , 'file_uploads' => '1'
+ , 'magic_quotes_runtime' => 'off' //INI_ALL
+ , 'magic_quotes_gpc' => 'off' //INI_PER_DIR -- just for check
);
$youtube_console_url = 'https://code.google.com/apis/console/ ';
@@ -57,470 +79,452 @@ $dailymotion_callback = '/prod/bridge/callback/dailymotion/';
$create_api_dailymotion = 'http://www.dailymotion.com/profile/developer ';
$GV = array(
- array(
- 'section' => _('GV::section:: Serveur HTTP'),
- 'vars' => array(
- array(
- 'type' => 'timezone',
- 'name' => 'GV_timezone',
- 'comment' => _('reglages:: Timezone de l\'installation'),
- 'default' => 'Europe/Paris',
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_sit',
- 'comment' => _('reglages:: Nom de linstallation'),
- 'default' => $GV_sit,
- 'readonly' => true,
- 'required' => true
- ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_default_lng',
- 'comment' => _('reglages:: Langue par defaut'),
- 'default' => 'fr_FR',
- 'available' => $avLanguages,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_STATIC_URL',
- 'end_slash' => false,
- 'comment' => _('reglages:: URL statique (optionnel)'),
- 'default' => '',
- 'required' => false
- )
- )
- ), array(
- 'section' => _('GV::section:: Etat de maintenance'),
- 'rolled' => true,
- 'vars' => array(
- array(
- 'type' => 'text',
- 'name' => 'GV_message',
- 'comment' => _('reglages:: Message a diffuser aux utilisateurs'),
- 'default' => "May the force be with you"
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_message_on',
- 'comment' => _('reglages:: activation du message a diffuser aux utilistaeurs'),
- 'default' => false
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_log_errors',
- 'comment' => _('reglages:: logguer les erreurs'),
- 'default' => false
- )
- )
- ), array(
- 'section' => _('GV::section:: Connectivite aux webservices'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_google_api',
- 'comment' => _('reglages:: Utiliser els google apis'),
- 'default' => true,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_i18n_service',
- 'comment' => _('reglages:: Service phrasea de localisation'),
- 'default' => 'http://localization.webservice.alchemyasp.com/',
- 'end_slash' => true,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_bitly_user',
- 'comment' => _('reglages:: Nom d\'utilisateur pour l\'api bit.ly'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_bitly_key',
- 'comment' => _('reglages:: ccle d\'api pour l\'api bit.ly'),
- 'default' => '',
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_captchas',
- 'comment' => _('reglages:: Utilisation de l\'api recpatcha'),
- 'default' => false,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_captcha_public_key',
- 'comment' => _('reglages:: clef publique recaptcha'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_captcha_private_key',
- 'comment' => _('reglages:: clef privee recaptcha'),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Connectivite a Youtube'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_youtube_api',
- 'comment' => sprintf(_('reglages:: Utiliser l\'api youtube, voir %s, mettre la callback a WEBSITE_URL/prod/bridge/callback/youtube'), $youtube_console_url),
- 'default' => false,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_youtube_client_id',
- 'comment' => _('reglages:: Youtube client id'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_youtube_client_secret',
- 'comment' => _('reglages:: Youtube clientsecret'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_youtube_dev_key',
- 'comment' => sprintf(_('reglages:: Youtube cle developpeur, voir %s'), $dashboard_youtube),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Connectivite a FlickR'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_flickr_api',
- 'comment' => sprintf(_('reglages:: Utiliser l api flickr, voir %s, puis set la callback a %s'), $create_api_flickr, $flickr_callback),
- 'default' => false,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_flickr_client_id',
- 'comment' => _('reglages:: FlickR client id'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_flickr_client_secret',
- 'comment' => _('reglages:: FlickR client secret'),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Connectivite a Dailymotion'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_dailymotion_api',
- 'comment' => sprintf(_('reglages:: Utiliser l api dailymotion, voir %s, puis set la callback a %s'), $create_api_dailymotion, $dailymotion_callback),
- 'default' => false,
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_dailymotion_client_id',
- 'comment' => _('reglages:: dailymotion client id'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_dailymotion_client_secret',
- 'comment' => _('reglages:: dailymotion client secret'),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Gestionnaire d\'evenements'),
- 'vars' => array(
- array(
- 'type' => 'enum_multi',
- 'name' => 'GV_events',
- 'default'=>null,
- 'comment' => _('reglages:: Evenements'),
- 'available'=> $eventsmanager->list_all('event'),
- 'default'=> array_keys($eventsmanager->list_all('event'))
- ),
- array(
- 'type' => 'enum_multi',
- 'name' => 'GV_notifications',
- 'default'=>null,
- 'comment' => _('reglages:: Notifications'),
- 'available'=> $eventsmanager->list_all('notify'),
- 'default'=> array_keys($eventsmanager->list_all('notify'))
- )
- )
- ), array(
- 'section' => _('GV::section:: Stockage des documents'),
- 'vars' => array(
- array(
- 'type' => 'string',
- 'name' => 'GV_appletAllowedFileExt',
- 'comment' => _('reglages:: extensions de fichier autorisees en upload, separees par des virgules. * pour autoriser tous les fichiers'),
- 'default' => 'jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2',
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_base_datapath_web',
- 'end_slash' => true,
- 'comment' => _('reglages:: dossier de stockage des vignettes publiees en acces direct'),
- 'default'=>'',
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_base_datapath_noweb',
- 'end_slash' => true,
- 'comment' => _('reglages:: dossier de stockage des fichiers proteges de l\'acces direct'),
- 'default'=>'',
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_base_dataurl',
- 'comment' => _('reglages:: point de montage des vignettes publiees en acces direct'),
- 'default' => 'web',
- 'end_slash' => false,
- 'required' => true
- )
- )
- ), array(
- 'section' => _('GV::section:: Serveurs de cache'),
- 'vars' => array(
-// array(
-// 'type' => 'boolean',
-// 'name' => 'GV_use_cache',
-// 'comment' => _('reglages:: Utiliser un serveur de cache'),
-// 'default' => false,
-// 'required' => true
-// ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_cache_server_type',
- 'comment' => _('reglages:: Utiliser un serveur de cache'),
- 'default' => '',
- 'available' => array(''=>_('Aucun'),'redis' => 'Redis', 'memcached' => 'Memcached')
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_cache_server_host',
- 'comment' => _('setup:: Hote du Serveur de cache'),
- 'default' => '127.0.0.1',
- 'required' => false
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_cache_server_port',
- 'comment' => _('reglages:: port du serveur de cache'),
- 'default' => 11211
- )
- )
- ),array(
- 'section' => _('GV::section:: Serveur Sphinx'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_sphinx',
- 'comment' => _('Utiliser Sphinx'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_sphinx_host',
- 'comment' => _('reglages:: de l\'adresse du serveur sphinx'),
- 'default' => '127.0.0.1'
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_sphinx_port',
- 'comment' => _('reglages:: port du serveur sphinx'),
- 'default' => 9306
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_sphinx_rt_host',
- 'comment' => _('reglages:: de l\'adresse du serveur RT sphinx'),
- 'default' => '127.0.0.1'
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_sphinx_rt_port',
- 'comment' => _('reglages:: port du serveur RT sphinx'),
- 'default' => 9308
- )
- )
- ), array(
- 'section' => _('GV::section:: Executables externes'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_modxsendfile',
- 'comment' => _('reglages:: mod_xsendfileapache active'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_X_Accel_Redirect',
- 'comment' => _('reglages:: Path en acces pour X-Accel-Redirect (NginX Uniquement)'),
- 'default' => '',
- 'end_slash' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_X_Accel_Redirect_mount_point',
- 'comment' => _('reglages:: Point de montage pour X-Accel-Redirect (NginX Uniquement)'),
- 'default' => 'noweb',
- 'end_slash' => false
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_h264_streaming',
- 'comment' => _('reglages:: activation du stream h264 via mod_token - attention, necessite les modules apache mod_h264_streaming et mod_auth_token'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_mod_auth_token_directory',
- 'end_slash' => true,
- 'comment' => _('reglages:: point de montage du dossier protege via auth_token'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_mod_auth_token_directory_path',
- 'end_slash' => false,
- 'comment' => _('reglages:: path complet du dossier protege via auth_token'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_mod_auth_token_passphrase',
- 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_cli',
- 'comment' => _('reglages:: executable PHP CLI'),
- 'default'=>'',
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_PHP_INI',
- 'comment' => _('reglages:: path du php.ini specifique (vide si non utilise)'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_imagick',
- 'default'=>'',
- 'comment' => _('reglages:: chemin de l\'executable convert'),
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_pathcomposite',
- 'default'=>'',
- 'comment' => _('reglages:: chemin de l\'executable composite'),
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_exiftool',
- 'default'=>'',
- 'comment' => _('reglages:: chemin de l\'executable exiftools'),
- 'required' => true
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_swf_extract',
- 'comment' => _('reglages:: chemin de l\'executable swfextract'),
- 'default' => '',
- 'required' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_pdf2swf',
- 'comment' => _('reglages:: chemin de l\'executable pdf2swf'),
- 'default' => '',
- 'required' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_swf_render',
- 'comment' => _('reglages:: chemin de l\'executable swfrender'),
- 'default' => '',
- 'required' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_unoconv',
- 'comment' => _('reglages:: chemin de l\'executable unoconv'),
- 'default' => '',
- 'required' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_ffmpeg',
- 'comment' => _('reglages:: chemin de l\'executable FFmpeg'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_mp4box',
- 'comment' => _('reglages:: chemin de l\'executable MP4Box'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_mplayer',
- 'comment' => _('reglages:: chemin de l\'executable Mplayer'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_pdftotext',
- 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'),
- 'default' => ''
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_pdfmaxpages',
- 'comment' => _('reglages:: nombre maximum de page a extraire (PDF)'),
- 'default' => 5
- )
- )
- ), array(
- 'section' => _('GV::section:: Repertoires utilitaires'),
- 'vars' => array(
- array(
- 'type' => 'string',
- 'name' => 'GV_filesOwner',
- 'comment' => _('reglages:: proprietaire des fichiers'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_filesGroup',
- 'comment' => _('reglages:: groupes des fichiers'),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Configuration principale'),
- 'vars' => array(
+ array(
+ 'section' => _('GV::section:: Serveur HTTP'),
+ 'vars' => array(
+ array(
+ 'type' => 'timezone',
+ 'name' => 'GV_timezone',
+ 'comment' => _('reglages:: Timezone de l\'installation'),
+ 'default' => 'Europe/Paris',
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_sit',
+ 'comment' => _('reglages:: Nom de linstallation'),
+ 'default' => $GV_sit,
+ 'readonly' => true,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_default_lng',
+ 'comment' => _('reglages:: Langue par defaut'),
+ 'default' => 'fr_FR',
+ 'available' => $avLanguages,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_STATIC_URL',
+ 'end_slash' => false,
+ 'comment' => _('reglages:: URL statique (optionnel)'),
+ 'default' => '',
+ 'required' => false
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Etat de maintenance'),
+ 'rolled' => true,
+ 'vars' => array(
+ array(
+ 'type' => 'text',
+ 'name' => 'GV_message',
+ 'comment' => _('reglages:: Message a diffuser aux utilisateurs'),
+ 'default' => "May the force be with you"
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_message_on',
+ 'comment' => _('reglages:: activation du message a diffuser aux utilistaeurs'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_log_errors',
+ 'comment' => _('reglages:: logguer les erreurs'),
+ 'default' => false
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Connectivite aux webservices'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_google_api',
+ 'comment' => _('reglages:: Utiliser els google apis'),
+ 'default' => true,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_i18n_service',
+ 'comment' => _('reglages:: Service phrasea de localisation'),
+ 'default' => 'http://localization.webservice.alchemyasp.com/',
+ 'end_slash' => true,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_bitly_user',
+ 'comment' => _('reglages:: Nom d\'utilisateur pour l\'api bit.ly'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_bitly_key',
+ 'comment' => _('reglages:: ccle d\'api pour l\'api bit.ly'),
+ 'default' => '',
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_captchas',
+ 'comment' => _('reglages:: Utilisation de l\'api recpatcha'),
+ 'default' => false,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_captcha_public_key',
+ 'comment' => _('reglages:: clef publique recaptcha'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_captcha_private_key',
+ 'comment' => _('reglages:: clef privee recaptcha'),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Connectivite a Youtube'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_youtube_api',
+ 'comment' => sprintf(_('reglages:: Utiliser l\'api youtube, voir %s, mettre la callback a WEBSITE_URL/prod/bridge/callback/youtube'), $youtube_console_url),
+ 'default' => false,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_youtube_client_id',
+ 'comment' => _('reglages:: Youtube client id'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_youtube_client_secret',
+ 'comment' => _('reglages:: Youtube clientsecret'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_youtube_dev_key',
+ 'comment' => sprintf(_('reglages:: Youtube cle developpeur, voir %s'), $dashboard_youtube),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Connectivite a FlickR'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_flickr_api',
+ 'comment' => sprintf(_('reglages:: Utiliser l api flickr, voir %s, puis set la callback a %s'), $create_api_flickr, $flickr_callback),
+ 'default' => false,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_flickr_client_id',
+ 'comment' => _('reglages:: FlickR client id'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_flickr_client_secret',
+ 'comment' => _('reglages:: FlickR client secret'),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Connectivite a Dailymotion'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_dailymotion_api',
+ 'comment' => sprintf(_('reglages:: Utiliser l api dailymotion, voir %s, puis set la callback a %s'), $create_api_dailymotion, $dailymotion_callback),
+ 'default' => false,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_dailymotion_client_id',
+ 'comment' => _('reglages:: dailymotion client id'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_dailymotion_client_secret',
+ 'comment' => _('reglages:: dailymotion client secret'),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Gestionnaire d\'evenements'),
+ 'vars' => array(
+ array(
+ 'type' => 'enum_multi',
+ 'name' => 'GV_events',
+ 'default' => null,
+ 'comment' => _('reglages:: Evenements'),
+ 'available' => $eventsmanager->list_all('event'),
+ 'default' => array_keys($eventsmanager->list_all('event'))
+ ),
+ array(
+ 'type' => 'enum_multi',
+ 'name' => 'GV_notifications',
+ 'default' => null,
+ 'comment' => _('reglages:: Notifications'),
+ 'available' => $eventsmanager->list_all('notify'),
+ 'default' => array_keys($eventsmanager->list_all('notify'))
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Stockage des documents'),
+ 'vars' => array(
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_appletAllowedFileExt',
+ 'comment' => _('reglages:: extensions de fichier autorisees en upload, separees par des virgules. * pour autoriser tous les fichiers'),
+ 'default' => 'jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2',
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_base_datapath_web',
+ 'end_slash' => true,
+ 'comment' => _('reglages:: dossier de stockage des vignettes publiees en acces direct'),
+ 'default' => '',
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_base_datapath_noweb',
+ 'end_slash' => true,
+ 'comment' => _('reglages:: dossier de stockage des fichiers proteges de l\'acces direct'),
+ 'default' => '',
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_base_dataurl',
+ 'comment' => _('reglages:: point de montage des vignettes publiees en acces direct'),
+ 'default' => 'web',
+ 'end_slash' => false,
+ 'required' => true
+ )
+ )
+ )
+ , array(
+ 'section' => _('GV::section:: Serveur Sphinx'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_sphinx',
+ 'comment' => _('Utiliser Sphinx'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_sphinx_host',
+ 'comment' => _('reglages:: de l\'adresse du serveur sphinx'),
+ 'default' => '127.0.0.1'
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_sphinx_port',
+ 'comment' => _('reglages:: port du serveur sphinx'),
+ 'default' => 9306
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_sphinx_rt_host',
+ 'comment' => _('reglages:: de l\'adresse du serveur RT sphinx'),
+ 'default' => '127.0.0.1'
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_sphinx_rt_port',
+ 'comment' => _('reglages:: port du serveur RT sphinx'),
+ 'default' => 9308
+ )
+ )
+ )
+ , array(
+ 'section' => _('Phrasea Engine'),
+ 'vars' => array(
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_phrasea_sort',
+ 'comment' => _('Default results sort'),
+ 'default' => '',
+ 'available' => $date_sort_fields
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Executables externes'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_modxsendfile',
+ 'comment' => _('reglages:: mod_xsendfileapache active'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_X_Accel_Redirect',
+ 'comment' => _('reglages:: Path en acces pour X-Accel-Redirect (NginX Uniquement)'),
+ 'default' => '',
+ 'end_slash' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_X_Accel_Redirect_mount_point',
+ 'comment' => _('reglages:: Point de montage pour X-Accel-Redirect (NginX Uniquement)'),
+ 'default' => 'noweb',
+ 'end_slash' => false
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_h264_streaming',
+ 'comment' => _('reglages:: activation du stream h264 via mod_token - attention, necessite les modules apache mod_h264_streaming et mod_auth_token'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_mod_auth_token_directory',
+ 'end_slash' => true,
+ 'comment' => _('reglages:: point de montage du dossier protege via auth_token'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_mod_auth_token_directory_path',
+ 'end_slash' => false,
+ 'comment' => _('reglages:: path complet du dossier protege via auth_token'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_mod_auth_token_passphrase',
+ 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_cli',
+ 'comment' => _('reglages:: executable PHP CLI'),
+ 'default' => '',
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_PHP_INI',
+ 'comment' => _('reglages:: path du php.ini specifique (vide si non utilise)'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_imagick',
+ 'default' => '',
+ 'comment' => _('reglages:: chemin de l\'executable convert'),
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_pathcomposite',
+ 'default' => '',
+ 'comment' => _('reglages:: chemin de l\'executable composite'),
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_exiftool',
+ 'default' => '',
+ 'comment' => _('reglages:: chemin de l\'executable exiftools'),
+ 'required' => true
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_swf_extract',
+ 'comment' => _('reglages:: chemin de l\'executable swfextract'),
+ 'default' => '',
+ 'required' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_pdf2swf',
+ 'comment' => _('reglages:: chemin de l\'executable pdf2swf'),
+ 'default' => '',
+ 'required' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_swf_render',
+ 'comment' => _('reglages:: chemin de l\'executable swfrender'),
+ 'default' => '',
+ 'required' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_unoconv',
+ 'comment' => _('reglages:: chemin de l\'executable unoconv'),
+ 'default' => '',
+ 'required' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_ffmpeg',
+ 'comment' => _('reglages:: chemin de l\'executable FFmpeg'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_mp4box',
+ 'comment' => _('reglages:: chemin de l\'executable MP4Box'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_mplayer',
+ 'comment' => _('reglages:: chemin de l\'executable Mplayer'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_pdftotext',
+ 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_pdfmaxpages',
+ 'comment' => _('reglages:: nombre maximum de page a extraire (PDF)'),
+ 'default' => 5
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Repertoires utilitaires'),
+ 'vars' => array(
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_filesOwner',
+ 'comment' => _('reglages:: proprietaire des fichiers'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_filesGroup',
+ 'comment' => _('reglages:: groupes des fichiers'),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Configuration principale'),
+ 'vars' => array(
// array(
// 'type' => 'boolean',
// 'name' => 'GV_logobeforebas',
@@ -528,33 +532,33 @@ $GV = array(
// 'default' => false,
// 'required' => true
// ),
- array(
- 'type' => 'string',
- 'name' => 'GV_adminMail',
- 'comment' => _('reglages:: email de l\'administrateur'),
- 'default' => 'support@alchemy.fr'
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_view_bas_and_coll',
- 'comment' => _('reglages:: Afficher le nom des bases et des collections'),
- 'default' => true,
- 'required' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_choose_export_title',
- 'comment' => _('reglages:: activer le choix du nom de fichier a l\'export'),
- 'default' => false,
- 'required' => true
- ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_default_export_title',
- 'comment' => _('reglages:: choix par defaut des noms de fichier a l\'export'),
- 'default' => 'support@alchemy.fr',
- 'available' => array('title' => 'Titre du document', 'original' => 'Nom original')
- ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_adminMail',
+ 'comment' => _('reglages:: email de l\'administrateur'),
+ 'default' => 'support@alchemy.fr'
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_view_bas_and_coll',
+ 'comment' => _('reglages:: Afficher le nom des bases et des collections'),
+ 'default' => true,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_choose_export_title',
+ 'comment' => _('reglages:: activer le choix du nom de fichier a l\'export'),
+ 'default' => false,
+ 'required' => true
+ ),
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_default_export_title',
+ 'comment' => _('reglages:: choix par defaut des noms de fichier a l\'export'),
+ 'default' => 'support@alchemy.fr',
+ 'available' => array('title' => 'Titre du document', 'original' => 'Nom original')
+ ),
// array(
// 'type' => 'boolean',
// 'name' => 'GV_ArchiveSorted',
@@ -562,19 +566,19 @@ $GV = array(
// 'default' => true,
// 'required' => true
// ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_social_tools',
- 'comment' => _('reglages:: Active les partages Facebook et Twitter'),
- 'available' => array('none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Activated'),
- 'default' => 'none',
- 'required' => false
- )
- )
- ), array(
- 'section' => _('GV::section:: Page d\'accueil'),
- 'rolled' => true,
- 'vars' => array(
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_social_tools',
+ 'comment' => _('reglages:: Active les partages Facebook et Twitter'),
+ 'available' => array('none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Activated'),
+ 'default' => 'none',
+ 'required' => false
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Page d\'accueil'),
+ 'rolled' => true,
+ 'vars' => array(
// array(
// 'type' => 'boolean',
// 'name' => 'GV_find_password',
@@ -582,78 +586,78 @@ $GV = array(
// 'default' => true,
// 'required' => true
// ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_home_publi',
- 'comment' => _('reglages:: presentation sur la home'),
- 'default' => 'COOLIRIS',
- 'available' => array('DISPLAYx1' => 'slideshow', 'SCROLL' => 'Bandeau defilant', 'COOLIRIS' => 'Cooliris'),
- 'required' => true
- )
- )
- ), array(
- 'section' => _('GV::section:: Moteur de recherche'),
- 'rolled' => true,
- 'vars' => array(
- array(
- 'type' => 'integer',
- 'name' => 'GV_min_letters_truncation',
- 'comment' => _('reglages:: Nombre minimal de lettre avec la troncature (Recherche)'),
- 'default' => 1
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_defaultQuery',
- 'comment' => _('reglages:: Question par defaut'),
- 'default' => 'all'
- ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_defaultQuery_type',
- 'comment' => _('reglages:: type de document cherches par defaut e l\'ouverture du site'),
- 'available' => array('0' => 'Documents', '1' => 'Regroupements'),
- 'default' => '0'
- )
- )
- ), array(
- 'section' => _('GV::section:: Report'),
- 'rolled' => true,
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_anonymousReport',
- 'comment' => _('reglages:: report anonyme (masque les infos concernant les utilisateurs)'),
- 'default' => false,
- 'required' => true
- )
- )
- ), array(
- 'section' => _('GV::section:: Modules supplementaires'),
- 'rolled' => true,
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_thesaurus',
- 'comment' => _('reglages:: Activation de l\'outil thesaurus'),
- 'default' => true
- ), array(
- 'type' => 'boolean',
- 'name' => 'GV_multiAndReport',
- 'comment' => _('reglages:: Activation du Mode MultiDOC'),
- 'default' => true
- ), array(
- 'type' => 'boolean',
- 'name' => 'GV_seeOngChgDoc',
- 'comment' => _('reglages:: Substitution de HD d\'un record '),
- 'default' => false
- ), array(
- 'type' => 'boolean',
- 'name' => 'GV_seeNewThumb',
- 'comment' => _('reglages:: Substitution de thumbnail d\'un record'),
- 'default' => false
- )
- )
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_home_publi',
+ 'comment' => _('reglages:: presentation sur la home'),
+ 'default' => 'COOLIRIS',
+ 'available' => array('DISPLAYx1' => 'slideshow', 'SCROLL' => 'Bandeau defilant', 'COOLIRIS' => 'Cooliris'),
+ 'required' => true
+ )
)
+ ), array(
+ 'section' => _('GV::section:: Moteur de recherche'),
+ 'rolled' => true,
+ 'vars' => array(
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_min_letters_truncation',
+ 'comment' => _('reglages:: Nombre minimal de lettre avec la troncature (Recherche)'),
+ 'default' => 1
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_defaultQuery',
+ 'comment' => _('reglages:: Question par defaut'),
+ 'default' => 'all'
+ ),
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_defaultQuery_type',
+ 'comment' => _('reglages:: type de document cherches par defaut e l\'ouverture du site'),
+ 'available' => array('0' => 'Documents', '1' => 'Regroupements'),
+ 'default' => '0'
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Report'),
+ 'rolled' => true,
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_anonymousReport',
+ 'comment' => _('reglages:: report anonyme (masque les infos concernant les utilisateurs)'),
+ 'default' => false,
+ 'required' => true
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Modules supplementaires'),
+ 'rolled' => true,
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_thesaurus',
+ 'comment' => _('reglages:: Activation de l\'outil thesaurus'),
+ 'default' => true
+ ), array(
+ 'type' => 'boolean',
+ 'name' => 'GV_multiAndReport',
+ 'comment' => _('reglages:: Activation du Mode MultiDOC'),
+ 'default' => true
+ ), array(
+ 'type' => 'boolean',
+ 'name' => 'GV_seeOngChgDoc',
+ 'comment' => _('reglages:: Substitution de HD d\'un record '),
+ 'default' => false
+ ), array(
+ 'type' => 'boolean',
+ 'name' => 'GV_seeNewThumb',
+ 'comment' => _('reglages:: Substitution de thumbnail d\'un record'),
+ 'default' => false
+ )
+ )
+ )
// , array(
// 'section' => _('GV::section:: Authentification LDAP'),
// 'rolled' => true,
@@ -732,243 +736,242 @@ $GV = array(
// )
// )
// )
- , array(
- 'section' => _('GV::section:: Envois de mails'),
- 'vars' => array(
+ , array(
+ 'section' => _('GV::section:: Envois de mails'),
+ 'vars' => array(
// array(
// 'type' => 'boolean',
// 'name' => 'GV_exportmail',
// 'comment' => _('reglages:: Activation de l\'export par mail'),
// 'default' => true
// ),
- array(
- 'type' => 'string',
- 'name' => 'GV_defaulmailsenderaddr',
- 'comment' => _('reglages:: Expediteur mail par defaut'),
- 'default' => 'phraseanet@example.com'
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_smtp',
- 'comment' => _('reglages:: Utilisation d\'un serveur SMTP'),
- 'default' => false
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_smtp_auth',
- 'comment' => _('reglages:: Activation de l\'authentification smtp'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_smtp_host',
- 'comment' => _('reglages:: Hote SMTP'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_smtp_port',
- 'comment' => _('reglages:: Port SMTP'),
- 'default' => ''
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_smtp_secure',
- 'comment' => _('reglages:: Utiliser une conenction SSL'),
- 'default' => false
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_smtp_user',
- 'comment' => _('reglages:: User SMTP'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_smtp_password',
- 'comment' => _('reglages:: Mot de passe SMTP'),
- 'default' => ''
- )
- )
- ), array(
- 'section' => _('GV::section:: Exports FTP'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_activeFTP',
- 'comment' => _('reglages:: active la possibilite d\'exports FTP ou non (onglet dans multiexports)'),
- 'default' => false
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_ftp_for_user',
- 'comment' => _('reglages:: Donne ou non export FTP aux utilisateurs ou e l\'admin uniquement'),
- 'default' => false
- )
- )
- ), array(
- 'section' => _('GV::section:: Configuration du client'),
- 'vars' => array(
-// array(
-// 'type' => 'enum',
-// 'name' => 'GV_bandeauHome',
-// 'comment' => _('reglages:: Affichage par defaut de la home du client'),
-// 'available' => array('QUERY' => _('Question'), 'PUBLI' => _('Publications'), 'HELP' => _('Aide')),
-// 'default' => 'QUERY'
-// ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_ong_search',
- 'comment' => _('reglages:: position de l\'onglet de recherche'),
- 'default' => 1
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_ong_advsearch',
- 'comment' => _('reglages:: position de l\'onglet de recherche avancee'),
- 'default' => 2
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_ong_topics',
- 'comment' => _('reglages:: position de l\'onglet des topics'),
- 'default' => 0
- ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_ong_actif',
- 'comment' => _('reglages:: numero de l\'onglet actif'),
- 'default' => 1
- ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_client_render_topics',
- 'comment' => _('reglages:: rendu des topics'),
- 'available' => array('tree' => 'Arbres', 'popups' => 'Menus deroulants'),
- 'default' => 'tree'
- ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_defaulmailsenderaddr',
+ 'comment' => _('reglages:: Expediteur mail par defaut'),
+ 'default' => 'phraseanet@example.com'
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_smtp',
+ 'comment' => _('reglages:: Utilisation d\'un serveur SMTP'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_smtp_auth',
+ 'comment' => _('reglages:: Activation de l\'authentification smtp'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_smtp_host',
+ 'comment' => _('reglages:: Hote SMTP'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_smtp_port',
+ 'comment' => _('reglages:: Port SMTP'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_smtp_secure',
+ 'comment' => _('reglages:: Utiliser une conenction SSL'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_smtp_user',
+ 'comment' => _('reglages:: User SMTP'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_smtp_password',
+ 'comment' => _('reglages:: Mot de passe SMTP'),
+ 'default' => ''
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Exports FTP'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_activeFTP',
+ 'comment' => _('reglages:: active la possibilite d\'exports FTP ou non (onglet dans multiexports)'),
+ 'default' => false
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_ftp_for_user',
+ 'comment' => _('reglages:: Donne ou non export FTP aux utilisateurs ou e l\'admin uniquement'),
+ 'default' => false
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Configuration du client'),
+ 'vars' => array(
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_download_max',
+ 'comment' => _('Maximum megabytes allowed in download (if request is bigger, then mail is still available)'),
+ 'default' => 120
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_ong_search',
+ 'comment' => _('reglages:: position de l\'onglet de recherche'),
+ 'default' => 1
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_ong_advsearch',
+ 'comment' => _('reglages:: position de l\'onglet de recherche avancee'),
+ 'default' => 2
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_ong_topics',
+ 'comment' => _('reglages:: position de l\'onglet des topics'),
+ 'default' => 0
+ ),
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_ong_actif',
+ 'comment' => _('reglages:: numero de l\'onglet actif'),
+ 'default' => 1
+ ),
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_client_render_topics',
+ 'comment' => _('reglages:: rendu des topics'),
+ 'available' => array('tree' => 'Arbres', 'popups' => 'Menus deroulants'),
+ 'default' => 'tree'
+ ),
// array(
// 'type' => 'boolean',
// 'name' => 'GV_grp_preview_list',
// 'comment' => _('reglages:: Voir les elements d\'un reportage sans Thumbnail (fenetre de preview)'),
// 'default' => false
// ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_rollover_reg_preview',
- 'comment' => _('reglages:: Voir le rollover sur les regroupements (fenetre de preview)'),
- 'default' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_rollover_chu',
- 'comment' => _('reglages:: Voir le rollover sur les elements du chutier'),
- 'default' => true
- ),
- array(
- 'type' => 'enum',
- 'name' => 'GV_client_coll_ckbox',
- 'comment' => _('reglages:: Presentation des collections'),
- 'default' => 'checkbox',
- 'available' => array('popup' => 'Menu deroulant', 'checkbox' => 'case a cocher')
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_viewSizeBaket',
- 'comment' => _('reglages:: Voir taille HD total des doc d\'un chutiers'),
- 'default' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_clientAutoShowProposals',
- 'comment' => _('reglages:: Afficher automatiquement l\'onglet des propositions s\'il y\'en a'),
- 'default' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_needAuth2DL',
- 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'),
- 'default' => true
- )
- )
- ), array(
- 'section' => _('GV::section:: Parametrage de l\'inscription'),
- 'vars' => array(
- array(
- 'type' => 'boolean',
- 'name' => 'GV_autoselectDB',
- 'comment' => _('reglages:: A true, cette option descative le choix de selection des bases sur lesquelles on s\'inscrit, et l\'inscription se fait sur toutes les bases ou jai le droit de m\'inscrire'),
- 'default' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_autoregister',
- 'comment' => _('reglages:: Activation de l\'autoinscription'),
- 'default' => false
- )
- )
- ), array(
- 'section' => _('GV::section:: Configuration du push'),
- 'vars' => array(
- array(
- 'type' => 'integer',
- 'name' => 'GV_validation_reminder',
- 'comment' => _('reglages:: Nombre de jour avant la fin de la validation pour envoie de mail de rappel'),
- 'default' => 2
- ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_rollover_reg_preview',
+ 'comment' => _('reglages:: Voir le rollover sur les regroupements (fenetre de preview)'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_rollover_chu',
+ 'comment' => _('reglages:: Voir le rollover sur les elements du chutier'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'enum',
+ 'name' => 'GV_client_coll_ckbox',
+ 'comment' => _('reglages:: Presentation des collections'),
+ 'default' => 'checkbox',
+ 'available' => array('popup' => 'Menu deroulant', 'checkbox' => 'case a cocher')
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_viewSizeBaket',
+ 'comment' => _('reglages:: Voir taille HD total des doc d\'un chutiers'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_clientAutoShowProposals',
+ 'comment' => _('reglages:: Afficher automatiquement l\'onglet des propositions s\'il y\'en a'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_needAuth2DL',
+ 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'),
+ 'default' => true
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Parametrage de l\'inscription'),
+ 'vars' => array(
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_autoselectDB',
+ 'comment' => _('reglages:: A true, cette option descative le choix de selection des bases sur lesquelles on s\'inscrit, et l\'inscription se fait sur toutes les bases ou jai le droit de m\'inscrire'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_autoregister',
+ 'comment' => _('reglages:: Activation de l\'autoinscription'),
+ 'default' => false
+ )
+ )
+ ), array(
+ 'section' => _('GV::section:: Configuration du push'),
+ 'vars' => array(
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_validation_reminder',
+ 'comment' => _('reglages:: Nombre de jour avant la fin de la validation pour envoie de mail de rappel'),
+ 'default' => 2
+ ),
// array(
// 'type' => 'boolean',
// 'name' => 'GV_DL_checkit',
// 'comment' => _('reglages:: Autorise le telechargement des fichiers pendant le process de validation'),
// 'default' => true
// ),
- array(
- 'type' => 'integer',
- 'name' => 'GV_val_expiration',
- 'comment' => _('reglages:: dure de validite des liens genere pour les validations, si 0 => validite permanente'),
- 'default' => 10
- )
- )
- ), array(
- 'section' => _('GV::section:: Indexation par les robots'),
- 'vars' => array(
- array(
- 'type' => 'string',
- 'name' => 'GV_homeTitle',
- 'comment' => _('reglages :: Titre de l\'installation'),
- 'default' => 'Phraseanet'
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_metaKeywords',
- 'comment' => _('reglages:: Mots clefs pour l\'indexation des robots de moteurs de recherche'),
- 'default' => ''
- ),
- array(
- 'type' => 'text',
- 'name' => 'GV_metaDescription',
- 'comment' => _('reglages :: Description de l\'installation'),
- 'default' => ''
- ),
- array(
- 'type' => 'string',
- 'name' => 'GV_googleAnalytics',
- 'comment' => _('reglages:: identifiant google analytics'),
- 'default' => ''
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_allow_search_engine',
- 'comment' => _('Allow the website to be indexed by search engines like Google'),
- 'default' => true
- ),
- array(
- 'type' => 'boolean',
- 'name' => 'GV_display_gcf',
- 'comment' => _('reglages:: Afficher le bandeau Google Chrome Frame'),
- 'default' => true
- )
- )
+ array(
+ 'type' => 'integer',
+ 'name' => 'GV_val_expiration',
+ 'comment' => _('reglages:: dure de validite des liens genere pour les validations, si 0 => validite permanente'),
+ 'default' => 10
+ )
)
- )
+ ), array(
+ 'section' => _('GV::section:: Indexation par les robots'),
+ 'vars' => array(
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_homeTitle',
+ 'comment' => _('reglages :: Titre de l\'installation'),
+ 'default' => 'Phraseanet'
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_metaKeywords',
+ 'comment' => _('reglages:: Mots clefs pour l\'indexation des robots de moteurs de recherche'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'text',
+ 'name' => 'GV_metaDescription',
+ 'comment' => _('reglages :: Description de l\'installation'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'string',
+ 'name' => 'GV_googleAnalytics',
+ 'comment' => _('reglages:: identifiant google analytics'),
+ 'default' => ''
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_allow_search_engine',
+ 'comment' => _('Allow the website to be indexed by search engines like Google'),
+ 'default' => true
+ ),
+ array(
+ 'type' => 'boolean',
+ 'name' => 'GV_display_gcf',
+ 'comment' => _('reglages:: Afficher le bandeau Google Chrome Frame'),
+ 'default' => true
+ )
+ )
+ )
+ )
?>
diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml
index 99c1b2968a..e9876c89b8 100644
--- a/lib/conf.d/bases_structure.xml
+++ b/lib/conf.d/bases_structure.xml
@@ -3816,7 +3816,7 @@
type
- enum('view','validate','password','rss','email','download')
+ enum('FEED_ENTRY', 'view','validate','password','rss','email','download')
ascii_bin
@@ -5160,30 +5160,6 @@
-
- regdate
- tinyint(1) unsigned
- YES
-
-
-
-
-
- regname
- tinyint(1) unsigned
- YES
-
-
-
-
-
- regdesc
- tinyint(1) unsigned
- YES
-
-
-
-
report
tinyint(1) unsigned
@@ -5208,6 +5184,22 @@
+
+ VocabularyControlType
+ CHAR(16)
+ YES
+
+
+
+
+
+ RestrictToVocabularyControl
+ TINYINT(1)
+
+
+ 0
+
+
@@ -5245,27 +5237,6 @@
required
-
- regname
- UNIQUE
-
- regname
-
-
-
- regdate
- UNIQUE
-
- regdate
-
-
-
- regdesc
- UNIQUE
-
- regdesc
-
-
sorter
UNIQUE
@@ -5311,6 +5282,24 @@
utf8_unicode_ci
+
+ VocabularyType
+ char(16)
+ YES
+
+
+
+ utf8_unicode_ci
+
+
+ VocabularyId
+ int(11)
+ YES
+
+
+
+
+
@@ -5335,8 +5324,8 @@
- unique
- UNIQUE
+ index_meta
+ INDEX
record_id
meta_struct_id
@@ -5792,7 +5781,7 @@
results
int(11) unsigned
-
+ YES
0
diff --git a/lib/conf.d/data_templates/en-simple.xml b/lib/conf.d/data_templates/en-simple.xml
index 1baaa0fabb..1602fc3170 100644
--- a/lib/conf.d/data_templates/en-simple.xml
+++ b/lib/conf.d/data_templates/en-simple.xml
@@ -47,7 +47,7 @@
Prévisualisation
Preview
-
+
{{datapathweb}}{{basename}}/subdefs
200
gif
@@ -86,6 +86,50 @@
Thumbnail
+
+
+ {{datapathnoweb}}{{basename}}/subdefs
+ flexpaper
+ no
+
+ Prévisualisation
+ Preview
+
+
+ {{datapathweb}}{{basename}}/subdefs
+ image
+ resample
+ 72
+ 200
+ no
+ {{dataurl}}/{{basename}}/subdefs
+ Imagette
+ Thumbnail
+
+
+
+
+ {{datapathnoweb}}{{basename}}/subdefs
+ image
+ 200
+ no
+ resample
+ 72
+
+ Prévisualisation
+ Preview
+
+
+ {{datapathweb}}{{basename}}/subdefs
+ image
+ no
+ resample
+ 72
+ {{dataurl}}/{{basename}}/subdefs
+ Imagette
+ Thumbnail
+
+
@@ -105,7 +149,7 @@
-
+
@@ -126,7 +170,7 @@
-
+
@@ -135,7 +179,7 @@
-
+
diff --git a/lib/conf.d/data_templates/fr-simple.xml b/lib/conf.d/data_templates/fr-simple.xml
index 6b7d22e9a7..f8c5a5ab2a 100755
--- a/lib/conf.d/data_templates/fr-simple.xml
+++ b/lib/conf.d/data_templates/fr-simple.xml
@@ -45,7 +45,7 @@
Prévisualisation
Preview
-
+
{{datapathweb}}{{basename}}/subdefs
200
gif
@@ -77,12 +77,57 @@
{{datapathweb}}{{basename}}/subdefs
image
+ 200
no
{{dataurl}}/{{basename}}/subdefs
Imagette
Thumbnail
+
+
+ {{datapathnoweb}}{{basename}}/subdefs
+ flexpaper
+ no
+
+ Prévisualisation
+ Preview
+
+
+ {{datapathweb}}{{basename}}/subdefs
+ image
+ resample
+ 72
+ 200
+ no
+ {{dataurl}}/{{basename}}/subdefs
+ Imagette
+ Thumbnail
+
+
+
+
+ {{datapathnoweb}}{{basename}}/subdefs
+ image
+ 200
+ no
+ resample
+ 72
+
+ Prévisualisation
+ Preview
+
+
+ {{datapathweb}}{{basename}}/subdefs
+ image
+ no
+ resample
+ 72
+ {{dataurl}}/{{basename}}/subdefs
+ Imagette
+ Thumbnail
+
+
@@ -104,7 +149,7 @@
-
+
@@ -125,7 +170,7 @@
-
+
@@ -134,7 +179,7 @@
-
+
diff --git a/lib/phpunit.xml.dist b/lib/phpunit.xml.dist
index 4cd75ae194..5a5c136840 100644
--- a/lib/phpunit.xml.dist
+++ b/lib/phpunit.xml.dist
@@ -9,6 +9,7 @@
stopOnFailure="false"
syntaxCheck="true"
verbose="false"
+ bootstrap="unitTest/bootstrap.inc"
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{home_title}}
+
+
+ {% if not session.is_authenticated %}
+
+ {% else %}
+ {% if user is not none %}
+ {% set username = '
' ~ user.get_display_name() ~ ' ' %}
+
+
+ {% trans %}
+ Hello {{username}}
+ {% endtrans %}
+
+
+ {% endif %}
+ {% if auth.getClient() is not none %}
+
+
+
{% trans %}Autorisation d'accès{% endtrans %}
+
+
+ {% set application_name = auth.getClient.get_name() %}
+
+ {% trans %}
+ Autorisez-vous l'application "{{application_name}} " à accéder à votre contenu sur {{home_title}} ?
+ {% endtrans %}
+
+
+
+ {% endif %}
+
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/mobile/api/auth/native_app_access_token.twig b/templates/mobile/api/auth/native_app_access_token.twig
new file mode 100644
index 0000000000..0ba7bce308
--- /dev/null
+++ b/templates/mobile/api/auth/native_app_access_token.twig
@@ -0,0 +1,98 @@
+
+
+
+
+
+ {% if error is defined %}
+ {% trans 'Fail' %}
+ {% else %}
+ {% trans 'Success' %}
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{home_title}}
+
+
+ {% if user is not none %}
+ {% set username = '
' ~ user.get_display_name() ~ ' ' %}
+
+
+ {% trans %}
+ Hello {{username}}
+ {% endtrans %}
+
+
+ {% endif %}
+
+ {% if error is defined %}
+
+
{% trans %}Erreur{% endtrans %}
+
+
+
+ {% trans %}
+ {{error}}
+ {% endtrans %}
+
+
+
+ {% else %}
+
+
{% trans %}Code d'accès{% endtrans %}
+
+
+
+ {% trans %}
+ Copiez le code ci-dessous, retournez dans votre application et collez-le à l'endroit requis :
+ {% endtrans %}
+
+
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/mobile/common/index.twig b/templates/mobile/common/index.twig
index 4f0d3c5948..6da44ad780 100644
--- a/templates/mobile/common/index.twig
+++ b/templates/mobile/common/index.twig
@@ -6,7 +6,7 @@
{{home_title}} - {{ module_name }}
-
+
{% block stylesheet %}{% endblock %}
{% block icon %}{% endblock %}
{% block javascript %}{% endblock %}
diff --git a/templates/mobile/lightbox/basket_element.twig b/templates/mobile/lightbox/basket_element.twig
index 9a870f8b6e..78fa9a075b 100644
--- a/templates/mobile/lightbox/basket_element.twig
+++ b/templates/mobile/lightbox/basket_element.twig
@@ -11,28 +11,32 @@
{% endblock %}
{% block content %}
- {% set record = basket_element.get_record() %}
+ {% set record = basket_element.getRecord() %}
-
Back
-
{{basket_element.get_order()}} - {{record.get_title()}}
+
Back
+
{{basket_element.getOrd()}} - {{record.get_title()}}
Home
{{ thumbnail.format100percent(record.get_preview(),'',session, record.get_thumbnail()) }}
- {% if basket_element.is_validation_item() %}
-
-
- {% trans 'validation:: OUI' %}
+ {% if basket_element.getBasket().getValidation() %}
+ {% if basket_element.getBasket().getValidation().getParticipant(user).getCanAgree() %}
+
+
+ {% trans 'validation:: OUI' %}
-
- {% trans 'validation:: NON' %}
-
+
+ {% trans 'validation:: NON' %}
+
+ {% endif %}
-
+
{% include 'lightbox/sc_note.twig' %}
diff --git a/templates/mobile/lightbox/feed.twig b/templates/mobile/lightbox/feed.twig
index 3fabc50d41..933e7385be 100644
--- a/templates/mobile/lightbox/feed.twig
+++ b/templates/mobile/lightbox/feed.twig
@@ -20,10 +20,10 @@
{{feed_entry.get_subtitle()|nl2br|raw}}
+ {% set author = feed_entry.get_author_name() %}
{% trans %}Par {{ author }}{% endtrans %}
{% set entry_length = feed_entry.get_content()|length %}
{% trans %}{{entry_length}} documents{% endtrans %}
- {% set author = feed_entry.get_author_name() %}
diff --git a/templates/mobile/lightbox/feed_element.twig b/templates/mobile/lightbox/feed_element.twig
index 28fe319a89..907a6c05b7 100644
--- a/templates/mobile/lightbox/feed_element.twig
+++ b/templates/mobile/lightbox/feed_element.twig
@@ -15,7 +15,7 @@
Back
-
{{feed_element.get_order()}} - {{record.get_title()}}
+
{{feed_element.get_ord()}} - {{record.get_title()}}
Home
diff --git a/templates/mobile/lightbox/index.twig b/templates/mobile/lightbox/index.twig
index 06507a78e6..854bf0c8d8 100644
--- a/templates/mobile/lightbox/index.twig
+++ b/templates/mobile/lightbox/index.twig
@@ -13,27 +13,23 @@
{% endblock %}
{% macro valid_baskets_length(baskets) %}
- {% set foo = 0 %}
+ {% set number = 0 %}
{% for item in baskets %}
- {% if item.is_valid() %}
- {% set foo = foo + 1 %}
+ {% if item.getValidation() %}
+ {% set number = number + 1 %}
{% endif %}
{% endfor %}
- {{foo}}
+ {{number}}
{% endmacro %}
-{% macro baskets_length(baskets_collection) %}
- {% set foo = 0 %}
- {% for key,baskets in baskets_collection.get_baskets() %}
- {% if key == 'baskets' or key == 'recept' %}
- {% for item in baskets %}
- {% if item.is_valid() == false %}
- {% set foo = foo + 1 %}
- {% endif %}
- {% endfor %}
+{% macro baskets_length(baskets) %}
+ {% set number = 0 %}
+ {% for item in baskets %}
+ {% if item.getValidation() == false %}
+ {% set number = number + 1 %}
{% endif %}
{% endfor %}
- {{foo}}
+ {{number}}
{% endmacro %}
{% block content %}
@@ -46,7 +42,7 @@
@@ -124,22 +116,18 @@
{% trans 'Voici vos paniers' %}
diff --git a/templates/mobile/lightbox/note_form.twig b/templates/mobile/lightbox/note_form.twig
index b17e2e1dfc..25ac74de76 100644
--- a/templates/mobile/lightbox/note_form.twig
+++ b/templates/mobile/lightbox/note_form.twig
@@ -11,17 +11,17 @@
{% endblock %}
{% block content %}
-