function display($display_type = null) { if ($this->getFileName() && !isset($this->_image)) { $this->_default_display = 'ArticleDocumentLink_Display'; } return parent::display($display_type); }
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); $aLinks = DocumentLink::getList(sprintf("link_type_id = %d", $link_id)); if (!empty($aLinks)) { foreach ($aLinks as $oLink) { $oLink->delete(); } } $oLinkType->delete(); // technically, this is a bad thing $count += 1; } //$oLinkType =& LinkType::createFromArray(array("sName" => $name, "sDescription" => $description)); $this->successRedirectToMain($count . " " . _kt("Link types deleted.")); }
/** * Creates a link between two documents * * @author KnowledgeTree Team * @access public * @param KTAPI_Document $document The document object * @param string $type The link relationship type: depended on|Attachment|Reference|Copy|Default * @return PEAR_Error|void Returns nothing on success | a PEAR_Error object on failure * */ function link_document($document, $type) { $typeid = $this->ktapi->get_link_type_id($type); if (PEAR::isError($typeid)) { return $typeid; } $link = new DocumentLink($this->get_documentid(), $document->get_documentid(), $typeid); $created = $link->create(); if ($created === false || PEAR::isError($created)) { return new PEAR_Error(_kt('Could not create link')); } }
function &getDocLinkRef() { require_once 'AMP/Content/Article/DocumentLink.inc.php'; $empty_value = false; if (!($doc = $this->getDocumentLink())) { return $empty_value; } $doclink = new DocumentLink(); $doclink->setFile($doc, $this->getDocLinkType()); return $doclink; }
function _addFileLink($data, $fieldname) { if (!(isset($data[$fieldname]) && $data[$fieldname])) { return null; } require_once 'AMP/Content/Article/DocumentLink.inc.php'; $fileLink = new DocumentLink($data[$fieldname]); if (strpos($this->fields[$fieldname]['label'], $data[$fieldname]) === FALSE) { $this->setFieldLabel($fieldname, $this->fields[$fieldname]['label'] . $fileLink->display('div')); } $this->form->setDefaults(array($fieldname . '_value' => $data[$fieldname])); }