Index: /extensions/pAnchor/CHANGELOG
===================================================================
--- /extensions/pAnchor/CHANGELOG	(revision 7862)
+++ /extensions/pAnchor/CHANGELOG	(revision 7862)
@@ -0,0 +1,4 @@
+2010-11-23 0.5b
+                  svn commit: 'first release'
+2010-11-23 0.5b
+                  Plugin creation.
Index: /extensions/pAnchor/main.inc.php
===================================================================
--- /extensions/pAnchor/main.inc.php	(revision 7862)
+++ /extensions/pAnchor/main.inc.php	(revision 7862)
@@ -0,0 +1,47 @@
+<?php
+/*
+Plugin Name: pAnchor
+Version: 0.5b
+Description: (beta) Improved piwigo picture browsing by adding HTML anchor to page and navigation URLs.
+Plugin URI: 
+Author: stellablue
+Author URI:  
+*/
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+//plug-in dir name
+define('PANCHOR_DIR' , basename(dirname(__FILE__)));
+//full path to plugin
+define('PANCHOR_PATH' , PHPWG_PLUGINS_PATH . PANCHOR_DIR . '/');
+//version
+define('PANCHOR_VER' , '0.5');
+//name of anchor  tag 
+define('PANCHOR_NAME' , 'pic');
+
+
+
+//CUSTOMIZATION VARS
+//name of div id to preceed with pAnchor tag  for picture.tpl
+//these tags could template dependent
+define('PANCHOR_PICTURE_SEARCH_TAG', '<div id="imageHeaderBar"');
+//name of div id to preceed with pAnchor tag  for  slideshow.tpl
+define('PANCHOR_SLIDESHOW_SEARCH_TAG', '<div id="imageHeaderBar"');
+//css fine adj is a pixel offset (y direction vertical) 
+define('PANCHOR_CSS_FINE_ADJ_PICTURE', '-20');
+define('PANCHOR_CSS_FINE_ADJ_SLIDESHOW', '-40');
+
+//Experimental feature!! - an automatic easing scroll can be implement via javascript
+//it is a nice smooth scroll to the pAnchor when navigating  to picture or slideshow 
+//from another page (that does not have # in url), versus a jump.  -  a nice effect!!
+//this feature will be DISABLED by default while experimental.  
+define('PANCHOR_EASE_ENABLE', false);
+
+//CSS for pAnchor
+//test and adjust CSS parameter in main.inc.php to fine tune as different browsers
+//can have subtle differences in anchor point.
+define('PANCHOR_CSS_PICTURE', '<style type="text/css"><!-- #pAnchor { position:relative; top: '.PANCHOR_CSS_FINE_ADJ_PICTURE.'px; } --> </style>');
+define('PANCHOR_CSS_SLIDESHOW', '<style type="text/css"><!-- #pAnchor { position:relative; top: '.PANCHOR_CSS_FINE_ADJ_SLIDESHOW.'px; } --> </style>');
+
+//include the plugin code
+include_once( PANCHOR_PATH . 'pAnchor.php');
+?>
Index: /extensions/pAnchor/pAnchor.js
===================================================================
--- /extensions/pAnchor/pAnchor.js	(revision 7862)
+++ /extensions/pAnchor/pAnchor.js	(revision 7862)
@@ -0,0 +1,67 @@
+// JavaScript Document
+
+//pAnchor plugin for piwigo - ease to anchor javascript functions (uses jquery)
+$(document).ready(function() {
+        //check for pAnchor anchor - name of anchor can be customized in main.inc.php
+        if ($('#pAnchor').attr('name')) {
+            //alert('pAnchor exists');
+            var url = window.location.href;
+            if (url.indexOf('#') == -1) {
+                //defaut values a=0.20, t=16 and delay=250
+                easeToInit('pAnchor', 0.20, 16, 250);
+            }
+        }        
+});
+
+
+function easeTo(yDest, yTemp, a, t) {
+	//easeTo function to scroll from 0 to yDest.  X will scroll to 0 also.
+	//yDest is y value of destination
+	//YTemp is temp value as scroll progresses to yDest
+	//a = a || 0.2;	//about  0.2
+	//t = t || 20;	//about 15-20 milliseconds
+
+	var x1 = 0;
+	var y1 = 0;
+	var x2 = 0;
+	var y2 = 0;
+	var x3 = 0;
+	var y3 = 0;
+
+	if (document.documentElement) {
+		x1 = document.documentElement.scrollLeft || 0;
+		y1 = document.documentElement.scrollTop || 0;
+	}
+	if (document.body) {
+		x2 = document.body.scrollLeft || 0;
+		y2 = document.body.scrollTop || 0;
+	}
+	x3 = window.scrollX || 0;
+	y3 = window.scrollY || 0;
+
+	var x = Math.max(x1, Math.max(x2, x3));
+	var y = Math.max(y1, Math.max(y2, y3));
+
+	var speed = 1 + a;
+	var yTemp =  Math.floor(yTemp / speed);
+	window.scrollTo(Math.floor(x / speed), yDest - yTemp);
+	if(x > 0 || yTemp > 1) {
+		var f = "easeTo(" + yDest + ", " + yTemp + ", " +  a + ", " + t + ")";
+		//alert(f);
+		window.setTimeout(f, t);
+	} else {
+		//alert('done');
+	}
+}
+
+function easeToInit(elem, a, t, delay){
+        //easeToInit initializes and easeTo operation
+        //elem is id of document element, a is psuedo-acceleration, t is timer for interative calls
+        //delay is just a small time delay before easeTo actually begins.  give the page a chance to be static before
+        //easeTo the desired element.  The position can be fined with params in the main.inc.php file.
+        //ALSO NOTE:  DIFFERENT BROWSERS WILL YEILDLY SLIGHLY DIFFERENT RESULTS, but typically within a few pixels.
+	y = document.getElementById(elem).offsetTop;
+	var f = "easeTo(" + y + ", " + y + ", " +  a + ", " + t + ")";
+	window.setTimeout(f, delay);
+}
+
Index: /extensions/pAnchor/pAnchor.php
===================================================================
--- /extensions/pAnchor/pAnchor.php	(revision 7862)
+++ /extensions/pAnchor/pAnchor.php	(revision 7862)
@@ -0,0 +1,113 @@
+<?php
+//pAnchor plugin code
+if (!defined('PHPWG_ROOT_PATH') or !defined('PANCHOR_DIR')) die('Hacking attempt!');
+
+function pAnchor_links($content) {
+	//iterate thru navigation links and append #<PANCHOR_NAME> to URL string variable
+	global $template;
+	
+	//picture nav buttons
+	$links = array('first','previous','next','last');
+	$tags = array('U_IMG');
+	foreach ($links as $link) {
+		$temp = $template->get_template_vars($link);
+		foreach ($tags as $tag) {
+			if (isset($temp[$tag]))  {
+				$temp[$tag] .= '#'.PANCHOR_NAME;
+				$template->assign($link, $temp);
+			}
+		}
+	}
+	
+	//slideshow nav buttons
+	$links = array('slideshow');
+	$tags = array('U_START_PLAY', 'U_STOP_PLAY', 'U_START_REPEAT', 'U_STOP_REPEAT', 'U_DEC_PERIOD', 'U_INC_PERIOD');
+	foreach ($links as $link) {
+		$temp = $template->get_template_vars($link);
+		foreach ($tags as $tag) {
+			if (isset($temp[$tag]))  {
+				$temp[$tag] .= '#'.PANCHOR_NAME;
+				$template->assign($link, $temp);
+			}
+		}
+	}
+	
+	//start slideshow nav button
+	$temp = $template->get_template_vars('U_SLIDESHOW_START');
+	if (isset($temp))  {
+		$temp .= '#'.PANCHOR_NAME;
+		$template->assign('U_SLIDESHOW_START', $temp);
+	}
+	//stop slideshow nav button
+	$temp = $template->get_template_vars('U_SLIDESHOW_STOP');
+	if (isset($temp))  {
+		$temp .= '#'.PANCHOR_NAME;
+		$template->assign('U_SLIDESHOW_STOP', $temp);
+	}
+	
+	//assign anchor name to  template var
+	$template->assign('PANCHOR_NAME', PANCHOR_NAME);
+	return $content;
+}	//end function pAnchor_links
+
+function pAnchor_picture_prefilter($content, &$smarty)	{
+	//add the HTML page anchor tag into picture template via search  string
+	global $template;
+	
+	$search = '#'.PANCHOR_PICTURE_SEARCH_TAG.'#';
+	$replacement = '<a id="pAnchor" name="{$PANCHOR_NAME}"></a>'.PANCHOR_PICTURE_SEARCH_TAG;
+	return preg_replace($search, $replacement, $content);
+}
+
+function pAnchor_slideshow_prefilter($content, &$smarty)	{
+	//add the HTML page anchor tag into slideshow template via search  string 
+	global $template;
+	
+	$search = '#'.PANCHOR_SLIDESHOW_SEARCH_TAG.'#';
+	$replacement = '<a id="pAnchor" name="{$PANCHOR_NAME}"></a>'.PANCHOR_SLIDESHOW_SEARCH_TAG;
+	return preg_replace($search, $replacement, $content);
+}
+
+function pAnchor_add_anchor() 	{
+	//setup add anchor prefilters for picture.tpl and slideshow.tpl
+	global $template;
+	$template->set_prefilter('picture', 'pAnchor_picture_prefilter');
+	$template->set_prefilter('slideshow', 'pAnchor_slideshow_prefilter');
+
+}
+
+function pAnchor_adj_meta_refresh() 	{
+	//adjust the <META refresh header element as this controls slideshow URL
+	global $template, $page;
+	  
+	$temp = $template->get_template_vars('page_refresh');
+	if (isset($temp['U_REFRESH']))  {
+		$temp['U_REFRESH'] = $temp['U_REFRESH'].'#'.PANCHOR_NAME;
+		$template->assign('page_refresh', $temp);
+	}
+	if (isset($page['slideshow'])) {
+		if ($page['slideshow']) {
+			//add CSS for  pAnchor to document head
+			$template->append('head_elements', PANCHOR_CSS_SLIDESHOW);
+			//load js for pAnchor
+		} else {
+		  //add CSS for  pAnchor to document head
+		  $template->append('head_elements', PANCHOR_CSS_PICTURE);		
+		}
+	}		
+	//experimental feature to auto ease scroll to pAnchor when navigating  
+	//to picture or slideshow from another page (that does not have # in url)
+	if ( PANCHOR_EASE_ENABLE == true) {
+		$template->append('head_elements', '<script src="'.get_root_url().PANCHOR_PATH.'pAnchor.js" type="text/javascript" charset="utf-8"></script>');
+	}
+}
+  
+//do NOT add anchors on ADMIN side of piwigo
+if (!defined('IN_ADMIN')) {
+	add_event_handler('render_element_content', 'pAnchor_links');
+	
+	add_event_handler('loc_end_picture', 'pAnchor_add_anchor');
+	add_event_handler('loc_end_page_header', 'pAnchor_adj_meta_refresh');
+}
+
+?>
