Merge branch '3.8'

This commit is contained in:
Romain Neutron
2013-09-18 12:09:20 +02:00
26 changed files with 224 additions and 115 deletions

View File

@@ -606,6 +606,14 @@ class Application extends SilexApplication
$twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets'));
$twig->addFilter('base_from_coll', new \Twig_Filter_Function('phrasea::baseFromColl'));
$twig->addFilter('AppName', new \Twig_Filter_Function('Alchemy\Phrasea\Controller\Admin\ConnectedUsers::appName'));
$twig->addFilter(new \Twig_SimpleFilter('escapeSimpleQuote', function ($value) {
$ret = str_replace("'", "\'", $value);
return $ret;
}));
$twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) {
return str_replace('"', '\"', $value);
}));
return $twig;
})

View File

@@ -31,7 +31,13 @@ return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
$app->before(function (Request $request) use ($app) {
if (0 === strpos($request->getPathInfo(), '/setup')) {
if (!$app['phraseanet.configuration-tester']->isInstalled()) {
if (!$app['phraseanet.configuration-tester']->isBlank()) {
if ('setup_upgrade_instructions' !== $app['request']->attributes->get('_route')) {
return $app->redirectPath('setup_upgrade_instructions');
}
}
} elseif (!$app['phraseanet.configuration-tester']->isBlank()) {
return $app->redirectPath('homepage');
}
} else {

View File

@@ -38,7 +38,7 @@ class ComposerInstall extends Command
$composer->command('self-update');
$output->writeln("<comment>OK</comment>");
$commands = array('install', '--optimize-autoloader');
$commands = array('install', '--optimize-autoloader', '--quiet', '--no-interaction');
if ($input->getOption('prefer-source')) {
$commands[] = '--prefer-source';
}

View File

@@ -1163,7 +1163,7 @@ class Collection implements ControllerProviderInterface
if ($vi && isset($structFields[$ki])) {
foreach ($vi->value as $oneValue) {
$suggestedValues[] = array(
'key' => $ki, 'value' => $f, 'name' => $oneValue
'key' => $ki, 'value' => $f, 'name' => (string) $oneValue
);
$f++;
}

View File

@@ -37,6 +37,9 @@ class Setup implements ControllerProviderInterface
$controllers->get('/installer/', 'controller.setup:rootInstaller')
->bind('install_root');
$controllers->get('/upgrade-instructions/', 'controller.setup:displayUpgradeInstructions')
->bind('setup_upgrade_instructions');
$controllers->get('/installer/step2/', 'controller.setup:getInstallForm')
->bind('install_step2');
@@ -70,6 +73,14 @@ class Setup implements ControllerProviderInterface
);
}
public function displayUpgradeInstructions(Application $app, Request $request)
{
return $app['twig']->render('/setup/upgrade-instructions.html.twig', array(
'locale' => $app['locale'],
'available_locales' => Application::getAvailableLanguages(),
));
}
public function getInstallForm(Application $app, Request $request)
{
$warnings = array();

View File

@@ -44,7 +44,6 @@ class ConfigurationPanel extends AbstractConfigurationPanel
$params = array(
'configuration' => $configuration,
'date_fields' => $this->getAvailableDateFields($app['phraseanet.appbox']->get_databoxes()),
'available_sort'=> $this->searchEngine->getAvailableSort(),
);
@@ -64,6 +63,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
}
$configuration['default_sort'] = $request->request->get('default_sort');
$configuration['stemming_enabled'] = (int) (Boolean) $request->request->get('stemming_enabled');
$this->saveConfiguration($configuration);
@@ -89,6 +89,10 @@ class ConfigurationPanel extends AbstractConfigurationPanel
$configuration['default_sort'] = null;
}
if (!isset($configuration['stemming_enabled'])) {
$configuration['stemming_enabled'] = false;
}
return $configuration;
}
}

View File

@@ -118,6 +118,16 @@ class PhraseaEngine implements SearchEngineInterface
return $sort;
}
/**
* {@inheritdoc}
*/
public function isStemmingEnabled()
{
$configuration = $this->getConfiguration();
return (Boolean) $configuration['stemming_enabled'];
}
/**
* {@inheritdoc}
*/

View File

@@ -59,6 +59,11 @@ interface SearchEngineInterface
*/
public function getDefaultSort();
/**
* @return string The default sort
*/
public function isStemmingEnabled();
/**
* @return array an array containing sort order values as key and sort order names as value
*/

View File

@@ -110,6 +110,14 @@ class SphinxSearchEngine implements SearchEngineInterface
return 'relevance';
}
/**
* {@inheritdoc}
*/
public function isStemmingEnabled()
{
return true;
}
/**
* {@inheritdoc}
*/

