--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Custom Fields Form Management
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Management Fields data abstract
+require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomFields.php';
+
+
+/*
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_customFieldsFront extends GlmDataFieldsCustomFields
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for data class
+ parent::__construct(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $actionData
+ *
+ * @return No return is expected from this model. Content should be output then wp_die();
+ */
+ public function modelAction ($actionData = false)
+ {
+
+ switch($_REQUEST['option']) {
+
+ case 'displayForm':
+
+ $actionData = array(
+ 'request' => array(
+ 'option' => $_REQUEST['option'],
+ 'fid' => $_REQUEST['fid'],
+ 'record-id' => $_REQUEST['recordId'],
+ 'parent-form-id' => $_REQUEST['parentFormId'],
+ 'form-data' => $_REQUEST['formData'],
+ )
+ );
+
+ // Call the GlmMembersFront_customFields_formDisplay to let it do the work
+ require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_PATH.'/models/front/customFields/formDisplay.php';
+ $FormDisplay = new GlmMembersFront_customFields_formDisplay($this->wpdb, $this->config);
+ $res = $FormDisplay->modelAction($actionData);
+
+ $html = $this->generateHTML($res['data'], $res['view']);
+
+ echo $html;
+ wp_die();
+
+ break;
+
+ default:
+ break;
+ }
+
+ wp_die();
+ }
+
+
+ /**
+ * Merge template and data to produce HTML
+ *
+ * Checks the theme's view directories and the view directories for
+ * this plugin for a matching view file.
+ *
+ * Note that $viewFile needs to have the proper view directory path
+ * includes. (i.e. "/views/front/registrations/summary.html")
+ *
+ * @param $data array Array of data to merge with the template
+ * @param $view string Path added to
+ *
+ * @access public
+ * @return void
+ */
+ function generateHTML($data, $viewFile)
+ {
+
+ // If a view file is specified
+ if ($viewFile) {
+
+ // Get the specified view file - check theme first
+ $viewPath = GLM_MEMBERS_PLUGIN_CURRENT_THEME_DIR."/views";
+ $viewPath2 = GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_PATH . "views"; // Save default
+
+ // If the view is not found in the theme, fall back to views in the plugin
+ if (!is_file($viewPath.'/'.$viewFile)) {
+
+ // Next try the plugin/add-on
+ $viewPath = GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_PATH . "/views";
+
+ if (!is_file($viewPath.'/'.$viewFile)) {
+
+ if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+ trigger_error("Bad or missing view file when generating checkout HTML: $viewPath/$viewFile", E_USER_NOTICE);
+ }
+
+ }
+
+ }
+
+ }
+
+ // Load Smarty Template support
+ $smarty = new smartyTemplateSupport();
+
+ // Add standard parameters
+ require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
+
+ // Add data from model to Smarty template
+ if (is_array($data) && count($data) > 0) {
+ foreach ($data as $k => $d) {
+ $smarty->templateAssign($k, $d);
+ }
+ }
+
+ // Update the Smarty view path
+ $smarty->template->setTemplateDir($viewPath);
+
+ // If the view path doesn't match the default, add the default (using theme view)
+ if ($viewPath2 != $viewPath) {
+ $smarty->template->addTemplateDir($viewPath2);
+ }
+
+ // Generate output from model data and view
+ $out = $smarty->template->fetch($viewFile);
+
+ return $out;
+
+ }
+
+
+
+}
-- Data Table
CREATE TABLE {prefix}custom_field_data (
id INT NOT NULL AUTO_INCREMENT,
- field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of custom_fields table for this field
- record_id INT NOT NULL DEFAULT 0, -- id for this submission of this form
- text_data TEXT NOT NULL DEFAULT '', -- Data for a text field
- checkbox_data BOOLEAN NOT NULL DEFAULT false, -- Data for a boolean field
- integer_data INTEGER NOT NULL DEFAULT 0, -- Data for an integer field
+ field_id INT NOT NULL DEFAULT 0, -- Pointer to ID of custom_fields table for this field
+ record_id INT NOT NULL DEFAULT 0, -- id for this submission of this form
+ text_data TEXT NOT NULL DEFAULT '', -- Data for a text field
+ checkbox_data BOOLEAN NOT NULL DEFAULT false, -- Data for a boolean field
+ integer_data INTEGER NOT NULL DEFAULT 0, -- Data for an integer field
float_data FLOAT NOT NULL DEFAULT '0.00', -- Data for a float field
PRIMARY KEY (id),
INDEX (field_id),