fixed bug in required pages admin menu
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 17 Jun 2016 17:17:21 +0000 (13:17 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 17 Jun 2016 17:17:21 +0000 (13:17 -0400)
js/shortcodeBuilder.js
models/admin/management/index.php
views/admin/management/index.html

index b2ac987..46b38ae 100644 (file)
@@ -6,10 +6,10 @@
 jQuery(document).ready(function ($) {
     
     'use strict';
-
+    
     var shortcodeDropdown, shortcodeCategory, blankStart, listBox, detailBox, target, boxTarget, shortcodeString,
-    editor_shortcodes, category_id;
-    var shortcodeValues = {};
+    editor_shortcodes, category_id, shortcodeValues = {};
+    
     $("#showDetail").hide();
     $("#categoryBox").hide();
     $("#showCategory").hide();
@@ -19,17 +19,33 @@ jQuery(document).ready(function ($) {
     $(".scCategories").hide();
     
     // reset checkboxes after page load
-    function uncheckAll() {
-      var w = document.getElementsByTagName('input');
-      for (var i = 0; i < w.length; i++){ 
-        if(w[i].type === 'checkbox'){ 
-          w[i].checked = false; 
-        }
-      }
-    }
+//    function uncheckAll() {
+//      var w = document.getElementsByTagName('input');
+//      for (var i = 0; i < w.length; i++){ 
+//        if(w[i].type === 'checkbox'){ 
+//          w[i].checked = false; 
+//        }
+//      }
+//    }
+    var shortcode = $("#shortcode_container").not('.glm-dynSelect-item'), clone, id_count;
+    id_count = 0;
+//    $("#additionalShortcode").on( "click", function () {
+//            id_count++;
+//            clone = shortcode.clone(true);
+//            clone.find("#shortcodeDropdown").attr("id", "shortcodeDropdown" + "_" + id_count);
+//            clone.find(".glm-dynSelect-item").remove();
+//            clone.find("#generate").attr("id", "generate" + "_" + id_count);
+//            clone.insertAfter("#shortcode_container:last");
+//         
+//    });
+
     
+    
+    /////////////////////////////////////////////////////////////////////////////////////////
+    // CHANGE MAIN SHORTCODE 
+    /////////////////////////////////////////////////////////////////////////////////////////
    // fire core events and reset settings when switching between shortcodes
-    $("#shortcodeDropdown").on("change", function () {
+    $("[id$=shortcodeDropdown]").on("change", function () {
         // reset the dropdowns and checkbox if when switching shortcodes
         document.getElementById('category-scDropdown').options[0].selected = 'selected';
         if($('#blank-start-scDropdown').length)
@@ -37,7 +53,7 @@ jQuery(document).ready(function ($) {
         if($('#id-scDropdown').length)
             document.getElementById('id-scDropdown').options[0].selected = 'selected';
         
-        uncheckAll();
+//        uncheckAll();
         
         // delete the object properties to reset the object
         shortcodeString = "";
@@ -46,7 +62,7 @@ jQuery(document).ready(function ($) {
         }
         
         // get the shortcode option name and hide / show necessary elements
-        shortcodeDropdown = $("#shortcodeDropdown option:selected").val();
+        shortcodeDropdown = $(".shortcodeDropdown option:selected").val();
         
         if(shortcodeDropdown === "glm-members-list"){
             $("#showCategory").show();
@@ -60,16 +76,6 @@ jQuery(document).ready(function ($) {
             $(".scCategories").show();
         }
         
-        if(shortcodeDropdown === "glm-member-detail") {
-            $("#detailBtn").show();
-            $("#showCategory").hide();
-            $("#blank-start-scDropdown").show();
-            $("#category-scDropdown").hide();  
-            $("#id-scDropdown").hide();
-            $("[id^='packageList']").hide();
-            $("#view-scDropdown").hide();
-        } 
-        
         if(shortcodeDropdown === "glm-members-packaging-list"){
             $("#blank-start-scDropdown").hide();
             $("#showCategory").hide();
@@ -81,46 +87,17 @@ jQuery(document).ready(function ($) {
             $("#view-scDropdown").hide();
              $(".scCategories").hide();
         } 
-        
-        if (shortcodeDropdown === "glm-members-packaging-detail"){
-            $("#blank-start-scDropdown").hide();
-            $("#showCategory").hide();
-            $("#category-scDropdown").hide();
-            $("#detailBtn").hide();
-            $("#id-scDropdown").show();
-            $("[id^='packageList']").hide();
-            $("#view-scDropdown").hide();
-        }
-        if (shortcodeDropdown === "glm-members-event-list"){
-            $("#blank-start-scDropdown").hide();
-            $("#showCategory").hide();
-            $("#category-scDropdown").hide();
-            $("#detailBtn").hide();
-            $("[id^='packageList']").hide();
-             $("#id-scDropdown").hide();
-             $("#view-scDropdown").hide();
-        }
-        if (shortcodeDropdown === "glm-members-event-detail"){
-            $("#blank-start-scDropdown").hide();
-            $("#showCategory").hide();
-            $("#category-scDropdown").hide();
-            $("#detailBtn").hide();
-            $("[id^='packageList']").hide();
-            $("#id-scDropdown").hide();
-            $("#view-scDropdown").hide();
-            $("#view-scDropdown").hide();
-        }
-        if (shortcodeDropdown === "glm-members-event-front-add"){
-            $("#blank-start-scDropdown").hide();
-            $("#showCategory").hide();
-            $("#category-scDropdown").hide();
-            $("#detailBtn").hide();
-            $("[id^='packageList']").hide();
-            $("#id-scDropdown").hide();
-            $("#view-scDropdown").hide();
-        }
-    });
 
+    });
+    
+    
+    
+    
+    
+    
+    ////////////////////////////////////////////////////////////////////
+    //  GET ATTRIBUTES
+    /////////////////////////////////////////////////////////////////////
      // shortcode attribute name from dropdowns containing '-scDropdown' in their ID
      // Then append the values to the shortcode object
      $("[id$=-scDropdown]").on("change", function () {
@@ -136,11 +113,11 @@ jQuery(document).ready(function ($) {
         $("#showDetail").dialog().dialog("option", "width", 422);
     });
     
+//    var regExp = /\[([^)]+)\]/;
+    var regExp = /glm_members_list_/g;
     function get_tinymce_content(){
         if (jQuery("#wp-content-wrap").hasClass("tmce-active")){
             
-            var regExp = /\[([^)]+)\]/;
-            
             tinyMCE.triggerSave();
             
             if(regExp.exec($('#content').val())){
@@ -153,7 +130,7 @@ jQuery(document).ready(function ($) {
         } else {
             
             // get the shortcode from the editor with [ ] as the delimiters
-            var regExp = /\[([^)]+)\]/;
+
             var editorContent = regExp.exec($("#content").val());
             
             // getting an array as the value from the previous reExp, will need to investigate
@@ -161,15 +138,31 @@ jQuery(document).ready(function ($) {
                 return editorContent[0];
             }
         }
-    }      
+    }
 
     editor_shortcodes = get_tinymce_content();
-    console.debug(editor_shortcodes);
     
+    if(editor_shortcodes){
+        
+        var number_of_categories = (editor_shortcodes.match(/category="(.*?)"/g) || []).length;
+     
+    }
+    console.debug(number_of_categories);
+
+    console.debug(editor_shortcodes);
     if(editor_shortcodes){
         if(editor_shortcodes.match(/category="(.*?)"/) !== null){
             category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
+//            console.debug(category_id);
+//            var cat_id_array = [];
+//            $.each(category_id, function (key, value) {
+//                  cat_id_array.push(value.match(/"(.*?)"/)[1]); 
+//            });
+
             category_id = category_id.split(',');
+
+        } else if (editor_shortcodes.match(/category=""/) !== null){
+            category_id = editor_shortcodes.match(/category="(.*?)"/)[1];       
         }
     }
 
@@ -196,20 +189,36 @@ jQuery(document).ready(function ($) {
     }
     
     
+    
+    
+    
+    
+    
+    
+    /////////////////////////////////////////////////////////////////////////////////////////////
    /*
     * Category Selection
     */
-     var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), editor_content;
-
+   //////////////////////////////////////////////////////////////////////////////////////////////
+     var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), editor_content, empty_space, count;
+   
     $('#category-scDropdown').change( function() {
        editor_shortcodes = get_tinymce_content();
 
        if(editor_shortcodes){
             if(editor_shortcodes.match(/category="(.*?)"/) !== null){
                 category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
-                category_id = category_id.split(',');
-                ids = category_id.join(',');
-                editor_category_index = editor_shortcodes.indexOf('category=');
+             
+                if(category_id !== ""){
+                    category_id = category_id.split(',');
+     
+                    ids = category_id.join(',');
+                    empty_space = false;
+                } else {
+
+                    ids = 'category=""';
+                    empty_space = true;
+                }
             }
         }
  
@@ -227,11 +236,6 @@ jQuery(document).ready(function ($) {
            }
        });
 
-       // Check if there's a parent
-//       parentName = '';
-//       if (catParent !== '') {
-//           parentName = catParent + ': ';
-//       }
 
        // If not found, Add the category
        if (!found) {
@@ -242,44 +246,80 @@ jQuery(document).ready(function ($) {
        }
        
        id_string = '';
+        
        $.each($(".glm-dynSelect-item"), function () {
            if($.inArray($(this).data("id"), new_ids) === -1){
                new_ids.push($(this).data("id"));
            }
-       });
-       
-       id_string = new_ids.join(',');
-       
+       });   
+        
+       if ( new_ids.length > 1){
+           id_string = new_ids.join(',');
+       } else if ( new_ids.length === 1) {
+           id_string = new_ids[0];
+       }
+
        if($("#content").css("display") !== "none"){
            editor_content = content.val();
-           editor_content = editor_content.replace(ids, id_string);
-           content.val(editor_content);
+           if(empty_space){
+                editor_content = editor_content.replace(ids, 'category="' + id_string + '"');
+                content.val(editor_content);
+           } else {
+               editor_content = editor_content.replace('category="' + ids, 'category="' + id_string);
+               content.val(editor_content);
+           }
        } else if(tinyMCE.activeEditor !== null){
-           editor_content = tinyMCE.get('content').getContent({format: 'raw'});
-           editor_content = editor_content.replace(ids, id_string);
-           tinyMCE.activeEditor.setContent(editor_content);
+           if(empty_space){
+                editor_content = tinyMCE.get('content').getContent({format: 'raw'});
+                editor_content = editor_content.replace(ids, 'category="' + id_string + '"' );
+                tinyMCE.activeEditor.setContent(editor_content);
+           } else {
+                editor_content = tinyMCE.get('content').getContent({format: 'raw'});
+                editor_content = editor_content.replace('category="' + ids, 'category="' + id_string);
+                tinyMCE.activeEditor.setContent(editor_content);
+           }
        }
 
        // Reset picklist
        $('#category-scDropdown').val('Select Category');
     });
     
+    
+    function insert_tag(text){
+        if(tinyMCE && tinyMCE.activeEditor)
+        {
+            tinyMCE.activeEditor.selection.setContent(text);
+        }
+            return false;
+    }
+    
+    /////////////////////////////////////////////////////////////////////////////////////////////////
+    // INSERT SHORTCODE FUNCTION 
+    /////////////////////////////////////////////////////////////////////////////////////////////////
     // generate the shortcode into a string and insert into the content upon clicking
-    $("#generate").on("click", function () {
+    $("[id$=generate]").on("click", function () {
+        count = 0;
+        if(number_of_categories){
+            count = number_of_categories;
+            count++;
+        } else {
+            count++;
+        }
         // enforce the selection of a shortcode
         if(shortcodeDropdown){
             // set up properties for shortcode lists
             if(shortcodeDropdown === "glm-members-list"){
-            var listValues = $('input[name="listBox"]:checkbox:checked').map(function() {
-                 boxTarget = $(this).attr("class").slice(0, -5);
-                return this.value;
-            }).get();
-
-            var listString = "";
-                listValues.forEach(function(value){
-                    listString += value + ",";
-                });
+                var listValues = $('input[name="listBox"]:checkbox:checked').map(function() {
+                     boxTarget = $(this).attr("class").slice(0, -5);
+                    return this.value;
+                }).get();
+                
                 
+                var listString = "";
+                    listValues.forEach(function(value){
+                        listString += value + ",";
+                    });
+
                 if(listValues !== ""){
                     listString = listString.replace(/,\s*$/, "");
                     shortcodeValues[boxTarget] = listString;
@@ -302,7 +342,7 @@ jQuery(document).ready(function ($) {
                 }
             }
             // start the shortcode string that will be added to the tinymce editor
-            shortcodeString = "[" + shortcodeDropdown;
+            shortcodeString = '<div class="previewCodes" id="' + shortcodeDropdown + '_' + count + '"> [' + shortcodeDropdown;
             
             // populate the shortcode object
             for (var key in shortcodeValues) {
@@ -319,7 +359,7 @@ jQuery(document).ready(function ($) {
                 ids = category_id.join(',');
                 shortcodeString = shortcodeString.replace(ids, id_string);
             }
-            shortcodeString += ']';
+            shortcodeString += '] </div>';
 
             // insert shortcode at current cursor position
              if($("#content").css("display") !== "none"){
@@ -330,14 +370,7 @@ jQuery(document).ready(function ($) {
                 $('#content').val( textBefore + shortcodeString + textAfter );
                  
             } else if($("#content").css("display") === "none") {
-                function insert_tag(text){
-                    if(tinyMCE && tinyMCE.activeEditor)
-                    {
-                        console.log(tinyMCE.activeEditor.id);
-                        tinyMCE.activeEditor.selection.setContent(text);
-                    }
-                        return false;
-                }
+    
                 insert_tag(shortcodeString);
             }
             } else {
@@ -345,16 +378,25 @@ jQuery(document).ready(function ($) {
         }
     });
 
+    
+    
+    
+    
+    
+    
+    /////////////////////////////////////////////////////////////////
+    // DELETE CATEGORY
+    /////////////////////////////////////////////////////////////////
     // Action to de-select a category and dynamically adjust the shortcode categories in the editor
     $('.catDelete').live('click', function() {
-       
+
        editor_shortcodes = get_tinymce_content();
 
-       if(editor_shortcodes.match(/category="(.*?)"/) !== null){
+       if(editor_shortcodes && editor_shortcodes.match(/category="(.*?)"/) !== null){
             category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
             category_id = category_id.split(',');
             ids = category_id.join(',');
-       }   
+       }
 
        $(this).parent().remove();
        
@@ -365,20 +407,31 @@ jQuery(document).ready(function ($) {
                new_ids.push($(this).data("id"));
            }
        });
-       
+
        id_string = new_ids.join(',');
-        
+
        if($("#content").css("display") !== "none"){
+           
            editor_content = content.val();
-           editor_content = editor_content.replace(ids, id_string);
+           editor_content = editor_content.replace('category="' + ids, 'category="' + id_string );
            content.val(editor_content);
+           
        } else if(tinyMCE.activeEditor !== null){
+           
            editor_content = tinyMCE.get('content').getContent({format: 'raw'});
-           editor_content = editor_content.replace(ids, id_string);
+           editor_content = editor_content.replace('category="' + ids, 'category="' + id_string);
            tinyMCE.activeEditor.setContent(editor_content);
+           
        }
+
     });
     
+    
+    
+    
+    
+    ///////////////////////////////////////////////////////////////////////////
+    // MAINENANCE
     // reset dropdowns and checkboxes to default values on page reload
     var scd = document.getElementById('shortcodeDropdown');
     var catscd = document.getElementById('category-scDropdown');
@@ -405,7 +458,6 @@ jQuery(document).ready(function ($) {
     if(view){
         window.onload = document.getElementById('view-scDropdown').options[0].selected = 'selected';
     }
-   window.onload = uncheckAll();
-     
-    
-}); 
\ No newline at end of file
+//    window.onload = uncheckAll();
+}); 
+
index 8cfb535..9835501 100644 (file)
@@ -25,6 +25,7 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
 {
     public $prefixSlugs = array();
     public $requiredPages = array();
+// s
     /**
      * WordPress Database Object
      *
@@ -62,17 +63,20 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
         parent::__construct(false, false);
 
     }
-    public function updateRequiredPages(){
+     public function updateRequiredPages(){
         $this->requiredPages = array();
+//        $this->reqPageTitlesStatic = array();
         foreach ($this->config['addOns'] as $a) {
             if (isset($a['requiredPages'])) {
                 foreach($a['requiredPages'] as $pageName => $pageData) {
+//                    $this->reqPageTitlesStatic[] = strtolower(str_replace(" ","-",$pageName));
                     $pageID = get_option(GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$pageData['underscored_title']);
                     $this->prefixSlugs[] = GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$pageData['underscored_title'];
                     $this->requiredPages[$a['underscored_name']][$pageName]['id'] = $pageID;
                     $page = get_post($pageID);
                     $this->requiredPages[$a['underscored_name']][$pageName]['slug'] = $page->post_name;
                     $this->requiredPages[$a['underscored_name']][$pageName]['title'] = $page->post_title;
+                    $this->requiredPages[$a['underscored_name']][$pageName]['static_name'] = strtolower(str_replace(" ","-",$pageName));
                 }
             }
         }
@@ -117,8 +121,8 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
         $settingsUpdated = false;
         $settingsUpdateError = false;
         $requiredPagesUpdateError = false;
-        $idError = false;
-        $titleError = false;
+        $id_error = false;
+        $title_error = false;
         // General settings are always stored in a record with ID=1.
         $id = 1;
 
@@ -137,73 +141,75 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
    
         // Check for submission option
         $option = '';
-        if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') {
+        if ( isset( $_REQUEST[ 'option' ] ) && $_REQUEST[ 'option' ] == 'submit' ) {
             $option = $_REQUEST['option'];
         }
         
         $this->updateRequiredPages();
-        switch($option) {
+        switch( $option ) {
 
             // Update General Settings and redisplay the form
             case 'submit':
-                
-                // get all of the IDs from the form 
-               $requiredPagesIDs = array_intersect_key($_REQUEST, array_flip(preg_grep('/^glm_members_database_id/', array_keys($_REQUEST))));
+                foreach ( $this->config[ 'addOns' ] as $a ) {
+                    if ( isset( $a[ 'requiredPages' ] ) ) {
+                        foreach( $a[ 'requiredPages'] as $pageName => $pageData ) {
+                            
+                            $current_page_id_value = get_option( GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$pageData[ 'underscored_title' ] );
 
-                foreach($requiredPagesIDs as $id){
-                    $page = get_post($id);
-                    $pageTitle = $page->post_title;
-                    $pageSlug= $page->post_name;
-                    $slug = 'glm_members_database_option_' . $pageSlug;
-                    $postValueTitle = filter_var($_POST[$slug], FILTER_SANITIZE_STRING);
-                    if($pageTitle != $postValueTitle && !empty($postValueTitle)){
-                        $args = array (
-                            'ID' => $id,
-                            'post_title' => $postValueTitle
-                        );
-                        wp_update_post($args);
-                    } else if($pageTitle == $postValueTitle) { 
-  
-                    } else if(empty($postValueTitle)){
-                        $settingsUpdateError = true;
-                        $settingsUpdated = false;
-                        $titleError = true;
-                    }
-                }
+                            $page_title_field_name = 'glm_members_database_title_' . $this->requiredPages[ $a[ 'underscored_name'] ][ $pageName ][ 'static_name' ];
+                            $page_id_field_name = 'glm_members_database_id_' . $this->requiredPages[ $a[ 'underscored_name' ] ][ $pageName ][ 'static_name' ];
+                            
+                            $page_option_slug = GLM_MEMBERS_PLUGIN_OPTION_PREFIX.$pageData['underscored_title'];
 
-                foreach($this->prefixSlugs as $slug){
-                    $id = get_option($slug);
-                    $pageTitle = $page->post_title;
-                    $page = get_post($id);
-                    $pageSlug = $page->post_name;
-                    $titleSlug = 'glm_members_database_option_' . $pageSlug;
-                    $pageSlug = 'glm_members_database_id_' . $pageSlug;
-                    $formID = filter_var($_POST[$pageSlug], FILTER_SANITIZE_STRING);
-                    $formTitle = filter_var($_POST[$titleSlug], FILTER_SANITIZE_STRING);
-                    if($id != $formID && get_post_status($formID) != false && is_numeric($formID)){
-                        update_option($slug, $formID);
-                    } else if($id == $formID && is_numeric($formID)) {
-                        update_option($slug, $id);
-                    } else {
-                       $settingsUpdateError = true;
-                       $settingsUpdated = false;
-                       $idError = true;
-                    }                 
+                            $current_page_title_value = $this->requiredPages[ $a[ 'underscored_name' ] ][ $pageName][ 'title' ];
+                            
+                            if( isset( $_POST[ $page_title_field_name ] ) && ! empty( $_POST[ $page_title_field_name ] ) ){
+                                $new_page_title_value = filter_var($_POST[$page_title_field_name], FILTER_SANITIZE_STRING);
+                            } else {
+                                $title_error = true;
+                            }
+                            
+                            if( isset( $_POST[ $page_id_field_name ] ) && !empty( $_POST[ $page_id_field_name ] ) && is_numeric( $_POST[ $page_id_field_name ] ) ){
+                                $new_page_id_value = filter_var( $_POST[ $page_id_field_name ], FILTER_SANITIZE_STRING );
+                            } else {
+                                $id_error = true;
+                            }
+                                             
+                            if( $current_page_title_value !== $new_page_title_value ){
+                                $args = array (
+                                    'ID' => $current_page_id_value,
+                                    'post_title' => $new_page_title_value,
+                                );
+                                wp_update_post( $args );
+                            }
+                            
+                            // ensure the new page id exists and the field is not empty
+                            if($current_page_id_value !== $new_page_id_value && get_post_status( $new_page_id_value ) ){
+                                update_option( $page_option_slug, $new_page_id_value );
+                            } else {
+       
+                            }                     
+                        }
+                    }
                 }
-
                 $this->updateRequiredPages();
-                
+  
                 // Required Pages
                 $requiredPagesUpdateError = false;
-                if (isset($_REQUEST[GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_LIST_ID]) ){
-                    $membersListIdOption = $requiredPages['glm-member-db']['members_list'][''];
-                    $newMembersListId = $_REQUEST[$membersListIdOption];
+                if ( isset( $_REQUEST[ GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_LIST_ID ] ) ){
+                    $membersListIdOption = $requiredPages[ 'glm-member-db' ][ 'members_list' ][''];
+                    $newMembersListId = $_REQUEST[ $membersListIdOption ];
+                } else {
+         
                 }
+                echo $_REQUEST[ 'glm_members_database_option_member-detail' ];
+                echo $newMembersListId;
                 $results = $this->wpdb->get_results( "SELECT ID FROM ".$this->wpdb->posts." WHERE ID = ".$newMembersListId);
-                if (get_option($membersListIdOption) == $newMembersListId) {
+                if ( get_option( $membersListIdOption) == $newMembersListId ) {
                     $requiredPagesUpdateError = false;
-                } else if (is_numeric($newMembersListId)) {
-                    if ($results) {
+                } else if ( is_numeric( $newMembersListId ) ) {
+                    if ( $results ) {
                         $requiredPagesUpdateError = false;
                     } else {
                         $requiredPagesUpdateError .= "\n Page ID $newMembersListId does not exist. ";
@@ -214,7 +220,7 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
                 
                // Update all general setttings
                 $generalSettings = $this->updateEntry(1);
-                if ($generalSettings['status']) {
+                if ( $generalSettings[ 'status' ]) {
                     $settingsUpdated = true;
                 } else {
                     $settingsUpdateError = true;
@@ -226,19 +232,18 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
             default:
 
                 // Try to get the first (should be only) entry for general settings.
-                $generalSettings = $this->editEntry($id);
+                $generalSettings = $this->editEntry( $id );
 
                 if ($generalSettings === false) {
 
-                    if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                    if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG ) {
                         glmMembersAdmin::addNotice("<b>&nbsp;&nbsp;/modesl/admin/settings/index.php: Unable to load General Settings.", 'Alert');
                     }
-
                 }
 
                 break;
         }
-        if($settingsUpdateError){
+        if( $settingsUpdateError ){
             $settingsUpdated = false;
         }
         // Compile template data
@@ -249,8 +254,8 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
             'settingsUpdated' => $settingsUpdated,
             'settingsUpdateError' => $settingsUpdateError,
             'requiredPages' => $this->requiredPages,
-            'idError'         => $idError,
-            'titleError'    => $titleError,
+            'id_error'         => $id_error,
+            'title_error'    => $title_error,
             'requiredPagesUpdateError' => $requiredPagesUpdateError
         );
 
@@ -262,9 +267,7 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
             'view' => 'admin/management/index.html',
             'data' => $templateData
         );
-
     }
-
 }
 
 ?>
\ No newline at end of file
index 8edcb0c..cd6ef0a 100644 (file)
         <!-- Required Pages -->
         
         <table id="glm-table-required-page" class="glm-admin-table glm-settings-table glm-hidden">
-            {if $idError}<span class="glm-error">Page ID should be numerical and should not be empty</span>{/if}
-            {if $titleError}<span class="glm-error">Page Title should not be blank</span>{/if}
-            {foreach from=$requiredPages key=addon item=requiredPage}
+            {if $id_error}<span class="glm-error">'Page ID' input should be numerical, not empty and the page must exist</span>{/if}
+            {if $title_error}<span class="glm-error">'Page Name' should not be blank</span>{/if}
+            {foreach from=$requiredPages key=addon item=requiredPage  name=count}
             <tr><td colspan="2"><h2>Plugin: {$addon}</h2></td></tr>
+  
                 {foreach from=$requiredPage key=requiredPageName item=requiredPageData}
                 <tr>
                     <th>{$requiredPageName}</th>
                             <tr>
                                 <th>Page Name</th>
                                 <td>
-                                    <input type="text" name="glm_members_database_option_{$requiredPageData.slug}" value="{$requiredPageData.title}">
+                                    <input type="text" name="glm_members_database_title_{$requiredPageData.static_name}"  value="{$requiredPageData.title}">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Page ID</th>
                                 <td>
-                                    <input name="glm_members_database_id_{$requiredPageData.slug}" type="text" value="{$requiredPageData.id}">
+                                    <input name="glm_members_database_id_{$requiredPageData.static_name}" type="text" value="{$requiredPageData.id}">
                                 </td>
                             </tr>
                             <tr>
@@ -79,6 +80,7 @@
                         </table>
                     </td>
                 </tr>
+
                 {/foreach}
             {/foreach}
         </table>