<?php
/* +----------------------------------------------------------------------+
| Netautor Professional Application Server |
+----------------------------------------------------------------------+
| Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net> |
+----------------------------------------------------------------------+
| This file is subject to license, that is bundled with this package |
| in the file LICENSE.TXT, and is available at through the |
| world-wide-web at http://www.netautor.com/license/ |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| hide@address.com so we can mail you a copy. |
+----------------------------------------------------------------------+
| Authors: Stefan Rottensteiner <hide@address.com> |
| Marek Kadziela <hide@address.com> |
| Gregor Wollner |
| Christian Unger |
| Helli Kleinhans |
+----------------------------------------------------------------------+*/
require_once('../../include/init.inc');
if(!$USER->check_feature('Admin') && !$USER->check_feature('ac_db_idx'))
{
$USER->login_call();
}
includeNaPro( 'array,fulltext,form,context' );
$LOCALE->textdomain('fulltext');
//error_reporting(65535);
// Liste von vorhandenen Indizes wenn verstecken ?
$HIDE_INDEX_LIST = true;
/* Create database dependent fulltext object */
$fulltext_obj = fulltext::get_ftext_obj($sql_world);
@$action = strtolower(strval($_POST['action']));
if (empty($action)) @$action = strtolower(strval($_GET['action']));
// Sicher keine Aktionen ausführen wenn es kein Volltext-Objekt gibt
if (!$fulltext_obj) $action = '';
//################################################## CLEAR
if( $action == 'clear' )
{
$_POST['fulltext'] = null;
}
/* check for required values */
if (empty($_POST['fulltext'])) $_POST['fulltext'] = array( 'name' =>'',
'stemmer' =>'1',
'lang' =>'',
'selected_name' =>'',
'stwl_file' =>'',
'selected_stwl_file' =>'',
'stwl' =>'',
'ctx_sections' =>0
);
$fulltext = $_POST['fulltext'];
$status = false;
$message = '';
/*
Wenn der Volltext unterstützt wird, die Index-Liste ausgeschalten ist, Auslesen von Indizes unterstütz wird,
dann versuchen den ersten gefunden Index anzugeben
*/
if ($HIDE_INDEX_LIST && $fulltext_obj && $fulltext_obj->check_support('list_indizes') && ($action!='update') )
{
$indexes = $fulltext_obj->get_index_names();
if (!empty($indexes))
{
foreach($indexes as $idx_name => $idx_data)
{
if (empty($idx_name)) continue;
$fulltext['selected_name'] = $idx_name;
break;
}
}
}
/* accept users choice from the selected indizes */
if (empty($fulltext['name']) && !empty($fulltext['selected_name'])) $fulltext['name'] = $fulltext['selected_name'];
/* accept users choice from the selected stopword lists */
if (empty($fulltext['stwl_file']) && !empty($fulltext['selected_stwl_file'])) $fulltext['stwl_file'] = $fulltext['selected_stwl_file'];
/**
* HTML: Make <OPTION> for a list of stored fulltext indizes
*/
function show_indexes( &$fulltext_obj,$pre_select='')
{
$indexes = $fulltext_obj->get_index_names();
if (empty($indexes)) return '';
/*
* Result with names as array_keys. the array-values should be reserved for further details in the future
*/
foreach($indexes as $idx_name => $idx_data)
{
$pre_sel = ($idx_name == $pre_select ? 'SELECTED' : '' );
echo '<option value="'.$idx_name.'" '.$pre_sel.'>'.$idx_name.'</option>';
}
}
//################################################## DELETE
if($action=='delete' && !empty($fulltext['name']))
{
echo '<!-- '.str_repeat('..', 4096 ).' -->';
ob_flush();
$fulltext_obj->set_name($fulltext['name']);
$status = $fulltext_obj->drop_index();
$message = $LOCALE->gettext( ( $status? 'msg_index_deleted' : 'msg_index_not_deleted' ) );
if ($status) $fulltext['name'] = '';
}
if($action=='create' || $action=='update' )
{
if(empty($fulltext['name']))
{
$message = $LOCALE->gettext( 'msg_empty_name' );
}
else
{
$fulltext_obj->set_name($fulltext['name']);
echo '<!-- '.str_repeat('..', 4096 ).' -->';
ob_flush();
if($action=='create')
{
//################################################## CREATE
$fulltext_obj->init_fulltext();
$status = $fulltext_obj->create_index();
$message = $LOCALE->gettext( ( $status? 'msg_index_created' : 'msg_index_not_created' ) );
}
else
{
//################################################## UPDATE
$status = $fulltext_obj->update_index();
$message= $LOCALE->gettext( ( $status? 'msg_index_updated' : 'msg_index_not_updated' ) );
}
}
}
include ('context.msk');
?>