public function indexAction()
 {
     $config = Tools::getConfig();
     $connection = Tools::getConnection();
     $tables = array();
     $result = $connection->query("SHOW TABLES");
     $result->setFetchMode(Phalcon\Db::FETCH_NUM);
     while ($table = $result->fetchArray($result)) {
         $tables[$table[0]] = $table[0];
     }
     $this->view->setVar('tables', $tables);
     $this->view->setVar('databaseName', $config->database->name);
 }
 public function runAction()
 {
     if ($this->request->isPost()) {
         $force = $this->request->getPost('force', 'int');
         try {
             Migrations::run(array('config' => Tools::getConfig(), 'directory' => null, 'tableName' => 'all', 'migrationsDir' => $this->migrationsDir, 'force' => $force));
             $this->flash->success('The migration was executed successfully.');
         } catch (BuilderException $e) {
             $this->flash->error($e->getMessage());
         }
     }
     $this->_prepareVersions();
 }
 public function saveAction()
 {
     if ($this->request->isPost()) {
         $fileName = $this->request->getPost('name', 'string');
         $fileName = str_replace('..', '', $fileName);
         $controllersDir = Tools::getConfig()->application->controllersDir;
         if (!file_exists($controllersDir . '/' . $fileName)) {
             $this->flash->error('Controller could not be found');
             return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
         }
         if (!is_writable($controllersDir . '/' . $fileName)) {
             $this->flash->error('Controller file does not has write access');
             return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
         }
         file_put_contents($controllersDir . '/' . $fileName, $this->request->getPost('code'));
         $this->flash->success('The controller "' . $fileName . '" was saved successfully');
     }
     return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list'));
 }
示例#4
0
 protected function _listTables($all = false)
 {
     $config = Tools::getConfig();
     $connection = Tools::getConnection();
     if ($all) {
         $tables = array('all' => 'All');
     } else {
         $tables = array();
     }
     $dbTables = $connection->listTables();
     foreach ($dbTables as $dbTable) {
         $tables[$dbTable] = $dbTable;
     }
     $this->view->tables = $tables;
     if ($config->database->adapter != 'Sqlite') {
         $this->view->databaseName = $config->database->dbname;
     } else {
         $this->view->databaseName = null;
     }
 }
 /**
  * Initialize system dirs
  *
  * @return $this
  */
 protected function initDirs()
 {
     $config = Tools::getConfig()->offsetGet('application');
     $dirs = array('modelsDir', 'controllersDir', 'migrationsDir');
     $this->path->setRootPath(dirname(getcwd()));
     $projectPath = $this->path->getRootPAth();
     foreach ($dirs as $dirName) {
         if (isset($config[$dirName]) && $config[$dirName]) {
             if ($this->isAbsolutePath($config[$dirName])) {
                 $path = $config[$dirName];
             } else {
                 $path = $projectPath . $config[$dirName];
             }
             $path = rtrim($path, '\\/') . DIRECTORY_SEPARATOR;
             if (file_exists($path)) {
                 $this->{$dirName} = $path;
             }
         }
     }
     return $this;
 }
 public function indexAction()
 {
     $this->view->setVar('posibleConfig', $this->_posibleConfig);
     $this->view->setVar('settings', Tools::getConfig());
 }