From ca7b08f49dba04150f53e403281ddf438293267a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 31 Mar 2017 08:29:33 -0400 Subject: [PATCH] Create file page from ImageGallery Using Image Gallery as example I'm creating a page in the member info that will be for files. --- classes/data/dataFiles.php | 12 +- js/imageUpload/imageUpload.js | 52 +++++--- models/admin/ajax/fileUpload.php | 7 +- models/admin/ajax/membersListExport.php | 2 + views/admin/ajax/membersListExport.html | 4 + views/admin/ajax/membersListExportCsv.html | 4 + views/admin/member/memberInfo/editFiles.html | 22 +--- .../admin/member/memberInfo/editLocation.html | 121 ++++++++++++++++++ views/admin/members/list.html | 2 + 9 files changed, 185 insertions(+), 41 deletions(-) create mode 100644 views/admin/member/memberInfo/editLocation.html diff --git a/classes/data/dataFiles.php b/classes/data/dataFiles.php index 31d19de7..eceaf81c 100644 --- a/classes/data/dataFiles.php +++ b/classes/data/dataFiles.php @@ -150,11 +150,11 @@ class GlmDataFiles extends GlmDataAbstract ), // Description - 'descr' => array( - 'field' => 'descr', - 'type' => 'text', - 'use' => 'a' - ), + //'descr' => array( + // 'field' => 'descr', + // 'type' => 'text', + // 'use' => 'a' + //), // Caption 'caption' => array( @@ -351,7 +351,7 @@ class GlmDataFiles extends GlmDataAbstract // Sanitize input $caption = sanitize_text_field( $_REQUEST['file_caption'][$k] ); - $descr = sanitize_text_field( $_REQUEST['file_descr'][$k] ); + $descr = (isset($_REQUEST['file_descr'])) ? sanitize_text_field( $_REQUEST['file_descr'][$k] ):''; // Update data for this image $sql = "UPDATE ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."files SET caption = '$caption', descr = '$descr' WHERE id = $id;"; diff --git a/js/imageUpload/imageUpload.js b/js/imageUpload/imageUpload.js index b06131c9..4b2724bf 100644 --- a/js/imageUpload/imageUpload.js +++ b/js/imageUpload/imageUpload.js @@ -26,6 +26,7 @@ jQuery(document).ready(function($) { var uploadStatusTemplate; var imageDataTemplate; var galleryImages; + var galleryFiles; var newImageAdded = false; var enableDraggable = true; @@ -451,22 +452,41 @@ jQuery(document).ready(function($) { // Check for success if (fileData.status) { - // Add image(s) to gallery display - for (var i = 0 ; i < fileData.files.length ; i++) { - - // Using a copy of the supplied template, add image information - imageData = imageDataTemplate; - imageData = imageData.replace(/bust-stupid-ngg-image-selection/g, 'img'); - imageData = imageData.replace(/{ id }/g, fileData.files[i].id); - imageData = imageData.replace(/\{ filename \}/g, fileData.files[i].newFileName); - galleryImages.prepend(imageData); - - // Enable the fields that were just added - $("#" + fileData.files[i].id + " input, #" + fileData.files[i].id + " textarea").removeAttr('disabled'); - - // Prepend image ID to position order input field - $("#galleryPositionOrder").val(fileData.files[i].id + ',' + $("#galleryPositionOrder").val()); - + // Check if these are not images (noimage will be true) + if ( fileData.noimage ) { + // Add files(s) to files display + for ( var i = 0; i < fileData.files.length; i++ ) { + // Using a copy of the supplied template, add file information + fData = fileDataTemplate; + fData = fData.replace(/{ id }/g, fileData.files[i].id); + fData = fData.replace(/\{ filename \}/g, fileData.files[i].newFileName); + fData = fData.replace(/\{ file_name \}/g, fileData.files[i].name); + galleryFiles.prepend(fData); + + // Enable the fields that were just added + $("#" + fileData.files[i].id + " input, #" + fileData.files[i].id + " textarea").removeAttr('disabled'); + + // Prepend file ID to position order input field + $("#filePositionOrder").val(fileData.files[i].id + ',' + $("#filePositionOrder").val()); + } + } else { + // Add image(s) to gallery display + for (var i = 0 ; i < fileData.files.length ; i++) { + + // Using a copy of the supplied template, add image information + imageData = imageDataTemplate; + imageData = imageData.replace(/bust-stupid-ngg-image-selection/g, 'img'); + imageData = imageData.replace(/{ id }/g, fileData.files[i].id); + imageData = imageData.replace(/\{ filename \}/g, fileData.files[i].newFileName); + galleryImages.prepend(imageData); + + // Enable the fields that were just added + $("#" + fileData.files[i].id + " input, #" + fileData.files[i].id + " textarea").removeAttr('disabled'); + + // Prepend image ID to position order input field + $("#galleryPositionOrder").val(fileData.files[i].id + ',' + $("#galleryPositionOrder").val()); + + } } } else { diff --git a/models/admin/ajax/fileUpload.php b/models/admin/ajax/fileUpload.php index 4916ce84..db226f84 100644 --- a/models/admin/ajax/fileUpload.php +++ b/models/admin/ajax/fileUpload.php @@ -124,12 +124,13 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages if (isset($file['name']) && is_file($file['tmp_name'])) { // Store the image - $file = $this->storeImage($file, $refType, $refTable, $refDest); + $file = $this->storeFile($file, $refType, $refTable, $refDest); $return['files'][] = $file; // Indicate if we actually stored an image $return['status'] = ($file != false); + $return['noimage'] = true; } else { @@ -194,7 +195,7 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages $newFilename = strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']); } - $fileUploaded = move_uploaded_file( $_FILES['file']['tm_name'], GLM_MEMBERS_PLUGIN_IMAGES_PATH . '/'. $newFilename ); + $fileUploaded = move_uploaded_file( $_FILES['file']['tmp_name'], GLM_MEMBERS_PLUGIN_FILES_PATH . '/'. $newFilename ); // If we have a good image if ( $fileUploaded ) { @@ -208,7 +209,6 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages ( name, file_name, - descr, caption, status, position, @@ -219,7 +219,6 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages ( '".$file['name']."', '".$file['newFileName']."', - '', '".addslashes($caption)."', ".$this->config['status_numb']['Active'].", 99, diff --git a/models/admin/ajax/membersListExport.php b/models/admin/ajax/membersListExport.php index c4b49a5f..8ffab3ac 100644 --- a/models/admin/ajax/membersListExport.php +++ b/models/admin/ajax/membersListExport.php @@ -109,6 +109,8 @@ class GlmMembersAdmin_ajax_membersListExport extends GlmDataMemberInfo 'exportCity' => $this->checkFlag('exportCity'), 'exportState' => $this->checkFlag('exportState'), 'exportZip' => $this->checkFlag('exportZip'), + 'exportCounty' => $this->checkFlag('exportCounty'), + 'exportRegion' => $this->checkFlag('exportRegion'), 'exportMailingAddr1' => $this->checkFlag('exportMailingAddr1'), 'exportMailingAddr2' => $this->checkFlag('exportMailingAddr2'), 'exportMailingCity' => $this->checkFlag('exportMailingCity'), diff --git a/views/admin/ajax/membersListExport.html b/views/admin/ajax/membersListExport.html index d9c54c91..197e74b7 100644 --- a/views/admin/ajax/membersListExport.html +++ b/views/admin/ajax/membersListExport.html @@ -20,6 +20,8 @@ {if $select.exportCity}City{/if} {if $select.exportState}State{/if} {if $select.exportZip}ZIP{/if} + {if $select.exportCounty}County{/if} + {if $select.exportRegion}Region{/if} {if $select.exportMailingAddr1}Mailing Address{/if} {if $select.exportMailingAddr2}Mailing Addr Line #2{/if} {if $select.exportMailingCity}Mailing City{/if} @@ -53,6 +55,8 @@ {if $select.exportCity}{$m.city}{/if} {if $select.exportState}{$m.state.value}{/if} {if $select.exportZip}{$m.zip}{/if} + {if $select.exportCounty}{$m.county.value}{/if} + {if $select.exportRegion}{$m.region.value}{/if} {if $select.exportMailingAddr1}{$m.mailing_addr1}{/if} {if $select.exportMailingAddr2}{$m.mailing_addr2}{/if} {if $select.exportMailingCity}{$m.mailing_city}{/if} diff --git a/views/admin/ajax/membersListExportCsv.html b/views/admin/ajax/membersListExportCsv.html index 4a08d511..92340dc6 100644 --- a/views/admin/ajax/membersListExportCsv.html +++ b/views/admin/ajax/membersListExportCsv.html @@ -9,6 +9,8 @@ {if $select.exportCity}"City",{/if} {if $select.exportState}"State",{/if} {if $select.exportZip}"ZIP/Postal",{/if} +{if $select.exportCounty}"County",{/if} +{if $select.exportRegion}"Region",{/if} {if $select.exportMailingAddr1}"Mailing Address",{/if} {if $select.exportMailingAddr2}"Mailing Addr Line #2",{/if} {if $select.exportMailingCity}"Mailing City",{/if} @@ -32,6 +34,8 @@ {if $select.exportCity}"{$m.city}",{/if} {if $select.exportState}"{$m.state.value}",{/if} {if $select.exportZip}"{$m.zip}",{/if} +{if $select.exportCounty}"{$m.county.value}",{/if} +{if $select.exportRegion}"{$m.region.value}",{/if} {if $select.exportMailingAddr1}"{$m.mailing_addr1}",{/if} {if $select.exportMailingAddr2}"{$m.mailing_addr2}",{/if} {if $select.exportMailingCity}"{$m.mailing_city}",{/if} diff --git a/views/admin/member/memberInfo/editFiles.html b/views/admin/member/memberInfo/editFiles.html index adc84d3f..059200f0 100644 --- a/views/admin/member/memberInfo/editFiles.html +++ b/views/admin/member/memberInfo/editFiles.html @@ -49,22 +49,20 @@
- - + + - - - -
Caption:File Name: -
Delete:
featured File:
New Upload
Description:
+
+ { file_name } +
@@ -83,8 +81,8 @@
- - + +
Caption:File Name: @@ -92,12 +90,6 @@ - - - - -
Delete:
Description: -
diff --git a/views/admin/member/memberInfo/editLocation.html b/views/admin/member/memberInfo/editLocation.html new file mode 100644 index 00000000..642f94c7 --- /dev/null +++ b/views/admin/member/memberInfo/editLocation.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if $memberInfo.fieldRequired.lat} + + +
Address Line 1: + + {if $memberInfo.fieldFail.addr1}

{$memberInfo.fieldFail.addr1}

{/if} +
Address Line 2: + + {if $memberInfo.fieldFail.addr2}

{$memberInfo.fieldFail.addr2}

{/if} +
City + +
Add a new City
+
+ + + + + +
City Name: + +
+
+

* Required

+ Cancel + +
+ + + +
State: + + {if $memberInfo.fieldFail.state}

{$memberInfo.fieldFail.state}

{/if} +
ZIP / Postal Code: + + {if $memberInfo.fieldFail.zip}

{$memberInfo.fieldFail.zip}

{/if} +
County: + + {if $memberInfo.fieldFail.county}

{$memberInfo.fieldFail.county}

{/if} +
Country: + + {if $memberInfo.fieldFail.country}

{$memberInfo.fieldFail.country}

{/if} +
Region: + + {if $memberInfo.fieldFail.region}

{$memberInfo.fieldFail.region}

{/if} +
{else}{/if}Location: +
Map Location Using Above Address
+

+ MAP USE: Drag the pointer to the desired location for this {$terms.term_member}. + Use + and - buttons or the mouse wheel to zoom in or out. + Click and drag anywhere else on the map to move to another area. +

+
(map loads here)
+

+ Selected Position: +   Latitude +   Longitude +   Update pointer with new lat/lon postion. +

+
diff --git a/views/admin/members/list.html b/views/admin/members/list.html index 3d1bd420..77c91621 100644 --- a/views/admin/members/list.html +++ b/views/admin/members/list.html @@ -135,6 +135,8 @@ City
State
ZIP/Postal Code
+ County
+ Region
Phone #
-- 2.17.1