ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPlugin Class Reference
+ Inheritance diagram for ilPlugin:
+ Collaboration diagram for ilPlugin:

Public Member Functions

 __construct ()
 
 getComponentType ()
 Get Component Type. More...
 
 getComponentName ()
 Get Component Name. More...
 
 getSlot ()
 Get Slot Name. More...
 
 getSlotId ()
 Get Slot ID. More...
 
 getPluginName ()
 Get Plugin Name. More...
 
 getId ()
 Get Id. More...
 
 getLastUpdateVersion ()
 Get Version of last update. More...
 
 getVersion ()
 Get Current Version (from plugin.php file). More...
 
 getIliasMinVersion ()
 Get Required ILIAS min. More...
 
 getIliasMaxVersion ()
 Get Required ILIAS max. More...
 
 getActive ()
 Get Active. More...
 
 setDBVersion ($a_dbversion)
 Set DB Version. More...
 
 getDBVersion ()
 Get DB Version. More...
 
 writeDBVersion ($a_dbversion)
 Write DB version to database. More...
 
 getDirectory ()
 Get Plugin Directory. More...
 
 includeClass ($a_class_file_name)
 Include (once) a class file. More...
 
 getPrefix ()
 Get plugin prefix, used for lang vars. More...
 
 getTablePrefix ()
 Get db table plugin prefix. More...
 
 updateLanguages ($a_lang_keys=null)
 
 updateDatabase ()
 Update database. More...
 
 loadLanguageModule ()
 Load language module for plugin. More...
 
 txt ($a_var)
 Get Language Variable (prefix will be prepended automatically) More...
 
 getTemplate ($a_template, $a_par1=true, $a_par2=true)
 Get template from plugin. More...
 
 getImagePath ($a_img)
 Get image path. More...
 
 getStyleSheetLocation ($a_css_file)
 Get css file location. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 Add template content to placeholder variable. More...
 
 isActive ()
 Check whether plugin is active. More...
 
 needsUpdate ()
 Check whether update is needed. More...
 
 install ()
 Install. More...
 
 activate ()
 Activate. More...
 
 deactivate ()
 Deactivate. More...
 
 uninstall ()
 
 update ()
 Update plugin. More...
 

Static Public Member Functions

static _getDirectory ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin directory. More...
 
static getAvailableLangFiles ($a_lang_directory)
 Get array of all language files in the plugin. More...
 
static hasConfigureClass ($a_slot_dir, $a_name)
 Has the plugin a configure class? More...
 
static getConfigureClassName ($a_name)
 Get plugin configure class name. More...
 
static getDBUpdateScriptName ($a_ctype, $a_cname, $a_slot_name, $a_pname)
 Get DB update script filename (full path) More...
 
static lookupTxt ($a_mod_prefix, $a_pl_id, $a_lang_var)
 Lookup language text. More...
 
static langExitsById ($pluginId, $langVar)
 Is searched lang var available in plugin lang files. More...
 
static _getImagePath ( $a_ctype, $a_cname, $a_slot_id, $a_pname, $a_img)
 Get image path. More...
 
static createPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 
static getPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get record from il_plugin table. More...
 
static getPluginObject ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin object. More...
 
static lookupStoredData ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Lookup information data in il_plugin. More...
 
static getActivePluginsForSlot ($a_ctype, $a_cname, $a_slot_id)
 Get all active plugin names for a slot. More...
 
static getActivePluginIdsForSlot ($a_ctype, $a_cname, $a_slot_id)
 Get All active plugin ids for a slot. More...
 
static lookupNameForId ($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
 Lookup name for id. More...
 
static lookupIdForName ($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
 Lookup id for name. More...
 

Protected Member Functions

 setSlotObject ($a_slot)
 Set Plugin Slot. More...
 
 getSlotObject ()
 Get Plugin Slot. More...
 
 getClassesDirectory ()
 Get Plugin's classes Directory. More...
 
 getLanguageDirectory ()
 Get Plugin's language Directory. More...
 
 slotInit ()
 Object initialization done by slot. More...
 
 init ()
 Object initialization. More...
 
 afterInstall ()
 After install processing. More...
 
 beforeActivation ()
 Before activation processing. More...
 
 afterActivation ()
 After activation processing. More...
 
 afterDeactivation ()
 After deactivation processing. More...
 
 beforeUninstall ()
 
 afterUninstall ()
 
 readEventListening ()
 Read the event listening definitions from the plugin.xml (if file exists) More...
 
 clearEventListening ()
 Clear the entries of this plugin in the event handling table. More...
 
 beforeUpdate ()
 Before update processing. More...
 
 afterUpdate ()
 After update processing. More...
 

Protected Attributes

 $lang_initialised = false
 
 $id = ''
 

Private Member Functions

 setId ($a_id)
 Set Id. More...
 
 setLastUpdateVersion ($a_lastupdateversion)
 Set Version of last update. More...
 
 setVersion ($a_version)
 Set Current Version (from plugin.php file). More...
 
 setIliasMinVersion ($a_iliasminversion)
 Set Required ILIAS min. More...
 
 setIliasMaxVersion ($a_iliasmaxversion)
 Set Required ILIAS max. More...
 
 setActive ($a_active)
 Set Active. More...
 
 __init ()
 Default initialization. More...
 

Detailed Description

Definition at line 16 of file class.ilPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

ilPlugin::__construct ( )

Definition at line 28 of file class.ilPlugin.php.

References __init(), getComponentName(), getComponentType(), getPluginName(), getSlot(), and getSlotId().

29  {
30  $this->__init();
31  }
__init()
Default initialization.
+ Here is the call graph for this function:

Member Function Documentation

◆ __init()

ilPlugin::__init ( )
private

Default initialization.

Definition at line 659 of file class.ilPlugin.php.

References $ilDB, $lng, getComponentName(), getComponentType(), getPluginName(), getPluginRecord(), getSlotId(), init(), loadLanguageModule(), setActive(), setDBVersion(), setId(), setIliasMaxVersion(), setIliasMinVersion(), setLastUpdateVersion(), setSlotObject(), setVersion(), and slotInit().

Referenced by __construct().

660  {
661  global $ilDB, $lng, $ilPluginAdmin;
662 
663  // read/set basic data
665  $this->getComponentType(),
666  $this->getComponentName(),
667  $this->getSlotId(),
668  $this->getPluginName()
669  );
670  $this->setLastUpdateVersion($rec["last_update_version"]);
671  $this->setDBVersion($rec["db_version"]);
672  $this->setActive($rec["active"]);
673 
674  // get id
675  $this->setId($ilPluginAdmin->getId(
676  $this->getComponentType(),
677  $this->getComponentName(),
678  $this->getSlotId(),
679  $this->getPluginName()
680  ));
681 
682  // get version
683  $this->setVersion($ilPluginAdmin->getVersion(
684  $this->getComponentType(),
685  $this->getComponentName(),
686  $this->getSlotId(),
687  $this->getPluginName()
688  ));
689 
690  // get ilias min version
691  $this->setIliasMinVersion($ilPluginAdmin->getIliasMinVersion(
692  $this->getComponentType(),
693  $this->getComponentName(),
694  $this->getSlotId(),
695  $this->getPluginName()
696  ));
697 
698  // get ilias max version
699  $this->setIliasMaxVersion($ilPluginAdmin->getIliasMaxVersion(
700  $this->getComponentType(),
701  $this->getComponentName(),
702  $this->getSlotId(),
703  $this->getPluginName()
704  ));
705 
706  // get slot object
707  $this->setSlotObject(new ilPluginSlot(
708  $this->getComponentType(),
709  $this->getComponentName(),
710  $this->getSlotId()
711  ));
712 
713  // load language module
714 
715  // Fix for authentication plugins
716  $this->loadLanguageModule();
717 
718  // call slot and plugin init methods
719  $this->slotInit();
720  $this->init();
721  }
loadLanguageModule()
Load language module for plugin.
setId($a_id)
Set Id.
setSlotObject($a_slot)
Set Plugin Slot.
setVersion($a_version)
Set Current Version (from plugin.php file).
getComponentName()
Get Component Name.
setIliasMaxVersion($a_iliasmaxversion)
Set Required ILIAS max.
static getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get record from il_plugin table.
getComponentType()
Get Component Type.
init()
Object initialization.
setDBVersion($a_dbversion)
Set DB Version.
Plugin Slot.
setLastUpdateVersion($a_lastupdateversion)
Set Version of last update.
getSlotId()
Get Slot ID.
global $lng
Definition: privfeed.php:17
slotInit()
Object initialization done by slot.
global $ilDB
getPluginName()
Get Plugin Name.
setIliasMinVersion($a_iliasminversion)
Set Required ILIAS min.
setActive($a_active)
Set Active.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getDirectory()

static ilPlugin::_getDirectory (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname 
)
static

Get plugin directory.

Definition at line 272 of file class.ilPlugin.php.

References ilPluginSlot\_getPluginsDirectory().

Referenced by _getImagePath(), and ilObjectDefinition\parsePluginData().

273  {
274  include_once "Services/Component/classes/class.ilPluginSlot.php";
275  return ilPluginSlot::_getPluginsDirectory($a_ctype, $a_cname, $a_slot_id) . "/" . $a_pname;
276  }
static _getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)
Get plugins directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getImagePath()

