• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilParagraphPlugin.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00032 class ParagraphPlugins {
00033         var $plugins;
00034         var $pluginDirectory;
00035         var $skipDirectories;
00036         
00037         function ParagraphPlugins () {
00038                 $this->plugins = array();
00039                 $this->pluginDirectory = ILIAS_ABSOLUTE_PATH."/content/plugins";
00040                 $this->skipDirectories = array ();
00041                 $this->skipDirectories [$this->pluginDirectory."/classes"] = "skip"; 
00042                 $this->skipDirectories [$this->pluginDirectory."/resources"]= "skip";
00043                 $this->skipDirectories [$this->pluginDirectory."/CVS"]= "skip";
00044         }
00045         
00049         function getRegisteredPluginsAsArray () {
00050                 return $this->plugins;          
00051         }
00052         
00053         
00057         function registerPlugin ($plugin) {
00058                 //echo "registered Plugin ".$plugin->getTitle();
00059                 $this->plugins[$plugin->serializeToString()] = $plugin;
00060         }
00061         
00066         function serializeToString (){
00067                 return implode ("|", array_keys($this->plugins));               
00068         }
00069         
00073         function initialize () {                
00074                 foreach (glob($this->pluginDirectory."/*",GLOB_ONLYDIR) as $pluginDir) {
00075                         if (array_key_exists($pluginDir,$this->skipDirectories))
00076                                 continue;
00077                         $pluginFile = $pluginDir . "/classes/class.plugin.php";
00078                         if (file_exists($pluginFile)) {
00079                                 include ($pluginFile);
00080                                 if (is_object($plugin)) {
00081                                         $this->registerPlugin($plugin);
00082                                         unset ($plugin);
00083                                 }
00084                         }
00085                 }       
00086         }
00087 }
00088 
00089 class ParagraphPlugin {
00090         var $properties;
00091         var $directory;
00092         
00093         function ParagraphPlugin ($directory, $title, $filetype, $link) {
00094                 $this->directory = $directory;
00095                 $this->properties = array ("filetype" => "", "title" => "", "link" => "");
00096                 $this->setTitle($title);
00097                 $this->setFileType($filetype);
00098                 $this->setLink ($link);         
00099         }
00100         
00101         function serializeToString (){          
00102                 return implode("#",$this->properties);
00103         }
00104         
00105         function setTitle ($title) {
00106                 $this->properties["title"] = $title;
00107         }
00108         
00109         function setLink ($link) {
00110                 $this->properties["link"] = $this->getPluginURL()."/".$link;
00111         }
00112         
00113         function setImage ($image) {
00114                 $this->properties["image"] = $this->getResourceURL()."/".$image;
00115         }
00116         
00117         function setFileType ($filetype) {
00118                 $this->properties["filetype"] = $filetype;
00119         }       
00120         
00121         function getTitle () {
00122                 return $this->properties["title"];
00123         }
00124                 
00125         function getPluginDir () {
00126                 return ILIAS_ABSOLUTE_PATH."/content/plugins"."/".$this->directory;
00127         }
00128         
00129         function getTemplateDir () {
00130                 return $this->getPluginDir()."/templates";      
00131         }
00132         
00133         function getClassDir () {
00134                 return $this->getPluginDir()."/classes";        
00135         }
00136         
00137         
00138         function getResourceDir () {
00139                 return $this->getPluginDir()."/resources";      
00140         }
00141         
00142         function getResourceURL () {
00143                 return ILIAS_HTTP_PATH."/content/plugins/".$this->directory."/resources";       
00144         }
00145         
00146         function getPluginURL () {
00147                 return ILIAS_HTTP_PATH."/content/plugins/".$this->directory;    
00148         }
00149 }
00150 
00151 $paragraph_plugins = new ParagraphPlugins();
00152 
00153 $paragraph_plugins->initialize ();
00154 
00155 $GLOBALS["paragraph_plugins"] = $paragraph_plugins;
00156 
00157 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1