Exemple #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(HTML::Tag('info', 'Обновляю список команд приложения'));
     $this->collectTasks();
     $this->filterTasks();
     $this->saveList();
 }
Exemple #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = 'Schema\\' . $input->getArgument('schema');
     $class = 'ORM\\' . $input->getArgument('class');
     $force = $input->getOption('force');
     $output->writeln(HTML::Tag('info', sprintf('Генерирую класс модели %s по схеме %s...', $class, $schema)));
     //Определяем неймспейс
     $ns = false;
     $path = DIR_APP;
     $a = explode('\\', trim(str_replace('/', '\\', $class), '\\'));
     $classname = array_pop($a);
     if (count($a)) {
         $ns = join('\\', $a);
         $path .= DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $a);
     }
     if (!class_exists($schema)) {
         $output->writeln(HTML::Tag('error', sprintf('Схема %s не существует!', $schema)));
         return;
     }
     /** @var $s \CMSx\DB\Schema */
     $s = new $schema(X::DB());
     $code = $s->buildModel($classname, $ns);
     if (!is_dir($path)) {
         mkdir($path, 0750, true);
     }
     $file = $path . DIRECTORY_SEPARATOR . $classname . '.php';
     if (!is_file($file) || $force) {
         file_put_contents($file, $code);
         $output->writeln(HTML::Tag('info', sprintf('Файл модели %s создан: %s', $classname, $file)));
     } else {
         $output->writeln(HTML::Tag('error', sprintf('Файл модели %s уже существует! Используйте опцию -f для перезаписи', $file)));
     }
 }
Exemple #3
0
Fichier : Drop.php Projet : cmsx/fw
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = 'Schema\\' . $input->getArgument('schema');
     $output->writeln(HTML::Tag('info', 'Сбрасываем таблицу схемы ' . $schema));
     if (!class_exists($schema)) {
         $output->writeln(HTML::Tag('error', sprintf('Схема %s не существует!', $schema)));
         return;
     }
     /** @var $s \CMSx\DB\Schema */
     $s = new $schema(X::DB());
     X::DB()->drop($s->getTable())->execute();
     $output->writeln(HTML::Tag('info', 'Таблица ' . $s->getTable() . ' сброшена'));
 }
Exemple #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = 'Schema\\' . $input->getArgument('schema');
     $output->writeln(HTML::Tag('info', 'Обновляем структуру таблицы по схеме ' . $schema));
     if (!class_exists($schema)) {
         $output->writeln(HTML::Tag('error', sprintf('Схема %s не существует!', $schema)));
         return;
     }
     /** @var $s \CMSx\DB\Schema */
     $s = new $schema(X::DB());
     $s->updateTable();
     $output->writeln(HTML::Tag('info', sprintf('Таблица %s%s обновлена', X::DB()->getPrefix(), $s->getTable())));
 }
Exemple #5
0
Fichier : Fill.php Projet : cmsx/fw
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = 'Schema\\' . $input->getArgument('schema');
     $output->writeln(HTML::Tag('info', 'Загружаем данные по схеме ' . $schema));
     if (!class_exists($schema)) {
         $output->writeln(HTML::Tag('error', sprintf('Схема %s не существует!', $schema)));
         return;
     }
     /** @var $s \CMSx\DB\Schema */
     $s = new $schema(X::DB());
     $s->fillTable();
     $output->writeln(HTML::Tag('info', 'Данные загружены'));
 }
Exemple #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = 'Schema\\' . $input->getArgument('schema');
     $drop = (bool) $input->getOption('drop');
     $skip = $input->getOption('skip-content');
     $output->writeln(HTML::Tag('info', 'Создаем таблицу по схеме ' . $schema));
     if (!class_exists($schema)) {
         $output->writeln(HTML::Tag('error', sprintf('Схема %s не существует!', $schema)));
         return;
     }
     /** @var $s \CMSx\DB\Schema */
     $s = new $schema(X::DB());
     $s->createTable($drop);
     $output->writeln(HTML::Tag('info', sprintf('Таблица %s%s создана', X::DB()->getPrefix(), $s->getTable())));
     if (!$skip) {
         $s->fillTable();
         $output->writeln(HTML::Tag('info', 'Начальные данные загружены'));
     }
 }
Exemple #7
0
 protected function recursiveCopy($source, $dest, InputInterface $input, OutputInterface $output)
 {
     $force = $input->getOption('force');
     $details = $input->getOption('details');
     $dummy = $input->getOption('dummy');
     $path = rtrim($source, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '{,.}*';
     $dest = rtrim($dest, DIRECTORY_SEPARATOR);
     $arr = glob($path, GLOB_BRACE);
     foreach ($arr as $f) {
         $a = explode(DIRECTORY_SEPARATOR, $f);
         $fn = array_pop($a);
         $p = $dest . DIRECTORY_SEPARATOR . $fn;
         if ($fn == '.' || $fn == '..' || !$dummy && false !== strpos(strtolower($f), 'dummy')) {
             continue;
         }
         if (is_dir($f)) {
             if (!is_dir($p)) {
                 if ($details) {
                     $output->writeln('Создаю директорию: "' . $p . '"');
                 }
                 mkdir($p, 0750, true);
             }
             if ($details) {
                 $output->writeln(HTML::Tag('info', 'Копирую файлы из "' . $f . '"'));
             }
             $this->recursiveCopy($f, $p, $input, $output);
         } else {
             if (!$force && is_file($p)) {
                 if ($details) {
                     $output->writeln(sprintf('Файл "%s" пропущен', $f));
                 }
                 continue;
             }
             if ($details) {
                 $output->writeln(sprintf('"%s" => "%s"', $f, $p));
             }
             copy($f, $p);
         }
     }
 }
Exemple #8
0
 /**
  * Отрисовка канонического адреса страницы.
  * Домен должен быть указан при вызове, или заранее через setDomain
  * $domain - домен с http://
  */
 public function renderCanonical($domain = null)
 {
     if (is_null($domain)) {
         $domain = $this->getDomain();
     }
     if (!$domain || !($c = $this->getCanonical($domain))) {
         return false;
     }
     $attr = array('rel' => 'canonical', 'href' => $c);
     return HTML::Tag('link', null, $attr, true) . "\n";
 }
Exemple #9
0
 /** Обработка ошибок */
 protected function handleException(\Exception $e)
 {
     $p = $this->getErrorPage();
     if ($e instanceof \CMSx\Controller\Exception) {
         $h = $e->getHTTPHeader();
         if ($e->isRedirect()) {
             //Для редиректа страница ошибки не выводится
             header('Location: ' . $e->getRedirectUrl());
             header($h);
             return false;
         }
         if ($h) {
             header($h);
         }
         $p->set('title', $e->getHumanMessage());
     } else {
         $p->set('title', 'Ошибка!');
     }
     if ($this->isDebugMode()) {
         $p->setText(HTML::Tag('h3', $e->getMessage()) . "\n" . HTML::Tag('p', nl2br($e->getTraceAsString())));
     }
     $p->set('exception', $e);
     return $p;
 }
Exemple #10
0
 public function render()
 {
     return HTML::Tag($this->tag, $this->getLabel(), $this->getAttributes(false));
 }