Create file page from ImageGallery
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 31 Mar 2017 12:29:33 +0000 (08:29 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 31 Mar 2017 12:29:33 +0000 (08:29 -0400)
Using Image Gallery as example I'm creating a page in the member info
that will be for files.

classes/data/dataFiles.php
js/imageUpload/imageUpload.js
models/admin/ajax/fileUpload.php
models/admin/ajax/membersListExport.php
views/admin/ajax/membersListExport.html
views/admin/ajax/membersListExportCsv.html
views/admin/member/memberInfo/editFiles.html
views/admin/member/memberInfo/editLocation.html
views/admin/members/list.html

index 31d19de..eceaf81 100644 (file)
@@ -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;";
index b06131c..4b2724b 100644 (file)
@@ -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 {
index 4916ce8..db226f8 100644 (file)
@@ -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,
index c4b49a5..8ffab3a 100644 (file)
@@ -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'),
index d9c54c9..197e74b 100644 (file)
@@ -20,6 +20,8 @@
                     {if $select.exportCity}<th align="left">City</th>{/if}
                     {if $select.exportState}<th align="left">State</th>{/if}
                     {if $select.exportZip}<th align="left">ZIP</th>{/if}
+                    {if $select.exportCounty}<th align="left">County</th>{/if}
+                    {if $select.exportRegion}<th align="left">Region</th>{/if}
                     {if $select.exportMailingAddr1}<th align="left">Mailing Address</th>{/if}
                     {if $select.exportMailingAddr2}<th align="left">Mailing Addr Line #2</th>{/if}
                     {if $select.exportMailingCity}<th align="left">Mailing City</th>{/if}
@@ -53,6 +55,8 @@
                     {if $select.exportCity}<td>{$m.city}</td>{/if}
                     {if $select.exportState}<td>{$m.state.value}</td>{/if}
                     {if $select.exportZip}<td>{$m.zip}</td>{/if}
+                    {if $select.exportCounty}<td>{$m.county.value}</td>{/if}
+                    {if $select.exportRegion}<td>{$m.region.value}</td>{/if}
                     {if $select.exportMailingAddr1}<td>{$m.mailing_addr1}</td>{/if}
                     {if $select.exportMailingAddr2}<td>{$m.mailing_addr2}</td>{/if}
                     {if $select.exportMailingCity}<td>{$m.mailing_city}</td>{/if}
index 4a08d51..92340dc 100644 (file)
@@ -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}
index adc84d3..059200f 100644 (file)
                             <div class="glm-fileData">
                                 <table class="glm-statusTable">
                                     <tr>
-                                        <th>Caption:</th>
-                                        <td><input id="file_caption_{ id }" type="text" name="file_caption[{ id }]" value="" class="glm-form-text-input-medium" disabled></td>
+                                        <th>File Name:</th>
+                                        <td><input id="file_caption_{ id }" type="text" name="file_caption[{ id }]" value="" class="glm-form-text-input-small" disabled></td>
                                         <td rowspan="2">
                                             <table>
                                                 <tr><th>Delete:</th><td><input type="checkbox" name="file_delete[{ id }]" disabled></td></tr>
-                                                <tr><th>featured File:</th><td><input type="radio" name="file_featured" value="{ id }"></td></tr>
                                                 <tr><th colspan="2" class="glm-notice" style="font-size: 1.2em;">New Upload</th></tr>
                                             </table>
                                         </td>
                                     </tr>
-                                    <tr>
-                                        <th>Description:</th>
-                                        <td><textarea name="file_descr[{ id }]" disabled></textarea></td>
-                                    </tr>
                                 </table>
                             </div>
+                            <div class="glm-file">
+                                <a target="_blank" href="{$glmPluginMediaUrl}/files/{ filename }">{ file_name }</a>
+                            </div>
                         </li>
                         <!-- End of template -->
 
@@ -83,8 +81,8 @@
                     <div class="glm-fileData">
                         <table class="glm-statusTable">
                             <tr>
-                                <th>Caption:</th>
-                                <td><input id="file_caption_{$i.id}" type="text" name="file_caption[{$i.id}]" value="{$i.caption}" class="glm-form-text-input-medium"></td>
+                                <th>File Name:</th>
+                                <td><input id="file_caption_{$i.id}" type="text" name="file_caption[{$i.id}]" value="{$i.caption}" class="glm-form-text-input-small"></td>
                                 <td rowspan="2">
                                     <table>
                                         <tr><th>Delete:</th><td><input type="checkbox" name="file_delete[{$i.id}]"></td></tr>
                                     <input type="hidden" name="file_position[{$i.id}]" value="{$i.position}">
                                 </td>
                             </tr>
-                            <tr>
-                                <th>Description:</th>
-                                <td><textarea name="file_descr[{$i.id}]">{$i.descr}</textarea></td>
-                                <th colspan="2">
-                                </th>
-                            </tr>
                         </table>
                     </div>
                     <div class="glm-file" data-id="{$i.id}">
index d2938fc..642f94c 100644 (file)
@@ -1,4 +1,4 @@
-        
+
         <table id="glm-table-address" class="glm-admin-table glm-hidden glm-member-info-table">
             <tr>
                 <th {if $memberInfo.fieldRequired.addr1}class="glm-required"{/if}>Address Line 1:</th>
                     {if $memberInfo.fieldFail.zip}<p>{$memberInfo.fieldFail.zip}</p>{/if}
                 </td>
             </tr>
+            <tr>
+                <th {if $memberInfo.fieldRequired.county}class="glm-required"{/if}>County:</th>
+                <td {if $memberInfo.fieldFail.county}class="glm-form-bad-input" data-tabid="glm-member-info-address"{/if}>
+                    <select name="county">
+                        {foreach from=$memberInfo.fieldData.county.list item=v}
+                            <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                        {/foreach}
+                    </select>
+                    {if $memberInfo.fieldFail.county}<p>{$memberInfo.fieldFail.county}</p>{/if}
+                </td>
+            </tr>
             <tr>
                 <th {if $memberInfo.fieldRequired.country}class="glm-required"{/if}>Country:</th>
                 <td {if $memberInfo.fieldFail.country}class="glm-form-bad-input" data-tabid="glm-member-info-address"{/if}>
@@ -82,9 +93,9 @@
                 <th {if $memberInfo.fieldRequired.region}class="glm-required"{/if}>Region:</th>
                 <td {if $memberInfo.fieldFail.region}class="glm-form-bad-input" data-tabid="glm-member-info-address"{/if}>
                     <select name="region">
-        {foreach from=$memberInfo.fieldData.region.list item=v}
-                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
-        {/foreach}
+                        {foreach from=$memberInfo.fieldData.region.list item=v}
+                            <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                        {/foreach}
                     </select>
                     {if $memberInfo.fieldFail.region}<p>{$memberInfo.fieldFail.region}</p>{/if}
                 </td>
                     </p>
                     <div id="locationMap" class="glm-map-edit">(map loads here)</div>
                     <p>
-                        <b>Selected Position:</b> 
+                        <b>Selected Position:</b>
                         &nbsp;&nbsp;Latitude <input id="glmLat" name="lat" type="text" value="{$memberInfo.fieldData.lat}" class="glm-form-text-input-veryshort">
                         &nbsp;&nbsp;Longitude <input id="glmLng" name="lon" type="text" value="{$memberInfo.fieldData.lon}" class="glm-form-text-input-veryshort">
                         &nbsp;&nbsp;<span id="latLonRecenter" class="button button-secondary">Update pointer with new lat/lon postion.</span>
index 4ad186d..68c6152 100644 (file)
                                     <input type="checkbox" name="exportCity" checked> City<br>
                                     <input type="checkbox" name="exportState" checked> State<br>
                                     <input type="checkbox" name="exportZip" checked> ZIP/Postal Code<br>
+                                    <input type="checkbox" name="exportCounty" checked> County <br>
+                                    <input type="checkbox" name="exportRegion" checked> Region <br>
                                 </td>
                                 <td>
                                     <input type="checkbox" name="exportPhone" checked> Phone #<br>