Commit 2d17f264 authored by lrargerich's avatar lrargerich

Jgraphpad updated. Drawings history added.

parent 8d5d3aa5
Version 1.7 -Eta Carinae-
* [NEW] Drawings history added. From the admin drawings panel you can view the history,
remove versions, etc.
* [NEW] Drawings jGraphPad replaced jHotDraw, lot of new features and tools to edit
drawings which can be included in any parsed tiki object.
* [NEW] Forums: Breadcrumb added. Links to next/prev topic when browsing threads
added.
* [NEW] Forums: Topic summaries added and can be used (optional)
......
......@@ -5,8 +5,10 @@ INSERT INTO users_permissions(permName,type,permDesc,level) VALUES ('tiki_p_live
drop table if exists tiki_drawings;
create table tiki_drawings(
drawId integer(12) not null auto_increment,
version integer(8),
name varchar(250),
filename varchar(250),
filename_draw varchar(250),
filename_pad varchar(250),
timestamp integer(14),
user varchar(200),
primary key(drawId)
......
<?php # $Header: /cvsroot/tikiwiki/tiki/jhot.php,v 1.3 2003-05-11 15:06:23 lrargerich Exp $
<?php # $Header: /cvsroot/tikiwiki/tiki/jhot.php,v 1.4 2003-05-14 15:40:32 lrargerich Exp $
include_once('tiki-setup.php');
include_once('lib/drawings/drawlib.php');
if(isset($_FILES['filepath'])&&is_uploaded_file($_FILES['filepath']['tmp_name'])) {
$size = $_FILES['filepath']['size'];
......@@ -8,26 +9,48 @@ if(isset($_FILES['filepath'])&&is_uploaded_file($_FILES['filepath']['tmp_name'])
$type = $_FILES['filepath']['type'];
$pos=strpos($name,'img/wiki/');
$name=substr($name,$pos);
$fw=fopen($name,"wb");
$absolute_name = str_replace('img/wiki/','',$name);
$absolute_name = str_replace('.gif','',$absolute_name);
$absolute_name = str_replace('.pad_xml','',$absolute_name);
$now = date("U");
if(strstr($name,'.gif')) {
$hash = $absolute_name.md5(uniqid('.')).'.gif';
}
if(strstr($name,'.pad_xml')) {
$hash = $absolute_name.md5(uniqid('.')).'.pad_xml';
}
if(strstr($name,'.pad_xml')) {
$drawlib->update_drawing($absolute_name,$hash,$user);
} else {
$drawlib->set_drawing_gif($absolute_name,$hash);
}
// Now check if the filename already exists
// if the filename exists save it as a hash and insert a record in
// the history
@$fw=fopen("img/wiki/$hash","wb");
@$fw2=fopen($name,"wb");
@$fp = fopen($_FILES['filepath']['tmp_name'],"rb");
while(!feof($fp)) {
$data=fread($fp,8192*16);
fwrite($fw,$data);
fwrite($fw2,$data);
}
fclose($fp);
fclose($fw);
fclose($fw2);
}
......
......@@ -10,7 +10,172 @@ class DrawLib extends TikiLib {
$this->db = $db;
}
/*
drawId integer(12) not null auto_increment,
name varchar(250),
filename varchar(250),
timestamp integer(14),
user varchar(200),
primary key(drawId)
*/
function replace_drawing($drawId,$name, $filename_draw,$filename_pad,$user,$version)
{
$name = addslashes($name);
$now = date("U");
if($drawId) {
$query = "update tiki_drawings set
name = '$name',
$version = $version,
filename_draw = '$filename_draw',
filename_pad = '$filename_pad',
timestamp = '$now',
version = $version,
user='$user'
where drawId = $drawId";
$this->qeury($query);
} else {
$query = "insert into tiki_drawings(name,filename_draw, filename_pad,timestamp,user, version)
values('$name','$filename_draw','$filename_pad',$now,'$user',$version)";
$this->query($query);
}
return true;
}
function update_drawing($name,$hash,$user)
{
// Updates a drawing, the last version (if existed) is changed to
// $hash while a new version is inserted with $name
$name = addslashes($name);
$version = $this->getOne("select max(version) from tiki_drawings where name='$name'");
if(!$version) $version = 0;
$version = $version + 1;
$this->replace_drawing(0,$name,'',$hash,$user,$version);
$maxversions = $this->get_preference("maxVersions",0);
$keep = $this->get_preference('keep_versions',0);
$cant = $this->getOne("select count(*) from tiki_drawings where name='$name'");
$now = date("U");
$oktodel = $now - ($keep * 24 * 3600);
if($cant>$maxversions) {
$query = "select * from tiki_drawings where name='$name' and timestamp <= $oktodel limit $maxversions,-1";
$result = $this->query($query);
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$query = "delete from tiki_drawings where drawId=".$res['drawId'];
$this->query($query);
}
}
}
function set_drawing_gif($name,$hash)
{
$name = addslashes($name);
$id = $this->getOne("select max(drawId) from tiki_drawings where name='$name'");
if($id) {
$query = "update tiki_drawings set filename_draw='$hash' where drawId=$id";
$this->query($query);
}
}
function get_drawing($drawId)
{
$query = "select * from tiki_drawings where drawId=$drawId";
$result = $this->query($query);
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $res;
}
function remove_drawing($drawId)
{
$info = $this->get_drawing($drawId);
$f1 = "img/wiki/".$info['filename_draw'];
$f2 = "img/wiki/".$info['filename_pad'];
$max = $this->getOne("select count(*) from tiki_drawings where name='".$info['name']."'");
@unlink($f1);
@unlink($f2);
if($max == 1) {
$f1 = "img/wiki/".$name.".pad_xml";
unlink($f1);
$f1 = "img/wiki/".$name.".gif";
unlink($f1);
}
$query = "delete from tiki_drawings where drawId=$drawId";
$this->query($query);
$max = $this->getOne("select max(version) from tiki_drawings where name='".$info['name']."'");
$query = "select * from tiki_drawings where name = '".$info['name']."' and version=$max";
$result = $this->query($query);
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
$f1 = 'img/wiki/'.$res['filename_draw'];
$f2 = 'img/wiki/'.$res['name'].'.gif';
copy($f1,$f2);
$f1 = 'img/wiki/'.$res['filename_pad'];
$f2 = 'img/wiki/'.$res['name'].'.pad_xml';
copy($f1,$f2);
}
function remove_all_drawings($name)
{
$name = addslashes($name);
$query = "delete from tiki_drawings where name='$name'";
$this->query($query);
}
function list_drawings($offset,$maxRecords,$sort_mode,$find)
{
$sort_mode = str_replace("_"," ",$sort_mode);
if($find) {
$mid=" where (name like '%".$find."%')";
} else {
$mid=" ";
}
$query = "select * from tiki_drawings $mid order by $sort_mode limit $offset,$maxRecords";
$query_cant = "select count(*) from tiki_drawings $mid";
$result = $this->query($query);
$cant = $this->getOne($query_cant);
$ret = Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$last_version = $this->getOne("select max(version) from tiki_drawings where name='".$res['name']."'");
if($res['version']==$last_version) {
$res['versions']=$this->getOne("select count(*) from tiki_drawings where name='".$res['name']."'");
$ret[] = $res;
}
}
$retval = Array();
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
function list_drawing_history($name,$offset,$maxRecords,$sort_mode,$find)
{
$name = addslashes($name);
$sort_mode = str_replace("_"," ",$sort_mode);
if($find) {
$mid=" where name='$name' and (name like '%".$find."%')";
} else {
$mid=" where name='$name' ";
}
$query = "select * from tiki_drawings $mid order by $sort_mode,version desc limit $offset,$maxRecords";
$query_cant = "select count(*) from tiki_drawings $mid";
$result = $this->query($query);
$cant = $this->getOne($query_cant);
$ret = Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$res['versions']=$this->getOne("select count(*) from tiki_drawings where name='".$res['name']."'");
$ret[] = $res;
}
$retval = Array();
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
}
$drawlib= new DrawLib($dbTiki);
......
<a class="pagetitle" href="tiki-admin_drawings.php">{tr}Edit drawings &amp; pictures{/tr}</a><br/><br/>
<a class="pagetitle" href="tiki-admin_drawings.php">{tr}Edit drawings{/tr}</a><br/><br/>
{if $preview eq 'y'}
<div align="center">
<a href='#' onClick="javascript:window.open('tiki-editdrawing.php?path={$path}&amp;drawing={$draw_info.name}','','menubar=no,width=252,height=25');">
<img width='154' height='98' border='0' src='img/wiki/{$draw_info.filename_draw}' alt='click to edit' />
</a>
</div>
{/if}
<form method="post" action="tiki-admin_drawings.php">
<input type="hidden" name="ver" value="{$smarty.request.ver}" />
<input type="hidden" name="offset" value="{$offset}" />
<input type="hidden" name="sort_mode" value="{$sort_mode}" />
{tr}Find{/tr}:<input type="text" name="find" value="{$find}" />
</form>
<h3>{tr}Available drawings{/tr}:</h3>
<form method="post" action="tiki-admin_drawings.php">
<input type="hidden" name="ver" value="{$smarty.request.ver}" />
<input type="hidden" name="offset" value="{$offset}" />
<input type="hidden" name="find" value="{$find}" />
<input type="hidden" name="sort_mode" value="{$sort_mode}" />
<table class="normal">
<tr>
<td class="heading">{tr}Thumbnail{/tr}</a></td>
<td class="heading">{tr}Name{/tr}</a></td>
{if $smarty.request.ver}
<td width="2%" class="heading"><input type="submit" name="del" value="{tr}x{/tr} " /></td>
{/if}
<td class="heading">{tr}Name{/tr}</td>
<td width="3%" class="heading">{tr}Ver{/tr}</a></td>
<td width="3%" class="heading">{tr}Versions{/tr}</a></td>
<td width="12%" class="heading">{tr}Action{/tr}</a></td>
</tr>
{section name=user loop=$files}
{if $smarty.section.user.index % 2}
{cycle values="odd,even" print=false}
{section name=user loop=$items}
<tr>
<td class="odd">
<a href='#' onClick="javascript:window.open('tiki-editdrawing.php?path={$path}&amp;drawing={$files[user]}','','menubar=no,width=252,height=25');"><img width='154' height='98' border='0' src='img/wiki/{$files[user]}.gif' alt='click to edit' /></a>
</td>
<td class="odd">{$files[user]}
[<a href="tiki-admin_drawings.php?remove={$files[user]}" class="link">{tr}x{/tr}</a>]
{if $smarty.request.ver}
<td class="{cycle advance=false}">
<input type="checkbox" name="draw[{$items[user].drawId}]" />
</td>
</tr>
{/if}
<td class="{cycle advance=false}">
{if $smarty.request.ver}
{$items[user].name}
{else}
<tr>
<td class="even">
<a href='#' onClick="javascript:window.open('tiki-editdrawing.php?path={$path}&amp;drawing={$files[user]}','','menubar=no,width=252,height=25');"><img width='154' height='98' border='0' src='img/wiki/{$files[user]}.gif' alt='click to edit' /></a>
<a href="tiki-admin_drawings.php?ver={$items[user].name}" class="link">
{$items[user].name}</a>
{/if}
</td>
<td class="even">{$files[user]}
[<a href="tiki-admin_drawings.php?remove={$files[user]}" class="link">{tr}x{/tr}</a>]
<td style="text-align:right;" class="{cycle advance=false}">
{$items[user].version}
</td>
</tr>
<td style="text-align:right;" class="{cycle advance=false}">
{$items[user].versions}
</td>
<td class="{cycle}">
{if $smarty.request.ver}
<a href="tiki-admin_drawings.php?ver={$smarty.request.ver}&amp;remove={$items[user].drawId}" class="link"><img src='img/icons2/delete.gif' alt='{tr}delete{/tr}' title='{tr}delete{/tr}' border='0' /></a>
{else}
<a href="tiki-admin_drawings.php?ver={$smarty.request.ver}&amp;removeall={$items[user].name}" class="link"><img src='img/icons2/delete.gif' alt='{tr}delete{/tr}' title='{tr}delete{/tr}' border='0' /></a>
{/if}
<a href="tiki-admin_drawings.php?ver={$smarty.request.ver}&amp;previewfile={$items[user].drawId}" class="link"><img src='img/icons/ico_img.gif' border='0' alt='{tr}view{/tr}' title='{tr}view{/tr}' /></a>
{if not $smarty.request.ver}
<a class="link" href='#' onClick="javascript:window.open('tiki-editdrawing.php?path={$path}&amp;drawing={$items[user].name}','','menubar=no,width=252,height=25');">
<img src='img/icons/edit.gif' border='0' alt='{tr}edit{/tr}' title='{tr}edit{/tr}' />
</a>
{/if}
</td>
</tr>
{sectionelse}
<tr><td colspan="2" class="odd">{tr}No records found{/tr}</td></tr>
{/section}
</table>
</form>
<div class="mini">
<div align="center">
{if $prev_offset >= 0}
[<a class="prevnext" href="tiki-admin_drawings.php?ver={$smart.request.ver}&amp;offset={$prev_offset}&amp;find={$find}">{tr}prev{/tr}</a>]&nbsp;
{/if}
{tr}Page{/tr}: {$actual_page}/{$cant_pages}
{if $next_offset >= 0}
&nbsp;[<a class="prevnext" href="ver={$smart.request.ver}&amp;offset={$next_offset}&amp;find={$find}">{tr}next{/tr}</a>]
{/if}
{if $direct_pagination eq 'y'}
<br/>
{section loop=$cant_pages name=foo}
{assign var=selector_offset value=$smarty.section.foo.index|times:$maxRecords}
<a class="prevnext" href="tiki-admin_drawings.php offset=$selector_offset">
{$smarty.section.foo.index_next}</a>&nbsp;
{/section}
{/if}
</div>
</div>
<?php
// Initialization
require_once('tiki-setup.php');
include_once('lib/drawings/drawlib.php');
if($feature_drawings != 'y') {
$smarty->assign('msg',tra("Feature disabled"));
......@@ -16,11 +16,20 @@ if($tiki_p_admin_drawings != 'y') {
}
if(isset($_REQUEST["remove"])) {
@unlink("img/wiki/".$_REQUEST["remove"].".gif");
@unlink("img/wiki/".$_REQUEST["remove"].".draw");
@unlink("img/wiki/".$_REQUEST["remove"].".map");
$drawlib->remove_drawing($_REQUEST["remove"]);
}
if(isset($_REQUEST["removeall"])) {
$drawlib->remove_all_drawings($_REQUEST["removeall"]);
}
if(isset($_REQUEST['del'])) {
foreach(array_keys($_REQUEST['draw']) as $id) {
$drawlib->remove_drawing($id);
}
}
$pars=parse_url($_SERVER["REQUEST_URI"]);
$pars_parts=split('/',$pars["path"]);
$pars=Array();
......@@ -30,21 +39,31 @@ $pars=parse_url($_SERVER["REQUEST_URI"]);
$pars=join('/',$pars);
$smarty->assign('path',$pars);
// Get templates from the templates directory
$files=Array();
$h = opendir("img/wiki");
while (($file = readdir($h)) !== false) {
if(strstr($file,'.gif')) {
$files[]=substr($file,0,strlen($file)-4);
}
}
closedir($h);
$smarty->assign('preview','n');
if(isset($_REQUEST['previewfile'])) {
$draw_info = $drawlib->get_drawing($_REQUEST['previewfile']);
$smarty->assign('draw_info',$draw_info);
$smarty->assign('preview','y');
}
sort($files);
$smarty->assign('files',$files);
// Manage offset here
if(!isset($_REQUEST["sort_mode"])) { $sort_mode = 'name_asc'; } else { $sort_mode = $_REQUEST["sort_mode"];}
if(!isset($_REQUEST["offset"])) { $offset = 0;} else { $offset = $_REQUEST["offset"]; }$smarty->assign_by_ref('offset',$offset);
if(isset($_REQUEST["find"])) { $find = $_REQUEST["find"]; } else { $find = ''; } $smarty->assign('find',$find);
$smarty->assign_by_ref('sort_mode',$sort_mode);
// Get templates from the templates/modules directori
if(isset($_REQUEST['ver']) && $_REQUEST['ver']) {
$items = $drawlib->list_drawing_history($_REQUEST['ver'],$offset,$maxRecords,$sort_mode,$find);
} else {
$items = $drawlib->list_drawings($offset,$maxRecords,$sort_mode,$find);
}
$smarty->assign('cant',$items['cant']);
$cant_pages = ceil($items["cant"] / $maxRecords);$smarty->assign_by_ref('cant_pages',$cant_pages);$smarty->assign('actual_page',1+($offset/$maxRecords));
if($items["cant"] > ($offset+$maxRecords)) { $smarty->assign('next_offset',$offset + $maxRecords);} else { $smarty->assign('next_offset',-1); }
if($offset>0) { $smarty->assign('prev_offset',$offset - $maxRecords); } else { $smarty->assign('prev_offset',-1); }
$smarty->assign_by_ref('items',$items["data"]);
$smarty->assign('mid','tiki-admin_drawings.tpl');
$smarty->display("styles/$style_base/tiki.tpl");
......
<?php # $Header: /cvsroot/tikiwiki/tiki/tiki-editdrawing.php,v 1.4 2003-04-24 20:45:44 lrargerich Exp $
<?php # $Header: /cvsroot/tikiwiki/tiki/tiki-editdrawing.php,v 1.5 2003-05-14 15:41:16 lrargerich Exp $
include_once("tiki-setup_base.php");
......@@ -11,12 +11,13 @@ if(isset($_REQUEST["close"])) {
print("<script>window.close();</script>");
die;
}
$tikilib->invalidate_cache($_REQUEST['page']);
$name=$_REQUEST["drawing"];
$path=$_REQUEST["path"];
?>
<applet archive="lib/jgraphpad/jgraphpad.jar"
code="com.jgraph.JGraphpad.class" width=100% height=40>
<param name="drawpath" value="<?php echo $path?>/img/wiki/<?php echo $name?>.draw">
<param name="drawpath" value="<?php echo $path?>/img/wiki/<?php echo $name?>.pad_xml">
<param name="gifpath" value="<?php echo $path?>/img/wiki/<?php echo $name?>.gif">
<param name="savepath" value="<?php echo $path?>/jhot.php">
<param name="viewpath" value="tiki-editdrawing.php?close=1">
......
......@@ -786,8 +786,9 @@ if ($https_login == 'y' || $https_login_required == 'y') {
$smarty->assign('stay_in_ssl_mode', $stay_in_ssl_mode);
}
$prefs = $tikilib->get_all_preferences();
if(!file_exists('templates_c/preferences.php')) {
$prefs = $tikilib->get_all_preferences();
$fw=fopen('templates_c/preferences.php',"wb");
fwrite($fw,'<?php'."\n");
foreach($prefs as $name => $val) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment