# ***** BEGIN LICENSE BLOCK *****
# This file is part of LiveWiki.
# Copyright (c) 2004 Pascal Guimier and contributors. All rights
# reserved.
#
# LiveWiki is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LiveWiki is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DotClear; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ***** END LICENSE BLOCK *****
#
# Contributor(s):
#
# Version : 0.1
# Release date : Thursday 2004-09-30
# History :
#
# 0.1
# Pascal
# => Basis of the app : JS to call and PHP to fetch
# TODO :
# Pascal
# => * More useful menu
# => * Identification and locking items
# => * Simple history of items:
# o files with _number and gz extension
# o add somewhere user informations: date, ip...
# o try to use diff in order to only save modifications
# o clear empty items
# => * Refresh bug in MSIE
# => * a XUL version
# proc
### OPTIONS ###
$default_item = "home";
### declarations and var setup
$query=(!empty($_GET["q"])?$_GET["q"]:$_POST["q"]);
$decode=(!empty($_GET["d"])?$_GET["d"]:$_POST["d"]);
$filename=(!empty($_GET["f"])?$_GET["f"]:$_POST["f"]);
$item=(!empty($_GET["i"])?$_GET["i"]:$_POST["i"]);
$string=(!empty($_GET["s"])?$_GET["s"]:$_POST["s"]);
if(!empty($filename)) $f=$filename; else $f="datas/".$default_item.".txt.gz";
header("Content-type: text/html; charset=utf-8");
include ("classes/class.wiki2xhtml.php");
### Functions and class extends
class wiki2xhtml_new extends wiki2xhtml
{
function wiki2xhtml_new()
{
parent::wiki2xhtml();
$this->setOpt('active_auto_urls',1); # Activation de la reconnaissance d'url
$this->setOpt('active_macros',1); # Activation des macros «««..»»»
$this->setOpt('active_wikiwords',1); # Activation des mots wiki
$this->setOpt('words_pattern','((?setOpt('mail_pattern','/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/');
$this->setOpt('url_pattern','/^(?registerFunction('macro:w',array($this,'__macroWikiWords'));
$this->functions['wikiword']='__macroWikiWords';
}
function parseWikiWord($str,&$tag,&$attr,&$type)
{
$tag = 'span';
$attr = ' class="wiki" onclick="wLink(this);" title="'.$str.'"';
return $str;
}
function parseMacro($str,&$tag,&$attr,&$type)
{
$data = $this->__splitTagsAttr($str);
if (count($data) == 1)
{
$item = trim($str);
$content = $str;
}
elseif (count($data) > 1)
{
$item = $data[0];
$content = trim($data[1]);
}
$tag = 'span';
$attr = ' class="wiki" onclick="wLink(this);" title="'.$content.'"';
$str = $item;
return $str;
}
function __specialUrls()
{
$res['#^google://(.*)$#'] = 'http://www.google.com/search?q=$1&start=0&start=0';
$res['#^wikipedia://(.*)$#'] = 'http://en.wikipedia.org/wiki/$1';
$res['#^wiki://(.*)$#'] = './?$1';
return $res;
}
function InsertLinks ( $Text )
{
$Result = preg_replace( $Expr, "$0", $Text );
return $Result;
}
function __macroWikiWords($s)
{
return ''.$s.'';
//return ''.$s.'';
}
}
function seems_utf8($Str)
{
for ($i=0; $iread());
sort($my_files);
while ($file=next($my_files)) {
if (ereg("^.*\.txt\.gz$", $file)) {
$ret []= $file;
}
}
$data_dir_obj->close();
foreach($ret as $r) {
$itm=basename($r, ".item.gz");
$new[$r]=$itm;
}
return $new;
}
function get_backlinks($item){}
function get_last_num($f){}
###
### Main
if ($query=="g")
{//to get the item
$wiki = new wiki2xhtml_new();
if (!file_exists($f)) {touch ($f);chmod($f,0666);}
if (!$decode) $res = $wiki->transform(@implode("",@gzfile($f))); //xhtml coded version
else $res = @implode("",@gzfile($f)); //brute wiki coded version
if (!empty($res)) print $res;
else print "Double-click to edit";
}
elseif ($query=="b")
{//backlinks list
global $item;
}
elseif ($query=="h")
{//history list
global $item;
}
elseif ($query=="r")
{//Recent list
}
else
{//to save the item
$fp=gzopen($f, "w");
gzwrite($fp, utf8_ensure(stripslashes($string)));
gzclose($fp);
chmod($f,0666);
}
?>