Cleaned up some initialization parameters and ini file parsing issues.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Mar 2015 16:35:29 +0000 (12:35 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Mar 2015 16:35:29 +0000 (12:35 -0400)
config/plugin.ini
defines.php
index.php
views/admin/member/memberInfo.html

index 910160d..dd5477d 100644 (file)
@@ -34,6 +34,12 @@ thumb['crop'] = false
 
 [common]
 
+; Debug Options
+admin_debug = false
+admin_debug_verbose = false
+front_debug = false
+front_debug_verbose = false
+
 ;
 ; Google Maps Browser API Key
 ; Account: cscott.glm@gmail.com
@@ -230,5 +236,6 @@ phrase['phrase_test'] = 'test'
 
 
 [chuck:common]
+;admin_debug = true
 
 
index 5476cd6..8879abd 100644 (file)
@@ -8,11 +8,12 @@
 define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Members Database');
 define('GLM_MEMBERS_PLUGIN_DIR', 'glm-member-db');
 
-// Debug Options
-define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', true);
-define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', true);
-define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', true);
-define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', true);
+// Determine which system we're running on - If not provided, assume PRODUCTION
+$host = getenv('GLM_HOST_ID');
+if (trim($host) == '') {
+    $host = 'PRODUCTION';
+}
+define('GLM_MEMBER_PLUGIN_HOST', $host);
 
 // Determine current http/https protocol
 $pageProtocol = 'http';
index 0a5aec2..703c487 100644 (file)
--- a/index.php
+++ b/index.php
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+$startupNotices = '';
+
 // Get standard defined parameters
 require_once('defines.php');
 
-// Get plugin configuration - Just use common section for now, we'll deal with others later
+// Get plugin configuration
 $configData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/plugin.ini', true);
 $config = $configData['common'];
+// Override parameters according to GLM_HOST_ID
+$hostSection = strtolower(GLM_MEMBER_PLUGIN_HOST).':common';
+if (isset($configData[$hostSection])) {
+    $config = array_replace($config, $configData[strtolower(GLM_MEMBER_PLUGIN_HOST).':common']);
+} else {
+    $startupNotices .=
+        '<p><b>Bad configuration file section name or section not found:</b> '. $hostSection
+        .'<br>See plugin '.GLM_MEMBERS_PLUGIN_PATH.'config/plugin.ini file.'
+        .'<br>Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.</p>'
+    ;
+}
+
+// Add Debug defines
+define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $config['admin_debug']);
+define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']);
+define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $config['front_debug']);
+define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', $config['front_debug_verbose']);
+
+// Also get image sizes array from the plugin.ini - uses separate ini section.
 $config['imageSizes'] = $configData['imageSizes'];
 
 // Get additional configuration data
@@ -355,11 +376,36 @@ function glmMembersAdminNotices($windowed = false)
     }
 
 }
-// Check if there's admin notices for output
+
+/*
+ * Check if there's any startup notices in this file. (stuff that happens before we get all setup)
+ *
+ * If there is, have the message displayed at the top of the wp-admin content area.
+ */
+function glmMembersStartupNotices() {
+    global $startupNotices;
+    echo '<div class="updated"><h3>'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning</h3><p>'.$startupNotices.'</p></div>';
+}
+if ($startupNotices != '') {
+    add_action('admin_notices','glmMembersStartupNotices');
+}
+
+/*
+ * Check if there's any debug information or other notices that need to be displayed
+ *
+ * If there is, display as a separate window.
+ *
+ * NOTE: Need to break out notices that should be displayed in the wp-admin content area. To
+ * do that I need to modify the glmMembersAdminNotices function above and the
+ * addNotice() function in the classes/glmPluginSupport.php file. Should have addNotice()
+ * function be able to add to another option specifically for doing this.
+ */
 $notices = get_option('glmMembersAdminNotices');
 if (is_admin() && $notices && !GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+
     // Add action to output the notices
     add_action('admin_notices','glmMembersAdminNotices');
+
 }
 
 ?>
\ No newline at end of file
index 8badaf8..7d97fcb 100644 (file)
                         Click and drag anywhere else on the map to move to another area.
                     </p>
                     <div id="locationMap" class="glm-map-edit">(map loads here)</div>     
-                    position: <span id="mapPosition">Lat {$memberInfo.fieldData.lat}, Lon {$memberInfo.fieldData.lon}</span>
+                    Selected Position: <span id="mapPosition">Lat {$memberInfo.fieldData.lat}, Lon {$memberInfo.fieldData.lon}</span>
                 </td>
             </tr>
             <tr>