<?php
/*
Page part
Display the LDAP search form
*/
include_once ("./page.header.php");
// !! dont change that unless you know what ur doing
$searchOperators = array(
"=" => " is ",
"match" => " match ",
"start" => " starts with ",
"end" => " ends with ",
"<=" => " superior or equals ",
">=" => " inferior or equals ",
"differs" => " different of ",
);
/**
* form fields default values
**/
( ! isset($searchdn) && isset($dn) ) && $searchdn = utf8_decode($dn);
( ! isset($searchdn) ) && $searchdn= $ldapmanager['basedn'];
/**
* creation des widgets (composants de page)
**/
$wFields = new Popup( "field", $field, $config->searchFields, $sbS );
$wQuery = new Textinput( "query", $query, $tbM );
$wOperator = new Popup( "operator", $operator, $searchOperators, $sbM );
// buttons to shift the search base DN (left and right)
$jscode = 'shiftDN(1)';
$wBtnShiftLeft = new Button( "<-", $jscode, "", $btnZ );
$jscode = 'shiftDN(-1)';
$wBtnShiftRight = new Button( "->", $jscode, "", $btnZ );
// base search DN
$wSearchDn = new Textinput( "searchdn", $searchdn, $tbM );
/**
* le display de la page commence ici
**/
echo '<div align=center>';
html::form( $PHP_SELF, "get", 'name="frm"' );
html::hidden( 'A', 'search' );
echo '<table cellspacing=0 border=0 style="align: left; padding: 4px; border: 1px solid gray;">';
echo '<caption>', $config->appName , " > Recherche</caption>\n";
// we use an inner table because we have 3 fields for only 2 cells
echo "<tr><td class=form colspan=2><table>\n";
RowN(
$wFields,
$wOperator,
$wQuery
);
echo "</table></td></tr>\n";
RowN(
"From DN ",
array(
$wBtnShiftLeft,
$wSearchDn,
$wBtnShiftRight
)
);
/* RowN(
"Objectclass",
new Textinput( "oc", $oc, $tbM )
);*/
$btn = new Button( "Search", "formAction('search')", '', $btS );
$btn->addOption( " selected " );
$strBtns .= $btn->toString();
$btn = new Button( "Batch action", "formAction('batch.form')", '', $btS );
$strBtns .= $btn->toString();
RowN(
new Button( "Advanced...", "formAction('search.advanced')", '', $btS ),
$strBtns
);
echo "</table></div>\n";
?>
<script language="javascript">
<!--
var savedDN = null;
function shiftDN( sens )
{
var currentvalue = document.frm.searchdn.value;
// conserve le DN original dans savedDN
if( savedDN == null )
savedDN = currentvalue;
if( sens == 1 ) {
var pos = currentvalue.indexOf(",");
if( pos != -1 )
document.frm.searchdn.value = currentvalue.substr( pos+1, currentvalue.length );
} else {
var pos = savedDN.lastIndexOf( currentvalue );
if( pos == -1 )
return;
pos = savedDN.lastIndexOf( ",", pos-2 );
if( pos != -1 ) {
currentvalue = savedDN.substr( pos+1, savedDN.length );
} else {
currentvalue = savedDN;
}
document.frm.searchdn.value = currentvalue;
}
}
function formAction( actionStr )
{
document.frm.A.value = actionStr;
document.frm.submit();
}
function Loadfile( url )
{
window.location = url;
}
// -->
</script>
<?php
?>