function renderData($aDataRow) { // only _ever_ show this for documents. if ($aDataRow["type"] === "folder") { return ' '; } $sUrl = KTUtil::kt_url() . '/' . $this->sPluginPath . '/documentPreview.php'; $sDir = KT_DIR; $iDelay = 1000; // milliseconds $iDocumentId = $aDataRow['document']->getId(); $sTitle = _kt('Property Preview'); $sLoading = _kt('Loading...'); $width = 500; // Check for existence of thumbnail plugin if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) { // hook into thumbnail plugin to get display for thumbnail include_once KT_DIR . '/plugins/thumbnails/thumbnails.php'; $thumbnailer = new ThumbnailViewlet(); $thumbnailwidth = $thumbnailer->get_width($iDocumentId); $width += $thumbnailwidth + 30; } //$link = '<a name = "ktP'.$iDocumentId.'" href = "#ktP'.$iDocumentId.'" class="ktAction ktPreview" id = "box_'.$iDocumentId.'" '; $link = '<a href = "#browseForm" class="ktAction ktPreview" id = "box_' . $iDocumentId . '" '; if ($this->sActivation == 'mouse-over') { $sJs = "javascript: this.t = setTimeout('showInfo(\\'{$iDocumentId}\\', \\'{$sUrl}\\', \\'{$sDir}\\', \\'{$sLoading}\\', {$width})', {$iDelay});"; $link .= 'onmouseover = "' . $sJs . '" onmouseout = "clearTimeout(this.t);">'; } else { $sJs = "javascript: showInfo('{$iDocumentId}', '{$sUrl}', '{$sDir}', '{$sLoading}', {$width});"; $link .= 'onclick = "' . $sJs . '" title="' . $sTitle . '">'; } return $link . $sTitle . '</a>'; }
function render() { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status'); $url = KTUtil::kt_url(); $aTemplateData = array('context' => $this, 'indexerName' => $this->indexerName, 'indexerDiagnosis' => $this->indexerDiagnosis, 'extractorDiagnosis' => $this->extractorDiagnosis, 'rootUrl' => $url); return $oTemplate->render($aTemplateData); }
function getDisplayName() { global $default; // The generation of the pdf is done through the PDF Converter plugin. // The PDF's are generated in the background by the document processor if (!empty($this->oDocument)) { $iDocId = $this->oDocument->iId; // Build the display name and url $sDisplayName = _kt('Generate PDF'); $sHostPath = KTUtil::kt_url(); $icon = "<img src='{$sHostPath}/resources/mimetypes/pdf.gif' alt='PDF' border=0 />"; $link = KTUtil::ktLink('action.php', 'ktstandard.pdf.generate', array('fDocumentId' => $this->oDocument->getId(), 'action' => 'pdfdownload')); $sDisplayLink = " <a href=\"{$link}\">{$icon}</a>"; // First check if the pdf has already been generated $dir = $default->pdfDirectory; $file = $dir . '/' . $iDocId . '.pdf'; if (file_exists($file)) { // Display the download link return $sDisplayName . $sDisplayLink; } // If the file does not exist, check if the document has the correct mimetype $converter = new pdfConverter(); $mimeTypes = $converter->getSupportedMimeTypes(); $docType = $this->getMimeExtension(); if ($mimeTypes === true || in_array($docType, $mimeTypes)) { // Display the download link return $sDisplayName . $sDisplayLink; } } else { // If the document is empty then we are probably in the workflow admin - action restrictions section, so we can display the name. return $sDisplayName; } return ''; /* //$cmdpath = KTUtil::findCommand('externalBinary/python'); // Check if openoffice and python are available if($cmdpath != false && file_exists($cmdpath) && !empty($cmdpath)) { $sDocType = $this->getMimeExtension(); // make sure that the selected document is of an acceptable extension foreach($this->aAcceptedMimeTypes as $acceptType){ if($acceptType == $sDocType){ // build server path $sHostPath = KTUtil::kt_url(); // create image $icon = "<img src='{$sHostPath}/resources/mimetypes/pdf.gif' alt='PDF' border=0 />"; $link = KTUtil::ktLink('action.php', 'ktstandard.pdf.generate', array( 'fDocumentId' => $this->oDocument->getId(), 'action' => 'pdfdownload')); return _kt('Generate PDF') . " <a href=\"{$link}\">{$icon}</a>"; } } // If the document is empty then we are probably in the workflow admin - action restrictions section, so we can display the name. if(empty($this->oDocument)){ return _kt('Generate PDF'); } } return ''; */ }
function render() { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/search2/external_resources'); $sUrl = KTUtil::kt_url(); foreach ($this->resources as $k => $v) { $this->resources[$k]['status'] = str_replace(array("\n", _kt('Administrator Guide')), array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $v['status']); } $aTemplateData = array('context' => $this, 'resources' => $this->resources, 'url' => $sUrl); return $oTemplate->render($aTemplateData); }
function takeover() { $oRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin('password.reset.plugin'); $dispatcherURL = $oPlugin->getURLPath('loginResetDispatcher.php'); $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); $url = KTUtil::kt_url() . $dispatcherURL; $url .= !empty($redirect) ? '?redirect=' . $redirect : ''; redirect($url); exit(0); }
function takeover() { $oRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin('password.reset.plugin'); $dispatcherURL = $oPlugin->getURLPath('loginResetDispatcher.php'); $queryString = $_SERVER['QUERY_STRING']; $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); $redirect = urlencode($redirect); $url = KTUtil::kt_url() . $dispatcherURL; $url .= !empty($queryString) ? '?' . $queryString : ''; redirect($url); exit(0); }
function render() { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktstandard/ktwebdavdashlet/dashlet'); $sURL = KTUtil::kt_url(); // Check if this is a commercial installation - before displaying the KT Tools webdav link // Shortcut: Check if the the wintools plugin exists and set to true. // Long way: Check that a license is installed - this is only text so having a license is not a requirement. $isComm = false; if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { $isComm = true; } $webdavUrl = $sURL . '/ktwebdav/ktwebdav.php'; $aTemplateData = array('url' => $sURL, 'webdav_url' => $webdavUrl, 'hasLicense' => $isComm); return $oTemplate->render($aTemplateData); }
function renderData($aDataRow) { // only _ever_ show this for documents. if ($aDataRow["type"] === "folder") { return ' '; } $sUrl = KTUtil::kt_url() . '/' . $this->sPluginPath . '/documentPreview.php'; $sDir = KT_DIR; $iDelay = 1000; // milliseconds $iDocumentId = $aDataRow['document']->getId(); $sTitle = _kt('Property Preview'); $sLoading = _kt('Loading...'); $link = '<a href = "#" class="ktAction ktPreview" id = "box_' . $iDocumentId . '" '; if ($this->sActivation == 'mouse-over') { $sJs = "javascript: this.t = setTimeout('showInfo(\\'{$iDocumentId}\\', \\'{$sUrl}\\', \\'{$sDir}\\', \\'{$sLoading}\\')', {$iDelay});"; $link .= 'onmouseover = "' . $sJs . '" onmouseout = "clearTimeout(this.t);">'; } else { $sJs = "javascript: showInfo('{$iDocumentId}', '{$sUrl}', '{$sDir}', '{$sLoading}');"; $link .= 'onclick = "' . $sJs . '" title="' . $sTitle . '">'; } return $link . $sTitle . '</a>'; }
function do_refreshDashboardStatus() { session_unregister('ExternalResourceStatus'); session_unregister('IndexingStatus'); redirect(KTUtil::kt_url() . '/dashboard.php'); }
function do_checkCookie() { $cookieTest = KTUtil::arrayGet($_COOKIE, "CookieTestCookie", null); $cookieVerify = KTUtil::arrayGet($_REQUEST, 'cookieVerify', null); $url = $_SERVER["PHP_SELF"]; $queryParams = array(); $redirect = strip_tags(KTUtil::arrayGet($_REQUEST, 'redirect')); if (!empty($redirect)) { $queryParams[] = 'redirect=' . urlencode($redirect); } if ($cookieTest !== $cookieVerify) { Session::destroy(); $this->simpleRedirectToMain(_kt('You must have cookies enabled to use the document management system.'), $url, $queryParams); exit(0); } // check for a location to forward to if (!empty($redirect)) { $url = $redirect; // else redirect to the dashboard if there is none } else { $url = KTUtil::kt_url(); $config = KTConfig::getSingleton(); $redirectToBrowse = $config->get('KnowledgeTree/redirectToBrowse', false); $redirectToDashboardList = $config->get('KnowledgeTree/redirectToBrowseExceptions', ''); if ($redirectToBrowse) { $exceptionsList = explode(',', str_replace(' ', '', $redirectToDashboardList)); $user = User::get($_SESSION['userID']); $username = $user->getUserName(); $url .= in_array($username, $exceptionsList) ? '/dashboard.php' : '/browse.php'; } else { $url .= '/dashboard.php'; } } exit(redirect($url)); }
function render() { global $default; $oConfig = KTConfig::getSingleton(); if (empty($this->contents)) { $this->contents = ""; } if (is_string($this->contents) && trim($this->contents) === "") { $this->addError(_kt("This page did not produce any content")); $this->contents = ""; } if (!is_string($this->contents)) { $this->contents = $this->contents->render(); } // if we have no portlets, make the ui a tad nicer. if (empty($this->portlets)) { $this->show_portlets = false; } if (empty($this->title)) { if (!empty($this->breadcrumbDetails)) { $this->title = $this->breadcrumbDetails; } else { if (!empty($this->breadcrumbs)) { $this->title = array_slice($this->breadcrumbs, -1); $this->title = $this->title[0]['label']; } else { if (!empty($this->breadcrumbSection)) { $this->title = $this->breadcrumbSection['label']; } else { $this->title = $this->componentLabel; } } } } $this->userMenu = array(); $sBaseUrl = KTUtil::kt_url(); if (!(PEAR::isError($this->user) || is_null($this->user) || $this->user->isAnonymous())) { if ($oConfig->get("user_prefs/restrictPreferences", false) && !Permission::userIsSystemAdministrator($this->user->getId())) { $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php'); } else { if ($default->enableESignatures) { $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); $heading = _kt('You are attempting to modify Preferences'); $this->userMenu['preferences']['url'] = '#'; $this->userMenu['preferences']['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'dms.administration.accessing_preferences', 'system', '{$sBaseUrl}/preferences.php', 'redirect');"; } else { $this->userMenu['preferences']['url'] = $sBaseUrl . '/preferences.php'; } // $this->userMenu['preferences'] = array('label' => _kt('Preferences'), 'url' => $sBaseUrl.'/preferences.php'); $this->userMenu['preferences']['label'] = _kt('Preferences'); $this->userMenu['aboutkt'] = array('label' => _kt('About'), 'url' => $sBaseUrl . '/about.php'); $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php'); } } else { $this->userMenu['login'] = array('label' => _kt('Login'), 'url' => $sBaseUrl . '/login.php'); } // FIXME we need a more complete solution to navigation restriction if (!is_null($this->menu['administration']) && !is_null($this->user)) { if (!Permission::userIsSystemAdministrator($this->user->getId())) { unset($this->menu['administration']); } } $sContentType = 'Content-type: ' . $this->contentType; if (!empty($this->charset)) { $sContentType .= '; charset=' . $this->charset; } header($sContentType); $savedSearches = SearchHelper::getSavedSearches($_SESSION['userID']); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate($this->template); $aTemplateData = array("page" => $this, "systemversion" => $default->systemVersion, "versionname" => $default->versionName, 'smallVersion' => substr($default->versionName, -17), 'savedSearches' => $savedSearches); if ($oConfig->get("ui/automaticRefresh", false)) { $aTemplateData['refreshTimeout'] = (int) $oConfig->get("session/sessionTimeout") + 3; } // unlike the rest of KT, we use echo here. echo $oTemplate->render($aTemplateData); }
function catchFatalErrors() { ini_set('display_errors', 'On'); $phperror = '><div id="phperror" style="display:none">'; ini_set('error_prepend_string', $phperror); $CustomErrorPage = KTUtil::kt_url() . '/customerrorpage.php'; $phperror = '</div>><form name="catcher" action="' . $CustomErrorPage . '" method="post" ><input type="hidden" name="fatal" value=""></form> <script> document.catcher.fatal.value = document.getElementById("phperror").innerHTML; document.catcher.submit();</script>'; ini_set('error_append_string', $phperror); }
/** * This function generates the email that will be sent for subscription notifications * * @author KnowledgeTree Team * @access public * @param object $oKTNotification: The notification object * @return string $str: The html string that will be sent via email */ function getEmailAlertContent($oKTNotification, $bulk_action = 0) { if ($bulk_action == 0) { $bulk_action = false; } // set up logo and title $rootUrl = KTUtil::kt_url(); $info = $this->_getSubscriptionData($oKTNotification); // set up email text $addFolderText = _kt('The folder "') . $info['object_name'] . _kt('" was added'); $removeSubscribedFolderText = _kt('The folder "') . $info['object_name'] . _kt('" to which you were subscribed, has been removed'); $removeChildFolderText = _kt('The folder "') . $info['object_name'] . _kt('" has been removed'); $addDocumentText = _kt('The document "') . $info['object_name'] . _kt('" was added'); $removeSubscribedDocumentText = _kt('The document "') . $info['object_name'] . _kt('" to which you were subscribed, has been removed'); $removeChildDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been removed'); $modifyDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been changed'); $checkInDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been checked in'); $checkOutDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been checked out'); $moveDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been moved'); $copiedDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been copied'); $archivedDocumentText = _kt('The document "') . $info['object_name'] . _kt('"'); $restoreArchivedDocumentText = _kt('The document "') . $info['object_name'] . _kt('" has been restored by an administrator'); $downloadDocumentText = _kt('The document "') . $info['object_name'] . _kt('"'); $documentAlertText = _kt('An alert on the document "') . $info['object_name'] . _kt('" has been added or modified'); if ($info['location_name'] !== NULL && !$bulk_action) { $addFolderText .= _kt(' to "') . $info['location_name'] . _kt('"'); $removeChildFolderText .= _kt(' from the folder "') . $info['location_name'] . _kt('"'); $addDocumentText .= _kt(' to "') . $info['location_name'] . _kt('"'); $removeChildDocumentText .= _kt(' from the folder "') . $info['location_name'] . _kt('" to which you are subscribed'); $modifyDocumentText .= _kt(' in the folder "') . $info['location_name'] . _kt('"'); $checkInDocumentText .= _kt(', in the folder "') . $info['location_name'] . _kt('"'); $checkOutDocumentText .= _kt(', from the folder "') . $info['location_name'] . _kt('"'); $moveDocumentText .= _kt(' to the folder "') . $info['location_name'] . _kt('"'); $copiedDocumentText .= _kt(' to the folder "') . $info['location_name'] . _kt('"'); $archivedDocumentText .= _kt(' in the folder "') . $info['location_name'] . _kt('" has been archived'); $downloadDocumentText .= _kt(' in the folder "') . $info['location_name'] . _kt('" has been downloaded'); $documentAlertText .= _kt(' in the folder "') . $info['location_name'] . _kt('"'); } if ($bulk_action && $info['event_type'] != "RemoveSubscribedFolder") { $browse = "{$rootUrl}/browse.php?fFolderId={$bulk_action}"; $subFolder = '<a href="' . $browse . '">' . _kt('View Subscription Folder ') . '</a>'; } // set up links switch ($info['event_type']) { case 'AddFolder': $text = $addFolderText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View New Folder') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'RemoveSubscribedFolder': $text = $removeSubscribedFolderText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links = '<a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'RemoveChildFolder': $text = $removeChildFolderText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Folder') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'AddDocument': $text = $addDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'RemoveSubscribedDocument': $text = $removeSubscribedDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links = '<a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'RemoveChildDocument': $text = $removeChildDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links = '<a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'ModifyDocument': $text = $modifyDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'CheckInDocument': $text = $checkInDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'CheckOutDocument': $text = $checkOutDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'MovedDocument': case 'MovedDocument2': $text = $modifyDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View New Location') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'CopiedDocument': case 'CopiedDocument2': $text = $copiedDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'ArchivedDocument': $text = $archivedDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links = '<a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'RestoreArchivedDocument': $text = $restoreArchivedDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'DownloadDocument': $text = $downloadDocumentText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; if (!$bulk_action) { $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; } $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; break; case 'ModifyDocumentAlert': $text = $documentAlertText; $url = $rootUrl . '/notify.php?id=' . $info['notify_id']; $links = '<a href="' . $url . '">' . _kt('View Document') . '</a>'; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=clear'; $links .= ' | <a href="' . $url . '">' . _kt('Clear Alert') . '</a>'; $url = $rootUrl . '/notify.php?id=' . $info['notify_id'] . '¬ify_action=viewall'; $links .= ' | <a href="' . $url . '">' . _kt('View all alerts on this document') . '</a>'; } if ($info['actor_name'] !== NULL && $info['event_type'] != 'RestoredArchivedDocument') { $text .= _kt(', by ') . $info['actor_name']; } // we can re-use the normal template. // however, we need to wrap it - no need for a second template here. //$str = '<html><body>' . $this->getNotificationAlertContent($oKTNotification) . '</body></html>'; if (!$bulk_action) { $str = '<br />     <b>' . _kt('Subscription notification') . ': ' . $this->_eventTypeNames[$info['event_type']] . '</b> <br /> <br />     ' . $text . ' <br /> <br />     ' . $links . ' <br /> <br />'; } else { $str = '<br /> <br /> ' . $subFolder . '  ' . $links . ' <br /> <br />'; } return $str; }
public function renderThumbnail($documentId) { // Set up the template $oKTTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oKTTemplating->loadTemplate('thumbnail_viewlet'); if (is_null($oTemplate)) { return ''; } // Check that the thumbnail exists on disk global $default; $varDir = $default->varDirectory; $thumbnailCheck = $varDir . '/thumbnails/' . $documentId . '.jpg'; // Use correct slashes for windows if (strpos(PHP_OS, 'WIN') !== false) { $thumbnailCheck = str_replace('/', '\\', $thumbnailCheck); } // if the thumbnail doesn't exist try to create it if (!file_exists($thumbnailCheck)) { $thumbnailer = new thumbnailGenerator(); $thumbnailer->setDocument($this->oDocument); $thumbnailer->processDocument(); // if it still doesn't exist, return an empty string if (!file_exists($thumbnailCheck)) { return ''; } } // check for existence and status of the instant view plugin $url = ''; if (KTPluginUtil::pluginIsActive('instaview.processor.plugin')) { require_once KTPluginUtil::getPluginPath('instaview.processor.plugin') . 'instaViewLinkAction.php'; $ivLinkAction = new instaViewLinkAction(); $url = $ivLinkAction->getViewLink($documentId, 'document'); } // Get the url to the thumbnail and render it // Ensure url has correct slashes $sHostPath = KTUtil::kt_url(); $plugin_path = KTPluginUtil::getPluginPath('thumbnails.generator.processor.plugin'); $thumbnailUrl = $plugin_path . 'thumbnail_view.php?documentId=' . $documentId; $thumbnailUrl = str_replace('\\', '/', $thumbnailUrl); $thumbnailUrl = str_replace(KT_DIR, $sHostPath, $thumbnailUrl); $oTemplate->setData(array('thumbnail' => $thumbnailUrl, 'url' => $url)); return $oTemplate->render(); }
function arrayToXML($aItems) { $hostPath = KTUtil::kt_url() . '/'; $head = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n\n \t <rss version=\"2.0\">\n\n \t <channel>\n\n \t <title>" . APP_NAME . " RSS</title>\n\n \t <copyright>(c) 2008 KnowledgeTree Inc.</copyright>\n\n \t <link>" . $hostPath . "</link>\n\n \t <description>KT-RSS</description>\n\n \t <image>\n\n \t <title>" . APP_NAME . " RSS</title>\n\n \t <width>140</width>\n\n \t <height>28</height>\n \t <link>" . $hostPath . "</link>\n\n \t <url>" . $hostPath . "resources/graphics/ktlogo_rss.png</url>\n\n \t </image>\n"; $feed = ''; foreach ($aItems as $aItem) { $aItemHead = $aItem[0][0]; $aItemList = $aItem[1]; if ($aItem[0][itemType] == 'folder') { $sTypeSelect = 'folder.transactions&fFolderId'; } elseif ($aItem[0][itemType] == 'document') { $sTypeSelect = 'document.transactionhistory&fDocumentId'; } if ($aItem[0][0][owner]) { $owner = $aItem[0][0][owner]; } else { $owner = _kt('None'); } $type = ''; if ($aItem[0][0][type]) { $type = '<tr><td>Document type: ' . $aItem[0][0][type] . "</td>\n<td></td></tr>\n"; } if ($aItem[0][0][workflow_status]) { $workflow = $aItem[0][0][workflow_status]; } else { $workflow = _kt('No Workflow'); } $xmlItemHead = "<item>\n\n\t \t <title>" . htmlspecialchars($aItem[0][0][name], ENT_QUOTES, 'UTF-8') . "</title>\n\n\t \t <link>" . $hostPath . "action.php?kt_path_info=ktcore.actions." . htmlspecialchars($sTypeSelect, ENT_QUOTES, 'UTF-8') . "=" . $aItem[0][0]['id'] . "</link>\n\n\t \t <description>\n"; $htmlItem = "<table border='0' width='90%'>\n\n\t \t <tr>\n\n\t \t <td width='5%' height='16px'>\n\t \t <a href='" . $hostPath . "action.php?kt_path_info=ktcore.actions." . $sTypeSelect . "=" . $aItem[0][0][id] . "' >\n\t \t <img src='" . $aItem[0][mimeTypeIcon] . "' align='left' height='16px' width='16px' alt='' border='0' /></a>\n\t \t </td>\n\n\t \t <td align='left'> " . $aItem[0][mimeTypeFName] . "</td>\n\n\t \t </tr>\n\n\t \t <tr>\n\n \t \t <td colspan='2'>\n\n \t \t " . ucfirst($aItem[0]['itemType']) . " Information (ID: " . $aItem[0][0][id] . ")</>\n\n \t \t <hr>\n\n\n \t \t <table width='95%'>\n\n \t \t <tr>\n\n \t \t <td>" . _kt('Filename') . ": " . htmlspecialchars($aItem[0][0][filename], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>" . _kt('Author') . ": " . htmlspecialchars($aItem[0][0][author], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>" . _kt('Owner') . ": " . htmlspecialchars($owner, ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t <td></td>\n\n \t \t </tr>\n\n \t \t " . $type . "\n\n \t \t <tr>\n\n \t \t <td>" . _kt('Workflow status') . ": " . htmlspecialchars($workflow, ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t <td></td>\n\n \t \t </tr>\n\n \t \t </table><br>\n\n\n \t \t " . _kt('Transaction Summary (Last 4)') . "\n\n \t \t <hr>\n\n\n\t \t <table width='100%'>\n"; foreach ($aItem[1] as $item) { $htmlItem .= "<tr>\n\n \t \t <td>" . $item[type] . " name:</td>\n\n \t \t <td>" . htmlspecialchars($item[name], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>Path:</td>\n\n \t \t <td>" . htmlspecialchars($item[fullpath], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>Transaction:</td>\n\n \t \t <td>" . htmlspecialchars($item[transaction_name], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>Comment:</td>\n\n \t \t <td>" . htmlspecialchars($item[comment], ENT_QUOTES, 'UTF-8') . "</td>\n\n\t\t\t\t\t\t\t\t\t\t\t</tr>\n\n\t\t\t\t\t\t\t\t\t\t\t<tr>\n"; if ($item[version]) { $htmlItem .= "<td>Version:</td>\n\n \t \t <td>" . $item[version] . "</td>\n"; } $htmlItem .= "</tr>\n\n \t \t <tr>\n\n \t \t <td>Date:</td>\n\n \t \t <td>" . $item[datetime] . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td>User:</td>\n\n \t \t <td>" . htmlspecialchars($item[user_name], ENT_QUOTES, 'UTF-8') . "</td>\n\n \t \t </tr>\n\n \t \t <tr>\n\n \t \t <td colspan='2'><hr width='100' align='left'></td>\n\n \t \t </tr>\n"; } $htmlItem .= "</table>\n\n </td>\n\n </tr>\n\n </table>"; $xmlItemFooter = "</description>\n</item>\n"; // Use htmlspecialchars to allow html tags in the xml. $htmlItem = htmlspecialchars($htmlItem, ENT_QUOTES, 'UTF-8'); $feed .= $xmlItemHead . $htmlItem . $xmlItemFooter; } $footer = "</channel>\n</rss>\n"; return $head . $feed . $footer; }
/** * Dispatch function */ function do_main() { // Load Templating Engine $oTemplating =& KTTemplating::getSingleton(); // Set Template to use $oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status'); // Do a runtime Service Resource Check $checker = new ResourceChecker(); $checker->check(); // Get Results $serviceErrors = KTUtil::getSystemSetting('externalResourceIssues'); $serviceErrors = unserialize($serviceErrors); // Array to Hold Items not working $this->serviceErrors = array(); // A reference array to use with extractors that depend on the service $errorReference = array(); if (count($serviceErrors) > 0) { // Add Service Errors foreach ($serviceErrors as $error) { $this->serviceErrors[$error['name']] = array('name' => $error['name'], 'status' => $error['status'], 'help' => IndexingHelp::getHelp($error['name'])); // Create Reference to the array $errorReference[$error['status']] =& $this->serviceErrors[$error['name']]; } } // --------------------------- // Do a run time check for extractors not working $indexer = Indexer::get(); $extractorDiagnosis = $indexer->diagnoseExtractors(); // Create an Array to store errors $this->extractorErrors = array(); if (count($extractorDiagnosis > 0)) { foreach ($extractorDiagnosis as $extractor => $props) { // Check if Extractor fault is due to a service not running if (array_key_exists($props['diagnosis'], $errorReference)) { // One service may affect multiple extractors $errorReference[$props['diagnosis']]['alsoaffects'] = array(array('extractor' => $props['name'], 'affectedtypes' => IndexingHelp::affectedTypes($extractor))); } else { // Else list as normal extractor error $this->extractorErrors[$extractor] = array('name' => $props['name'], 'status' => $props['diagnosis'], 'help' => IndexingHelp::getHelp($extractor), 'affectedtypes' => IndexingHelp::affectedTypes($extractor)); } } } // Create URL to Send to Template $url = KTUtil::kt_url(); // Prepare Template Data $aTemplateData = array('context' => $this, 'serviceErrors' => $this->serviceErrors, 'extractorErrors' => $this->extractorErrors, 'url' => $url); // Send to template and render return $oTemplate->render($aTemplateData); }
/** * This method sets up the server url * */ public function setUp() { $url = KTUtil::kt_url(); $this->rootUrl = $url . '/ktwebservice/KTWebService.php?'; }
function do_performaction() { $config = KTConfig::getSingleton(); $useQueue = $config->get('export/useDownloadQueue', true); // Create the export code $this->sExportCode = KTUtil::randomString(); $_SESSION['exportcode'] = $this->sExportCode; // Save the return url in session so it is not lost when doing the download $folderurl = $this->getReturnUrl(); $_SESSION['export_return_url'] = $folderurl; $download_url = KTUtil::addQueryStringSelf("action=downloadZipFile&fFolderId={$this->oFolder->getId()}&exportcode={$this->sExportCode}"); if ($useQueue) { $result = parent::do_performaction(); $url = KTUtil::kt_url() . '/presentation/lookAndFeel/knowledgeTree/bulkdownload/downloadTask.php'; $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download'); $aParams = array('folder_url' => $folderurl, 'url' => $url, 'code' => $this->sExportCode, 'download_url' => $download_url); return $oTemplate->render($aParams); } $this->oZip = new ZipFolder('', $this->sExportCode); $res = $this->oZip->checkConvertEncoding(); if (PEAR::isError($res)) { $this->addErrorMessage($res->getMessage()); return $sReturn; } $this->startTransaction(); $result = parent::do_performaction(); $sExportCode = $this->oZip->createZipFile(); if (PEAR::isError($sExportCode)) { $this->addErrorMessage($sExportCode->getMessage()); $this->rollbackTransaction(); return $sReturn; } $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP())); $this->commitTransaction(); $str = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>'; $str .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>'; $str .= sprintf('<p>' . _kt('Once your download is complete, click <a href="%s">here</a> to return to the original folder') . "</p>\n", $folderurl); $str .= sprintf('<script language="JavaScript"> function kt_bulkexport_redirect() { document.location.href = "%s"; } callLater(5, kt_bulkexport_redirect); </script>', $download_url); return $str; }
$sub_url = trim($sub_url); $sub_url = trim($sub_url, '/'); if (empty($sub_url)) { $oDispatcher = new AdminSplashDispatcher(); } else { $oRegistry =& KTAdminNavigationRegistry::getSingleton(); if ($oRegistry->isRegistered($sub_url)) { $oDispatcher = $oRegistry->getDispatcher($sub_url); $aParts = explode('/', $sub_url); $oRegistry =& KTAdminNavigationRegistry::getSingleton(); $aCategory = $oRegistry->getCategory($aParts[0]); $oDispatcher->aBreadcrumbs = array(); $oDispatcher->aBreadcrumbs[] = array('action' => 'administration', 'name' => _kt('Administration')); $oDispatcher->aBreadcrumbs[] = array('name' => $aCategory['title'], 'url' => KTUtil::ktLink('admin.php', $aParts[0])); } else { // FIXME (minor) redirect to no-suburl? $oDispatcher = new AdminSplashDispatcher(); $oDispatcher->category = $sub_url; } } // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes global $main; global $default; if ($default->enableAdminSignatures && $_SESSION['electronic_signature_time'] < time()) { $sBaseUrl = KTUtil::kt_url(); $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); $heading = _kt('You are attempting to access Administration'); $main->setBodyOnload("javascript: showSignatureForm('{$sUrl}', '{$heading}', 'dms.administration.administration_section_access', 'admin', '{$sBaseUrl}/browse.php', 'close');"); } $oDispatcher->dispatch(); // we _may_ be redirected at this point (see KTAdminNavigation)
function do_main() { $config = KTConfig::getSingleton(); $useQueue = $config->get('export/useDownloadQueue', true); // Create the export code $exportCode = KTUtil::randomString(); $this->oZip = new ZipFolder('', $exportCode); if (!$this->oZip->checkConvertEncoding()) { redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $bNoisy = $config->get("tweaks/noisyBulkOperations"); $bNotifications = $config->get('export/enablenotifications', 'on') == 'on' ? true : false; $sCurrentFolderId = $this->oFolder->getId(); $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $sCurrentFolderId, $exportCode)); $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); if ($useQueue) { DownloadQueue::addItem($exportCode, $sCurrentFolderId, $sCurrentFolderId, 'folder'); $task_url = KTUtil::kt_url() . '/bin/ajaxtasks/downloadTask.php'; $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download'); $aParams = array('folder_url' => $folderurl, 'url' => $task_url, 'code' => $exportCode, 'download_url' => $url); return $oTemplate->render($aParams); } // Get all folders and sub-folders $sWhereClause = "parent_folder_ids = '{$sCurrentFolderId}' OR\n parent_folder_ids LIKE '{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId}'"; $aFolderList = $this->oFolder->getList($sWhereClause); // Get any folder shortcuts within the folders $aLinkedFolders = KTBulkAction::getLinkingEntities($aFolderList); $aFolderList = array_merge($aFolderList, $aLinkedFolders); // Add the folders to the zip file $aFolderObjects = array($sCurrentFolderId => $this->oFolder); if (!empty($aFolderList)) { foreach ($aFolderList as $oFolderItem) { $itemId = $oFolderItem->getId(); $linkedFolder = $oFolderItem->getLinkedFolderId(); // If the folder has been added or is a shortcut then skip // The shortcut folders don't need to be added as their targets will be added. if (array_key_exists($itemId, $aFolderObjects) || !empty($linkedFolder)) { continue; } $this->oZip->addFolderToZip($oFolderItem); $aFolderObjects[$oFolderItem->getId()] = $oFolderItem; } } // Get the list of folder ids $aFolderIds = array_keys($aFolderObjects); // Get all documents in the folder list $aQuery = $this->buildQuery($aFolderIds); $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id'); if (PEAR::isError($aDocumentIds)) { $this->addErrorMessage(_kt('There was a problem exporting the documents: ') . $aDocumentIds->getMessage()); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } // Redirect if there are no documents and no folders to export if (empty($aDocumentIds) && empty($aFolderList)) { $this->addErrorMessage(_kt("No documents found to export")); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $this->oPage->template = "kt3/minimal_page"; $this->handleOutput(""); // Add the documents to the zip file if (!empty($aDocumentIds)) { foreach ($aDocumentIds as $iId) { $oDocument = Document::get($iId); $sFolderId = $oDocument->getFolderID(); if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.view')) { $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be exported as it is restricted by the workflow.')); continue; } $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId); if ($bNoisy) { $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array()); $oDocumentTransaction->create(); } // fire subscription alerts for the downloaded document if ($bNotifications) { //$oSubscriptionEvent = new SubscriptionEvent(); //$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); } $this->oZip->addDocumentToZip($oDocument, $oFolder); } } $sExportCode = $this->oZip->createZipFile(TRUE); $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP())); $sReturn = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>'; $sReturn .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>'; $sReturn .= '<p>' . _kt('Once your download is complete, click <a href="' . $folderurl . '">here</a> to return to the original folder') . "</p>\n"; print $sReturn; printf("</div></div></body></html>\n"); printf('<script language="JavaScript"> function kt_bulkexport_redirect() { document.location.href = "%s"; } callLater(2, kt_bulkexport_redirect); </script>', $url); exit(0); }
<?php require_once '../../config/dmsDefaults.php'; //header('Content-Type: text/xml'); $url = KTUtil::kt_url(); $search_url = $url . "/search2.php?action=process&txtQuery=GeneralText+contains+%22{searchTerms}%22"; $xml .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $xml = "<OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\">\r\n"; $xml .= "<ShortName>KnowledgeTree " . _kt('Quick Search') . "</ShortName>\r\n"; $xml .= "<Description>" . _kt('Search metadata and content on KnowledgeTree') . "</Description>\r\n"; $xml .= "<Image width=\"16\" height=\"16\" type=\"image/x-icon\">{$url}/resources/favicon.ico</Image>\r\n"; $xml .= "<Url type=\"text/html\" template=\"{$search_url}\"/>\r\n"; $xml .= "<OutputEncoding>UTF-8</OutputEncoding>\n"; $xml .= "<InputEncoding>UTF-8</InputEncoding>\n"; $xml .= "</OpenSearchDescription>"; print $xml;