adressed @romainneutron's comments

This commit is contained in:
Nicolas Le Goff
2013-08-07 11:58:46 +02:00
committed by Romain Neutron
parent aa92dbe124
commit 93b48fdcea
6 changed files with 73 additions and 51 deletions

View File

@@ -94,7 +94,7 @@ class Install extends Command
$abConn = $this->getABConn($input, $output, $dialog);
list($dbConn, $template) = $this->getDBConn($input, $output, $abConn, $dialog);
list($email, $password) = $this->getCredentials($input, $output, $dialog);
$dataPath = $this->getDataPath($input, $output,$dialog);
$dataPath = $this->getDataPath($input, $output, $dialog);
$serverName = $this->getServerName($input, $output, $dialog);
$indexer = $this->getindexer($input, $output);

View File

@@ -871,6 +871,7 @@ class Databox implements ControllerProviderInterface
{
$msg = _('An error occurred');
$success = false;
$taskCreated = false;
try {
$databox = $app['phraseanet.appbox']->get_databox($databox_id);
@@ -879,11 +880,17 @@ class Databox implements ControllerProviderInterface
foreach ($databox->get_collections() as $collection) {
if ($collection->get_record_amount() <= 500) {
$collection->empty_collection(500);
$msg = _('Base empty successful');
if (false === $taskCreated) {
$msg = _('Base empty successful');
}
} else {
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
\task_period_emptyColl::create($app, $settings);
$msg = _('A task has been creted, please run it to complete empty collection');
if (false === $taskCreated) {
$msg = _('A task has been created, please run it to complete empty collection');
$taskCreated = true;
}
}
}
} else {

View File

@@ -15,19 +15,19 @@ class BytesConverter extends \Twig_Extension
{
protected $unit;
public function __construct()
{
$this->unit = array();
$this->unit['B'] = 'Bytes'; // 8 bits
$this->unit['KB'] = 'Kilobytes'; // 1024 bytes
$this->unit['MB'] = 'Megabytes'; // 1048576 bytes
$this->unit['GB'] = 'Gigabytes'; // 1073741824 bytes
$this->unit['TB'] = 'Terabytes'; // 1099511627776 bytes
$this->unit['PB'] = 'Petabytes'; // 1.12589991e15 bytes
$this->unit['EB'] = 'Exabytes'; // 1.1529215e18 bytes
$this->unit['ZB'] = 'Zettabytes'; // 1.18059162e21 bytes
$this->unit['YB'] = 'Yottabytes'; // 1.20892582e24 bytes
}
public function __construct()
{
$this->unit = array();
$this->unit['B'] = 'Bytes'; // 8 bits
$this->unit['KB'] = 'Kilobytes'; // 1024 bytes
$this->unit['MB'] = 'Megabytes'; // 1048576 bytes
$this->unit['GB'] = 'Gigabytes'; // 1073741824 bytes
$this->unit['TB'] = 'Terabytes'; // 1099511627776 bytes
$this->unit['PB'] = 'Petabytes'; // 1.12589991e15 bytes
$this->unit['EB'] = 'Exabytes'; // 1.1529215e18 bytes
$this->unit['ZB'] = 'Zettabytes'; // 1.18059162e21 bytes
$this->unit['YB'] = 'Yottabytes'; // 1.20892582e24 bytes
}
public function getName()
{
@@ -35,37 +35,37 @@ class BytesConverter extends \Twig_Extension
}
public function getFilters()
{
return array(
{
return array(
'bytesTo*' => new \Twig_Filter_Method($this, 'bytes2Filter')
);
}
}
public function bytes2Filter($suffix, $bytes, $precision = 2)
{
$auto = array('Human', 'Auto');
$unit = array_keys($this->unit);
public function bytes2Filter($suffix, $bytes, $precision = 2)
{
$auto = array('Human', 'Auto');
$unit = array_keys($this->unit);
if ($bytes <= 0) {
return '0 ' . $unit[0];
}
if ($bytes <= 0) {
return '0 ' . $unit[0];
}
if ($suffix == '') {
$suffix = 'Auto';
}
if ($suffix == '') {
$suffix = 'Auto';
}
if (array_search($suffix, array_merge($auto, $unit)) === false) {
throw new \Exception('Sorry, you have to specify a legal Byte value or "Human" for automatic. Legal options are: Human, ' . implode(', ', $unit));
}
if (array_search($suffix, array_merge($auto, $unit)) === false) {
throw new \Exception('Sorry, you have to specify a legal Byte value or "Human" for automatic. Legal options are: Human, ' . implode(', ', $unit));
}
switch ($suffix) {
case '':
case 'Human':
case 'Auto':
return round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision) . ' ' . $unit[$i];
default:
$i = array_search($suffix, $unit);
return round($bytes / pow(1024, $i), $precision) . ' ' . $unit[$i];
}
}
switch ($suffix) {
case '':
case 'Human':
case 'Auto':
return round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision) . ' ' . $unit[$i];
default:
$i = array_search($suffix, $unit);
return round($bytes / pow(1024, $i), $precision) . ' ' . $unit[$i];
}
}
}

View File

@@ -658,12 +658,10 @@ class task_period_cindexer extends task_abstract
*/
public static function getDefaultSettings(Configuration $config, array $params = array())
{
$binaries = $config['binaries'];
$database = $config['main']['database'];
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<binpath>"
. (array_key_exists('phraseanet_indexer', $binaries) ? str_replace('/phraseanet_indexer', '', $binaries['phraseanet_indexer']) : '')
. "</binpath><host>" . $database['host'] . "</host><port>"
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n"
."<host>" . $database['host'] . "</host><port>"
. $database['port'] . "</port><base>"
. $database['dbname'] . "</base><user>"
. $database['user'] . "</user><password>"

View File

@@ -13,7 +13,6 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Notification\Mail\MailSuccessFTPSender;
use Alchemy\Phrasea\Notification\Receiver;
class task_period_ftp extends task_appboxAbstract
{
protected $proxy;
@@ -707,7 +706,6 @@ class task_period_ftp extends task_appboxAbstract
return $this;
}
/**
* @param array $params
*/

View File

@@ -238,8 +238,29 @@
{% endif %}
</div>
{# Invalid file type modal shown when uploaded logo file is invalid #}
<div id="invalid-modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{% trans %}Invalid file type{% endtrans %}</h3>
</div>
<div class="modal-body">
<p>
{% set supported_file_types = ['jpg', 'jpeg', 'pjpg', 'gif', 'png']|join(' | ') %}
{% trans %} Invalid file type, only ({{ supported_file_types }}) file formats are supported {% endtrans %}
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">Close</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#invalid-modal').modal({
"show": false
});
//add admins
$( ".admin_adder" ).autocomplete({
source: "/admin/users/typeahead/search/?have_not_right[]=order_master&on_base[]={{ bas_id }}",
@@ -330,9 +351,7 @@
add: function(e, data) {
if (typeof data.files[0].type !== "undefined") {
if( ! /(\.|\/)(png|jpeg|jpg|pjpg|gif)$/i.test(data.files[0].type)) {
{% set supported_file_types = ['jpg', 'jpeg', 'pjpg', 'gif', 'png']|join(' | ') %}
alert("{% trans %} Invalid file type, only ({{ supported_file_types }}) file formats are supported {% endtrans %}");
$('#invalid-modal').modal('toggle');
return false;
}
}