Commit c7756d5f authored by zaufi's avatar zaufi

Tiki Integrator: first (very development :) implementation

parent 5ab12791
......@@ -1922,6 +1922,7 @@ tiki/lib/htmlparser/htmlparser.inc -text
tiki/lib/htmlparser/readme.eng.txt -text
tiki/lib/htmlparser/rebuildgrammar.php -text
tiki/lib/imagegals/imagegallib.php -text
tiki/lib/integrator/integrator.php -text
tiki/lib/irc/irclib.php -text
tiki/lib/irc/split_logs.php -text
tiki/lib/irc/tikiwiki.php -text
......@@ -2841,6 +2842,8 @@ tiki/templates/tiki-admin_forums.tpl -text
tiki/templates/tiki-admin_hotwords.tpl -text
tiki/templates/tiki-admin_html_page_content.tpl -text
tiki/templates/tiki-admin_html_pages.tpl -text
tiki/templates/tiki-admin_integrator.tpl -text
tiki/templates/tiki-admin_integrator_rules.tpl -text
tiki/templates/tiki-admin_layout.tpl -text
tiki/templates/tiki-admin_links.tpl -text
tiki/templates/tiki-admin_mailin.tpl -text
......@@ -2945,6 +2948,7 @@ tiki/templates/tiki-imexport_languages.tpl -text
tiki/templates/tiki-import_phpwiki.tpl -text
tiki/templates/tiki-index_p.tpl -text
tiki/templates/tiki-install.tpl -text
tiki/templates/tiki-integrator.tpl -text
tiki/templates/tiki-lastchanges.tpl -text
tiki/templates/tiki-likepages.tpl -text
tiki/templates/tiki-list_articles.tpl -text
......@@ -2956,6 +2960,7 @@ tiki/templates/tiki-list_faqs.tpl -text
tiki/templates/tiki-list_file_gallery.tpl -text
tiki/templates/tiki-list_gallery.tpl -text
tiki/templates/tiki-list_games.tpl -text
tiki/templates/tiki-list_integrator_repositories.tpl -text
tiki/templates/tiki-list_posts.tpl -text
tiki/templates/tiki-list_quizzes.tpl -text
tiki/templates/tiki-list_submissions.tpl -text
......@@ -3150,6 +3155,8 @@ tiki/tiki-admin_include_trackers.php -text
tiki/tiki-admin_include_userfiles.php -text
tiki/tiki-admin_include_webmail.php -text
tiki/tiki-admin_include_wiki.php -text
tiki/tiki-admin_integrator.php -text
tiki/tiki-admin_integrator_rules.php -text
tiki/tiki-admin_layout.php -text
tiki/tiki-admin_links.php -text
tiki/tiki-admin_mailin.php -text
......@@ -3274,6 +3281,7 @@ tiki/tiki-index.php -text
tiki/tiki-index_p.php -text
tiki/tiki-index_raw.php -text
tiki/tiki-install.php -text
tiki/tiki-integrator.php -text
tiki/tiki-lastchanges.php -text
tiki/tiki-layout_options.php -text
tiki/tiki-likepages.php -text
......@@ -3286,6 +3294,7 @@ tiki/tiki-list_faqs.php -text
tiki/tiki-list_file_gallery.php -text
tiki/tiki-list_gallery.php -text
tiki/tiki-list_games.php -text
tiki/tiki-list_integrator_repositories.php -text
tiki/tiki-list_posts.php -text
tiki/tiki-list_quizzes.php -text
tiki/tiki-list_submissions.php -text
......
<?php
/** \file
* $Header: /cvsroot/tikiwiki/tiki/lib/integrator/integrator.php,v 1.1 2003-10-13 17:18:09 zaufi Exp $
*
* Tiki integrator support class
*
*/
class TikiIntegrator extends TikiLib
{
function TikiIntegrator($db)
{
if (!$db) die("Invalid db object passed to FAQLib constructor");
$this->db = $db;
}
/// Repository management
//\{
/// List all
function list_repositories()
{
$query = "select * from tiki_integrator_repositories order by 'name'";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) $ret[] = $res;
return $ret;
}
/// Add/Update
function add_replace_repository($repID, $name, $path, $start, $css, $descr)
{
$name = addslashes($name);
$path = addslashes($path);
$start = addslashes($start);
$css = addslashes($css);
$descr = addslashes($descr);
if (strlen($repID) == 0 || $repID == 0)
$query = "insert into tiki_integrator_repositories(name,path,start_page,css_file,description)
values('$name','$path','$start','$css','$descr')";
else
$query = "update tiki_integrator_repositories
set name='$name',path='$path',start_page='$start',
css_file='$css',description='$descr' where repID='$repID'";
$result = $this->query($query);
}
/// Get one entry by ID
function get_repository($repID)
{
$query = "select * from tiki_integrator_repositories where repID='$repID'";
$result = $this->query($query);
if (!$result->numRows()) return false;
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $res;
}
/// Remove
function remove_repository($repID)
{
$query = "delete from tiki_integrator_repositories where repID=$repID";
$result = $this->query($query);
}
//\}
/// Rules management
//\{
/// List rules for given repository
function list_rules($repID)
{
$query = "select * from tiki_integrator_rules where repID='$repID'";
$result = $this->query($query);
$ret = Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) $ret[] = $res;
return $ret;
}
/// Add or update rule for repository
function add_replace_rule($repID, $ruleID, $srch, $repl, $type, $case, $rxmod, $descr)
{
$srch = addslashes($srch);
$repl = addslashes($repl);
$rxmod = addslashes($rxmod);
$descr = addslashes($descr);
if (strlen($ruleID) == 0 || $ruleID == 0)
$query = "insert into tiki_integrator_rules(repID,srch,repl,type,casesense,rxmod,description)
values('$repID','$srch','$repl','$type','$case','$rxmod','$descr')";
else
$query = "update tiki_integrator_rules
set repID='$repID',srch='$srch',repl='$repl',
type='$type',casesense='$case',rxmod='$rxmod',description='$descr'
where ruleID='$ruleID'";
$result = $this->query($query);
}
/// Get one entry by ID
function get_rule($ruleID)
{
$query = "select * from tiki_integrator_rules where ruleID='$ruleID'";
$result = $this->query($query);
if (!$result->numRows()) return false;
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $res;
}
/// Remove rule
function remove_rule($ruleID)
{
$query = "delete from tiki_integrator_rules where ruleID=$ruleID";
$result = $this->query($query);
}
/// Apply rule to string
function apply_rule(&$rep, &$rule, $data)
{
// Is there something to search? If no return original data
if (strlen($rule["srch"]) == 0) return $data;
// Prepare replace string (subst {path})
$repl = str_replace('{path}', $rep["path"], $rule["repl"]);
//
$d = $data;
if ($rule["type"] == 'y')
{
// regex rule
$d = preg_replace('_'.$rule["srch"].'_'.$rule["rxmod"], $repl, $data);
}
else
{
// simple str_replace rule
if ($rule["casesense"] == 'y')
$data = str_replace($rule["srch"], $repl, $data);
else
// \todo Hmmm... where is str_ireplace() ???
$data = str_replace($rule["srch"], $repl, $data);
}
return $d;
}
//\}
/// Build full path to file inside given repository
function get_rep_file($rep, $file = '')
{
return $_SERVER['DOCUMENT_ROOT'].'/'.$rep["path"].'/'.((strlen($file) > 0) ? $file : $rep["start_page"]);
}
/// Return CSS file for given repository
function get_rep_css($rep)
{
global $style;
global $style_base;
// Return if no CSS file defined for repository
if (strlen($rep["css_file"]) == 0) return '';
$tiki_root = $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['SCRIPT_NAME']);
// Fill array of dirs to scan (local filesystem, and web based)
$dirs = array();
$dirs[] = array('fs' => $tiki_root."/styles/".$style_base, 'rel' => "styles/".$style_base);
$dirs[] = array('fs' => $tiki_root."/styles/integrator", 'rel' => "styles/integrator");
$dirs[] = array('fs' => $tiki_root."/".$rep['path'], 'rel' => "/".$rep['path']);
// Fill array of files to search
$ts = preg_replace('|\.css|', '', $style); // Tiki style w/o '.css' extension
$is = preg_replace('|\.css|', '', $rep["css_file"]);
$files = array();
$files[] = $ts.'-'.$rep["css_file"]; // matrix-doxygen.css
$files[] = $ts.'.'.$rep["css_file"]; // matrix.doxygen.css
$files[] = $ts.'_'.$rep["css_file"]; // matrix_doxygen.css
$files[] = $is.'-'.$style; // doxygen-matrix.css
$files[] = $is.'.'.$style; // doxygen.matrix.css
$files[] = $is.'_'.$style; // doxygen_matrix.css
$files[] = $rep["css_file"]; // doxygen.css
// Make full list of files to search (combine all dirs with all files)
$candidates = array();
foreach ($dirs as $dir) foreach ($files as $file)
$candidates[] = array('fs' => $dir['fs'].'/'.$file, 'rel' => $dir['rel'].'/'.$file);
// Search for CSS file
foreach ($candidates as $candidate)
{
if (file_exists($candidate['fs'])) return $candidate['rel'];
}
// Nothing found...
return '';
}
}
$integrator = new TikiIntegrator($dbTiki);
?>
\ No newline at end of file
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-admin_integrator.tpl,v 1.1 2003-10-13 17:17:22 zaufi Exp $ *}
{if $repID > 0}
<h2>{tr}Edit this Repository:{/tr} {$name}</h2>
{else}
<h2>{tr}Create New Repository:{/tr}</h2>
{/if}
<div id="page-bar">
<table><tr>
<td><div class="button2">
<a href="tiki-list_integrator_repositories.php" class="linkbut">{tr}list repositories{/tr}</a>
</div></td>
</tr></table>
</div>
<br />
{* Add form *}
<form action="tiki-admin_integrator.php" method="post">
<input type="hidden" name="repID" value="{$repID|escape}" />
<table class="normal">
<tr><td class="formcolor">{tr}Name{/tr}</td>
<td class="formcolor"><input type="text" name="name" value="{$name|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}Path{/tr}</td>
<td class="formcolor"><input type="text" name="path" value="{$path|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}Start page{/tr}</td>
<td class="formcolor"><input type="text" name="start" value="{$start|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}CSS file{/tr}</td>
<td class="formcolor"><input type="text" name="cssfile" value="{$cssfile|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}Description{/tr}</td>
<td class="formcolor"><textarea name="description" rows="4">{$description|escape}</textarea></td>
</tr><tr>
<td class="formcolor"></td>
<td class="formcolor"><input type="submit" name="save" value="{tr}Save{/tr}" /></td>
</tr>
</table>
<h2>{tr}Available Repositories{/tr}</h2>
{* Table with list of repositories *}
<table class="normal" id="integrator-repositories">
<tr>
<td class="heading" rowspan="2">{tr}Name{/tr}</td>
<td class="heading">{tr}Path{/tr}</td>
<td class="heading">{tr}Start{/tr}</td>
<td class="heading">{tr}CSS File{/tr}</td>
<td class="heading">{tr}Actions{/tr}</td>
</tr><tr>
<td class="heading" colspan="4">{tr}Description{/tr}</td>
</tr>
{cycle values="odd,even" print=false}
{section name=rep loop=$repositories}
<tr>
<td class="{cycle advance=false}"{if (strlen($repositories[rep].description) > 0)} rowspan="2"{/if}>
<a href="tiki-admin_integrator_rules.php?repID={$repositories[rep].repID|escape}" title={tr}Edit rules{/tr}>
{$repositories[rep].name}
</a>
</td>
<td class="{cycle advance=false}">{$repositories[rep].path}</td>
<td class="{cycle advance=false}">{$repositories[rep].start_page}</td>
<td class="{cycle advance=false}">{$repositories[rep].css_file}</td>
<td class="{if (strlen($repositories[rep].description) > 0)}{cycle advance=false}{else}{cycle}{/if}">
<a href="tiki-admin_integrator.php?action=edit&repID={$repositories[rep].repID|escape}" title='{tr}edit{/tr}' >
<img src='img/icons/config.gif' alt='{tr}edit{/tr}' border='0' />
</a>
<a href="tiki-admin_integrator.php?action=rm&repID={$repositories[rep].repID|escape}" title='{tr}remove{/tr}' >
<img src='img/icons2/delete.gif' alt='{tr}remove{/tr}' border='0' />
</a>
</td>
{* Show description as colspaned row if it is not an empty *}
{if (strlen($repositories[rep].description) > 0)}
</tr><tr>
<td class="{cycle}" colspan="4">{$repositories[rep].description}</td>
{/if}
</tr>
{/section}
</table>
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-admin_integrator_rules.tpl,v 1.1 2003-10-13 17:17:22 zaufi Exp $ *}
<h2>{tr}Edit Rules for Repository:{/tr} {$name}</h2>
<div id="page-bar">
<table><tr>
<td><div class="button2">
<a href="tiki-admin_integrator.php" class="linkbut">{tr}configure repositories{/tr}</a>
</div></td>
<td><div class="button2">
<a href="tiki-list_integrator_repositories.php" class="linkbut">{tr}list repositories{/tr}</a>
</div></td>
<td><div class="button2">
<a href="tiki-integrator.php?repID={$repID|escape}" class="linkbut">{tr}view repository{/tr}</a>
</div></td>
</tr></table>
</div>
<br />
{* Add form *}
<form action="tiki-admin_integrator_rules.php?repID={$repID|escape}" method="post">
<input type="hidden" name="ruleID" value="{$ruleID|escape}" />
<input type="hidden" name="repID" value="{$repID|escape}" />
<table class="normal">
<tr><td class="formcolor">{tr}Search{/tr}</td>
<td class="formcolor"><input type="text" name="srch" value="{$srch|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}Replace{/tr}</td>
<td class="formcolor"><input type="text" name="repl" value="{$repl|escape}" /></td>
</tr><tr>
<td class="formcolor">{tr}Regex{/tr}</td>
<td class="formcolor">
<input type="checkbox" name="type" {if $type eq 'y'}checked="checked"{/if} /> &nbsp;&nbsp;
{tr}Use preg_replace or str_replace to filter text{/tr}
</td>
</tr><tr>
<td class="formcolor">{tr}Case sensitive{/tr}</td>
<td class="formcolor">
<input type="checkbox" name="casesense" {if $type eq 'y'}checked="checked"{/if} /> &nbsp;&nbsp;
{tr}Use case sensitive str_replace{/tr}
</td>
</tr><tr>
<td class="formcolor">{tr}<span title="set of: imsxeADSXUu">Regex modifiers{/tr}</span></td>
<td class="formcolor">
<input type="text" name="rxmod" value="{$rxmod|escape}" /> &nbsp;&nbsp;
{tr}Aux modifiers for preg_replace{/tr}
</td>
</tr><tr>
<td class="formcolor">{tr}Description{/tr}</td>
<td class="formcolor"><textarea name="description" rows="4">{$description|escape}</textarea></td>
</tr><tr>
<td class="formcolor"></td>
<td class="formcolor"><input type="submit" name="save" value="{tr}Save{/tr}" /></td>
</tr><tr>
<td class="formcolor" colspan="2">{tr}Preview options{/tr}</td>
</tr><tr>
<td class="formcolor">{tr}Code preview{/tr}</td>
<td class="formcolor"><input type="checkbox" name="code" {if $code eq 'y'}checked="checked"{/if} /></td>
</tr><tr>
<td class="formcolor">{tr}HTLM preview{/tr}</td>
<td class="formcolor"><input type="checkbox" name="html" {if $html eq 'y'}checked="checked"{/if} /></td>
</tr><tr>
<td class="formcolor">{tr}File{/tr}</td>
<td class="formcolor">
<input type="text" name="file" value="{$file|escape}" /> &nbsp;&nbsp;
{tr}Test file from repository (empty = configured start page){/tr}
</td>
</tr><tr>
<td class="formcolor"></td>
<td class="formcolor"><input type="submit" name="preview" value="{tr}Preview{/tr}" /></td>
</tr>
</table>
{if (($html eq 'y') or ($code eq 'y')) and (strlen($preview_data) gt 0)}
<h2>{tr}Preview Results{/tr}</h2>
{if strlen($css_file) > 0}
<link rel="StyleSheet" href="{$css_file}" type="text/css" />
{/if}
<div class="integration_preview">
{if $code eq 'y'}
<div class="codelisting"><pre>{$preview_data|escape:"html"|wordwrap:120:"\n"}</pre></div>
{/if}
{if $html eq 'y'}
<div class="integrated-page">{$preview_data}</div>
{/if}
</div>
{/if}
<h2>{tr}Rules List{/tr}</h2>
{* Table with list of repositories *}
<table class="normal" id="integrator_rules">
<tr>
<td class="heading">{tr}Search{/tr}</td>
<td class="heading">{tr}Replace{/tr}</td>
<td class="heading">{tr}Regex{/tr}</td>
<td class="heading">{tr}Case{/tr}</td>
<td class="heading">{tr}Actions{/tr}</td>
</tr><tr>
<td class="heading" colspan="5">{tr}Description{/tr}</td>
</tr>
{cycle values="odd,even" print=false}
{section name=rule loop=$rules}
<tr>
<td class="{cycle advance=false}">{$rules[rule].srch|escape}</td>
<td class="{cycle advance=false}">{$rules[rule].repl|escape}</td>
<td class="{cycle advance=false}">{$rules[rule].type|escape}</td>
<td class="{cycle advance=false}">{$rules[rule].casesense|escape}</td>
<td class="{if (strlen($rules[rule].description) > 0)}{cycle advance=false}{else}{cycle}{/if}">
<a href="tiki-admin_integrator_rules.php?action=edit&repID={$repID|escape}&ruleID={$rules[rule].ruleID|escape}" title='{tr}edit{/tr}' >
<img src='img/icons/config.gif' alt='{tr}edit{/tr}' border='0' />
</a>
<a href="tiki-admin_integrator_rules.php?action=rm&repID={$repID|escape}&ruleID={$rules[rule].ruleID|escape}" title='{tr}remove{/tr}' >
<img src='img/icons2/delete.gif' alt='{tr}remove{/tr}' border='0' />
</a>
</td>
{* Show description as colspaned row if it is not an empty *}
{if (strlen($rules[rule].description) > 0)}
</tr><tr>
<td class="{cycle}" colspan="5">{$rules[rule].description|escape}</td>
{/if}
</tr>
{/section}
</table>
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-integrator.tpl,v 1.1 2003-10-13 17:17:22 zaufi Exp $ *}
{if strlen($css_file) > 0}
<head><link rel="StyleSheet" href="{$css_file}" type="text/css" /></head>
{/if}
<div class="integrated-page">
{$data}
</div>
{* $Header: /cvsroot/tikiwiki/tiki/templates/tiki-list_integrator_repositories.tpl,v 1.1 2003-10-13 17:17:22 zaufi Exp $ *}
<h2>{tr}Available Repositories{/tr}</h2>
<div id="page-bar">
<table><tr>
<td><div class="button2">
<a href="tiki-admin_integrator.php" class="linkbut">{tr}configure repositories{/tr}</a>
</div></td>
</tr></table>
</div>
<br />
{* Table with list of repositories *}
<table class="normal" id="integrator-repositories">
<tr>
<td class="heading">{tr}Name{/tr}</td>
<td class="heading">{tr}Description{/tr}</td>
</tr>
{cycle values="odd,even" print=false}
{section name=rep loop=$repositories}
<tr>
<td class="{cycle advance=false}">
<a href="tiki-integrator.php?repID={$repositories[rep].repID|escape}">
{$repositories[rep].name}
</a>
</td>
<td class="{cycle}">{$repositories[rep].description}</td>
</tr>
{/section}
</table>
<?php
/**
* $Header: /cvsroot/tikiwiki/tiki/tiki-admin_integrator.php,v 1.1 2003-10-13 17:17:49 zaufi Exp $
*
* Admin interface for repositories management
*
*/
require_once('tiki-setup.php');
require_once('lib/integrator/integrator.php');
// Setup local variables from request or set default values
$repID = isset($_REQUEST["repID"]) ? $_REQUEST["repID"] : 0;
$name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
$path = isset($_REQUEST["path"]) ? $_REQUEST["path"] : '';
$start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : '';
$cssfile = isset($_REQUEST["cssfile"]) ? $_REQUEST["cssfile"] : '';
$description = isset($_REQUEST["description"]) ? $_REQUEST["description"] : '';
// Check if 'submit' pressed ...
if (isset($_REQUEST["save"]))
{
// ... and all mandatory paramaters r OK
if ((strlen($name) > 0) && (strlen($path) > 0) && (strlen($start) > 0))
$integrator->add_replace_repository($repID, $name, $path, $start, $cssfile, $description);
else
{
$smarty->assign('msg',tra("Name, path and start page are mandatory fields"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
}
// Whether some action requested?
if (isset($_REQUEST["action"]))
{
switch ($_REQUEST["action"])
{
case 'edit':
if ($repID != 0)
{
$rep = $integrator->get_repository($repID);
$smarty->assign('repID', $repID);
$smarty->assign('name', $rep["name"]);
$smarty->assign('path', $rep["path"]);
$smarty->assign('start', $rep["start_page"]);
$smarty->assign('cssfile', $rep["css_file"]);
$smarty->assign('description', $rep["description"]);
}
break;
case 'rm':
if ($repID != 0) $integrator->remove_repository($repID);
break;
default:
$smarty->assign('msg', tra("Requested action in not supportted on repository"));
$smarty->display("styles/$style_base/error.tpl");
die;
break;
}
}
//
// Fill list of repositories
$repositories = $integrator->list_repositories();
$smarty->assign_by_ref('repositories', $repositories);
// Display the template
$smarty->assign('mid','tiki-admin_integrator.tpl');
$smarty->display("styles/$style_base/tiki.tpl");
?>
\ No newline at end of file
<?php
/**
* $Header: /cvsroot/tikiwiki/tiki/tiki-admin_integrator_rules.php,v 1.1 2003-10-13 17:17:49 zaufi Exp $
*
* Admin interface for rules management
*
*/
require_once('tiki-setup.php');
require_once('lib/integrator/integrator.php');
// Setup local variables from request or set default values
$repID = isset($_REQUEST["repID"]) ? $_REQUEST["repID"] : 0;
$ruleID = isset($_REQUEST["ruleID"]) ? $_REQUEST["ruleID"] : 0;
$srch = isset($_REQUEST["srch"]) ? $_REQUEST["srch"] : '';
$repl = isset($_REQUEST["repl"]) ? $_REQUEST["repl"] : '';
$description = isset($_REQUEST["description"]) ? $_REQUEST["description"] : '';
$rxmod = isset($_REQUEST["rxmod"]) ? $_REQUEST["rxmod"] : '';
$file = isset($_REQUEST["file"]) ? $_REQUEST["file"] : '';
$type = isset($_REQUEST["type"]) ? ($_REQUEST["type"] == 'on' ? 'y' : 'n') : 'n';
$casesense = isset($_REQUEST["casesense"]) ? ($_REQUEST["casesense"] == 'on' ? 'y' : 'n') : 'n';
$code = isset($_REQUEST["code"]) ? ($_REQUEST["code"] == 'on' ? 'y' : 'n') : 'n';
$html = isset($_REQUEST["html"]) ? ($_REQUEST["html"] == 'on' ? 'y' : 'n') : 'n';
if (!isset($_REQUEST["repID"]) || $repID <= 0)
{
$smarty->assign('msg',tra("No repository"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
// Check if 'save' button pressed ...
if (isset($_REQUEST["save"]))
{
// ... and all mandatory paramaters r OK
if (strlen($srch) > 0)
$integrator->add_replace_rule($repID, $ruleID, $srch, $repl, $type, $casesense, $rxmod, $description);
else
{
$smarty->assign('msg',tra("Search is mandatory field"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
}
// Check if 'preview' button pressed ...
if (isset($_REQUEST["preview"]) && ($html == 'y' || $code == 'y'))
{
// Prepeare rule data
$rule = array();
$rule["repID"] = $repID;
$rule["ruleID"] = $ruleID;
$rule["srch"] = $srch;
$rule["repl"] = $repl;
$rule["type"] = $type;
$rule["casesense"] = $casesense;
$rule["rxmod"] = $rxmod;
$rule["description"] = $description;
// Reassign values in form
$smarty->assign('ruleID', $rule["ruleID"]);
$smarty->assign('srch', $rule["srch"]);
$smarty->assign('repl', $rule["repl"]);
$smarty->assign('type', $rule["type"]);
$smarty->assign('casesense', $rule["casesense"]);
$smarty->assign('rxmod', $rule["rxmod"]);
$smarty->assign('description', $rule["description"]);
// Have smth to show?
if (($html != 'y' || $code != 'y'))
{
// Get repository configuration data
$rep = $integrator->get_repository($repID);
// Check if file given and present at configured location
$f = $integrator->get_rep_file($rep, $file);
if (!file_exists($f))
{
$smarty->assign('msg',tra("File not found"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
// Get file content to string
$data = file_get_contents($f);
// Apply rule
$data = $integrator->apply_rule($rep, $rule, $data);
$smarty->assign_by_ref('preview_data', $data);
}
}
// Whether some action requested?
if (isset($_REQUEST["action"]))
{
switch ($_REQUEST["action"])
{
case 'edit':
if ($ruleID != 0)
{
$rule = $integrator->get_rule($ruleID);
$smarty->assign('ruleID', $rule["ruleID"]);
$smarty->assign('srch', $rule["srch"]);
$smarty->assign('repl', $rule["repl"]);
$smarty->assign('type', $rule["type"]);
$smarty->assign('casesense', $rule["casesense"]);
$smarty->assign('rxmod', $rule["rxmod"]);
$smarty->assign('description', $rule["description"]);
}
break;
case 'rm':
if ($ruleID != 0) $integrator->remove_rule($ruleID);
break;
default:
$smarty->assign('msg', tra("Requested action in not supportted on repository"));
$smarty->display("styles/$style_base/error.tpl");
die; break;
}
}
// Get repository name
$r = $integrator->get_repository($repID);
$smarty->assign('name', $r["name"]);
$smarty->assign('file', $file);
$smarty->assign('code', $code);
$smarty->assign('html', $html);
// Fill list of repositories
$rules = $integrator->list_rules($repID);
$smarty->assign_by_ref('rules', $rules);
$smarty->assign('repID', $repID);
// Display the template
$smarty->assign('mid','tiki-admin_integrator_rules.tpl');
$smarty->display("styles/$style_base/tiki.tpl");
?>
\ No newline at end of file
<?php
/**
* $Header: /cvsroot/tikiwiki/tiki/tiki-integrator.php,v 1.1 2003-10-13 17:17:49 zaufi Exp $