Commit 73d33126c2198e0fc5c3fd30a34c04c11ebaa133

Authored by Michael Joseph
1 parent 0ca3d6d7

added document status constants

additional optional parameter for getDisplayPath to display the file type icon


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2116 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
1 <?php 1 <?php
  2 +
  3 +// document statuses
  4 +DEFINE("LIVE", 1);
  5 +DEFINE("PUBLISHED", 2);
  6 +DEFINE("DELETED", 3);
  7 +DEFINE("ARCHIVED", 4);
  8 +
2 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); 9 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
3 10
4 /** 11 /**
@@ -74,7 +81,7 @@ class Document { @@ -74,7 +81,7 @@ class Document {
74 $this->bIsCheckedOut = false; 81 $this->bIsCheckedOut = false;
75 $this->iCheckedOutUserID = -1; 82 $this->iCheckedOutUserID = -1;
76 // FIXME: statuses 83 // FIXME: statuses
77 - $this->iStatusID = lookupStatusID("Live"); 84 + $this->iStatusID = LIVE;
78 } 85 }
79 86
80 /** Get the document primary key */ 87 /** Get the document primary key */
@@ -226,14 +233,14 @@ class Document { @@ -226,14 +233,14 @@ class Document {
226 * Returns the live status of the document 233 * Returns the live status of the document
227 */ 234 */
228 function isLive() { 235 function isLive() {
229 - return $this->getStatusID() == lookupStatusID("Live"); 236 + return $this->getStatusID() == LIVE;
230 } 237 }
231 238
232 /** 239 /**
233 * Get status ID wrapper for archived status 240 * Get status ID wrapper for archived status
234 */ 241 */
235 function isArchived() { 242 function isArchived() {
236 - return $this->getStatusID() == lookupStatusID("Archived"); 243 + return $this->getStatusID() == ARCHIVED;
237 } 244 }
238 245
239 /** returns the number of days since this document has been last modified **/ 246 /** returns the number of days since this document has been last modified **/
@@ -493,7 +500,7 @@ class Document { @@ -493,7 +500,7 @@ class Document {
493 $oDocument->sFullPath = stripslashes($sql->f("full_path")); 500 $oDocument->sFullPath = stripslashes($sql->f("full_path"));
494 $oDocument->setCheckedOutUserID($sql->f("checked_out_user_id")); 501 $oDocument->setCheckedOutUserID($sql->f("checked_out_user_id"));
495 // FIXME: nasty hack- paying the penalty for adding status_id late in phase 2 502 // FIXME: nasty hack- paying the penalty for adding status_id late in phase 2
496 - $oDocument->setStatusID( ($sql->f("status_id") == "" ? lookupStatusID("Live") : $sql->f("status_id")) ); 503 + $oDocument->setStatusID( ($sql->f("status_id") == "" ? LIVE : $sql->f("status_id")) );
497 $oDocument->iId = $iDocumentID; 504 $oDocument->iId = $iDocumentID;
498 return $oDocument; 505 return $oDocument;
499 } 506 }
@@ -608,6 +615,14 @@ class Document { @@ -608,6 +615,14 @@ class Document {
608 return false; 615 return false;
609 } 616 }
610 } 617 }
  618 +
  619 + /**
  620 + * Returns the html to display the document icon image
  621 + */
  622 + function getIcon() {
  623 + global $default;
  624 + return generateImage($this->getMimeTypeIconUrl() ? $this->getMimeTypeIconUrl() : "$default->graphicsUrl/unknown.gif");
  625 + }
611 626
612 /** 627 /**
613 * Get the full path for a document 628 * Get the full path for a document
@@ -623,8 +638,8 @@ class Document { @@ -623,8 +638,8 @@ class Document {
623 * 638 *
624 * @return string full path to document 639 * @return string full path to document
625 */ 640 */
626 - function getDisplayPath() {  
627 - return Folder::getFolderDisplayPath($this->iFolderID) . " > " . $this->sName; 641 + function getDisplayPath($bDisplayIcon = false) {
  642 + return ($bDisplayIcon ? $this->getIcon() : "") . Folder::getFolderDisplayPath($this->iFolderID) . " > " . $this->sName;
628 } 643 }
629 644
630 /** 645 /**