Commit 6b638467f143a744dedef54c8e1ec4c1a583debb
1 parent
c763d2e3
The page registry allows for entirely dispatcher objects to be reached
via the web using /plugin.php/pagename. Plugins will automatically put their namespaces at the beginning, so for subscriptions, it would be /plugin.php/ktstandard.subscriptions.plugin/pagename. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4134 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
30 additions
and
0 deletions
lib/plugins/pageregistry.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +class KTPageRegistry { | |
| 4 | + var $aResources = array(); | |
| 5 | + | |
| 6 | + function &getSingleton() { | |
| 7 | + if (!KTUtil::arrayGet($GLOBALS, 'oKTPageRegistry')) { | |
| 8 | + $GLOBALS['oKTPageRegistry'] = new KTPageRegistry; | |
| 9 | + } | |
| 10 | + return $GLOBALS['oKTPageRegistry']; | |
| 11 | + } | |
| 12 | + | |
| 13 | + function registerPage($sPath, $sClassName, $sFilename = null) { | |
| 14 | + $this->aResources[$sPath] = array($sPath, $sClassName, $sFilename); | |
| 15 | + } | |
| 16 | + | |
| 17 | + function getPage($sPath) { | |
| 18 | + $aInfo = KTUtil::arrayGet($this->aResources, $sPath); | |
| 19 | + if (empty($aInfo)) { | |
| 20 | + return null; | |
| 21 | + } | |
| 22 | + $sClassName = $aInfo[1]; | |
| 23 | + $sFilename = $aInfo[2]; | |
| 24 | + if ($sFilename) { | |
| 25 | + require_once($sFilename); | |
| 26 | + } | |
| 27 | + return new $sClassName; | |
| 28 | + } | |
| 29 | +} | |
| 30 | + | ... | ... |