diff --git a/lib/documentmanagement/DocumentLink.inc b/lib/documentmanagement/DocumentLink.inc index 0cca05e..5042506 100644 --- a/lib/documentmanagement/DocumentLink.inc +++ b/lib/documentmanagement/DocumentLink.inc @@ -8,32 +8,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 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 . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. 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 + * 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. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * * @@ -50,6 +50,10 @@ class DocumentLink extends KTEntity { var $iChildDocumentId; /** type of link */ var $iLinkTypeId; + /** external url */ + var $sTargetUrl; + /** external name */ + var $sTargetName; var $_aFieldToSelect = array( @@ -57,6 +61,8 @@ class DocumentLink extends KTEntity { 'iParentDocumentId' => 'parent_document_id', 'iChildDocumentId' => 'child_document_id', 'iLinkTypeId' => 'link_type_id', + 'sTargetUrl' => 'external_url', + 'sTargetName' => 'external_name', ); @@ -68,13 +74,15 @@ class DocumentLink extends KTEntity { * @param Link type primary key * */ - function DocumentLink($iNewParentDocumentID = null, $iNewChildDocumentID = null, $iLinkTypeId = null) { + function DocumentLink($iNewParentDocumentID = null, $iNewChildDocumentID = null, $iLinkTypeId = null, $sTargetUrl = null, $sTargetName = null) { //object not created yet global $default; $this->iId = -1; $this->iParentDocumentId = $iNewParentDocumentID; $this->iChildDocumentId = $iNewChildDocumentID; $this->iLinkTypeId = $iLinkTypeId; + $this->sTargetUrl = $sTargetUrl; + $this->sTargetName = $sTargetName; } function getID() { return $this->iId; } @@ -84,6 +92,10 @@ class DocumentLink extends KTEntity { function setChildDocumentID($iNewValue) { $this->iChildDocumentId = $iNewValue; } function getLinkTypeID() { return $this->iLinkTypeId; } function setLinkTypeID($iNewValue) { $this->iLinkTypeId = $iNewValue; } + function getTargetUrl() { return $this->sTargetUrl; } + function setTargetUrl($iNewValue) { $this->sTargetUrl = $iNewValue; } + function getTargetName() { return $this->sTargetName; } + function setTargetName($iNewValue) { $this->sTargetName = $iNewValue; } /** * Helper getters @@ -118,6 +130,8 @@ class DocumentLink extends KTEntity { 'parent_document_id' => $this->iParentDocumentId, 'child_document_id' => $this->iChildDocumentId, 'link_type_id' => $this->iLinkTypeId, + 'external_url' => $this->sTargetUrl, + 'external_name' => $this->sTargetName, ); } @@ -126,29 +140,33 @@ class DocumentLink extends KTEntity { return $default->document_link_table; } - // static boilerplate function & get($iDocumentLinkID) { - global $default; - - $sql = $default->db; - $result = $sql->query(array("SELECT * FROM $default->document_link_table WHERE id = ?", $iDocumentLinkID));/*ok*/ - if ($result) { - if ($sql->next_record()) { - $oDocumentLink = new DocumentLink($sql->f("parent_document_id"), $sql->f("child_document_id"), $sql->f("link_type_id")); - $oDocumentLink->iId = $sql->f("id"); - return $oDocumentLink; - } - $_SESSION["errorMessage"] = $lang_err_object_not_exist."id = ".$iDocumentLinkID." table = $default->document_link_table"; - return false; - } - $_SESSION["errorMessage"] = $lang_err_database; - return false; + $table = DocumentLink::_table(); + $query = "SELECT * FROM $table WHERE id = '$iDocumentLinkID'"; + $result = DBUtil::getOneResult($query); + + if(PEAR::isError($result)) { + $_SESSION['errorMessage'] = $result->getMessage(); + return false; + } + + if(!empty($result)){ + $oDocumentLink = new DocumentLink($result['parent_document_id'], $result['child_document_id'], $result['link_type_id'], $result['external_url'], $result['external_name']); + $oDocumentLink->iId = $result['id']; + return $oDocumentLink; + } + $_SESSION['errorMessage'] = _kt('The object does not exist. id = '.$iDocumentLinkID.' table = '.$table); + return false; } + function getList($sWhereClause = null) { return KTEntityUtil::getList2('DocumentLink', $sWhereClause); } - function &createFromArray($aArray) { return KTEntityUtil::createFromArray('DocumentLink', $aArray); } + + function &createFromArray($aArray) { + return KTEntityUtil::createFromArray('DocumentLink', $aArray); + } /** * Static function @@ -159,7 +177,8 @@ class DocumentLink extends KTEntity { * @return Array array of DocumentLink objects, false otherwise. */ function getLinksFromDocument($iDocumentId) { - return KTEntityUtil::getList2('DocumentLink', sprintf("parent_document_id = %d", $iDocumentId)); + $sWhere = "parent_document_id = $iDocumentId AND child_document_id != $iDocumentId"; + return KTEntityUtil::getList2('DocumentLink', $sWhere); } /** @@ -171,8 +190,22 @@ class DocumentLink extends KTEntity { * @return Array array of DocumentLink objects, false otherwise. */ function getLinksToDocument($iDocumentId) { - return KTEntityUtil::getList2('DocumentLink', sprintf("child_document_id = %d", $iDocumentId)); + $sWhere = "child_document_id = $iDocumentId AND parent_document_id != $iDocumentId"; + return KTEntityUtil::getList2('DocumentLink', $sWhere); + } + + /** + * Static function + * Get a list of external DocumentLinks where iDocumentId is the parent + * + * @param Integer Document ID of parent + * + * @return Array array of DocumentLink objects, false otherwise. + */ + function getExternalLinks($iDocumentId) { + $sWhere = "child_document_id = $iDocumentId AND parent_document_id = $iDocumentId"; + return KTEntityUtil::getList2('DocumentLink', $sWhere); } } -?> +?> \ No newline at end of file diff --git a/lib/validation/dispatchervalidation.inc.php b/lib/validation/dispatchervalidation.inc.php index e0810e8..91297f1 100644 --- a/lib/validation/dispatchervalidation.inc.php +++ b/lib/validation/dispatchervalidation.inc.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 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 . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. 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 + * 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. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -222,10 +222,10 @@ class KTDispatcherValidation { $iMaxlen = (int)KTUtil::arrayGet($aOptions, 'max_str_len', false); if($iMaxlen !== false && $iMaxlen !== 0 && strlen($sString) > $iMaxlen) { - $aOptions['message'] = KTUtil::arrayGet($aOptions, - 'max_str_len_message', + $aOptions['message'] = KTUtil::arrayGet($aOptions, + 'max_str_len_message', _kt("The string is too long: the maximum length in characters is ") . $iMaxlen); - $this->handleError($aOptions); + $this->handleError($aOptions); } return $sString; @@ -238,8 +238,8 @@ class KTDispatcherValidation { 'message', _kt("An empty string was given")); $this->handleError($aOptions); } - - // illegal characters: /\ <>|%+':"?* + + // illegal characters: /\ <>|%+':"?* $pattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; if(preg_match($pattern, $sString)){ $sChars = "\/<>|%+*':\"?"; @@ -262,20 +262,20 @@ class KTDispatcherValidation { if(!is_numeric($sInteger)) { $aOptions['message'] = KTUtil::arrayGet($aOptions, 'message', _kt("A non-numeric value was given")); $this->handleError($aOptions); - } + } return intval($sInteger); } function validateFile($aFile, $aOptions = null) { $bError = false; - + if (strlen(trim($aFile['name'])) == 0) { $bError = true; } else { $bError = KTUtil::arrayGet($aFile, 'error'); } - + if ($bError) { $message = _kt("You did not select a valid document to upload"); @@ -388,29 +388,29 @@ class KTDispatcherValidation { } return $oEntity; } - - - - - + + + + + /* unlike the KTEmail version, this only handles ONE email address */ function validateEmailAddress($sEmailAddress, $aOptions = null) { $sEmailAddress = trim($sEmailAddress); - + if (!ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $sEmailAddress )) { $aOptions['message'] = KTUtil::arrayGet($aOptions, - 'message', + 'message', _kt("This is not a valid email address.")); $this->handleError($aOptions); } return $sEmailAddress; } - - + + /* just does an empty string validation with an appropriate message, and then a duplicate name validation */ function validateEntityName($sEntityTypeName, $sName, $aOptions = null) { $aOptions['message'] = KTUtil::arrayGet($aOptions, 'empty_message', _kt("No name was given for this item")); - + $sName = $this->validateString($sName, $aOptions); $aOptions['message'] = KTUtil::arrayGet($aOptions, 'duplicate_message', _kt("An item with this name already exists")); return $this->validateDuplicateName($sEntityTypeName, $sName, $aOptions); @@ -446,8 +446,16 @@ class KTDispatcherValidation { $aOptions['message'] = _kt('Password and confirmation password do not match'); $this->handleError($aOptions); } - + function validateUrl($sUrl, $aOptions = null) { + $sUrl = trim($sUrl); + + if(!((bool) preg_match("'^[^:]+:(?:[0-9a-z\.\?&-_=\+\/]+[\.]{1})*(?:[0-9a-z\.\?&-_=\+\/]+\.)[a-z]{2,3}.*$'i", $sUrl))){ + $aOptions['message'] = KTUtil::arrayGet($aOptions, 'message', _kt('This is not a valid URL.')); + $this->handleError($aOptions); + } + return $sUrl; + } } ?> diff --git a/plugins/ktstandard/KTDocumentLinks.php b/plugins/ktstandard/KTDocumentLinks.php index bebb099..27ee103 100644 --- a/plugins/ktstandard/KTDocumentLinks.php +++ b/plugins/ktstandard/KTDocumentLinks.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 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 . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. 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 + * 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. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ * */ @@ -49,22 +49,22 @@ 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', + $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); + __FILE__, null); } } @@ -72,64 +72,87 @@ class KTDocumentLinks extends KTPlugin { 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 ""; } + if (is_null($oTemplate)) { return ''; } - $temp_links_from = DocumentLink::getLinksFromDocument($this->oDocument->getId()); - $temp_links_to = DocumentLink::getLinksToDocument($this->oDocument->getId()); + $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(); - - 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; + $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; + } } } - - foreach ($temp_links_to as $link) { - $oDoc = $link->getParentDocument(); - if (PEAR::isError($oDoc)) { - continue; + + 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 (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.read', $oDoc)) { + } + + if(!empty($temp_links_external)){ + foreach ($temp_links_external as $link) { $type = $link->getLinkType(); + $aInfo = array( - 'url' => KTBrowseUtil::getUrlForDocument($oDoc), - 'name' => $oDoc->getName(), - 'type' => $type->getName(), - 'description' => $type->getDescription(), + 'url' => $link->getTargetUrl(), + 'name' => $link->getTargetName(), + 'type' => $type->getName(), + 'description' => $type->getDescription(), ); - - $links_to[] = $aInfo; + + $links_external[] = $aInfo; } - } + } - if (empty($links_from) && empty($links_to)) { - return ""; + 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(); } @@ -149,27 +172,24 @@ class KTDocumentLinkAction extends KTDocumentAction { $this->oPage->setBreadcrumbDetails(_kt("Links")); $this->oPage->setTitle(_kt("Links")); - $oDocument = Document::get( - KTUtil::arrayGet($_REQUEST, 'fDocumentId', 0) - ); + $iDocId = $_REQUEST['fDocumentId']; + $oDocument = Document::get($iDocId); $oReadPermission =& KTPermission::getByName('ktcore.permissions.read'); $oWritePermission =& KTPermission::getByName('ktcore.permissions.write'); - + $aTemplateData = array( 'context' => $this, - 'links_from' => DocumentLink::getLinksFromDocument($oDocument->getId()), - 'links_to' => DocumentLink::getLinksToDocument($oDocument->getId()), + '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); - } - - + return $oTemplate->render($aTemplateData); + } // select a target for the link function do_new() { @@ -177,176 +197,204 @@ class KTDocumentLinkAction extends KTDocumentAction { $this->oPage->setTitle(_kt("New Link")); $oPermission =& KTPermission::getByName('ktcore.permissions.write'); - if (PEAR::isError($oPermission) || + 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)) { + + 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)) { + 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('ktcore.columns.singleselection'); - $col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId())))); - $collection->addColumn($col); - $col = $oCR->getColumn('ktdocumentlinks.columns.title'); - $col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId())))); + $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['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], + //$aOptions['is_browse'] = true; + $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId())))); $collection->setOptions($aOptions); - $oWF =& KTWidgetFactory::getSingleton(); - $oWidget = $oWF->get('ktcore.widgets.collection', - array('label' => _kt('Target Document'), - 'description' => _kt('Use the folder collection and path below to browse to the document you wish to link to.'), - 'required' => true, - 'name' => 'browse', - 'folder_id' => $oFolder->getId(), - 'bcurl_params' => $aBaseParams, - 'collection' => $collection)); + $aURLParams = $aBaseParams; + $aURLParams['action'] = 'new'; + $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); - - $aTemplateData = array( 'context' => $this, 'folder' => $oFolder, 'parent' => $oParentDocument, 'breadcrumbs' => $aBreadcrumbs, - 'collection' => $oWidget, + 'collection' => $collection, 'link_types' => LinkType::getList("id > 0"), ); - + $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link'); - return $oTemplate->render($aTemplateData); + return $oTemplate->render($aTemplateData); } - // select a type for the link - function do_type_select() { - $this->oPage->setBreadcrumbDetails(_kt("link")); + function do_external() { + $this->oPage->setBreadcrumbDetails(_kt("New External Link")); + $this->oPage->setTitle(_kt("New External Link")); - $oParentDocument = Document::get(KTUtil::arrayGet($_REQUEST, 'fDocumentId')); - if (PEAR::isError($oParentDocument)) { - $this->errorRedirectToMain(_kt('Invalid parent document selected.')); + $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); } - /* - print '
';
-        var_dump($_REQUEST);
-        exit(0);
-        */
+        $oParentDocument =& $this->oDocument;
+        $iParentId = $oParentDocument->getId();
 
+        $aTemplateData = array(
+              'context' => $this,
+              'iDocId' => $iParentId,
+              'link_types' => LinkType::getList("id > 0"),
+        );
 
-        $oTargetDocument = Document::get(KTUtil::arrayGet($_REQUEST, '_d'));
-        if (PEAR::isError($oTargetDocument)) { 
-            $this->errorRedirectToMain(_kt('Invalid target document selected.'));
-            exit(0);
-        }
+        $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_external');
+        return $oTemplate->render($aTemplateData);
+    }
+
+    // select a type for the link
+    function do_type_select() {
+        $this->oPage->setBreadcrumbDetails(_kt("link"));
+
+        $sType = (isset($_REQUEST['linktype'])) ? $_REQUEST['linktype'] : 'internal';
+        $sTarget = '';
+        $aTarget = array();
 
+        if($sType == 'external'){
+            $iParentId = $_REQUEST['fDocumentId'];
+            $aTarget['url'] = $_REQUEST['target_url'];
+            $aTarget['name'] = $_REQUEST['target_name'];
+            $aDocuments = array($iParentId);
+
+            $this->oValidator->validateUrl($aTarget['url']);
+            if(empty($aTarget['name'])){
+                $aTarget['name'] = $aTarget['url'];
+            }
+        }else{
+            $iParentId = $_REQUEST['fDocumentId'];
+            $aDocuments = $_REQUEST['linkselection'];
+            if(empty($aDocuments)){
+                $this->errorRedirectToMain(_kt('No documents have been selected.'));
+                exit;
+            }
+        }
+        $sDocuments = serialize($aDocuments);
+        $sTarget = serialize($aTarget);
 
         // form fields
         $aFields = array();
-        
+
         $aVocab = array();
         foreach(LinkType::getList("id > 0") as $oLinkType) {
             $aVocab[$oLinkType->getID()] = $oLinkType->getName();
-        }        
+        }
 
         $aOptions = array('vocab' => $aVocab);
         $aFields[] = new KTLookupWidget(
-                _kt('Link Type'), 
-                _kt('The type of link you wish to use'), 
-                'fLinkTypeId', 
+                _kt('Link Type'),
+                _kt('The type of link you wish to use'),
+                'fLinkTypeId',
                 null,
                 $this->oPage,
                 true,
                 null,
                 null,
                 $aOptions);
-                
+
         $aTemplateData = array(
               'context' => $this,
-              'parent_id' => $oParentDocument->getId(),
-              'target_id' => $oTargetDocument->getId(),
+              'parent_id' => $iParentId,
+              'target_id' => $sDocuments,
+              'target_url' => $sTarget,
               'fields' => $aFields,
         );
-        
-        $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_type_select');
-        return $oTemplate->render($aTemplateData);                  
-
 
+        $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link_type_select');
+        return $oTemplate->render($aTemplateData);
     }
 
-
-
     // make the link
     function do_make_link() {
         $this->oPage->setBreadcrumbDetails(_kt("link"));
-
-        // check validity of things
-        $oParentDocument = Document::get(KTUtil::arrayGet($_REQUEST, 'fDocumentId'));
-        if (PEAR::isError($oParentDocument)) { 
-            $this->errorRedirectToMain(_kt('Invalid parent document selected.'));
-            exit(0);
-        }
-
-        $oTargetDocument = Document::get(KTUtil::arrayGet($_REQUEST, 'fTargetDocumentId'));
-        if (PEAR::isError($oTargetDocument)) { 
-            $this->errorRedirectToMain(_kt('Invalid target document selected.'));
-            exit(0);
-        }
-
-        $oLinkType = LinkType::get(KTUtil::arrayGet($_REQUEST, 'fLinkTypeId'));
-        if (PEAR::isError($oLinkType)) { 
+        $iParentId = $_REQUEST['fDocumentId'];
+        $iLinkTypeId = $_REQUEST['fLinkTypeId'];
+        $sDocIds = $_REQUEST['fTargetDocumentId'];
+        $aDocIds = unserialize($sDocIds);
+        $sTarget = $_REQUEST['fTargetUrl'];
+        $aTarget = unserialize($sTarget);
+
+        $oLinkType = LinkType::get($iLinkTypeId);
+        if (PEAR::isError($oLinkType)) {
             $this->errorRedirectToMain(_kt('Invalid link type selected.'));
             exit(0);
         }
 
+        $sTargetUrl = '';
+        $sTargetName = '';
+        if(!empty($aTarget)){
+            $sTargetUrl = $aTarget['url'];
+            $sTargetName = $aTarget['name'];
+        }
 
-        // create document link
+        // create document links
         $this->startTransaction();
-        
-        $oDocumentLink =& DocumentLink::createFromArray(array(
-            'iParentDocumentId' => $oParentDocument->getId(),
-            'iChildDocumentId'  => $oTargetDocument->getId(),
-            'iLinkTypeId'       => $oLinkType->getId(),
-        ));
 
-        if (PEAR::isError($oDocumentLink)) {
-            $this->errorRedirectToMain(_kt('Could not create document link'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
-            exit(0);
+        if(!empty($aDocIds)){
+            foreach ($aDocIds as $iDocId){
+
+                $oDocumentLink =& DocumentLink::createFromArray(array(
+                    'iParentDocumentId' => $iParentId,
+                    'iChildDocumentId'  => $iDocId,
+                    'iLinkTypeId'       => $iLinkTypeId,
+                    'sTargetUrl'       => $sTargetUrl,
+                    'sTargetName'       => $sTargetName,
+                ));
+
+                if (PEAR::isError($oDocumentLink)) {
+                    $this->rollbackTransaction();
+                    $this->errorRedirectToMain(_kt('Could not create document link'), sprintf('fDocumentId=%d', $iParentId));
+                    exit(0);
+                }
+            }
         }
 
         $this->commitTransaction();
 
-        $this->successRedirectToMain(_kt('Document link created'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
+        $this->successRedirectToMain(_kt('Document link created'), sprintf('fDocumentId=%d', $iParentId));
         exit(0);
     }
 
@@ -357,30 +405,29 @@ class KTDocumentLinkAction extends KTDocumentAction {
 
         // check security
         $oPermission =& KTPermission::getByName('ktcore.permissions.write');
-        if (PEAR::isError($oPermission) || 
+        if (PEAR::isError($oPermission) ||
             !KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) {
             $this->errorRedirectToMain(_kt('You do not have sufficient permissions to delete a link'), sprintf("fDocumentId=%d", $this->oDocument->getId()));
             exit(0);
         }
 
-
         // check validity of things
         $oDocumentLink = DocumentLink::get(KTUtil::arrayGet($_REQUEST, 'fDocumentLinkId'));
-        if (PEAR::isError($oDocumentLink)) { 
+        if (PEAR::isError($oDocumentLink)) {
             $this->errorRedirectToMain(_kt('Invalid document link selected.'));
             exit(0);
         }
         $oParentDocument = Document::get(KTUtil::arrayGet($_REQUEST, 'fDocumentId'));
-        if (PEAR::isError($oParentDocument)) { 
+        if (PEAR::isError($oParentDocument)) {
             $this->errorRedirectToMain(_kt('Invalid document selected.'));
             exit(0);
         }
-        
+
         // do deletion
         $this->startTransaction();
-        
+
         $res = $oDocumentLink->delete();
-        
+
         if (PEAR::isError($res)) {
             $this->errorRedirectToMain(_kt('Could not delete document link'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
             exit(0);
@@ -391,7 +438,61 @@ class KTDocumentLinkAction extends KTDocumentAction {
         $this->successRedirectToMain(_kt('Document link deleted'), sprintf('fDocumentId=%d', $oParentDocument->getId()));
         exit(0);
     }
+
+    function _generate_breadcrumbs($oFolder, $iFolderId, $aURLParams) {
+        static $aFolders = array();
+        static $aBreadcrumbs = array();
+
+        // Check if selected folder is a parent of the current folder
+        if(in_array($iFolderId, $aFolders)){
+            $temp = array_flip($aFolders);
+            $key = $temp[$iFolderId];
+            array_splice($aFolders, $key);
+            array_splice($aBreadcrumbs, $key);
+            return $aBreadcrumbs;
+        }
+
+        // Check for the parent of the selected folder unless its the root folder
+        $iParentId = $oFolder->getParentID();
+        if($iFolderId != 1 && in_array($iParentId, $aFolders)){
+            $temp = array_flip($aFolders);
+            $key = $temp[$iParentId];
+            array_splice($aFolders, $key);
+            array_splice($aBreadcrumbs, $key);
+            array_push($aFolders, $iFolderId);
+
+            $aParams = $aURLParams;
+            $aParams['fFolderId'] = $iFolderId;
+            $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams);
+            $aBreadcrumbs[] = array('url' => $url, 'name' => $oFolder->getName());
+            return $aBreadcrumbs;
+        }
+
+        // Create the breadcrumbs
+        $folder_path_names = $oFolder->getPathArray();
+        $folder_path_ids = explode(',', $oFolder->getParentFolderIds());
+        $folder_path_ids[] = $oFolder->getId();
+        if ($folder_path_ids[0] == 0) {
+            array_shift($folder_path_ids);
+            array_shift($folder_path_names);
+        }
+
+        $iCount = count($folder_path_ids);
+        $range = range(0, $iCount - 1);
+        foreach ($range as $index) {
+            $id = $folder_path_ids[$index];
+            $name = $folder_path_names[$index];
+
+            $aParams = $aURLParams;
+            $aParams['fFolderId'] = $id;
+            $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams);
+            $aBreadcrumbs[] = array('url' => $url, 'name' => $name);
+        }
+        $aFolders = $folder_path_ids;
+        return $aBreadcrumbs;
+    }
 }
+
 class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
     var $sHelpPage = 'ktcore/admin/link type management.html';
 
@@ -403,17 +504,17 @@ class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
     function do_main() {
         $this->aBreadcrumbs[] = array('name' => _kt('Document Links'));
         $this->oPage->setBreadcrumbDetails(_kt("view"));
-        
+
         $aLinkTypes =& LinkType::getList('id > 0');
-        
+
         $addLinkForm = array();
-        // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null) 
+        // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null)
         $addLinkForm[] = new KTStringWidget(_kt('Name'), _kt('A short, human-readable name for the link type.'), 'fName', null, $this->oPage, true);
         $addLinkForm[] = new KTStringWidget(_kt('Description'), _kt('A short brief description of the relationship implied by this link type.'), 'fDescription', null, $this->oPage, true);
-        
-        
+
+
         $oTemplating =& KTTemplating::getSingleton();
-        $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');       
+        $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');
         $oTemplate->setData(array(
             "context" => $this,
             "add_form" => $addLinkForm,
@@ -421,28 +522,28 @@ class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
         ));
         return $oTemplate;
     }
-    
+
     function do_edit() {
         $link_id = KTUtil::arrayGet($_REQUEST, 'fLinkTypeId', null, false);
         if ($link_id === null) {
            $this->errorRedirectToMain(_kt("Please specify a link type to edit."));
         }
-        
+
         $oLinkType =& LinkType::get($link_id);
-        
+
         $this->aBreadcrumbs[] = array('name' => _kt('Document Links'));
         $this->oPage->setBreadcrumbDetails(_kt("view"));
-        
+
         $aLinkTypes =& LinkType::getList('id > 0');
-        
+
         $editLinkForm = array();
-        // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null) 
+        // KTBaseWidget($sLabel, $sDescription, $sName, $value, $oPage, $bRequired = false, $sId = null, $aErrors = null, $aOptions = null)
         $editLinkForm[] = new KTStringWidget(_kt('Name'), _kt('A short, human-readable name for the link type.'), 'fName', $oLinkType->getName(), $this->oPage, true);
         $editLinkForm[] = new KTStringWidget(_kt('Description'), _kt('A short brief description of the relationship implied by this link type.'), 'fDescription', $oLinkType->getDescription(), $this->oPage, true);
-        
-        
+
+
         $oTemplating =& KTTemplating::getSingleton();
-        $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');       
+        $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/linktypesadmin');
         $oTemplate->setData(array(
             "context" => $this,
             "edit_form" => $editLinkForm,
@@ -450,54 +551,54 @@ class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
             "links" => $aLinkTypes,
         ));
         return $oTemplate;
-    }    
-    
+    }
+
 
     function do_update() {
         $link_id = KTUtil::arrayGet($_REQUEST, 'fLinkTypeId', null, false);
         if ($link_id === null) {
             $this->errorRedirectToMain(_kt("Please specify a link type to update."));
         }
-        
-        $name = KTUtil::arrayGet($_REQUEST, 'fName');        
+
+        $name = KTUtil::arrayGet($_REQUEST, 'fName');
         $description = KTUtil::arrayGet($_REQUEST, 'fDescription');
 
         if (empty($name) || empty($description)) { // for bonus points, make this go to edit, and edit catch it.
             $this->errorRedirectToMain(_kt('Please enter information for all fields.'));
         }
-        
+
         $oLinkType =& LinkType::get($link_id);
-        
+
         $oLinkType->setName($name);
         $oLinkType->setDescription($description);
         $oLinkType->update();
-        
+
         $this->successRedirectToMain(_kt("Link Type updated."));
     }
-    
+
     function do_add() {
-        $name = KTUtil::arrayGet($_REQUEST, 'fName');        
+        $name = KTUtil::arrayGet($_REQUEST, 'fName');
         $description = KTUtil::arrayGet($_REQUEST, 'fDescription');
 
         if (empty($name) || empty($description)) {
             $this->errorRedirectToMain(_kt('Please enter information for all fields.'));
         }
-        
+
         $oLinkType = new LinkType($name, $description);
         $oLinkType->create();
-             
+
         //$oLinkType =& LinkType::createFromArray(array("sName" => $name, "sDescription" => $description));
-        
+
         $this->successRedirectToMain(_kt("Link Type created."));
     }
-    
+
     function do_delete() {
         $types_to_delete = KTUtil::arrayGet($_REQUEST, 'fLinksToDelete');         // is an array.
 
         if (empty($types_to_delete)) {
             $this->errorRedirectToMain(_kt('Please select one or more link types to delete.'));
         }
-        
+
         $count = 0;
         foreach ($types_to_delete as $link_id) {
             $oLinkType = LinkType::get($link_id);
@@ -505,13 +606,13 @@ class KTDocLinkAdminDispatcher extends KTAdminDispatcher {
             foreach(DocumentLink::getList(sprintf("link_type_id = %d", $link_id)) as $oLink) {
                 $oLink->delete();
             }
-            
+
             $oLinkType->delete(); // technically, this is a bad thing
-            $count += 1; 
+            $count += 1;
         }
-        
+
         //$oLinkType =& LinkType::createFromArray(array("sName" => $name, "sDescription" => $description));
-        
+
         $this->successRedirectToMain($count . " " . _kt("Link types deleted."));
     }
 
diff --git a/plugins/rssplugin/KTrss.inc.php b/plugins/rssplugin/KTrss.inc.php
index dddea9d..d8ca6a3 100644
--- a/plugins/rssplugin/KTrss.inc.php
+++ b/plugins/rssplugin/KTrss.inc.php
@@ -84,6 +84,27 @@ class KTrss{
     	return $response;
     }
 
+    // Get the data for the document or folder
+    function getExternalInternalFeed($sFeed, $iUserId){
+        $aRss = array();
+        $pos = strpos($sFeed, 'docId');
+
+        if($pos === false){
+            $pos = strpos($sFeed, 'folderId');
+            $folderId = substr($sFeed, $pos+9);
+            $aRss[] = KTrss::getOneFolder($folderId, $iUserId);
+        }else{
+            $docId = substr($sFeed, $pos+6);
+            $aRss[] = KTrss::getOneDocument($docId, $iUserId);
+        }
+
+    	if($aRss){
+    		$internalFeed = KTrss::arrayToXML($aRss);
+    		$response = rss2arrayBlock($internalFeed);
+    	}
+    	return $response;
+    }
+
     // Get list of document subscriptions
     function getDocumentList($iUserId){
     	$sQuery = "SELECT document_id as id FROM document_subscriptions WHERE user_id = ?";
diff --git a/plugins/rssplugin/loadFeed.inc.php b/plugins/rssplugin/loadFeed.inc.php
index 0153137..ec20e6d 100644
--- a/plugins/rssplugin/loadFeed.inc.php
+++ b/plugins/rssplugin/loadFeed.inc.php
@@ -5,49 +5,69 @@
  * KnowledgeTree Open Source Edition
  * Document Management Made Simple
  * Copyright (C) 2004 - 2007 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 .
- * 
+ *
  * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
  * Blake Street, Observatory, 7925 South Africa. 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 
+ * 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. 
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
  * Contributor( s): ______________________________________
  *
  */
  require_once('../../config/dmsDefaults.php');
  require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php');
  require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php');
- 
+
  $feed = $_GET["feed"];
  $user = $_GET["user"];
- 
+
+ // URL must start with http:// - change it if it starts with feed://
+ if(preg_match("/^feed:\/\/([^\/]+)(.*)$/", $feed, $matches)){
+     $feed = preg_replace("/^feed:\/\//", "http://", $feed);
+ }
+
  // Check if the feed matches a url
  if(!preg_match("/^http:\/\/([^\/]+)(.*)$/", $feed, $matches)){
  	// If not, it is an internal feed
  	$aRSSArray = KTrss::getInternalFeed($user);
  }else{
  	// If it is a url, it is an external feed
- 	$aRSSArray = rss2array($feed);
+ 	// However, sometimes internal documents get added as external feeds
+ 	// Check that the url isn't an internal one.
+ 	global $default;
+    $rootUrl = $default->rootUrl;
+	$bSSL = $default->sslEnabled;
+
+	$sProtocol = ($bSSL) ? 'https' : 'http';
+	$sBaseUrl = $sProtocol.'://'.$_SERVER['HTTP_HOST'].$rootUrl;
+
+ 	$sInternal = $sBaseUrl.'/rss.php';
+ 	if(!(strpos($feed, $sInternal) === FALSE)){
+ 	    // Feed is internal
+ 	    $aRSSArray = KTrss::getExternalInternalFeed($feed, $user);
+ 	}else{
+ 	    $aRSSArray = rss2array($feed);
+ 	}
  }
  if(count($aRSSArray[errors]) > 0){
  	for($i=0;$i
"; } $response .= "
"; - + echo $response; -?> +?> \ No newline at end of file diff --git a/plugins/rssplugin/rss2array.inc.php b/plugins/rssplugin/rss2array.inc.php index e7fa981..92c2b82 100644 --- a/plugins/rssplugin/rss2array.inc.php +++ b/plugins/rssplugin/rss2array.inc.php @@ -143,7 +143,10 @@ xml_parser_free($xml_parser); } - + else if($status == 401) + { + $rss2array_globals[errors][] = "Password authenticated feeds are not supported."; + } else { $rss2array_globals[errors][] = "Can't get feed: HTTP status code $status"; diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index 9a0ba74..79d9595 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -318,6 +318,8 @@ CREATE TABLE `document_link` ( `parent_document_id` int(11) NOT NULL default '0', `child_document_id` int(11) NOT NULL default '0', `link_type_id` int(11) NOT NULL default '0', + `external_url` varchar(255), + `external_name` varchar(50), PRIMARY KEY (`id`), KEY `parent_document_id` (`parent_document_id`), KEY `child_document_id` (`child_document_id`), diff --git a/sql/mysql/upgrade/3.5.2/document_link.sql b/sql/mysql/upgrade/3.5.2/document_link.sql new file mode 100644 index 0000000..20af4b9 --- /dev/null +++ b/sql/mysql/upgrade/3.5.2/document_link.sql @@ -0,0 +1 @@ +ALTER TABLE `document_link` ADD `external_url` varchar(255), ADD `external_name` varchar(50); \ No newline at end of file diff --git a/templates/ktstandard/action/document_links.smarty b/templates/ktstandard/action/document_links.smarty index 34c1281..f99a044 100644 --- a/templates/ktstandard/action/document_links.smarty +++ b/templates/ktstandard/action/document_links.smarty @@ -19,7 +19,7 @@ -{if $links_from || $links_to} +{if $links_from || $links_to || $links_external} {foreach from=$links_from item=link} @@ -35,7 +35,7 @@ {/if} - getId()}&qs[action]=main">{$target->getName()|sanitize} + getId()}&qs[action]=main" title="{"viewDocument"|generateControllerUrl}&qs[fDocumentId]={$target->getId()}&qs[action]=main">{$target->getName()|sanitize} {$type->getName()} {i18n}Linked from this document{/i18n} @@ -55,14 +55,34 @@   {/if} - - getId()}&qs[action]=main">{$target->getName()|sanitize} + getId()}&qs[action]=main" href="{"viewDocument"|generateControllerUrl}&qs[fDocumentId]={$target->getId()}&qs[action]=main">{$target->getName()|sanitize} {$type->getName()} {i18n}Links to this document{/i18n} {/foreach} +{foreach from=$links_external item=link} + +{assign var="type" value=$link->getLinkType()} +{assign var="url" value=$link->getTargetUrl()} +{assign var="name" value=$link->getTargetName()} + + + + {if $write_permission} + {i18n}Delete{/i18n} + {else} +   + {/if} + + + {$link->getTargetName()|sanitize} + {$type->getName()} + {i18n}External link from this document{/i18n} + + +{/foreach} {else} {i18n}There are no links to or from this document.{/i18n} @@ -78,6 +98,10 @@ {if $write_permission} {i18n}Add a new link{/i18n} {i18n}Add a new link{/i18n}. +href="{addQS}action=new&fDocumentId={$context->oDocument->getId()}&fFolderId={$context->oDocument->getFolderId()}{/addQS}">{i18n}Add a new link{/i18n} +

+{i18n}Add a new link{/i18n} +{i18n}Add an external link{/i18n}. {/if} diff --git a/templates/ktstandard/action/link.smarty b/templates/ktstandard/action/link.smarty index a752f6d..d453fae 100644 --- a/templates/ktstandard/action/link.smarty +++ b/templates/ktstandard/action/link.smarty @@ -5,6 +5,14 @@

{i18n}Select a target document to link to.{/i18n}

+{foreach from=$breadcrumbs item=breadcrumb name=bc} + {if !$smarty.foreach.bc.last} + {$breadcrumb.name|sanitize} » + {else} + {$breadcrumb.name|sanitize} + {/if} +{/foreach} +
{$collection->render()}
diff --git a/templates/ktstandard/action/link_external.smarty b/templates/ktstandard/action/link_external.smarty new file mode 100644 index 0000000..823aa55 --- /dev/null +++ b/templates/ktstandard/action/link_external.smarty @@ -0,0 +1,27 @@ +

{i18n}Add External Link{/i18n}

+ + +{if $link_types} +

{i18n}Enter the URL to the external document or site.{/i18n} +

+ + + +
+ +
+
+ + +
+ + + + +
+ +{else} +
+{i18n}No link types are defined. Please ask the administrator to add them.{/i18n}
+ +{/if} \ No newline at end of file diff --git a/templates/ktstandard/action/link_type_select.smarty b/templates/ktstandard/action/link_type_select.smarty index 97a10e5..12110e7 100644 --- a/templates/ktstandard/action/link_type_select.smarty +++ b/templates/ktstandard/action/link_type_select.smarty @@ -1,10 +1,11 @@

{i18n}Add Link{/i18n}

-
+ - - - + + + +
{i18n}Select a link type.{/i18n} @@ -14,8 +15,8 @@ {/foreach}
-
- +
+
diff --git a/templates/ktstandard/links/links_viewlet.smarty b/templates/ktstandard/links/links_viewlet.smarty index ac60179..7accf56 100644 --- a/templates/ktstandard/links/links_viewlet.smarty +++ b/templates/ktstandard/links/links_viewlet.smarty @@ -1,20 +1,29 @@
{if $links_from} -

{i18n}Links from this document{/i18n}

-
    - {foreach from=$links_from item=info} -
  • {i18n}from{/i18n} {$info.name|sanitize} ({$info.type})
  • - {/foreach} -
+

{i18n}Links from this document{/i18n}

+ {/if} {if $links_to} -

{i18n}Links to this document{/i18n}

-
    - {foreach from=$links_to item=info} -
  • {i18n}to{/i18n} {$info.name|sanitize} ({$info.type})
  • - {/foreach} -
+

{i18n}Links to this document{/i18n}

+ + {/if} + + {if $links_external} +

{i18n}External Links from this document{/i18n}

+ {/if}