some small tweaks, but mostly adding favorites and rss-able version of the gallery
authorToby Elliott <telliott@mozilla.com>
Tue, 09 Jun 2009 10:49:46 -0700
changeset 1007 0de4652a64ddcc106ebb6d544a3f4e0dc70efd24
parent 1006 c24785292d11c77098c0e6e0ad428869f25fba95
child 1008 cb6d129d137d46faf5fb0a6bd6d8f4bfc357fe34
child 1009 76a39d37aa0a468ada6990d8e4461b40274b2f1b
push id636
push usertelliott@mozilla.com
push dateTue, 09 Jun 2009 17:49:52 +0000
some small tweaks, but mostly adding favorites and rss-able version of the gallery
server/favorite.php
server/lib/storage.php
server/personadetail.php
server/templates/gallery.php
server/templates/gallery_rss.php
server/templates/persona_detail.php
server/viewpersonas.php
new file mode 100644
--- /dev/null
+++ b/server/favorite.php
@@ -0,0 +1,75 @@
+<?php
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Personas Server
+#
+# The Initial Developer of the Original Code is
+# Mozilla Labs.
+# Portions created by the Initial Developer are Copyright (C) 2008
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#	Toby Elliott (telliott@mozilla.com)
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+	
+	require_once 'lib/personas_constants.php';
+	require_once 'lib/personas_functions.php';
+	require_once 'lib/storage.php';
+	require_once 'lib/user.php';
+
+	
+	$path = array_key_exists('PATH_INFO', $_SERVER) ? $_SERVER['PATH_INFO'] : '/';
+	$path = substr($path, 1); #chop the lead slash
+	list($id) = explode('/', $path);
+	
+	$user = new PersonaUser();
+
+	$auth_user = $user->authenticate();
+	if (!$auth_user)
+	{
+		#should improve this at some point...
+		echo 0;
+		exit;
+	}
+	
+	if (!array_key_exists('action', $_GET))
+	{
+		echo 0;
+		exit;
+	}
+	
+	$db = new PersonaStorage();
+	
+	
+	if ($_GET['action'])
+		echo $db->add_user_favorite($user->get_username(), $id);
+	else
+		echo $db->delete_user_favorite($user->get_username(), $id);
+
+?>
+
--- a/server/lib/storage.php
+++ b/server/lib/storage.php
@@ -1088,10 +1088,149 @@ class PersonaStorage
 
 		if ($this->_memcache)
 		{
 			$this->_memcache->delete("categories");
 		}
 		return 1;
 	}
 	
