From: Steve Sutton Date: Sun, 12 Jul 2015 19:06:43 +0000 (-0400) Subject: Updates for plugin X-Git-Tag: v0.0.2^2~42 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5e31dd7cb0b7e6a5af123cd30426d242b46db4eb;p=WP-Plugins%2Fglm-wp-importer.git Updates for plugin Check that the settings for connection to db is setup. --- diff --git a/controllers/Import.php b/controllers/Import.php index 064a8a4..b72e8b8 100644 --- a/controllers/Import.php +++ b/controllers/Import.php @@ -88,14 +88,54 @@ echo ''; } + private function _checkRequiredOptions() + { + $errors = array(); + if (!$this->_options['site_url']) { + $errors[] = 'Site URL'; + } + if (!$this->_options['db_host']) { + $errors[] = 'Database Host'; + } + if (!$this->_options['db_name']) { + $errors[] = 'Database Name'; + } + if (!$this->_options['db_user']) { + $errors[] = 'Database Usecr'; + } + if (!$this->_options['toolbox_schema']) { + $errors[] = 'Toolbox Schema'; + } + if (!$this->_options['toolbox_page_table']) { + $errors[] = 'Toolbox Page Table'; + } + if (!$this->_options['toolbox_paragraphs_table']) { + $errors[] = 'Toolbox Paragraph Table'; + } + if (!$this->_options['toolbox_files_table']) { + $errors[] = 'Toolbox Files Table'; + } + return $errors; + } + private function _greet() { - echo '

Hello there person!

'; - $this->_connect(); - $sql = "SELECT * FROM toolbox.pages"; - $data = $this->_dbh->query($sql)->fetchAll(); - printf('

Found %d Pages

', count($data)); - echo 'Start the Import Now'; + // Verify that everything is setup + $checkErrors = $this->_checkRequiredOptions(); + echo '

Confirming Settings...

'; + if (isset($checkErrors) && is_array($checkErrors) && !empty($checkErrors)) { + printf("
Please update empty GLM Import Settings:\n%s
", + 'options-general.php?page=glmwpimporter', + implode("\n", $checkErrors) + ); + } else { + echo '

All Set!

'; + $this->_connect(); + $sql = "SELECT * FROM toolbox.pages"; + $data = $this->_dbh->query($sql)->fetchAll(); + printf('

Found %d Pages

', count($data)); + echo 'Start the Import Now'; + } } private function _displayImage($data, $alignment) @@ -246,7 +286,7 @@ switch($step) { case 0: $this->_greet(); - $this->_readOptions(); + //$this->_readOptions(); break; case 1: $this->_import();