From f617cd537759186ad14fa6de98acfd9795024066 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 Feb 2012 15:31:42 +0100 Subject: [PATCH 001/142] Fix cache insta nciation --- .../Phrasea/Core/Service/Cache/ApcCache.php | 11 +++-- .../Phrasea/Core/Service/Cache/ArrayCache.php | 11 +++-- .../Core/Service/Cache/MemcacheCache.php | 42 +++++++++++-------- .../Phrasea/Core/Service/Cache/RedisCache.php | 41 ++++++++++-------- .../Core/Service/Cache/XcacheCache.php | 12 ++++-- 5 files changed, 72 insertions(+), 45 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php index b31328201a..254a335687 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class ApcCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -38,11 +40,14 @@ class ApcCache extends ServiceAbstract implements ServiceInterface throw new \Exception('The APC cache requires the APC extension.'); } - $service = new CacheDriver\ApcCache(); + if (!$this->cache) + { + $this->cache = new CacheDriver\ApcCache(); - $service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); + $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); + } - return $service; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php index d2fe9cfb06..919f4bc78b 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php @@ -27,6 +27,8 @@ use Alchemy\Phrasea\Core, class ArrayCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -34,11 +36,14 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface public function getDriver() { - $service = new CacheDriver\ArrayCache(); + if (!$this->cache) + { + $this->cache = new CacheDriver\ArrayCache(); - $service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); + $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); + } - return $service; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php index 3342e08867..7a50a19512 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class MemcacheCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + const DEFAULT_HOST = "localhost"; const DEFAULT_PORT = "11211"; @@ -53,27 +55,31 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface throw new \Exception('The Memcache cache requires the Memcache extension.'); } - $memcache = new \Memcache(); - - $memcache->addServer($this->host, $this->port); - - $key = sprintf("%s:%s", $this->host, $this->port); - - $stats = @$memcache->getExtendedStats(); - - if (isset($stats[$key])) + if(!$this->cache) { - $service = new CacheDriver\MemcacheCache(); - $service->setMemcache($memcache); - } - else - { - throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port)); + $memcache = new \Memcache(); + + $memcache->addServer($this->host, $this->port); + + $key = sprintf("%s:%s", $this->host, $this->port); + + $stats = @$memcache->getExtendedStats(); + + if (isset($stats[$key])) + { + $service = new CacheDriver\MemcacheCache(); + $service->setMemcache($memcache); + } + else + { + throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port)); + } + + $this->cache = $service; + $this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../'))); } - $service->setNamespace(md5(realpath(__DIR__.'/../../../../../../'))); - - return $service; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php index 5f999b9f19..00e9b44183 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/RedisCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class RedisCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + const DEFAULT_HOST = "localhost"; const DEFAULT_PORT = "6379"; @@ -34,7 +36,7 @@ class RedisCache extends ServiceAbstract implements ServiceInterface public function __construct(Core $core, $name, Array $options) { - parent::__construct( $core, $name, $options); + parent::__construct($core, $name, $options); $this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST; @@ -57,26 +59,31 @@ class RedisCache extends ServiceAbstract implements ServiceInterface throw new \Exception('The Redis cache requires the Redis extension.'); } - $redis = new \Redis(); - if (!$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY)) + if (!$this->cache) { - $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); + $redis = new \Redis(); + + if (!$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY)) + { + $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP); + } + + if ($redis->connect($this->host, $this->port)) + { + $service = new CacheDriver\RedisCache(); + $service->setRedis($redis); + } + else + { + throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port)); + } + + $this->cache = $service; + $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); } - if ($redis->connect($this->host, $this->port)) - { - $service = new CacheDriver\RedisCache(); - $service->setRedis($redis); - } - else - { - throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port)); - } - - $service->setNamespace(md5(realpath(__DIR__.'/../../../../../../'))); - - return $service; + return $this->cache; } public function getType() diff --git a/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php b/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php index aa2b5acdce..f849caf7f2 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php +++ b/lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php @@ -26,6 +26,8 @@ use Alchemy\Phrasea\Core, class XcacheCache extends ServiceAbstract implements ServiceInterface { + protected $cache; + public function getScope() { return 'cache'; @@ -38,11 +40,14 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface throw new \Exception('The XCache cache requires the XCache extension.'); } - $service = new CacheDriver\XcacheCache(); + if (!$this->cache) + { + $service = new CacheDriver\XcacheCache(); - $service->setNamespace(md5(realpath(__DIR__.'/../../../../../../'))); + $service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../'))); + } - return $service; + return $this->cache; } public function getType() @@ -55,5 +60,4 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface return array(); } - } From 59a04e363f6ec251bd679a4bcf09e0e3d947656a Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 Feb 2012 15:32:46 +0100 Subject: [PATCH 002/142] Reformat basket cache key --- lib/Doctrine/Repositories/BasketRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Repositories/BasketRepository.php b/lib/Doctrine/Repositories/BasketRepository.php index 1e7aa9a768..d6fae2542a 100644 --- a/lib/Doctrine/Repositories/BasketRepository.php +++ b/lib/Doctrine/Repositories/BasketRepository.php @@ -56,7 +56,7 @@ class BasketRepository extends EntityRepository $query = $this->_em->createQuery($dql); $query->setParameters(array('usr_id' => $user->get_id())); - $idCache = "_active_by_user_" . ($sort === null ? "" : $sort ) . "_" . $user->get_id() . Entities\Basket::CACHE_SUFFIX; + $idCache = "_active_by_user_" . ($sort === null ? "" : $sort. "_" ) . $user->get_id() . Entities\Basket::CACHE_SUFFIX; $query->useResultCache(true, 1800, $idCache); From c50118007d3e41d56f59561df47016399ed69aa9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 Feb 2012 15:33:12 +0100 Subject: [PATCH 003/142] Fix config check --- .../module/console/fileConfigCheck.class.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/classes/module/console/fileConfigCheck.class.php b/lib/classes/module/console/fileConfigCheck.class.php index 1174b48f47..efab242c14 100644 --- a/lib/classes/module/console/fileConfigCheck.class.php +++ b/lib/classes/module/console/fileConfigCheck.class.php @@ -143,7 +143,7 @@ class module_console_fileConfigCheck extends Command private function checkParse(OutputInterface $output) { - if (!$this->configuration->getConfigurations()) + if (!$this->configuration) { throw new \Exception("Unable to load configurations\n"); } @@ -163,7 +163,7 @@ class module_console_fileConfigCheck extends Command { try { - $this->configuration->getConfiguration(); + $this->configuration; } catch (\Exception $e) { @@ -178,15 +178,8 @@ class module_console_fileConfigCheck extends Command { $configuration = Core\Configuration::build(); - try - { - $configuration->getConfiguration(); - } - catch (\Exception $e) - { - throw new \Exception(sprintf("Check get selected environment from file\n"), null, $e); - } - $output->writeln("Get Selected Environment from file OK"); + $env = $configuration->getEnvironnement(); + $output->writeln("Get Selected Environment from file : ".$env.""); return; } From 47efcba5487140ba7f2a65c94812b824e3061e7c Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 Feb 2012 15:33:35 +0100 Subject: [PATCH 004/142] Enhanced metadatas tests --- lib/unitTest/Alchemy/Phrasea/Application/ApiJsonTest.php | 2 +- lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/unitTest/Alchemy/Phrasea/Application/ApiJsonTest.php b/lib/unitTest/Alchemy/Phrasea/Application/ApiJsonTest.php index f042b147ac..4c1d7e64bc 100644 --- a/lib/unitTest/Alchemy/Phrasea/Application/ApiJsonTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Application/ApiJsonTest.php @@ -654,7 +654,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract { if (!in_array($metadata->meta_id, array_keys($toupdate))) continue; - $saved_value = $toupdate[$metadata->meta_id]['value'][0]; + $saved_value = $toupdate[$metadata->meta_id]['value']; $this->assertEquals($saved_value, $metadata->value); } $record->delete(); diff --git a/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php b/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php index c108659dbe..44b72464f2 100644 --- a/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php +++ b/lib/unitTest/Alchemy/Phrasea/Application/ApiYamlTest.php @@ -681,7 +681,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract { if (!in_array($metadata["meta_id"], array_keys($toupdate))) continue; - $saved_value = $toupdate[$metadata["meta_id"]]['value'][0]; + $saved_value = $toupdate[$metadata["meta_id"]]['value']; $this->assertEquals($saved_value, $metadata["value"]); } $record->delete(); From dc410932d36cd338a6e373dbfaaafe055fa41882 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 27 Feb 2012 15:33:56 +0100 Subject: [PATCH 005/142] Remove bootstrap calls --- .../Phrasea/Controller/Setup/FakeSetupApplication.inc | 7 +++---- .../Phrasea/Controller/Setup/FakeUpgradeApplication.inc | 7 +++---- lib/unitTest/Bridge/Bridge_datas.inc | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc index f5d8fce005..ef94e897eb 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeSetupApplication.inc @@ -7,7 +7,6 @@ use Symfony\Component\HttpFoundation\Request; use Alchemy\Phrasea\Controller\Setup as Controller; use Alchemy\Phrasea\Controller\Utils as ControllerUtils; -require_once __DIR__ . '/../../../../../bootstrap.php'; return call_user_func(function() { @@ -26,10 +25,10 @@ return call_user_func(function() $app->mount('/test', new ControllerUtils\PathFileTest()); $app->mount('/connection_test', new ControllerUtils\ConnectionTest()); - + $app->error(function($e){ - + }); - + return $app; }); diff --git a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc index 5422e5b299..1e26903014 100644 --- a/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc +++ b/lib/unitTest/Alchemy/Phrasea/Controller/Setup/FakeUpgradeApplication.inc @@ -7,7 +7,6 @@ use Symfony\Component\HttpFoundation\Request; use Alchemy\Phrasea\Controller\Setup as Controller; use Alchemy\Phrasea\Controller\Utils as ControllerUtils; -require_once __DIR__ . '/../../../../../bootstrap.php'; return call_user_func(function() { @@ -26,10 +25,10 @@ return call_user_func(function() $app->mount('/test', new ControllerUtils\PathFileTest()); $app->mount('/connection_test', new ControllerUtils\ConnectionTest()); - + $app->error(function($e){ }); - - + + return $app; }); diff --git a/lib/unitTest/Bridge/Bridge_datas.inc b/lib/unitTest/Bridge/Bridge_datas.inc index 26da656ddc..246f8db47a 100644 --- a/lib/unitTest/Bridge/Bridge_datas.inc +++ b/lib/unitTest/Bridge/Bridge_datas.inc @@ -1,6 +1,5 @@ Date: Mon, 27 Feb 2012 15:35:25 +0100 Subject: [PATCH 006/142] Add unit tests bootstrap --- lib/unitTest/bootstrap.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/unitTest/bootstrap.inc diff --git a/lib/unitTest/bootstrap.inc b/lib/unitTest/bootstrap.inc new file mode 100644 index 0000000000..e88c54205c --- /dev/null +++ b/lib/unitTest/bootstrap.inc @@ -0,0 +1,20 @@ + Date: Mon, 27 Feb 2012 15:35:37 +0100 Subject: [PATCH 007/142] Add unit tests bootstrap --- lib/phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/phpunit.xml.dist b/lib/phpunit.xml.dist index 35bbca23e6..0daccfcdda 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" > + + +get_aggregate()->get_entries(0, 5)->get_entries() as $entry) +{ + /* @var $entry \Feed_Entry_Adapter */ + + $feed .= '
' . + '
' . + '

' . + '' + . $entry->get_title() . + '

' . + '' . + ' ' . \phraseadate::getPrettyString($entry->get_created_on()) . + ' '; + + if ($entry->get_author_email()) + $feed .= ''; + + $feed .= $entry->get_author_name(); + + if ($entry->get_author_email()) + $feed .= ''; + + if ($entry->get_updated_on() > $entry->get_created_on()) + $feed .= '
' . _('publications:: derniere mise a jour') + . ' ' . \phraseadate::getPrettyString($entry->get_updated_on()) . '

'; + + $feed .= '
'; + + + if (trim($entry->get_subtitle()) != '') + { + $feed .= '' . nl2br($entry->get_subtitle()); + } + $feed .= '
'; + + $feed .= '
'; + + + + + + + foreach ($entry->get_content() as $Feed_item) + { + /* @var $Feed_item \Feed_Entry_Item */ + $record = $Feed_item->get_record(); + + $thumbnail = $record->get_thumbnail(); + + $title = $record->get_title(); + $caption = $twig->render( + 'common/caption.html', array('view' => 'internal_publi', 'record' => $record) + ); + + $preview = "
 "; + + $docType = $record->get_type(); + $isVideo = ($docType == 'video'); + $isAudio = ($docType == 'audio'); + $isImage = ($docType == 'image'); + + $duration = ''; + + if (!$isVideo && !$isAudio) + $isImage = true; + + if ($isVideo) + { + $duration = $record->get_formated_duration(); + if ($duration != '') + $duration = '
' . $duration . '
'; + } + if ($isAudio) + { + $duration = $record->get_formated_duration(); + if ($duration != '') + $duration = '
' . $duration . '
'; + } + + + $ratio = $thumbnail->get_width() / $thumbnail->get_height(); + + if ($ratio > 1) + { + $cw = min(((int) $th_size - 30), $thumbnail->get_width()); + $ch = $cw / $ratio; + $pv = floor(($th_size - $ch) / 2); + $ph = floor(($th_size - $cw) / 2); + $imgStyle = 'width:' . $cw . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; + } + else + { + $ch = min(((int) $th_size - 30), $thumbnail->get_height()); + $cw = $ch * $ratio; + + $pv = floor(($th_size - $ch) / 2); + $ph = floor(($th_size - $cw) / 2); + + $imgStyle = 'height:' . $ch . 'px;xpadding:' . $pv . 'px ' . $ph . 'px;'; + } + + $feed .= "
get_sbas_id() . "\" + id='IMGT_" . $record->get_serialize_key() . "_PUB_" . $entry->get_id() + . "' class='IMGT diapo' + onclick=\"openPreview('FEED','" . $Feed_item->get_ord() . "','" . $entry->get_id() . "');\">"; + + $feed .= '
'; + $feed .= "
"; + + $feed .= $title; + + $feed .= "
\n"; + + $feed .= '
'; + + $feed .= "\n
"; + + $feed .= $duration . "get_url() . "\" style=\"" . $imgStyle . "\" />"; + + $feed .= "
"; + + $feed .= '
'; + $feed .= ''; + $feed .= ''; + $feed .= '\n"; + + $feed .= ""; + $feed .= ""; + $feed .= "
'; + + $feed .= "\n"; + + $feed .= $preview; + + $feed .= "
"; + $feed .= "
"; + + + $feed .= "
"; + } + $feed .= '
' . + '
'; +} + +echo '
' . $feed . '
'; + diff --git a/www/include/js/jquery.Selection.js b/www/include/js/jquery.Selection.js index e2d7dbaaca..9297746494 100644 --- a/www/include/js/jquery.Selection.js +++ b/www/include/js/jquery.Selection.js @@ -218,10 +218,16 @@ return this.datas; }, empty : function(){ + var $this = this; this.datas = new Array(); jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected'); + if(typeof $this.options.selectStop === 'function') + { + $this.options.selectStop(jQuery.Event('selectStop'), $this); + } + return this; }, length : function(){ From 69fec3d36042fec8663bd0415a07fc8bc192bbff Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 28 Feb 2012 16:06:57 +0100 Subject: [PATCH 029/142] Fix page selection --- www/prod/page0.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/prod/page0.js b/www/prod/page0.js index 257d51de21..638927f31a 100644 --- a/www/prod/page0.js +++ b/www/prod/page0.js @@ -320,7 +320,6 @@ function resize(){ function clearAnswers(){ $('#formAnswerPage').val(''); - $('#searchForm input[name="sel"]').val(''); $('#searchForm input[name="nba"]').val(''); $('#answers, #dyn_tool').empty(); } @@ -346,6 +345,7 @@ function newSearch() { console.log('Fresh new search, cache empty'); } + p4.Results.Selection.empty() clearAnswers(); var val = $('#searchForm input[name="qry"]').val(); @@ -475,11 +475,14 @@ function initAnswerForm(){ success: function(datas){ - $('#answers').empty().append(datas.results).removeClass('loading'); $('#tool_results').empty().append(datas.infos); $('#tool_navigate').empty().append(datas.navigation); + $.each(p4.Results.Selection.get(), function(i, el){ + $('#IMGT_' + el).addClass('selected'); + }); + $('#proposals').empty().append(datas.phrasea_props); if($.trim(datas.phrasea_props) !== '') From a2ae5d395e1b50d87c827e90cdb9b4e15e1146f4 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 28 Feb 2012 16:18:12 +0100 Subject: [PATCH 030/142] Fix client --- www/client/answer.php | 143 ++++++++++++++++++++++-------------------- www/client/index.php | 54 ++++------------ 2 files changed, 88 insertions(+), 109 deletions(-) diff --git a/www/client/answer.php b/www/client/answer.php index 023bcf8434..0d14567ccc 100644 --- a/www/client/answer.php +++ b/www/client/answer.php @@ -14,35 +14,34 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ - /* @var $Core \Alchemy\Phrasea\Core */ require_once __DIR__ . "/../../lib/bootstrap.php"; -$Core= \bootstrap::getCore(); -$appbox = appbox::get_instance($Core); -$session = $appbox->get_session(); +$Core = \bootstrap::getCore(); +$appbox = appbox::get_instance($Core); +$session = $appbox->get_session(); $registry = $appbox->get_registry(); -$user = $Core->getAuthenticatedUser(); +$user = $Core->getAuthenticatedUser(); if (!isset($parm)) { $request = http_request::getInstance(); - $parm = $request->get_parms("mod", "bas" - , "pag" - , "qry", "search_type", "recordtype" - , "qryAdv", 'opAdv', 'status', 'datemin', 'datemax' - , 'dateminfield', 'datemaxfield' - , 'datefield' - , 'sort' - , 'stemme' - , 'infield' - , "nba" - , "regroup" // si rech par doc, regroup ,ou pizza - , "ord" + $parm = $request->get_parms("mod", "bas" + , "pag" + , "qry", "search_type", "recordtype" + , "qryAdv", 'opAdv', 'status', 'datemin', 'datemax' + , 'dateminfield', 'datemaxfield' + , 'datefield' + , 'sort' + , 'stemme' + , 'infield' + , "nba" + , "regroup" // si rech par doc, regroup ,ou pizza + , "ord" ); } -$qry = ''; +$qry = ''; if (trim($parm['qry']) != '') { @@ -88,7 +87,7 @@ else $mod_row = (int) ($mod[0]); $mod_col = (int) ($mod[1]); } -$mod_xy = $mod_col * $mod_row; +$mod_xy = $mod_col * $mod_row; $tbases = array(); @@ -102,9 +101,9 @@ $options->set_bases($parm['bas'], $user->ACL()); if (!is_array($parm['infield'])) $parm['infield'] = array(); -foreach($parm['infield'] as $offset=>$value) +foreach ($parm['infield'] as $offset => $value) { - if(trim($value) === '') + if (trim($value) === '') unset($parm['infield'][$offset]); } @@ -162,8 +161,8 @@ if ($registry->get('GV_thesaurus')) if ($registry->get('GV_clientAutoShowProposals')) { ?> - if("proposals), "JS") ?>" != "
") - chgOng(4); + if("proposals), "JS") ?>" != "
") + chgOng(4); @@ -178,14 +177,14 @@ $history = queries::history(); echo ''; $nbanswers = $result->get_count_available_results(); -$longueur = strlen($parm['qry']); +$longueur = strlen($parm['qry']); $qrys = '
' . _('client::answers: rapport de questions par bases') . '
'; foreach ($qrySbas as $sbas => $qryBas) $qrys .= '
' . phrasea::sbas_names($sbas) . '
' . $qryBas . '
'; -$txt = "" . substr($parm['qry'], 0, 36) . ($longueur > 36 ? "..." : "") . "" . sprintf(_('client::answers: %d reponses'), (int) $nbanswers) . "  "; +$txt = "" . substr($parm['qry'], 0, 36) . ($longueur > 36 ? "..." : "") . "" . sprintf(_('client::answers: %d reponses'), (int) $nbanswers) . "  "; ?> get_total_pages(); -$pages = ''; -$ecart = 3; -$max = (2 * $ecart) + 3; +$pages = ''; +$ecart = 3; +$max = (2 * $ecart) + 3; if ($npages > $max) { - for ($p = 1; $p < $npages; $p++) + for ($p = 1; $p <= $npages; $p++) { if ($p == $page) $pages .= '' . ($p) . ''; @@ -217,23 +216,23 @@ if ($npages > $max) $pages .= '' . ($p) . '...'; if (($p == $page) - || ( ( $p >= ($page - $ecart) ) && ( $p <= ($page + $ecart) )) - || ( ($page < ($ecart + 2)) && ($p < ($max - $ecart + 2) ) ) - || ( ($page >= ($npages - $ecart - 2)) && ($p >= ($npages - (2 * $ecart) - 2) ) ) - || ( $p == 0) + || ( ( $p >= ($page - $ecart) ) && ( $p <= ($page + $ecart) )) + || ( ($page < ($ecart + 2)) && ($p < ($max - $ecart + 2) ) ) + || ( ($page >= ($npages - $ecart - 2)) && ($p >= ($npages - (2 * $ecart) - 2) ) ) + || ( $p == 0) ) $pages .= ' - '; } } else { - for ($p = 1; $p < $npages; $p++) + for ($p = 1; $p <= $npages; $p++) { if ($p == $page) $pages .= '' . ($p) . ''; else $pages .= '' . ($p) . ''; - if ($p < $npages) + if ($p < $npages) $pages .= ' - '; } } @@ -251,30 +250,29 @@ $string2.= ''; if ($page != 0 && $nbanswers) { ?> - $("#PREV_PAGE").bind('click',function(){gotopage()}); + $("#PREV_PAGE").bind('click',function(){gotopage()}); - $("#PREV_PAGE").unbind('click'); + $("#PREV_PAGE").unbind('click'); - $("#NEXT_PAGE").bind('click',function(){gotopage()}); + $("#NEXT_PAGE").bind('click',function(){gotopage()}); - $("#NEXT_PAGE").unbind('click'); + $("#NEXT_PAGE").unbind('click'); -}); + }); get_datas()) > 0) $docType = $record->get_type(); $title = $record->get_title(); - $light_info = $twig->render('common/technical_datas.twig', array('record' => $record)); - $caption = $twig->render('common/caption.html', array('view' => 'answer', 'record' => $record)); + + try + { + $record->get_subdef('document'); + $light_info = $twig->render('common/technical_datas.twig', array('record' => $record)); + } + catch (\Exception $e) + { + $light_info = ''; + } + $caption = $twig->render('common/caption.html', array('view' => 'answer', 'record' => $record)); if ($i == 0) @@ -345,8 +352,6 @@ if (count($result->get_datas()) > 0) } ?>
'; $status .= $record->get_status_icons(); @@ -354,21 +359,20 @@ if (count($result->get_datas()) > 0) echo $status; - $isVideo = ($docType == 'video'); - $isAudio = ($docType == 'audio'); - $isImage = ($docType == 'image'); + $isVideo = ($docType == 'video'); + $isAudio = ($docType == 'audio'); + $isImage = ($docType == 'image'); $isDocument = ($docType == 'document'); $sd = $record->get_subdefs(); - $isImage = false; + $isImage = false; $isDocument = false; if (!$isVideo && !$isAudio) { $isImage = true; } - ?>
get_datas()) > 0) $pic_roll = str_replace(array('&', '"'), array('&', '"'), $pic_roll); ?> + { + ?>height:128px;" onclick="" class=" captionTips" id="IMGget_base_id() ?>_get_record_id() ?>" src="get_url() ?>" tooltipsrc="" />
' . collection::getLogo($record->get_base_id()); - $minilogos .= '
'; - $sbas_id = $record->get_sbas_id(); - echo $minilogos; + $minilogos .= '
' . collection::getLogo($record->get_base_id()); + $minilogos .= '
'; + $sbas_id = $record->get_sbas_id(); + echo $minilogos; - if ( - $ACL->has_right_on_base($record->get_base_id(), 'candwnldpreview') || - $ACL->has_right_on_base($record->get_base_id(), 'candwnldhd') || - $ACL->has_right_on_base($record->get_base_id(), 'cancmd') - ) - { + if ( + $ACL->has_right_on_base($record->get_base_id(), 'candwnldpreview') || + $ACL->has_right_on_base($record->get_base_id(), 'candwnldhd') || + $ACL->has_right_on_base($record->get_base_id(), 'cancmd') + ) + { ?>
'; - $b = true; + $b = true; foreach ($proposals["BASES"] as $zbase) { if ((int) (count($proposals["BASES"]) > 1) && count($zbase["TERMS"]) > 0) { $style = $b ? 'style="margin-top:0px;"' : ''; - $b = false; + $b = false; $html .= "

" . sprintf(_('reponses::propositions pour la base %s'), htmlentities($zbase["NAME"])) . "

"; } - $t = true; + $t = true; foreach ($zbase["TERMS"] as $path => $props) { $style = $t ? 'style="margin-top:0px;"' : ''; - $t = false; + $t = false; $html .= "

" . sprintf(_('reponses::propositions pour le terme %s'), htmlentities($props["TERM"])) . "

"; $html .= $props["HTML"]; } diff --git a/www/client/index.php b/www/client/index.php index 5dafe03272..f93357da20 100644 --- a/www/client/index.php +++ b/www/client/index.php @@ -102,6 +102,14 @@ $user = User_Adapter::getInstance($usr_id, $appbox); +
@@ -231,17 +239,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); } foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { - if ($showbases) - { - $options .= ''; - $allbcol = array(); - $n_allbcol = 0; - if (count($databox->get_collections()) > 0) - { - $options .= ''; - } - foreach ($databox->get_collections() as $coll) - { $allbcol[] = $coll->get_base_id(); $n_allbcol++; @@ -262,8 +259,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); } } echo ''; - } - } ?>
get('GV_view_bas_and_coll')) { - if ($registry->get('GV_view_bas_and_coll')) - { ?>
@@ -434,28 +427,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); '' . '
'; } - } - } - if ($sxe->description) - { - foreach ($sxe->description->children() as $f => $field) - { - if ($field['type'] == 'date' && $field['searchclient'] == '1') - { - $dateFilters .= '
' . - '' . - '' . - '
' . - $f . '
' . _('phraseanet::time:: de') . - '' . - _('phraseanet::time:: a') . - '
' . - '' . - ' ' . - '' . - '
' . - '
'; - } elseif ($field['type'] != 'date') { $fieldsFilters .= ''; @@ -481,7 +452,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
get_collections() as $coll) + foreach ($user->ACL()->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { $s = "checked"; echo '
'; @@ -497,7 +468,6 @@ $user = User_Adapter::getInstance($usr_id, $appbox); get('GV_thesaurus')) { ?> @@ -576,7 +546,7 @@ $user = User_Adapter::getInstance($usr_id, $appbox);
-