当前位置: 首页>>代码示例>>PHP>>正文


PHP DocumentType::get方法代码示例

本文整理汇总了PHP中DocumentType::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentType::get方法的具体用法?PHP DocumentType::get怎么用?PHP DocumentType::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentType的用法示例。


在下文中一共展示了DocumentType::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check

 function check()
 {
     $this->browse_mode = KTUtil::arrayGet($_REQUEST, 'fBrowseMode', 'folder');
     $action = KTUtil::arrayGet($_REQUEST, $this->event_var, 'main');
     $this->editable = false;
     // catch the alternative actions.
     if ($action != 'main') {
         return true;
     }
     // if we're going to main ...
     // folder browse mode
     if ($this->browse_mode == 'folder') {
         $in_folder_id = KTUtil::arrayGet($_REQUEST, 'fFolderId');
         if (empty($in_folder_id)) {
             $oConfig = KTConfig::getSingleton();
             if ($oConfig->get('tweaks/browseToUnitFolder')) {
                 $iHomeFolderId = $this->oUser->getHomeFolderId();
                 if ($iHomeFolderId) {
                     $in_folder_id = $iHomeFolderId;
                 }
             }
         }
         $folder_id = (int) $in_folder_id;
         // conveniently, will be 0 if not possible.
         if ($folder_id == 0) {
             $folder_id = 1;
         }
         $_REQUEST['fBrowseMode'] = 'folder';
         // here we need the folder object to do the breadcrumbs.
         $oFolder =& Folder::get($folder_id);
         if (PEAR::isError($oFolder)) {
             return false;
             // just fail.
         }
         // check whether the user can edit this folder
         $oPerm = KTPermission::getByName('ktcore.permissions.write');
         if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oFolder)) {
             $this->editable = true;
         } else {
             $this->editable = false;
         }
         // set the title and breadcrumbs...
         $this->oPage->setTitle(_kt('Browse'));
         if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $oFolder)) {
             $this->oPage->setSecondaryTitle($oFolder->getName());
         } else {
             if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
                 $this->oPage->setSecondaryTitle(sprintf('(%s)', $oFolder->getName()));
             } else {
                 $this->oPage->setSecondaryTitle('...');
             }
         }
         //Figure out if we came here by navigating trough a shortcut.
         //If we came here from a shortcut, the breadcrumbspath should be relative
         //to the shortcut folder.
         $iSymLinkFolderId = KTUtil::arrayGet($_REQUEST, 'fShortcutFolder', null);
         if (is_numeric($iSymLinkFolderId)) {
             $oBreadcrumbsFolder = Folder::get($iSymLinkFolderId);
             $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oBreadcrumbsFolder, array('final' => false)));
             $this->aBreadcrumbs[] = array('name' => $oFolder->getName());
         } else {
             $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oFolder));
         }
         $this->oFolder =& $oFolder;
         // we now have a folder, and need to create the query.
         $aOptions = array('ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder));
         $this->oQuery = new BrowseQuery($oFolder->getId(), $this->oUser, $aOptions);
         $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $oFolder->getId()));
         // and the portlets
         $portlet = new KTActionPortlet(sprintf(_kt('About this folder')));
         $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser);
         $portlet->setActions($aActions, $this->sName);
         $this->oPage->addPortlet($portlet);
         $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder')));
         $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser);
         $portlet->setActions($aActions, null);
         $this->oPage->addPortlet($portlet);
     } else {
         if ($this->browse_mode == 'lookup_value') {
             // browsing by a lookup value
             $this->editable = false;
             // check the inputs
             $field = KTUtil::arrayGet($_REQUEST, 'fField', null);
             $oField = DocumentField::get($field);
             if (PEAR::isError($oField) || $oField == false) {
                 $this->errorRedirectToMain('No Field selected.');
                 exit(0);
             }
             $value = KTUtil::arrayGet($_REQUEST, 'fValue', null);
             $oValue = MetaData::get($value);
             if (PEAR::isError($oValue) || $oValue == false) {
                 $this->errorRedirectToMain('No Value selected.');
                 exit(0);
             }
             $this->oQuery = new ValueBrowseQuery($oField, $oValue);
             $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value));
             // setup breadcrumbs
             $this->aBreadcrumbs = array(array('name' => _kt('Lookup Values'), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectField')), array('name' => $oField->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectLookup&fField=' . $oField->getId())), array('name' => $oValue->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value))));
         } else {
             if ($this->browse_mode == 'document_type') {
//.........这里部分代码省略.........
开发者ID:5haman,项目名称:knowledgetree,代码行数:101,代码来源:browse.php

示例2: form_changetype

 function form_changetype()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt("Change Document Type"), 'description' => _kt("Changing the document type will allow different metadata to be associated with it."), 'identifier' => 'ktcore.doc.edit.typechange', 'submit_label' => _kt("Update Document"), 'context' => $this, 'cancel_action' => 'main', 'action' => 'trytype'));
     $type = DocumentType::get($this->oDocument->getDocumentTypeId());
     $current_type_name = $type->getName();
     $oFolder = Folder::get($this->oDocument->getFolderID());
     $oForm->setWidgets(array(array('ktcore.widgets.entityselection', array('label' => _kt("New Document Type"), 'description' => _kt("Please select the new type for this document."), 'important_description' => sprintf(_kt("The document is currently of type \"%s\"."), $current_type_name), 'value' => $type->getId(), 'label_method' => 'getName', 'vocab' => DocumentType::getListForUserAndFolder($this->oUser, $oFolder), 'simple_select' => false, 'required' => true, 'name' => 'type'))));
     $oForm->setValidators(array(array('ktcore.validators.entity', array('test' => 'type', 'output' => 'type', 'class' => 'DocumentType'))));
     return $oForm;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:11,代码来源:edit.php