+	function get_user_favorites($username, $category = 'All')
+	{
+		if (!$username)
+			return array();
+			
+		if ($this->_memcache)
+		{
+			$result = $this->_memcache->get("fav." . $category . "." . $username);
+			if ($result)
+				return $result;
+		}
+
+		if (!$this->_dbh)
+			$this->db_connect();		
+
+		try
+		{
+			$statement = 'select personas.*, favorites.added from personas, favorites where personas.id = favorites.id and favorites.username = ?';
+			$params = array($username);
+			if ($category != 'All')
+			{
+				$statement .= " and personas.category = ?";
+				$params[] = $category;
+			}
+			$statement .= ' order by favorites.added desc';
+			$sth = $this->_dbh->prepare($statement);
+			$sth->execute($params);
+		}
+		catch( PDOException $exception )
+		{
+			error_log($exception->getMessage());
+			throw new Exception("Database unavailable", 503);
+		}
+		
+		$results = array();
+		
+		while ($result = $sth->fetch(PDO::FETCH_ASSOC))
+		{
+			$results[] = $result;
+		}		
+
+		if ($this->_memcache)
+			$this->_memcache->set("fav." . $category . "." . $username, $results, MEMCACHE_DECAY);
+
+		return $results;
+		
+	}
+	
+	function is_favorite_persona($username, $persona_id)
+	{
+		if (!$username || !$persona_id)
+			return 0;
+
+		if (!$this->_dbh)
+			$this->db_connect();		
+
+		try
+		{
+			$select_stmt = 'select count(*) from favorites where username = :username and id = :id';
+			$sth = $this->_dbh->prepare($select_stmt);
+			$sth->bindParam(':username', $username);
+			$sth->bindParam(':id', $persona_id);
+			$sth->execute();
+		}
+		catch( PDOException $exception )
+		{
+			error_log("is_favorite: " . $exception->getMessage());
+			throw new Exception("Database unavailable", 503);
+		}
+
+		$result = $sth->fetchColumn();
+		return $result ? 1 : 0;
+	
+	}
+	
+	function add_user_favorite($username, $persona_id)
+	{
+		if (!$username || !$persona_id)
+			return 0;
+			
+		if (!$this->_dbh)
+			$this->db_connect();		
+
+		try
+		{
+			$stmt = 'replace into favorites (username, id, added) values (:username, :id, NOW())';
+			$sth = $this->_dbh->prepare($stmt);
+			$sth->bindParam(':username', $username);
+			$sth->bindParam(':id', $persona_id);
+			$sth->execute();
+
+		}
+		catch( PDOException $exception )
+		{
+			error_log("add_user_favorite: " . $exception->getMessage());
+			throw new Exception("Database unavailable");
+		}
+
+		if ($this->_memcache)
+		{
+			$this->_memcache->delete("fav." . $category . "." . $username);
+			$this->_memcache->delete("fav.All." . $username);
+		}
+
+		return 1;		
+		
+	}
+	
+	function delete_user_favorite($username, $persona_id)
+	{
+		if (!$username || !$persona_id)
+			return 0;
+
+		if (!$this->_dbh)
+			$this->db_connect();		
+
+		try
+		{
+			$stmt = 'delete from favorites where username = :username and id = :id';
+			$sth = $this->_dbh->prepare($stmt);
+			$sth->bindParam(':username', $username);
+			$sth->bindParam(':id', $persona_id);
+			$sth->execute();
+
+		}
+		catch( PDOException $exception )
+		{
+			error_log("delete favorite: " . $exception->getMessage());
+			throw new Exception("Database unavailable");
+		}
+
+		if ($this->_memcache)
+		{
+			$this->_memcache->delete("fav." . $category . "." . $username);
+			$this->_memcache->delete("fav.All." . $username);
+		}
+		return 1;
+		
+	}
 }
 ?>
\ No newline at end of file
--- a/server/personadetail.php
+++ b/server/personadetail.php
@@ -38,17 +38,17 @@
 
 	require_once 'lib/personas_constants.php';	
 	require_once 'lib/personas_functions.php';	
 	require_once 'lib/storage.php';
 	require_once 'lib/user.php';
 
 	$db = new PersonaStorage();
 	$user = new PersonaUser();
-	
+	$username = $user->authenticate();
 
 	$categories = $db->get_categories();
 	array_unshift($categories, 'All');
 	$category = null;
 	
 	$path = array_key_exists('PATH_INFO', $_SERVER) ? $_SERVER['PATH_INFO'] : '/';
 	$path = substr($path, 1); #chop the lead slash
 	list($persona_id) = explode('/', $path);
@@ -60,16 +60,17 @@
 	{
 		$persona_id = intval($persona_id);
 		$persona = $db->get_persona_by_id($persona_id);
 		$page_header = $persona['name'] . ' by ' . $persona['author'];
 		$category = $persona['category'];
 		$persona['json'] = htmlentities(json_encode(extract_record_data($persona)));
 	}
 
+	$favorite_persona = $username ? $db->is_favorite_persona($username, $persona_id) : null;
 	$url_prefix = '/gallery';
 	$tabs = null;
 	
 	$title = $persona['name']; 
 	include 'templates/header.php'; 
 ?>
 <body>
     <div id="outer-wrapper">
@@ -86,16 +87,32 @@
 			</div>
 <?php include 'templates/category_nav.php'; ?>
             
         </div>
     </div>
     
 <?php include 'templates/footer.php'; ?>
     <script type="text/javascript" charset="utf-8">
