mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
V 3.5 RC 1
This commit is contained in:
45
lib/classes/module/console/aboutAuthors.class.php
Normal file
45
lib/classes/module/console/aboutAuthors.class.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_aboutAuthors extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('List authors and contributors');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../AUTHORS'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
45
lib/classes/module/console/aboutLicense.class.php
Normal file
45
lib/classes/module/console/aboutLicense.class.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_aboutLicense extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('This program license');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln(file_get_contents(dirname(__FILE__) . '/../../../../LICENSE'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
56
lib/classes/module/console/schedulerStart.class.php
Normal file
56
lib/classes/module/console/schedulerStart.class.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_schedulerStart extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Start the scheduler');
|
||||
$this->setHelp(
|
||||
"You should use launch the command and finish it with `&`"
|
||||
. " to return to the console\n\n"
|
||||
. "\tie : <info>bin/console scheduler:start &</info>"
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$scheduler = new task_Scheduler();
|
||||
$scheduler->run($output, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
62
lib/classes/module/console/schedulerState.class.php
Normal file
62
lib/classes/module/console/schedulerState.class.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_schedulerState extends Command
|
||||
{
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Get scheduler state');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$appbox = appbox::get_instance();
|
||||
$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']));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
53
lib/classes/module/console/schedulerStop.class.php
Normal file
53
lib/classes/module/console/schedulerStop.class.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_schedulerStop extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Stop the scheduler');
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$appbox = appbox::get_instance();
|
||||
$task_manager = new task_manager($appbox);
|
||||
|
||||
$task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
101
lib/classes/module/console/systemBackupDB.class.php
Normal file
101
lib/classes/module/console/systemBackupDB.class.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_systemBackupDB extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$dir = sprintf(
|
||||
'%s/config/'
|
||||
, dirname(dirname(dirname(dirname(dirname(__FILE__)))))
|
||||
);
|
||||
|
||||
$this->setDescription('Backup Phraseanet Databases');
|
||||
|
||||
$this->addArgument('directory', null, 'The directory where to backup', $dir);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$output->write('Phraseanet is going to be backup...', true);
|
||||
|
||||
$appbox = appbox::get_instance();
|
||||
|
||||
$this->dump_base($appbox, $input, $output);
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox)
|
||||
{
|
||||
$this->dump_base($databox, $input, $output);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
protected function dump_base(base $base, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$date_obj = new DateTime();
|
||||
|
||||
$filename = sprintf(
|
||||
'%s%s_%s.sql'
|
||||
, p4string::addEndSlash($input->getArgument('directory'))
|
||||
, $base->get_dbname()
|
||||
, $date_obj->format('Y_m_d_H_i_s')
|
||||
);
|
||||
|
||||
$output->write(sprintf('Generating %s ... ', $filename));
|
||||
|
||||
$command = sprintf(
|
||||
'mysqldump --host %s --port %s --user %s --password=%s'
|
||||
. ' --database %s --default-character-set=utf8 > %s'
|
||||
, $base->get_host()
|
||||
, $base->get_port()
|
||||
, $base->get_user()
|
||||
, $base->get_passwd()
|
||||
, $base->get_dbname()
|
||||
, escapeshellarg($filename)
|
||||
);
|
||||
|
||||
system($command);
|
||||
|
||||
if (file_exists($filename) && filesize($filename) > 0)
|
||||
$output->writeln('OK');
|
||||
else
|
||||
$output->writeln('<error>Failed</error>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
99
lib/classes/module/console/systemClearCache.class.php
Normal file
99
lib/classes/module/console/systemClearCache.class.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_systemClearCache extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Empty cache directories, clear Memcached, Redis if avalaible');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$files = $dirs = array();
|
||||
$finder = new Finder();
|
||||
$finder
|
||||
->files()
|
||||
->exclude('.git')
|
||||
->exclude('.svn')
|
||||
->in(array(
|
||||
dirname(__FILE__) . '/../../../../tmp/cache_minify/'
|
||||
, dirname(__FILE__) . '/../../../../tmp/cache_twig/'
|
||||
))
|
||||
;
|
||||
$count = 1;
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
$files[$file->getPathname()] = $file->getPathname();
|
||||
$count++;
|
||||
}
|
||||
|
||||
$finder = new Finder();
|
||||
$finder
|
||||
->directories()
|
||||
->in(array(
|
||||
dirname(__FILE__) . '/../../../../tmp/cache_minify'
|
||||
, dirname(__FILE__) . '/../../../../tmp/cache_twig'
|
||||
))
|
||||
->exclude('.git')
|
||||
->exclude('.svn')
|
||||
;
|
||||
foreach ($finder as $file)
|
||||
{
|
||||
$dirs[$file->getPathname()] = $file->getPathname();
|
||||
printf('%4d) %s' . PHP_EOL, $count, $file->getPathname());
|
||||
$count++;
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
foreach ($dirs as $dir)
|
||||
{
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
if(setup::is_installed())
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$cache = cache_adapter::get_instance($registry);
|
||||
if($cache->ping())
|
||||
{
|
||||
$cache->flush();
|
||||
}
|
||||
}
|
||||
|
||||
$output->write('Finished !', true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
108
lib/classes/module/console/systemConfigCheck.class.php
Normal file
108
lib/classes/module/console/systemConfigCheck.class.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_systemConfigCheck extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Check the configuration');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!function_exists('_'))
|
||||
{
|
||||
$output->writeln('<error>YOU MUST ENABLE GETTEXT SUPPORT TO USE PHRASEANET</error>');
|
||||
$output->writeln('Canceled');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (setup::is_installed())
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
|
||||
$output->writeln(_('*** CHECK BINARY CONFIGURATION ***'));
|
||||
$this->processConstraints(setup::check_binaries($registry), $output);
|
||||
$output->writeln("");
|
||||
}
|
||||
else
|
||||
{
|
||||
$registry = new Setup_Registry();
|
||||
}
|
||||
|
||||
$output->writeln(_('*** FILESYSTEM CONFIGURATION ***'));
|
||||
$this->processConstraints(setup::check_writability($registry), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK CACHE OPCODE ***'));
|
||||
$this->processConstraints(setup::check_cache_opcode(), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK CACHE SERVER ***'));
|
||||
$this->processConstraints(setup::check_cache_server(), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK PHP CONFIGURATION ***'));
|
||||
$this->processConstraints(setup::check_php_configuration(), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK PHP EXTENSIONS ***'));
|
||||
$this->processConstraints(setup::check_php_extension(), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK PHRASEA ***'));
|
||||
$this->processConstraints(setup::check_phrasea(), $output);
|
||||
$output->writeln("");
|
||||
$output->writeln(_('*** CHECK SYSTEM LOCALES ***'));
|
||||
$this->processConstraints(setup::check_system_locales(), $output);
|
||||
$output->writeln("");
|
||||
|
||||
$output->write('Finished !', true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
protected function processConstraints(Setup_ConstraintsIterator $constraints, OutputInterface &$output)
|
||||
{
|
||||
foreach ($constraints as $constraint)
|
||||
{
|
||||
$this->processConstraint($constraint, $output);
|
||||
}
|
||||
}
|
||||
|
||||
protected function processConstraint(Setup_Constraint $constraint, OutputInterface &$output)
|
||||
{
|
||||
if ($constraint->is_ok())
|
||||
$output->writeln("\t\t<info>" . $constraint->get_message() . '</info>');
|
||||
elseif ($constraint->is_blocker())
|
||||
$output->writeln("\t!!!\t<error>" . $constraint->get_message() . '</error>');
|
||||
else
|
||||
$output->writeln("\t/!\\\t<comment>" . $constraint->get_message() . '</comment>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
124
lib/classes/module/console/systemTemplateGenerator.class.php
Normal file
124
lib/classes/module/console/systemTemplateGenerator.class.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_systemTemplateGenerator extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Generate template files');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
|
||||
Twig_Autoloader::register();
|
||||
Twig_Extensions_Autoloader::register();
|
||||
|
||||
|
||||
$tplDir = dirname(__FILE__) . '/../../../../templates/';
|
||||
$tmpDir = dirname(__FILE__) . '/../../../../tmp/cache_twig/';
|
||||
$loader = new Twig_Loader_Filesystem($tplDir);
|
||||
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
'cache' => $tmpDir,
|
||||
'auto_reload' => true
|
||||
));
|
||||
$twig->addExtension(new Twig_Extensions_Extension_I18n());
|
||||
|
||||
|
||||
$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'));
|
||||
$twig->addFilter('unite', new Twig_Filter_Function('p4string::format_octets'));
|
||||
$twig->addFilter('stristr', new Twig_Filter_Function('stristr'));
|
||||
$twig->addFilter('implode', new Twig_Filter_Function('implode'));
|
||||
$twig->addFilter('stripdoublequotes', new Twig_Filter_Function('stripdoublequotes'));
|
||||
$twig->addFilter('phraseadate', new Twig_Filter_Function('phraseadate::getPrettyString'));
|
||||
$twig->addFilter('format_octets', new Twig_Filter_Function('p4string::format_octets'));
|
||||
$twig->addFilter('geoname_display', new Twig_Filter_Function('geonames::name_from_id'));
|
||||
$twig->addFilter('get_collection_logo', new Twig_Filter_Function('collection::getLogo'));
|
||||
$twig->addFilter('nl2br', new Twig_Filter_Function('nl2br'));
|
||||
$twig->addFilter('floor', new Twig_Filter_Function('floor'));
|
||||
$twig->addFilter('bas_name', new Twig_Filter_Function('phrasea::bas_names'));
|
||||
$twig->addFilter('bas_names', new Twig_Filter_Function('phrasea::bas_names'));
|
||||
$twig->addFilter('basnames', new Twig_Filter_Function('phrasea::bas_names'));
|
||||
$twig->addFilter('urlencode', new Twig_Filter_Function('urlencode'));
|
||||
$twig->addFilter('sbasFromBas', new Twig_Filter_Function('phrasea::sbasFromBas'));
|
||||
$twig->addFilter('str_replace', new Twig_Filter_Function('str_replace'));
|
||||
$twig->addFilter('strval', new Twig_Filter_Function('strval'));
|
||||
$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('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('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'));
|
||||
|
||||
|
||||
$n_ok = $n_error = 0;
|
||||
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
|
||||
{
|
||||
if (strpos($file, '/.svn/') !== false)
|
||||
continue;
|
||||
if (substr($file->getFilename(), 0, 1) === '.')
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
$twig->loadTemplate(str_replace($tplDir, '', $file));
|
||||
$output->writeln('' . $file . '');
|
||||
$n_ok++;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||
$n_error++;
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln("");
|
||||
$output->write(sprintf('%d templates generated. ', $n_ok));
|
||||
|
||||
if ($n_error > 0)
|
||||
{
|
||||
$output->write(sprintf('<error>%d templates failed.</error>', $n_error));
|
||||
}
|
||||
|
||||
$output->writeln("");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
79
lib/classes/module/console/systemUpgrade.class.php
Normal file
79
lib/classes/module/console/systemUpgrade.class.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_systemUpgrade extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Upgrade Phraseanet to the lastest version');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$output->write('Phraseanet is going to be upgraded', true);
|
||||
$dialog = $this->getHelperSet()->get('dialog');
|
||||
|
||||
do
|
||||
{
|
||||
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Continuer ?') . ' (Y/n)</question>', 'Y'));
|
||||
}
|
||||
while (!in_array($continue, array('y', 'n')));
|
||||
|
||||
|
||||
if ($continue == 'y')
|
||||
{
|
||||
try
|
||||
{
|
||||
$output->write('<info>Upgrading...</info>', true);
|
||||
$appbox = appbox::get_instance();
|
||||
$upgrader = new Setup_Upgrade($appbox);
|
||||
$advices = $appbox->forceUpgrade($upgrader);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$output->writeln(sprintf('<error>An error occured while upgrading : %s </error>', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$output->write('<info>Canceled</info>', true);
|
||||
}
|
||||
$output->write('Finished !', true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
70
lib/classes/module/console/tasklist.class.php
Normal file
70
lib/classes/module/console/tasklist.class.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_tasklist extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('List tasks');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../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)
|
||||
{
|
||||
$this->print_task($task, $output);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
protected function print_task(task_abstract $task, OutputInterface &$output)
|
||||
{
|
||||
$message = $task->get_task_id()."\t".($task->get_status() )."\t".$task->get_title();
|
||||
$output->writeln($message);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
74
lib/classes/module/console/taskrun.class.php
Normal file
74
lib/classes/module/console/taskrun.class.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo write tests
|
||||
*
|
||||
* @package KonsoleKomander
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class module_console_taskrun extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->addArgument('task_id', InputArgument::REQUIRED, 'The task_id to run');
|
||||
$this->addOption(
|
||||
'runner'
|
||||
, 'r'
|
||||
, InputOption::VALUE_REQUIRED
|
||||
, 'The name of the runner (manual, scheduler...)'
|
||||
, task_abstract::RUNNER_MANUAL
|
||||
);
|
||||
$this->setDescription('Run task');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';
|
||||
|
||||
$task_id = (int) $input->getArgument('task_id');
|
||||
|
||||
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
|
||||
throw new \RuntimeException('Argument must be an Id.');
|
||||
|
||||
$appbox = appbox::get_instance();
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($task_id);
|
||||
|
||||
$runner = task_abstract::RUNNER_SCHEDULER;
|
||||
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL)
|
||||
$runner = task_abstract::RUNNER_MANUAL;
|
||||
|
||||
$task->run($runner);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user