--- /dev/null
+<?php
+
+/**
+ * Admin.php
+ *
+ * PHP version 5.3
+ *
+ * @category Importer
+ * @package GLM WP Importer
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @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 <steve@gaslightmedia.com>
+ * @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';
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Plugin Name: GLM WP Importer
+ * Description: Import Gaslight Media Toolbox Content Into WordPress
+ * Version: 0.0.1
+ * Author: Steve Sutton
+ * Author URI: http://www.gaslightmedia.com
+ * License: All right reserved
+ */
+define('GLM_WP_IMPORT_SETTINGS', 'glm_wp_import_settings');
+define('GLM_WP_IMPORT_CAPABILITY', 'manage_options');
+define('GLM_WP_IMPORT_OPTION_GROUP', 'glmwp_import_group');
+
+if (is_admin()) {
+ require_once 'controllers/Admin.php';
+ require_once 'controllers/Import.php';
+ register_activation_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'activate_plugin'));
+ register_deactivation_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'deactivate_plugin'));
+ register_uninstall_hook(__FILE__, array('GlmWPImporter_Admin_Controller', 'uninstall'));
+
+
+ if ($action = filter_var($_REQUEST['glm_action'], FILTER_SANITIZE_STRING)) {
+ $importController = new GlmWPImporter_Import_Controller(plugin_dir_path(__FILE__));
+ } else {
+ $adminController = new GlmWPImporter_Admin_Controller(plugin_dir_path(__FILE__));
+ }
+}