[pLog-svn] r832 - in plugins/trunk/flickr: . class/action install
install/css install/js install/js/annotation install/templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Tue Jan 25 16:55:53 GMT 2005
Author: mark
Date: 2005-01-25 16:55:52 +0000 (Tue, 25 Jan 2005)
New Revision: 832
Added:
plugins/trunk/flickr/class/action/pluginflickrshowaction.class.php
plugins/trunk/flickr/install/css/
plugins/trunk/flickr/install/css/annotation.css
plugins/trunk/flickr/install/js/
plugins/trunk/flickr/install/js/annotation/
plugins/trunk/flickr/install/js/annotation/annotation.js
plugins/trunk/flickr/install/templates/
plugins/trunk/flickr/install/templates/flickr.template
Removed:
plugins/trunk/flickr/install/flickr.template
Modified:
plugins/trunk/flickr/pluginflickr.class.php
plugins/trunk/flickr/readme.txt
Log:
Update the flickr plugin with FlickrShow Action. This action will render the flickr template without smarty cache.
Added: plugins/trunk/flickr/class/action/pluginflickrshowaction.class.php
===================================================================
--- plugins/trunk/flickr/class/action/pluginflickrshowaction.class.php 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/class/action/pluginflickrshowaction.class.php 2005-01-25 16:55:52 UTC (rev 832)
@@ -0,0 +1,27 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/blogview.class.php" );
+
+ /**
+ * shows a flickr template without smarty cache
+ */
+ class PluginFlickrShowAction extends BlogAction
+ {
+
+ function PluginFlickrShowAction( $actionInfo, $request )
+ {
+ $this->BlogAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new BlogView( $this->_blogInfo, "flickr", SMARTY_CACHED_DISABLED );
+ $this->_view->setValue( "request", $this->_request );
+ // add all the common information to the view
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/flickr/install/css/annotation.css
===================================================================
--- plugins/trunk/flickr/install/css/annotation.css 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/install/css/annotation.css 2005-01-25 16:55:52 UTC (rev 832)
@@ -0,0 +1,25 @@
+a.annotation {
+ position: absolute;
+ border: 2px solid yellow;
+ padding: 0;
+ display: none;
+ opacity: 0.2;
+ -moz-opacity: 0.2;
+ filter: alpha(opacity=20);
+}
+a.annotation span {
+ display: block;
+ width: 100%;
+ height: 100%;
+ background: white;
+ opacity: 0.2;
+ -moz-opacity: 0.2;
+ filter: alpha(opacity=20);
+}
+a.annotation:hover {
+ background: white;
+ opacity: 0.2;
+ -moz-opacity: 0.2;
+ filter: alpha(opacity=20);
+ border: 2px solid blue;
+}
\ No newline at end of file
Deleted: plugins/trunk/flickr/install/flickr.template
===================================================================
--- plugins/trunk/flickr/install/flickr.template 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/install/flickr.template 2005-01-25 16:55:52 UTC (rev 832)
@@ -1,35 +0,0 @@
-{include file="$blogtemplate/header.template"}
-{assign var=albumId value=$smarty.request.album}
-{assign var=photoId value=$smarty.request.photo}
-{assign var=secretId value=$smarty.request.secret}
-{if $albumId != NULL && $photoId != NULL && secretId != NULL}
- {assign var=flickrPhotoInfo value=$flickr->getPhotoInfo($photoId,$secretId)}
- <h3>{$flickrPhotoInfo.title}</h3>
- <span class="date">{$flickrPhotoInfo.description} | {$flickrPhotoInfo.date}</span><br /><br />
- <a href="{$flickrPhotoInfo.originalimageUrl}"><img class="annotated" src="{$flickrPhotoInfo.resizeimageUrl}" alt="" usemap="imgmap" /></a><br />
- {assign var=flickrNotes value=$flickrPhotoInfo.notes}
- <map id="imgmap">
- {foreach item=flickrNote from=$flickrNotes}
- <area alt="" title="{$flickrNote.noteDesc}" nohref="nohref" shape="rect" coords="{$flickrNote.noteX},{$flickrNote.noteY},{$flickrNote.noteX+$flickrNote.noteW-1},{$flickrNote.noteY+$flickrNote.noteH-1}" />
- {/foreach}
- </map>
- {assign var=flickrTags value=$flickrPhotoInfo.tags}
- See Similar: {foreach item=flickrTag from=$flickrTags}<a href="{$flickrTag.tagUrl}">{$flickrTag.tagName}</a> {/foreach}<br />
- Flickr URL: <a href="{$flickrPhotoInfo.flickrUrl}">See the photo in Flickr ({$flickrPhotoInfo.comments} Comments)</a><br />
-{elseif $albumId != NULL && ($photoId == NULL || secretId == NULL)}
- {assign var=flickrPhotos value=$flickr->getPhotos($albumId)}
- {foreach item=flickrPhoto from=$flickrPhotos}
- <a href="{$flickrPhoto.photoUrl}"><img src="{$flickrPhoto.thumbnailUrl}" alt="" /></a>
- {/foreach}
-{else}
- {assign var=flickrAlbums value=$flickr->getPhotoList()}
- {foreach name=flickrAlbum item=flickrAlbum from=$flickrAlbums}
- <a href="{$flickrAlbum.albumUrl}"><img src="{$flickrAlbum.thumbnailUrl}" alt="{$flickrAlbum.title}" /></a><br />
- Title: {$flickrAlbum.title} <br />
- Description: {$flickrAlbum.description} <br />
- Photos: <a href="{$flickrAlbum.albumUrl}">{$flickrAlbum.photos}</a> <br />
- Flickr URL: <a href="{$flickrAlbum.flickrUrl}">See the album in Flickr</a> <br /><br />
- {/foreach}
- {assign var=totalAlbums value=$smarty.foreach.flickrAlbum.total}
-{/if}
-{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Added: plugins/trunk/flickr/install/js/annotation/annotation.js
===================================================================
--- plugins/trunk/flickr/install/js/annotation/annotation.js 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/install/js/annotation/annotation.js 2005-01-25 16:55:52 UTC (rev 832)
@@ -0,0 +1,127 @@
+var aI = {
+
+ init: function() {
+ if (!document.getElementById ||
+ !document.createElement ||
+ !document.getElementsByTagName)
+ return;
+ var anni = document.getElementsByTagName('img');
+ for (var i=0;i<anni.length;i++) {
+ if ((anni[i].className.search(/\bannotated\b/) != -1) &&
+ (anni[i].getAttribute('usemap') != null)) {
+ aI.prepImage(anni[i]);
+ }
+ }
+ },
+
+ prepImage: function(img) {
+ var mapName = img.getAttribute('usemap');
+ var mapObj = document.getElementById(mapName);
+ var areas = mapObj.getElementsByTagName('area');
+ img.areas = [];
+ for (var j=areas.length-1;j>=0;j--) {
+ if (areas[j].getAttribute('shape').toLowerCase() == 'rect') {
+ var coo = areas[j].getAttribute('coords').split(',');
+ if (coo.length != 4) break;
+ var a = document.createElement('a');
+ a.associatedCoords = coo;
+ a.style.width = (parseInt(coo[2]) - parseInt(coo[0])) + 'px';
+ a.style.height = (parseInt(coo[3]) - parseInt(coo[1])) + 'px';
+ var thisAreaPosition = aI.__getAreaPosition(img,coo);
+ a.style.left = thisAreaPosition[0] + 'px';
+ a.style.top = thisAreaPosition[1] + 'px';
+ a.className = 'annotation';
+ var href = areas[j].getAttribute('href');
+ if (href) {
+ a.href = href;
+ } else {
+ // set an explicit href, otherwise it doesn't count as a link
+ // for IE
+ a.href = "#";
+ }
+ a.title = areas[j].getAttribute('title');
+ var s = document.createElement('span');
+ s.appendChild(document.createTextNode(''));
+ a.appendChild(s);
+
+ img.areas[img.areas.length] = a;
+ document.getElementsByTagName('body')[0].appendChild(a);
+
+ aI.addEvent(a,"mouseover",
+ function() {
+ clearTimeout(aI.hiderTimeout);
+ }
+ );
+
+ if ((typeof showNiceTitle == 'function') &&
+ (typeof hideNiceTitle == 'function')) {
+ a.setAttribute('nicetitle',a.title);
+ a.title = '';
+ aI.addEvent(a,"mouseover",showNiceTitle);
+ aI.addEvent(a,"mouseout",hideNiceTitle);
+ }
+
+ }
+ }
+
+ aI.addEvent(img,"mouseover",aI.showAreas);
+ aI.addEvent(img,"mouseout",aI.hideAreas);
+ },
+
+ __getAreaPosition: function(img,coo) {
+ var aleft = (img.offsetLeft + parseInt(coo[0]));
+ var atop = (img.offsetTop + parseInt(coo[1]));
+ var oo = img;
+ while (oo.offsetParent) {
+ oo = oo.offsetParent;
+ aleft += oo.offsetLeft;
+ atop += oo.offsetTop;
+ }
+ return [aleft,atop];
+ },
+
+ __setAreas: function(t,disp) {
+ if (!t || !t.areas) return;
+ for (var i=0;i<t.areas.length;i++) {
+ t.areas[i].style.display = disp;
+ }
+ },
+
+ showAreas: function(e) {
+ var t = null;
+ if (e && e.target) t = e.target;
+ if (window.event && window.event.srcElement) t = window.event.srcElement;
+ // Recalculate area positions
+ for (var k=0;k<t.areas.length;k++) {
+ var thisAreaPosition = aI.__getAreaPosition(t,t.areas[k].associatedCoords);
+ t.areas[k].style.left = thisAreaPosition[0] + 'px';
+ t.areas[k].style.top = thisAreaPosition[1] + 'px';
+
+ }
+ aI.__setAreas(t,'block');
+ },
+ hideAreas: function(e) {
+ var t = null;
+ if (e && e.target) t = e.target;
+ if (window.event && window.event.srcElement) t = window.event.srcElement;
+ clearTimeout(aI.hiderTimeout);
+ aI.hiderTimeout = setTimeout(
+ function() { aI.__setAreas(t,'none') }, 300);
+ },
+
+ addEvent: function(elm, evType, fn, useCapture) {
+ // cross-browser event handling for IE5+, NS6 and Mozilla
+ // By Scott Andrew
+ if (elm.addEventListener){
+ elm.addEventListener(evType, fn, useCapture);
+ return true;
+ } else if (elm.attachEvent){
+ var r = elm.attachEvent("on"+evType, fn);
+ return r;
+ } else {
+ elm['on'+evType] = fn;
+ }
+ }
+}
+
+aI.addEvent(window,"load",aI.init);
Added: plugins/trunk/flickr/install/templates/flickr.template
===================================================================
--- plugins/trunk/flickr/install/templates/flickr.template 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/install/templates/flickr.template 2005-01-25 16:55:52 UTC (rev 832)
@@ -0,0 +1,35 @@
+{include file="$blogtemplate/header.template"}
+{assign var=albumId value=$smarty.request.album}
+{assign var=photoId value=$smarty.request.photo}
+{assign var=secretId value=$smarty.request.secret}
+{if $albumId != NULL && $photoId != NULL && secretId != NULL}
+ {assign var=flickrPhotoInfo value=$flickr->getPhotoInfo($photoId,$secretId)}
+ <h3>{$flickrPhotoInfo.title}</h3>
+ <span class="date">{$flickrPhotoInfo.description} | {$flickrPhotoInfo.date}</span><br /><br />
+ <a href="{$flickrPhotoInfo.originalimageUrl}"><img class="annotated" src="{$flickrPhotoInfo.resizeimageUrl}" alt="" usemap="imgmap" /></a><br />
+ {assign var=flickrNotes value=$flickrPhotoInfo.notes}
+ <map id="imgmap">
+ {foreach item=flickrNote from=$flickrNotes}
+ <area alt="" title="{$flickrNote.noteDesc}" nohref="nohref" shape="rect" coords="{$flickrNote.noteX},{$flickrNote.noteY},{$flickrNote.noteX+$flickrNote.noteW-1},{$flickrNote.noteY+$flickrNote.noteH-1}" />
+ {/foreach}
+ </map>
+ {assign var=flickrTags value=$flickrPhotoInfo.tags}
+ See Similar: {foreach item=flickrTag from=$flickrTags}<a href="{$flickrTag.tagUrl}">{$flickrTag.tagName}</a> {/foreach}<br />
+ Flickr URL: <a href="{$flickrPhotoInfo.flickrUrl}">See the photo in Flickr ({$flickrPhotoInfo.comments} Comments)</a><br />
+{elseif $albumId != NULL && ($photoId == NULL || secretId == NULL)}
+ {assign var=flickrPhotos value=$flickr->getPhotos($albumId)}
+ {foreach item=flickrPhoto from=$flickrPhotos}
+ <a href="{$flickrPhoto.photoUrl}"><img src="{$flickrPhoto.thumbnailUrl}" alt="" /></a>
+ {/foreach}
+{else}
+ {assign var=flickrAlbums value=$flickr->getPhotoList()}
+ {foreach name=flickrAlbum item=flickrAlbum from=$flickrAlbums}
+ <a href="{$flickrAlbum.albumUrl}"><img src="{$flickrAlbum.thumbnailUrl}" alt="{$flickrAlbum.title}" /></a><br />
+ Title: {$flickrAlbum.title} <br />
+ Description: {$flickrAlbum.description} <br />
+ Photos: <a href="{$flickrAlbum.albumUrl}">{$flickrAlbum.photos}</a> <br />
+ Flickr URL: <a href="{$flickrAlbum.flickrUrl}">See the album in Flickr</a> <br /><br />
+ {/foreach}
+ {assign var=totalAlbums value=$smarty.foreach.flickrAlbum.total}
+{/if}
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Modified: plugins/trunk/flickr/pluginflickr.class.php
===================================================================
--- plugins/trunk/flickr/pluginflickr.class.php 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/pluginflickr.class.php 2005-01-25 16:55:52 UTC (rev 832)
@@ -55,6 +55,7 @@
{
$this->registerAdminAction( "flickr", "PluginFlickrConfigAction" );
$this->registerAdminAction( "updateFlickrConfig", "PluginFlickrUpdateConfigAction" );
+ $this->registerBlogAction( "FlickrShow", "PluginFlickrShowAction" );
$menu =& Menu::getMenu();
if( !$menu->entryExists( "/menu/controlCenter/manageIntegrationPlugins" ))
@@ -82,6 +83,18 @@
$this->expiredTime = $blogSettings->getValue( "plugin_flickr_expiredtime" );
}
+ function pluginTemplatePage( $template )
+ {
+ $rg = new RawRequestGenerator($this->blogInfo);
+
+ $rg->addParameter( "op", "FlickrShow" );
+ $rg->addParameter( "blogId", $this->blogInfo->getId());
+
+ $templatePage = $rg->getIndexUrl().$rg->getRequest();
+
+ return $templatePage;
+ }
+
/**
* Get the photo albums from specific user
*/
@@ -90,8 +103,7 @@
$apiUrl = FLICKR_GET_PHOTOLIST.FLICKR_API_KEY;
$apiUrl .= '&email=' . $this->email . '&password=' . $this->password;
- $rg = new RawRequestGenerator($this->blogInfo);
- $this->userRoot = $rg->templatePage( "flickr" );
+ $this->userRoot = $this->pluginTemplatePage( "flickr" );
$data = $this->cached_get_file_contents($apiUrl, 'r', $this->expiredTime, $this->cacheFolder);
$parser = new XMLParser($data, 'raw', 1);
@@ -150,10 +162,9 @@
$data = $this->cached_get_file_contents($apiUrl, 'r', $this->expiredTime, $this->cacheFolder);
$parser = new XMLParser($data, 'raw', 1);
$tree = $parser->getTree();
-
- $rg = new RawRequestGenerator($this->blogInfo);
- $this->userRoot = $rg->templatePage( "flickr" );
+ $this->userRoot = $this->pluginTemplatePage( "flickr" );
+
$totalPhotos = count($tree['RSP']['PHOTOSET']['PHOTO']);
$photos = Array();
@@ -196,8 +207,7 @@
else
$apiUrl .= '&email=' . $this->email . '&password=' . $this->password . '&photo_id=' . $photoId;
- $rg = new RawRequestGenerator($this->blogInfo);
- $this->userRoot = $rg->templatePage( "flickr" );
+ $this->userRoot = $this->pluginTemplatePage( "flickr" );
$data = $this->cached_get_file_contents($apiUrl, 'r', $this->expiredTime, $this->cacheFolder);
$parser = new XMLParser($data, 'raw', 1);
@@ -258,8 +268,10 @@
// Clear file stats so we get an accurate file creation time for cache files
clearstatcache();
+ $encode_file = "%%Flickr%%".md5($file);
+
// Path to cached file
- $cache_filename = $cache_path .'/' . urlencode($file) . ".cached";
+ $cache_filename = $cache_path .'/' . $encode_file . ".cached";
if ($debug)
{
Modified: plugins/trunk/flickr/readme.txt
===================================================================
--- plugins/trunk/flickr/readme.txt 2005-01-25 14:19:58 UTC (rev 831)
+++ plugins/trunk/flickr/readme.txt 2005-01-25 16:55:52 UTC (rev 832)
@@ -6,8 +6,13 @@
This plugin offers you to integrate with Flickr service.
It is inspired by Wordpress Flickr Gallery Plugin written by Ray.
-Example:
-Copy the install\flickr.template to your template folder.
+Install:
+1. Copy the install/templates/flickr.template to your plog template folder.
+2. Copy the install/js/*.* to your plog installation /js folder.
+3. Add the content of install/css/annotation.css to your template style.css.
+4. Configurate your Flickr plugin in your pLog control center
-Note:
-This plugin only works when smarty cache turned off.
\ No newline at end of file
+Usage:
+Use the following URL to call your pLog Flickr Plugin Page
+http://your-plog/index.php?op=FlickrShow&blogId=1
+
More information about the pLog-svn
mailing list