protected function execute(InputInterface $input, OutputInterface $output) { if (parent::execute($input, $output)) { $this->loadOCConfig(); $properties = array('string $id', 'string $template', 'array $children', 'array $data', 'string $output'); // TODO: get all library classes as well, maybe extract from registry somehow... $searchLine = "abstract class Controller {"; $pathToController = "engine/controller.php"; $catalogModels = $this->getModels(\DIR_APPLICATION); $adminModels = $this->getModels(str_ireplace("catalog/", "admin/", \DIR_APPLICATION)); $textToInsert = array_unique(array_merge($properties, $catalogModels, $adminModels)); //get line number where start Controller description $fp = fopen(\DIR_SYSTEM . $pathToController, 'r'); $lineNumber = $this->getLineOfFile($fp, $searchLine); fclose($fp); //regenerate Controller text with properties $file = new \SplFileObject(\DIR_SYSTEM . $pathToController); $file->seek($lineNumber); $tempFile = sprintf("<?php %s \t/**%s", PHP_EOL, PHP_EOL); foreach ($textToInsert as $val) { $tempFile .= sprintf("\t* @property %s%s", $val, PHP_EOL); } $tempFile .= sprintf("\t**/%s%s%s", PHP_EOL, $searchLine, PHP_EOL); while (!$file->eof()) { $tempFile .= $file->fgets(); } //write Controller $fp = fopen(\DIR_SYSTEM . $pathToController, 'w'); fwrite($fp, $tempFile); fclose($fp); } }
protected function execute(InputInterface $input, OutputInterface $output) { if (parent::execute($input, $output)) { if (!$input->getOption("catalog")) { chdir('admin'); } foreach ($input->getArgument("args") as $arg) { $pair = explode("=", $arg); if (count($pair) === 2) { if ($input->getOption("post")) { $_POST[$pair[0]] = $pair[1]; } else { $_GET[$pair[0]] = $pair[1]; } } } ob_start(); require_once $this->getOCDirectory() . DIRECTORY_SEPARATOR . "index.php"; ob_end_clean(); $registry->set('is_cli', true); $this->registry = $registry; $controller = new \Front($registry); $controller->dispatch(new \Action($input->getArgument("route")), new \Action('error/not_found')); } }
protected function execute(InputInterface $input, OutputInterface $output) { if (parent::execute($input, $output)) { $file_system_helper = new FileSystem(); $this->loadOCConfig(); $this->backup_folder = $this->getOCDirectory() . DIRECTORY_SEPARATOR . ".backup_tmp/"; $za = new \ZipArchive(); if ($za->open("ocok_backup_" . date("Y_m_d_H_i") . ".zip", \ZipArchive::OVERWRITE)) { if (is_dir($this->backup_folder)) { $file_system_helper->rmdir($this->backup_folder); } mkdir($this->backup_folder); $image_path = DIR_IMAGE; if ($this->isVersion('2')) { $image_path .= 'catalog/'; } elseif ($this->isVersion('1')) { $image_path .= 'data/'; } if ($input->getOption("images")) { $files = $file_system_helper->getFilesRecursively($image_path); foreach ($files as $file) { if ($file->isFile() && $file->isReadable() && $file_system_helper->isImage($file->getPathname())) { // remove basefolder prefix from path if (substr($file->getPathname(), 0, strlen($this->getOCDirectory())) == $this->getOCDirectory()) { $path = substr($file->getPathname(), strlen($this->getOCDirectory())); } $za->addFile($file->getPathname(), substr($path, 1)); } } } if ($input->getOption("database")) { $dumper = new Mysqldump(DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_HOSTNAME, 'mysql', array('add-drop-table' => true, 'add-drop-database' => true, 'databases' => true)); $dumper->start($this->backup_folder . $this->backup_db); $za->addFile($this->backup_folder . $this->backup_db, $this->backup_db); } $za->close(); $file_system_helper->rmdir($this->backup_folder); } } }