Ejemplo n.º 1
0
 function do_main()
 {
     //registerTypes registers the mime types and populates the needed tables.
     $indexer = Indexer::get();
     $indexer->registerTypes();
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/managemimetypes');
     $aMimeTypes = KTMime::getAllMimeTypesInformation();
     $indexer = Indexer::get();
     $numExtensions = 0;
     $numIndexedExtensions = 0;
     foreach ($aMimeTypes as $key => $mimeType) {
         $extractorClass = $mimeType['extractor'];
         $numExtensions++;
         if (empty($extractorClass)) {
             continue;
         }
         $extractor = $indexer->getExtractor($extractorClass);
         $aMimeTypes[$key]['extractor'] = $extractor->getDisplayName();
         $numIndexedExtensions++;
     }
     $indexedPercentage = 0;
     if ($numExtensions > 0) {
         $indexedPercentage = number_format($numIndexedExtensions * 100 / $numExtensions, 2, '.', ',');
     }
     $oTemplate->setData(array('context' => $this, 'mime_types' => $aMimeTypes, 'numExtensions' => $numExtensions, 'numIndexedExtensions' => $numIndexedExtensions, 'indexedPercentage' => $indexedPercentage));
     return $oTemplate;
 }
Ejemplo n.º 2
0
 function transform()
 {
     global $default;
     $iMimeTypeId = $this->oDocument->getMimeTypeId();
     $sMimeType = KTMime::getMimeTypeName($iMimeTypeId);
     $sFileName = $this->oDocument->getFileName();
     $aTestTypes = array('application/octet-stream', 'application/zip', 'application/x-zip');
     if (in_array($sMimeType, $aTestTypes)) {
         $sExtension = KTMime::stripAllButExtension($sFileName);
         $sTable = KTUtil::getTableName('mimetypes');
         $sQuery = "SELECT id, mimetypes FROM {$sTable} WHERE LOWER(filetypes) = ?";
         $aParams = array($sExtension);
         $aRow = DBUtil::getOneResult(array($sQuery, $aParams));
         if (PEAR::isError($aRow)) {
             $default->log->debug("ODI: error in query: " . print_r($aRow, true));
             return;
         }
         if (empty($aRow)) {
             $default->log->debug("ODI: query returned entry");
             return;
         }
         $id = $aRow['id'];
         $mimetype = $aRow['mimetypes'];
         $default->log->debug("ODI: query returned: " . print_r($aRow, true));
         if (in_array($mimetype, $aTestTypes)) {
             // Haven't changed, really not an OpenDocument file...
             return;
         }
         if ($id) {
             $this->oDocument->setMimeTypeId($id);
             $this->oDocument->update();
         }
     }
     parent::transform();
 }
Ejemplo n.º 3
0
 /**
  * Gets the document path and calls the conversion function
  *
  * @return boolean
  */
 public function processDocument()
 {
     $oStorage = KTStorageManagerUtil::getSingleton();
     $path = $oStorage->temporaryFile($this->document);
     $ext = KTMime::getFileType($this->document->getMimeTypeID());
     if (!file_exists($path)) {
         global $default;
         $default->log->debug('PDF Converter: Document, id: ' . $this->document->iId . ', does not exist at given storage path: ' . $path);
         return sprintf(_kt("The document, id: %s, does not exist at the given storage path: %s"), $this->document->iId, $path);
     }
     // check for OO
     $available = $this->checkOO();
     // do pdf conversion
     if (!$available) {
         global $default;
         $default->log->error("PDF Converter: Cannot connect to Open Office Server on host {$this->ooHost} : {$this->ooPort}");
         return _kt('Cannot connect to Open Office Server.');
     }
     $res = $this->convertFile($path, $ext);
     if ($res !== true) {
         global $default;
         $default->log->debug('PDF Converter: Document, id: ' . $this->document->iId . ', could not be converted to pdf.');
         return sprintf(_kt("The document, id: %s, could not be converted to pdf format. The following error occurred: \"%s\"."), $this->document->iId, $res);
     }
     return true;
 }
Ejemplo n.º 4
0
 function do_main()
 {
     //registerTypes registers the mime types and populates the needed tables.
     $indexer = Indexer::get();
     $indexer->registerTypes();
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplating->addLocation('Extractor Information', '/plugins/search2/reporting/templates');
     $oTemplate =& $oTemplating->loadTemplate('extractorinfo');
     $aExtractorInfo = KTMime::getMimeExtractorInformation();
     if (empty($aExtractorInfo)) {
         $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo));
         return $oTemplate;
     }
     foreach ($aExtractorInfo as $key => $info) {
         $extractorClass = $info['name'];
         $extractor = $indexer->getExtractor($extractorClass);
         $info['mimeTypes'] = array();
         $aMimeTypes = $this->getSupportedMimeTypesDB($extractorClass);
         //$extractor->getSupportedMimeTypes();
         foreach ($aMimeTypes as $mimeType) {
             $sMimeInfo = KTMime::getFriendlyNameAndExtension($mimeType);
             $info['mimeTypes'][$mimeType] = array('description' => $sMimeInfo[0]['friendly_name'], 'extensions' => array($sMimeInfo[0]['filetypes']));
             $extensions = array();
             foreach ($sMimeInfo as $item) {
                 $extensions[] = $item['filetypes'];
             }
             $info['mimeTypes'][$mimeType]['extensions'] = implode(', ', $extensions);
         }
         $aExtractorInfo[$key] = $info;
     }
     $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo));
     return $oTemplate;
 }