static ilPlugin::_getImagePath (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname,
  $a_img 
)
static

Get image path.

Definition at line 553 of file class.ilPlugin.php.

References $d, $img, _getDirectory(), ilUtil\getImagePath(), ilComponent\lookupId(), and lookupIdForName().

Referenced by ilOrgUnitExtensionPlugin\_getIcon(), and ilRepositoryObjectPlugin\_getIcon().

559  {
560  $d2 = ilComponent::lookupId($a_ctype, $a_cname) . "_" . $a_slot_id . "_" .
561  ilPlugin::lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_pname);
562 
563  $img = ilUtil::getImagePath($d2 . "/" . $a_img);
564  if (is_int(strpos($img, "Customizing"))) {
565  return $img;
566  }
567 
568  $d = ilPlugin::_getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname);
569  return $d . "/templates/images/" . $a_img;
570  }
static lookupId($a_type, $a_name)
Lookup ID of a component.
static lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
static _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activate()

ilPlugin::activate ( )

Activate.

Definition at line 792 of file class.ilPlugin.php.

References $ilDB, $lng, $result, afterActivation(), beforeActivation(), ilCachedComponentData\flush(), getComponentName(), getComponentType(), getPluginName(), getSlotId(), needsUpdate(), and update().

793  {
794  global $lng, $ilDB;
795 
797 
798  $result = true;
799 
800  // check whether update is necessary
801  if ($this->needsUpdate()) {
802  //$result = $this->isUpdatePossible();
803 
804  // do update
805  if ($result === true) {
806  $result = $this->update();
807  }
808  }
809  if ($result === true) {
810  $result = $this->beforeActivation();
811  // activate plugin
812  if ($result === true) {
813  $q = "UPDATE il_plugin SET active = " . $ilDB->quote(1, "integer") .
814  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
815  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
816  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
817  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
818 
819  $ilDB->manipulate($q);
820  $this->afterActivation();
821  }
822  }
824  return $result;
825  }
$result
update()
Update plugin.
needsUpdate()
Check whether update is needed.
getComponentName()
Get Component Name.
beforeActivation()
Before activation processing.
getComponentType()
Get Component Type.
afterActivation()
After activation processing.
getSlotId()
Get Slot ID.
global $lng
Definition: privfeed.php:17
global $ilDB
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

◆ addBlockFile()

ilPlugin::addBlockFile (   $a_tpl,
  $a_var,
  $a_block,
  $a_tplname 
)

Add template content to placeholder variable.

Definition at line 605 of file class.ilPlugin.php.

References getDirectory().

606  {
607  $a_tpl->addBlockFile(
608  $a_var,
609  $a_block,
610  $this->getDirectory() . "/templates/" . $a_tplname
611  );
612  }
getDirectory()
Get Plugin Directory.
+ Here is the call graph for this function:

◆ afterActivation()

ilPlugin::afterActivation ( )
protected

After activation processing.

Definition at line 850 of file class.ilPlugin.php.

Referenced by activate().

851  {
852  }
+ Here is the caller graph for this function:

◆ afterDeactivation()

ilPlugin::afterDeactivation ( )
protected

After deactivation processing.

Definition at line 881 of file class.ilPlugin.php.

Referenced by deactivate().

882  {
883  }
+ Here is the caller graph for this function:

◆ afterInstall()

ilPlugin::afterInstall ( )
protected

After install processing.

Returns
void

Definition at line 832 of file class.ilPlugin.php.

Referenced by install().

833  {
834  }
+ Here is the caller graph for this function:

◆ afterUninstall()

ilPlugin::afterUninstall ( )
protected

Definition at line 928 of file class.ilPlugin.php.

Referenced by uninstall().

929  {
930  // plugin-specific
931  }
+ Here is the caller graph for this function:

◆ afterUpdate()

ilPlugin::afterUpdate ( )
protected

After update processing.

Definition at line 1036 of file class.ilPlugin.php.

Referenced by update().

1037  {
1038  }
+ Here is the caller graph for this function:

◆ beforeActivation()

ilPlugin::beforeActivation ( )
protected

Before activation processing.

Definition at line 839 of file class.ilPlugin.php.

Referenced by activate().

840  {
841  return true; // false would indicate that anything went wrong
842  // activation would not proceed
843  // throw an exception in this case
844  //throw new ilPluginException($lng->txt(""));
845  }
+ Here is the caller graph for this function:

