PhotoBlox plugin

About

PhotoBlox plugin is a simple usage of the PhotoBlox application in DokuWiki.

PhotoBlox is an image viewing Internet application that can be embedded into a personal blog template or Web page, and displayed in any modern Web browser. With some simple editing of an external XML configuration file, you can:

  • Display your own images on the Web with dynamic transition effects at any of 3 window sizes
  • Customize presentation such as speed, panning, zooming, framing borders and image annotations
  • Easily specify Creative Commons licenses to define usage rights for your images
  • Integrate a Buy via PayPal link just for fun (please note our terms of service in the next paragraph :-)
  • Point to an MP3 file to play background audio during the slideshow

With this plugin you can easily set up the PhotoBlox application. The only thing you have to specify is the location of the images to display which can be any directory on the server which is accessible.

Status

:!: Unfortunately the offical PhotoBlox site is down for a time ago. I don’t know what’s the problem with them. If it will be on-line, I will get the source code and change it to can be used as a local service. — Csík Norbert 2006.03.19 23:34

Syntax

The syntax is very easy, it’s a modified format of the media link syntax:

{PB{path/to/image/dir}}

The pointed directory should contain other directories called galleries. The galleries should contain the files you would like to show in the gallery. Every file in the galleries will shown in the application.

PhotoBlox can display JPEG, GIF, PNG and SWF files of arbitrary dimensions. For best viewing performance, authors recommend compressing files to 100 Kb or less.

Example

Check out my PhotoBlox Example page.

Configuration

Put these configuration parameters to the conf/local.php file and modify them to fit your needs.

$conf['photoblox']['path'] = '/file/system/path/to/image/root/'; // System path to the images. Used to create the list of files. Can be relative path too, in that case ../../../ is the DokuWiki root directory.
$conf['photoblox']['url'] = 'http://www.myhost.com/'; // Web path to the images. Used to download the images to the client.

$conf['photoblox']['fit'] = 'view2image'; // Fit image to view or the view to the image (image2view, view2image)
$conf['photoblox']['effect'] = 'pan'; // Available in image2view mode (pan, zoom)
$conf['photoblox']['effecttime'] = '6000'; // Milliseconds
$conf['photoblox']['crossfadetime'] = '3000'; // Milliseconds
$conf['photoblox']['slidedelay'] = '6000'; // Milliseconds
$conf['photoblox']['playallgalleries'] = 'false'; // In show mode plays all gallerys (true, false)
$conf['photoblox']['useframe'] = 'true'; // Frame around the image (true, false)
$conf['photoblox']['framewidth'] = '10'; // Frame size in pixels

Installation

Plugin sources: zip format (3k)

If your wiki uses either the plugin manager plugin you can use them with the links above to install the plugin.

To install the plugin manually, download the source to your plugin folder, lib/plugins and extract its contents. That will create a new plugin folder, lib/plugins/photoblox, and install the plugin.

The folder will contain:

syntax.php                             plugin script
list.php                               content xml generator script

The plugin is now installed.

Details

The plugin consists of two files, the plugin script syntax.php, and the content XML generator script list.php.

syntax.php

<?php
/**
 * Plugin PhotoBlox: Uses BlogBox's PhotoBlox application to show galleries
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Norbert CsĂ­k <norbert.csik@gmail.com>
 * @version    0.6.1
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_photoblox extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Norbert CsĂ­k',
            'email'  => 'norbert.csik@gmail.com',
            'date'   => '2006-03-08',
            'name'   => 'PhotoBlox Plugin',
            'desc'   => 'Uses BlogBox\'s PhotoBlox application to show galleries',
            'url'    => 'http://www.csik.net/project:photoblox',
        );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    /**
     * What kind of syntax do we allow (optional)
     */
//    function getAllowedTypes() {
//        return array();
//    }
 
    /**
     * What about paragraphs? (optional)
     */