+		var favorite_action = <?= $favorite_persona ? 0 : 1 ?>;
+		function change_favorite()
+		{
+			//change to loading here
+			$("#favoritebutton").html("loading...");
+			$.get('/favorite/<?= $persona_id ?>', {"action": favorite_action}, 
+				function(data) 
+					{ 
+						favorite_action = favorite_action ? 0 : 1; 
+						$("#favoritebutton").html(favorite_action ? "Add to favorites" : "Remove from favorites"); 
+					}
+				);
+			
+			return false;
+		}
+
         $(document).ready(function () {
             $("#header").ie6Warning({"message":'<div id="ie6">Upgrade your browser to get the most out of this website. <a href="%LINK%">Download Firefox for free</a>.</div>'});
             $("#try-button").personasButton({
                                         'hasPersonas':'<span>wear this</span><span>&nbsp;</span>',
                                         'hasFirefox':'<span>get personas now!</span><span>&nbsp;</span>',
                                         'noFirefox':'<span>get personas with firefox</span><span>&nbsp;</span>'
                                         });
         });
new file mode 100644
--- /dev/null
+++ b/server/templates/gallery.php
@@ -0,0 +1,101 @@
+<?php
+	include 'header.php'; 
+?>
+<body>
+    <div id="outer-wrapper">
+        <div id="inner-wrapper">
+<?php include 'nav.php'; ?>
+<?php
+	if ($category == 'Designer' && file_exists("designer/$tab.php"))
+	{
+		include "designer/$tab.php";
+	}
+	else
+	{
+		if (!($category == 'Designer' && $header_text = $user->get_description($tab)))
+		{
+			$header_text = 'Your browser, your style! Dress it up with easy-to-change "skins" for your Firefox.';
+		}
+?>
+			<div id="header">
+                <h2><?= $page_header ?></h2>
+                <h3><?= $header_text ?></h3>
+            </div>
+<?php } ?>
+			<div id="maincontent">
+                <p id="breadcrumbs"><a href="http://www.getpersonas.com">Personas Home</a> : <a href="http://www.getpersonas.com/gallery/All/Popular">Gallery</a> : <?= $category ?><?php if ($category == 'Designer') { echo " : $display_username"; } else if ($tab != "All") { echo " : $tab"; } ?></p>
+                <div id="gallery">
+<?php
+			
+			if ($tab == 'Search')
+			{
+?>  
+				<form action="" method="GET">
+				    <input type=text name=p value='<?= array_key_exists('p', $_GET) ? $_GET['p'] : '' ?>'>
+				    <button class="button search" type="submit">
+                    <span>search</span>
+                    <span class="arrow"/>
+                    </button>
+				</form>
+<?php
+				if (count($list) == 0 && array_key_exists('p', $_GET))
+				{
+					echo "<p>We were unable to locate any personas that match those search terms. Please try again</p>";
+				}
+			}
+			elseif (count($list) == 0)
+			{
+				echo "<p>There are no personas available here. Please use the navigation on the left to choose another category.</p>";
+			}
+			
+			
+			
+			include 'pagination.php';
+?>
+					<ul>
+<?php
+			foreach ($list as &$persona)
+			{
+?>
+                        <li class="gallery-item">
+                            <div>
+                                <h3><?= $persona['name'] ?></h3>
+                                <div class="preview">
+                                    <a href="/persona/<?= ($persona['id'] < 10 ? "0" : "") . $persona['id'] ?>"><img src="<?= $persona['preview_url'] ?>" alt="<?= $persona['name'] ?>" persona="<?= $persona['json'] ?>"/></a>
+                                </div>
+                                <p class="designer"><strong>Designer:</strong> <a href="/gallery/Designer/<?= $persona['author'] ?>"><?= $persona['display_username'] ?></a></p>
+                                <p class="added"><strong>Added:</strong> <?= $persona['date'] ?></p>
+                                <p><?= $persona['short_description'] ?></p>
+                                <p><?= number_format($persona['popularity']) ?> active daily users</p>
+                                <p><a href="<?= "/persona/" . ($persona['id'] < 10 ? "0" : "") . $persona['id'] ?>" class="view">view details »</a></p>
+<?php
+				if ($user->has_admin_privs() || ($tab == 'My' && $persona['locale'] == PERSONAS_LOCALE))
+				{
+?>
+								<p><a href="/upload?id=<?= $persona['id'] ?>" target="_blank">Edit</a>
+								| 
+								<a href="/delete/<?= $persona['id'] ?>" target="_blank">Delete</a></p>
+<?php
+				}
+?>
+                            </div>
+                        </li>
+ <?php
+ 			}
+ ?>
+                    </ul>
+                    <?php if($category == 'Designer')  echo '<p><script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=df86b16e-195c-4917-ae28-61a1382ba281&amp;type=website&amp;send_services=&amp;post_services=facebook%2Cdigg%2Cdelicious%2Cybuzz%2Ctwitter%2Cstumbleupon%2Creddit%2Ctechnorati%2Cmixx%2Cblogger%2Ctypepad%2Cwordpress%2Cgoogle_bmarks%2Cwindows_live%2Cmyspace%2Cfark%2Cbus_exchange%2Cpropeller%2Cnewsvine%2Clinkedin"></script></p>'; ?>                    
+                </div>
+<?php include 'pagination.php'; ?>
+            </div>
+<?php include 'category_nav.php'; ?>
+        </div>
+    </div>
+<?php include 'footer.php'; ?>
+    <script type="text/javascript" charset="utf-8">
+        $(document).ready(function() {
+           $("#gallery .preview img").previewPersona();
+        });
+    </script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/server/templates/gallery_rss.php
@@ -0,0 +1,23 @@
+<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
+<channel>
+	<title>Personas - <?= $category ?> - <?= $tab ?></title>
+<link><?= $path ?></link>
+<description>Personas - <?= $category ?> - <?= $tab ?></description>
+<?php
+	foreach ($list as &$persona)
+	{
+?>
+	<item>
+		<title><?= $persona['name'] ?></title>
+		<link>http://getpersonas.com/persona/<?= $persona['id'] ?></link>
+		<description><?= $persona['description'] ?></description>
+		<media:content url="<?= $persona['header_url'] ?>" type="<?= $persona['media_type'] ?>">
+			<media:title><?= $persona['name'] ?></media:title>
+			<media:thumbnail url="<?= $persona['preview_url'] ?>" height="100" width="200"/>
+		</media:content>
+	</item>
+<?php
+	}
+?>
+</channel>
+</rss>
\ No newline at end of file
--- a/server/templates/persona_detail.php
+++ b/server/templates/persona_detail.php
@@ -23,17 +23,29 @@
 ?>
                 <p id="buttons">
                     <a href="#" class="button" id="try-button" persona="<?= $persona['json'] ?>"><span>try it now</span><span>&nbsp;</span></a>
                 </p>
                 
 <?php
 		if ($persona['popularity'])
 			print '<p class="numb-users">' . number_format($persona['popularity']) . ' active daily users</p>';
