$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';
$all = isset($_REQUEST["all"]) ? $_REQUEST["all"] == 'on' ? 'y' : 'n' : 'n';
$enabled = isset($_REQUEST["enabled"]) ? $_REQUEST["enabled"] == 'on' ? 'y' : 'n' : 'n';
if (!isset($_REQUEST["repID"]) || $repID <= 0) {
    $smarty->assign('msg', tra("No repository"));
    $smarty->display("error.tpl");
    die;
}
// Create instance of integrator
$integrator = new TikiIntegrator($dbTiki);
// Check if copy button pressed
if (isset($_REQUEST["copy"]) && $srcrep > 0) {
    $integrator->copy_rules($srcrep, $repID);
}
// 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, $ord, $srch, $repl, $type, $casesense, $rxmod, $enabled, $description);
    } else {
        $smarty->assign('msg', tra("Search is mandatory field"));
        $smarty->display("error.tpl");
        die;
    }
}
// Check if 'preview' button pressed ...
if (isset($_REQUEST["preview"])) {
    // Prepeare rule data
$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';
$all = isset($_REQUEST["all"]) ? ($_REQUEST["all"] == 'on' ? 'y' : 'n') : 'n';
$enabled = isset($_REQUEST["enabled"]) ? ($_REQUEST["enabled"] == 'on' ? 'y' : 'n') : 'n';
if (!isset($_REQUEST["repID"]) || $repID <= 0) {
	$smarty->assign('msg', tra("No repository"));
	$smarty->display("error.tpl");
	die;
}
// Create instance of integrator
$integrator = new TikiIntegrator($dbTiki);
// Check if copy button pressed
if (isset($_REQUEST["copy"]) && ($srcrep > 0)) $integrator->copy_rules($srcrep, $repID);
// 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, $ord, $srch, $repl, $type, $casesense, $rxmod, $enabled, $description);
	else {
		$smarty->assign('msg', tra("Search is mandatory field"));
		$smarty->display("error.tpl");
		die;
	}
}
// Check if 'preview' button pressed ...
if (isset($_REQUEST["preview"])) {
	// Prepeare rule data
	$rule = array();
	$rule["repID"] = $repID;