/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $common_questions = $project->getCommonQuestions($input->getOption('locale')); if (count($common_questions)) { $table = new Table($output); $table->setHeaders(['Question', 'Book', 'Page', 'Position']); foreach ($common_questions as $common_question) { $table->addRow([$common_question['question'], $common_question['book'], $common_question['page'], $common_question['position']]); } $table->render(); $output->writeln(''); if (count($common_questions) === 1) { $output->writeln('1 question found'); } else { $output->writeln(count($common_questions) . ' questions found'); } } else { $output->writeln('0 questions found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * Build index.html page * * @param InputInterface $input * @param OutputInterface $output * @param Project $project * @param string $target_path * @param Theme $theme * @param string $locale * @return bool * @throws Exception * @throws \SmartyException */ public function buildLandingPage(InputInterface $input, OutputInterface $output, Project $project, $target_path, Theme $theme, $locale) { if ($locale === $project->getDefaultLocale()) { $index_path = "{$target_path}/index.html"; } else { $index_path = "{$target_path}/{$locale}/index.html"; Shade::createDir("{$target_path}/{$locale}", function ($path) use(&$output) { $output->writeln("Directory '{$path}' created"); }); Shade::createDir("{$target_path}/assets/images/{$locale}", function ($path) use(&$output) { $output->writeln("Directory '{$path}' created"); }); } $this->smarty->assign(['common_questions' => $project->getCommonQuestions(), 'page_level' => 0, 'current_section' => 'home']); Shade::writeFile($index_path, $this->smarty->fetch('index.tpl'), function ($path) use(&$output) { $output->writeln("File '{$path}' created"); }); return true; }