-	?>
+
+		if ($user->get_unauthed_username())
+		{
+			if ($favorite_persona)
+			{
+				echo '<a href="" id="favoritebutton" onClick="return change_favorite();">Remove from favorites</a>"';
+			}
+			else
+			{
+				echo '<a href="" id="favoritebutton" onClick="return change_favorite();">Add to favorites</a>"';			
+			}
+		}
+?>
 	<p><script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=df86b16e-195c-4917-ae28-61a1382ba281&amp;type=website&amp;send_services=&amp;post_services=facebook%2Cdigg%2Cdelicious%2Cybuzz%2Ctwitter%2Cstumbleupon%2Creddit%2Ctechnorati%2Cmixx%2Cblogger%2Ctypepad%2Cwordpress%2Cgoogle_bmarks%2Cwindows_live%2Cmyspace%2Cfark%2Cbus_exchange%2Cpropeller%2Cnewsvine%2Clinkedin"></script></p>
-	<?php
+<?php
 	} else {
 ?>            
                 <p class="description">We are unable to find this persona. Please return to the gallery and try again.</p>
 <?php
 	}
 ?>
--- a/server/viewpersonas.php
+++ b/server/viewpersonas.php
@@ -49,17 +49,17 @@
 	$description_max = 50; #truncated description size
 	$url_prefix = '/gallery'; #telling the templates the gallery root
 	$title = "Gallery"; #page title for the header template
 	$no_my = array_key_exists('no_my', $_GET) ? 1 : 0; #whether to display all the dynamic stuff
 	$display_username = '';
 	
 	$categories = $db->get_categories();
 	array_unshift($categories, 'All');