◆ beforeUninstall()

ilPlugin::beforeUninstall ( )
protected

Definition at line 886 of file class.ilPlugin.php.

Referenced by uninstall().

887  {
888  // plugin-specific
889  // false would indicate that anything went wrong
890  return true;
891  }
+ Here is the caller graph for this function:

◆ beforeUpdate()

ilPlugin::beforeUpdate ( )
protected

Before update processing.

Definition at line 1025 of file class.ilPlugin.php.

Referenced by update().

1026  {
1027  return true; // false would indicate that anything went wrong
1028  // update would not proceed
1029  // throw an exception in this case
1030  //throw new ilPluginException($lng->txt(""));
1031  }
+ Here is the caller graph for this function:

◆ clearEventListening()

ilPlugin::clearEventListening ( )
protected

Clear the entries of this plugin in the event handling table.

Definition at line 1010 of file class.ilPlugin.php.

References $reader, getComponentName(), getComponentType(), getDirectory(), getPluginName(), and getSlotId().

Referenced by uninstall().

1011  {
1012  $reader = new ilPluginReader(
1013  $this->getDirectory() . '/plugin.xml',
1014  $this->getComponentType(),
1015  $this->getComponentName(),
1016  $this->getSlotId(),
1017  $this->getPluginName()
1018  );
1019  $reader->clearEvents();
1020  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getDirectory()
Get Plugin Directory.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
Class ilPluginReader.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPluginRecord()

static ilPlugin::createPluginRecord (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname 
)
static
Parameters
$a_ctype
$a_cname
$a_slot_id
$a_pnameCreate plugin record

Definition at line 623 of file class.ilPlugin.php.

References $ilDB, and ilCachedComponentData\flush().

Referenced by ilPluginSlot\getPluginsInformation().

624  {
625  global $ilDB;
626 
628 
629  $q = "INSERT INTO il_plugin (component_type, component_name, slot_id, name)" .
630  " VALUES (" . $ilDB->quote($a_ctype, "text") . "," .
631  $ilDB->quote($a_cname, "text") . "," .
632  $ilDB->quote($a_slot_id, "text") . "," .
633  $ilDB->quote($a_pname, "text") . ")";
634 
635  $ilDB->manipulate($q);
636  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deactivate()

ilPlugin::deactivate ( )

Deactivate.

Definition at line 857 of file class.ilPlugin.php.

References $ilDB, $result, afterDeactivation(), ilCachedComponentData\flush(), getComponentName(), getComponentType(), getPluginName(), and getSlotId().

858  {
859  global $ilDB;
860 
862 
863  $result = true;
864 
865  $q = "UPDATE il_plugin SET active = " . $ilDB->quote(0, "integer") .
866  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
867  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
868  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
869  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
870 
871  $ilDB->manipulate($q);
872  $this->afterDeactivation();
873 
874  return $result;
875  }
$result
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getSlotId()
Get Slot ID.
global $ilDB
getPluginName()
Get Plugin Name.
afterDeactivation()
After deactivation processing.
+ Here is the call graph for this function:

◆ getActive()

ilPlugin::getActive ( )

Get Active.

Returns
boolean Active

Definition at line 193 of file class.ilPlugin.php.

194  {
195  return $this->active;
196  }

◆ getActivePluginIdsForSlot()

static ilPlugin::getActivePluginIdsForSlot (   $a_ctype,
  $a_cname,
  $a_slot_id 
)
static

Get All active plugin ids for a slot.

Parameters
$a_ctype
$a_cname
$a_slot_id
Returns
array

Definition at line 1131 of file class.ilPlugin.php.

References array, and ilCachedComponentData\getInstance().

Referenced by ilOrgUnitExtension\__construct().

1132  {
1133  global $ilPluginAdmin;
1134 
1135  $plugins = array();
1136  $cached_component = ilCachedComponentData::getInstance();
1137  $lookupActivePluginsBySlotId = $cached_component->lookupActivePluginsBySlotId($a_slot_id);
1138  foreach ($lookupActivePluginsBySlotId as $rec) {
1139  if ($ilPluginAdmin->isActive($a_ctype, $a_cname, $a_slot_id, $rec["name"])) {
1140  $plugins[] = $rec["plugin_id"];
1141  }
1142  }
1143 
1144  return $plugins;
1145  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivePluginsForSlot()

static ilPlugin::getActivePluginsForSlot (   $a_ctype,
  $a_cname,
  $a_slot_id 
)
static

Get all active plugin names for a slot.

Definition at line 1106 of file class.ilPlugin.php.

References array, and ilCachedComponentData\getInstance().

Referenced by ilPluginAdmin\getActivePluginsForSlot().

1107  {
1108  global $ilPluginAdmin;
1109 
1110  $plugins = array();
1111 
1112  $cached_component = ilCachedComponentData::getInstance();
1113 
1114  $lookupActivePluginsBySlotId = $cached_component->lookupActivePluginsBySlotId($a_slot_id);
1115  foreach ($lookupActivePluginsBySlotId as $rec) {
1116  if ($ilPluginAdmin->isActive($a_ctype, $a_cname, $a_slot_id, $rec["name"])) {
1117  $plugins[] = $rec["name"];
1118  }
1119  }
1120 
1121  return $plugins;
1122  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableLangFiles()

static ilPlugin::getAvailableLangFiles (   $a_lang_directory)
static

Get array of all language files in the plugin.

Definition at line 310 of file class.ilPlugin.php.

References $file, and array.

Referenced by ilPluginsOverviewTableGUI\gatherPluginData(), ilObjComponentSettingsGUI\showPlugin(), and updateLanguages().

311  {
312  $langs = array();
313 
314  if (!@is_dir($a_lang_directory)) {
315  return array();
316  }
317 
318  $dir = opendir($a_lang_directory);
319  while ($file = readdir($dir)) {
320  if ($file != "." and
321  $file != "..") {
322  // directories
323  if (@is_file($a_lang_directory . "/" . $file)) {
324  if (substr($file, 0, 6) == "ilias_" &&
325  substr($file, strlen($file) - 5) == ".lang") {
326  $langs[] = array("key" => substr($file, 6, 2), "file" => $file,
327  "path" => $a_lang_directory . "/" . $file);
328  }
329  }
330  }
331  }
332 
333  return $langs;
334  }
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the caller graph for this function:

◆ getClassesDirectory()

ilPlugin::getClassesDirectory ( )
protected

Get Plugin's classes Directory.

Returns
object classes directory

Definition at line 284 of file class.ilPlugin.php.

References getDirectory().

Referenced by includeClass().

285  {
286  return $this->getDirectory() . "/classes";
287  }
getDirectory()
Get Plugin Directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentName()

ilPlugin::getComponentName ( )
abstract

Get Component Name.

Must be overwritten in plugin class of plugin slot.

Returns
string Component Name

Referenced by __construct(), __init(), activate(), clearEventListening(), deactivate(), getImagePath(), getStyleSheetLocation(), install(), isActive(), needsUpdate(), readEventListening(), uninstall(), update(), updateDatabase(), and writeDBVersion().

+ Here is the caller graph for this function:

◆ getComponentType()

ilPlugin::getComponentType ( )
abstract

Get Component Type.

Must be overwritten in plugin class of plugin slot.

Returns
string Component Type

Referenced by __construct(), __init(), activate(), clearEventListening(), deactivate(), getImagePath(), getStyleSheetLocation(), install(), isActive(), needsUpdate(), readEventListening(), uninstall(), update(), updateDatabase(), and writeDBVersion().

+ Here is the caller graph for this function:

◆ getConfigureClassName()

static ilPlugin::getConfigureClassName (   $a_name)
static

Get plugin configure class name.

Parameters

Definition at line 358 of file class.ilPlugin.php.

Referenced by ilPluginsOverviewTableGUI\gatherPluginData(), ilObjComponentSettingsGUI\showPlugin(), and update().

359  {
360  return "il" . $a_name . "ConfigGUI";
361  }
+ Here is the caller graph for this function:

◆ getDBUpdateScriptName()

static ilPlugin::getDBUpdateScriptName (   $a_ctype,
  $a_cname,
  $a_slot_name,
  $a_pname 
)
static

Get DB update script filename (full path)

Returns
string DB Update script name

Definition at line 376 of file class.ilPlugin.php.

Referenced by ilPluginDBUpdate\__construct(), and ilObjComponentSettingsGUI\showPlugin().

377  {
378  return "Customizing/global/plugins/" . $a_ctype . "/" . $a_cname . "/" .
379  $a_slot_name . "/" . $a_pname . "/sql/dbupdate.php";
380  }
+ Here is the caller graph for this function:

◆ getDBVersion()

ilPlugin::getDBVersion ( )

Get DB Version.

Returns
int DB Version

Definition at line 233 of file class.ilPlugin.php.

Referenced by writeDBVersion().

234  {
235  return $this->dbversion;
236  }
+ Here is the caller graph for this function:

◆ getDirectory()

ilPlugin::getDirectory ( )

Get Plugin Directory.

Returns
object Plugin Slot

Definition at line 264 of file class.ilPlugin.php.

References getPluginName(), and getSlotObject().

Referenced by addBlockFile(), clearEventListening(), getClassesDirectory(), getLanguageDirectory(), getStyleSheetLocation(), getTemplate(), readEventListening(), and update().

265  {
266  return $this->getSlotObject()->getPluginsDirectory() . "/" . $this->getPluginName();
267  }
getPluginName()
Get Plugin Name.
getSlotObject()
Get Plugin Slot.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilPlugin::getId ( )

◆ getIliasMaxVersion()

ilPlugin::getIliasMaxVersion ( )

Get Required ILIAS max.

release.

Returns
string Required ILIAS max. release

Definition at line 173 of file class.ilPlugin.php.

174  {
175  return $this->iliasmaxversion;
176  }

◆ getIliasMinVersion()

ilPlugin::getIliasMinVersion ( )

Get Required ILIAS min.

release.

Returns
string Required ILIAS min. release

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

154  {
155  return $this->iliasminversion;
156  }

◆ getImagePath()

ilPlugin::getImagePath (   $a_img)

Get image path.

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

References getComponentName(), getComponentType(), getPluginName(), and getSlotId().

576  {
577  return self::_getImagePath(
578  $this->getComponentType(),
579  $this->getComponentName(),
580  $this->getSlotId(),
581  $this->getPluginName(),
582  $a_img
583  );
584  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

◆ getLanguageDirectory()

ilPlugin::getLanguageDirectory ( )
protected

Get Plugin's language Directory.

Returns
object classes directory

Definition at line 302 of file class.ilPlugin.php.

References getDirectory().

Referenced by updateLanguages().

303  {
304  return $this->getDirectory() . "/lang";
305  }
getDirectory()
Get Plugin Directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastUpdateVersion()

ilPlugin::getLastUpdateVersion ( )

Get Version of last update.

Returns
string Version of last update

Definition at line 113 of file class.ilPlugin.php.

114  {
115  return $this->lastupdateversion;
116  }

◆ getPluginName()

ilPlugin::getPluginName ( )
abstract

◆ getPluginObject()

static ilPlugin::getPluginObject (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname 
)
static

Get plugin object.

Parameters
string$a_ctypeIL_COMP_MODULE | IL_COMP_SERVICE
string$a_cnamecomponent name
string$a_snameplugin slot name
string$a_pnameplugin name

Definition at line 1048 of file class.ilPlugin.php.

References $file, ilCachedComponentData\getInstance(), and ilPluginSlot\lookupSlotName().

Referenced by SurveyQuestion\_getQuestionTypeName(), assQuestion\_getQuestionTypeName(), ilObjSurveyQuestionPool\_getQuestiontypes(), ilObjQuestionPool\_getQuestionTypes(), ilObjSurveyQuestionPool\_getQuestionTypeTranslations(), SurveyQuestion\_includeClass(), ilObjComponentSettingsGUI\activatePlugin(), ilObjComponentSettingsGUI\confirmUninstallPlugin(), ilObjComponentSettingsGUI\deactivatePlugin(), ilObjTest\getAvailableQuestions(), ilDclFieldFactory\getClassPathByInstance(), ilDclFieldFactory\getFieldTypeByInstance(), ilOrgUnitExtensionListGUI\getPlugin(), ilOrgUnitExtensionGUI\getPlugin(), ilObjectPluginListGUI\getPlugin(), ilOrgUnitExtension\getPlugin(), ilObjectPlugin\getPlugin(), ilObjectPluginGUI\getPlugin(), ilPluginAdmin\getPluginObject(), ilObjQuestionPool\getQuestionTypeTranslations(), ilPluginAdmin\includeClass(), assQuestion\includePluginClass(), ilObjComponentSettingsGUI\installPlugin(), ilObjQuestionPool\isPluginActive(), ilObjectPlugin\loadRepoPlugin(), ilObjComponentSettingsGUI\refreshLanguages(), ilObjLanguage\refreshPlugins(), ilObjComponentSettingsGUI\uninstallPlugin(), ilObjComponentSettingsGUI\updatePlugin(), and ilObjQuestionPoolGUI\uploadQplObject().

1049  {
1050  include_once("./Services/Component/classes/class.ilPluginSlot.php");
1051  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
1052 
1053  $cached_component = ilCachedComponentData::getInstance();
1054  $rec = $cached_component->lookCompId($a_ctype, $a_cname);
1055  if (!$rec) {
1056  return null;
1057  }
1058 
1059  $file = "./Customizing/global/plugins/" . $a_ctype . "/" .
1060  $a_cname . "/" . $slot_name . "/" .
1061  $a_pname . "/classes/class.il" . $a_pname . "Plugin.php";
1062 
1063  if (is_file($file)) {
1064  include_once($file);
1065  $class = "il" . $a_pname . "Plugin";
1066  $plugin = new $class();
1067  return $plugin;
1068  }
1069 
1070  return null;
1071  }
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPluginRecord()

static ilPlugin::getPluginRecord (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname 
)
static

Get record from il_plugin table.

Definition at line 642 of file class.ilPlugin.php.

References ilCachedComponentData\getInstance().

Referenced by __init(), ilPluginAdmin\getPluginData(), ilCloudHookPlugin\getPluginTablePrefix(), and ilDclFieldTypePlugin\getPluginTablePrefix().

643  {
644  $cached_component = ilCachedComponentData::getInstance();
645  $rec = $cached_component->lookupPluginByName($a_pname);
646 
647  if ($rec['component_type'] == $a_ctype and $rec['component_name'] == $a_cname and $rec['slot_id'] == $a_slot_id) {
648  return $rec;
649  } else {
650  include_once("./Services/Component/exceptions/class.ilPluginException.php");
651  throw (new ilPluginException("No plugin record found for '" . $a_ctype . "', '" . $a_cname . "', '" . $a_slot_id . "', '" . $a_pname
652  . "'."));
653  }
654  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrefix()

ilPlugin::getPrefix ( )

Get plugin prefix, used for lang vars.

Definition at line 366 of file class.ilPlugin.php.

References getId(), and getSlotObject().

Referenced by getTablePrefix(), loadLanguageModule(), txt(), uninstall(), update(), and updateLanguages().

367  {
368  return $this->getSlotObject()->getPrefix() . "_" . $this->getId();
369  }
getId()
Get Id.
getSlotObject()
Get Plugin Slot.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSlot()

ilPlugin::getSlot ( )
abstract

Get Slot Name.

Must be overwritten in plugin class of plugin slot.

Returns
string Slot Name

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getSlotId()

ilPlugin::getSlotId ( )
abstract

Get Slot ID.

Must be overwritten in plugin class of plugin slot.

Returns
string Slot Id

Referenced by __construct(), __init(), activate(), clearEventListening(), deactivate(), getImagePath(), getStyleSheetLocation(), install(), isActive(), needsUpdate(), readEventListening(), uninstall(), update(), updateDatabase(), and writeDBVersion().

+ Here is the caller graph for this function:

◆ getSlotObject()

ilPlugin::getSlotObject ( )
protected

Get Plugin Slot.

Returns
object Plugin Slot

Definition at line 213 of file class.ilPlugin.php.

Referenced by getDirectory(), ilCloudHookPlugin\getPluginTablePrefix(), ilDclFieldTypePlugin\getPluginTablePrefix(), and getPrefix().

214  {
215  return $this->slot;
216  }
+ Here is the caller graph for this function:

◆ getStyleSheetLocation()

ilPlugin::getStyleSheetLocation (   $a_css_file)

Get css file location.

Definition at line 589 of file class.ilPlugin.php.

References getComponentName(), getComponentType(), getDirectory(), getPluginName(), getSlotId(), ilUtil\getStyleSheetLocation(), ilComponent\lookupId(), and lookupIdForName().

590  {
591  $d2 = ilComponent::lookupId($this->getComponentType(), $this->getComponentName()) . "_" . $this->getSlotId() . "_" .
593 
594  $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
595  if (is_int(strpos($css, "Customizing"))) {
596  return $css;
597  }
598 
599  return $this->getDirectory() . "/templates/" . $a_css_file;
600  }
static lookupId($a_type, $a_name)
Lookup ID of a component.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
getComponentName()
Get Component Name.
static lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
getComponentType()
Get Component Type.
getDirectory()
Get Plugin Directory.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

◆ getTablePrefix()

ilPlugin::getTablePrefix ( )

Get db table plugin prefix.

Definition at line 385 of file class.ilPlugin.php.

References getPrefix().

Referenced by updateDatabase().

386  {
387  return $this->getPrefix();
388  }
getPrefix()
Get plugin prefix, used for lang vars.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTemplate()

ilPlugin::getTemplate (   $a_template,
  $a_par1 = true,
  $a_par2 = true 
)

Get template from plugin.

Definition at line 543 of file class.ilPlugin.php.

References $tpl, and getDirectory().

544  {
545  $tpl = new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
546 
547  return $tpl;
548  }
$tpl
Definition: ilias.php:10
getDirectory()
Get Plugin Directory.
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ getVersion()

ilPlugin::getVersion ( )

Get Current Version (from plugin.php file).

Returns
string Current Version (from plugin.php file)

Definition at line 133 of file class.ilPlugin.php.

References $version.

Referenced by update().

134  {
135  return $this->version;
136  }
+ Here is the caller graph for this function:

◆ hasConfigureClass()

static ilPlugin::hasConfigureClass (   $a_slot_dir,
  $a_name 
)
static

Has the plugin a configure class?

Parameters
stringslot directory
stringplugin name
Returns
boolean true/false

Definition at line 343 of file class.ilPlugin.php.

Referenced by ilPluginsOverviewTableGUI\gatherPluginData(), and ilObjComponentSettingsGUI\showPlugin().

344  {
345  if (is_file($a_slot_dir . "/" .
346  $a_name . "/classes/class.il" . $a_name . "ConfigGUI.php")) {
347  return true;
348  }
349  return false;
350  }
+ Here is the caller graph for this function:

◆ includeClass()

ilPlugin::includeClass (   $a_class_file_name)

Include (once) a class file.

Definition at line 292 of file class.ilPlugin.php.

References getClassesDirectory().

Referenced by ilPreviewRendererPlugin\getRendererClassInstance(), ilUserInterfaceHookPlugin\getUIClassInstance(), and ilPageComponentPlugin\getUIClassInstance().

293  {
294  include_once($this->getClassesDirectory() . "/" . $a_class_file_name);
295  }
getClassesDirectory()
Get Plugin&#39;s classes Directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilPlugin::init ( )
protected

Object initialization.

Can be overwritten by plugin class (and should be made protected)

Definition at line 735 of file class.ilPlugin.php.

Referenced by __init().

736  {
737  }
+ Here is the caller graph for this function:

◆ install()

ilPlugin::install ( )

Install.

Returns
void

Definition at line 774 of file class.ilPlugin.php.

References $ilDB, afterInstall(), ilCachedComponentData\flush(), getComponentName(), getComponentType(), getId(), getPluginName(), and getSlotId().

775  {
776  global $ilDB;
777 
779  $q = "UPDATE il_plugin SET plugin_id = " . $ilDB->quote($this->getId(), "text") .
780  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
781  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
782  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
783  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
784 
785  $ilDB->manipulate($q);
786  $this->afterInstall();
787  }
getComponentName()
Get Component Name.
getId()
Get Id.
getComponentType()
Get Component Type.
afterInstall()
After install processing.
getSlotId()
Get Slot ID.
global $ilDB
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

◆ isActive()

ilPlugin::isActive ( )

Check whether plugin is active.

Definition at line 742 of file class.ilPlugin.php.

References getComponentName(), getComponentType(), getPluginName(), and getSlotId().

743  {
744  global $ilPluginAdmin;
745 
746  return $ilPluginAdmin->isActive(
747  $this->getComponentType(),
748  $this->getComponentName(),
749  $this->getSlotId(),
750  $this->getPluginName()
751  );
752  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

◆ langExitsById()

static ilPlugin::langExitsById (   $pluginId,
  $langVar 
)
static

Is searched lang var available in plugin lang files.

Parameters
int$pluginId
string$langVar
Returns
bool

Definition at line 529 of file class.ilPlugin.php.

References $lng, and ilObjectPlugin\getRepoPluginObjectByType().

Referenced by ilObjectRolePermissionTableGUI\fillRow().

530  {
531  global $lng;
532 
534  $pl->loadLanguageModule();
535 
536  return $lng->exists($pl->getPrefix() . "_" . $langVar);
537  }
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadLanguageModule()

ilPlugin::loadLanguageModule ( )

Load language module for plugin.

Definition at line 489 of file class.ilPlugin.php.

References $lng, and getPrefix().

Referenced by __init(), and txt().

490  {
491  global $lng;
492 
493  if (!$this->lang_initialised && is_object($lng)) {
494  $lng->loadLanguageModule($this->getPrefix());
495  $this->lang_initialised = true;
496  }
497  }
getPrefix()
Get plugin prefix, used for lang vars.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupIdForName()

static ilPlugin::lookupIdForName (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_plugin_name 
)
static

Lookup id for name.

Definition at line 1169 of file class.ilPlugin.php.

References $ilDB.

Referenced by _getImagePath(), ilObjRepositorySettings\getAllObjTypes(), ilObjectDefinition\getGroupedPluginObjectTypes(), ilModulesTableGUI\getPluginComponents(), getStyleSheetLocation(), and ilObjectDefinition\parsePluginData().

1170  {
1171  global $ilDB;
1172 
1173  $q = "SELECT plugin_id FROM il_plugin " .
1174  " WHERE component_type = " . $ilDB->quote($a_ctype, "text") .
1175  " AND component_name = " . $ilDB->quote($a_cname, "text") .
1176  " AND slot_id = " . $ilDB->quote($a_slot_id, "text") .
1177  " AND name = " . $ilDB->quote($a_plugin_name, "text");
1178 
1179  $set = $ilDB->query($q);
1180  if ($rec = $ilDB->fetchAssoc($set)) {
1181  return $rec["plugin_id"];
1182  }
1183  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupNameForId()

static ilPlugin::lookupNameForId (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_plugin_id 
)
static

Lookup name for id.

Definition at line 1150 of file class.ilPlugin.php.

References $ilDB.

Referenced by ilOrgUnitExtensionPlugin\_getIcon(), ilRepositoryObjectPlugin\_getIcon(), ilOrgUnitExtensionPlugin\_getName(), ilRepositoryObjectPlugin\_getName(), ilNavigationHistory\getItems(), ilOrgUnitExtensionListGUI\getPlugin(), ilOrgUnitExtensionGUI\getPlugin(), ilObjectPluginListGUI\getPlugin(), ilOrgUnitExtension\getPlugin(), ilObjectPlugin\getPlugin(), ilObjectPluginGUI\getPlugin(), ilObjectDefinition\isActivePluginType(), ilRepositoryObjectPluginSlot\isTypePlugin(), ilRepositoryObjectPluginSlot\isTypePluginWithLP(), and ilObjectPlugin\loadRepoPlugin().

1151  {
1152  global $ilDB;
1153 
1154  $q = "SELECT name FROM il_plugin " .
1155  " WHERE component_type = " . $ilDB->quote($a_ctype, "text") .
1156  " AND component_name = " . $ilDB->quote($a_cname, "text") .
1157  " AND slot_id = " . $ilDB->quote($a_slot_id, "text") .
1158  " AND plugin_id = " . $ilDB->quote($a_plugin_id, "text");
1159 
1160  $set = $ilDB->query($q);
1161  if ($rec = $ilDB->fetchAssoc($set)) {
1162  return $rec["name"];
1163  }
1164  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupStoredData()

static ilPlugin::lookupStoredData (   $a_ctype,
  $a_cname,
  $a_slot_id,
  $a_pname 
)
static

Lookup information data in il_plugin.

Parameters
string$a_ctype
string$a_cname
string$a_slot_id
string$a_pname
Returns
string[]

Definition at line 1084 of file class.ilPlugin.php.

References $ilDB, and array.

Referenced by ilPluginSlot\getPluginsInformation().

1085  {
1086  global $ilDB;
1087 
1088  $q = "SELECT * FROM il_plugin WHERE" .
1089  " component_type = " . $ilDB->quote($a_ctype, "text") . " AND" .
1090  " component_name = " . $ilDB->quote($a_cname, "text") . " AND" .
1091  " slot_id = " . $ilDB->quote($a_slot_id, "text") . " AND" .
1092  " name = " . $ilDB->quote($a_pname, "text");
1093 
1094  $set = $ilDB->query($q);
1095 
1096  if ($ilDB->numRows($set) == 0) {
1097  return array();
1098  }
1099 
1100  return $ilDB->fetchAssoc($set);
1101  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ lookupTxt()

static ilPlugin::lookupTxt (   $a_mod_prefix,
  $a_pl_id,
  $a_lang_var 
)
static

Lookup language text.

Definition at line 512 of file class.ilPlugin.php.

References $lng.

513  {
514  global $lng;
515 
516  // this enables default language fallback
517  $prefix = $a_mod_prefix . "_" . $a_pl_id;
518  return $lng->txt($prefix . "_" . $a_lang_var, $prefix);
519  }
global $lng
Definition: privfeed.php:17

◆ needsUpdate()

ilPlugin::needsUpdate ( )

Check whether update is needed.

Definition at line 757 of file class.ilPlugin.php.

References getComponentName(), getComponentType(), getPluginName(), and getSlotId().

Referenced by activate().

758  {
759  global $ilPluginAdmin;
760 
761  return $ilPluginAdmin->needsUpdate(
762  $this->getComponentType(),
763  $this->getComponentName(),
764  $this->getSlotId(),
765  $this->getPluginName()
766  );
767  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readEventListening()

ilPlugin::readEventListening ( )
protected

Read the event listening definitions from the plugin.xml (if file exists)

Definition at line 993 of file class.ilPlugin.php.

References $reader, getComponentName(), getComponentType(), getDirectory(), getPluginName(), and getSlotId().

Referenced by update().

994  {
995  $reader = new ilPluginReader(
996  $this->getDirectory() . '/plugin.xml',
997  $this->getComponentType(),
998  $this->getComponentName(),
999  $this->getSlotId(),
1000  $this->getPluginName()
1001  );
1002  $reader->clearEvents();
1003  $reader->startParsing();
1004  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getDirectory()
Get Plugin Directory.
getSlotId()
Get Slot ID.
getPluginName()
Get Plugin Name.
Class ilPluginReader.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActive()

ilPlugin::setActive (   $a_active)
private

Set Active.

Parameters
boolean$a_activeActive

Definition at line 183 of file class.ilPlugin.php.

Referenced by __init().

184  {
185  $this->active = $a_active;
186  }
+ Here is the caller graph for this function:

◆ setDBVersion()

ilPlugin::setDBVersion (   $a_dbversion)

Set DB Version.

Parameters
int$a_dbversionDB Version

Definition at line 223 of file class.ilPlugin.php.

Referenced by __init(), and writeDBVersion().

224  {
225  $this->dbversion = $a_dbversion;
226  }
+ Here is the caller graph for this function:

◆ setId()

ilPlugin::setId (   $a_id)
private

Set Id.

Parameters
string$a_idId

Definition at line 83 of file class.ilPlugin.php.

Referenced by __init().

84  {
85  $this->id = $a_id;
86  }
+ Here is the caller graph for this function:

◆ setIliasMaxVersion()

ilPlugin::setIliasMaxVersion (   $a_iliasmaxversion)
private

Set Required ILIAS max.

release.

Parameters
string$a_iliasmaxversionRequired ILIAS max. release

Definition at line 163 of file class.ilPlugin.php.

Referenced by __init().

164  {
165  $this->iliasmaxversion = $a_iliasmaxversion;
166  }
+ Here is the caller graph for this function:

◆ setIliasMinVersion()

ilPlugin::setIliasMinVersion (   $a_iliasminversion)
private

Set Required ILIAS min.

release.

Parameters
string$a_iliasminversionRequired ILIAS min. release

Definition at line 143 of file class.ilPlugin.php.

Referenced by __init().

144  {
145  $this->iliasminversion = $a_iliasminversion;
146  }
+ Here is the caller graph for this function:

◆ setLastUpdateVersion()

ilPlugin::setLastUpdateVersion (   $a_lastupdateversion)
private

Set Version of last update.

Parameters
string$a_lastupdateversionVersion of last update

Definition at line 103 of file class.ilPlugin.php.

Referenced by __init().

104  {
105  $this->lastupdateversion = $a_lastupdateversion;
106  }
+ Here is the caller graph for this function:

◆ setSlotObject()

ilPlugin::setSlotObject (   $a_slot)
protected

Set Plugin Slot.

Parameters
object$a_slotPlugin Slot

Definition at line 203 of file class.ilPlugin.php.

Referenced by __init().

204  {
205  $this->slot = $a_slot;
206  }
+ Here is the caller graph for this function:

◆ setVersion()

ilPlugin::setVersion (   $a_version)
private

Set Current Version (from plugin.php file).

Parameters
string$a_versionCurrent Version (from plugin.php file)

Definition at line 123 of file class.ilPlugin.php.

Referenced by __init().

124  {
125  $this->version = $a_version;
126  }
+ Here is the caller graph for this function:

◆ slotInit()

ilPlugin::slotInit ( )
abstractprotected

Object initialization done by slot.

Must be overwritten in plugin class of plugin slot.

(and should be made protected)

Referenced by __init().

+ Here is the caller graph for this function:

◆ txt()

ilPlugin::txt (   $a_var)

Get Language Variable (prefix will be prepended automatically)

Definition at line 502 of file class.ilPlugin.php.

References $lng, getPrefix(), and loadLanguageModule().

Referenced by ilTestExportPlugin\getFormat().

503  {
504  global $lng;
505  $this->loadLanguageModule();
506  return $lng->txt($this->getPrefix() . "_" . $a_var, $this->getPrefix());
507  }
loadLanguageModule()
Load language module for plugin.
getPrefix()
Get plugin prefix, used for lang vars.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uninstall()

ilPlugin::uninstall ( )
final

Definition at line 893 of file class.ilPlugin.php.

References $ilDB, afterUninstall(), beforeUninstall(), clearEventListening(), ilCachedComponentData\flush(), getComponentName(), getComponentType(), getPluginName(), getPrefix(), and getSlotId().

894  {
895  global $ilDB;
896 
897  if ($this->beforeUninstall()) {
898  // remove all language entries (see ilObjLanguage)
899  // see updateLanguages
900  $prefix = $this->getPrefix();
901  if ($prefix) {
902  $ilDB->manipulate("DELETE FROM lng_data" .
903  " WHERE module = " . $ilDB->quote($prefix, "text"));
904  $ilDB->manipulate("DELETE FROM lng_modules" .
905  " WHERE module = " . $ilDB->quote($prefix, "text"));
906  }
907 
908  $this->clearEventListening();
909 
910  // db version is kept in il_plugin - will be deleted, too
911 
912  $q = "DELETE FROM il_plugin" .
913  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
914  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
915  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
916  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
917  $ilDB->manipulate($q);
918 
919  $this->afterUninstall();
920 
922  return true;
923  }
924 
925  return false;
926  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
getPrefix()
Get plugin prefix, used for lang vars.
getSlotId()
Get Slot ID.
global $ilDB
getPluginName()
Get Plugin Name.
clearEventListening()
Clear the entries of this plugin in the event handling table.
+ Here is the call graph for this function:

◆ update()

ilPlugin::update ( )

Update plugin.

Definition at line 936 of file class.ilPlugin.php.

References $ilCtrl, $ilDB, $result, afterUpdate(), beforeUpdate(), ilCachedComponentData\flush(), getComponentName(), getComponentType(), getConfigureClassName(), getDirectory(), getPluginName(), getPrefix(), getSlotId(), getVersion(), readEventListening(), updateDatabase(), and updateLanguages().

Referenced by activate(), and ilObjComponentSettingsGUI\update().

937  {
938  global $ilDB, $ilCtrl;
939 
941 
942  $result = $this->beforeUpdate();
943  if ($result === false) {
944  return false;
945  }
946 
947  // DB update
948  if ($result === true) {
949  $result = $this->updateDatabase();
950  }
951 
952  // Load language files
953  $this->updateLanguages();
954 
955  // load control structure
956  include_once("./setup/classes/class.ilCtrlStructureReader.php");
957  $structure_reader = new ilCtrlStructureReader();
958  $structure_reader->readStructure(
959  true,
960  "./" . $this->getDirectory(),
961  $this->getPrefix(),
962  $this->getDirectory()
963  );
964  // $ilCtrl->storeCommonStructures();
965 
966  // add config gui to the ctrl calls
967  $ilCtrl->insertCtrlCalls(
968  "ilobjcomponentsettingsgui",
970  $this->getPrefix()
971  );
972 
973  $this->readEventListening();
974 
975  // set last update version to current version
976  if ($result === true) {
977  $q = "UPDATE il_plugin SET last_update_version = " . $ilDB->quote($this->getVersion(), "text") .
978  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
979  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
980  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
981  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
982 
983  $ilDB->manipulate($q);
984  $this->afterUpdate();
985  }
986 
987  return $result;
988  }
getVersion()
Get Current Version (from plugin.php file).
$result
updateLanguages($a_lang_keys=null)
static getConfigureClassName($a_name)
Get plugin configure class name.
readEventListening()
Read the event listening definitions from the plugin.xml (if file exists)
getComponentName()
Get Component Name.
Class ilCtrlStructureReader.
global $ilCtrl
Definition: ilias.php:18
getComponentType()
Get Component Type.
updateDatabase()
Update database.
getDirectory()
Get Plugin Directory.
getPrefix()
Get plugin prefix, used for lang vars.
afterUpdate()
After update processing.
getSlotId()
Get Slot ID.
global $ilDB
getPluginName()
Get Plugin Name.
beforeUpdate()
Before update processing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateDatabase()

ilPlugin::updateDatabase ( )

Update database.

Definition at line 451 of file class.ilPlugin.php.

References $ilDB, $lng, $message, $result, $row, ilCachedComponentData\flush(), getComponentName(), getComponentType(), getPluginName(), getSlotId(), and getTablePrefix().

Referenced by update().

452  {
453  global $ilDB, $lng;
454 
456 
457  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
458  $dbupdate = new ilPluginDBUpdate(
459  $this->getComponentType(),
460  $this->getComponentName(),
461  $this->getSlotId(),
462  $this->getPluginName(),
463  $ilDB,
464  true,
465  $this->getTablePrefix()
466  );
467 
468  //$dbupdate->getDBVersionStatus();
469  //$dbupdate->getCurrentVersion();
470 
471  $result = $dbupdate->applyUpdate();
472  $message = '';
473  if ($dbupdate->updateMsg == "no_changes") {
474  $message = $lng->txt("no_changes") . ". " . $lng->txt("database_is_uptodate");
475  } else {
476  foreach ($dbupdate->updateMsg as $row) {
477  $message .= $lng->txt($row["msg"]) . ": " . $row["nr"] . "<br/>";
478  }
479  }
480 
481  $this->message.= $message;
482 
483  return $result;
484  }
getTablePrefix()
Get db table plugin prefix.
$result
Database Update class.
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
catch(Exception $e) $message
getSlotId()
Get Slot ID.
global $lng
Definition: privfeed.php:17
global $ilDB
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateLanguages()

ilPlugin::updateLanguages (   $a_lang_keys = null)

Definition at line 394 of file class.ilPlugin.php.

References $lang, $row, $txt, array, file, getAvailableLangFiles(), ilObjLanguage\getInstalledLanguages(), getLanguageDirectory(), getPrefix(), and ilObjLanguage\replaceLangEntry().

Referenced by update().

395  {
396  ilGlobalCache::flushAll();
397  include_once("./Services/Language/classes/class.ilObjLanguage.php");
398 
399  // get the keys of all installed languages if keys are not provided
400  if (!isset($a_lang_keys)) {
401  $a_lang_keys = array();
402  foreach (ilObjLanguage::getInstalledLanguages() as $langObj) {
403  if ($langObj->isInstalled()) {
404  $a_lang_keys[] = $langObj->getKey();
405  }
406  }
407  }
408 
409  $langs = $this->getAvailableLangFiles($this->getLanguageDirectory());
410 
411  $prefix = $this->getPrefix();
412 
413  foreach ($langs as $lang) {
414  // check if the language should be updated, otherwise skip it
415  if (!in_array($lang['key'], $a_lang_keys)) {
416  continue;
417  }
418 
419  $txt = file($this->getLanguageDirectory() . "/" . $lang["file"]);
420  $lang_array = array();
421 
422  // get locally changed variables of the module (these should be kept)
423  $local_changes = ilObjLanguage::_getLocalChangesByModule($lang['key'], $prefix);
424 
425  // get language data
426  if (is_array($txt)) {
427  foreach ($txt as $row) {
428  if ($row[0] != "#" && strpos($row, "#:#") > 0) {
429  $a = explode("#:#", trim($row));
430  $identifier = $prefix . "_" . trim($a[0]);
431  $value = trim($a[1]);
432 
433  if (isset($local_changes[$identifier])) {
434  $lang_array[$identifier] = $local_changes[$identifier];
435  } else {
436  $lang_array[$identifier] = $value;
437  ilObjLanguage::replaceLangEntry($prefix, $identifier, $lang["key"], $value);
438  }
439  //echo "<br>-$prefix-".$prefix."_".trim($a[0])."-".$lang["key"]."-";
440  }
441  }
442  }
443 
444  ilObjLanguage::replaceLangModule($lang["key"], $prefix, $lang_array);
445  }
446  }
static getInstalledLanguages()
Get the language objects of the installed languages.
Reload workbook from saved file
$txt
Definition: error.php:11
getPrefix()
Get plugin prefix, used for lang vars.
Create styles array
The data for the language used.
static getAvailableLangFiles($a_lang_directory)
Get array of all language files in the plugin.
getLanguageDirectory()
Get Plugin&#39;s language Directory.
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeDBVersion()

ilPlugin::writeDBVersion (   $a_dbversion)

Write DB version to database.

Parameters
int$a_dbversionDB Version

Definition at line 243 of file class.ilPlugin.php.

References $ilDB, getComponentName(), getComponentType(), getDBVersion(), getPluginName(), getSlotId(), and setDBVersion().

244  {
245  global $ilDB;
246 
247  $this->setDBVersion($a_dbversion);
248 
249  $q = "UPDATE il_plugin SET db_version = " . $ilDB->quote((int) $this->getDBVersion(), "integer") .
250  " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
251  " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
252  " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
253  " AND name = " . $ilDB->quote($this->getPluginName(), "text");
254 
255  $ilDB->manipulate($q);
256  }
getComponentName()
Get Component Name.
getComponentType()
Get Component Type.
setDBVersion($a_dbversion)
Set DB Version.
getDBVersion()
Get DB Version.
getSlotId()
Get Slot ID.
global $ilDB
getPluginName()
Get Plugin Name.
+ Here is the call graph for this function:

Field Documentation

◆ $id

ilPlugin::$id = ''
protected

◆ $lang_initialised

ilPlugin::$lang_initialised = false
protected

Definition at line 22 of file class.ilPlugin.php.


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