Commit 10295e772f7e2586d2e94a2b27e8d4e8ec25bc91
1 parent
c6bebf9f
"CLONE -Custom Numbering Plugin - Workflow Transition (SUP-1248)"
KTC-654 Merge to trunk. Committed by: Donald Jackson Reviewed by: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9674 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
48 additions
and
20 deletions
lib/documentmanagement/documentmetadataversion.inc.php
| ... | ... | @@ -72,26 +72,9 @@ class KTDocumentMetadataVersion extends KTEntity { |
| 72 | 72 | var $iWorkflowId; |
| 73 | 73 | var $iWorkflowStateId; |
| 74 | 74 | |
| 75 | - var $_aFieldToSelect = array( | |
| 76 | - "iId" => "id", | |
| 77 | - | |
| 78 | - "iDocumentId" => 'document_id', | |
| 79 | - "iMetadataVersion" => 'metadata_version', | |
| 80 | - "iContentVersionId" => 'content_version_id', | |
| 81 | - | |
| 82 | - "iDocumentTypeId" => 'document_type_id', | |
| 83 | - | |
| 84 | - "sName" => 'name', | |
| 85 | - "sDescription" => 'description', | |
| 86 | - | |
| 87 | - "iStatusId" => 'status_id', | |
| 88 | - | |
| 89 | - "dVersionCreated" => 'version_created', | |
| 90 | - "iVersionCreatorId" => 'version_creator_id', | |
| 91 | - | |
| 92 | - "iWorkflowId" => 'workflow_id', | |
| 93 | - "iWorkflowStateId" => 'workflow_state_id', | |
| 94 | - ); | |
| 75 | + var $_aFieldToSelect; | |
| 76 | + | |
| 77 | + public static $_versionFields = null; | |
| 95 | 78 | |
| 96 | 79 | // {{{ getters/setters |
| 97 | 80 | function getDocumentId() { return $this->iDocumentId; } |
| ... | ... | @@ -118,6 +101,41 @@ class KTDocumentMetadataVersion extends KTEntity { |
| 118 | 101 | function getWorkflowStateId() { return $this->iWorkflowStateId; } |
| 119 | 102 | function setWorkflowStateId($mValue) { $this->iWorkflowStateId = $mValue; } |
| 120 | 103 | // }}} |
| 104 | + | |
| 105 | + function __construct() { | |
| 106 | + $this->_aFieldToSelect = KTDocumentMetaDataVersion::getFieldsToSelect(); | |
| 107 | + } | |
| 108 | + | |
| 109 | + static | |
| 110 | + function getFieldsToSelect() { | |
| 111 | + if(self::$_versionFields == null) { | |
| 112 | + $sTable = KTUtil::getTableName('document_metadata_version'); | |
| 113 | + $aFields = DBUtil::getResultArray(array("DESCRIBE $sTable")); | |
| 114 | + $result = array(); | |
| 115 | + for($i=0;$i<count($aFields);$i++) { | |
| 116 | + $result[KTDocumentMetaDataVersion::getFieldType($aFields[$i]['Type']).KTUtil::camelize($aFields[$i]['Field'])] = $aFields[$i]['Field']; | |
| 117 | + } | |
| 118 | + self::$_versionFields = $result; | |
| 119 | + } | |
| 120 | + return self::$_versionFields; | |
| 121 | + } | |
| 122 | + | |
| 123 | + static | |
| 124 | + function getFieldType($dbType) { | |
| 125 | + /* Integer test */ | |
| 126 | + if(strpos($dbType, "int") !== FALSE) { | |
| 127 | + return "i"; | |
| 128 | + } | |
| 129 | + | |
| 130 | + /* Time test */ | |
| 131 | + if(strpos($dbType, "time") !== FALSE) { | |
| 132 | + return "d"; | |
| 133 | + } | |
| 134 | + | |
| 135 | + /* Default */ | |
| 136 | + return "s"; | |
| 137 | + } | |
| 138 | + | |
| 121 | 139 | |
| 122 | 140 | function &createFromArray($aOptions) { |
| 123 | 141 | return KTEntityUtil::createFromArray('KTDocumentMetadataVersion', $aOptions); | ... | ... |
lib/util/ktutil.inc
| ... | ... | @@ -1343,6 +1343,16 @@ class KTUtil { |
| 1343 | 1343 | return false; |
| 1344 | 1344 | } |
| 1345 | 1345 | } |
| 1346 | + | |
| 1347 | + static | |
| 1348 | + function camelize($string) { | |
| 1349 | + $result = ""; | |
| 1350 | + $parts = explode("_", $string); | |
| 1351 | + for($i=0;$i<count($parts);$i++) { | |
| 1352 | + $result .= ucfirst($parts[$i]); | |
| 1353 | + } | |
| 1354 | + return $result; | |
| 1355 | + } | |
| 1346 | 1356 | } |
| 1347 | 1357 | |
| 1348 | 1358 | /** | ... | ... |