Ejemplo n.º 5
0
 /**
  * Gets the document path and calls the conversion function
  *
  * @return boolean
  */
 public function processDocument()
 {
     $oStorage = KTStorageManagerUtil::getSingleton();
     $path = $oStorage->temporaryFile($this->document);
     $ext = KTMime::getFileType($this->document->getMimeTypeID());
     if (!file_exists($path)) {
         global $default;
         $default->log->debug('Document, id: ' . $this->document->iId . ', does not exist at given storage path: ' . $path);
         return false;
     }
     // do pdf conversion
     $res = $this->convertFile($path, $ext);
     if ($res === false) {
         global $default;
         $default->log->debug('Document, id: ' . $this->document->iId . ', could not be converted to pdf.');
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function createDocument($repositoryId, $typeId, $properties, $folderId = null, $contentStream = null, $versioningState = null)
 {
     $objectId = null;
     // fetch type definition of supplied type and check for base type "document", if not true throw exception
     $RepositoryService = new CMISRepositoryService();
     try {
         $typeDefinition = $RepositoryService->getTypeDefinition($repositoryId, $typeId);
     } catch (Exception $e) {
         throw new ConstraintViolationException('Object base type could not be determined. ' . $e->getMessage());
     }
     if ($typeDefinition['attributes']['baseType'] != 'document') {
         throw new ConstraintViolationException('Object is not of base type document');
     }
     // if no $folderId submitted and repository does not support "unfiling" throw exception
     if (empty($folderId)) {
         $repositoryInfo = $RepositoryService->getRepositoryInfo($repositoryId);
         $capabilities = $repositoryInfo->getCapabilities();
         if (!$capabilities->hasCapabilityUnfiling()) {
             throw new ConstraintViolationException('Repository does not support the Unfiling capability and no folder id was supplied');
         }
     }
     // Attempt to decode $folderId, use as is if not detected as encoded
     $tmpObjectId = $folderId;
     $tmpObjectId = CMISUtil::decodeObjectId($tmpObjectId, $tmpTypeId);
     if ($tmpTypeId != 'Unknown') {
         $folderId = $tmpObjectId;
     }
     // if parent folder is not allowed to hold this type, throw exception
     $CMISFolder = new CMISFolderObject($folderId, $this->ktapi);
     $allowed = $CMISFolder->getProperty('AllowedChildObjectTypeIds');
     $typeAllowed = false;
     if (is_array($allowed)) {
         foreach ($allowed as $type) {
             if (strtolower($type) == strtolower($typeId)) {
                 $typeAllowed = true;
                 break;
             }
         }
     }
     if (!$typeAllowed) {
         throw new ConstraintViolationException('Parent folder may not hold objects of this type (' . $typeId . ')');
     }
     // if content stream is required and no content stream is supplied, throw a ConstraintViolationException
     if ($typeDefinition['attributes']['contentStreamAllowed'] == 'required' && is_null($contentStream)) {
         throw new ConstraintViolationException('This repository requires a content stream for document creation.  ' . 'Refusing to create an empty document');
     } else {
         if ($typeDefinition['attributes']['contentStreamAllowed'] == 'notAllowed' && !empty($contentStream)) {
             throw new StreamNotSupportedException('Content Streams are not supported');
         }
     }
     // if versionable attribute is set to false and versioningState is supplied, throw a ConstraintViolationException
     if (!$typeDefinition['attributes']['versionable'] && !empty($versioningState)) {
         throw new ConstraintViolationException('This repository does not support versioning');
     }
     // TODO deal with $versioningState when supplied
     // set title and name identical if only one submitted
     if ($properties['title'] == '') {
         $properties['title'] = $properties['name'];
     } else {
         if ($properties['name'] == '') {
             $properties['name'] = $properties['title'];
         }
     }
     // if name is blank throw exception (check type) - using invalidArgument Exception for now
     if (trim($properties['name']) == '') {
         throw new InvalidArgumentException('Refusing to create an un-named document');
     }
     // TODO also set to Default if a non-supported type is submitted
     if ($properties['type'] == '') {
         $properties['type'] = 'Default';
     }
     // create the content stream from the supplied data
     // NOTE since the repository is set to require a content stream and we don't currently have another way to get the document data
     //      this check isn't strictly necessary;  however it is needed for a repository which does not support content streams
     if (!is_null($contentStream)) {
         $tempfilename = CMISUtil::createTemporaryFile($contentStream);
         // metadata
         $metadata = array();
         $metaFields = array();
         $sysdata = array();
         if (!empty($properties['summary'])) {
             $metadata[] = array('fieldset' => 'Tag Cloud', 'fields' => array(array('name' => 'Tag', 'value' => $properties['summary'])));
         }
         $user = $this->ktapi->get_user();
         if (!PEAR::isError($user)) {
             $metaFields['General Information'][] = array('name' => 'Document Author', 'value' => $user->getName());
         }
         if (!empty($properties['category'])) {
             $category = $properties['category'];
         } else {
             $category = 'Miscellaneous';
         }
         $metaFields['General Information'][] = array('name' => 'Category', 'value' => $category);
         /**
          * Try to determine mime type which maps to one of the following KnowledgetTree document types:
          *
          * Audio
          * Image
          * Text
          * Video
          *
          * example mime types:
          *
          * text/plain
          * image/gif
          * application/x-dosexec
          * application/pdf
          * application/msword
          * audio/mpeg
          * application/octet-stream
          * application/zip
          */
         // TODO check extension for types which are not obvious?  e.g. wmv video returns application/octet-stream
         $mediatype = null;
         include_once KT_LIB_DIR . '/mime.inc.php';
         $KTMime = new KTMime();
         $mimetype = $KTMime->getMimeTypeFromFile($tempfilename);
         preg_match('/^([^\\/]*)\\/([^\\/]*)/', $mimetype, $matches);
         if ($matches[1] == 'text' || $matches[1] == 'image' || $matches[1] == 'audio') {
             $mediatype = ucwords($matches[1]);
         } else {
             if ($matches[2] == 'pdf' || $matches[2] == 'msword') {
                 $mediatype = 'Text';
             }
         }
         if (!is_null($mediatype)) {
             $metaFields['General Information'][] = array('name' => 'Media Type', 'value' => $mediatype);
         }
         if (count($metaFields['General Information']) > 0) {
             foreach ($metaFields['General Information'] as $field) {
                 $fields[] = $field;
             }
             $metadata[] = array('fieldset' => 'General Information', 'fields' => $fields);
         }
         $response = $this->ktapi->add_document_with_metadata((int) $folderId, $properties['title'], $properties['name'], $properties['type'], $tempfilename, $metadata, $sysdata);
         if ($response['status_code'] != 0) {
             throw new StorageException('The repository was unable to create the document.  ' . $response['message']);
         } else {
             $objectId = CMISUtil::encodeObjectId('Document', $response['results']['document_id']);
         }
         // remove temporary file
         @unlink($tempfilename);
     } else {
         // TODO creation of document without content.  leaving this for now as we require content streams and any code
         //      here will therefore never be executed; if we implement some form of template based document creation
         //      then we may have something else to do here;
         //      for now we just throw a general RuntimeException, since we should not
         //      actually reach this code unless something is wrong; this may be removed or replaced later
         throw new RuntimeException('Cannot create document without a content stream');
     }
     return $objectId;
 }
Ejemplo n.º 7
0
 /**
  * This returns detailed information on the document.
  *
  * @author KnowledgeTree Team
  * @access public
  * @return array The document information
  */
 function get_detail()
 {
     global $default;
     // make sure we ge tthe latest
     $this->clearCache();
     $config = KTConfig::getSingleton();
     $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
     $detail = array();
     $document = $this->document;
     // get the document id
     $detail['document_id'] = (int) $document->getId();
     $oem_document_no = null;
     if ($wsversion >= 2) {
         $oem_document_no = $document->getOemNo();
     }
     if (empty($oem_document_no)) {
         $oem_document_no = 'n/a';
     }
     $detail['custom_document_no'] = 'n/a';
     $detail['oem_document_no'] = $oem_document_no;
     // get the title
     $detail['title'] = $document->getName();
     // get the document type
     $documenttypeid = $document->getDocumentTypeID();
     $documenttype = '* unknown *';
     if (is_numeric($documenttypeid)) {
         $dt = DocumentType::get($documenttypeid);
         if (!is_null($dt) && !PEAR::isError($dt)) {
             $documenttype = $dt->getName();
         }
     }
     $detail['document_type'] = $documenttype;
     // get the filename
     $detail['filename'] = $document->getFilename();
     // get the filesize
     $detail['filesize'] = (int) $document->getFileSize();
     // get the folder id
     $detail['folder_id'] = (int) $document->getFolderID();
     // get the creator
     $userid = $document->getCreatorID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['created_by'] = $username;
     // get the creation date
     $detail['created_date'] = $document->getCreatedDateTime();
     // get the checked out user
     $userid = $document->getCheckedOutUserID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['checked_out_by'] = $username;
     // get the checked out date
     list($major, $minor, $fix) = explode('.', $default->systemVersion);
     if ($major == 3 && $minor >= 5) {
         $detail['checked_out_date'] = $document->getCheckedOutDate();
     } else {
         $detail['checked_out_date'] = $detail['modified_date'];
     }
     if (is_null($detail['checked_out_date'])) {
         $detail['checked_out_date'] = 'n/a';
     }
     // get the modified user
     $userid = $document->getModifiedUserId();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['modified_by'] = $detail['updated_by'] = $username;
     // get the modified date
     $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate();
     // get the owner
     $userid = $document->getOwnerID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['owned_by'] = $username;
     // get the version
     $detail['version'] = $document->getVersion();
     if ($wsversion >= 2) {
         $detail['version'] = (double) $detail['version'];
     }
     //might be unset at the bottom in case of old webservice version
     //make sure we're using the real document for this one
     $this->document->switchToRealCore();
     $detail['linked_document_id'] = $document->getLinkedDocumentId();
     $this->document->switchToLinkedCore();
     // check immutability
     $detail['is_immutable'] = (bool) $document->getImmutable();
     // check permissions
     $detail['permissions'] = KTAPI_Document::get_permission_string($document);
     // get workflow name
     $workflowid = $document->getWorkflowId();
     $workflowname = 'n/a';
     if (is_numeric($workflowid)) {
         $workflow = KTWorkflow::get($workflowid);
         if (!is_null($workflow) && !PEAR::isError($workflow)) {
             $workflowname = $workflow->getName();
         }
     }
     $detail['workflow'] = $workflowname;
     // get the workflow state
     $stateid = $document->getWorkflowStateId();
     $workflowstate = 'n/a';
     if (is_numeric($stateid)) {
         $state = KTWorkflowState::get($stateid);
         if (!is_null($state) && !PEAR::isError($state)) {
             $workflowstate = $state->getName();
         }
     }
     $detail['workflow_state'] = $workflowstate;
     // get the full path
     $detail['full_path'] = '/' . $this->document->getFullPath();
     // get mime info
     $mimetypeid = $document->getMimeTypeID();
     $detail['mime_type'] = KTMime::getMimeTypeName($mimetypeid);
     $detail['mime_icon_path'] = KTMime::getIconPath($mimetypeid);
     $detail['mime_display'] = KTMime::getFriendlyNameForString($detail['mime_type']);
     // get the storage path
     $detail['storage_path'] = $document->getStoragePath();
     if ($wsversion >= 2) {
         unset($detail['updated_by']);
         unset($detail['updated_date']);
     }
     if ($wsversion < 3) {
         unset($detail['linked_document_id']);
     }
     return $detail;
 }
Ejemplo n.º 8
0
    /**
     * Method to get any documents added by the user via the Drop Box.
     * Returns the HTML displaying the document list.
     *
     * @param string $sUserName
     * @param numeric $iDropDocsFolderID
     * @return string HTML - the document list on success or an error message on failure
     */
    function getUsersDocument($sUserName, $iDropDocsFolderID)
    {
        $oUser = $this->oUser;
        $oDropDocsFolder = Folder::get($iDropDocsFolderID);
        $fullPath = $oDropDocsFolder->getFullPath() . '/' . $sUserName;
        $aExternalWhereClauses[] = '(DT.transaction_namespace IN (?,?,?) AND (D.full_path LIKE "' . $fullPath . '/%"))';
        $aExternalWhereParams[] = 'ktcore.transactions.create';
        $aExternalWhereParams[] = 'ktcore.transactions.check_in';
        $aExternalWhereParams[] = 'ktcore.transactions.event';
        $aDocumentTransactions = $this->getTransactionsMatchingQuery($oUser, '', $aExternalWhereClauses, $aExternalWhereParams);
        if (empty($aDocumentTransactions) || PEAR::isError($aDocumentTransactions)) {
            if (PEAR::isError($aDocumentTransactions)) {
                global $default;
                $default->log->debug('Error retrieving dropped documents - ' . $aDocumentTransactions->getMessage());
            }
            return _kt('<span class="descriptiveText"> You do not have any dropped documents </span><br><br><br>');
        }
        $maxcount = 5;
        $sReturnTable = '<span class="descriptiveText">' . _kt('Recently Dropped Documents') . '</span>
       				<table width="100%" class="kt_collection drop_box" cellspacing="0">

					<thead>
    				<tr>
        			<th width="100%">' . _kt('Document') . '</th>
        			<th width="1%">' . _kt('Date Dropped') . '</th>
        			</tr>
					</thead>
					<tbody>';
        $sOddorEven = '';
        $count = 1;
        $rendered = array();
        foreach ($aDocumentTransactions as $aRow) {
            $documentId = $aRow['document_id'];
            if (in_array($documentId, $rendered)) {
                continue;
            }
            $rendered[] = $documentId;
            $oDocument = Document::get($documentId);
            $sContentType = KTMime::getIconPath($oDocument->getMimeTypeID());
            $aAnchorData = $this->getDocInfo($documentId);
            $sLink = $aAnchorData[0];
            $sShortDocName = $sDocName = $aAnchorData[1];
            $iDocLength = strlen($sDocName);
            $iMax = 40;
            if ($iDocLength > $iMax) {
                $sShortDocName = substr($sDocName, 0, $iMax) . '...';
            }
            $sOddorEven = $count % 2 == 0 ? 'even' : 'odd';
            $sReturnTable .= '<tr class="' . $sOddorEven . '">' . '<td width="100%"><span class="contenttype ' . $sContentType . '"><a title="' . $sDocName . '" href=' . $sLink . '>' . $sShortDocName . '</a></span></td>' . '<td width="1%">' . $aRow['datetime'] . '</td>' . '</tr>';
            if (++$count > 5) {
                break;
            }
        }
        $location = 'browse.php?fFolderId=' . $iMyDocsFolderID;
        $sReturnTable .= '</tbody>' . '</table>' . '<br>' . '<a href="' . $location . '">' . _kt(' View All') . ' </a><br><br>';
        //$this->session->logout();
        return $sReturnTable;
    }
Ejemplo n.º 9
0
 function transform()
 {
     $iMimeTypeId = $this->oDocument->getMimeTypeId();
     $sMimeType = KTMime::getMimeTypeName($iMimeTypeId);
     if (!array_key_exists($sMimeType, $this->mimetypes)) {
         return;
     }
     $oStorage = KTStorageManagerUtil::getSingleton();
     $sFile = $oStorage->temporaryFile($this->oDocument);
     $tempstub = 'transform';
     if ($this->command != null) {
         $tempstub = $this->command;
     }
     $oKTConfig =& KTConfig::getSingleton();
     $sBasedir = $oKTConfig->get("urls/tmpDirectory");
     $myfilename = tempnam($sBasedir, 'kt.' . $tempstub);
     if (OS_WINDOWS) {
         $intermediate = tempnam($sBasedir, 'kt.' . $tempstub);
         if (!@copy($sFile, $intermediate)) {
             return;
         }
     } else {
         $intermediate = $sFile;
     }
     $contents = $this->extract_contents($intermediate, $myfilename);
     @unlink($myfilename);
     if (OS_WINDOWS) {
         @unlink($intermediate);
     }
     if (empty($contents)) {
         return;
     }
     $aInsertValues = array('document_id' => $this->oDocument->getId(), 'document_text' => $contents);
     $sTable = KTUtil::getTableName('document_text');
     // clean up the document query "stuff".
     // FIXME this suggests that we should move the _old_ document_searchable_text across to the old-document's id if its a checkin.
     DBUtil::runQuery(array('DELETE FROM ' . $sTable . ' WHERE document_id = ?', array($this->oDocument->getId())));
     DBUtil::autoInsert($sTable, $aInsertValues, array('noid' => true));
 }
Ejemplo n.º 10
0
 public static function getDocumentContent($oDocument)
 {
     global $default;
     //get the path to the document on the server
     //$docRoot = $default->documentRoot;
     $oConfig =& KTConfig::getSingleton();
     $docRoot = $oConfig->get('urls/documentRoot');
     $path = $docRoot . '/' . $oDocument->getStoragePath();
     // Ensure the file exists
     if (file_exists($path)) {
         // Get the mime type - this is not relevant at the moment...
         $mimeId = $oDocument->getMimeTypeID();
         $mimetype = KTMime::getMimeTypeName($mimeId);
         if ($bIsCheckout && $default->fakeMimetype) {
             // note this does not work for "image" types in some browsers
             $mimetype = 'application/x-download';
         }
         $sFileName = $oDocument->getFileName();
         $iFileSize = $oDocument->getFileSize();
     } else {
         return null;
     }
     $content = file_get_contents($path);
     return $content;
 }
Ejemplo n.º 11
0
 function getMimeTypeInfo($iUserId, $iDocumentId)
 {
     global $default;
     $mimeinfo['typeId'] = KTrss::getDocumentMimeTypeId($iUserId, $iDocumentId);
     // mime type id
     $mimeinfo['typeName'] = KTMime::getMimeTypeName($mimeinfo['typeId']);
     // mime type name
     $mimeinfo['typeFName'] = KTMime::getFriendlyNameForString($mimeinfo['typeName']);
     // mime type friendly name
     $mimeinfo['typeIcon'] = "http" . ($default->sslEnabled ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . "/" . $GLOBALS['KTRootUrl'] . "/resources/mimetypes/" . KTMime::getIconPath($mimeinfo['typeId']) . ".png";
     //icon path
     return $mimeinfo;
 }
Ejemplo n.º 12
0
 function getIconPath($iMimeTypeId, $type = null)
 {
     $icon = KTUtil::arrayGet($GLOBALS['_KT_icon_path_cache'], $iMimeTypeId);
     if (empty($icon)) {
         $GLOBALS['_KT_icon_path_cache'][$iMimeTypeId] = KTMime::_getIconPath($iMimeTypeId);
         $icon = $GLOBALS['_KT_icon_path_cache'][$iMimeTypeId];
     }
     if (!empty($type)) {
         $icon .= '_' . $type;
     }
     return $icon;
 }
Ejemplo n.º 13
0
 /**
  * Generates the thumbnail from the pdf
  *
  * @return boolean
  */
 private function generateThumbnail()
 {
     /*
        The thumbnail is displayed in the info panel and the document view
        The info panel is in the plugin ktcore/documentpreview/
            - add a hook in there but build the functionality in this plugin ie keep the plugins separate and don't create dependencies
            - if the thumbnail plugin is disabled then maybe display a normal sized info panel
     
                The document view will display the thumbnail on the right in a document viewlet similar to the workflow viewlet
                    - check out ktcore/KTDocumentViewlets.php
                    - viewlet class is below
     */
     global $default;
     $mimeTypeId = $this->document->getMimeTypeID();
     $mimeType = KTMime::getMimeTypeName($mimeTypeId);
     // Get the pdf source file - if the document is a pdf then use the document as the source
     if ($mimeType == 'application/pdf') {
         $pdfDir = $default->documentRoot;
         $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->getStoragePath();
     } else {
         $pdfDir = $default->pdfDirectory;
         $pdfFile = $pdfDir . DIRECTORY_SEPARATOR . $this->document->iId . '.pdf';
     }
     $thumbnaildir = $default->varDirectory . DIRECTORY_SEPARATOR . 'thumbnails';
     if (stristr(PHP_OS, 'WIN')) {
         $thumbnaildir = str_replace('/', '\\', $thumbnaildir);
         $pdfFile = str_replace('/', '\\', $pdfFile);
     }
     $thumbnailfile = $thumbnaildir . DIRECTORY_SEPARATOR . $this->document->iId . '.jpg';
     //if thumbail dir does not exist, generate one and add an index file to block access
     if (!file_exists($thumbnaildir)) {
         mkdir($thumbnaildir, 0755);
         touch($thumbnaildir . DIRECTORY_SEPARATOR . 'index.html');
         file_put_contents($thumbnaildir . DIRECTORY_SEPARATOR . 'index.html', 'You do not have permission to access this directory.');
     }
     // if there is no pdf that exists - hop out
     if (!file_exists($pdfFile)) {
         $default->log->debug('Thumbnail Generator Plugin: PDF file does not exist, cannot generate a thumbnail');
         return false;
     }
     // if a previous version of the thumbnail exists - delete it
     if (file_exists($thumbnailfile)) {
         @unlink($thumbnailfile);
     }
     // do generation
     $pathConvert = !empty($default->convertPath) ? $default->convertPath : 'convert';
     // windows path may contain spaces
     if (stristr(PHP_OS, 'WIN')) {
         $cmd = "\"{$pathConvert}\" \"{$pdfFile}[0]\" -resize 200x200 \"{$thumbnailfile}\"";
     } else {
         $cmd = "{$pathConvert} {$pdfFile}[0] -resize 200x200 {$thumbnailfile}";
     }
     $result = KTUtil::pexec($cmd);
     return true;
 }
Ejemplo n.º 14
0
 function _mimeHelper($iMimeTypeId)
 {
     require_once KT_LIB_DIR . '/mime.inc.php';
     return KTMime::getIconPath($iMimeTypeId);
 }
Ejemplo n.º 15
0
 function rename($oDocument, $sNewFilename, $oUser)
 {
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $oKTConfig = KTConfig::getSingleton();
     $updateVersion = $oKTConfig->get('tweaks/incrementVersionOnRename', true);
     $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
     $oOldContentVersion = $oDocument->_oDocumentContentVersion;
     if ($updateVersion) {
         $bSuccess = $oDocument->startNewContentVersion($oUser);
         if (PEAR::isError($bSuccess)) {
             return $bSuccess;
         }
         KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
     }
     $res = $oStorage->renameDocument($oDocument, $oOldContentVersion, $sNewFilename);
     if (!$res) {
         return PEAR::raiseError(_kt('An error occurred while storing the new file'));
     }
     $oDocument->setLastModifiedDate(getCurrentDateTime());
     $oDocument->setModifiedUserId($oUser->getId());
     if ($updateVersion) {
         // Update version number
         $oDocument->setMinorVersionNumber($oDocument->getMinorVersionNumber() + 1);
     }
     $oDocument->_oDocumentContentVersion->setFilename($sNewFilename);
     $sType = KTMime::getMimeTypeFromFile($sNewFilename);
     $iMimeTypeId = KTMime::getMimeTypeID($sType, $sNewFilename);
     $oDocument->setMimeTypeId($iMimeTypeId);
     $bSuccess = $oDocument->update();
     if ($bSuccess !== true) {
         if (PEAR::isError($bSuccess)) {
             return $bSuccess;
         }
         return PEAR::raiseError(_kt('An error occurred while storing this document in the database'));
     }
     // create the document transaction record
     $oDocumentTransaction = new DocumentTransaction($oDocument, _kt('Document renamed'), 'ktcore.transactions.update');
     $oDocumentTransaction->create();
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('renameDocument', 'postValidate');
     foreach ($aTriggers as $aTrigger) {
         $sTrigger = $aTrigger[0];
         $oTrigger = new $sTrigger();
         $aInfo = array('document' => $oDocument);
         $oTrigger->setInfo($aInfo);
         $ret = $oTrigger->postValidate();
         if (PEAR::isError($ret)) {
             return $ret;
         }
     }
     // fire subscription alerts for the checked in document
     $oSubscriptionEvent = new SubscriptionEvent();
     $oFolder = Folder::get($oDocument->getFolderID());
     $oSubscriptionEvent->ModifyDocument($oDocument, $oFolder);
     return true;
 }
Ejemplo n.º 16
0
 /**
  * Method for getting the MIME type extension for the current document.
  *
  * @return string mime time extension
  */
 function getMimeExtension()
 {
     if ($this->oDocument == null || $this->oDocument == "" || PEAR::isError($this->oDocument)) {
         return _kt('Unknown Type');
     }
     $oDocument = $this->oDocument;
     $iMimeTypeId = $oDocument->getMimeTypeID();
     $mimetypename = KTMime::getMimeTypeName($iMimeTypeId);
     // mime type name
     // the pdf converter uses the mime type and not the extension.
     return $mimetypename;
     /*
     $sTable = KTUtil::getTableName('mimetypes');
     $sQuery = "SELECT filetypes FROM " . $sTable . " WHERE mimetypes = ?";
     $aQuery = array($sQuery, array($mimetypename));
     $res = DBUtil::getResultArray($aQuery);
     if (PEAR::isError($res)) {
         return $res;
     } else if (count($res) != 0){
         return $res[0]['filetypes'];
     }
     
     return _kt('Unknown Type');
     */
 }
Ejemplo n.º 17
0
 /**
  * Create a table of the document metadata.
  * Hard coded for the moment
  *
  * @return unknown
  */
 function getMetadata()
 {
     /* Get document info */
     // Filename
     $sFilenameLb = _kt('Document Filename: ');
     $sFilename = $this->_oDocument->getFileName();
     // Mime type
     $sMimeTypeLb = _kt('File is a: ');
     $iMimeId = $this->_oDocument->getMimeTypeID();
     $sMimeType = KTMime::getMimeTypeName($iMimeId);
     $sMimeType = KTMime::getFriendlyNameForString($sMimeType);
     // Version
     $sVersionLb = _kt('Document Version: ');
     $iVersion = $this->_oDocument->getVersion();
     // Created by
     $sCreatedByLb = _kt('Created by: ');
     $iCreatorId = $this->_oDocument->getCreatorID();
     $sCreated = $this->_oDocument->getCreatedDateTime();
     $oCreator = User::get($iCreatorId);
     $sCreatedBy = $oCreator->getName() . ' (' . $sCreated . ')';
     // Owned by
     $sOwnedByLb = _kt('Owned by: ');
     $iOwnedId = $this->_oDocument->getOwnerID();
     $oOwner = User::get($iOwnedId);
     $sOwnedBy = $oOwner->getName();
     // Last update by
     $iModifiedId = $this->_oDocument->getModifiedUserId();
     $sLastUpdatedByLb = '';
     $sLastUpdatedBy = '';
     if (!empty($iModifiedId)) {
         $sLastUpdatedByLb = _kt('Last updated by: ');
         $sModified = $this->_oDocument->getLastModifiedDate();
         $oModifier = User::get($iModifiedId);
         $sLastUpdatedBy = $oModifier->getName() . ' (' . $sModified . ')';
     }
     // Document type
     $sDocTypeLb = _kt('Document Type: ');
     $iDocTypeId = $this->_oDocument->getDocumentTypeID();
     $oDocType = DocumentType::get($iDocTypeId);
     $sDocType = $oDocType->getName();
     // Workflow
     $iWFId = $this->_oDocument->getWorkflowId();
     $sWF = '';
     $sWFLb = '';
     if (!empty($iWFId)) {
         $sWFLb = _kt('Workflow: ');
         $iWFStateId = $this->_oDocument->getWorkflowStateId();
         $oWF = KTWorkflow::get($iWFId);
         $sWF = $oWF->getHumanName();
         $oWFState = KTWorkflowState::get($iWFStateId);
         $sWF .= ' (' . $oWFState->getHumanName() . ')';
     }
     // Checked out by
     $sCheckedLb = '';
     $sCheckedOutBy = '';
     if ($this->_oDocument->getIsCheckedOut()) {
         $sCheckedLb = _kt('Checked out by: ');
         $iCheckedID = $this->_oDocument->getCheckedOutUserID();
         $oCheckedUser = User::get($iCheckedID);
         $sCheckedOutBy = $oCheckedUser->getName();
     }
     // Id
     $sIdLb = _kt('Document ID: ');
     $sId = $this->_IDocId;
     /* Create table */
     $sInfo = "<div style='float:left; width:405px;'>\n            <table cellspacing='3px' cellpadding='3px' width='405px'>\n            <tr><td>{$sFilenameLb}</td><td><b>{$sFilename}</b></td></tr>\n            <tr><td>{$sMimeTypeLb}</td><td><b>{$sMimeType}</b></td></tr>\n            <tr><td>{$sVersionLb}</td><td><b>{$iVersion}</b></td></tr>\n            <tr><td>{$sCreatedByLb}</td><td><b>{$sCreatedBy}</b></td></tr>\n            <tr><td>{$sOwnedByLb}</td><td><b>{$sOwnedBy}</b></td></tr>";
     if (!empty($sLastUpdatedBy)) {
         $sInfo .= "<tr><td>{$sLastUpdatedByLb}</td><td><b>{$sLastUpdatedBy}</b></td></tr>";
     }
     $sInfo .= "<tr><td>{$sDocTypeLb}</td><td><b>{$sDocType}</b></td></tr>";
     if (!empty($sWF)) {
         $sInfo .= "<tr><td>{$sWFLb}</td><td><b>{$sWF}</b></td></tr>";
     }
     if (!empty($sCheckedOutBy)) {
         $sInfo .= "<tr><td>{$sCheckedLb}</td><td><b>{$sCheckedOutBy}</b></td></tr>";
     }
     $sInfo .= "<tr><td>{$sIdLb}</td><td><b>{$sId}</b></td></tr>";
     $sInfo .= " </table></div>";
     return $sInfo;
 }
Ejemplo n.º 18
0
 /**
  * Get's a folder listing, recursing to the maximum depth.
  * Derived from the get_listing function.
  *
  * <code>
  * $root = $this->ktapi->get_root_folder();
  * $listing = $root->get_full_listing();
  * foreach($listing as $val) {
  * 	if($val['item_type'] == 'F') {
  *   // It's a folder
  *   echo $val['title'];
  *  }
  * }
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $what
  * @return array
  */
 function get_full_listing($what = 'DFS')
 {
     $what = strtoupper($what);
     $read_permission =& KTPermission::getByName(KTAPI_PERMISSION_READ);
     $folder_permission =& KTPermission::getByName(KTAPI_PERMISSION_VIEW_FOLDER);
     $config = KTConfig::getSingleton();
     $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
     $user = $this->ktapi->get_user();
     $contents = array();
     if (strpos($what, 'F') !== false) {
         $folder_children = Folder::getList(array('parent_id = ?', $this->folderid));
         foreach ($folder_children as $folder) {
             if (KTPermissionUtil::userHasPermissionOnItem($user, $folder_permission, $folder) || KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $folder)) {
                 $sub_folder =& $this->ktapi->get_folder_by_id($folder->getId());
                 if (!PEAR::isError($sub_folder)) {
                     $items = $sub_folder->get_full_listing($what);
                 } else {
                     $items = array();
                 }
                 $creator = $this->_resolve_user($folder->getCreatorID());
                 if ($wsversion >= 2) {
                     $array = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'custom_document_no' => 'n/a', 'oem_document_no' => 'n/a', 'title' => $folder->getName(), 'document_type' => 'n/a', 'filename' => $folder->getName(), 'filesize' => 'n/a', 'created_by' => is_null($creator) ? 'n/a' : $creator->getName(), 'created_date' => 'n/a', 'checked_out_by' => 'n/a', 'checked_out_date' => 'n/a', 'modified_by' => 'n/a', 'modified_date' => 'n/a', 'owned_by' => 'n/a', 'version' => 'n/a', 'is_immutable' => 'n/a', 'permissions' => KTAPI_Folder::get_permission_string($folder), 'workflow' => 'n/a', 'workflow_state' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'storage_path' => 'n/a');
                     if ($wsversion >= 3) {
                         $array['linked_folder_id'] = $folder->getLinkedFolderId();
                         if ($folder->isSymbolicLink()) {
                             $array['item_type'] = "S";
                         }
                     }
                     $array['items'] = $items;
                     if ($wsversion < 3 || strpos($what, 'F') !== false && !$folder->isSymbolicLink() || $folder->isSymbolicLink() && strpos($what, 'S') !== false) {
                         $contents[] = $array;
                     }
                 } else {
                     $contents[] = array('id' => (int) $folder->getId(), 'item_type' => 'F', 'title' => $folder->getName(), 'creator' => is_null($creator) ? 'n/a' : $creator->getName(), 'checkedoutby' => 'n/a', 'modifiedby' => 'n/a', 'filename' => $folder->getName(), 'size' => 'n/a', 'major_version' => 'n/a', 'minor_version' => 'n/a', 'storage_path' => 'n/a', 'mime_type' => 'folder', 'mime_icon_path' => 'folder', 'mime_display' => 'Folder', 'items' => $items, 'workflow' => 'n/a', 'workflow_state' => 'n/a');
                 }
             }
         }
     }
     if (strpos($what, 'D') !== false) {
         $document_children = Document::getList(array('folder_id = ? AND status_id = 1', $this->folderid));
         // I hate that KT doesn't cache things nicely...
         $mime_cache = array();
         foreach ($document_children as $document) {
             if (KTPermissionUtil::userHasPermissionOnItem($user, $read_permission, $document)) {
                 $created_by = $this->_resolve_user($document->getCreatorID());
                 $created_date = $document->getCreatedDateTime();
                 if (empty($created_date)) {
                     $created_date = 'n/a';
                 }
                 $checked_out_by = $this->_resolve_user($document->getCheckedOutUserID());
                 $checked_out_date = $document->getCheckedOutDate();
                 if (empty($checked_out_date)) {
                     $checked_out_date = 'n/a';
                 }
                 $modified_by = $this->_resolve_user($document->getCreatorID());
                 $modified_date = $document->getLastModifiedDate();
                 if (empty($modified_date)) {
                     $modified_date = 'n/a';
                 }
                 $owned_by = $this->_resolve_user($document->getOwnerID());
                 $mimetypeid = $document->getMimeTypeID();
                 if (!array_key_exists($mimetypeid, $mime_cache)) {
                     $type = KTMime::getMimeTypeName($mimetypeid);
                     $icon = KTMime::getIconPath($mimetypeid);
                     $display = KTMime::getFriendlyNameForString($type);
                     $mime_cache[$mimetypeid] = array('type' => $type, 'icon' => $icon, 'display' => $display);
                 }
                 $mimeinfo = $mime_cache[$mimetypeid];
                 $workflow = 'n/a';
                 $state = 'n/a';
                 $wf = KTWorkflowUtil::getWorkflowForDocument($document);
                 if (!is_null($wf) && !PEAR::isError($wf)) {
                     $workflow = $wf->getHumanName();
                     $ws = KTWorkflowUtil::getWorkflowStateForDocument($document);
                     if (!is_null($ws) && !PEAR::isError($ws)) {
                         $state = $ws->getHumanName();
                     }
                 }
                 if ($wsversion >= 2) {
                     $docTypeId = $document->getDocumentTypeID();
                     $documentType = DocumentType::get($docTypeId);
                     $oemDocumentNo = $document->getOemNo();
                     if (empty($oemDocumentNo)) {
                         $oemDocumentNo = 'n/a';
                     }
                     $array = array('id' => (int) $document->getId(), 'item_type' => 'D', 'custom_document_no' => 'n/a', 'oem_document_no' => $oemDocumentNo, 'title' => $document->getName(), 'document_type' => $documentType->getName(), 'filename' => $document->getFileName(), 'filesize' => $document->getFileSize(), 'created_by' => is_null($created_by) ? 'n/a' : $created_by->getName(), 'created_date' => $created_date, 'checked_out_by' => is_null($checked_out_by) ? 'n/a' : $checked_out_by->getName(), 'checked_out_date' => $checked_out_date, 'modified_by' => is_null($modified_by) ? 'n/a' : $modified_by->getName(), 'modified_date' => $modified_date, 'owned_by' => is_null($owned_by) ? 'n/a' : $owned_by->getName(), 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(), 'content_id' => $document->getContentVersionId(), 'is_immutable' => $document->getImmutable() ? 'true' : 'false', 'permissions' => KTAPI_Document::get_permission_string($document), 'workflow' => $workflow, 'workflow_state' => $state, 'mime_type' => $mime_cache[$mimetypeid]['type'], 'mime_icon_path' => $mime_cache[$mimetypeid]['icon'], 'mime_display' => $mime_cache[$mimetypeid]['display'], 'storage_path' => $document->getStoragePath());
                     if ($wsversion >= 3) {
                         $document->switchToRealCore();
                         $array['linked_document_id'] = $document->getLinkedDocumentId();
                         $document->switchToLinkedCore();
                         if ($document->isSymbolicLink()) {
                             $array['item_type'] = "S";
                         }
                     }
                     $array['items'] = array();
                     if ($wsversion < 3 || strpos($what, 'D') !== false && !$document->isSymbolicLink() || $document->isSymbolicLink() && strpos($what, 'S') !== false) {
                         $contents[] = $array;
                     }
                 } else {
                     $contents[] = array('id' => (int) $document->getId(), 'item_type' => 'D', 'title' => $document->getName(), 'creator' => is_null($created_by) ? 'n/a' : $created_by->getName(), 'checkedoutby' => is_null($checked_out_by) ? 'n/a' : $checked_out_by->getName(), 'modifiedby' => is_null($modified_by) ? 'n/a' : $modified_by->getName(), 'filename' => $document->getFileName(), 'size' => $document->getFileSize(), 'major_version' => $document->getMajorVersionNumber(), 'minor_version' => $document->getMinorVersionNumber(), 'storage_path' => $document->getStoragePath(), 'mime_type' => $mime_cache[$mimetypeid]['type'], 'mime_icon_path' => $mime_cache[$mimetypeid]['icon'], 'mime_display' => $mime_cache[$mimetypeid]['display'], 'items' => array(), 'workflow' => $workflow, 'workflow_state' => $state);
                 }
             }
         }
     }
     return $contents;
 }
Ejemplo n.º 19
0
 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator($oUser)) {
         return false;
     }
     require_once KT_LIB_DIR . '/triggers/triggerregistry.inc.php';
     $noTransforms = false;
     $oKTTriggerRegistry = KTTriggerRegistry::getSingleton();
     $aTriggers = $oKTTriggerRegistry->getTriggers('content', 'transform');
     $aTriggerSet = array();
     if (empty($aTriggers)) {
         $noTransforms = true;
     } else {
         foreach ($aTriggers as $aTrigger) {
             $sTrigger = $aTrigger[0];
             if ($aTrigger[1]) {
                 require_once $aTrigger[1];
             }
             $oTrigger = new $sTrigger();
             $sDiagnostic = $oTrigger->getDiagnostic();
             // empty is OK.
             if (is_null($sDiagnostic) || $sDiagnostic == false) {
                 continue;
             }
             $aTypes = (array) $oTrigger->mimetypes;
             $aTypesStr = array();
             foreach ($aTypes as $sTypeName => $v) {
                 //if ($sTypeName != 'application/octet-stream') { // never use application/octet-stream
                 $aTypesStr[KTMime::getFriendlyNameForString($sTypeName)] = 1;
                 //}
             }
             $aTriggerSet[] = array('types' => $aTypesStr, 'diagnostic' => $sDiagnostic);
         }
     }
     $this->aTriggerSet = $aTriggerSet;
     $this->noTransforms = $noTransforms;
     return $noTransforms || !empty($aTriggerSet);
     // no diags and have some transforms.
 }