//    function getPType(){
//        return 'normal';
//    }
 
    /**
     * Where to sort in?
     */
    function getSort(){
        return 999;
    }
 
 
    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern('\{PB\{.*?\}\}',$mode,'plugin_photoblox');
    }
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        switch ($state) {
          case DOKU_LEXER_ENTER :
            break;
          case DOKU_LEXER_MATCHED :
            break;
          case DOKU_LEXER_UNMATCHED :
            break;
          case DOKU_LEXER_EXIT :
            break;
          case DOKU_LEXER_SPECIAL :
            return array(substr($match, 4, strlen($match)-6));
            break;
        }
        return array();
    }
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
            $protocol = (isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'on') ? "https://" : "http://";
            $host = $_SERVER['HTTP_HOST'];
            $dir = dirname($_SERVER['PHP_SELF']);
            $url = $protocol.$host.$dir;
            
            $renderer->doc .= "<script type=\"text/javascript\" language=\"JavaScript\" src=\"http://www.mylaszlo.com/lps-krank/includes/embed.js\"></script>";
            $renderer->doc .= "<script type=\"text/javascript\" language=\"JavaScript\">";
            $renderer->doc .= "lzEmbed({url: 'http://www.mylaszlo.com/lps-2.0/showcase/photoblox/photoblox480x480.lzx?lzt=swf&data_url=".urlencode($url."/lib/plugins/photoblox/list.php?dir=".$data[0])."', bgcolor: '#ffffff', scale: 'noscale', width: '480', height: '480', menu: 'false'});";
            $renderer->doc .= "</script>";
 
            return true;
        }
        return false;
    }
}

list.php

<?php
/**
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Norbert Csík <norbert.csik@gmail.com>
 */
 
	header("Content-Type: text/xml; charset=utf-8");
 
	if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
	if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/');
	require_once(DOKU_CONF.'local.php');
	
	$dirname = $conf['photoblox']['path'].$_GET["dir"].'/';
	$hostname = $conf['photoblox']['url'];
	
	echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
	echo '<photobloxdata>';
	echo '<customize ';
	// fit
	if ($conf['photoblox']['fit'] == 'view2image') {
		echo 'fitimagetoview="false" fitviewtoimage="true" ';
	} elseif ($conf['photoblox']['fit'] == 'image2view') {
		echo 'fitimagetoview="true" fitviewtoimage="false" ';
	}
	// effect
	if ($conf['photoblox']['effect'] == 'pan') {
		echo 'pan="true" ';
	} elseif ($conf['photoblox']['effect'] == 'zoom') {
		echo 'zoom="true" ';
	}
	
	echo 'playallgalleries="'.$conf['photoblox']['playallgalleries'].'" ';
	echo 'useframe="'.$conf['photoblox']['useframe'].'" ';
	echo 'crossfadetime="'.$conf['photoblox']['crossfadetime'].'" ';
	echo 'slidedelaytime="'.$conf['photoblox']['slidedelay'].'" ';
	echo 'panzoomtime="'.$conf['photoblox']['effecttime'].'" ';
	echo 'motionmode="linear" zoomdepth="2" frameurl="lzmodules/assets/drop_shadow.png" origframesize="64" ';
	echo 'artframewidth="'.$conf['photoblox']['framewidth'].'" ';
	echo '/>';
	
	$dir = opendir($dirname);
	while ($subdirname=readdir($dir)) {
 
		if ($subdirname != "." && $subdirname != ".." && is_dir($dirname."/".$subdirname)) {
			echo '	<gallery name="'.$subdirname.'">';
 
			$subdir = opendir($dirname."/".$subdirname);
			while ($file = readdir($subdir)) {
				if ($file != "." && $file != "..") {
					echo "<image><imageurl>".$hostname.$_GET["dir"]."/".$subdirname."/".$file."</imageurl></image>";
				}
			}
 
			echo '	</gallery>';
		} else {
			echo $subdirname;
		}
	}
 
	echo '</photobloxdata>';
?>

Change log

  • 2006-03-10 — 0.6.1 Minor bugfix
    • Fixed bug: determining the location of the list.php was bad if you are using DokuWiki from a subdirectory
  • 2006-03-08 — 0.6 First release

To Do

  • Be able to set configuration parameters at usage
  • Using different size of boxes
  • Use local resources (currenlty flash is generated by www.mylaszlo.com)
  • Get useful information about the images (gallery description, image title, etc)
  • Use DokuWiki’s namespaces and media handling mechanism
 
project/photoblox.txt · Utolsó módosítás: 2006.04.11 13:54 szerkesztette: norbert
 
Valid XHTML 1.0 Valid CSS Driven by DokuWiki Get Firefox! Hosted by AION CSIK.net