)
);
-
+
// add shortcode metabox
add_action('add_meta_boxes', array(
$this,
'glmMembersShortcode'
- ) );
+ ) );
// Add AJAX image upload action
add_action( 'wp_ajax_glm_members_admin_ajax',
* Create new pages containing the member DB shortcodes
* @return void
*/
- public function createPages($requiredPages)
+ public function createPages($requiredPages)
{
foreach($requiredPages as $requiredPage => $requiredPageInfo) {
$trimmedName = GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$requiredPageInfo['optionSuffix'];
// Jquery DatePicker
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
-
+
wp_enqueue_media();
}
}
public function glmMembersShortcode(){
-
+
// load shortcodeBuilder.js when the shortcode function has been fired
add_action('admin_print_styles-post.php', 'custom_js_css');
add_action('admin_print_styles-post-new.php', 'custom_js_css');
-
+
// tried calling the adminScripts function here but it throws js errors in the console
wp_enqueue_script('jquery', false, array(), false, true);
wp_enqueue_script('jquery-style', false, array(), false, true);
// Jquery DatePicker
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
-
+
function custom_js_css() {
-
+
wp_enqueue_script('your-meta-box', GLM_MEMBERS_PLUGIN_URL. '/js/shortcodeBuilder.js', array('jquery'), null, true);
}
-
- add_meta_box("shortcode_builder",
- "Shortcode Builder",
- array($this,'shortcode_builder_markup'),
+
+ add_meta_box("shortcode_builder",
+ "Shortcode Builder",
+ array($this,'shortcode_builder_markup'),
"page", 'normal', 'high'
);
-
- }
+
+ }
// // metabox content
public function shortcode_builder_markup(){
-
- require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
$listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes'];
$detailAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-member-detail']['attributes'];
-
+
$glmcat = new GlmDataCategories($this->wpdb, $this->wpconfig);
- $list = $glmcat->getList();
+ $list = $glmcat->getList();
// get the each addOn slugs to pass to the config array later
$addOns = $this->config['addOns'];
foreach($addOns as $addOn){
$shortCodes[] = $shortCode;
}
}
- }
+ }
// /*
// * HTML Markup for the shortodes
// */
// if(file_exists(GLM_MEMBERS_EVENTS_PLUGIN_PATH . "/setup/shortcodeBuilder.php")){
// include GLM_MEMBERS_EVENTS_PLUGIN_PATH . "/setup/shortcodeBuilder.php";
// }
-//
-//
+//
+//
//dropdown for shortcode names
echo '<div id="shortcodeBuilder">';
echo '<select id="shortcodeDropdown">
echo '<option value = "' . $code . '">' . $code . '</option>';
}
echo '</select>';
-
+
// /*
// * Member DB Shortcode Attributes
// */
-//
+//
//dropdown for categories
echo '<select id="category-scDropdown">';
echo '<option value=""> Select Category </option>';
<option selected="selected" value="False"> False </option>
<option value = "True"> True </option>';
echo '</select>';
-
- // show list options 'scb' = shortcode builder acronym
+
+ // show list options 'scb' = shortcode builder acronym
echo '<div id="showList" title="List Options">';
echo '<label><input class="listBox" type="checkbox" name="list-scb" value="all">All</label>';
echo '<label><input class="listBox" type="checkbox" name="list-scb" value="none">None</label>';
if($value != ''){
echo '<label><input class="showLists" type="checkbox" name="listBox" value='. $key . '>' . $key .'</label>';
}
- }
+ }
echo '</div>';
// show detail options
if($value != ''){
echo '<label><input class="showDetails" type="checkbox" name="detailBox" value='. $key . '>' . $key .'</label>';
}
- }
+ }
echo '</div>';
-
+
// packaging addOn mark up
if(file_exists(GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php")){
include GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php";
echo '<button id="detailBtn" class="glm-button" type="button"> Show Detail Options </button>';
echo '<button id="generate" class="glm-button" type="button"> Insert Shortcode </button>';
-
+
}
/**
$this->createPages($a['requiredPages']);
}
}
-
+
// Loop till we have a final action
$loopCheck = 0;
$loopTracking = "<p>Menu: $menuItem, Action = $action</p>";
'phone',
'file',
'image',
+ 'b64image',
'latitude',
'longitude'
);
// Check for a list data
if (!isset($f['list']) || !is_array($f['list'])) {
-
- echo "Field '".$f['name']."' is type list but does not have supplied 'list' data.";
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "Field '".$f['name']."' is type list but does not have supplied 'list' data.",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// Build list array
// Check for a list data
if (!isset($f['list']) || !is_array($f['list'])) {
-
- echo "Field '".$f['name']."' is type list but does not have supplied 'list' data.";
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "Field '".$f['name']."' is type list but does not have supplied 'list' data.",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// Build list array
{\r
// Check for a bitmap data\r
if (!isset($f['bitmap']) || !is_array($f['bitmap'])) {\r
- echo "Field '".$f['name']."' is type bitmap but does not have supplied 'bitmap' data.";\r
- exit;\r
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "Field '".$f['name']."' is type bitmap but does not have supplied 'bitmap' data.",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}\r
\r
// Build bitmap array\r
// Check for a bitmap data
if (!isset($f['bitmap']) || !is_array($f['bitmap'])) {
- echo "Field '".$f['name']."' is type bitmap but does not have supplied 'bitmap' data.";
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "Field '".$f['name']."' is type bitmap but does not have supplied 'bitmap' data.",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// If this is setup for a new entry, then just use default
$filter = FILTER_SANITIZE_STRING;
if (isset($f['filter'])) {
if (!is_numeric($f['filter'])) {
- echo "<P> </p><strong>ERROR:</strong> Supplied value for option 'filter' in fields array not a defined filter for PHP filter_input();";
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "<P> </p><strong>ERROR:</strong> Supplied value for option 'filter' in fields array not a defined filter for PHP filter_input();",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
$filter = $f['filter'];
$filter_options = 0; //FILTER_FLAG_NO_ENCODE_QUOTES;
if (isset($f['filter_options'])) {
if (!is_numeric($f['filter_options']) && !is_array($f['filter_options'])) {
- echo "<P> </p><strong>ERROR:</strong> Supplied value for 'filter_options' is not valid;";
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "<P> </p><strong>ERROR:</strong> Supplied value for 'filter_options' is not valid;",
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
$filter_options = $f['filter_options'];
}
return "'".addslashes($in)."'";
}
+ /*
+ * Base64 Image Field Processing (for inline images)
+ */
+ function b64imageField($f)
+ {
+ return 'T.'.$f['field'];
+ }
+ function b64imageOptions($f)
+ {
+ return false;
+ }
+ function b64imageOutput($f, $d)
+ {
+ return $d;
+ }
+ function b64imageInput($as, $f, $id, $idfield, $op)
+ {
+
+ $new = false;
+ $currentImage = '';
+
+ // Get the current image data
+ $sql = "SELECT $as
+ FROM $this->table
+ WHERE $idfield = $id;";
+ $d = $this->wpdb->get_row($sql, ARRAY_A);
+ $b64image = $d[$as];
+
+ // Check if we have a new image being submitted
+ if (isset($_FILES[$as.'_new']) && is_array($_FILES[$as.'_new']) && $_FILES[$as.'_new']['tmp_name'] != '') {
+
+ // Get the size of the uploaded file
+ $imageSize = filesize($_FILES[$as.'_new']['tmp_name']);
+
+ // Set absolute max image size to 10K
+ if ($r['maxSize'] > 10000) {
+ $r['maxSize'] == 10;
+ }
+
+ // If it's bigger than the max image size ($fileSize is in Bytes
+ if ($imgeSize > ($max * 1000) || $imageSize > 10000) {
+ $this->inputFieldStatus = false;
+ $this->inputErrorReason = 'Image uploaded is '.intval($imageSize/1000).' kB. The maximum image size that may be submitted for this image is '.$f['maxSize'].' kB.';
+ return $in;
+ }
+
+ // Get new image using temporary file name
+ $b64image = base64_encode(file_get_contents($_FILES[$as.'_new']['tmp_name']));
+
+ }
+
+ return $b64image;
+ }
+ function b64imageStore($in, $f)
+ {
+ return $in;
+ }
+
/*
* File Field Processing
*/
// Check that we have a fields list
if (!is_array($this->fields) || count($this->fields) == 0) {
- echo "ALERT: Empty Fields List in data abstract buildFieldsList()! Likely programming error.";
- return false;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "ALERT: Empty Fields List in data abstract buildFieldsList()! Likely programming error.",
+ 'Alert',
+ 'Member Types Data'
+ );
+ }
}
// For each possible field
// Check for good field type
if (!in_array($v['type'], $this->knownFieldTypes)) {
- echo "CONFIGURATION ERROR: Unknown field type - ".$v['type'];
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "CONFIGURATION ERROR: Unknown field type - ".$v['type'],
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// Call field processing function based on field tye
// Check for good field type
if (!in_array($type, $this->knownFieldTypes)) {
- echo "CONFIGURATION ERROR: Unknown field type - ".$v['type'];
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "CONFIGURATION ERROR: Unknown field type - ".$v['type'],
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// Check for "as" output field name
// Check for good field type
if (!in_array($v['type'], $this->knownFieldTypes)) {
- echo "CONFIGURATION ERROR: Unknown field type - ".$v['type'];
- exit;
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "CONFIGURATION ERROR: Unknown field type - ".$v['type'],
+ 'Alert',
+ ''
+ );
+ }
+ return false;
}
// Check for "as" output field name
{
if ($id-0 == 0) {
- // echo "DataAbstract.php - getEntry() called with invalid ID";
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ glmMembersAdmin::addNotice(
+ "DataAbstract.php - getEntry() called with invalid ID",
+ 'Alert',
+ ''
+ );
+ }
return false;
}