<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Houston Web Design Blog &#187; Web Programming</title>
	<atom:link href="http://blog.levantainteractive.com/category/web-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.levantainteractive.com</link>
	<description>A blog regarding web design, search engine optimization, web programming, online marketing and website development for the Houston, TX area.</description>
	<lastBuildDate>Wed, 13 Jan 2010 17:25:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Embed Picasa web album using PHP and Lightbox</title>
		<link>http://blog.levantainteractive.com/web-programming/embed-picasa-web-album-using-php-and-lightbox/</link>
		<comments>http://blog.levantainteractive.com/web-programming/embed-picasa-web-album-using-php-and-lightbox/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 16:17:05 +0000</pubDate>
		<dc:creator>Jack Arnold</dc:creator>
				<category><![CDATA[Web Programming]]></category>

		<guid isPermaLink="false">http://blog.levantainteractive.com/?p=52</guid>
		<description><![CDATA[About Picasa Web Albums
Picasa Web Albums allow the common web user to post and share photos with relative ease. You can organize your photos into albums and albums within albums. »Read more
About Lightbox
Lightbox is a simple, unobtrusive script used to overlay images on the current page. It&#8217;s a snap to setup and works on all [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right:10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.levantainteractive.com%2Fweb-programming%2Fembed-picasa-web-album-using-php-and-lightbox%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.levantainteractive.com%2Fweb-programming%2Fembed-picasa-web-album-using-php-and-lightbox%2F" height="61" width="51" /></a></div><h2><a href="http://www.joyyogacenter.com/photo_album.php" target="_blank"><img title="Joy Yoga Center Photo Album" src="/images/picasa-lightbox-example.jpg" border="0" alt="Joy Yoga Center Photo Album" align="right" /></a>About Picasa Web Albums</h2>
<p><strong>Picasa Web Albums</strong> allow the common web user to post and share photos with relative ease. You can organize your photos into albums and albums within albums. <a class="orange-link" href="http://picasa.google.com/features.html" target="_blank">»Read more</a></p>
<h2>About Lightbox</h2>
<p><strong>Lightbox</strong> is a simple, unobtrusive script used to overlay images on the current page. It&#8217;s a snap to setup and works on all modern browsers. <a class="orange-link" href="http://www.huddletogether.com/projects/lightbox2/" target="_blank">»Read more</a></p>
<h2>Posting pictures to your website using Picasa and Lightbox</h2>
<p>Why not use the Picasa engine to power your website&#8217;s photo gallery, project portfolio or work examples? Levanta has helped many a client embed their Picasa Web Album in their website.</p>
<h2>Step 1: Embed the Lightbox Framework</h2>
<p style="background: #FFC;padding:10px;"><code>&lt;link rel="stylesheet" href="js/lightbox/css/lightbox.css" type="text/css" media="screen" /&gt;<br />
&lt;script type="text/javascript" src="js/lightbox/prototype.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="js/lightbox/scriptaculous.js?load=effects,builder"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="js/lightbox/lightbox.js"&gt;&lt;/script&gt;</code></p>
<h2>Step 2: Add CSS Styling</h2>
<p style="background: #FFC;padding:10px;"><code>&lt;style&gt;<br />
#pa_images {width:auto;}<br />
#pa_images h2 {font-weight:bold;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:1.5em;color:#3E8CA8;width:auto;text-align:center;}<br />
#pa_images ul {float: left;list-style:none;}<br />
#pa_images li {float: left;width: 96px;height: 96px;margin: 10px;border: 1px solid #999;}<br />
#pa_images li a {display: block;text-decoration:none;width: 96px;height: 96px;}<br />
&lt;/style&gt;</code></p>
<h2>Step 3: Add the PHP code and add your Picasa username</h2>
<p style="background: #FFC;padding:10px;"><code>&lt;div id="pa_images"&gt;</p>
<p>&lt;?php</p>
<p>// PICASA URL<br />
$picasa_url = "http://picasaweb.google.com/data/feed/base/user/";</p>
<p>// ENTER YOUR PICASA USERNAME<br />
$picasa_username = "";</p>
<p>// GET VARIABLES<br />
if (isset($_GET["ft"])) $ft = $_GET["ft"];<br />
else $ft = 0;<br />
if (isset($_GET["albumid"])) $albumid = $_GET["albumid"];<br />
else $albumid = 0;</p>
<p>if ($ft&gt;0) echo('&lt;p&gt;&lt;a href="'.$_SERVER['PHP_SELF'].'"&gt;return to all albums&lt;/a&gt;&lt;/p&gt;');</p>
<p>switch ($ft) {<br />
case 0:<br />
$file = $picasa_url . $picasa_username . '?alt=rss&amp;kind=album&amp;hl=en_US&amp;access=public';<br />
break;<br />
case 1:<br />
$file =  $picasa_url . . $picasa_username . '/albumid/'.$albumid.'?alt=rss&amp;hl=en_US';<br />
break;<br />
}<br />
$insideitem = false;<br />
$insidetitle = false;<br />
$tag = "";<br />
$album_title = "";<br />
$title = "";<br />
$link = "";<br />
$guid="";<br />
$rssfeed="";<br />
$url="";<br />
$fullimage = "";<br />
$smallimage = "";<br />
$tdcount=0;<br />
$imageheight=0;<br />
$imagewidth=0;<br />
$thumbcount=0;</p>
<p>if ($ft==0) echo("&lt;table align=\"center\" cellpadding=\"0\" cellspacing=\"25\"&gt;");<br />
else echo("&lt;div id=\"pa_images\"&gt;");</p>
<p>$xml_parser = xml_parser_create();<br />
xml_set_element_handler($xml_parser, "startElement", "endElement");<br />
xml_set_character_data_handler($xml_parser, "characterData");<br />
if (!($fp = fopen($file,"r"))) {<br />
die ("could not open RSS for input");<br />
}<br />
while ($data = fread($fp, 4096)) {<br />
if (!xml_parse($xml_parser, $data, feof($fp))) {<br />
die(sprintf("XML error: %s at line %d",<br />
xml_error_string(xml_get_error_code($xml_parser)),<br />
xml_get_current_line_number($xml_parser)));<br />
}<br />
}<br />
xml_parser_free($xml_parser);</p>
<p>if ($ft==0&amp;&amp;$tdcount&gt;0) echo("&lt;/tr&gt;");<br />
if ($ft==0) echo("&lt;/table&gt;");<br />
else echo("&lt;/ul&gt;&lt;/div&gt;");</p>
<p>?&gt;</p>
<p>&lt;/div&gt;</code></p>
<h2>Step 4: Include XML parsing functions at the bottom of the page</h2>
<p style="background: #FFC;padding:10px;"><code>&lt;?php</p>
<p>function startElement($parser, $tagName, $attrs) {</p>
<p>global $insideitem, $insidetitle, $tag, $fullimage, $smallimage, $imageheight,<br />
$imagewidth, $ft, $thumbcount;</p>
<p>if ($tagName=="MEDIA:CONTENT") {//$ft&gt;0&amp;&amp;<br />
$fullimage = $attrs["URL"];<br />
}<br />
if ($tagName=="MEDIA:THUMBNAIL") {<br />
if (($ft&gt;0&amp;&amp;$thumbcount==1)||$ft==0) {<br />
$smallimage=$attrs["URL"];<br />
$imageheight=$attrs["HEIGHT"];<br />
$imagewidth=$attrs["WIDTH"];<br />
}<br />
$thumbcount+=1;<br />
}<br />
if ($insideitem) {<br />
$tag = $tagName;<br />
} elseif  ($tagName == "ITEM") {<br />
$insideitem = true;<br />
} elseif ($tagName == "TITLE") {<br />
$insidetitle = true;<br />
}<br />
}</p>
<p>function characterData($parser, $data) {<br />
global $insideitem, $insidetitle, $tag, $title, $album_title, $link, $rssfeed, $url;<br />
if ($insideitem) {<br />
switch ($tag) {<br />
case "GUID":<br />
$rssfeed.=$data;<br />
break;<br />
case "TITLE":<br />
$title .= $data;<br />
break;<br />
case "LINK":<br />
$link .= $data;<br />
break;<br />
case "URL":<br />
$url .= $data;<br />
break;<br />
}<br />
}elseif($insidetitle&amp;&amp;$album_title==""){<br />
$album_title = $data;<br />
$insidetitle=false;<br />
}<br />
}</p>
<p>function endElement($parser, $tagName) {</p>
<p>global $insideitem, $tag, $title, $album_title, $link, $rssfeed, $ft, $url,<br />
$fullimage, $smallimage, $tdcount, $imageheight,  $imagewidth,$thumbcount,<br />
$picasa_username,$picasa_url;</p>
<p>if ($tagName=="ITEM") {<br />
$albumid=$rssfeed;<br />
$albumid=str_replace("?alt=rss&amp;hl=en_US","",$albumid);<br />
$albumid=str_replace($picasa_url . $picasa_username."/albumid/","",$albumid);<br />
switch ($ft) {<br />
case 0:<br />
$link = $_SERVER["PHP_SELF"]."?albumid=".$albumid."&amp;ft=1";<br />
if ($tdcount==0) echo("&lt;tr&gt;");<br />
echo("&lt;td align=\"center\"&gt;");<br />
echo("&lt;a href=\"".trim($link)."\"&gt;&lt;img src=\"".htmlspecialchars($smallimage)."\" border=\"0\"	/&gt;&lt;/a&gt;&lt;br&gt;");<br />
echo("&lt;a class=\"redlink\" href=\"".trim($link)."\"&gt;".$title."&lt;/a&gt;");<br />
echo("&lt;/td&gt;");<br />
$tdcount+=1;<br />
if ($tdcount==3) {<br />
echo("&lt;/tr&gt;");<br />
$tdcount=0;<br />
}<br />
break;<br />
case 1:<br />
if ($tdcount==0) echo("&lt;h2&gt;$album_title&lt;/h2&gt;&lt;ul&gt;");<br />
echo("&lt;li style=\"background:url('$smallimage') center center no-repeat;\"&gt;");<br />
echo("&lt;a rel=\"lightbox[group]\" href=\"".str_replace('/s144', '/s800',<br />
$smallimage)."\"&gt; &lt;/a&gt;");<br />
echo("&lt;/li&gt;");<br />
$tdcount+=1;<br />
break;<br />
}<br />
$rssfeed="";<br />
$title = "";<br />
$description = "";<br />
$link = "";<br />
$url="";<br />
$thumbcount=0;<br />
$insideitem=false;<br />
}<br />
}<br />
?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.levantainteractive.com/web-programming/embed-picasa-web-album-using-php-and-lightbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

