index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
diff --git a/plugins/dokuwiki/lib/exe/fetch.php b/plugins/dokuwiki/lib/exe/fetch.php new file mode 100644 index 0000000..59e59ca --- /dev/null +++ b/plugins/dokuwiki/lib/exe/fetch.php @@ -0,0 +1,433 @@ +<?php +/** + * DokuWiki media passthrough file + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Andreas Gohr <andi@splitbrain.org> + */ + +# security hotfix +die(); + + if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); + define('DOKU_DISABLE_GZIP_OUTPUT', 1); + require_once(DOKU_INC.'inc/init.php'); + require_once(DOKU_INC.'inc/common.php'); + require_once(DOKU_INC.'inc/pageutils.php'); + require_once(DOKU_INC.'inc/confutils.php'); + //close sesseion + session_write_close(); + if(!defined('CHUNK_SIZE')) define('CHUNK_SIZE',16*1024); + + $mimetypes = getMimeTypes(); + + //get input + $MEDIA = stripctl(getID('media',false)); // no cleaning except control chars - maybe external + $CACHE = calc_cache($_REQUEST['cache']); + $WIDTH = (int) $_REQUEST['w']; + $HEIGHT = (int) $_REQUEST['h']; + list($EXT,$MIME) = mimetype($MEDIA); + if($EXT === false){ + $EXT = 'unknown'; + $MIME = 'application/octet-stream'; + } + + //media to local file + if(preg_match('#^(https?)://#i',$MEDIA)){ + //handle external images + if(strncmp($MIME,'image/',6) == 0) $FILE = get_from_URL($MEDIA,$EXT,$CACHE); + if(!$FILE){ + //download failed - redirect to original URL + header('Location: '.$MEDIA); + exit; + } + }else{ + $MEDIA = cleanID($MEDIA); + if(empty($MEDIA)){ + header("HTTP/1.0 400 Bad Request"); + print 'Bad request'; + exit; + } + + $FILE = mediaFN($MEDIA); + } + + //check file existance + if(!@file_exists($FILE)){ + header("HTTP/1.0 404 Not Found"); + //FIXME add some default broken image + print 'Not Found'; + exit; + } + + //handle image resizing + if((substr($MIME,0,5) == 'image') && $WIDTH){ + $FILE = get_resized($FILE,$EXT,$WIDTH,$HEIGHT); + } + + // finally send the file to the client + sendFile($FILE,$MIME,$CACHE); + +/* ------------------------------------------------------------------------ */ + +/** + * Set headers and send the file to the client + * + * @author Andreas Gohr <andi@splitbrain.org> + * @author Ben Coburn <btcoburn@silicodon.net> + */ +function sendFile($file,$mime,$cache){ + global $conf; + $fmtime = filemtime($file); + // send headers + header("Content-Type: $mime"); + // smart http caching headers + if ($cache==-1) { + // cache + // cachetime or one hour + header('Expires: '.gmdate("D, d M Y H:i:s", time()+max($conf['cachetime'], 3600)).' GMT'); + header('Cache-Control: public, proxy-revalidate, no-transform, max-age='.max($conf['cachetime'], 3600)); + header('Pragma: public'); + } else if ($cache>0) { + // recache + // remaining cachetime + 10 seconds so the newly recached media is used + header('Expires: '.gmdate("D, d M Y H:i:s", $fmtime+$conf['cachetime']+10).' GMT'); + header('Cache-Control: public, proxy-revalidate, no-transform, max-age='.max($fmtime-time()+$conf['cachetime']+10, 0)); + header('Pragma: public'); + } else if ($cache==0) { + // nocache + header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0'); + header('Pragma: public'); + } + header('Accept-Ranges: bytes'); + //send important headers first, script stops here if '304 Not Modified' response + http_conditionalRequest($fmtime); + list($start,$len) = http_rangeRequest(filesize($file)); + + //application mime type is downloadable + if(substr($mime,0,11) == 'application'){ + header('Content-Disposition: attachment; filename="'.basename($file).'";'); + } + + // send file contents + $fp = @fopen($file,"rb"); + if($fp){ + fseek($fp,$start); //seek to start of range + + $chunk = ($len > CHUNK_SIZE) ? CHUNK_SIZE : $len; + while (!feof($fp) && $chunk > 0) { + @set_time_limit(); // large files can take a lot of time + print fread($fp, $chunk); + flush(); + $len -= $chunk; + $chunk = ($len > CHUNK_SIZE) ? CHUNK_SIZE : $len; + } + fclose($fp); + }else{ + header("HTTP/1.0 500 Internal Server Error"); + print "Could not read $file - bad permissions?"; + } +} + +/** + * Checks and sets headers to handle range requets + * + * @author Andreas Gohr <andi@splitbrain.org> + * @returns array The start byte and the amount of bytes to send + */ +function http_rangeRequest($size){ + if(!isset($_SERVER['HTTP_RANGE'])){ + // no range requested - send the whole file + header("Content-Length: $size"); + return array(0,$size); + } + + $t = explode('=', $_SERVER['HTTP_RANGE']); + if (!$t[0]=='bytes') { + // we only understand byte ranges - send the whole file + header("Content-Length: $size"); + return array(0,$size); + } + + $r = explode('-', $t[1]); + $start = (int)$r[0]; + $end = (int)$r[1]; + if (!$end) $end = $size - 1; + if ($start > $end || $start > $size || $end > $size){ + header('HTTP/1.1 416 Requested Range Not Satisfiable'); + print 'Bad Range Request!'; + exit; + } + + $tot = $end - $start + 1; + header('HTTP/1.1 206 Partial Content'); + header("Content-Range: bytes {$start}-{$end}/{$size}"); + header("Content-Length: $tot"); + + return array($start,$tot); +} + +/** + * Resizes the given image to the given size + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function get_resized($file, $ext, $w, $h=0){ + global $conf; + + $info = getimagesize($file); + if(!$h) $h = round(($w * $info[1]) / $info[0]); + + // we wont scale up to infinity + if($w > 2000 || $h > 2000) return $file; + + //cache + $local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext); + $mtime = @filemtime($local); // 0 if not exists + + if( $mtime > filemtime($file) || + resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) || + resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){ + return $local; + } + //still here? resizing failed + return $file; +} + +/** + * Returns the wanted cachetime in seconds + * + * Resolves named constants + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function calc_cache($cache){ + global $conf; + + if(strtolower($cache) == 'nocache') return 0; //never cache + if(strtolower($cache) == 'recache') return $conf['cachetime']; //use standard cache + return -1; //cache endless +} + +/** + * Download a remote file and return local filename + * + * returns false if download fails. Uses cached file if available and + * wanted + * + * @author Andreas Gohr <andi@splitbrain.org> + * @author Pavel Vitis <Pavel.Vitis@seznam.cz> + */ +function get_from_URL($url,$ext,$cache){ + global $conf; + + // if no cache or fetchsize just redirect + if ($cache==0) return false; + if (!$conf['fetchsize']) return false; + + $local = getCacheName(strtolower($url),".media.$ext"); + $mtime = @filemtime($local); // 0 if not exists + + //decide if download needed: + if( ($mtime == 0) || // cache does not exist + ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired + ){ + if(image_download($url,$local)){ + return $local; + }else{ + return false; + } + } + + //if cache exists use it else + if($mtime) return $local; + + //else return false + return false; +} + +/** + * Download image files + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function image_download($url,$file){ + global $conf; + $http = new DokuHTTPClient(); + $http->max_bodysize = $conf['fetchsize']; + $http->timeout = 25; //max. 25 sec + $http->header_regexp = '!\r\nContent-Type: image/(jpe?g|gif|png)!i'; + + $data = $http->get($url); + if(!$data) return false; + + $fileexists = @file_exists($file); + $fp = @fopen($file,"w"); + if(!$fp) return false; + fwrite($fp,$data); + fclose($fp); + if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); + + // check if it is really an image + $info = @getimagesize($file); + if(!$info){ + @unlink($file); + return false; + } + + return true; +} + +/** + * resize images using external ImageMagick convert program + * + * @author Pavel Vitis <Pavel.Vitis@seznam.cz> + * @author Andreas Gohr <andi@splitbrain.org> + */ +function resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ + global $conf; + + // check if convert is configured + if(!$conf['im_convert']) return false; + + // prepare command + $cmd = $conf['im_convert']; + $cmd .= ' -resize '.$to_w.'x'.$to_h.'!'; + if ($ext == 'jpg' || $ext == 'jpeg') { + $cmd .= ' -quality '.$conf['jpg_quality']; + } + $cmd .= " $from $to"; + + @exec($cmd,$out,$retval); + if ($retval == 0) return true; + return false; +} + +/** + * resize images using PHP's libGD support + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ + global $conf; + + if($conf['gdlib'] < 1) return false; //no GDlib available or wanted + + // check available memory + if(!is_mem_available(($from_w * $from_h * 4) + ($to_w * $to_h * 4))){ + return false; + } + + // create an image of the given filetype + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists("imagecreatefromjpeg")) return false; + $image = @imagecreatefromjpeg($from); + }elseif($ext == 'png') { + if(!function_exists("imagecreatefrompng")) return false; + $image = @imagecreatefrompng($from); + + }elseif($ext == 'gif') { + if(!function_exists("imagecreatefromgif")) return false; + $image = @imagecreatefromgif($from); + } + if(!$image) return false; + + if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor")){ + $newimg = @imagecreatetruecolor ($to_w, $to_h); + } + if(!$newimg) $newimg = @imagecreate($to_w, $to_h); + if(!$newimg){ + imagedestroy($image); + return false; + } + + //keep png alpha channel if possible + if($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')){ + imagealphablending($newimg, false); + imagesavealpha($newimg,true); + } + + //try resampling first + if(function_exists("imagecopyresampled")){ + if(!@imagecopyresampled($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h)) { + imagecopyresized($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h); + } + }else{ + imagecopyresized($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h); + } + + $okay = false; + if ($ext == 'jpg' || $ext == 'jpeg'){ + if(!function_exists('imagejpeg')){ + $okay = false; + }else{ + $okay = imagejpeg($newimg, $to, $conf['jpg_quality']); + } + }elseif($ext == 'png') { + if(!function_exists('imagepng')){ + $okay = false; + }else{ + $okay = imagepng($newimg, $to); + } + }elseif($ext == 'gif') { + if(!function_exists('imagegif')){ + $okay = false; + }else{ + $okay = imagegif($newimg, $to); + } + } + + // destroy GD image ressources + if($image) imagedestroy($image); + if($newimg) imagedestroy($newimg); + + return $okay; +} + +/** + * Checks if the given amount of memory is available + * + * If the memory_get_usage() function is not available the + * function just assumes $used bytes of already allocated memory + * + * @param int $mem Size of memory you want to allocate in bytes + * @param int $used already allocated memory (see above) + * @author Filip Oscadal <webmaster@illusionsoftworks.cz> + * @author Andreas Gohr <andi@splitbrain.org> + */ +function is_mem_available($mem,$bytes=1048576){ + $limit = trim(ini_get('memory_limit')); + if(empty($limit)) return true; // no limit set! + + // parse limit to bytes + $unit = strtolower(substr($limit,-1)); + switch($unit){ + case 'g': + $limit = substr($limit,0,-1); + $limit *= 1024*1024*1024; + break; + case 'm': + $limit = substr($limit,0,-1); + $limit *= 1024*1024; + break; + case 'k': + $limit = substr($limit,0,-1); + $limit *= 1024; + break; + } + + // get used memory if possible + if(function_exists('memory_get_usage')){ + $used = memory_get_usage(); + } + + + if($used+$mem > $limit){ + return false; + } + + return true; +} + +//Setup VIM: ex: et ts=2 enc=utf-8 : +?> diff --git a/plugins/dokuwiki/lib/images/fileicons/bz2.png b/plugins/dokuwiki/lib/images/fileicons/bz2.png Binary files differnew file mode 100644 index 0000000..d48cae0 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/bz2.png diff --git a/plugins/dokuwiki/lib/images/fileicons/conf.png b/plugins/dokuwiki/lib/images/fileicons/conf.png Binary files differnew file mode 100644 index 0000000..ddffe6f --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/conf.png diff --git a/plugins/dokuwiki/lib/images/fileicons/deb.png b/plugins/dokuwiki/lib/images/fileicons/deb.png Binary files differnew file mode 100644 index 0000000..9229d87 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/deb.png diff --git a/plugins/dokuwiki/lib/images/fileicons/doc.png b/plugins/dokuwiki/lib/images/fileicons/doc.png Binary files differnew file mode 100644 index 0000000..932567f --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/doc.png diff --git a/plugins/dokuwiki/lib/images/fileicons/file.gif b/plugins/dokuwiki/lib/images/fileicons/file.gif Binary files differnew file mode 100644 index 0000000..815ccb1 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/file.gif diff --git a/plugins/dokuwiki/lib/images/fileicons/file.png b/plugins/dokuwiki/lib/images/fileicons/file.png Binary files differnew file mode 100644 index 0000000..817014f --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/file.png diff --git a/plugins/dokuwiki/lib/images/fileicons/gif.png b/plugins/dokuwiki/lib/images/fileicons/gif.png Binary files differnew file mode 100644 index 0000000..b4c07a9 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/gif.png diff --git a/plugins/dokuwiki/lib/images/fileicons/gz.png b/plugins/dokuwiki/lib/images/fileicons/gz.png Binary files differnew file mode 100644 index 0000000..2426bd1 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/gz.png diff --git a/plugins/dokuwiki/lib/images/fileicons/htm.png b/plugins/dokuwiki/lib/images/fileicons/htm.png Binary files differnew file mode 100644 index 0000000..1a68121 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/htm.png diff --git a/plugins/dokuwiki/lib/images/fileicons/html.png b/plugins/dokuwiki/lib/images/fileicons/html.png Binary files differnew file mode 100644 index 0000000..672cbce --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/html.png diff --git a/plugins/dokuwiki/lib/images/fileicons/index.php b/plugins/dokuwiki/lib/images/fileicons/index.php new file mode 100644 index 0000000..805b36d --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/index.php @@ -0,0 +1,49 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" + lang="en" dir="ltr"> + <title>filetype icons</title> + + <style type="text/css"> + body { + background-color: #ccc; + font-family: Arial; + } + + .box { + width: 200px; + float:left; + padding: 0.5em; + margin: 0; + } + + .white { + background-color: #fff; + } + + .black { + background-color: #000; + } + </style> + +</head> +<body> + +<div class="white box"> +<?php +foreach (glob('*.png') as $img) { + echo '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> '; +} +?> +</div> + +<div class="black box"> +<?php +foreach (glob('*.png') as $img) { + echo '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> '; +} +?> +</div> + +</body> +</html> diff --git a/plugins/dokuwiki/lib/images/fileicons/jpeg.png b/plugins/dokuwiki/lib/images/fileicons/jpeg.png Binary files differnew file mode 100644 index 0000000..aa4cc23 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/jpeg.png diff --git a/plugins/dokuwiki/lib/images/fileicons/jpg.png b/plugins/dokuwiki/lib/images/fileicons/jpg.png Binary files differnew file mode 100644 index 0000000..1fb6cc1 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/jpg.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odc.png b/plugins/dokuwiki/lib/images/fileicons/odc.png Binary files differnew file mode 100644 index 0000000..47f65c8 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odc.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odf.png b/plugins/dokuwiki/lib/images/fileicons/odf.png Binary files differnew file mode 100644 index 0000000..a2fbc51 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odf.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odg.png b/plugins/dokuwiki/lib/images/fileicons/odg.png Binary files differnew file mode 100644 index 0000000..434f182 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odg.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odi.png b/plugins/dokuwiki/lib/images/fileicons/odi.png Binary files differnew file mode 100644 index 0000000..74f6303 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odi.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odp.png b/plugins/dokuwiki/lib/images/fileicons/odp.png Binary files differnew file mode 100644 index 0000000..a5c77f8 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odp.png diff --git a/plugins/dokuwiki/lib/images/fileicons/ods.png b/plugins/dokuwiki/lib/images/fileicons/ods.png Binary files differnew file mode 100644 index 0000000..2ab1273 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/ods.png diff --git a/plugins/dokuwiki/lib/images/fileicons/odt.png b/plugins/dokuwiki/lib/images/fileicons/odt.png Binary files differnew file mode 100644 index 0000000..b0c21fc --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/odt.png diff --git a/plugins/dokuwiki/lib/images/fileicons/pdf.png b/plugins/dokuwiki/lib/images/fileicons/pdf.png Binary files differnew file mode 100644 index 0000000..638066d --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/pdf.png diff --git a/plugins/dokuwiki/lib/images/fileicons/png.png b/plugins/dokuwiki/lib/images/fileicons/png.png Binary files differnew file mode 100644 index 0000000..f0b5b00 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/png.png diff --git a/plugins/dokuwiki/lib/images/fileicons/ppt.png b/plugins/dokuwiki/lib/images/fileicons/ppt.png Binary files differnew file mode 100644 index 0000000..adaefc6 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/ppt.png diff --git a/plugins/dokuwiki/lib/images/fileicons/ps.png b/plugins/dokuwiki/lib/images/fileicons/ps.png Binary files differnew file mode 100644 index 0000000..c51c763 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/ps.png diff --git a/plugins/dokuwiki/lib/images/fileicons/rpm.png b/plugins/dokuwiki/lib/images/fileicons/rpm.png Binary files differnew file mode 100644 index 0000000..22212ea --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/rpm.png diff --git a/plugins/dokuwiki/lib/images/fileicons/rtf.png b/plugins/dokuwiki/lib/images/fileicons/rtf.png Binary files differnew file mode 100644 index 0000000..d8bada5 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/rtf.png diff --git a/plugins/dokuwiki/lib/images/fileicons/swf.png b/plugins/dokuwiki/lib/images/fileicons/swf.png Binary files differnew file mode 100644 index 0000000..0729ed0 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/swf.png diff --git a/plugins/dokuwiki/lib/images/fileicons/sxc.png b/plugins/dokuwiki/lib/images/fileicons/sxc.png Binary files differnew file mode 100644 index 0000000..419c183 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/sxc.png diff --git a/plugins/dokuwiki/lib/images/fileicons/sxd.png b/plugins/dokuwiki/lib/images/fileicons/sxd.png Binary files differnew file mode 100644 index 0000000..5801bb2 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/sxd.png diff --git a/plugins/dokuwiki/lib/images/fileicons/sxi.png b/plugins/dokuwiki/lib/images/fileicons/sxi.png Binary files differnew file mode 100644 index 0000000..2a94290 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/sxi.png diff --git a/plugins/dokuwiki/lib/images/fileicons/sxw.png b/plugins/dokuwiki/lib/images/fileicons/sxw.png Binary files differnew file mode 100644 index 0000000..6da97be --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/sxw.png diff --git a/plugins/dokuwiki/lib/images/fileicons/tar.png b/plugins/dokuwiki/lib/images/fileicons/tar.png Binary files differnew file mode 100644 index 0000000..5a2f717 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/tar.png diff --git a/plugins/dokuwiki/lib/images/fileicons/tgz.png b/plugins/dokuwiki/lib/images/fileicons/tgz.png Binary files differnew file mode 100644 index 0000000..141acf5 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/tgz.png diff --git a/plugins/dokuwiki/lib/images/fileicons/txt.png b/plugins/dokuwiki/lib/images/fileicons/txt.png Binary files differnew file mode 100644 index 0000000..da20009 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/txt.png diff --git a/plugins/dokuwiki/lib/images/fileicons/xls.png b/plugins/dokuwiki/lib/images/fileicons/xls.png Binary files differnew file mode 100644 index 0000000..e8cd58d --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/xls.png diff --git a/plugins/dokuwiki/lib/images/fileicons/xml.png b/plugins/dokuwiki/lib/images/fileicons/xml.png Binary files differnew file mode 100644 index 0000000..eb46323 --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/xml.png diff --git a/plugins/dokuwiki/lib/images/fileicons/zip.png b/plugins/dokuwiki/lib/images/fileicons/zip.png Binary files differnew file mode 100644 index 0000000..999ffbe --- /dev/null +++ b/plugins/dokuwiki/lib/images/fileicons/zip.png diff --git a/plugins/dokuwiki/lib/images/interwiki/amazon.de.gif b/plugins/dokuwiki/lib/images/interwiki/amazon.de.gif Binary files differnew file mode 100644 index 0000000..f52c1c5 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/amazon.de.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/amazon.gif b/plugins/dokuwiki/lib/images/interwiki/amazon.gif Binary files differnew file mode 100644 index 0000000..f52c1c5 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/amazon.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/amazon.uk.gif b/plugins/dokuwiki/lib/images/interwiki/amazon.uk.gif Binary files differnew file mode 100644 index 0000000..f52c1c5 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/amazon.uk.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/bug.gif b/plugins/dokuwiki/lib/images/interwiki/bug.gif Binary files differnew file mode 100644 index 0000000..3432b8d --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/bug.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/coral.gif b/plugins/dokuwiki/lib/images/interwiki/coral.gif Binary files differnew file mode 100644 index 0000000..0f9f675 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/coral.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/doku.gif b/plugins/dokuwiki/lib/images/interwiki/doku.gif Binary files differnew file mode 100644 index 0000000..7dc4248 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/doku.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/google.gif b/plugins/dokuwiki/lib/images/interwiki/google.gif Binary files differnew file mode 100644 index 0000000..fb39f61 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/google.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/meatball.gif b/plugins/dokuwiki/lib/images/interwiki/meatball.gif Binary files differnew file mode 100644 index 0000000..7ac5454 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/meatball.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/phpfn.gif b/plugins/dokuwiki/lib/images/interwiki/phpfn.gif Binary files differnew file mode 100644 index 0000000..638d4c4 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/phpfn.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/sb.gif b/plugins/dokuwiki/lib/images/interwiki/sb.gif Binary files differnew file mode 100644 index 0000000..e272a29 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/sb.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/wiki.gif b/plugins/dokuwiki/lib/images/interwiki/wiki.gif Binary files differnew file mode 100644 index 0000000..e8dc5d2 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/wiki.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/wp.gif b/plugins/dokuwiki/lib/images/interwiki/wp.gif Binary files differnew file mode 100644 index 0000000..ca853b8 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/wp.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/wpde.gif b/plugins/dokuwiki/lib/images/interwiki/wpde.gif Binary files differnew file mode 100644 index 0000000..ca853b8 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/wpde.gif diff --git a/plugins/dokuwiki/lib/images/interwiki/wpmeta.gif b/plugins/dokuwiki/lib/images/interwiki/wpmeta.gif Binary files differnew file mode 100644 index 0000000..ca853b8 --- /dev/null +++ b/plugins/dokuwiki/lib/images/interwiki/wpmeta.gif diff --git a/plugins/dokuwiki/lib/images/smileys/delete.gif b/plugins/dokuwiki/lib/images/smileys/delete.gif Binary files differnew file mode 100644 index 0000000..d668348 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/delete.gif diff --git a/plugins/dokuwiki/lib/images/smileys/fixme.gif b/plugins/dokuwiki/lib/images/smileys/fixme.gif Binary files differnew file mode 100644 index 0000000..b66ea99 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/fixme.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_arrow.gif b/plugins/dokuwiki/lib/images/smileys/icon_arrow.gif Binary files differnew file mode 100644 index 0000000..2880055 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_arrow.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_biggrin.gif b/plugins/dokuwiki/lib/images/smileys/icon_biggrin.gif Binary files differnew file mode 100644 index 0000000..d352772 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_biggrin.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_confused.gif b/plugins/dokuwiki/lib/images/smileys/icon_confused.gif Binary files differnew file mode 100644 index 0000000..0c49e06 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_confused.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_cool.gif b/plugins/dokuwiki/lib/images/smileys/icon_cool.gif Binary files differnew file mode 100644 index 0000000..cead030 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_cool.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_cry.gif b/plugins/dokuwiki/lib/images/smileys/icon_cry.gif Binary files differnew file mode 100644 index 0000000..7d54b1f --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_cry.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_doubt.gif b/plugins/dokuwiki/lib/images/smileys/icon_doubt.gif Binary files differnew file mode 100644 index 0000000..fd7903b --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_doubt.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_doubt2.gif b/plugins/dokuwiki/lib/images/smileys/icon_doubt2.gif Binary files differnew file mode 100644 index 0000000..eb4b70b --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_doubt2.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_eek.gif b/plugins/dokuwiki/lib/images/smileys/icon_eek.gif Binary files differnew file mode 100644 index 0000000..5d39781 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_eek.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_evil.gif b/plugins/dokuwiki/lib/images/smileys/icon_evil.gif Binary files differnew file mode 100644 index 0000000..ab1aa8e --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_evil.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_exclaim.gif b/plugins/dokuwiki/lib/images/smileys/icon_exclaim.gif Binary files differnew file mode 100644 index 0000000..6e50e2e --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_exclaim.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_frown.gif b/plugins/dokuwiki/lib/images/smileys/icon_frown.gif Binary files differnew file mode 100644 index 0000000..d2ac78c --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_frown.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_fun.gif b/plugins/dokuwiki/lib/images/smileys/icon_fun.gif Binary files differnew file mode 100644 index 0000000..a8bb8a3 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_fun.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_idea.gif b/plugins/dokuwiki/lib/images/smileys/icon_idea.gif Binary files differnew file mode 100644 index 0000000..a40ae0d --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_idea.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_kaddi.gif b/plugins/dokuwiki/lib/images/smileys/icon_kaddi.gif Binary files differnew file mode 100644 index 0000000..1410f7f --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_kaddi.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_lol.gif b/plugins/dokuwiki/lib/images/smileys/icon_lol.gif Binary files differnew file mode 100644 index 0000000..374ba15 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_lol.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_mrgreen.gif b/plugins/dokuwiki/lib/images/smileys/icon_mrgreen.gif Binary files differnew file mode 100644 index 0000000..b54cd0f --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_mrgreen.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_neutral.gif b/plugins/dokuwiki/lib/images/smileys/icon_neutral.gif Binary files differnew file mode 100644 index 0000000..4f31156 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_neutral.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_question.gif b/plugins/dokuwiki/lib/images/smileys/icon_question.gif Binary files differnew file mode 100644 index 0000000..9d07226 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_question.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_razz.gif b/plugins/dokuwiki/lib/images/smileys/icon_razz.gif Binary files differnew file mode 100644 index 0000000..29da2a2 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_razz.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_redface.gif b/plugins/dokuwiki/lib/images/smileys/icon_redface.gif Binary files differnew file mode 100644 index 0000000..ad76283 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_redface.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_rolleyes.gif b/plugins/dokuwiki/lib/images/smileys/icon_rolleyes.gif Binary files differnew file mode 100644 index 0000000..d7f5f2f --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_rolleyes.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_sad.gif b/plugins/dokuwiki/lib/images/smileys/icon_sad.gif Binary files differnew file mode 100644 index 0000000..d2ac78c --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_sad.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_silenced.gif b/plugins/dokuwiki/lib/images/smileys/icon_silenced.gif Binary files differnew file mode 100644 index 0000000..448399b --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_silenced.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_smile.gif b/plugins/dokuwiki/lib/images/smileys/icon_smile.gif Binary files differnew file mode 100644 index 0000000..7b1f6d3 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_smile.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_smile2.gif b/plugins/dokuwiki/lib/images/smileys/icon_smile2.gif Binary files differnew file mode 100644 index 0000000..769639d --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_smile2.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_surprised.gif b/plugins/dokuwiki/lib/images/smileys/icon_surprised.gif Binary files differnew file mode 100644 index 0000000..cb21424 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_surprised.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_twisted.gif b/plugins/dokuwiki/lib/images/smileys/icon_twisted.gif Binary files differnew file mode 100644 index 0000000..502fe24 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_twisted.gif diff --git a/plugins/dokuwiki/lib/images/smileys/icon_wink.gif b/plugins/dokuwiki/lib/images/smileys/icon_wink.gif Binary files differnew file mode 100644 index 0000000..d148288 --- /dev/null +++ b/plugins/dokuwiki/lib/images/smileys/icon_wink.gif diff --git a/plugins/dokuwiki/lib/plugins/changelinks/syntax.php b/plugins/dokuwiki/lib/plugins/changelinks/syntax.php new file mode 100644 index 0000000..263e066 --- /dev/null +++ b/plugins/dokuwiki/lib/plugins/changelinks/syntax.php @@ -0,0 +1,157 @@ +<?php +/** + * Change-Interwikilinks Plugin + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Florian Schmitz floele at gmail dot com + */ + +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_changelinks extends DokuWiki_Syntax_Plugin { + + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Florian Schmitz', + 'email' => 'floele@gmail.com', + 'date' => '2005-12-18', + 'name' => 'Change-Interwikilinks Plugin', + 'desc' => 'Changes the functionality of interwikilinks', + 'url' => 'http://flyspray.org/', + ); + } + + /** + * What kind of syntax are we? + */ + function getType(){ + return 'substition'; + } + + /** + * Where to sort in? + */ + function getSort(){ + return 299; + } + + /** + * Connect pattern to lexer + */ + + function connectTo($mode) { + // Word boundaries? + $this->Lexer->addSpecialPattern("\[\[.+?\]\]",$mode,'plugin_changelinks'); + } + + /** + * Handle the match + */ + function handle($match, $state, $pos, &$handler){ + // Strip the opening and closing markup + $link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match); + + // Split title from URL + $link = preg_split('/\|/u',$link,2); + if ( !isset($link[1]) ) { + $link[1] = NULL; + } else if ( preg_match('/^\{\{[^\}]+\}\}$/',$link[1]) ) { + // If the title is an image, convert it to an array containing the image details + $link[1] = Doku_Handler_Parse_Media($link[1]); + } + $link[0] = trim($link[0]); + + //decide which kind of link it is + + if ( preg_match('/^[a-zA-Z]+>{1}.*$/u',$link[0]) ) { + // Interwiki + $interwiki = preg_split('/>/u',$link[0]); + $handler->_addCall( + 'interwikilink', + array($link[0],$link[1],strtolower($interwiki[0]),$interwiki[1]), + $pos + ); + } elseif ( preg_match('/^\\\\\\\\[\w.:?\-;,]+?\\\\/u',$link[0]) ) { + // Windows Share + $handler->_addCall( + 'windowssharelink', + array($link[0],$link[1]), + $pos + ); + } elseif ( preg_match('#^([a-z0-9\-\.+]+?)://#i',$link[0]) ) { + // external link (accepts all protocols) + $handler->_addCall( + 'externallink', + array($link[0],$link[1]), + $pos + ); + } elseif ( preg_match('#([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i',$link[0]) ) { + // E-Mail + $handler->_addCall( + 'emaillink', + array($link[0],$link[1]), + $pos + ); + } elseif ( preg_match('!^#.+!',$link[0]) ){ + // local link + $handler->_addCall( + 'locallink', + array(substr($link[0],1),$link[1]), + $pos + ); + } else { + return array($link[0],$link[1]); + } + } + + /** + * Create output + */ + function render($mode, &$renderer, $data) { + if($mode == 'xhtml') { + global $conf; + $id = $data[0]; + $name = $data[1]; + + //prepare for formating + $link['target'] = $conf['target']['wiki']; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = ''; + $link['class'] = 'internallink'; + $link['url'] = DOKU_INTERNAL_LINK . $id; + + if(is_array($name)){ + $link['name'] = (isset($name['title'])) ? hsc($name['title']) : hsc($id); + $link['title'] = $id; + } else{ + $link['name'] = ($name) ? hsc($name) : hsc($id); + $link['title'] = ($name) ? $name : $id; + } + + //add search string + if($search){ + ($conf['userewrite']) ? $link['url'].='?s=' : $link['url'].='&s='; + $link['url'] .= urlencode($search); + } + + //output formatted + $renderer->doc .= $renderer->_formatLink($link); + } + return true; + } + +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : +?> diff --git a/plugins/dokuwiki/lib/plugins/fslink/syntax.php b/plugins/dokuwiki/lib/plugins/fslink/syntax.php new file mode 100644 index 0000000..57c91c3 --- /dev/null +++ b/plugins/dokuwiki/lib/plugins/fslink/syntax.php @@ -0,0 +1,81 @@ +<?php +/** + * FS#X and bug X plugin + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Florian Schmitz floele at gmail dot com + */ + +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_fslink extends DokuWiki_Syntax_Plugin { + + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Florian Schmitz', + 'email' => 'floele@gmail.com', + 'date' => '2005-12-17', + 'name' => 'FS-link Plugin', + 'desc' => 'Enables Flyspray\'s bug links', + 'url' => 'http://flyspray.org/', + ); + } + + /** + * What kind of syntax are we? + */ + function getType(){ + return 'substition'; + } + + /** + * Where to sort in? + */ + function getSort(){ + return 301; + } + + /** + * Connect pattern to lexer + */ + + function connectTo($mode) { + // Word boundaries? + $this->Lexer->addSpecialPattern('FS#\d+',$mode,'plugin_fslink'); + $this->Lexer->addSpecialPattern('bug \d+',$mode,'plugin_fslink'); + } + + /** + * Handle the match + */ + function handle($match, $state, $pos, &$handler){ + return array($match, $state); + } + + /** + * Create output + */ + function render($mode, &$renderer, $data) { + if($mode == 'xhtml'){ + $fsid = explode('#', $data[0]); + if(count($fsid) < 2) { + $fsid = explode(' ', $data[0]); + } + $renderer->doc .= tpl_tasklink($fsid[1], $data[0]); + } + return true; + } + +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : +?>
\ No newline at end of file diff --git a/plugins/dokuwiki/lib/plugins/newline/syntax.php b/plugins/dokuwiki/lib/plugins/newline/syntax.php new file mode 100644 index 0000000..6a5eed8 --- /dev/null +++ b/plugins/dokuwiki/lib/plugins/newline/syntax.php @@ -0,0 +1,77 @@ +<?php +/** + * Adds simple <br />s + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Florian Schmitz floele at gmail dot com + */ + +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_newline extends DokuWiki_Syntax_Plugin { + + /** + * return some info + */ + function getInfo(){ + return array( + 'author' => 'Florian Schmitz', + 'email' => 'floele@gmail.com', + 'date' => '2005-12-17', + 'name' => '<br /> Plugin', + 'desc' => 'Enables simple newlines', + 'url' => 'http://flyspray.org/', + ); + } + + /** + * What kind of syntax are we? + */ + function getType(){ + return 'substition'; + } + + /** + * Where to sort in? + */ + function getSort(){ + return 201; + } + + /** + * Connect pattern to lexer + */ + + function connectTo($mode) { + // Word boundaries? + $this->Lexer->addSpecialPattern("(?<!^|\n)\n(?!\n)",$mode,'plugin_newline'); + } + + /** + * Handle the match + */ + function handle($match, $state, $pos, &$handler){ + return array($match, $state); + } + + /** + * Create output + */ + function render($mode, &$renderer, $data) { + if($mode == 'xhtml'){ + if ($data[0]) $renderer->doc .= '<br />'; + return true; + } + return false; + } + +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : +?>
\ No newline at end of file diff --git a/plugins/dokuwiki/lib/plugins/syntax.php b/plugins/dokuwiki/lib/plugins/syntax.php new file mode 100644 index 0000000..ccf6577 --- /dev/null +++ b/plugins/dokuwiki/lib/plugins/syntax.php @@ -0,0 +1,270 @@ +<?php +/** + * Syntax Plugin Prototype + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Andreas Gohr <andi@splitbrain.org> + */ +// must be run within Dokuwiki +if(!defined('DOKU_INC')) die(); + +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_INC.'inc/parser/parser.php'); + +/** + * All DokuWiki plugins to extend the parser/rendering mechanism + * need to inherit from this class + */ +class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { + + var $allowedModesSetup = false; + var $localised = false; // set to true by setupLocale() after loading language dependent strings + var $lang = array(); // array to hold language dependent strings, best accessed via ->getLang() + var $configloaded = false; // set to true by loadConfig() after loading plugin configuration variables + var $conf = array(); // array to hold plugin settings, best accessed via ->getConf() + + /** + * General Info + * + * Needs to return a associative array with the following values: + * + * author - Author of the plugin + * email - Email address to contact the author + * date - Last modified date of the plugin in YYYY-MM-DD format + * name - Name of the plugin + * desc - Short description of the plugin (Text only) + * url - Website with more information on the plugin (eg. syntax description) + */ + function getInfo(){ + trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING); + } + + /** + * Syntax Type + * + * Needs to return one of the mode types defined in $PARSER_MODES in parser.php + */ + function getType(){ + trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING); + } + + /** + * Allowed Mode Types + * + * Defines the mode types for other dokuwiki markup that maybe nested within the + * plugin's own markup. Needs to return an array of one or more of the mode types + * defined in $PARSER_MODES in parser.php + */ + function getAllowedTypes() { + return array(); + } + + /** + * Paragraph Type + * + * Defines how this syntax is handled regarding paragraphs. This is important + * for correct XHTML nesting. Should return one of the following: + * + * 'normal' - The plugin can be used inside paragraphs + * 'block' - Open paragraphs need to be closed before plugin output + * 'stack' - Special case. Plugin wraps other paragraphs. + * + * @see Doku_Handler_Block + */ + function getPType(){ + return 'normal'; + } + + /** + * Handler to prepare matched data for the rendering process + * + * This function can only pass data to render() via its return value - render() + * may be not be run during the object's current life. + * + * Usually you should only need the $match param. + * + * @param $match string The text matched by the patterns + * @param $state int The lexer state for the match + * @param $pos int The character position of the matched text + * @param $handler ref Reference to the Doku_Handler object + * @return array Return an array with all data you want to use in render + */ + function handle($match, $state, $pos, &$handler){ + trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); + } + + /** + * Handles the actual output creation. + * + * The function must not assume any other of the classes methods have been run + * during the object's current life. The only reliable data it receives are its + * parameters. + * + * The function should always check for the given output format and return false + * when a format isn't supported. + * + * $renderer contains a reference to the renderer object which is + * currently handling the rendering. You need to use it for writing + * the output. How this is done depends on the renderer used (specified + * by $format + * + * The contents of the $data array depends on what the handler() function above + * created + * + * @param $format string output format to being Rendered + * @param $renderer ref reference to the current renderer object + * @param $data array data created by handler() + * @return boolean rendered correctly? + */ + function render($format, &$renderer, $data) { + trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); + + } + + /** + * There should be no need to override these functions + */ + function accepts($mode) { + + if (!$this->allowedModesSetup) { + global $PARSER_MODES; + + $allowedModeTypes = $this->getAllowedTypes(); + foreach($allowedModeTypes as $mt) { + $this->allowedModes = array_merge($this->allowedModes, $PARSER_MODES[$mt]); + } + + $idx = array_search(substr(get_class($this), 7), $this->allowedModes); + if ($idx !== false) { + unset($this->allowedModes[$idx]); + } + $this->allowedModesSetup = true; + } + + return parent::accepts($mode); + } + + // plugin introspection methods + // extract from class name, format = <plugin type>_plugin_<name>[_<component name>] + function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; } + function getPluginName() { list($t, $p, $n) = explode('_', get_class($this), 4); return $n; } + function getPluginComponent() { list($t, $p, $n, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); } + + // localisation methods + /** + * getLang($id) + * + * use this function to access plugin language strings + * to try to minimise unnecessary loading of the strings when the plugin doesn't require them + * e.g. when info plugin is querying plugins for information about themselves. + * + * @param $id id of the string to be retrieved + * @return string string in appropriate language or english if not available + */ + function getLang($id) { + if (!$this->localised) $this->setupLocale(); + + return (isset($this->lang[$id]) ? $this->lang[$id] : ''); + } + + /** + * locale_xhtml($id) + * + * retrieve a language dependent wiki page and pass to xhtml renderer for display + * plugin equivalent of p_locale_xhtml() + * + * @param $id id of language dependent wiki page + * @return string parsed contents of the wiki page in xhtml format + */ + function locale_xhtml($id) { + return p_cached_output($this->localFN($id)); + } + + /** + * localFN($id) + * prepends appropriate path for a language dependent filename + * plugin equivalent of localFN() + */ + function localFN($id) { + global $conf; + $plugin = $this->getPluginName(); + $file = DOKU_PLUGIN.$plugin.'/lang/'.$conf['lang'].'/'.$id.'.txt'; + if(!@file_exists($file)){ + //fall back to english + $file = DOKU_PLUGIN.$plugin.'/lang/en/'.$id.'.txt'; + } + return $file; + } + + /** + * setupLocale() + * reads all the plugins language dependent strings into $this->lang + * this function is automatically called by getLang() + */ + function setupLocale() { + if ($this->localised) return; + + global $conf; // definitely don't invoke "global $lang" + $path = DOKU_PLUGIN.$this->getPluginName().'/lang/'; + + // don't include once, in case several plugin components require the same language file + @include($path.'en/lang.php'); + if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); + + $this->lang = $lang; + $this->localised = true; + } + + // configuration methods + /** + * getConf($setting) + * + * use this function to access plugin configuration variables + */ + function getConf($setting){ + + if (!$this->configloaded){ $this->loadConfig(); } + + return $this->conf[$setting]; + } + + /** + * loadConfig() + * merges the plugin's default settings with any local settings + * this function is automatically called through getConf() + */ + function loadConfig(){ + global $conf; + + $defaults = $this->readDefaultSettings(); + $plugin = $this->getPluginName(); + + foreach ($defaults as $key => $value) { + if (isset($conf['plugin'][$plugin][$key])) continue; + $conf['plugin'][$plugin][$key] = $value; + } + + $this->configloaded = true; + $this->conf =& $conf['plugin'][$plugin]; + } + + /** + * read the plugin's default configuration settings from conf/default.php + * this function is automatically called through getConf() + * + * @return array setting => value + */ + function readDefaultSettings() { + + $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; + $conf = array(); + + if (@file_exists($path.'default.php')) { + include($path.'default.php'); + } + + return $conf; + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : |