ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFileExplorer Class Reference

Class ilFileExplorer. More...

+ Collaboration diagram for ilFileExplorer:

Public Member Functions

 ilFileExplorer ($a_directory, $a_target)
 Constructor public.
 setOrderColumn ($a_column)
 set the order column public
 setTargetGet ($a_target_get)
 set the varname in Get-string public
 setParamsGet ($a_params_get)
 set additional params to be passed in Get-string public
 setExpandTarget ($a_exp_target)
 target script for expand icons
 checkPermissions ($a_check)
 check permissions via rbac
 outputIcons ($a_icons)
 output icons
 setOutput ($a_parent_dir, $a_depth=1)
 Creates output for explorer view in admin menue recursive method public.
 getFiles ($a_parent_dir, $a_order)
 getOutput ()
 Creates output recursive method public.
 formatHeader ($a_obj_id, $a_option)
 Creates output for header (is empty here but can be overwritten in derived classes)
 formatObject ($a_node_id, $a_option)
 Creates output recursive method private.
 createTarget ($a_type, $a_node_id)
 Creates Get Parameter private.
 setFrameTarget ($a_target)
 set target frame or not frame?
 createLines ($a_depth)
 Creates lines for explorer view private.
 is_in_array ($a_start, $a_depth)
 DESCRIPTION MISSING private.
 getIndex ($a_data)
 get index of format_options array from specific ref_id,parent_id private
 addFilter ($a_item)
 adds item to the filter public
 delFilter ($a_item)
 adds item to the filter public
 setExpand ($a_node_id)
 set the expand option this value is stored in a SESSION variable to save it different view (lo view, frm view,...) private
 setFiltered ($a_bool)
 active/deactivate the filter public
 checkFilter ($a_item)
 check if item is in filter private

Data Fields

 $ilias
 $output
 $format_options
 $directory
 $target
 $target_get
 $params_get
 $expanded
 $order_column
 $expand_target
 $output_icons

Detailed Description

Class ilFileExplorer.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilFileExplorer.php 20150 2009-06-08 18:02:33Z akill

Definition at line 12 of file class.ilFileExplorer.php.

Member Function Documentation

ilFileExplorer::addFilter (   $a_item)

adds item to the filter public

Parameters
stringobject type to add
Returns
boolean

Definition at line 538 of file class.ilFileExplorer.php.

{
$ispresent = 0;
if (is_array($this->filter))
{
//run through filter
foreach ($this->filter as $item)
{
if ($item == $a_item)
{
$is_present = 1;
return false;
}
}
}
else
{
$this->filter = array();
}
if ($is_present == 0)
{
$this->filter[] = $a_item;
}
return true;
}
ilFileExplorer::checkFilter (   $a_item)

check if item is in filter private

Parameters
string
Returns
integer

Definition at line 656 of file class.ilFileExplorer.php.

Referenced by setOutput().

{
if (is_array($this->filter))
{
return in_array($a_item, $this->filter);
}
else
{
return false;
}
}

+ Here is the caller graph for this function:

ilFileExplorer::checkPermissions (   $a_check)

check permissions via rbac

Parameters
boolean$a_checkcheck true/false

Definition at line 185 of file class.ilFileExplorer.php.

{
$this->rbac_check = $a_check;
}
ilFileExplorer::createLines (   $a_depth)

Creates lines for explorer view private.

Parameters
integer

Definition at line 455 of file class.ilFileExplorer.php.

References is_in_array().

{
for ($i = 0; $i < count($this->format_options); ++$i)
{
if ($this->format_options[$i]["depth"] == $a_depth+1
and !$this->format_options[$i]["container"]
and $this->format_options[$i]["depth"] != 1)
{
$this->format_options[$i]["tab"]["$a_depth"] = "quer";
}
if ($this->format_options[$i]["depth"] == $a_depth+2)
{
if ($this->is_in_array($i+1,$this->format_options[$i]["depth"]))
{
$this->format_options[$i]["tab"]["$a_depth"] = "winkel";
}
else
{
$this->format_options[$i]["tab"]["$a_depth"] = "ecke";
}
}
if ($this->format_options[$i]["depth"] > $a_depth+2)
{
if ($this->is_in_array($i+1,$a_depth+2))
{
$this->format_options[$i]["tab"]["$a_depth"] = "hoch";
}
}
}
}

+ Here is the call graph for this function:

ilFileExplorer::createTarget (   $a_type,
  $a_node_id 
)

Creates Get Parameter private.

