[pLog-svn] r3736 - in plugins/trunk: . reflection reflection/class reflection/class/action reflection/class/js reflection/class/view reflection/locale reflection/templates

pwestbro at devel.lifetype.net pwestbro at devel.lifetype.net
Tue Jul 18 06:41:50 GMT 2006


Author: pwestbro
Date: 2006-07-18 06:41:48 +0000 (Tue, 18 Jul 2006)
New Revision: 3736

Added:
   plugins/trunk/reflection/
   plugins/trunk/reflection/README.txt
   plugins/trunk/reflection/class/
   plugins/trunk/reflection/class/action/
   plugins/trunk/reflection/class/action/pluginreflectionconfigaction.class.php
   plugins/trunk/reflection/class/action/pluginreflectionupdateconfigaction.class.php
   plugins/trunk/reflection/class/js/
   plugins/trunk/reflection/class/js/reflection.js
   plugins/trunk/reflection/class/view/
   plugins/trunk/reflection/class/view/pluginreflectionconfigview.class.php
   plugins/trunk/reflection/locale/
   plugins/trunk/reflection/locale/locale_en_UK.php
   plugins/trunk/reflection/pluginreflection.class.php
   plugins/trunk/reflection/templates/
   plugins/trunk/reflection/templates/reflection.template
Log:
Added the reflection plugin.  This allows the Reflection.js script to be
used.

http://cow.neondragon.net/stuff/reflection/

This was inspired by the WP Wetfloor Wordpress plugin


Added: plugins/trunk/reflection/README.txt
===================================================================
--- plugins/trunk/reflection/README.txt	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/README.txt	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,22 @@
+[USAGES]: 
+1. Upload: Upload all the extract files and directorys to $LifeType_Install_Dir/plugin/reflection 
+2. Modify template: Use $reflection->show() in template file to all a LifeType post to be tracked. 
+
+
+Reflection.js web site:
+http://cow.neondragon.net/stuff/reflection/
+
+
+[EXAMPLE]: 
+Add the following code in header.template: 
+
+Code: 
+{$reflection->show()} 
+
+On the image tag add a reflect class attribute:
+
+class="reflect rheight80 ropacity40"
+
+
+[TODO]:
+1) Add support for some tag, that would be parsed from the posts, to make it easier to add the effect.
\ No newline at end of file

Added: plugins/trunk/reflection/class/action/pluginreflectionconfigaction.class.php
===================================================================
--- plugins/trunk/reflection/class/action/pluginreflectionconfigaction.class.php	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/class/action/pluginreflectionconfigaction.class.php	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,26 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/reflection/class/view/pluginreflectionconfigview.class.php" );
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginReflectionConfigAction extends AdminAction
+	{
+		
+		function PluginReflectionConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_view = new PluginReflectionConfigView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/reflection/class/action/pluginreflectionupdateconfigaction.class.php
===================================================================
--- plugins/trunk/reflection/class/action/pluginreflectionupdateconfigaction.class.php	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/class/action/pluginreflectionupdateconfigaction.class.php	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,58 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/reflection/class/view/pluginreflectionconfigview.class.php" );
+		
+	/**
+	 * updates the plugin configuration
+	 */
+	class PluginReflectionUpdateConfigAction extends AdminAction
+	{
+		var $_pluginEnabled;
+		
+		function PluginReflectionUpdateConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
+			
+			return true;
+		}
+		        
+		function perform()
+		{
+            // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_reflection_enabled", $this->_pluginEnabled );
+            $this->_blogInfo->setSettings( $blogSettings ); 
+		
+			// save the blogs settings
+			$blogs = new Blogs();
+            if( !$blogs->updateBlog( $this->_blogInfo )) {
+                $this->_view = new PluginReflectionConfigView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+                $this->setCommonData();
+
+                return false;                       
+            }
+			
+			// if everything went ok...
+            $this->_blogInfo->setSettings( $blogSettings );
+            $this->_session->setValue( "blogInfo", $this->_blogInfo );
+            $this->saveSession();
+			
+			$this->_view = new PluginReflectionConfigView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("reflection_settings_saved_ok"));			
+			$this->setCommonData();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());					
+            
+            return true;		
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/reflection/class/js/reflection.js
===================================================================
--- plugins/trunk/reflection/class/js/reflection.js	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/class/js/reflection.js	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,170 @@
+/**
+ * reflection.js v1.6
+ *
+ * Contributors: Cow http://cow.neondragon.net
+ *               Gfx http://www.jroller.com/page/gfx/
+ *               Sitharus http://www.sitharus.com
+ *               Andreas Linde http://www.andreaslinde.de
+ *               Tralala, coder @ http://www.vbulletin.org
+ *
+ * Freely distributable under MIT-style license.
+ */
+ 
+/* From prototype.js */
+document.getElementsByClassName = function(className) {
+	var children = document.getElementsByTagName('*') || document.all;
+	var elements = new Array();
+  
+	for (var i = 0; i < children.length; i++) {
+		var child = children[i];
+		var classNames = child.className.split(' ');
+		for (var j = 0; j < classNames.length; j++) {
+			if (classNames[j] == className) {
+				elements.push(child);
+				break;
+			}
+		}
+	}
+	return elements;
+}
+
+var Reflection = {
+	defaultHeight : 0.5,
+	defaultOpacity: 0.5,
+	
+	add: function(image, options) {
+		Reflection.remove(image);
+		
+		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
+		if (options) {
+			for (var i in doptions) {
+				if (!options[i]) {
+					options[i] = doptions[i];
+				}
+			}
+		} else {
+			options = doptions;
+		}
+	
+		try {
+			var d = document.createElement('div');
+			var p = image;
+			
+			var classes = p.className.split(' ');
+			var newClasses = '';
+			for (j=0;j<classes.length;j++) {
+				if (classes[j] != "reflect") {
+					if (newClasses) {
+						newClasses += ' '
+					}
+					
+					newClasses += classes[j];
+				}
+			}
+
+			var reflectionHeight = Math.floor(p.height*options['height']);
+			var divHeight = Math.floor(p.height*(1+options['height']));
+			
+			var reflectionWidth = p.width;
+			
+			if (document.all && !window.opera) {
+				/* Copy original image's classes & styles to div */
+				d.className = newClasses;
+				p.className = 'reflected';
+				
+				d.style.cssText = p.style.cssText;
+				p.style.cssText = 'vertical-align: bottom';
+			
+				var reflection = document.createElement('img');
+				reflection.src = p.src;
+				reflection.style.width = reflectionWidth+'px';
+				
+				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
+				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
+				
+				d.style.width = reflectionWidth+'px';
+				d.style.height = divHeight+'px';
+				p.parentNode.replaceChild(d, p);
+				
+				d.appendChild(p);
+				d.appendChild(reflection);
+			} else {
+				var canvas = document.createElement('canvas');
+				if (canvas.getContext) {
+					/* Copy original image's classes & styles to div */
+					d.className = newClasses;
+					p.className = 'reflected';
+					
+					d.style.cssText = p.style.cssText;
+					p.style.cssText = 'vertical-align: bottom';
+			
+					var context = canvas.getContext("2d");
+				
+					canvas.style.height = reflectionHeight+'px';
+					canvas.style.width = reflectionWidth+'px';
+					canvas.height = reflectionHeight;
+					canvas.width = reflectionWidth;
+					
+					d.style.width = reflectionWidth+'px';
+					d.style.height = divHeight+'px';
+					p.parentNode.replaceChild(d, p);
+					
+					d.appendChild(p);
+					d.appendChild(canvas);
+					
+					context.save();
+					
+					context.translate(0,image.height-1);
+					context.scale(1,-1);
+					
+					context.drawImage(image, 0, 0, reflectionWidth, image.height);
+	
+					context.restore();
+					
+					context.globalCompositeOperation = "destination-out";
+					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
+					
+					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
+					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
+		
+					context.fillStyle = gradient;
+					if (navigator.appVersion.indexOf('WebKit') != -1) {
+						context.fill();
+					} else {
+						context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);
+					}
+				}
+			}
+		} catch (e) {
+	    }
+	},
+	
+	remove : function(image) {
+		if (image.className == "reflected") {
+			image.className = image.parentNode.className;
+			image.parentNode.parentNode.replaceChild(image, image.parentNode);
+		}
+	}
+}
+
+function addReflections() {
+	var rimages = document.getElementsByClassName('reflect');
+	for (i=0;i<rimages.length;i++) {
+		var rheight = null;
+		var ropacity = null;
+		
+		var classes = rimages[i].className.split(' ');
+		for (j=0;j<classes.length;j++) {
+			if (classes[j].indexOf("rheight") == 0) {
+				var rheight = classes[j].substring(7)/100;
+			} else if (classes[j].indexOf("ropacity") == 0) {
+				var ropacity = classes[j].substring(8)/100;
+			}
+		}
+		
+		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
+	}
+}
+
+var previousOnload = window.onload;
+window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }


Property changes on: plugins/trunk/reflection/class/js/reflection.js
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/trunk/reflection/class/view/pluginreflectionconfigview.class.php
===================================================================
--- plugins/trunk/reflection/class/view/pluginreflectionconfigview.class.php	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/class/view/pluginreflectionconfigview.class.php	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,28 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class PluginReflectionConfigView extends AdminPluginTemplatedView
+	{
+
+		function PluginReflectionConfigView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "reflection", "reflection" );
+		}
+		
+		function render()
+		{
+			// load some configuration settings
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_reflection_enabled" );
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );		
+			
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/reflection/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/reflection/locale/locale_en_UK.php	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/locale/locale_en_UK.php	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,13 @@
+<?php
+$messages["manageAppearancePlugins"] = "Appearance Management";
+$messages["reflection"] = "Reflection";
+
+$messages["reflection_plugin_enabled"] = "Enable this plugin";
+$messages["reflection_plugin"] = "co.mments Plugin";
+$messages["detail"] = "Detail";
+
+$messages["reflection_settings_saved_ok"] = "Reflection settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+?>
\ No newline at end of file

Added: plugins/trunk/reflection/pluginreflection.class.php
===================================================================
--- plugins/trunk/reflection/pluginreflection.class.php	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/pluginreflection.class.php	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,58 @@
+<?php
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+
+	class PluginReflection extends PluginBase
+	{
+		var $pluginEnabled;
+		
+		function PluginReflection()
+		{
+			$this->PluginBase();
+
+			$this->id      = "reflection";
+			$this->author  = "Paul Westbrook";
+			$this->desc    = "Plugin to add reflections to images.";
+
+			$this->locales = Array( "en_UK");
+
+			$this->init();
+		}
+
+		function init()
+		{
+            $this->registerAdminAction( "reflectionConfig", "PluginReflectionConfigAction" );
+			$this->registerAdminAction( "updateReflectionConfig", "PluginReflectionUpdateConfigAction" );
+			
+			$menu =& Menu::getMenu();
+			if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))						
+				$this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );			
+            $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "reflection", "?op=reflectionConfig", "" );
+		}
+
+		function register()
+		{
+		    $blogSettings = $this->blogInfo->getSettings();
+			$this->pluginEnabled = $blogSettings->getValue( "plugin_reflection_enabled" );
+		}
+
+	    function isEnabled()
+	    {
+	        return $this->pluginEnabled;
+	    }
+	    
+	    function show()
+	    {
+
+			$str = '';
+	    
+            if ($this->isEnabled())
+            {
+                $rg = $this->blogInfo->getBlogRequestGenerator();
+                
+                $str = '<script type="text/javascript" src="' . $rg->blogLink() . '/plugins/reflection/class/js/reflection.js"></script>';
+             }
+	    	return $str;
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/reflection/templates/reflection.template
===================================================================
--- plugins/trunk/reflection/templates/reflection.template	2006-07-17 21:23:57 UTC (rev 3735)
+++ plugins/trunk/reflection/templates/reflection.template	2006-07-18 06:41:48 UTC (rev 3736)
@@ -0,0 +1,24 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=reflection title=$locale->tr("reflection_plugin")}
+<form name="reflectionPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>  
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}   
+  <div class="field">
+   <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+   <div class="formHelp">   
+    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("reflection_plugin_enabled")}
+   </div>
+  </div>
+  
+ </fieldset>  
+
+ <div class="buttons">
+  <input type="hidden" name="op" value="updateReflectionConfig" />
+  <input type="reset" name="{$locale->tr("reset")}" />    
+  <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file



More information about the pLog-svn mailing list