-	$tabs = array('Popular', 'Recent', 'All', 'My', 'Search'); # pulling 'Search'
+	$tabs = array('Popular', 'Recent', 'All', 'My', 'Favorites', 'Search'); # pulling 'Search'
 	
 	$path = array_key_exists('PATH_INFO', $_SERVER) ? $_SERVER['PATH_INFO'] : '/';
 	$path = substr($path, 1); #chop the lead slash
 	list($category, $tab, $page) = explode('/', $path.'//');
 
 	$category = ucfirst($category);
 	if ($category != 'Designer')
 	{
@@ -87,139 +87,60 @@
 	}
 	elseif ($tab == 'My')
 	{
 		$user->force_signin();
 		$page_header = "My Personas";
 		if ($user->get_username())
 			$list = $db->get_persona_by_author($user->get_username(), $category == 'All' ? null : $category);			
 	}
+	elseif ($tab == 'Favorites')
+	{
+		$user->force_signin();
+		$page_header = "My Favorite Personas";
+		if ($user->get_username())
+			$list = $db->get_user_favorites($user->get_username(), $category);			
+	}
 	elseif ($tab == 'Search')
 	{
 		if (array_key_exists('p', $_GET) && $_GET['p'])
 		{
 			$list = $db->search_personas($_GET['p'], $category, $page_size);
 		}
 	}
 	else #tab = all
 	{
 		$page_size = 501;
 		$page = is_numeric($page) ? $page : 1;
 		$start = ($page - 1) * $page_size;
 		$list = $db->get_recent_personas($category == 'All' ? null : $category, $page_size, $start);
 	}
 
-	include 'templates/header.php'; 
-
-?>
-<body>
-    <div id="outer-wrapper">
-        <div id="inner-wrapper">
-<?php include 'templates/nav.php'; ?>
-<?php
-	if ($category == 'Designer' && file_exists("templates/designer/$tab.php"))
+	if (array_key_exists('rss', $_GET))
 	{
-		include "templates/designer/$tab.php";
+		header("Content-Type: application/xml"); 
+		$types = array('png' => 'application/png', 'jpg' => 'application/jpg');
+		foreach ($list as &$persona)
+		{
+			$persona['header_url'] = 'http://www.getpersonas.com' . PERSONAS_LIVE_PREFIX . '/' . url_prefix($persona['id']) . '/' . $persona['header'];
+			$persona['preview_url'] ='http://www.getpersonas.com' .  PERSONAS_LIVE_PREFIX . '/' . url_prefix($persona['id']) . '/' . "preview.jpg";
+			$persona['media_type'] = $types[substr($persona['header'], -3)];
+		}
+		include 'templates/gallery_rss.php';
 	}
 	else
 	{
-		if (!($category == 'Designer' && $header_text = $user->get_description($tab)))
+		foreach ($list as &$persona)
 		{
-			$header_text = 'Your browser, your style! Dress it up with easy-to-change "skins" for your Firefox.';
-		}
-?>
-			<div id="header">
-                <h2><?= $page_header ?></h2>
-                <h3><?= $header_text ?></h3>
-            </div>
-<?php } ?>
-			<div id="maincontent">
-                <p id="breadcrumbs"><a href="http://www.getpersonas.com">Personas Home</a> : <a href="http://www.getpersonas.com/gallery/All/Popular">Gallery</a> : <?= $category ?><?php if ($category == 'Designer') { echo " : $display_username"; } else if ($tab != "All") { echo " : $tab"; } ?></p>
-                <div id="gallery">
-<?php
-			
-			if ($tab == 'Search')
-			{
-?>  
-				<form action="" method="GET">
-				    <input type=text name=p value='<?= array_key_exists('p', $_GET) ? $_GET['p'] : '' ?>'>
-				    <button class="button search" type="submit">
-                    <span>search</span>
-                    <span class="arrow"/>
-                    </button>
-				</form>
-<?php
-				if (count($list) == 0 && array_key_exists('p', $_GET))
-				{
-					echo "<p>We were unable to locate any personas that match those search terms. Please try again</p>";
-				}
-			}
-			elseif (count($list) == 0)
-			{
-				echo "<p>There are no personas available here. Please use the navigation on the left to choose another category.</p>";
-			}
-			
-			
-			
-			include 'templates/pagination.php';
-?>
-					<ul>
-<?php
-			foreach ($list as $persona)
+			$persona['preview_url'] = PERSONAS_LIVE_PREFIX . '/' . url_prefix($persona['id']) . '/' . "preview.jpg";
+			$persona['json'] = htmlentities(json_encode(extract_record_data($persona)));
+			$persona['date'] = date("n/j/Y", strtotime($persona['approve']));
+			$persona['short_description'] = $persona['description'];
+			if (strlen($persona['short_description']) > $description_max)
 			{
-				$preview_url = PERSONAS_LIVE_PREFIX . '/' . url_prefix($persona['id']) . '/' . "preview.jpg";
-				$persona['json'] = htmlentities(json_encode(extract_record_data($persona)));
-				$persona['date'] = date("n/j/Y", strtotime($persona['approve']));
-				$persona['short_description'] = $persona['description'];
-				if (strlen($persona['short_description']) > $description_max)
-				{
-					$persona['short_description'] = substr($persona['short_description'], 0, $description_max);
-					$persona['short_description'] = preg_replace('/ [^ ]+$/', '', $persona['short_description']) . '...';
-				}
-?>
-                        <li class="gallery-item">
-                            <div>
-                                <h3><?= $persona['name'] ?></h3>
-                                <div class="preview">
-                                    <a href="/persona/<?= ($persona['id'] < 10 ? "0" : "") . $persona['id'] ?>"><img src="<?= $preview_url ?>" alt="<?= $persona['name'] ?>" persona="<?= $persona['json'] ?>"/></a>
-                                </div>
-                                <p class="designer"><strong>Designer:</strong> <a href="/gallery/Designer/<?= $persona['author'] ?>"><?= $persona['display_username'] ?></a></p>
-                                <p class="added"><strong>Added:</strong> <?= $persona['date'] ?></p>
-                                <p><?= $persona['short_description'] ?></p>
-                                <p><?= number_format($persona['popularity']) ?> active daily users</p>
-                                <p><a href="<?= "/persona/" . ($persona['id'] < 10 ? "0" : "") . $persona['id'] ?>" class="view">view details »</a></p>
-<?php
-				if ($user->has_admin_privs() || ($tab == 'My' && $persona['locale'] == PERSONAS_LOCALE))
-				{
+				$persona['short_description'] = substr($persona['short_description'], 0, $description_max);
+				$persona['short_description'] = preg_replace('/ [^ ]+$/', '', $persona['short_description']) . '...';
+			}
+		}
+		include 'templates/gallery.php';
+	}
+
 ?>
-								<p><a href="/upload?id=<?= $persona['id'] ?>" target="_blank">Edit</a>
-								| 
-								<a href="/delete/<?= $persona['id'] ?>" target="_blank">Delete</a></p>
-<?php
-				}
-?>
-                            </div>
-                        </li>
- <?php
- 			}
- ?>
-                    </ul>
-                    <?php
-                    if($category == 'Designer') 
-        			{
-        			    echo '<p><script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=df86b16e-195c-4917-ae28-61a1382ba281&amp;type=website&amp;send_services=&amp;post_services=facebook%2Cdigg%2Cdelicious%2Cybuzz%2Ctwitter%2Cstumbleupon%2Creddit%2Ctechnorati%2Cmixx%2Cblogger%2Ctypepad%2Cwordpress%2Cgoogle_bmarks%2Cwindows_live%2Cmyspace%2Cfark%2Cbus_exchange%2Cpropeller%2Cnewsvine%2Clinkedin"></script></p>';
-        			}
-                    ?>
-                    
-                </div>
-<?php include 'templates/pagination.php'; ?>
-            </div>
-<?php include 'templates/category_nav.php'; ?>
-        </div>
-    </div>
-<?php include 'templates/footer.php'; ?>
-    <script type="text/javascript" charset="utf-8">
-        $(document).ready(function() {
-           $("#gallery .preview img").previewPersona();
-        });
-    </script>
-</body>
-</html>