View File

@@ -400,7 +400,7 @@ class API_V1_adapter extends API_V1_Abstract
'active' => $app['phraseanet.registry']->get('GV_client_navigator'),
),
'office-plugin' => array(
'active' => $registry->get('GV_client_navigator'),
'active' => $app['phraseanet.registry']->get('GV_client_navigator'),
),
'homepage' => array(
'viewType' => $app['phraseanet.registry']->get('GV_home_publi'),

View File

@@ -54,7 +54,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
* @desc la periode par defaut d'affichage du dashboard
* @var <string>
*/
public $periode = '-1 month';
public $periode = '-5 days';
/**
* @desc le sbasid de la base ou on effectue le report
@@ -276,7 +276,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
$listeColl[] = (int) $value['coll_id'];
}
$this->authorizedCollection[] = array(
$this->authorizedCollection[(int) $sbas] = array(
'sbas_id' => (int) $sbas,
'coll' => implode(',', $listeColl),
'name' => phrasea::sbas_labels($sbas, $this->app)

View File

@@ -1163,11 +1163,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function reindex()
{
$connbas = connection::getPDOConnection($this->app, $this->get_sbas_id());
$sql = 'UPDATE record SET status=(status & ~7 | 4)
WHERE record_id= :record_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id));
$this->app['phraseanet.SE']->updateRecord($this);
$this->delete_data_from_cache(self::CACHE_STATUS);
return $this;

View File

@@ -117,7 +117,7 @@
</div>
<div id="divXml" style="display:none">
<textarea nowrap id="txtareaxml" onchange="chgXml();" style=" width:99%;height:380px;white-space:pre" >{{ collection.get_prefs() }}</textarea>
<textarea nowrap id="txtareaxml" onchange="chgXml();" style=" width:99%;height:380px;white-space:pre" >{{ collection.get_prefs() | raw }}</textarea>
</div>
</td>
</tr>
@@ -135,7 +135,7 @@
</table>
<form method="post" name="chgStructure" action="{{ path('admin_collection_display_suggested_values', { 'bas_id' : app['request'].attributes.get('bas_id') }) }}" onsubmit="return(false);" target="right" style="visibility:hidden;">
<textarea nowrap style="visibility:hidden;white-space:pre" name="str" id="idstr">{{ collection.get_prefs() }}</textarea>
<textarea nowrap style="visibility:hidden;white-space:pre" name="str" id="idstr">{{ collection.get_prefs() | raw }}</textarea>
</form>
<script type="text/javascript">
@@ -174,26 +174,6 @@
tableLeft.scrollTop(theTable.scrollTop());
}
/*function addEvent(obj, evType, fn, useCapture)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, useCapture);
return true;
}
else
{
if (obj.attachEvent) {
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
alert("Handler could not be attached");
}
}
}*/
/* Chargement de tt les elements dans un tableau pour un acces plus rapide */
function scandom(node, depth)
{
@@ -432,7 +412,7 @@ function write_valsug()
for (i=0; i<pref[o.val()].valsug.length; i++)
{
if (pref[o.val()].valsug[i]) {
x = p.options[p.options.length] = new Option(unescape(pref[o.val()].valsug[i]), pref[o.val()].valsug[i]);
x = p.options[p.options.length] = new Option((pref[o.val()].valsug[i]), pref[o.val()].valsug[i]);
}
}
}
@@ -576,7 +556,7 @@ function ajouter()
o = $("#nomchamPH");
// pref[o.value].valsug.push( UtEncode(o2.value) );
// pref[o.value].valsug[pref[o.value].valsug.length]= UtEncode(o2.value);
pref[o.val()].valsug[pref[o.val()].valsug.length]= escape(o2.val());
pref[o.val()].valsug[pref[o.val()].valsug.length]= (o2.val());
o2.val("");
}
@@ -815,7 +795,7 @@ pref["{{ name }}"].empty = true;
{% for value in suggestedValues %}
pref["{{ value['key'] }}"].valsug["{{ value['value'] }}"] = unescape('{{ value['name'] }}');
pref["{{ value['key']|escapeDoubleQuote|raw }}"].valsug["{{ value['value']|escapeDoubleQuote|raw }}"] = ('{{ value['name']|escapeSimpleQuote|raw }}');
{% endfor %}
@@ -829,44 +809,64 @@ pref["{{ value['key'] }}"].valsug["{{ value['value'] }}"] = unescape('{{ value['
function getSruct()
{
var lexmlstruct = '<'+ '?xml version="1.0" encoding="UTF-8"?'+'>\n<baseprefs>\n';
lexmlstruct += "\t" + statuscoll+"\n";
if(otherFields!="") {
lexmlstruct += "\t" + otherFields+"\n";
}
lexmlstruct +='\t<sugestedValues>\n';
var dom = document.implementation.createDocument(null, 'baseprefs');
var values = dom.createElement('sugestedValues');
for (a in pref ) {
lexmlstruct2 = "";
var section = dom.createElement(a);
var go = false;
for (b in pref[a].valsug ) {
// rempl
var reg=new RegExp("&", "g");
var reg2=new RegExp("<", "g");
var reg3=new RegExp(">", "g");
pref[a].valsug[b] = unescape(pref[a].valsug[b]).replace(reg,"&amp;");
pref[a].valsug[b] = pref[a].valsug[b].replace(reg2,"&lt;");
pref[a].valsug[b] = pref[a].valsug[b].replace(reg3,"&gt;");
if(pref[a].valsug[b]!="") {
lexmlstruct2 += '\t\t\t<value>'+ unescape(pref[a].valsug[b]).replace(reg,"&amp;") + '</value>\n';
go = true;
var value = dom.createElement('value');
value.appendChild(dom.createTextNode(pref[a].valsug[b]));
section.appendChild(value);
}
}
if (go) {
values.appendChild(section);
}
}
dom.getElementsByTagName('baseprefs')[0].appendChild(values);
var serializer = new XMLSerializer();
var xml = '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(dom);
xml.replace('<sugestedValues>', statuscoll + otherFields + '<sugestedValues>');
return formatXml(xml);
}
function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.replace(reg, '$1\r\n$2$3');
var pad = 0;
jQuery.each(xml.split('\r\n'), function(index, node) {
var indent = 0;
if (node.match( /.+<\/\w[^>]*>$/ )) {
indent = 0;
} else if (node.match( /^<\/\w/ )) {
if (pad != 0) {
pad -= 1;
}
} else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
indent = 1;
} else {
indent = 0;
}
if(lexmlstruct2 != "") {
lexmlstruct += '\t\t<' + a + '>\n';
lexmlstruct += lexmlstruct2;
lexmlstruct += '\t\t</' + a + '>\n';
}
var padding = '';
for (var i = 0; i < pad; i++) {
padding += ' ';
}
lexmlstruct += '\t</sugestedValues>\n';
lexmlstruct += '</baseprefs>';
formatted += padding + node + '\r\n';
pad += indent;
});
return(lexmlstruct);
return formatted;
}
function view(type)

