* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @package directory
* @subpackage main
* @version $Id: eduorg_html.inc.php,v 1.4 2007/07/05 08:37:26 avel Exp $
* @copyright (c) 1999-2004 Alexandros Vellis
*/
/**
* Print "select" options for Restrict to Organizational Units feature.
* This algorithm needs a properly formatted "$orgs2" array.
* @param array $orgs2
* @param int $level
* @return void
*/
function directory_print_orgs2($orgs2, $level) {
global $restrict;
foreach($orgs2 as $id=>$info) {
$ind = ' ';
$indent = '';
if($level > 0 ) {
for($i=0; $i<$level; $i++) {
$indent .= $ind;
}
}
if(isset($info['text'])) {
echo '\n";
}
if(isset($info['sub'])) {
directory_print_orgs2($info['sub'], $level+1);
}
}
}
/**
* Print "select" options for Restrict to Organizational Units feature.
* This algorithm needs a properly formatted "$orgs3" array.
* @param array $orgs3
* @param int $level
* @global array $restrict
* @global int $trim_at
* @return void
*/
function directory_print_orgs3($orgs3, $level) {
global $restrict, $trim_at;
foreach($orgs3 as $dn=>$info) {
print $dn;
$ind = ' ';
$indent = '';
if($level > 0 ) {
for($i=0; $i<$level; $i++) {
$indent .= $ind;
}
}
if(isset($info['text'])) {
if(isset($trim_at) && mb_strlen($info['text']) > $trim_at && $dn != '*') {
$text = mb_substr($info['text'], 0, $trim_at);
$text .= '...';
} else {
$text = $info['text'];
}
echo '\n";
}
if(isset($info['sub'])) {
directory_print_orgs3($info['sub'], $level+1);
}
}
}
/**
* Output "Browse" Tree for eduOrg ou's.
*
* @param array $orgs3
* @param int $level
* @param int $stop_at
* @param string $current
* @param array $expand
* @param int $editlink 0 = do not display edit links, 1 = display edit link
* only for currently selected entry, 2 = display edit link for all entries in
* the tree, 3 = also show link to new entry (this is actually done in
* browse.php or elsewhere).
* @return void
*/
function directory_print_browse_tree($orgs3, $level, $stop_at = 1, $current = '', $expand = array(), $editlink = 0) {
global $restrict, $trim_at, $ldq_standalone, $directory_enable_browse;
if($stop_at == 0) {
return;
}
if($ldq_standalone) {
$target_browse = 'dirbrowse';
$target_results = 'dirresults';
} else {
$target_browse = '_self';
$target_results = '_self';
}
foreach($orgs3 as $dn=>$info) {
if(isset($niaou)) unset($niaou);
if(isset($gab)) unset($gab);
$ind = ' ';
$indent = '';
if($level > 0 ) {
for($i=0; $i<$level; $i++) {
$indent .= $ind;
}
}
if(isset($info['text'])) {
if(isset($trim_at) && mb_strlen($info['text']) > $trim_at && $dn != '*') {
$text = mb_substr($info['text'], 0, $trim_at);
$text .= '...';
} else {
$text = $info['text'];
}
echo $indent;
/* Set up "Rest of URL", for all links below! */
$restofurl = '';
if(isset($level)) {
$restofurl .= '&level='.$level;
}
if(isset($expand)) {
foreach($expand as $exp) {
$restofurl .= '&expand[]='.urlencode($exp);
}
}
global $formname, $inputname, $popup;
if(!empty($formname)) {
$restofurl .= '&formname='.urlencode($formname);
}
if(!empty($inputname)) {
$restofurl .= '&inputname='.urlencode($inputname);
}
if(isset($popup) && $popup == 1) {
$restofurl .= '&popup=1';
}
/* Plus/Minus gif, expand/collapse functionality */
if(array_key_exists('sub', $info)) {
if(in_array($dn, $expand) ) {
echo ''.
'
';
} else {
echo ''.
'
';
}
} else {
echo '
';
}
/* Text & Link Print */
if($dn == $current) {
echo '';
$niaou = true;
} elseif($dn == '*') {
echo '';
$gab = true;
} else {
// echo '';
$selfuri = 'browse.php?dn='.urlencode($dn).$restofurl.
'&expand[]='.urlencode($dn);
$selftarget = urlencode($dn);
echo '';
}
echo ( isset($info['struct']) ? $info['struct'] . ' ' : '' ) . $text;
if(isset($niaou)) {
echo ' ';
if($directory_enable_browse) {
echo ''.
'
';
}
echo ' '.
'
';
if($editlink != 0) {
echo ' '.
'
';
}
} elseif(isset($gab)) {
echo ' ';
} else {
echo '';
if($editlink >= 2) {
echo ' '.
'
';
}
}
echo "
\n";
}
if(isset($info['sub']) && in_array($dn, $expand) ) {
//print "directory_print_browse_tree(".$info['sub'].", $level+1, $stop_at, $current)\n
";
directory_print_browse_tree($info['sub'], $level+1, $stop_at, $current, $expand, $editlink);
} elseif(isset($info['sub'])) {
directory_print_browse_tree($info['sub'], $level+1, $stop_at-1, $current, $expand, $editlink);
}
}
if($editlink > 2 && $level == 0) {
echo '';
}
}
/**
* Return a nice link using javascript & HTML to the information page of the
* EduOrgUnitDN specified.
*
* @param string $dn EduOrgUnitDN
* @return string The hyperlink (Text)
* @author avel
*/
function eduorgunit_link($dn) {
global $orgs, $baseuri, $javascript_on, $lang;
if($ldq_standalone) {
$target_browse = 'dirbrowse';
$target_results = 'dirresults';
} else {
$target_browse = '_self';
$target_results = '_self';
}
$dn = strtolower($dn);
$uri = DIR_PATH .'showeduorginfo.php?dn='.urlencode($dn).'';
if($javascript_on) {
$out = ''.
'
' .
'('.$orgs[$dn]['struct'].') '.$orgs[$dn]['text'] . '';
return $out;
}