implementing file and image gallery uploads and captions for files and image gallery...
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 26 Feb 2019 21:48:45 +0000 (16:48 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 26 Feb 2019 21:48:45 +0000 (16:48 -0500)
classes/data/dataFiles.php
js/imageUpload/imageUpload.js
models/admin/ajax/memberManagement.php
views/admin/manageDashboard/index.html
views/admin/member/memberInfo/editFiles.html

index 0d18e04..5d8b9f3 100644 (file)
@@ -25,6 +25,7 @@
  *          @release SVN: $Id: dataFiles.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
  */
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmPluginSupport.php';
 class GlmDataFiles extends GlmDataAbstract
 {
 
@@ -86,7 +87,7 @@ class GlmDataFiles extends GlmDataAbstract
      */
     function __construct ($wpdb, $config)
     {
-
+        
         // If this class is not being extended along with existing $wpdb and $config
         if (!$this->wpdb) {
 
@@ -316,7 +317,7 @@ class GlmDataFiles extends GlmDataAbstract
      */
     public function filesDataUpdate($refType, $refID, $orderField)
     {
-
+        $support = new glmPluginSupport();
         // Re-order image gallery files
         $this->filePositionOrder($refType, $refID, $orderField);
 
@@ -324,12 +325,15 @@ class GlmDataFiles extends GlmDataAbstract
         if (isset($_REQUEST['file_caption'])
             && is_array($_REQUEST['file_caption'])
             && count($_REQUEST['file_caption']) > 0) {
-
+            
             // Update other data for this image
             reset($_REQUEST['file_caption']);
+            
             foreach ( $_REQUEST['file_caption'] as $k => $v ) {
+                $support->write_log($k);
                 $id = ($k -0);
-
+                $support->write_log($_REQUEST['file_caption']);
+                
                 // Sanitize input
                 $caption = sanitize_text_field( $_REQUEST['file_caption'][$k] );
                 $descr   = (isset($_REQUEST['file_descr'])) ? sanitize_text_field( $_REQUEST['file_descr'][$k] ):'';
index d81e92b..c4aa4b1 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 jQuery(document).ready(function($) {
-
+    window.Glma['fileUploaderInit'] = function(){
     var drop;
     var fileDrop;
     var recordID;
@@ -30,49 +30,51 @@ jQuery(document).ready(function($) {
     var newImageAdded = false;
     var enableDraggable = true;
     var statusArea = false;
-
+    window.Glma = window.Glma || {};
+    
     // Setup Drag and Drop when Add
     if (window.File && window.FileList && window.FileReader) {
 
         // is XHR2 available?
         var xhr = new XMLHttpRequest();
         if (xhr.upload) {
-
-            // Change from Drag/Drop not supported to drop here text
-            $('.glm-imageBrowseButton').addClass('glm-imageItemHidden');
-            $('.glm-imageDropText').removeClass('glm-imageItemHidden');
-            $('.glm-imageDrop').removeClass('glm-imageItemHidden');
-
-            // Change from Drag/Drop not supported to drop here text
-            $('.glm-fileBrowseButton').addClass('glm-fileItemHidden');
-            $('.glm-fileDropText').removeClass('glm-fileItemHidden');
-            $('.glm-fileDrop').removeClass('glm-fileItemHidden');
-
-            // Prevent dropping on the document
-            $(document).on('dragenter', function (e) {
+           
+                // Change from Drag/Drop not supported to drop here text
+                $('.glm-imageBrowseButton').addClass('glm-imageItemHidden');
+                $('.glm-imageDropText').removeClass('glm-imageItemHidden');
+                $('.glm-imageDrop').removeClass('glm-imageItemHidden');
+
+                // Change from Drag/Drop not supported to drop here text
+                $('.glm-fileBrowseButton').addClass('glm-fileItemHidden');
+                $('.glm-fileDropText').removeClass('glm-fileItemHidden');
+                $('.glm-fileDrop').removeClass('glm-fileItemHidden');
+
+                // Prevent dropping on the document
+                $(document).on('dragenter', function (e) {
+                    e.stopPropagation();
+                    e.preventDefault();
+                });
+                $(document).on('dragover', function (e) {
                 e.stopPropagation();
                 e.preventDefault();
-            });
-            $(document).on('dragover', function (e) {
-              e.stopPropagation();
-              e.preventDefault();
-            });
-            $(document).on('drop', function (e) {
-                e.preventDefault();
-            });
-
-            // For each image drop area on the page
-            $('.glm-imageDrop').each(function() {
-                drop = $(this);
-                initDrop();
-            });
+                });
+                $(document).on('drop', function (e) {
+                    e.preventDefault();
+                });
 
-            // For each file drop area on the page
-            $('.glm-fileDrop').each(function() {
-                fileDrop = $(this);
-                initFileDrop();
-            });
+                // For each image drop area on the page
+                $('.glm-imageDrop').each(function() {
+                    drop = $(this);
+                    initDrop();
+                });
 
+                // For each file drop area on the page
+                $('.glm-fileDrop').each(function() {
+                    fileDrop = $(this);
+                    initFileDrop();
+                });
+            
+            
         } else {
             alert('Your Web browser does not support "Drag & Drop" image uploads using "XHR2".\nThat capability is required to upload images for the image gallery on this page.\nConsider upgrading your browser.');
         }
@@ -623,4 +625,6 @@ jQuery(document).ready(function($) {
     }
     setupExpandedImageEvents();
     setupExpandedFileEvents();
+}
+window.Glma.fileUploaderInit();
 });
index 334398c..a3698b9 100644 (file)
@@ -115,12 +115,20 @@ class GlmMembersAdmin_ajax_memberManagement extends glmMembersAdmin
                     $_REQUEST['category'][$field['name']] = $field['value'];
                 }elseif( strpos($field['name'], "amenity[") !== false){
                     $_REQUEST['amenity'][$field['name']] = $field['value'];
+                }elseif( strpos($field['name'], "file_caption[") !== false){
+                    preg_match_all("/\\[(.*?)\\]/", $field['name'], $match); 
+                    $_REQUEST['file_caption'][$match[1][0]] = $field['value'];
+                }elseif( strpos($field['name'], "galleryImage_caption[") !== false){
+                    preg_match_all("/\\[(.*?)\\]/", $field['name'], $match); 
+                    $_REQUEST['galleryImage_caption'][$match[1][0]] = $field['value'];
                 }else{
                     $_REQUEST[$field['name']] = $field['value'];
                 }
                 
             }
+
             unset($_REQUEST['form']);
+            //$support->write_log($_REQUEST);
             $data  = $this->controller( 'member', 'memberInfo',  false, true, true);
         }
         if($_REQUEST['option'] == 'delete'){
index 28edd6d..cccd35d 100644 (file)
             editData.option     = "edit";
             editData.memberInfo = $(this).data("memberinfo");
             editData.member     = memberID;
+            
             Glma.manageMember(
                 editData,
                 function(complete) {},
                 function(success) {
                     $(".edit-screen").html(success.searchData);
+                    window.Glma.fileUploaderInit();
                 },
                 function(error) {
                     console.log(error);
index 253b784..1d12aae 100644 (file)
@@ -85,6 +85,7 @@
                         <div class="glm-fileData glm-small-12 glm-large-4 glm-left">
                             <div class="glm-statusTable">
                                 <h4>File Name:</h4>
+                                <!-- <pre>{ $i|@print_r} </pre> -->
                                 <div><input id="file_caption_{$i.id}" type="text" name="file_caption[{$i.id}]" value="{$i.caption}" class="glm-form-text-input-small"></div>
                             </div>
                         </div>