From 7e303dc73d01ab90ee503b5cfe80a05d385bc2b3 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 18 Feb 2010 14:12:52 +0000 Subject: [PATCH] whitespace consistency --- contrib/blotter/main.php | 110 +++++++++++++------------- contrib/blotter/theme.php | 160 +++++++++++++++++++------------------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/contrib/blotter/main.php b/contrib/blotter/main.php index dbbc92a1..4fa16f2d 100644 --- a/contrib/blotter/main.php +++ b/contrib/blotter/main.php @@ -20,20 +20,20 @@ class Blotter extends SimpleExtension { * * REMINDER: If I change the database tables, I must change up version by 1. */ - if($version < 1) { - /** - * Installer - */ + if($version < 1) { + /** + * Installer + */ global $database, $config; - $database->create_table("blotter", - "id SCORE_AIPK - , entry_date SCORE_DATETIME DEFAULT SCORE_NOW - , entry_text TEXT NOT NULL - , important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N - "); + $database->create_table("blotter", " + id SCORE_AIPK, + entry_date SCORE_DATETIME DEFAULT SCORE_NOW, + entry_text TEXT NOT NULL, + important SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N + "); // Insert sample data: $database->execute("INSERT INTO blotter (id, entry_date, entry_text, important) VALUES (?, now(), ?, ?)", - array(NULL, "Installed the blotter extension!", "Y")); + array(NULL, "Installed the blotter extension!", "Y")); log_info("blotter", "Installed tables for blotter extension."); $config->set_int("blotter_version", 1); } @@ -61,71 +61,73 @@ class Blotter extends SimpleExtension { if($event->page_matches("blotter")) { switch($event->get_arg(0)) { case "editor": - /** - * Displays the blotter editor. - */ + /** + * Displays the blotter editor. + */ global $database, $user; - if(!$user->is_admin()) { - $this->theme->display_permission_denied($page); - } else { - $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC"); - $this->theme->display_editor($entries); - } - break; + if(!$user->is_admin()) { + $this->theme->display_permission_denied($page); + } else { + $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC"); + $this->theme->display_editor($entries); + } + break; case "add": /** * Adds an entry */ global $page, $database, $user; - if(!$user->is_admin()) { - $this->theme->display_permission_denied($page); - } else { - $entry_text = $_POST['entry_text']; - if($entry_text == "") { die("No entry message!"); } - if(isset($_POST['important'])) { $important = 'Y'; } else { $important = 'N'; } - // Now insert into db: - $database->execute("INSERT INTO blotter (id, entry_date, entry_text, important) VALUES (?, now(), ?, ?)", - array(NULL, $entry_text, $important)); - log_info("blotter", "Added Message: $entry_text"); - $page->set_mode("redirect"); - $page->set_redirect(make_link("blotter/editor")); - } - break; + if(!$user->is_admin()) { + $this->theme->display_permission_denied($page); + } else { + $entry_text = $_POST['entry_text']; + if($entry_text == "") { die("No entry message!"); } + if(isset($_POST['important'])) { $important = 'Y'; } else { $important = 'N'; } + // Now insert into db: + $database->execute("INSERT INTO blotter (id, entry_date, entry_text, important) VALUES (?, now(), ?, ?)", + array(NULL, $entry_text, $important)); + log_info("blotter", "Added Message: $entry_text"); + $page->set_mode("redirect"); + $page->set_redirect(make_link("blotter/editor")); + } + break; case "remove": /** * Removes an entry */ global $page, $database, $user; - if(!$user->is_admin()) { - $this->theme->display_permission_denied($page); - } else { - $id = $_POST['id']; - if(!isset($id)) { die("No ID!"); } - $database->Execute("DELETE FROM blotter WHERE id=$id"); - log_info("blotter", "Removed Entry #$id"); - $page->set_mode("redirect"); - $page->set_redirect(make_link("blotter/editor")); - } - break; + if(!$user->is_admin()) { + $this->theme->display_permission_denied($page); + } else { + $id = int_escape($_POST['id']); + if(!isset($id)) { die("No ID!"); } + $database->Execute("DELETE FROM blotter WHERE id=$id"); + log_info("blotter", "Removed Entry #$id"); + $page->set_mode("redirect"); + $page->set_redirect(make_link("blotter/editor")); + } + break; case "": /** * Displays all blotter entries */ global $database, $user; - $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC"); - $this->theme->display_blotter_page($entries); - break; + $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC"); + $this->theme->display_blotter_page($entries); + break; } } - /** - * Finally, display the blotter on whatever page we're viewing. - */ - $this->display_blotter(); + /** + * Finally, display the blotter on whatever page we're viewing. + */ + $this->display_blotter(); } + private function display_blotter() { global $database, $config; $limit = $config->get_int("blotter_recent", 5); $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC LIMIT 0,$limit"); $this->theme->display_blotter($entries); } -} \ No newline at end of file +} +?> diff --git a/contrib/blotter/theme.php b/contrib/blotter/theme.php index db809983..3ea3bc2b 100644 --- a/contrib/blotter/theme.php +++ b/contrib/blotter/theme.php @@ -1,63 +1,63 @@ -get_html_for_blotter_editor($entries); $page->set_title("Blotter Editor"); $page->set_heading("Blotter Editor"); - $page->add_block(new Block("Welcome to the Blotter Editor!", $html, "main", 10)); - $page->add_block(new Block("Navigation", "Index", "left", 0)); + $page->add_block(new Block("Welcome to the Blotter Editor!", $html, "main", 10)); + $page->add_block(new Block("Navigation", "Index", "left", 0)); } - + public function display_blotter_page($entries) { global $page; $html = $this->get_html_for_blotter_page($entries); $page->set_mode("data"); $page->set_data($html); } - + public function display_blotter($entries) { global $page, $config; $html = $this->get_html_for_blotter($entries); $position = $config->get_string("blotter_position", "subheading"); $page->add_block(new Block(null, $html, $position, 20)); } - + private function is_odd($number) { - return $number & 1; // 0 = even, 1 = odd + return $number & 1; // 0 = even, 1 = odd } - + private function get_html_for_blotter_editor($entries) { /** * Long function name, but at least I won't confuse it with something else ^_^ */ $html = ""; - // Add_new stuff goes here. - $table_header = " - - Date - Message - Important? - Action - "; - $add_new = " - -
- - - -
- "; + // Add_new stuff goes here. + $table_header = " + + Date + Message + Important? + Action + "; + $add_new = " + +
+ + + +
+ "; // Now, time for entries list. $table_rows = ""; - for ($i = 0 ; $i < count($entries) ; $i++) - { - /** - * Add table rows - */ + for ($i = 0 ; $i < count($entries) ; $i++) + { + /** + * Add table rows + */ $id = $entries[$i]['id']; $entry_date = $entries[$i]['entry_date']; $entry_text = $entries[$i]['entry_text']; @@ -68,31 +68,31 @@ class BlotterTheme extends Themelet { // Add the new table row(s) $table_rows .= "$entry_date - $entry_text - $important -
- - -
- + $entry_date + $entry_text + $important +
+ + +
+ "; } $html = " - $table_header - $add_new - $table_rows + $table_header + $add_new + $table_rows

Help:
Add entries to the blotter, and they will be displayed.
"; - + return $html; } - + private function get_html_for_blotter_page($entries) { /** * This one displays a list of all blotter entries. @@ -101,14 +101,14 @@ class BlotterTheme extends Themelet { $i_color = $config->get_string("blotter_color","#FF0000"); $html = ""; $html .= "Blotter -
";
+			
";
 
-        for ($i = 0 ; $i < count($entries) ; $i++)
-        {
-		/**
-		 * Blotter entries
-		 */
-		 	// Reset variables:
+		for ($i = 0 ; $i < count($entries) ; $i++)
+		{
+			/**
+			 * Blotter entries
+			 */
+			// Reset variables:
 			$i_open = "";
 			$i_close = "";
 			$id = $entries[$i]['id'];
@@ -122,7 +122,7 @@ class BlotterTheme extends Themelet {
 		$html .= "
"; return $html; } - + private function get_html_for_blotter($entries) { /** * Show the blotter widget @@ -132,35 +132,33 @@ class BlotterTheme extends Themelet { $i_color = $config->get_string("blotter_color","#FF0000"); $position = $config->get_string("blotter_position", "subheading"); $html = ""; +#blotter1 {font-size: 80%; position: relative;} +#blotter2 {font-size: 80%;} +"; $html .= ""; +$(document).ready(function() { + $(\"#blotter2-toggle\").click(function() { + $(\"#blotter2\").slideToggle(\"slow\", function() { + if($(\"#blotter2\").is(\":hidden\")) { + $.cookie(\"blotter2-hidden\", 'true', {path: '/'}); + } + else { + $.cookie(\"blotter2-hidden\", 'false', {path: '/'}); + } + }); + }); + if($.cookie(\"blotter2-hidden\") == 'true') { + $(\"#blotter2\").hide(); + } +}); +//-->"; $entries_list = ""; - for ($i = 0 ; $i < count($entries) ; $i++) - { - /** - * Blotter entries - */ - // Reset variables: + for ($i = 0 ; $i < count($entries) ; $i++) + { + /** + * Blotter entries + */ + // Reset variables: $i_open = ""; $i_close = ""; $id = $entries[$i]['id']; @@ -175,14 +173,14 @@ class BlotterTheme extends Themelet { $pos_break = ""; $pos_align = "text-align: right; position: absolute; right: 0px;"; if($position == "left") { $pos_break = "
"; $pos_align = ""; } - if (count($entries) == 0) { $out_text = "No blotter entries yet."; $in_text = "Empty.";} + if(count($entries) == 0) { $out_text = "No blotter entries yet."; $in_text = "Empty.";} else { $clean_date = date("m/d/y",strtotime($entries[0]['entry_date'])); - $out_text = "Blotter updated: {$clean_date}"; - $in_text = ""; + $out_text = "Blotter updated: {$clean_date}"; + $in_text = ""; } $html .= "
$out_text{$pos_break}Show/Hide Show All
"; $html .= "
$in_text
"; return $html; } } -?> \ No newline at end of file +?>