Parameters
string
integer
Returns
string

Definition at line 420 of file class.ilFileExplorer.php.

Referenced by formatObject().

{
if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id))
{
$this->ilias->raiseError(get_class($this)."::createTarget(): Missing parameter or wrong datatype! ".
"type: ".$a_type." node_id:".$a_node_id,$this->ilias->error_obj->WARNING);
}
// SET expand parameter:
// positive if object is expanded
// negative if object is compressed
$a_node_id = $a_type == '+' ? $a_node_id : -(int) $a_node_id;
$sep = (is_int(strpos($this->expand_target, "?")))
? "&"
: "?";
return $this->expand_target.$sep."expand=".$a_node_id.$this->params_get;
}

+ Here is the caller graph for this function:

ilFileExplorer::delFilter (   $a_item)

adds item to the filter public

Parameters
stringobject type to delete
Returns
boolean

Definition at line 575 of file class.ilFileExplorer.php.

{
//check if a filter exists
if (is_array($this->filter))
{
//build copy of the existing filter without the given item
$tmp = array();
foreach ($this->filter as $item)
{
if ($item != $a_item)
{
$tmp[] = $item;
}
else
{
$deleted = 1;
}
}
$this->filter = $tmp;
}
else
{
return false;
}
if ($deleted == 1)
{
return true;
}
else
{
return false;
}
}
ilFileExplorer::formatHeader (   $a_obj_id,
  $a_option 
)

Creates output for header (is empty here but can be overwritten in derived classes)

public

Parameters
integerobj_id
integerarray options

Definition at line 336 of file class.ilFileExplorer.php.

Referenced by getOutput().

{
}

+ Here is the caller graph for this function:

ilFileExplorer::formatObject (   $a_node_id,
  $a_option 
)

Creates output recursive method private.

Parameters
integer
array
Returns
string

Definition at line 348 of file class.ilFileExplorer.php.

References $lng, $target, $tpl, createTarget(), and ilUtil\getImagePath().

Referenced by getOutput().