Ejemplo n.º 20
0
 /**
  * GET method helper
  *
  * @param  array  parameter passing array
  * @param  int  Document ID
  * @return bool   true on success
  */
 function _GETDocument(&$options, $iDocumentID)
 {
     global $default;
     $oDocument =& Document::get($iDocumentID);
     // get a temp file, and read.  NOTE: NEVER WRITE TO THIS
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $fspath = $oStorage->temporaryFile($oDocument);
     $this->ktwebdavLog("Filesystem Path is " . $fspath, 'info', true);
     // detect resource type
     $mimetype = KTMime::getMimeTypeName($oDocument->getMimeTypeID());
     $options['mimetype'] = KTMime::getFriendlyNameForString($mimetype);
     // detect modification time
     // see rfc2518, section 13.7
     // some clients seem to treat this as a reverse rule
     // requiering a Last-Modified header if the getlastmodified header was set
     $options['mtime'] = $oDocument->getVersionCreated();
     // detect resource size
     $options['size'] = $oDocument->getFileSize();
     // no need to check result here, it is handled by the base class
     $options['stream'] = fopen($fspath, "r");
     $this->ktwebdavLog("Method is " . $this->currentMethod, 'info', true);
     if ($this->currentMethod == "get") {
         // create the document transaction record
         include_once KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc';
         $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document viewed via KTWebDAV", 'ktcore.transactions.view');
         $oDocumentTransaction->iUserID = $this->userID;
         $oDocumentTransaction->create();
     }
     return true;
 }
 function downloadVersion($oDocument, $iVersionId)
 {
     //get the document
     $oContentVersion = KTDocumentContentVersion::get($iVersionId);
     $oConfig =& KTConfig::getSingleton();
     $sPath = sprintf("%s/%s", $oConfig->get('urls/documentRoot'), $this->getPath($oContentVersion));
     $sVersion = sprintf("%d.%d", $oContentVersion->getMajorVersionNumber(), $oContentVersion->getMinorVersionNumber());
     $mimeType = KTMime::getMimeTypeName($oContentVersion->getMimeTypeID());
     $fileSize = $oContentVersion->getFileSize();
     $fileName = $sVersion . '-' . $oContentVersion->getFileName();
     return KTUtil::download($sPath, $mimeType, $fileSize, $fileName);
 }