parent
9b27f561a9
commit
5f7d19f3e7
@ -0,0 +1 @@ |
||||
/vendor/ |
||||
@ -0,0 +1 @@ |
||||
/vendor/ |
||||
@ -0,0 +1,6 @@ |
||||
/tests/phpunit_report |
||||
/nbproject/ |
||||
/vendor/ |
||||
/docs/build |
||||
composer.phar |
||||
|
||||
@ -0,0 +1,6 @@ |
||||
vendor/ |
||||
Resources/docs/code-coverage |
||||
phpunit.xml |
||||
|
||||
Resources/public/js/bootstrap.compiled*.js |
||||
Resources/public/css/bootstrap.compiled*.css |
||||
@ -0,0 +1,4 @@ |
||||
vendor/ |
||||
phpunit.xml |
||||
composer.lock |
||||
*.DS_Store |
||||
@ -0,0 +1,7 @@ |
||||
# IDE settings |
||||
|
||||
.idea |
||||
.idea/* |
||||
.idea/dictionaries/* |
||||
.idea/cssxfire.xml |
||||
/vendor |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,122 @@ |
||||
<?php |
||||
/* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This software consists of voluntary contributions made by many individuals |
||||
* and is licensed under the MIT license. For more information, see |
||||
* <http://www.doctrine-project.org>. |
||||
*/ |
||||
|
||||
namespace Chash\Command\Database; |
||||
|
||||
use Symfony\Component\Console\Input\InputArgument, |
||||
Symfony\Component\Console; |
||||
|
||||
/** |
||||
* Task for executing arbitrary SQL that can come from a file or directly from |
||||
* the command line. |
||||
* |
||||
* |
||||
* @link www.doctrine-project.org |
||||
* @since 2.0 |
||||
* @author Benjamin Eberlei <kontakt@beberlei.de> |
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> |
||||
* @author Jonathan Wage <jonwage@gmail.com> |
||||
* @author Roman Borschel <roman@code-factory.org> |
||||
*/ |
||||
class ImportCommand extends Console\Command\Command |
||||
{ |
||||
/** |
||||
* @see Console\Command\Command |
||||
*/ |
||||
protected function configure() |
||||
{ |
||||
$this |
||||
->setName('dbal:import') |
||||
->setDescription('Import SQL file(s) directly to Database.') |
||||
->setDefinition(array( |
||||
new InputArgument( |
||||
'file', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'File path(s) of SQL to be executed.' |
||||
) |
||||
)) |
||||
->setHelp(<<<EOT |
||||
Import SQL file(s) directly to Database. |
||||
EOT |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @see Console\Command\Command |
||||
*/ |
||||
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) |
||||
{ |
||||
$conn = $this->getHelper('db')->getConnection(); |
||||
|
||||
if (($fileNames = $input->getArgument('file')) !== null) { |
||||
foreach ((array) $fileNames as $fileName) { |
||||
if ( ! file_exists($fileName)) { |
||||
throw new \InvalidArgumentException( |
||||
sprintf("SQL file '<info>%s</info>' does not exist.", $fileName) |
||||
); |
||||
} else if ( ! is_readable($fileName)) { |
||||
throw new \InvalidArgumentException( |
||||
sprintf("SQL file '<info>%s</info>' does not have read permissions.", $fileName) |
||||
); |
||||
} |
||||
|
||||
$output->write(sprintf("Processing file '<info>%s</info>'... ", $fileName)); |
||||
$sql = file_get_contents($fileName); |
||||
|
||||
if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) { |
||||
// PDO Drivers |
||||
try { |
||||
$lines = 0; |
||||
|
||||
$stmt = $conn->prepare($sql); |
||||
$stmt->execute(); |
||||
|
||||
do { |
||||
// Required due to "MySQL has gone away!" issue |
||||
$stmt->fetch(); |
||||
$stmt->closeCursor(); |
||||
|
||||
$lines++; |
||||
} while ($stmt->nextRowset()); |
||||
|
||||
$output->write(sprintf('%d statements executed!', $lines) . PHP_EOL); |
||||
} catch (\PDOException $e) { |
||||
$output->write('error!' . PHP_EOL); |
||||
|
||||
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e); |
||||
} |
||||
} else { |
||||
// Non-PDO Drivers (ie. OCI8 driver) |
||||
$stmt = $conn->prepare($sql); |
||||
$rs = $stmt->execute(); |
||||
|
||||
if ($rs) { |
||||
$output->writeln('OK!' . PHP_EOL); |
||||
} else { |
||||
$error = $stmt->errorInfo(); |
||||
|
||||
$output->write('error!' . PHP_EOL); |
||||
|
||||
throw new \RuntimeException($error[2], $error[0]); |
||||
} |
||||
|
||||
$stmt->closeCursor(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,85 @@ |
||||
<?php |
||||
|
||||
namespace Chash\Command\Files; |
||||
|
||||
use Chash\Command\Database\CommonChamiloDatabaseCommand; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputInterface; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
use Symfony\Component\Console\Output\OutputInterface; |
||||
|
||||
/** |
||||
* Class CleanDeletedDocmentsCommand |
||||
* Clean the courses/[CODE]/documents/ directory, removing all documents and folders marked DELETED |
||||
* @package Chash\Command\Files |
||||
*/ |
||||
class CleanDeletedDocumentsCommand extends CommonChamiloDatabaseCommand |
||||
{ |
||||
/** |
||||
* |
||||
*/ |
||||
protected function configure() |
||||
{ |
||||
parent::configure(); |
||||
$this |
||||
->setName('files:clean_deleted_documents') |
||||
->setDescription('Cleans the documents that were deleted but left as _DELETED_') |
||||
->addOption( |
||||
'size', |
||||
null, |
||||
InputOption::VALUE_NONE, |
||||
'Show the total size of space that will be freed. Requires more processing' |
||||
) |
||||
->addOption( |
||||
'list', |
||||
null, |
||||
InputOption::VALUE_NONE, |
||||
'Show the complete list of files to be deleted before asking for confirmation' |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param InputInterface $input |
||||
* @param OutputInterface $output |
||||
* @return bool|int|null|void |
||||
*/ |
||||
protected function execute(InputInterface $input, OutputInterface $output) |
||||
{ |
||||
parent::execute($input, $output); |
||||
|
||||
$files = $this->getConfigurationHelper()->getDeletedDocuments(); |
||||
if ($input->isInteractive()) { |
||||
$this->writeCommandHeader($output, 'Cleaning deleted documents.'); |
||||
$list = $input->getOption('list'); //1 if the option was set |
||||
if ($list) { |
||||
if (count($files) > 0) { |
||||
foreach ($files as $file) { |
||||
$output->writeln($file->getRealpath()); |
||||
} |
||||
} else { |
||||
$output->writeln('No file to be deleted in courses/ directory'); |
||||
return; |
||||
} |
||||
} |
||||
$stats = $input->getOption('size'); //1 if the option was set |
||||
if ($stats) { |
||||
$size = 0; |
||||
foreach ($files as $file) { |
||||
$size += $file->getSize(); |
||||
} |
||||
$output->writeln('Total size used by deleted documents: '.round(((float)$size/1024)/1024,2).'MB'); |
||||
} |
||||
$dialog = $this->getHelperSet()->get('dialog'); |
||||
if (!$dialog->askConfirmation( |
||||
$output, |
||||
'<question>Are you sure you want to clean the Chamilo deleted documents? (y/N)</question>', |
||||
false |
||||
) |
||||
) { |
||||
return; |
||||
} |
||||
} |
||||
$this->removeFiles($files, $output); |
||||
} |
||||
} |
||||
@ -0,0 +1,179 @@ |
||||
<?php |
||||
|
||||
namespace Chash\Command\Files; |
||||
|
||||
use Chash\Command\Database\CommonChamiloDatabaseCommand; |
||||
use Symfony\Component\Console\Command\Command; |
||||
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\Finder\Finder; |
||||
use Symfony\Component\Filesystem\Filesystem; |
||||
|
||||
/** |
||||
* Class ConvertVideosCommand |
||||
* Convert all videos found in the given directory (recursively) to the given format, using ffmpeg |
||||
* @package Chash\Command\Files |
||||
*/ |
||||
class ConvertVideosCommand extends CommonChamiloDatabaseCommand |
||||
{ |
||||
public $excluded = array(); |
||||
public $ext; |
||||
public $origExt; |
||||
/** |
||||
* |
||||
*/ |
||||
protected function configure() |
||||
{ |
||||
parent::configure(); |
||||
$this |
||||
->setName('files:convert_videos') |
||||
->setDescription('Converts all videos found in the given directory (recursively) to the given format, using the ffmpeg command line') |
||||
->addArgument( |
||||
'source', |
||||
InputArgument::REQUIRED, |
||||
'The directory containing the videos, as an absolute path' |
||||
) |
||||
->addOption( |
||||
'ext', |
||||
null, |
||||
InputOption::VALUE_REQUIRED, |
||||
'The extension of the files to be found and converted - defaults to "webm"' |
||||
) |
||||
->addOption( |
||||
'orig-ext', |
||||
null, |
||||
InputOption::VALUE_REQUIRED, |
||||
'The extension that we want to add to the original files. Defaults to "orig", so video.webm will be saved as video.orig.webm. Use "none" to skip saving the original.' |
||||
) |
||||
->addOption( |
||||
'fps', |
||||
null, |
||||
InputOption::VALUE_REQUIRED, |
||||
'The fps we want the final videos to be outputted in. Defaults to 24' |
||||
) |
||||
->addOption( |
||||
'bitrate', |
||||
null, |
||||
InputOption::VALUE_REQUIRED, |
||||
'The bitrate (~image quality) we want to export in, expressed in Kbits. Defaults to 512Kbits.' |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param InputInterface $input |
||||
* @param OutputInterface $output |
||||
* @return bool|int|null|void |
||||
*/ |
||||
protected function execute(InputInterface $input, OutputInterface $output) |
||||
{ |
||||
parent::execute($input, $output); |
||||
|
||||
if ($input->isInteractive()) { |
||||
$this->writeCommandHeader($output, 'Looking for videos...'); |
||||
$confPath = $this->getConfigurationHelper()->getConfigurationFilePath(); |
||||
$sysPath = $this->getConfigurationHelper()->getSysPathFromConfigurationFile($confPath); |
||||
|
||||
$dir = $input->getArgument('source'); //1 if the option was set |
||||
if (substr($dir,0,1) != '/') { |
||||
$dir = $sysPath . $dir; |
||||
} |
||||
if (!is_dir($dir)) { |
||||
$output->writeln($dir. ' was not confirmed as a directory (if not starting with /, it is considered as relative to Chamilo\'s root folder)'); |
||||
return; |
||||
} |
||||
$this->ext = $input->getOption('ext'); |
||||
if (empty($this->ext)) { |
||||
$this->ext = 'webm'; |
||||
} |
||||
$this->origExt = $input->getOption('orig-ext'); |
||||
if (empty($this->origExt)) { |
||||
$this->origExt = 'orig'; |
||||
} |
||||
$fps = $input->getOption('fps'); |
||||
if (empty($fps)) { |
||||
$fps = '24'; |
||||
} |
||||
$bitRate = $input->getOption('bitrate'); |
||||
if (empty($bitRate)) { |
||||
$bitRate = '512'; |
||||
} |
||||
$vcodec = 'copy'; |
||||
if ($this->ext == 'webm') { |
||||
$vcodec = 'libvpx'; |
||||
} |
||||
|
||||
// Find the files we want to treat, using Finder selectors |
||||
$finder = new Finder(); |
||||
$filter = function (\SplFileInfo $file, $ext, $orig) |
||||
{ |
||||
$combinedExt = '.'.$orig.'.'.$ext; |
||||
$combinedExtLength = strlen($combinedExt); |
||||
$extLength = strlen('.' . $ext); |
||||
if (substr($file->getRealPath(),-$combinedExtLength) == $combinedExt) { |
||||
return false; |
||||
} |
||||
if (is_file(substr($file->getRealPath(),0,-$extLength) . $combinedExt)) { |
||||
$this->excluded[] = $file; |
||||
return false; |
||||
} |
||||
}; |
||||
$finder->sortByName()->files()->in($dir)->name('*.'.$this->ext)->filter($filter, $this->ext, $this->origExt); |
||||
|
||||
// Print the list of matching files we found |
||||
if (count($finder) > 0) { |
||||
$output->writeln('Videos found for conversion: '); |
||||
foreach ($finder as $file) { |
||||
$output->writeln($file->getRealpath()); |
||||
} |
||||
} else { |
||||
if (count($this->excluded) > 0) { |
||||
$output->writeln('The system has detected several videos already converted: '); |
||||
foreach ($this->excluded as $file) { |
||||
$output->writeln('- '.$file->getRealPath()); |
||||
} |
||||
} |
||||
$output->writeln('No video left to convert'); |
||||
return; |
||||
} |
||||
|
||||
$dialog = $this->getHelperSet()->get('dialog'); |
||||
if (!$dialog->askConfirmation( |
||||
$output, |
||||
'<question>All listed videos will be altered and a copy of the original will be taken with a .orig.webm extension. Are you sure you want to proceed? (y/N)</question>', |
||||
false |
||||
) |
||||
) { |
||||
return; |
||||
} |
||||
$fs = new Filesystem(); |
||||
$time = time(); |
||||
$counter = 0; |
||||
$sizeNew = $sizeOrig = 0; |
||||
foreach ($finder as $file) { |
||||
$sizeOrig += $file->getSize(); |
||||
$origName = $file->getRealPath(); |
||||
$newName = substr($file->getRealPath(),0,-4).'orig.webm'; |
||||
$fs->rename($origName, $newName); |
||||
$out = array(); |
||||
$newNameCommand = preg_replace('/\s/','\ ',$newName); |
||||
$newNameCommand = preg_replace('/\(/','\(',$newNameCommand); |
||||
$newNameCommand = preg_replace('/\)/','\)',$newNameCommand); |
||||
$origNameCommand = preg_replace('/\s/','\ ',$origName); |
||||
$origNameCommand = preg_replace('/\(/','\(',$origNameCommand); |
||||
$origNameCommand = preg_replace('/\)/','\)',$origNameCommand); |
||||
$output->writeln('ffmpeg -i ' . $newNameCommand . ' -b ' . $bitRate . 'k -f ' . $this->ext . ' -vcodec ' . $vcodec . ' -acodec copy -r ' . $fps . ' ' . $origNameCommand); |
||||
$exec = @system('ffmpeg -i ' . $newNameCommand . ' -b ' . $bitRate . 'k -f ' . $this->ext . ' -vcodec ' . $vcodec . ' -acodec copy -r ' . $fps . ' ' . $origNameCommand, $out); |
||||
$sizeNew += filesize($origName); |
||||
$counter ++; |
||||
} |
||||
} |
||||
$output->writeln(''); |
||||
$output->writeln('Done converting all videos from '.$dir); |
||||
$output->writeln('Total videos converted: ' . $counter . ' videos in ' . (time() - $time) .' seconds'); |
||||
$output->writeln('Total size of old videos combined: ' . round($sizeOrig/(1024*1024)).'M'); |
||||
$output->writeln('Total size of all new videos combined: ' . round($sizeNew/(1024*1024)).'M'); |
||||
//$this->removeFiles($files, $output); |
||||
} |
||||
} |
||||
@ -0,0 +1,230 @@ |
||||
<?php |
||||
/** |
||||
* This script contains the TermsPackage command, made to simplify the live of |
||||
* translators by providing them with a list of the 10,000 most used words in |
||||
* their own language to make sure they can have a strong first impact. |
||||
* To make this work, you will have to have the original 10,000 most used words |
||||
* in English. You can either get them by sending an e-mail to ywarnier@chamilo.org |
||||
* or by starting the langstats scripts (check main/cron/lang/ and |
||||
* main/inc/global.inc.php ~600), then collecting the variables with the scripts |
||||
* in main/cron/lang/ |
||||
* The present command serves only at the end of this process, to generate the |
||||
* corresponding language packages in other languages than English |
||||
* @package chamilo.chash.translation |
||||
*/ |
||||
namespace Chash\Command\Translation; |
||||
|
||||
use Chash\Command\Database\CommonChamiloDatabaseCommand; |
||||
use Symfony\Component\Console\Command\Command; |
||||
use Symfony\Component\Console\Input\InputArgument; |
||||
use Symfony\Component\Console\Input\InputInterface; |
||||
use Symfony\Component\Console\Input\InputOption; |
||||
use Symfony\Component\Console\Output\OutputInterface; |
||||
|
||||
/** |
||||
* Class ExportLanguageCommand |
||||
* @package Chash\Command\Translation |
||||
*/ |
||||
class TermsPackageCommand extends CommonChamiloDatabaseCommand |
||||
{ |
||||
/** |
||||
* Set the input variables and what will be shown in command helper |
||||
*/ |
||||
protected function configure() |
||||
{ |
||||
parent::configure(); |
||||
$this |
||||
->setName('translation:terms_package') |
||||
->setDescription('Generates a package of given language terms') |
||||
//(provided in English), in a specific destination language. It requires a Chamilo installation to work as it needs the existing main/lang/ folder to produce the destination language files with as much data as possible.') |
||||
->addArgument( |
||||
'source', |
||||
InputArgument::REQUIRED, |
||||
'The directory containing the reference files and terms, in English' |
||||
) |
||||
->addArgument( |
||||
'language', |
||||
InputArgument::REQUIRED, |
||||
'The language in which you want the package of files and terms' |
||||
) |
||||
->addArgument( |
||||
'dest', |
||||
InputArgument::REQUIRED, |
||||
'The directory in which you want the package files to be put' |
||||
) |
||||
->addOption( |
||||
'tgz', |
||||
null, |
||||
InputOption::VALUE_NONE, |
||||
'Add this option to compress the files (including the directories and the original English form) into one .tar.gz file ready for shipping' |
||||
) |
||||
->addOption( |
||||
'new', |
||||
null, |
||||
InputOption::VALUE_NONE, |
||||
'Allow new languages (languages that do not exist yet). This will generate empty (but usable) translation files.' |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* @param InputInterface $input |
||||
* @param OutputInterface $output |
||||
* @return int|null|void |
||||
*/ |
||||
protected function execute(InputInterface $input, OutputInterface $output) |
||||
{ |
||||
parent::execute($input, $output); |
||||
|
||||
$source = $input->getArgument('source'); |
||||
$language = $input->getArgument('language'); |
||||
$destination = $input->getArgument('dest'); |
||||
$tgz = $input->getOption('tgz'); |
||||
$allowNew = $input->getOption('new'); |
||||
|
||||
$_configuration = $this->getHelper('configuration')->getConfiguration(); |
||||
$baseDir = $_configuration['root_sys']; |
||||
if (substr($baseDir,-1,1) != '/') { |
||||
$baseDir .= '/'; |
||||
} |
||||
if (substr($source,-1,1) != '/') { |
||||
$source .= '/'; |
||||
} |
||||
if (substr($destination,-1,1) != '/') { |
||||
$destination .= '/'; |
||||
} |
||||
|
||||
if (!is_dir($source)) { |
||||
$output->writeln('The directory '.$source.' does not seem to exist. The source directory must exist and contain the language files, similar to e.g. /var/www/chamilo/main/lang/english'); |
||||
exit; |
||||
} |
||||
// Generate a folder name for saving the *partial* files in the original language - use suffix "_partial |
||||
$origLang = substr(substr($source,0,-1),strrpos(substr($source,0,-1),'/')).'_partial'; |
||||
|
||||
if (!is_dir($destination)) { |
||||
$output->writeln('The directory '.$destination.' does not seem to exist. The destination directory must exist in order for this script to write the results in a safe place'); |
||||
exit; |
||||
} |
||||
if (!is_writeable($destination)) { |
||||
$output->writeln('The destination directory must be writeable. '.$destination.' seems not to be writeable now.'); |
||||
exit; |
||||
} |
||||
if (empty($language)) { |
||||
$output->writeln('The destination language must be provided for this script to work. Received '.$language.', which could not be identified.'); |
||||
exit; |
||||
} |
||||
$langDir = $baseDir.'main/lang/'; |
||||
$listDir = scandir($langDir); |
||||
$langs = array(); |
||||
foreach ($listDir as $lang) { |
||||
if (substr($lang,0,1) == '.') { continue; } |
||||
if (!is_dir($langDir.$lang)) { continue; } |
||||
$langs[] = $lang; |
||||
} |
||||
$new = false; |
||||
if (!in_array($language, $langs)) { |
||||
if (!$allowNew) { |
||||
$output->writeln('The destination language must be expressed as one of the directories available in your Chamilo installation. If you are exporting for the creation of a new language, use the --new option to ignore this warning'); |
||||
exit; |
||||
} else { |
||||
$new = true; |
||||
} |
||||
} |
||||
if (is_dir($destination.$language)) { |
||||
if (!is_writeable($destination.$language)) { |
||||
$output->writeln('Destination directory '.$destination.$language.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.'); |
||||
exit; |
||||
} |
||||
$output->writeln('Destination directory '.$destination.$language.' already exists. We recommend using an empty directory. Files in this directory will be overwritten if necessary. Sorry.'); |
||||
} elseif (!@mkdir($destination.$language)) { |
||||
$output->writeln('For some reason, the directory creation returned an error for '.$destination.$language); |
||||
exit; |
||||
} |
||||
if (is_dir($destination.$origLang)) { |
||||
if (!is_writeable($destination.$origLang)) { |
||||
$output->writeln('Destination directory '.$destination.$origLang.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.'); |
||||
exit; |
||||
} |
||||
$output->writeln('Destination directory '.$destination.$origLang.' already exists. We recommend using an empty directory. Files in this directory will be overwritten if necessary. Sorry.'); |
||||
} elseif (!@mkdir($destination.$origLang)) { |
||||
$output->writeln('For some reason, the directory creation returned an error for '.$destination.$origLang); |
||||
exit; |
||||
} |
||||
// Start working on those files! |
||||
$listFiles = scandir($source); |
||||
$countVars = 0; |
||||
$countTranslatedVars = 0; |
||||
$countWords = 0; |
||||
$countTranslatedWords = 0; |
||||
$fileString = '<?php'."\n"; |
||||
foreach ($listFiles as $file) { |
||||
if (substr($file,-1,1) == '.') { continue; } |
||||
$destFileLines = $fileString; |
||||
$origFileLines = $fileString; |
||||
$partialSourceFile = $langDir.$language.'/'.$file; |
||||
$output->writeln('Source File 2 = '.$partialSourceFile); |
||||
$sourceVars = $this->_getLangVars($source.$file); |
||||
$source2Vars = array(); |
||||
if (is_file($partialSourceFile)) { |
||||
$source2Vars = $this->_getLangVars($partialSourceFile); |
||||
} |
||||
$source2Keys = array_keys($source2Vars); |
||||
foreach ($sourceVars as $var => $val) { |
||||
if (in_array($var, $source2Keys)) { |
||||
$destFileLines .= '$'.$var.'='.$source2Vars[$var]."\n"; |
||||
$origFileLines .= '$'.$var.'='.$val."\n"; |
||||
$countTranslatedVars++; |
||||
$countTranslatedWords += str_word_count($sourceVars[$var]); |
||||
} else { |
||||
$destFileLines .= '$'.$var.'="";'."\n"; |
||||
$origFileLines .= '$'.$var.'='.$val."\n"; |
||||
} |
||||
$countVars++; |
||||
$countWords += str_word_count($sourceVars[$var]); |
||||
} |
||||
$output->writeln('Writing to file '.$destination.$language.'/'.$file); |
||||
$w = file_put_contents($destination.$language.'/'.$file, $destFileLines); |
||||
$w = file_put_contents($destination.$origLang.'/'.$file, $origFileLines); |
||||
} |
||||
$output->writeln('Written translation files for packaging in '.$destination.$language.'.'); |
||||
$output->writeln('Found '.$countVars.' variables, of which '.$countTranslatedVars.' were already translated (and '.($countVars-$countTranslatedVars).' are missing).'); |
||||
$output->writeln('In words, there are '.$countWords.' words in total, of which only '.($countWords - $countTranslatedWords).' still need translating.'); |
||||
if ($tgz) { |
||||
$output->writeln('Compressing as .tar.gz...'); |
||||
chdir($destination); |
||||
exec('tar zcf '.$destination.$language.'.tar.gz '.$language); |
||||
$output->writeln('Written to '.$destination.$language.'.tar.gz'); |
||||
$output->writeln('Removing work directory '.$destination.$language); |
||||
exec('rm -rf '.$destination.$language); |
||||
} |
||||
$output->writeln('Finished exporting language package.'); |
||||
if (!$tgz) { |
||||
$output->writeln('Please make sure you review your work directory for possible cleaning.'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Gets all the variables in a language file as a hash |
||||
* This is a copy of the get_all_language_variable_in_file method in main/admin/sub_language.class.php |
||||
* @param string $file The asbolute path to the file from which to extract variables |
||||
* @return array Named array of variable => translation |
||||
*/ |
||||
private function _getLangVars($file) { |
||||
$res_list = array(); |
||||
if (!is_readable($file)) { |
||||
return $res_list; |
||||
} |
||||
$info_file = file($file); |
||||
foreach ($info_file as $line) { |
||||
if (substr($line, 0, 1) != '$') { |
||||
continue; |
||||
} |
||||
list($var, $val) = preg_split('/=/', $line, 2); |
||||
$var = trim($var); |
||||
$val = trim($val); |
||||
//remove the $ prefix |
||||
$var = substr($var, 1); |
||||
$res_list[$var] = $val; |
||||
} |
||||
return $res_list; |
||||
} |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
<?php |
||||
|
||||
// autoload_psr4.php @generated by Composer |
||||
|
||||
$vendorDir = dirname(dirname(__FILE__)); |
||||
$baseDir = dirname($vendorDir); |
||||
|
||||
return array( |
||||
); |
||||
@ -0,0 +1,10 @@ |
||||
/.settings |
||||
/.project |
||||
/.buildpath |
||||
/composer.phar |
||||
/vendor |
||||
/nbproject |
||||
phpunit.xml |
||||
.vagrant |
||||
Vagrantfile |
||||
.idea |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@ |
||||
composer.lock |
||||
vendor |
||||
@ -0,0 +1,3 @@ |
||||
vendor/ |
||||
composer.lock |
||||
composer.phar |
||||
@ -0,0 +1,3 @@ |
||||
vendor/ |
||||
build/ |
||||
phpunit.xml |
||||
@ -0,0 +1 @@ |
||||
vendor/ |
||||
@ -0,0 +1,9 @@ |
||||
build/ |
||||
logs/ |
||||
reports/ |
||||
dist/ |
||||
tests/Doctrine/Tests/Common/Proxy/generated/ |
||||
vendor/ |
||||
.idea |
||||
doctrine-common-*.tar |
||||
doctrine-common-*.tar.gz |
||||
@ -0,0 +1,3 @@ |
||||
[submodule "lib/vendor/doctrine-build-common"] |
||||
path = lib/vendor/doctrine-build-common |
||||
url = git://github.com/doctrine/doctrine-build-common.git |
||||
@ -0,0 +1,3 @@ |
||||
Doctrine/Tests/Proxies/ |
||||
Doctrine/Tests/ORM/Proxy/generated/ |
||||
Doctrine/Tests/ORM/Tools/Export/export |
||||
@ -0,0 +1,8 @@ |
||||
build.properties |
||||
build/ |
||||
logs/ |
||||
reports/ |
||||
dist/ |
||||
tests/phpunit.xml |
||||
vendor/ |
||||
composer.lock |
||||
@ -0,0 +1,2 @@ |
||||
composer.lock |
||||
vendor |
||||
@ -0,0 +1 @@ |
||||
configdoc/usage.xml -crlf |
||||
@ -0,0 +1,24 @@ |
||||
tags |
||||
conf/ |
||||
test-settings.php |
||||
config-schema.php |
||||
library/HTMLPurifier/DefinitionCache/Serializer/*/ |
||||
library/standalone/ |
||||
library/HTMLPurifier.standalone.php |
||||
library/HTMLPurifier*.tgz |
||||
library/package*.xml |
||||
smoketests/test-schema.html |
||||
configdoc/*.html |
||||
configdoc/configdoc.xml |
||||
docs/doxygen* |
||||
*.phpt.diff |
||||
*.phpt.exp |
||||
*.phpt.log |
||||
*.phpt.out |
||||
*.phpt.php |
||||
*.phpt.skip.php |
||||
*.htmlt.ini |
||||
*.patch |
||||
/*.php |
||||
vendor |
||||
composer.lock |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue