Changeset 995138
- Timestamp:
- 09/23/2014 04:14:53 AM (12 years ago)
- Location:
- rhj4-notifications/trunk
- Files:
-
- 7 edited
-
css/rhj4-notifications.css (modified) (4 diffs)
-
include/demo.php (modified) (3 diffs)
-
js/demo.js (modified) (2 diffs)
-
js/jquery.notifications.js (modified) (1 diff)
-
readme.htm (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
rhj4_notifications.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rhj4-notifications/trunk/css/rhj4-notifications.css
r993970 r995138 8 8 Author : Bob Jones 9 9 */ 10 table.rhj4_plugins_demo {10 .rhj4_plugins_demo { 11 11 background-color: lightgray; 12 12 border: 1px solid black; 13 width: 400px; 14 padding-top: 8px; 15 padding-bottom: 8px; 16 padding-left: 8px; 17 padding-right: 8px; 13 18 } 14 19 … … 28 33 margin-left: 8px; 29 34 margin-right: 10px; 35 vertical-align: top; 30 36 } 31 37 … … 41 47 42 48 .rhj4_plugins_demo td { 43 vertical-align: middle;49 vertical-align: top; 44 50 color:black; 51 } 52 53 .rhj4_radio, .rhj4_checkbox { 54 height:18px; 55 width: 18px; 56 } 57 58 .rhj4_plugins_shortcode td { 59 vertical-align: top; 45 60 } 46 61 … … 50 65 51 66 .rhj4_plugins_buttons { 52 background-color: silver; 67 background-color: silver; 68 border: 1px solid black; 69 margin-top: 15px; 70 } 71 72 .rhj4_plugin_log { 73 vertical-align: top; 74 } 75 76 .rhj4_plugin_buttons { 77 margin-top: 15px; 53 78 } 54 79 -
rhj4-notifications/trunk/include/demo.php
r993970 r995138 1 1 <div> 2 <table class='rhj4_plugins_demo'>2 <table> 3 3 <tbody> 4 4 <tr> 5 <td class='rhj4_plugins_input'>Text: <input id="messageText" type="text" placeholder='Message text...'/></td> 6 <td class='rhj4_plugins_comment'>Enter notification text</td> 7 </tr> 8 <tr> 9 <td class='rhj4_plugins_input'>Type: 10 <select id="messageType"> 5 <td> 6 <div class="rhj4_plugins_demo"> 7 <table> 8 <tr> 9 <td> 10 Text: <input id="messageText" type="text" placeholder='Enter notification text...'/></td> 11 </tr> 12 <tr> 13 <td class='rhj4_plugins_input'>Type: <select id="messageType"> 11 14 <?php 12 15 // Get list of currently enabled notification types 13 16 $notif = RHJ4Notifications::instance(); 14 17 15 18 // Get defaults array - this defines the notification types 16 19 $types = $notif->defaults; … … 32 35 echo $options; 33 36 ?> 34 </select> 37 </select> 38 </td> 39 </tr> 40 <tr> 41 <td class='rhj4_plugins_input'> 42 <span>Browser:<input name="messageSource" type="radio" value="browser" class='rhj4_radio' /></span> 43 <span>Server:<input name="messageSource" type="radio" value="server" class='rhj4_radio' checked="checked" /> 44 </td> 45 </tr> 46 <tr> 47 <td class='rhj4_plugins_input'>Sticky: 48 <input id="messageIsSticky" type="checkbox" class="rhj4_checkbox" /> 49 Auto-Drain: 50 <input id="autoDrainQueue" type="checkbox" class="rhj4_checkbox" /></td> 51 </tr> 52 </table> 53 </div> 54 <div> 55 <table class='rhj4_plugins_buttons'> 56 <tr><td>Generate Notifications: 57 <input type="button" value="Single" onclick="do_notification_submit();return false;" /> 58 <input type="button" value="Multiple" onclick="do_notification_submit_all();return false;" /> 59 <span id="queue_size"></span> 60 <input id="drain" type="button" value="Drain Queue" onclick="do_notification_drain_queue();return false;"/> 61 <span id='queuing' class='blink'>Queuing...</span> 62 <input type="button" value="Clear" onclick="do_clear_diagnostic_log();return false;" /> 63 </td> 64 </tr> 65 </table> 66 </div> 67 </td> 68 <td> 69 <div class="rhj4_plugins_log"> 70 <?php 71 if (is_plugin_active('rhj4-diagnostics/rhj4_diagnostics.php')) { 72 $diags = RHJ4Diagnostics::instance(); 73 echo $diags->show(); 74 } else { 75 echo "This demonstration requires the RHJ4 Diagnostics plugin which is not currently enabled."; 76 } 77 ?> 78 </div> 35 79 </td> 36 <td class='rhj4_plugins_comment'>Select notification type</td>37 80 </tr> 38 <tr>39 <td class='rhj4_plugins_input'>Source:40 <span>Browser:<input name="messageSource" type="radio" value="browser" /></span>41 <span>Server:<input name="messageSource" type="radio" value="server" checked="checked" />42 </td>43 <td class='rhj4_plugins_comment'>Select notification source</td>44 </tr>45 <tr>46 <td class='rhj4_plugins_input'>Sticky:47 <input id="messageIsSticky" type="checkbox" /></td>48 <td class='rhj4_plugins_comment'>Check if notification should remain on screen</td></tr>49 <tr><td class='rhj4_plugins_input'>Auto-Drain:50 <input id="autoDrainQueue" type="checkbox" />51 <td class='rhj4_plugins_comment'>Check if queue should be drained immediately</td></tr>52 81 </table> 53 <table class='rhj4_plugins_buttons'>54 <tr><td>Generate Notifications:55 <input type="button" value="Single" onclick="do_notification_submit();return false;" />56 <input type="button" value="Multiple" onclick="do_notification_submit_all();return false;" />57 <span id="queue_size"></span>58 <input id="drain" type="button" value="Drain Queue" onclick="do_notification_drain_queue();return false;"/>59 <span id='queuing' class='blink'>Queuing...</span>60 </td></tr></table>61 82 </div> 62 83 <hr /> … … 77 98 'source' => 'Notification Demo'); 78 99 // Initialize the plugin 79 $diags = RHJ4Diagnostics::instance(); 100 if (is_plugin_active('rhj4-diagnostics/rh4_diagnostics.php')) { 101 $diags = RHJ4Diagnostics::instance(); 80 102 81 // Set error handler to process all errors 82 error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE); 83 set_error_handler(array($diags,'error_handler')); 103 // Set error handler to process all errors 104 error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE); 105 set_error_handler(array($diags,'error_handler')); 106 } 84 107 85 108 // Write the plugin name into the output stream -
rhj4-notifications/trunk/js/demo.js
r993970 r995138 17 17 check_for_autodrain(); 18 18 do_notification_check_queue(); 19 do_show_diagnostic_log(); 19 20 }); 20 21 21 22 } 22 23 24 function do_show_diagnostic_log() { 25 jQuery.diagnostic.show(function(data) { 26 jQuery('.plugin_log').html(data); 27 }); 28 } 29 30 function do_clear_diagnostic_log() { 31 jQuery.diagnostic.clear(function(data) { 32 jQuery('.plugin_log').html(data); 33 }); 34 } 35 23 36 function do_notification_submit_single(messageText, messageType, messageIsSticky, handler) { 24 37 var messageSource = jQuery("input:radio[name='messageSource']:checked").val(); 25 jQuery.diagnostic('Type: ' + messageType + ', Source: ' + messageSource + ', Sticky: ' + messageIsSticky + ':[' + messageText + ']', 'notification demo.single'); 26 if (messageSource === 'browser') { 27 jQuery.notification(messageText, messageType, messageIsSticky); 28 } else { 29 jQuery.diagnostic('saving message to server', 'notification demo'); 30 jQuery.notification.save( 31 messageText, messageType, messageIsSticky, 32 function(result) { 33 if (handler) { 34 handler(result); 35 } 38 try { 39 jQuery.diagnostic('Type: ' + messageType + ', Source: ' + messageSource + ', Sticky: ' + messageIsSticky + ':[' + messageText + ']', 'notification demo.single'); 40 if (messageSource === 'browser') { 41 jQuery.notification(messageText, messageType, messageIsSticky); 42 } else { 43 jQuery.diagnostic('saving message to server', 'notification demo'); 44 } 45 } catch (err) { 46 } 47 jQuery.notification.save( 48 messageText, messageType, messageIsSticky, 49 function(result) { 50 if (handler) { 51 handler(result); 36 52 } 37 );38 }53 } 54 ); 39 55 } 40 56 … … 152 168 153 169 jQuery(document).ready(function (jQuery) { 154 jQuery.diagnostic('Notifications Demo loaded','notification demo'); 170 try { 171 jQuery.diagnostic('Notifications Demo loaded','notification demo'); 172 } catch (err) { 173 } 174 155 175 hide_queuing(); 156 176 hide_queue(); -
rhj4-notifications/trunk/js/jquery.notifications.js
r993970 r995138 539 539 catch (err) { 540 540 //Handle errors here 541 $.diagnostic('Notifications Error: ' + err, 'jGrowl');542 541 return -1; 543 542 } -
rhj4-notifications/trunk/readme.htm
r994700 r995138 73 73 74 74 <h3>Description</h3> 75 <p>RHJ4 Notifications solves a problem that hasplagued programmers for years: How to communicate with users in a clean, clear and visually consistent fashion regardless of where in the program the message originates.</p>75 <p>RHJ4 Notifications and its sibling, RHJ4 Diagnostics solve problems that have plagued programmers for years: How to communicate with users in a clean, clear and visually consistent fashion regardless of where in the program the message originates.</p> 76 76 77 77 <p>A notification message can be sent from jQuery code in the browser or from PHP code in the server. Either type of message can be displayed immediately or queued for display after the next page turn.</p> … … 133 133 <h3>Upgrade Notice</h3> 134 134 <dl> 135 <dt>1.2</dt> 136 <dd>Overhauled demo.php to use AJAX calls to RHJ4 Diagnostics. It now displays the current Diagnostic log file updates as they happen.</dd> 137 <dt>1.12</dt> 138 <dd>Very small cosmetic fixes.</dd> 135 139 <dt>1.0</dt> 136 140 <dd>Initial version</dd> 137 <dt>1.12</dt>138 <dd>Very small cosmetic fixes.</dd>139 141 </dl> 140 142 -
rhj4-notifications/trunk/readme.txt
r994700 r995138 13 13 == Description == 14 14 15 RHJ4 Notifications solves a problem that hasplagued programmers for years: How to communicate with users in a clean, clear and visually consistent fashion regardless of where in the program the message originates.15 RHJ4 Notifications and its sibling, RHJ4 Diagnostics solve problems that have plagued programmers for years: How to communicate with users in a clean, clear and visually consistent fashion regardless of where in the program the message originates. 16 16 17 17 A notification message can be sent from jQuery code in the browser or from PHP code in the server. Either type of message can be displayed immediately or queued for display after the next page turn. … … 68 68 == Changelog == 69 69 70 = 1.2 = 71 72 Overhauled demo.php to use AJAX calls to RHJ4 Diagnostics. It now displays the current Diagnostic log file updates as they happen. 73 74 = 1.12 = 75 76 Very small cosmetic fixes. 77 70 78 = 1.1 = 71 79 72 80 Completed testing and documentation. First public release. 73 74 = 1.12 =75 76 Very small cosmetic fixes.77 81 78 82 == Upgrade Notice == -
rhj4-notifications/trunk/rhj4_notifications.php
r994700 r995138 4 4 Plugin URI: http://bellinghamwordpressdevelopers.com/donate/ 5 5 Description: Integrates jGrowl jQuery plugin into WordPress, enabling creation of jGrowl messages from anywhere in the code. 6 Version: 1. 126 Version: 1.2 7 7 Author: Bob Jones 8 8 Author Email: bob@rhj4.com … … 160 160 $this->register_scripts_and_styles(); 161 161 162 /** 163 * Generate hidden fields required to connect with server code 164 */ 165 add_action('wp_head', 'rhj4_notifications_generate_hidden_inputs'); 166 167 /** 168 * Enable saving of notifications from javaScript code 169 */ 170 add_action('wp_ajax_nopriv_rhj4_notifications_save','rhj4_notifications_save'); 171 172 /** 173 174 * Enable listing of session notifications 175 */ 176 add_action('wp_ajax_nopriv_rhj4_notifications_list_by_session','rhj4_notifications_list_by_session'); 177 add_action('wp_ajax_nopriv_rhj4_notifications_session_queue_size','rhj4_notifications_session_queue_size'); 178 179 add_action('wp_ajax_nopriv_rhj4_notifications_delete_by_session','rhj4_notifications_delete_by_session'); 180 181 /** 182 * Enable return of plugin url 183 */ 184 add_action('wp_ajax_nopriv_rhj4_notifications_plugin_url','rhj4_notifications_plugin_url'); 185 186 /** 187 * Enable return of session id 188 */ 189 add_action('wp_ajax_nopriv_rhj4_notifications_session_id','rhj4_notifications_session_id'); 190 //this will run when on the frontend 162 /** 163 * Generate hidden fields required to connect with server code 164 */ 165 add_action('wp_head', 'rhj4_notifications_generate_hidden_inputs'); 166 167 /** 168 * Enable saving of notifications from javaScript code 169 */ 170 add_action('wp_ajax_nopriv_rhj4_notifications_save','rhj4_notifications_save'); 171 172 /** 173 174 * Enable listing of session notifications 175 */ 176 add_action('wp_ajax_nopriv_rhj4_notifications_list_by_session','rhj4_notifications_list_by_session'); 177 add_action('wp_ajax_nopriv_rhj4_notifications_session_queue_size','rhj4_notifications_session_queue_size'); 178 179 add_action('wp_ajax_nopriv_rhj4_notifications_delete_by_session','rhj4_notifications_delete_by_session'); 180 181 /** 182 * Enable return of plugin url 183 */ 184 add_action('wp_ajax_nopriv_rhj4_notifications_plugin_url','rhj4_notifications_plugin_url'); 185 186 /** 187 * Enable return of session id 188 */ 189 add_action('wp_ajax_nopriv_rhj4_notifications_session_id','rhj4_notifications_session_id'); 190 191 //this will run when on the frontend 191 192 192 193 if (is_admin() ) { … … 209 210 210 211 public function activate() { 211 rhj4_diagnostic('RHJ4 Notifications Activated'); 212 if (is_plugin_active('rhj4-diagnostics/rhj4_diagnostics.php')) { 213 rhj4_diagnostic('RHJ4 Notifications Activated'); 214 } else { 215 echo 'RHJ4 Diagnostics not installed and active'; 216 } 212 217 } 213 218 214 219 public function deactivate() { 215 220 // We cannot use notification here because it has been deactivated 216 rhj4_diagnostic('RHJ4 Notifications Deactivated'); 217 } 218 221 } 222 223 private function diag($message) { 224 if (is_plugin_active('rhj4-diagnostics/rhj4_diagnostics.php')) { 225 rhj4_diagnostic($message); 226 } 227 } 228 219 229 public function render_shortcode($atts) { 220 230 // … … 306 316 // Present demo panel 307 317 if ($atts['demo']) { 308 rhj4_diagnostic('Rendering Notifications Demo',318 $this->diag('Rendering Notifications Demo', 309 319 array('enabled' => true, 'source' => 'RHJ4 Notifications: ')); 310 320 $path = plugin_dir_path(__FILE__); … … 405 415 406 416 default: 407 if (function_exists(error_log)) { 408 error_log('unknown/invalid option key: ['.$key.']'); 409 } 417 echo 'unknown/invalid option key: ['.$key.']'; 410 418 } 411 419 } … … 1007 1015 1008 1016 $notify->save($message, $type, $is_sticky); 1009 1017 $notify->report("Notification [".$message."]"); 1018 1010 1019 // If an error was found, report_database_error will return true 1011 1020 if (!$notify->report_database_error('saving notification')) { … … 1144 1153 } 1145 1154 1155 function rhj4_notifications_start_session() { 1156 if(!session_id()) { 1157 session_start(); 1158 } 1159 } 1160 1161 function rhj4_notifications_logout() { 1162 session_destroy (); 1163 } 1164 1165 function rhj4_notifications_login() { 1166 if(!session_id()) { 1167 session_start(); 1168 } 1169 } 1170 1171 function rhj4_notifications_initialize($args = NULL) { 1172 $instance = RHJ4Notifications::instance(); 1173 if (!$instance->initialized) { 1174 $instance->init($args); 1175 } 1176 } 1177 1146 1178 /** 1147 1179 * Actions to be performed under various conditions 1148 1180 */ 1149 1181 1182 add_action('wp_logout', 'rhj4_notifications_logout'); 1183 add_action('wp_login', 'rhj4_notifications_login'); 1150 1184 add_action('init', 'rhj4_notifications_start_session', 1); 1151 function rhj4_notifications_start_session() {1152 if(!session_id()) {1153 session_start();1154 }1155 }1156 1157 add_action('wp_logout', 'rhj4_notifications_logout');1158 function rhj4_notifications_logout() {1159 session_destroy ();1160 }1161 1162 add_action('wp_login', 'rhj4_notifications_login');1163 function rhj4_notifications_login() {1164 if(!session_id()) {1165 session_start();1166 }1167 }1168 1169 1185 add_action('init','rhj4_notifications_initialize'); 1170 function rhj4_notifications_initialize($args = NULL) {1171 $diags = RHJ4Diagnostics::instance();1172 if (!$diags->initialized || !$diags->enabled) {1173 $diags->init(array('enabled' => true));1174 }1175 1176 $instance = RHJ4Notifications::instance();1177 if (!$instance->initialized) {1178 $instance->init($args);1179 }1180 1181 if (!empty($diags)) {1182 // $diags->diagnostic($instance->plugin_name. ' initialized');1183 }1184 }1185 1186 1186 1187 /**
Note: See TracChangeset
for help on using the changeset viewer.