From 7c70d813f93570ec558876fce3d5b6e86e7f893c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 8 Jul 2015 16:52:39 -0400 Subject: [PATCH 1/1] Initial import of the plugin --- NOTES.md | 12 +++ README.md | 14 +++ controllers/Admin.php | 200 +++++++++++++++++++++++++++++++++++++++++ controllers/Import.php | 38 ++++++++ index.php | 27 ++++++ views/deniedAccess.php | 1 + views/optionsPage.php | 14 +++ views/text.php | 2 + 8 files changed, 308 insertions(+) create mode 100644 NOTES.md create mode 100644 README.md create mode 100644 controllers/Admin.php create mode 100644 controllers/Import.php create mode 100644 index.php create mode 100644 views/deniedAccess.php create mode 100644 views/optionsPage.php create mode 100644 views/text.php diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..a3e1c6b --- /dev/null +++ b/NOTES.md @@ -0,0 +1,12 @@ +Resources for the image importing: + +Plugins that work well with importing the images into the Media Library. +Currently the Html Import 2 Plugin does a nice job of parsing out a list of images and files from the page content (post and pages) +and fetches a list of images and files that then is added to the Media Library. Pages or Post are then updated with the media information. + +I'm planning on using the same thing here. + +1. Store db options in settings. +2. Fetch all pages from the database and add pages. +3. Fetch list of all images, files and import them into Media Library +4. Update all pages with new references of the images. diff --git a/README.md b/README.md new file mode 100644 index 0000000..243114f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Gaslight Media Word Press Importer Plugin +The objective of this plugin is to fetch all toolbox page content from the database. This will also fetch all images and files from the pages and import them properly into the Wordpress Pages. + +## +First you'll need to setup the Database Options. GLM WP Importer +1. Database Host: The database host name +2. Database Name: The database name +3. Database User: The database user name +4. Database Password: The database password (if set) +5. Toolbox Schema: The schema used for the Toolbox (blank for no schema or public) +6. Toolbox Page Table: Table name of the Toolbox Pages +7. Toolbox Paragraph Table: Table name of the Toolbox Paragraphs +8. CKEditor Schema: Schema name for the CKEditor +9. CKEditor Images Table: Table name for the CKEditor Images diff --git a/controllers/Admin.php b/controllers/Admin.php new file mode 100644 index 0000000..4071142 --- /dev/null +++ b/controllers/Admin.php @@ -0,0 +1,200 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.0.1) + * @link <> + */ + +/** + * GlmWPImporter_Admin_Controller + * + * Main Controller for the Gaslight WP Importer Plugin + * + * @category Importer + * @package GLM WP Importer + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.0.1) + * @link <> + */ +class GlmWPImporter_Admin_Controller +{ + public $path; + + public function __construct($path) + { + $this->path = $path; + add_action('admin_menu', array($this, 'glmwpimporter_add_admin_menu')); + add_action('admin_init', array($this, 'glmwpimporter_settings_init')); + + } + + static public function activate_plugin() + { + } + + static public function deactivate_plugin() + { + } + + + static public function glmwpimporter_uninstall() + { + delete_option(GLM_WP_IMPORT_SETTINGS); + } + + public function glmwpimporter_add_admin_menu() + { + add_menu_page( + 'Gaslight WP Importer Setup', + 'GLM WP Importer', + GLM_WP_IMPORT_CAPABILITY, + 'glmwpimporter', + array($this, 'glmwpimporter_options_page'), + 'dashicons-download' + ); + } + + public function glmwpimporter_settings_exist() + { + if (false == get_option(GLM_WP_IMPORT_SETTINGS)) { + add_option(GLM_WP_IMPORT_SETTINGS); + } + } + + public function glmwpimporter_settings_init() + { + register_setting(GLM_WP_IMPORT_OPTION_GROUP, GLM_WP_IMPORT_SETTINGS); + add_filter( + 'option_page_capability_' . GLM_WP_IMPORT_OPTION_GROUP, + array($this, 'glmwpimporter_option_page_capability') + ); + + add_settings_section( + 'glmwpimporter_' . GLM_WP_IMPORT_OPTION_GROUP . '_section', + __('Edit your Import Setting', 'wordpress'), + array($this, 'glmwpimporter_settings_section_callback'), + GLM_WP_IMPORT_OPTION_GROUP + ); + + $fieldNames = array( + array( + 'name' => 'db_host', + 'label' => 'Database Host', + 'type' => 'text' + ), + array( + 'name' => 'db_name', + 'label' => 'Database Name', + 'type' => 'text' + ), + array( + 'name' => 'db_user', + 'label' => 'Database User', + 'type' => 'text' + ), + array( + 'name' => 'db_password', + 'label' => 'Database Password', + 'type' => 'text' + ), + array( + 'name' => 'toolbox_schema', + 'label' => 'Toolbox Schema', + 'type' => 'text' + ), + array( + 'name' => 'toolbox_page_table', + 'label' => 'Toolbox Page Table', + 'type' => 'text' + ), + array( + 'name' => 'toolbox_paragraphs_table', + 'label' => 'Toolbox Paragraph Table', + 'type' => 'text' + ), + array( + 'name' => 'toolbox_files_table', + 'label' => 'Toolbox Files Table', + 'type' => 'text' + ), + array( + 'name' => 'ckeditor_schema', + 'label' => 'CKEditor Schema', + 'type' => 'text' + ), + array( + 'name' => 'ckeditor_images_table', + 'label' => 'CKEditor Images Table', + 'type' => 'text' + ), + ); + + foreach ($fieldNames as $field) { + $this->glmwpimporterAddSettingTextField( + $field['name'], + $field['label'], + $field['type'] + ); + } + } + + public function glmwpimporterAddSettingTextField($name, $label, $type) + { + switch ($type) { + case 'text': + $callback = 'glmwpimporterRenderText'; + break; + default: + return false; + break; + } + add_settings_field( + $name, + __($label, 'wordpress'), + array($this, $callback), + GLM_WP_IMPORT_OPTION_GROUP, + 'glmwpimporter_' . GLM_WP_IMPORT_OPTION_GROUP. '_section', + $name + ); + } + + public function glmwpimporterRenderText($fieldName) + { + static $options; + if (!$options) { + $options = get_option(GLM_WP_IMPORT_SETTINGS); + } + include $this->path . 'views/text.php'; + } + + public function glmwpimporter_settings_section_callback() + { + echo __('Database Options', 'wordpress'); + } + + public function glmwpimporter_option_page_capability($capability) + { + return GLM_WP_IMPORT_CAPABILITY; + } + + public function glmwpimporter_options_page() + { + if (current_user_can(GLM_WP_IMPORT_CAPABILITY)) { + include $this->path . 'views/optionsPage.php'; + } else { + include $this->path . 'views/deniedAccess.php'; + } + } + +} diff --git a/controllers/Import.php b/controllers/Import.php new file mode 100644 index 0000000..c771250 --- /dev/null +++ b/controllers/Import.php @@ -0,0 +1,38 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.0.1) + * @link <> + */ + +/** + * GlmWPImporter_Import_Controller + * + * Main Controller for the Gaslight WP Importer Plugin + * + * @category Importer + * @package GLM WP Importer + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.0.1) + * @link <> + */ +class GlmWPImporter_Import_Controller +{ + public $path; + + public function __construct($path) + { + $this->path = $path; + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..690c9d3 --- /dev/null +++ b/index.php @@ -0,0 +1,27 @@ +

You do not have permission to edit Gaslight Media WP Importer Settings

diff --git a/views/optionsPage.php b/views/optionsPage.php new file mode 100644 index 0000000..f3bfda6 --- /dev/null +++ b/views/optionsPage.php @@ -0,0 +1,14 @@ +
+
+

Gaslight WP Importer Settings

+ +
+
+ + +
+
diff --git a/views/text.php b/views/text.php new file mode 100644 index 0000000..e62126b --- /dev/null +++ b/views/text.php @@ -0,0 +1,2 @@ +"> -- 2.17.1