ktdocumentlinks.php.svn-base
来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 595 行 · 第 1/2 页
SVN-BASE
595 行
<?php/** * $Id$ * * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * */require_once(KT_LIB_DIR . "/actions/documentviewlet.inc.php");require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');require_once(KT_LIB_DIR . '/documentmanagement/DocumentLink.inc');require_once(KT_LIB_DIR . '/documentmanagement/LinkType.inc');require_once(KT_LIB_DIR . "/browse/DocumentCollection.inc.php");require_once(KT_LIB_DIR . "/browse/BrowseColumns.inc.php");require_once(KT_LIB_DIR . "/browse/PartialQuery.inc.php");require_once(KT_LIB_DIR . "/browse/browseutil.inc.php");require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");class KTDocumentLinks extends KTPlugin { var $sNamespace = "ktstandard.documentlinks.plugin"; function KTDocumentLinks($sFilename = null) { $res = parent::KTPlugin($sFilename); $this->sFriendlyName = _kt('Inter-document linking'); return $res; } function setup() { $this->registerAction('documentaction', 'KTDocumentLinkAction', 'ktcore.actions.document.link'); $this->registerAction('documentviewlet', 'KTDocumentLinkViewlet', 'ktcore.viewlets.document.link'); $this->registerColumn(_kt('Link Title'), 'ktdocumentlinks.columns.title', 'KTDocumentLinkTitle', dirname(__FILE__) . '/KTDocumentLinksColumns.php'); $this->registerAdminPage("linkmanagement", 'KTDocLinkAdminDispatcher', 'documents', _kt('Link Type Management'), _kt('Manage the different ways documents can be associated with one another.'), __FILE__, null); }}class KTDocumentLinkViewlet extends KTDocumentViewlet { var $sName = 'ktcore.viewlets.document.link'; function display_viewlet() { $oKTTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oKTTemplating->loadTemplate("ktstandard/links/links_viewlet"); if (is_null($oTemplate)) { return ''; } $iDocId = $this->oDocument->getId(); $temp_links_from = DocumentLink::getLinksFromDocument($iDocId); $temp_links_to = DocumentLink::getLinksToDocument($iDocId); $temp_links_external = DocumentLink::getExternalLinks($iDocId); $links_to = array(); $links_from = array(); $links_external = array(); if(!empty($temp_links_from)){ foreach ($temp_links_from as $link) { $oDoc = $link->getChildDocument(); if (PEAR::isError($oDoc)) { continue; } if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) { $type = $link->getLinkType(); $aInfo = array( 'url' => KTBrowseUtil::getUrlForDocument($oDoc), 'name' => $oDoc->getName(), 'type' => $type->getName(), 'description' => $type->getDescription(), ); $links_from[] = $aInfo; } } } if(!empty($temp_links_to)){ foreach ($temp_links_to as $link) { $oDoc = $link->getParentDocument(); if (PEAR::isError($oDoc)) { continue; } if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) { $type = $link->getLinkType(); $aInfo = array( 'url' => KTBrowseUtil::getUrlForDocument($oDoc), 'name' => $oDoc->getName(), 'type' => $type->getName(), 'description' => $type->getDescription(), ); $links_to[] = $aInfo; } } } if(!empty($temp_links_external)){ foreach ($temp_links_external as $link) { $type = $link->getLinkType(); $aInfo = array( 'url' => $link->getTargetUrl(), 'name' => $link->getTargetName(), 'type' => $type->getName(), 'description' => $type->getDescription(), ); $links_external[] = $aInfo; } } if (empty($links_from) && empty($links_to) && empty($links_external)) { return ''; } $oTemplate->setData(array( 'context' => $this, 'links_from' => $links_from, 'links_to' => $links_to, 'links_external' => $links_external, )); return $oTemplate->render(); }}class KTDocumentLinkAction extends KTDocumentAction { var $sName = 'ktcore.actions.document.link'; function getDisplayName() { return _kt('Links'); } // display existing links function do_main() { $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/document_links'); $this->oPage->setBreadcrumbDetails(_kt("Links")); $this->oPage->setTitle(_kt("Links")); $iDocId = $_REQUEST['fDocumentId']; $oDocument = Document::get($iDocId); $oReadPermission =& KTPermission::getByName('ktcore.permissions.read'); $oWritePermission =& KTPermission::getByName('ktcore.permissions.write'); $aTemplateData = array( 'context' => $this, 'iDocId' => $iDocId, 'links_external' => DocumentLink::getExternalLinks($iDocId), 'links_from' => DocumentLink::getLinksFromDocument($iDocId), 'links_to' => DocumentLink::getLinksToDocument($iDocId), 'read_permission' => KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oReadPermission, $this->oDocument), 'write_permission' => KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oWritePermission, $this->oDocument), ); return $oTemplate->render($aTemplateData); } // select a target for the link function do_new() { $this->oPage->setBreadcrumbDetails(_kt("New Link")); $this->oPage->setTitle(_kt("New Link")); $oPermission =& KTPermission::getByName('ktcore.permissions.write'); if (PEAR::isError($oPermission) || !KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) { $this->errorRedirectToMain(_kt('You do not have sufficient permissions to add a document link'), sprintf("fDocumentId=%d", $this->oDocument->getId())); exit(0); } $oParentDocument =& $this->oDocument; if (PEAR::isError($oParentDocument)) { $this->errorRedirectToMain(_kt('Invalid parent document selected.')); exit(0); } $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', $oParentDocument->getFolderID())); if (PEAR::isError($oFolder) || ($oFolder == false)) { $this->errorRedirectToMain(_kt('Invalid folder selected.')); exit(0); } $iFolderId = $oFolder->getId(); // Setup the collection for move display. $collection = new AdvancedCollection(); $aBaseParams = array('fDocumentId'=>$oParentDocument->getId()); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.selection'); $aColOptions = array(); $aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId())); $aColOptions['show_folders'] = false; $aColOptions['show_documents'] = true; $aColOptions['rangename'] = 'linkselection[]'; $col->setOptions($aColOptions); $collection->addColumn($col); $col = $oCR->getColumn('ktdocumentlinks.columns.title'); $col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId())))); $collection->addColumn($col); $qObj = new BrowseQuery($iFolderId); $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); //$aOptions['is_browse'] = true; $aResultUrl = $aBaseParams; $aResultUrl['fFolderId'] = $oFolder->getId(); $aResultUrl['action'] = 'new'; $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aResultUrl); $collection->setOptions($aOptions); $aURLParams = $aBaseParams; $aURLParams['action'] = 'new'; $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); $aTemplateData = array( 'context' => $this, 'folder' => $oFolder, 'parent' => $oParentDocument, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection, 'link_types' => LinkType::getList("id > 0"), ); $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link'); return $oTemplate->render($aTemplateData); } function do_external() { $this->oPage->setBreadcrumbDetails(_kt("New External Link")); $this->oPage->setTitle(_kt("New External Link")); $oPermission =& KTPermission::getByName('ktcore.permissions.write'); if (PEAR::isError($oPermission) || !KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) { $this->errorRedirectToMain(_kt('You do not have sufficient permissions to add a document link'), sprintf("fDocumentId=%d", $this->oDocument->getId())); exit(0); } $oParentDocument =& $this->oDocument; $iParentId = $oParentDocument->getId(); $aTemplateData = array( 'context' => $this, 'iDocId' => $iParentId, 'link_types' => LinkType::getList("id > 0"), ); $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_external'); return $oTemplate->render($aTemplateData); } // select a type for the link function do_type_select() { //Checking to see if the document is being linked to itself and returning an error if it is. $iTempParentDocId = $_REQUEST['fDocumentId']; $aTempDocuments = $_REQUEST['linkselection']; if(!empty($aTempDocuments)){ foreach ($aTempDocuments as $iTempDocId)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?