{
global $lng;
if (!isset($a_node_id) or !is_array($a_option))
{
$this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
"node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
}
$tpl = new ilTemplate("tpl.tree.html", true, true);
foreach ($a_option["tab"] as $picture)
{
if ($picture == 'plus')
{
$target = $this->createTarget('+',$a_node_id);
$tpl->setCurrentBlock("expander");
$tpl->setVariable("LINK_TARGET", $target);
$tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/plus.gif"));
$tpl->parseCurrentBlock();
}
if ($picture == 'minus')
{
$target = $this->createTarget('-',$a_node_id);
$tpl->setCurrentBlock("expander");
$tpl->setVariable("LINK_TARGET", $target);
$tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/minus.gif"));
$tpl->parseCurrentBlock();
}
if ($picture == 'blank' or $picture == 'winkel'
or $picture == 'hoch' or $picture == 'quer' or $picture == 'ecke')
{
$tpl->setCurrentBlock("expander");
$tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/".$picture.".gif"));
$tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
$tpl->parseCurrentBlock();
}
}
if ($this->output_icons)
{
$tpl->setCurrentBlock("icon");
$tpl->setVariable("ICON_IMAGE" ,ilUtil::getImagePath("icon_".$a_option["type"].".gif"));
$tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock("row");
$target = (strpos($this->target, "?") === false) ?
$this->target."?" : $this->target."&";
$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
$tpl->setVariable("TITLE", $a_option["title"]);
if ($this->frame_target != "")
{
$tpl->setVariable("TARGET", " target=\"".$this->frame_target."\"");
}
$tpl->parseCurrentBlock();
$this->output[] = $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileExplorer::getFiles (   $a_parent_dir,
  $a_order 
)

Definition at line 277 of file class.ilFileExplorer.php.

References $file, and $files.

Referenced by setOutput().

{
$files = array();
$handle = opendir($a_parent_dir);
while (false !== ($file = readdir($handle)))
{
if (!is_dir($file))
{
$files[] = array("type" => "file", "name" => $file);
}
else
{
$files[] = array("type" => "dir", "name" => $file);
}
}
return $files;
}

+ Here is the caller graph for this function:

ilFileExplorer::getIndex (   $a_data)

get index of format_options array from specific ref_id,parent_id private

Parameters
arrayobject data
Returns
integer index

Definition at line 518 of file class.ilFileExplorer.php.

Referenced by setOutput().

{
foreach ($this->format_options as $key => $value)
{
if (($value["child"] == $a_data["parent"]))
{
return $key;
}
}
// exit on error
$this->ilias->raiseError(get_class($this)."::getIndex(): Error in tree. No index found!",$this->ilias->error_obj->FATAL);
}

+ Here is the caller graph for this function:

ilFileExplorer::getOutput ( )

Creates output recursive method public.

Returns
string

Definition at line 301 of file class.ilFileExplorer.php.

References formatHeader(), and formatObject().

{
$this->format_options[0]["tab"] = array();
/* ???
$depth = $this->tree->getMaximumDepth();
for ($i=0;$i<$depth;++$i)
{
$this->createLines($i);
}*/
foreach ($this->format_options as $key => $options)
{
if ($options["visible"] and $key != 0)
{
$this->formatObject($options["child"],$options);
}
if ($key == 0)
{
$this->formatHeader($options["child"],$options);
}
}
return implode('',$this->output);
}

+ Here is the call graph for this function:

ilFileExplorer::ilFileExplorer (   $a_directory,
  $a_target 
)

Constructor public.

Parameters
stringscriptname

Definition at line 96 of file class.ilFileExplorer.php.

References $ilias.

{
global $ilias;
if (!isset($a_target) or !is_string($a_target))
{
$this->ilias->raiseError(get_class($this)."::Constructor(): No target given!",$this->ilias->error_obj->WARNING);
}
if (!isset($a_directory) or !is_string($a_directory))
{
$this->ilias->raiseError(get_class($this)."::Constructor(): No directory given!",$this->ilias->error_obj->WARNING);
}
$this->ilias =& $ilias;
$this->directory = $a_directory;
$this->output = array();
$this->expanded = array();
$this->target = $a_target;
$this->target_get = 'ref_id';
$this->frame_target = "_top";
$this->order_column = "title";
$this->expand_target = $_SERVER["PATH_INFO"];
$this->rbac_check = true;
$this->output_icons = true;
}
ilFileExplorer::is_in_array (   $a_start,
  $a_depth 
)

DESCRIPTION MISSING private.

Parameters
integer
integer
Returns
boolean

Definition at line 495 of file class.ilFileExplorer.php.

Referenced by createLines().

{
for ($i=$a_start;$i<count($this->format_options);++$i)
{
if ($this->format_options[$i]["depth"] < $a_depth)
{
break;
}
if ($this->format_options[$i]["depth"] == $a_depth)
{
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

ilFileExplorer::outputIcons (   $a_icons)

output icons

Parameters
boolean$a_iconsoutput icons true/false

Definition at line 195 of file class.ilFileExplorer.php.

{
$this->output_icons = $a_icons;
}
ilFileExplorer::setExpand (   $a_node_id)

set the expand option this value is stored in a SESSION variable to save it different view (lo view, frm view,...) private

Parameters
stringpipe-separated integer

Definition at line 617 of file class.ilFileExplorer.php.

References $_SESSION.

{
// IF ISN'T SET CREATE SESSION VARIABLE
if(!is_array($_SESSION["expand"]))
{
$_SESSION["expand"] = array($this->tree->getRootId());
}
// IF $_GET["expand"] is positive => expand this node
if ($a_node_id > 0 && !in_array($a_node_id,$_SESSION["expand"]))
{
array_push($_SESSION["expand"],$a_node_id);
}
// IF $_GET["expand"] is negative => compress this node
if ($a_node_id < 0)
{
$key = array_keys($_SESSION["expand"],-(int) $a_node_id);
unset($_SESSION["expand"][$key[0]]);
}
$this->expanded = $_SESSION["expand"];
}
ilFileExplorer::setExpandTarget (   $a_exp_target)

target script for expand icons

Parameters
string$a_exp_targetscript name of target script(may include parameters) initially set to $_SERVER["PATH_INFO"]

Definition at line 175 of file class.ilFileExplorer.php.

{
$this->expand_target = $a_exp_target;
}
ilFileExplorer::setFiltered (   $a_bool)

active/deactivate the filter public

Parameters
boolean
Returns
boolean

Definition at line 644 of file class.ilFileExplorer.php.

{
$this->filtered = $a_bool;
return true;
}
ilFileExplorer::setFrameTarget (   $a_target)

set target frame or not frame?

Parameters
stringpublic

Definition at line 445 of file class.ilFileExplorer.php.

{
$this->frame_target = $a_target;
}
ilFileExplorer::setOrderColumn (   $a_column)

set the order column public

Parameters
stringname of order column

Definition at line 128 of file class.ilFileExplorer.php.

{
$this->order_column = $a_column;
}
ilFileExplorer::setOutput (   $a_parent_dir,
  $a_depth = 1 
)

Creates output for explorer view in admin menue recursive method public.

Parameters
integerparent_node_id where to start from (default=0, 'root')
integerdepth level where to start (default=1)
Returns
string

Definition at line 209 of file class.ilFileExplorer.php.

References $files, $tab, checkFilter(), getFiles(), and getIndex().

{
static $counter = 0;
if (!isset($a_parent_id))
{
$this->ilias->raiseError(get_class($this)."::setOutput(): No node_id given!",$this->ilias->error_obj->WARNING);
}
$files = $this->getFiles($a_parent_dir, $this->order_column);
if (count($files) > 0)
{
$tab = ++$a_depth - 2;
foreach ($objects as $key => $object)
{
//ask for FILTER
if ($this->filtered == false || $this->checkFilter($object["type"])==true)
{
if ($object["child"] != $this->tree->getRootId())
{
$parent_index = $this->getIndex($object);
}
$this->format_options["$counter"]["parent"] = $object["parent"];
$this->format_options["$counter"]["child"] = $object["child"];
$this->format_options["$counter"]["title"] = $object["title"];
$this->format_options["$counter"]["type"] = $object["type"];
$this->format_options["$counter"]["desc"] = "obj_".$object["type"];
$this->format_options["$counter"]["depth"] = $tab;
$this->format_options["$counter"]["container"] = false;
$this->format_options["$counter"]["visible"] = true;
// Create prefix array
for ($i = 0; $i < $tab; ++$i)
{
$this->format_options["$counter"]["tab"][] = 'blank';
}
// only if parent is expanded and visible, object is visible
if ($object["child"] != $this->tree->getRootId() and (!in_array($object["parent"],$this->expanded)
or !$this->format_options["$parent_index"]["visible"]))
{
$this->format_options["$counter"]["visible"] = false;
}
// if object exists parent is container
if ($object["child"] != $this->tree->getRootId())
{
$this->format_options["$parent_index"]["container"] = true;
if (in_array($object["parent"],$this->expanded))
{
$this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
}
else
{
$this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
}
}
++$counter;
// Recursive
$this->setOutput($object["child"],$a_depth);
} //if FILTER
} //foreach
} //if
} //function

+ Here is the call graph for this function:

ilFileExplorer::setParamsGet (   $a_params_get)

set additional params to be passed in Get-string public

Parameters
array

Definition at line 153 of file class.ilFileExplorer.php.

{
if (!isset($a_params_get) or !is_array($a_params_get))
{
$this->ilias->raiseError(get_class($this)."::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
}
foreach ($a_params_get as $key => $val)
{
$str .= "&".$key."=".$val;
}
$this->params_get = $str;
}
ilFileExplorer::setTargetGet (   $a_target_get)

set the varname in Get-string public

Parameters
stringvarname containing Ids to be used in GET-string

Definition at line 138 of file class.ilFileExplorer.php.

{
if (!isset($a_target_get) or !is_string($a_target_get))
{
$this->ilias->raiseError(get_class($this)."::setTargetGet(): No target given!",$this->ilias->error_obj->WARNING);
}
$this->target_get = $a_target_get;
}

Field Documentation

ilFileExplorer::$directory

Definition at line 40 of file class.ilFileExplorer.php.

ilFileExplorer::$expand_target

Definition at line 82 of file class.ilFileExplorer.php.

ilFileExplorer::$expanded

Definition at line 68 of file class.ilFileExplorer.php.

ilFileExplorer::$format_options

Definition at line 33 of file class.ilFileExplorer.php.

ilFileExplorer::$ilias

Definition at line 19 of file class.ilFileExplorer.php.

Referenced by ilFileExplorer().

ilFileExplorer::$order_column

Definition at line 75 of file class.ilFileExplorer.php.

ilFileExplorer::$output

Definition at line 26 of file class.ilFileExplorer.php.

ilFileExplorer::$output_icons

Definition at line 89 of file class.ilFileExplorer.php.

ilFileExplorer::$params_get

Definition at line 61 of file class.ilFileExplorer.php.

ilFileExplorer::$target

Definition at line 47 of file class.ilFileExplorer.php.

Referenced by formatObject().

ilFileExplorer::$target_get

Definition at line 54 of file class.ilFileExplorer.php.


The documentation for this class was generated from the following file: