adding image uploading functionality
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 19 Sep 2017 20:29:16 +0000 (16:29 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 19 Sep 2017 20:29:16 +0000 (16:29 -0400)
setting up the image uploading for admin

classes/data/dataBuySell.php
setup/databaseScripts/create_database_V0.0.1.sql
views/admin/buySell/edit.html
views/admin/buySell/parts/image_input.html [new file with mode: 0644]

index ef139f1..9674ba7 100644 (file)
@@ -204,12 +204,12 @@ class GlmDataBuySell extends GlmDataAbstract
             ),
             'image_1' => array (
                 'field' => 'image_1',
-                'type' => 'text',
+                'type' => 'image',
                 'use' => 'a'
             ),
             'image_2' => array (
                 'field' => 'image_2',
-                'type' => 'text',
+                'type' => 'image',
                 'use' => 'a'
             ),
             'company' => array (
@@ -219,7 +219,7 @@ class GlmDataBuySell extends GlmDataAbstract
             ),
             'image_3' => array (
                 'field' => 'image_3',
-                'type' => 'text',
+                'type' => 'image',
                 'use' => 'a'
             ),
             'member' => array (
index 0772e54..7b500fa 100644 (file)
@@ -41,6 +41,6 @@ INSERT INTO {prefix}items (
 id,title,descr,topic,contact_email,contact_name,contact_phone,post_date,visible, 
 terms,location,item_expiration,image_3,post,image_1,
 company,member,image_2
-) VALUES ( 1, "TITLE", "DESCR", 1, "CONTACT_EMAIL", "CONTACT_NAME", "CONTACT_PHONE", NOW(), true, "TERMS", "LOCATION", 60, "IMAGE_3", "POST", 
-"IMAGE_1", "COMPANY", 1, "IMAGE_2"
+) VALUES ( 1, "TITLE", "DESCR", 1, "CONTACT_EMAIL", "CONTACT_NAME", "CONTACT_PHONE", NOW(), true, "TERMS", "LOCATION", 60, "IMAGE_3.jpg", "POST", 
+"IMAGE_1.jpg", "COMPANY", 1, "IMAGE_2.jpg"
 );
\ No newline at end of file
index b9f8713..fe2c67f 100644 (file)
             <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
                 Item 
             </div>
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-input">
-                <select id="item_title" data-id="title" name="title">
-                    <option value="">Select a Item Title</option>
-                    {$itemTitles|@print_r}
-                    {foreach from=$itemTitles item=j}
-                        {if 'fieldData'|array_key_exists:$item}
-                            <option value="{$j.id}" {if $item.fieldData.title.name == {$j.item_title}} selected="selected"{/if}>
-                        {else if}
-                            <option value="{$j.id}">
-                        {/if}
-                            {$j.item_title}
-                        </option>
-                    {/foreach}
-                </select>
-            </div>
             <div class="glm-small-12 glm-medium-8 glm-columns admin-item-input">
-                <label for="new_title">New Item Title</label>
-               <input id="new_item_title" type="text" name="new_item_title">
+                <input type="text" name="title" {if $item.fieldData.title} value='{$item.fieldData.title}' {/if}>
             </div>
         </div>
         <!-- MEMBER for admins only-->
                 <input type="text" name="company" {if $item.fieldData.company} value='{$item.fieldData.company}' {/if}>
             </div>
         </div>
-        <!-- FACILITY OPERATION -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                    Facility Operation
-            </div>
-            
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                {php}
-                    wp_editor(
-              
-                        '{$item.fieldData.facility_operation|escape:quotes}', 
-   
-               
-                    'facility_operation', array(
-                        'media_buttons' => false,
-                        'tinymce'      => false,
-                        // 'quicktags' => false,
-                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
-                        'textarea_name' => 'facility_operation',
-                        'editor_height' => 200,     // Height in px, overrides editor_rows
-                            // 'textarea_rows' => 8
-                    ));
-                {/php}
-            </div>
-        </div>
         <!-- DESCRIPTION -->
         <div class="glm-item-row glm-row">
             <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
                 {/php}
             </div>
         </div>
-        <!-- ITEM REQUIREMENTS -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                 Item Requirements   
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                {php}
-                    wp_editor(
-               
-                        '{$item.fieldData.requirements|escape:quotes}', 
-     
-                    'requirements', array(
-                        'media_buttons' => false,
-                        'tinymce'      => false,
-                        // 'quicktags' => false,
-                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
-                        'textarea_name' => 'requirements',
-                        'editor_height' => 200,     // Height in px, overrides editor_rows
-                            // 'textarea_rows' => 8
-                    ));
-                {/php}
-            </div>
-        </div>
-        <!-- BENEFITS -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                  Item Benefits 
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                {php}
-                    wp_editor(
-                
-                        '{$item.fieldData.benefits|escape:quotes}', 
-         
-   
-                    'benefits', array(
-                        'media_buttons' => false,
-                        'tinymce'      => false,
-                        // 'quicktags' => false,
-                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
-                        'textarea_name' => 'benefits',
-                        'editor_height' => 200,     // Height in px, overrides editor_rows
-                            // 'textarea_rows' => 8
-                    ));
-                {/php}
-            </div>
-        </div>
-        <!-- SALARY -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                   Salary 
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="salary" {if $item.fieldData.salary} value='{$item.fieldData.salary}' {/if}>
-            </div>
-        </div>
-        <!-- POSITION AVAILABLE -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                    Position Available
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="position_available" {if $item.fieldData.position_available} value='{$item.fieldData.position_available}' {/if}>
-            </div>
-        </div>
-       <!-- DURATION -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                Item Duration    
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="duration" {if $item.fieldData.duration} value='{$item.fieldData.duration}' {/if}>
-            </div>
-        </div>
-       <!-- DEADLINE -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                Deadline    
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="deadline" {if $item.fieldData.deadline} value='{$item.fieldData.deadline}' {/if}>
-            </div>
-        </div>
-       <!-- ITEM LOCATION -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                Item Location    
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                {php}
-                    wp_editor(
-         
-                        '{$item.fieldData.item_location|escape:quotes}', 
-      
-                    'item_location', array(
-                        'media_buttons' => false,
-                        'tinymce'      => false,
-                        // 'quicktags' => false,
-                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
-                        'textarea_name' => 'item_location',
-                        'editor_height' => 200,     // Height in px, overrides editor_rows
-                            // 'textarea_rows' => 8
-                    ));
-                {/php}
-            </div>
-        </div>
-        <!-- SEND RESUME TO  -->
-        <div class="glm-item-row glm-row">
-            <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
-                    Send Resume To
-            </div>
-            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                {php}
-                wp_editor(
-     
-                    '{$item.fieldData.resume_location|escape:quotes}', 
-  
-                'resume_location', array(
-                    'media_buttons' => false,
-                    'tinymce'      => false,
-                    // 'quicktags' => false,
-                    // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
-                    'textarea_name' => 'resume_location',
-                    'editor_height' => 200,     // Height in px, overrides editor_rows
-                        // 'textarea_rows' => 8
-                ));
-            {/php}
-            </div>
-        </div>
        <!-- CONTACT NAME -->
         <div class="glm-item-row glm-row">
             <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
                     Contact Name
             </div>
             <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="contactname" {if $item.fieldData.contactname} value='{$item.fieldData.contactname}' {/if}>
+                <input type="text" name="contactname" {if $item.fieldData.contact_name} value='{$item.fieldData.contact_name}' {/if}>
             </div>
         </div>
        <!-- EMAIL TO -->
                     Contact Email
             </div>
             <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="email_location" {if $item.fieldData.email_location} value='{$item.fieldData.email_location}' {/if}>
+                <input type="text" name="email_location" {if $item.fieldData.contact_email} value='{$item.fieldData.contact_email}' {/if}>
             </div>
         </div>
        <!-- CONTACT PHONE -->
                     Contact Phone
             </div>
             <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
-                <input type="text" name="contactphone" {if $item.fieldData.contactphone} value='{$item.fieldData.contactphone}' {/if}>
+                <input type="text" name="contactphone" {if $item.fieldData.contact_phone} value='{$item.fieldData.contact_phone}' {/if}>
             </div>
         </div>
+        <br>
+        {include file='admin/buySell/parts/image_input.html'}
+        <br>
        <!-- VISIBLE -->
         <div class="glm-item-row glm-row">
             <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
                     Visible
             </div>
-             <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
+            <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
                     <input id="item-visible" data-id="item-visible" type="checkbox" name="visible" class="visible-checkbox" {if $item.fieldData.visible.value} checked{/if}>
             </div>
         </div>
diff --git a/views/admin/buySell/parts/image_input.html b/views/admin/buySell/parts/image_input.html
new file mode 100644 (file)
index 0000000..66a718c
--- /dev/null
@@ -0,0 +1,63 @@
+<div class="glm-item-row glm-row">
+    <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
+        Image 1: 
+    </div>
+    <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
+        <pre>{$item|@print_r}</pre>
+        {if $item.fieldData.image_1}
+            <img src="{$glmPluginMediaUrl}/images/small/{$item.fieldData.image_1}">
+        {/if}
+        <b>New image:</b> <input type="file" name="image_1_new">
+
+        <div id="glm-galleryImageLarger_image" class="glm-imageDialog">
+            {if $item.fieldData.image_1}
+                <img src="{$glmPluginMediaUrl}/images/large/{$item.fieldData.image_1}">
+            {/if}
+        </div>
+        <div>
+            <input type="checkbox" name="image_1_delete"> Delete Image<br>
+        </div>
+    </div>
+</div>
+<div class="glm-item-row glm-row">
+    <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
+        Image 2: 
+    </div>
+    <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
+        
+        {if $item.fieldData.image_2}
+            <img src="{$glmPluginMediaUrl}/images/small/{$item.fieldData.image_2}">
+        {/if}
+        <b>New image:</b> <input type="file" name="image_2_new">
+
+        <div id="glm-galleryImageLarger_image" class="glm-imageDialog">
+            {if $item.fieldData.image_2}
+                <img src="{$glmPluginMediaUrl}/images/large/{$item.fieldData.image_2}">
+            {/if}
+        </div>
+        <div>
+            <input type="checkbox" name="image_2_delete"> Delete Image<br>
+        </div>
+    </div>
+</div>
+<div class="glm-item-row glm-row">
+    <div class="glm-small-12 glm-medium-2 glm-columns admin-item-label">
+        Image 3: 
+    </div>
+    <div class="glm-small-12 glm-medium-5 glm-columns admin-item-input">
+        
+        {if $item.fieldData.image_3}
+            <img src="{$glmPluginMediaUrl}/images/small/{$item.fieldData.image_3}">
+        {/if}
+        <b>New image:</b> <input type="file" name="image_3_new">
+
+        <div id="glm-galleryImageLarger_image" class="glm-imageDialog">
+            {if $item.fieldData.image_3}
+                <img src="{$glmPluginMediaUrl}/images/large/{$item.fieldData.image_3}">
+            {/if}
+        </div>
+        <div>
+            <input type="checkbox" name="image_3_delete"> Delete Image<br>
+        </div>
+    </div>
+</div>
\ No newline at end of file