From b57a63c644d7b21b45606a30885be7c2847b7228 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 26 Feb 2018 10:33:12 -0500 Subject: [PATCH] Write out HLP.html for mack bridge. Also update last_update with date and time. --- index.php | 6 +- models/admin/conditions/index.php | 63 +++- .../create_database_V0.0.2.sql | 4 +- views/front/conditions/HLP.html | 313 ++++++++++++++++++ 4 files changed, 371 insertions(+), 15 deletions(-) create mode 100644 views/front/conditions/HLP.html diff --git a/index.php b/index.php index a88ec80..be77063 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Conditions * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.0.2 + * Version: 1.0.4 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabaseConditionsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.2 + * @version 1.0.4 */ /* @@ -37,7 +37,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_CONDITIONS_PLUGIN_VERSION', '1.0.2'); +define('GLM_MEMBERS_CONDITIONS_PLUGIN_VERSION', '1.0.4'); define('GLM_MEMBERS_CONDITIONS_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/admin/conditions/index.php b/models/admin/conditions/index.php index 09cec97..05872a8 100644 --- a/models/admin/conditions/index.php +++ b/models/admin/conditions/index.php @@ -108,12 +108,12 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { $option = $_REQUEST['option']; } - + $selected_condition = 0; if (isset($_REQUEST['selected_condition']) && trim($_REQUEST['selected_condition']) != '') { $selected_condition = $_REQUEST['selected_condition']; } - + $cond_id = 0; if (isset($_REQUEST['cond_id']) && trim($_REQUEST['cond_id']) != '') { $cond_id = $_REQUEST['cond_id']; @@ -130,7 +130,7 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions $selected_condition = $this->wpdb->get_results( $sql, ARRAY_A ); $success_message = "Update Successful"; break; - + default: if (isset($_POST['condition_edit']) && trim($_REQUEST['condition_edit']) != '') { if (isset($_REQUEST['condition_name']) && trim($_REQUEST['condition_name']) != '') { @@ -147,14 +147,18 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions } $sql = "UPDATE ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."conditions C - SET C.name='$condition_name', C.descr='$condition_descr', C.descr_short='$condition_descr_short' + SET C.name='$condition_name', + C.descr='$condition_descr', + C.descr_short='$condition_descr_short', + C.last_update = now() WHERE C.id = $cond_id "; $this->wpdb->get_results( $sql ); $success_message = "Update Successful"; + $this->writeHighLoadPage(); break; } - + if (isset($_POST['condition_update']) && trim($_POST['condition_selected']) != '') { if (isset($_REQUEST['condition_selected']) && trim($_REQUEST['condition_selected']) != '') { $selected_condition = $_REQUEST['condition_selected']; @@ -163,13 +167,16 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions $condition_current_additional = $_REQUEST['condition_current_additional']; } $sql = "UPDATE ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."current_condition CC - SET CC.cond_id='$selected_condition', CC.additional='$condition_current_additional' + SET CC.cond_id='$selected_condition', + CC.additional='$condition_current_additional', + CC.last_update = now() WHERE CC.id = 1 "; $this->wpdb->get_results( $sql ); $success_message = "Update Successful"; + $this->writeHighLoadPage(); } - + $sql = "SELECT C.* FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."conditions C WHERE C.id = ( @@ -179,18 +186,18 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions $selected_condition = $this->wpdb->get_results( $sql, ARRAY_A ); break; } - + $sql = " SELECT C.* FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."conditions C "; $condition_list = $this->wpdb->get_results( $sql, ARRAY_A ); - + $sql = "SELECT CC.* FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."current_condition CC "; $current_condition = $this->wpdb->get_results( $sql, ARRAY_A ); - + // Compile template data $templateData = array( 'conditionList' => $condition_list, @@ -209,4 +216,40 @@ class GlmMembersAdmin_conditions_index extends GlmDataConditions } + public function writeHighLoadPage() + { + // Setup the Smarty Engine + $smarty = new smartyTemplateSupport(); + $viewPath = GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/views'; + $smarty->template->setTemplateDir( $viewPath ); + + // Add standard parameters + require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php'; + $viewFile = GLM_MEMBERS_CONDITIONS_PLUGIN_PATH . '/views/front/conditions/HLP.html'; + + $sql = "SELECT CC.* + FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."current_condition CC + "; + $current_condition = $this->wpdb->get_row( $sql, ARRAY_A ); + + $sql = "SELECT C.* + FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."conditions C + WHERE C.id = ( + SELECT CC.cond_id + FROM ".GLM_MEMBERS_CONDITIONS_PLUGIN_DB_PREFIX."current_condition CC + )"; + $selected_condition = $this->wpdb->get_row( $sql, ARRAY_A ); + + $smarty->templateAssign( 'condition', $selected_condition ); + $smarty->templateAssign( 'additional', $current_condition['additional'] ); + $smarty->templateAssign( 'last_update', $current_condition['last_update'] ); + + // Generate output from model data and view + $htmlOutput = $smarty->template->fetch( $viewFile ); + + // Write the file out + $site_path = get_home_path(); + file_put_contents( $site_path . 'HLP.html', $htmlOutput ); + } + } diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql index 4ffbc40..508f723 100644 --- a/setup/databaseScripts/create_database_V0.0.2.sql +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -17,7 +17,7 @@ CREATE TABLE {prefix}conditions ( name TEXT NOT NULL, descr_short TEXT NULL, descr TEXT NULL, - last_update DATE NULL, + last_update DATETIME NULL, PRIMARY KEY (id) ); @@ -28,7 +28,7 @@ CREATE TABLE {prefix}current_condition ( id INT NOT NULL AUTO_INCREMENT, cond_id INT NOT NULL, additional TEXT NULL, - last_update DATE NULL, + last_update DATETIME NULL, PRIMARY KEY (id) ); diff --git a/views/front/conditions/HLP.html b/views/front/conditions/HLP.html new file mode 100644 index 0000000..6b33858 --- /dev/null +++ b/views/front/conditions/HLP.html @@ -0,0 +1,313 @@ + + + + + + Mackinac Bridge Authority + + + +
+
+
+
+ +
+

Mackinac Bridge Authority

+

Spanning the Straits of Mackinac since 1957

+
+ Embedded Header Bridge Image +
+
+ +
+
+
+
+
+
+
+

{$condition.name}

+

{$condition.descr|nl2br}

+ {if $additional}

{$additional|nl2br}

{/if} +

Monitoring of weather conditions will be ongoing

+

To sign up for Mackinac Bridge alerts, text "MacBridge" to 67283

+
+
+
+
+

Camera #2 from St. Ignace looking south

+

Looking South

+
+
+ +
+

Camera #4 from Mackinaw City looking north

+

Looking North

+
+
+ +
+
+
+
+ +
+ + +
+
+ + + -- 2.17.1