Commit 782e0175250990b32a74dfc781b8dd43edef1629
1 parent
1dce675a
Add some accessors to allow easy use of actions via templates.
Add getAllDocumentActions and getDocumentActionsByNames to help workflow mappings to actions. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3728 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
47 additions
and
2 deletions
lib/actions/documentaction.inc.php
| ... | ... | @@ -66,19 +66,31 @@ class KTDocumentAction { |
| 66 | 66 | return $this->customiseInfo($aInfo); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + function getName() { | |
| 70 | + return $this->sName; | |
| 71 | + } | |
| 72 | + | |
| 73 | + function getDisplayName() { | |
| 74 | + return $this->sDisplayName; | |
| 75 | + } | |
| 76 | + | |
| 77 | + function getDescription() { | |
| 78 | + return $this->sDescription; | |
| 79 | + } | |
| 80 | + | |
| 69 | 81 | function customiseInfo($aInfo) { |
| 70 | 82 | return $aInfo; |
| 71 | 83 | } |
| 72 | 84 | } |
| 73 | 85 | |
| 74 | 86 | class KTDocumentActionUtil { |
| 75 | - function getDocumentActions() { | |
| 87 | + function getDocumentActionInfo() { | |
| 76 | 88 | $oRegistry =& KTActionRegistry::getSingleton(); |
| 77 | 89 | return $oRegistry->getActions('documentaction'); |
| 78 | 90 | } |
| 79 | 91 | function &getDocumentActionsForDocument($oDocument, $oUser) { |
| 80 | 92 | $aObjects = array(); |
| 81 | - foreach (KTDocumentActionUtil::getDocumentActions() as $aAction) { | |
| 93 | + foreach (KTDocumentActionUtil::getDocumentActionInfo() as $aAction) { | |
| 82 | 94 | list($sClassName, $sPath) = $aAction; |
| 83 | 95 | if (!empty($sPath)) { |
| 84 | 96 | // require_once(KT_DIR . |
| ... | ... | @@ -88,6 +100,39 @@ class KTDocumentActionUtil { |
| 88 | 100 | } |
| 89 | 101 | return $aObjects; |
| 90 | 102 | } |
| 103 | + | |
| 104 | + function getAllDocumentActions() { | |
| 105 | + $aObjects = array(); | |
| 106 | + $oDocument = null; | |
| 107 | + $oUser = null; | |
| 108 | + foreach (KTDocumentActionUtil::getDocumentActionInfo() as $aAction) { | |
| 109 | + list($sClassName, $sPath, $sName) = $aAction; | |
| 110 | + if (!empty($sPath)) { | |
| 111 | + // require_once(KT_DIR . | |
| 112 | + // Or something... | |
| 113 | + } | |
| 114 | + $aObjects[] =& new $sClassName($oDocument, $oUser); | |
| 115 | + } | |
| 116 | + return $aObjects; | |
| 117 | + } | |
| 118 | + | |
| 119 | + function getDocumentActionsByNames($aNames) { | |
| 120 | + $aObjects = array(); | |
| 121 | + $oDocument = null; | |
| 122 | + $oUser = null; | |
| 123 | + foreach (KTDocumentActionUtil::getDocumentActionInfo() as $aAction) { | |
| 124 | + list($sClassName, $sPath, $sName) = $aAction; | |
| 125 | + if (!in_array($sName, $aNames)) { | |
| 126 | + continue; | |
| 127 | + } | |
| 128 | + if (!empty($sPath)) { | |
| 129 | + // require_once(KT_DIR . | |
| 130 | + // Or something... | |
| 131 | + } | |
| 132 | + $aObjects[] =& new $sClassName($oDocument, $oUser); | |
| 133 | + } | |
| 134 | + return $aObjects; | |
| 135 | + } | |
| 91 | 136 | } |
| 92 | 137 | |
| 93 | 138 | class KTBuiltInDocumentAction extends KTDocumentAction { | ... | ... |