Exemple #1
0
 /** Генерация тега INPUT для фильтра. Значение будет подставлено если оно проходит валидацию */
 public function asInput($attr = null, $value = null)
 {
     if (is_null($value)) {
         $value = $this->getCleanValue();
     }
     return HTML::Input($this->getColumn(), $value, $attr);
 }
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
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(HTML::Tag('info', 'Обновляю список команд приложения'));
     $this->collectTasks();
     $this->filterTasks();
     $this->saveList();
 }
Exemple #4
0
 public function render()
 {
     $opt = null;
     if (is_array($this->options)) {
         $opt = HTML::OptionListing($this->options, $this->getValue(), null, (bool) $this->ignore_keys);
     }
     return HTML::Select($opt, $this->getName(), null, $this->getAttributes(false), $this->getPlaceholder());
 }
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');
     $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 #7
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 #8
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 #9
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 #10
0
 public function render()
 {
     return HTML::Tag($this->tag, $this->getLabel(), $this->getAttributes(false));
 }
Exemple #11
0
 public function render()
 {
     return HTML::CheckboxListing($this->options, $this->getName(), $this->getTaintedValue(), $this->separator, $this->ignore_keys);
 }
Exemple #12
0
 /** Атрибуты тега формы */
 public function getFormAttributes($attr = null)
 {
     $a = HTML::AttrConvert($attr ?: $this->form_attributes);
     if ($this->name) {
         $a['id'] = 'form-' . $this->name;
     }
     return $a;
 }
Exemple #13
0
 public function render()
 {
     return HTML::Password($this->getName(), $this->getTaintedValue(), $this->getAttributes());
 }
Exemple #14
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 #15
0
 public function render($with_label = true)
 {
     return HTML::Checkbox($this->getName(), $this->getIsChecked(), $this->getCheckboxValue(), $this->getAttributes(false), $with_label ? $this->getLabel() : null);
 }
Exemple #16
0
 function testTextarea()
 {
     $t = HTML::Textarea('hello', 'Hi');
     $this->assertEquals('<textarea name="hello">Hi</textarea>', $t, 'Пустое поле');
     $t = HTML::Textarea('hello', 'bla bla', 'myclass', 10, 20);
     $this->assertSelectCount('textarea[class=myclass]', true, $t, 'Атрибуты');
     $this->assertSelectCount('textarea[rows=10]', true, $t, 'Ряды');
     $this->assertSelectCount('textarea[cols=20]', true, $t, 'Столбцы');
 }
Exemple #17
0
 public function render()
 {
     return HTML::Textarea($this->getName(), $this->getTaintedValue(), $this->getAttributes(), $this->getRows(), $this->getCols());
 }
Exemple #18
0
 public function render()
 {
     return HTML::Hidden($this->getName(), $this->getTaintedValue(), $this->getAttributes(false));
 }
Exemple #19
0
 /** Варианты выбора сортировки в виде опций для SELECT */
 public function getOrderByAsSelectOptions($selected = null)
 {
     if (is_null($selected)) {
         $o = $this->getOrderBy();
         $selected = $o ? $o->asUrlParameter() : null;
     }
     return HTML::OptionListing($this->getOrderByOptionsForSelect(), $selected);
 }
Exemple #20
0
 /** Массив атрибутов для HTML тега инпута */
 public function getAttributes($include_placeholder = true)
 {
     $arr = array('id' => $this->getId());
     if ($include_placeholder) {
         $arr['placeholder'] = $this->getPlaceholder();
     }
     return HTML::AttrConvert($this->attributes, $arr);
 }
Exemple #21
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;
 }