ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilParagraphPlugins Class Reference

class which contains all registered plugins More...

+ Collaboration diagram for ilParagraphPlugins:

Public Member Functions

 ilParagraphPlugins ()
 constructor initializes skip Directories
 getRegisteredPluginsAsArray ()
 getPluginArray
 getParagraphPlugin ($pluginDir)
 get a specific plugin by its directory name (since directories are unique)
 registerPlugin ($plugin)
 register plugin
 isRegistered ($pluginClassname)
 serializeToString ()
 serializes all plugin to one string format filetype::title::link::image|filetype#title#link#image|...
 initialize ()
 parses plugin subdirectory to determine registered plugins
 getTextContent ($a_element, $nodename)
 get Text content from a child node (unique by name), otherwise first will be taken.

Data Fields

 $plugins
 array which contains an instance of each plugin keys are equal to the serialization string of a plugin
 $pluginDirectory
 contains the plugins directory
 $skipDirectories
 array which contains all directories which should not be parsed within the plugins directory, by default the sub directories resources, CVS and classes are skipped

Detailed Description

class which contains all registered plugins

Definition at line 34 of file class.ilParagraphPlugins.php.

Member Function Documentation

ilParagraphPlugins::getParagraphPlugin (   $pluginDir)

get a specific plugin by its directory name (since directories are unique)

Parameters
ilParagraphPlugin$pluginDir

Definition at line 77 of file class.ilParagraphPlugins.php.

{
foreach ($this->plugins as $plugin) {
if (strcasecmp($pluginDir, $plugin->getDirectory()) == 0)
return $plugin;
}
return null;
}
ilParagraphPlugins::getRegisteredPluginsAsArray ( )

getPluginArray

Definition at line 67 of file class.ilParagraphPlugins.php.

References $plugins.

{
}
ilParagraphPlugins::getTextContent (   $a_element,
  $nodename 
)

get Text content from a child node (unique by name), otherwise first will be taken.

Parameters
DOM_ELEMENT$a_element
String$nodename
Returns
String

Definition at line 197 of file class.ilParagraphPlugins.php.

Referenced by initialize().

{
$elems = $a_element -> get_elements_by_tagname ( $nodename );
if (count ($elems) > 0)
{
return $elems[0]->get_content();
}
return "";
}

+ Here is the caller graph for this function:

ilParagraphPlugins::ilParagraphPlugins ( )

constructor initializes skip Directories

Definition at line 55 of file class.ilParagraphPlugins.php.

References ILIAS_ABSOLUTE_PATH.

{
$this->plugins = array();
$this->pluginDirectory = ILIAS_ABSOLUTE_PATH."/Services/COPage/plugins";
$this->skipDirectories = array ();
$this->skipDirectories [$this->pluginDirectory."/classes"] = "skip";
$this->skipDirectories [$this->pluginDirectory."/resources"]= "skip";
$this->skipDirectories [$this->pluginDirectory."/CVS"]= "skip";
}
ilParagraphPlugins::initialize ( )

parses plugin subdirectory to determine registered plugins

Definition at line 112 of file class.ilParagraphPlugins.php.

References $title, getTextContent(), isRegistered(), and registerPlugin().

{
if (file_exists($this->pluginDirectory))
{
$pluginDirs = glob($this->pluginDirectory."/*",GLOB_ONLYDIR);
if (is_array($pluginDirs))
{
foreach ($pluginDirs as $pluginDir) {
// if there is no plugin xml file, or we are in a skipping directory then continue loop
if (array_key_exists($pluginDir,$this->skipDirectories) || !file_exists($pluginDir."/plugin.xml")) {
continue;
}
// load plugin xml, to retrieve plugin node (see dtd)
$pluginDOM = new ilDOMXML();
$pluginDOM->loadDocument("plugin.xml", $pluginDir, false);
$pluginNodes = $pluginDOM->getElementsByTagname("plugin");
if ( count ($pluginNodes)>0 )
{
// found plugin node
$pluginNode = $pluginNodes[0];
//print_r($pluginNode) ;
//this is the subdirectory of the plugin
$pluginSubDir = str_replace($this->pluginDirectory."/","",$pluginDir);
// class file containing class which inherits from paragraph plugin
$classfile = $pluginNode->get_attribute ("classfile");
// according classname
$classname = $pluginNode->get_attribute ("classname");
// filter filetype, refers to sourcecode directory, hfile, e.g. java122 affects, that this plugin is for this paragraph type only
$filetype = $pluginNode->get_attribute ("filetype");
// enable/disable plugin
$active = strcasecmp($pluginNode->get_attribute ("active"),"true") == 0;
// title is alt text for image
$title = $this->getTextContent($pluginNode,"title");
// link
$link = $this->getTextContent($pluginNode,"link");
// description, not shown at the momemnt
$description = $this->getTextContent($pluginNode,"description");
// prepare class file for include, must reside in classes directory
$classfile = $pluginDir . "/classes/".$classfile;
/* echo $classfile."<br>";
echo $classname."<br>";
echo $filetype."<br>";
echo $active."<br>";
echo $title."<br>";
echo $description."<br>";*/
if (file_exists($classfile) && $active && !$this->isRegistered($classname))
{
include_once ($classfile);
$plugin = new $classname($pluginSubDir, $title, $filetype, $link, $description, $active);
//print_r($plugin);
if (is_a($plugin,"ilParagraphPlugin") && $plugin->isActive()) {
$this->registerPlugin($plugin);
unset ($plugin);
}
}
}
}
}
}
}

+ Here is the call graph for this function:

ilParagraphPlugins::isRegistered (   $pluginClassname)

Definition at line 94 of file class.ilParagraphPlugins.php.

Referenced by initialize().

{
foreach ($this->plugins as $plugin) {
if (strcasecmp(get_class($plugin), $pluginClassname) == 0)
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilParagraphPlugins::registerPlugin (   $plugin)

register plugin

Definition at line 88 of file class.ilParagraphPlugins.php.

Referenced by initialize().

{
//echo "registered Plugin ".$plugin->getTitle();
$this->plugins[$plugin->serializeToString()] = $plugin;
}

+ Here is the caller graph for this function:

ilParagraphPlugins::serializeToString ( )

serializes all plugin to one string format filetype::title::link::image|filetype#title#link#image|...

Definition at line 105 of file class.ilParagraphPlugins.php.

{
return implode ("|", array_keys($this->plugins));
}

Field Documentation

ilParagraphPlugins::$pluginDirectory

contains the plugins directory

Definition at line 44 of file class.ilParagraphPlugins.php.

ilParagraphPlugins::$plugins

array which contains an instance of each plugin keys are equal to the serialization string of a plugin

Definition at line 39 of file class.ilParagraphPlugins.php.

Referenced by getRegisteredPluginsAsArray().

ilParagraphPlugins::$skipDirectories

array which contains all directories which should not be parsed within the plugins directory, by default the sub directories resources, CVS and classes are skipped

Definition at line 50 of file class.ilParagraphPlugins.php.


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