View File

@@ -286,6 +286,7 @@
}
}
});
setTimeout("refreshDatabaseInformations();", 10000);
}
$(document).ready(function(){
@@ -365,8 +366,6 @@
});
}
setTimeout("refreshDatabaseInformations();", 6000);
$('#fileupload').fileupload({
dataType: 'html',
add: function(e, data) {

View File

@@ -4,13 +4,8 @@
<form method="post" action="{{ path('admin_searchengine_post') }}">
<fieldset>
<legend>{% trans 'Date fields available for search' %}</legend>
{% for field in date_fields %}
<label class="checkbox">
<input type="checkbox" name="date_fields[]" value="{{ field }}" {% if field in configuration['date_fields'] %}checked="checked"{% endif %} >
{{ field }}
</label>
{% endfor %}
<legend>{% trans 'Stemming' %}</legend>
{% trans 'Enable stemming' %} <input type="checkbox" name="stemming_enabled" value="1" {% if configuration['stemming_enabled'] %}checked="checked"{% endif %} />
</fieldset>
<fieldset>
<legend>{% trans 'Default sort' %}</legend>

View File

@@ -339,7 +339,7 @@
<span>{% trans 'Trier par ' %}</span>
<select name="sort" class="input-small">
{% for sort, sort_name in app['phraseanet.SE'].getAvailableSort() %}
<option value="{{ sort }}" {% if sort == app['phraseanet.SE'].getDefaultSort() %}selected="selected"{% endif %}>{{ sort_name }}</option>
<option value="{{ sort }}" {% if sort == app['phraseanet.SE'].getDefaultSort() %}selected="selected" class="default-selection"{% endif %}>{{ sort_name }}</option>
{% endfor %}
</select>
<select name="ord" class="input-medium">
@@ -350,7 +350,7 @@
{% if app['phraseanet.SE'].hasStemming() %}
<div>
<label class="checkbox">
<input type="checkbox" checked="checked" name="stemme" /> {% trans 'rechercher par stemme' %}
<input type="checkbox" {% if app['phraseanet.SE'].isStemmingEnabled() %} checked="checked" {% endif %} name="stemme" /> {% trans 'rechercher par stemme' %}
</label>
</div>
{% endif %}

View File

@@ -2,12 +2,9 @@
<div id="title_dash" class="center" style="clear:left;">{% trans "report:: Dashboard" %}</div>
<div id="periode_dash" class="center" >{{ dashboard.getTitleDate('dmin') }} - {{ dashboard.getTitleDate('dmax') }}</div>
<div id="liste_dash" class="center">
{% for key in dashboard.authorizedCollection|keys %}
{% if not loop.first %}
<em id="em_{{ key }}" >{{ key|sbas_labels(app) }}</em>
{% else %}
<em id="em_all" class="selected_em" >Toutes les bases</em>
{% endif %}
{% for key in dashboard.authorizedCollection|keys %}
<em id="em_{{ key }}" >{{ key|sbas_labels(app) }}</em>
{% endfor %}
</div>
<div id="dashboard-table" >

View File

@@ -0,0 +1,38 @@
{% extends '/setup/wrapper.html.twig' %}
{% block content %}
<div class="steps" style="min-height:450px;">
<table style="width:100%;">
<tr>
<td>
<div style="height:400px;overflow:auto;">
<h2>
Upgrade Instructions
</h2>
<p>
This Phraseanet install requires an upgrade.
</p>
<table style="width:100%;margin-top:60px;">
<tr>
<td colspan="2">
Please run the following command at your application install root.
<code>
bin/setup system:upgrade
</code>
</td>
</tr>
</table>
</div>
<div>
<table style="width:100%;">
<tr>
<td style="text-align:right;">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
{% endblock %}

View File

@@ -21,7 +21,7 @@ class ComposerInstallTest extends \PhraseanetPHPUnitAbstract
self::$DI['cli']['driver.composer']->expects($this->at(1))
->method('command')
->with(array('install', '--optimize-autoloader', '--dev'));
->with(array('install', '--optimize-autoloader', '--quiet', '--no-interaction', '--dev'));
$command = new ComposerInstall();
$command->setContainer(self::$DI['cli']);

View File

@@ -39,6 +39,9 @@ class SetupTest extends \Silex\WebTestCase
public function testRouteSlashWhenInstalled()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isInstalled')
->will($this->returnValue(true));
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(false));
@@ -50,6 +53,22 @@ class SetupTest extends \Silex\WebTestCase
$this->assertEquals('/login/', $response->headers->get('location'));
}
public function testRouteInstructionsWhenUpgradeRequired()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isInstalled')
->will($this->returnValue(false));
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(false));
$client = $this->createClient();
$crawler = $client->request('GET', '/setup/');
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/upgrade-instructions/', $response->headers->get('location'));
}
public function testRouteSetupInstaller()
{
$client = $this->createClient();

View File

@@ -529,4 +529,14 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
if ( ! $found)
$this->fail();
}
public function testReindex()
{
$record = new \record_adapter(self::$DI['app'], self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id());
self::$DI['app']['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
self::$DI['app']['phraseanet.SE']->expects($this->once())
->method('updateRecord')
->with($record);
$record->reindex();
}
}

View File

@@ -607,6 +607,7 @@ img.ui-datepicker-trigger{
#grid,#grid tr, #grid td{
z-index:50;
text-align:center;
}
.diapo
{

View File

@@ -223,16 +223,16 @@ function pquit(){
function resize(){
var h = bodySize.y = $(window).height() - $('#mainMenu').outerHeight();
var w = bodySize.x = $(window).width();
var h = bodySize.y = $(document).height() - $('#mainMenu').outerHeight();
var w = bodySize.x = $(document).width();
controlPubliSize();
var rightw = w - 265;
rightw = ((rightw) > 0) ? rightw : 0;
$('#container').height($(window).height());
$('#container').width($(window).width());
$('#container').height($(document).height());
$('#container').width($(document).width());
$('#right').width(rightw);
$('#answers').height(h - $('#nb_answersEXT').outerHeight() - $('#navigation').outerHeight() - 20);

View File

@@ -2146,6 +2146,7 @@ DIV.thesaurus DIV.c {
BACKGROUND-COLOR: #F0F0F0;
cursor: pointer;
color: black;
line-height:10px;
}
#idFrameE DIV.thesaurus B {

View File

@@ -2190,6 +2190,7 @@ DIV.thesaurus DIV.c {
BACKGROUND-COLOR: #F0F0F0;
cursor: pointer;
color: black;
line-height:10px;
}
#idFrameE DIV.thesaurus B {

View File

@@ -197,7 +197,7 @@ function checkFilters(save)
switches.filter('option:selected, input:checked').addClass('was');
$('#sbasfiltercont select option:selected').removeAttr('selected').selected(false);
$('#sbasfiltercont select option:selected:not(".default-selection")').removeAttr('selected').selected(false);
$('#sbasfiltercont select option.field_switch').hide();