/** * Method that regenerates the translations * @GET * @param $locale string * @route /admin/translations/{locale} * @visible false * @return string HTML */ public function getTranslations($locale) { //Default locale if (null === $locale) { $locale = $this->config->get("default_language"); } //Generating the templates translations $translations = $this->tpl->regenerateTemplates(); $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; //xgettext localizations $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); $translations = array_merge($translations, GeneratorService::findTranslations(CORE_DIR, $locale)); $translations = array_merge($translations, GeneratorService::findTranslations(CACHE_DIR, $locale)); $translations[] = "msgfmt {$locale_path}translations.po -o {$locale_path}translations.mo"; $translations[] = shell_exec("export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt {$locale_path}translations.po -o {$locale_path}translations.mo"); return $this->render("translations.html.twig", array("translations" => $translations)); }
} public function infoLog($msg) { if ($this->verbosity) { $this->log->writeln($msg); } } } } if (!isset($console)) { $console = new Application(); } $console->register('psfs:create:module')->setDefinition(array(new InputArgument('module', InputArgument::OPTIONAL, 'Nombre del módulo a crear')))->setDescription('Comando de creación de módulos psfs')->setCode(function (InputInterface $input, OutputInterface $output) { $module = $input->getArgument('module'); $helper = new QuestionHelper(); $log = new CLog($output, $output->isVerbose()); try { //En caso de no tener nombre del módulo lo solicitamos al usuario if (empty($module)) { $question = new Question("Introduce el nombre del módulo a crear:\n"); $module = $helper->ask($input, $output, $question); } //Sólo si tenemos nombre del módulo if (!empty($module)) { \PSFS\services\GeneratorService::getInstance()->createStructureModule($module, $log); } } catch (\Exception $e) { $output->writeln($e->getMessage()); $output->writeln($e->getTraceAsString()); } });
/** * Función que copia un recurso directamente en el DocumentRoot * @param string $path * @param string $dest * @param bool|FALSE $force * * @return string * @throws ConfigException */ public static function resource($path, $dest, $force = false) { $debug = Config::getInstance()->getDebugMode(); $domains = Template::getDomains(true); $filename_path = self::extractPathname($path, $domains); GeneratorService::copyResources($dest, $force, $filename_path, $debug); return ''; }
if (!isset($console)) { $console = new Application(); } $console->register('psfs:create:root')->setDefinition(array(new InputArgument('path', InputArgument::OPTIONAL, 'Path en el que crear el Document Root')))->setDescription('Comando de creación del Document Root del projecto')->setCode(function (InputInterface $input, OutputInterface $output) { // Creates the html path $path = $input->getArgument('path'); if (empty($path)) { $path = WEB_DIR; } \PSFS\base\config\Config::createDir($path); $paths = array("js", "css", "img", "media", "font"); foreach ($paths as $htmlPath) { \PSFS\base\config\Config::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); } // Generates the root needed files $files = ['_' => '_.php', 'browserconfig' => 'browserconfig.xml', 'crossdomain' => 'crossdomain.xml', 'humans' => 'humans.txt', 'robots' => 'robots.txt']; foreach ($files as $templates => $filename) { $text = \PSFS\base\Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { $output->writeln('Can\\t create the file ' . $filename); } else { $output->writeln($filename . ' created successfully'); } } //Export base locale translations if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { \PSFS\base\config\Config::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); } $output->writeln("Document root generado en " . $path); });