Making notes
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 23 Jun 2017 13:34:42 +0000 (09:34 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 23 Jun 2017 13:34:42 +0000 (09:34 -0400)
Adding comments.

models/admin/import/index.php
views/admin/import/index.html

index 357fad3..cf374eb 100644 (file)
@@ -198,6 +198,7 @@ class GlmMembersAdmin_import_index
      */
     public function modelAction ($actionData = false)
     {
+        // Set the view file
         $view        = 'index.html';
         $failure     = false;
         $option      = 'default';
@@ -212,6 +213,12 @@ class GlmMembersAdmin_import_index
         if ( isset( $_REQUEST['numberProcessed'] ) ) {
             $this->numberProcessed = filter_var( $_REQUEST['numberProcessed'], FILTER_VALIDATE_INT );
         }
+        // $fileData - The main files needed for the member import
+        // - field:    input field name
+        // - name:     file name
+        // - exists:   Does file exists. Set to false at first.
+        // - validate: Validation array. Header line must match this.
+        // - type:     Type of file. Used in the processing function.
         $fileData = array(
             'Amenity' => array(
                 'field'    => 'amenity_file',
@@ -264,19 +271,29 @@ class GlmMembersAdmin_import_index
         );
         $readyToProcess = false;
 
+        // Set the $option if found in $_REQUEST array
         if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
             $option = $_REQUEST['option'];
         }
 
+        // Set the $option2 if found in $_REQUEST array
         if (isset($_REQUEST['option2']) && $_REQUEST['option2'] != '') {
             $option2 = $_REQUEST['option2'];
         }
 
+        // Set variable for the upload directory
         $wpUploadDir = wp_get_upload_dir();
-        $uploadPath  = $wpUploadDir['basedir'] . '/' . 'glm-member-import';
+
+        // Set the $uploadPath for import files
+        $uploadPath = $wpUploadDir['basedir'] . '/' . 'glm-member-import';
+
+        // If the folder for the upload import files doesn't exists create one.
         if ( !is_dir( $uploadPath ) ) {
+            // Get old umask
             $oldMask = umask(0);
+            // Set folder permission
             mkdir( $uploadPath, 0770 );
+            // reset old umask
             umask( $oldMask );
         }
 
@@ -284,6 +301,7 @@ class GlmMembersAdmin_import_index
 
         case 'validate';
             $validFiles = 0;
+            // Set the view file
             $view       = 'validate.html';
             $fileCount  = count( $fileData );
             // Move any files uploaded
@@ -315,7 +333,8 @@ class GlmMembersAdmin_import_index
         case 'process':
             $clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
             if ( $clearData ) {
-                // empty tables
+                // Empty the tables for the member data.
+                // Not including the management options.
                 $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenity_ref');
                 $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenities');
                 $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenity_groups');
@@ -331,10 +350,11 @@ class GlmMembersAdmin_import_index
                 $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info');
                 $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members');
             }
-            //exit;
+
+            // Loop through the $fileData array.
+            // This will setup the wordpress options for each file.
             foreach ( $fileData as $fileHeader => $file ) {
                 if ( is_file( $uploadPath . '/' . $file['name'] ) && $fileHeader != 'Member' ) {
-                    //$fileData[$fileHeader]['results']
                     $success = $this->processFile( $uploadPath . '/' . $file['name'], $file['type'] );
                     if ( $success ) {
                         $fileData[$fileHeader]['results'] = "<p>$fileHeader file processed successfully.</p>";
@@ -363,6 +383,7 @@ class GlmMembersAdmin_import_index
             if ( count( $this->errors ) == 0 ) {
                 $readyToProcess = true;
             }
+            // Set the view file
             $view = 'process.html';
             break;
 
@@ -396,6 +417,7 @@ class GlmMembersAdmin_import_index
             if ( $this->numberProcessed == $this->totalMembers ) {
                 $this->processingComplete = true;
             }
+            // Set the view file
             $view = 'processMembers.html';
             break;
 
@@ -412,6 +434,7 @@ class GlmMembersAdmin_import_index
             $isValid  = ( $fData == $validate );
             // If the file validates then we're ready to process
             $readyToProcess = $isValid;
+            // Set the view file
             $view= 'photosValidate.html';
             $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
 
@@ -474,22 +497,27 @@ class GlmMembersAdmin_import_index
 
                 }
 
+                // Set the view file
                 $view= 'photosProcess.html';
             } else {
+                // Set the view file
                 $view= 'photosValidate.html';
             }
             break;
 
         case 'photos':
+            // Set the view file
             $view= 'photos.html';
             break;
 
         case 'files':
+            // Set the view file
             $view = 'files.html';
             break;
 
         case 'default':
         default:
+            // Set the view file
             $view = 'index.html';
             // check upload dir to see if they have any files in yet
             foreach ( $fileData as $fileHeader => $file ) {
@@ -521,6 +549,7 @@ class GlmMembersAdmin_import_index
             'haveMembers'     => $haveMembers,
             'isValid'         => $isValid,
         );
+
         // Return status, suggested view, and data to controller
         return array(
             'status'           => true,
@@ -593,7 +622,7 @@ class GlmMembersAdmin_import_index
      * Report errors in the $this->errors array.
      *
      * @param mixed $fileName File name for the csv file.
-     * @param mixed $type     Type (category,amenity,city)
+     * @param mixed $type     Type (category,amenity,city...)
 
      * @access public
      * @return void
index 0c6e860..18212bc 100644 (file)
@@ -6,10 +6,19 @@
         <input type="hidden" name="glm_action" value="index" />
         <input type="hidden" name="option" value="validate" />
 
-        <table class="glm-admin-table">
-            {foreach $fileData as $fileHeader => $file}
+        <table class="glm-admin-table" border="0" cellspacing="2" cellpadding="5">
             <tr>
-                <td>{$fileHeader}</td>
+                <th>File Type</th>
+                <th>New File</th>
+                <th>Current File</th>
+                <th>Updated</th>
+            </tr>
+            {$count = 0}
+            {foreach $fileData as $fileHeader => $file}
+            <tr{if $count%2 == 0} class="alternate"{/if}>
+                <td>
+                    <a href="#" data-filetype="{$file.type}">{$fileHeader}</a>
+                </td>
                 <td>
                     <input type="file" name="{$file.field}">
                 </td>
                     {/if}
                 </td>
             </tr>
+            {$count = $count + 1}
             {/foreach}
             <tr>
                 <td>Clear Data</td>
-                <td>
+                <td colspan="4">
                     <input type="hidden" name="clear_data" value="0">
                     <input type="checkbox" name="clear_data" value="1" checked>
                 </td>