示例3: do_addfieldsets

 function do_addfieldsets()
 {
     $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']);
     $aFieldsetId = $_REQUEST['fieldsetid'];
     if (!count($aFieldsetId)) {
         $this->errorRedirectTo('edit', _kt('You must select at least one fieldset'), 'fDocumentTypeId=' . $oDocumentType->getId());
         exit(0);
     }
     $res = KTMetadataUtil::addSetsToDocumentType($oDocumentType, $aFieldsetId);
     if (PEAR::isError($res)) {
         var_dump($res);
         $this->errorRedirectTo('edit', _kt('Changes not saved'), 'fDocumentTypeId=' . $oDocumentType->getId());
         exit(0);
     }
     $this->successRedirectTo('edit', _kt('Fieldsets associated.'), 'fDocumentTypeId=' . $oDocumentType->getId());
     exit(0);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:17,代码来源:documentTypes.php

示例4: get_detail

 /**
  * 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 = 'n/a';
     if (is_numeric($userid)) {
         $username = '* unknown *';
         $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 = 'n/a';
     if (is_numeric($userid)) {
         $username = '* unknown *';
         $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 = 'n/a';
     if (is_numeric($userid)) {
         $username = '* unknown *';
         $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 = 'n/a';
     if (is_numeric($userid)) {
         $username = '* unknown *';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
//.........这里部分代码省略.........
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:101,代码来源:KTAPIDocument.inc.php

示例5: do_viewComparison

 function do_viewComparison()
 {
     $document_data = array();
     $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     if ($document_id === null) {
         $this->oPage->addError(sprintf(_kt("No document was requested.  Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
         return $this->do_error();
     }
     $document_data['document_id'] = $document_id;
     $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion');
     // try get the document.
     $oDocument =& Document::get($document_id, $base_version);
     if (PEAR::isError($oDocument)) {
         $this->oPage->addError(sprintf(_kt("The base document you attempted to retrieve is invalid.   Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl()));
         return $this->do_error();
     }
     if (!Permission::userHasDocumentReadPermission($oDocument)) {
         // FIXME inconsistent.
         $this->oPage->addError(_kt('You are not allowed to view this document'));
         return $this->permissionDenied();
     }
     $this->oDocument =& $oDocument;
     $this->oPage->setSecondaryTitle($oDocument->getName());
     $aOptions = array('documentaction' => 'viewDocument', 'folderaction' => 'browse');
     $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions));
     $this->oPage->setBreadcrumbDetails(_kt('compare versions'));
     $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion');
     if ($comparison_version === null) {
         $this->oPage->addError(sprintf(_kt("No comparison version was requested.  Please <a href=\"%s\">select a version</a>."), KTUtil::addQueryStringSelf('action=history&fDocumentId=' . $document_id)));
         return $this->do_error();
     }
     $oComparison =& Document::get($oDocument->getId(), $comparison_version);
     if (PEAR::isError($oComparison)) {
         $this->errorRedirectToMain(_kt('Invalid document to compare against.'));
     }
     $comparison_data = array();
     $comparison_data['document_id'] = $oComparison->getId();
     $document_data['document'] = $oDocument;
     $comparison_data['document'] = $oComparison;
     $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID());
     $comparison_data['document_type'] =& DocumentType::get($oComparison->getDocumentTypeID());
     // follow twice:  once for normal, once for comparison.
     $is_valid_doctype = true;
     if (PEAR::isError($document_data['document_type'])) {
         $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>.  Unfortunately, this means that we cannot effectively display it.'));
         $is_valid_doctype = false;
     }
     // we want to grab all the md for this doc, since its faster that way.
     $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($base_version)));
     $field_values = array();
     foreach ($mdlist as $oFieldLink) {
         $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
     }
     $document_data['field_values'] = $field_values;
     $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($comparison_version)));
     $field_values = array();
     foreach ($mdlist as $oFieldLink) {
         $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue();
     }
     $comparison_data['field_values'] = $field_values;
     // Fieldset generation.
     //
     //   we need to create a set of FieldsetDisplay objects
     //   that adapt the Fieldsets associated with this lot
     //   to the view (i.e. ZX3).   Unfortunately, we don't have
     //   any of the plumbing to do it, so we handle this here.
     $fieldsets = array();
     // we always have a generic.
     array_push($fieldsets, new GenericFieldsetDisplay());
     // FIXME can we key this on fieldset namespace?  or can we have duplicates?
     // now we get the other fieldsets, IF there is a valid doctype.
     if ($is_valid_doctype) {
         // these are the _actual_ fieldsets.
         $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
         // and the generics
         $activesets = KTFieldset::getGenericFieldsets();
         foreach ($activesets as $oFieldset) {
             $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
             array_push($fieldsets, new $displayClass($oFieldset));
         }
         $activesets = KTFieldset::getForDocumentType($oDocument->getDocumentTypeID());
         foreach ($activesets as $oFieldset) {
             $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
             array_push($fieldsets, new $displayClass($oFieldset));
         }
     }
     // FIXME handle ad-hoc fieldsets.
     $this->addPortlets();
     $oTemplate = $this->oValidator->validateTemplate('ktcore/document/compare');
     $aTemplateData = array('context' => $this, 'document_id' => $document_id, 'document' => $oDocument, 'document_data' => $document_data, 'comparison_data' => $comparison_data, 'comparison_document' => $oComparison, 'fieldsets' => $fieldsets);
     //var_dump($aTemplateData['comparison_data']);
     return $oTemplate->render($aTemplateData);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:93,代码来源:view.php

示例6: array

 function &getAssociatedTypes()
 {
     // NOTE:  this returns null if we are generic (all is the wrong answer)
     if ($this->getIsGeneric()) {
         return array();
     }
     $sTable = KTUtil::getTableName('document_type_fieldsets');
     $aQuery = array("SELECT document_type_id FROM {$sTable} WHERE fieldset_id = ?", array($this->getId()));
     $aIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id');
     $aRet = array();
     foreach ($aIds as $iID) {
         $oType = DocumentType::get($iID);
         if (!PEAR::isError($oType)) {
             $aRet[] = $oType;
         }
     }
     return $aRet;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:18,代码来源:fieldset.inc.php

示例7: getMetadata

 /**
  * 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;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:86,代码来源:documentPreview.php

示例8: do_finalise

 function do_finalise()
 {
     $this->persistParams(array('fFileKey'));
     $sess_key = $_REQUEST['fFileKey'];
     $oForm = $this->form_metadata($sess_key);
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $data = $res['results'];
     $extra_d = $_SESSION['_add_data'][$sess_key];
     $doctypeid = $extra_d['document_type'];
     $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false));
     $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false));
     $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds);
     $MDPack = array();
     foreach ($fieldsets as $oFieldset) {
         $fields = $oFieldset->getFields();
         $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId());
         foreach ($fields as $oField) {
             $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
             if ($oFieldset->getIsConditional()) {
                 if ($val == _kt('No selection.')) {
                     $val = null;
                 }
             }
             // ALT.METADATA.LAYER.DIE.DIE.DIE
             if (!is_null($val)) {
                 $MDPack[] = array($oField, $val);
             }
         }
     }
     // older code
     $mpo =& new JavascriptObserver($this);
     $oUploadChannel =& KTUploadChannel::getSingleton();
     $oUploadChannel->addObserver($mpo);
     require_once KT_LIB_DIR . '/storage/storagemanager.inc.php';
     //require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
     require_once KT_LIB_DIR . '/documentmanagement/DocumentType.inc';
     require_once KT_LIB_DIR . '/metadata/fieldset.inc.php';
     require_once KT_LIB_DIR . '/documentmanagement/documentutil.inc.php';
     $aErrorOptions = array('redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), 'max_str_len' => 200);
     $aFile = $this->oValidator->validateFile($extra_d['file'], $aErrorOptions);
     $sTitle = $extra_d['document_name'];
     $iFolderId = $this->oFolder->getId();
     $aOptions = array('temp_file' => $aFile['tmp_name'], 'documenttype' => DocumentType::get($extra_d['document_type']), 'metadata' => $MDPack, 'description' => $sTitle, 'cleanup_initial_file' => true);
     $mpo->start();
     //$this->startTransaction();
     $oDocument =& KTDocumentUtil::add($this->oFolder, $aFile['name'], $this->oUser, $aOptions);
     if (PEAR::isError($oDocument)) {
         $message = $oDocument->getMessage();
         $this->errorRedirectTo('main', sprintf(_kt("Unexpected failure to add document - %s"), $message), 'fFolderId=' . $this->oFolder->getId());
         exit(0);
     }
     $this->addInfoMessage(_kt("Document added"));
     //$this->commitTransaction();
     $mpo->redirectToDocument($oDocument->getId());
     exit(0);
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:59,代码来源:addDocument.php

示例9: renderData

 function renderData($aDataRow)
 {
     // only show this for documents.
     if ($aDataRow['type'] === 'folder') {
         return '&nbsp;';
     }
     // Check if document is checked out
     $iDocTypeId = $aDataRow['document']->getDocumentTypeID();
     if (!empty($iDocTypeId)) {
         $oDocumentType = DocumentType::get($iDocTypeId);
         $sType = $oDocumentType->getName();
         return '<span class="descriptive">' . htmlentities($sType, ENT_NOQUOTES, 'UTF-8') . '</span>';
     }
     return '&mdash;';
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:15,代码来源:KTColumns.inc.php

示例10: add_document

 /**
  * This adds a document to the current folder.
  *
  * <code>
  * $kt = new KTAPI();
  * $kt->start_session("admin", "admin");
  * $folder = $kt->get_folder_by_name("My New folder");
  * $res = $folder->add_document("Test Document", "test.txt", "Default", $tmpfname);
  * </code>
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $title This is the title for the file in the repository.
  * @param string $filename This is the filename in the system for the file.
  * @param string $documenttype This is the name or id of the document type. It first looks by name, then by id.
  * @param string $tempfilename This is a reference to the file that is accessible locally on the file system.
  * @return KTAPI_Document
  */
 function add_document($title, $filename, $documenttype, $tempfilename)
 {
     if (!is_file($tempfilename)) {
         return new PEAR_Error('File does not exist.');
     }
     $user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_WRITE);
     if (PEAR::isError($user)) {
         return $user;
     }
     //KTS-4016: removed the replacing of special characters from the title as they should be allowed there
     //$title = KTUtil::replaceInvalidCharacters($title);
     $filename = basename($filename);
     $filename = KTUtil::replaceInvalidCharacters($filename);
     $documenttypeid = KTAPI::get_documenttypeid($documenttype);
     if (PEAR::isError($documenttypeid)) {
         $config = KTCache::getSingleton();
         $defaultToDefaultDocType = $config->get('webservice/useDefaultDocumentTypeIfInvalid', true);
         if ($defaultToDefaultDocType) {
             $documenttypeid = KTAPI::get_documenttypeid('Default');
         } else {
             return new KTAPI_DocumentTypeError('The document type could not be resolved or is disabled: ' . $documenttype);
         }
     }
     $options = array('contents' => new KTFSFileLike($tempfilename), 'temp_file' => $tempfilename, 'novalidate' => true, 'documenttype' => DocumentType::get($documenttypeid), 'description' => $title, 'metadata' => array(), 'cleanup_initial_file' => true);
     DBUtil::startTransaction();
     $document =& KTDocumentUtil::add($this->folder, $filename, $user, $options);
     if (PEAR::isError($document)) {
         DBUtil::rollback();
         return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR . ' : ' . $document->getMessage());
     }
     DBUtil::commit();
     KTUploadManager::temporary_file_imported($tempfilename);
     return new KTAPI_Document($this->ktapi, $this, $document);
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:52,代码来源:KTAPIFolder.inc.php


注:本文中的DocumentType::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。