Commit cb76ac0c2d33a58314c8a73924b03760bd55ae30

Authored by Neil Blakey-Milner
1 parent e547daea

Allow plugins to order themselves numerically - plugins default to order

0.  Negative orders are possible.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5139 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 16 additions and 3 deletions
lib/plugins/pluginutil.inc.php
@@ -61,7 +61,9 @@ class KTPluginUtil { @@ -61,7 +61,9 @@ class KTPluginUtil {
61 if (count($aPlugins) === 0) { 61 if (count($aPlugins) === 0) {
62 KTPluginUtil::registerPlugins(); 62 KTPluginUtil::registerPlugins();
63 } 63 }
64 - $aPaths = array(KT_DIR . '/plugins/ktcore/KTCorePlugin.php'); 64 + $aPaths = array();
  65 + $aPaths[] = KT_DIR . '/plugins/ktcore/KTCorePlugin.php';
  66 + $aPaths[] = KT_DIR . '/plugins/ktcore/KTCoreLanguagePlugin.php';
65 foreach ($aPlugins as $oPlugin) { 67 foreach ($aPlugins as $oPlugin) {
66 if (!is_a($oPlugin, 'KTPluginEntity')) { 68 if (!is_a($oPlugin, 'KTPluginEntity')) {
67 print "<pre>"; 69 print "<pre>";
@@ -81,9 +83,20 @@ class KTPluginUtil { @@ -81,9 +83,20 @@ class KTPluginUtil {
81 require_once($sPath); 83 require_once($sPath);
82 } 84 }
83 } 85 }
  86 +
84 $oRegistry =& KTPluginRegistry::getSingleton(); 87 $oRegistry =& KTPluginRegistry::getSingleton();
85 - foreach ($oRegistry->getPlugins() as $oPlugin) {  
86 - $oPlugin->load(); 88 + $aPlugins =& $oRegistry->getPlugins();
  89 + foreach ($aPlugins as $oPlugin) {
  90 + if (!isset($aOrder[$oPlugin->iOrder])) {
  91 + $aOrder[$oPlugin->iOrder] = array();
  92 + }
  93 + $aOrder[$oPlugin->iOrder][] = $oPlugin;
  94 + }
  95 + ksort($aOrder, SORT_NUMERIC);
  96 + foreach ($aOrder as $iOrder => $aOrderPlugins) {
  97 + foreach ($aOrderPlugins as $oPlugin) {
  98 + $oPlugin->load();
  99 + }
87 } 100 }
88 } 101 }
89 102