function do_main()
 {
     $this->oPage->setShowPortlets(false);
     // retrieve action items for the user.
     // FIXME what is the userid?
     $oDashletRegistry =& KTDashletRegistry::getSingleton();
     $aDashlets = $oDashletRegistry->getDashlets($this->oUser);
     $this->sSection = "dashboard";
     $this->oPage->setBreadcrumbDetails(_kt("Home"));
     $this->oPage->title = _kt("Dashboard");
     // simplistic improvement over the standard rendering:  float half left
     // and half right.  +Involves no JS -can leave lots of white-space at the bottom.
     $aDashletsLeft = array();
     $aDashletsRight = array();
     $i = 0;
     foreach ($aDashlets as $oDashlet) {
         if ($i == 0) {
             $aDashletsLeft[] = $oDashlet;
         } else {
             $aDashletsRight[] = $oDashlet;
         }
         $i += 1;
         $i %= 2;
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("kt3/olddashboard");
     $aTemplateData = array("context" => $this, "dashlets_left" => $aDashletsLeft, "dashlets_right" => $aDashletsRight);
     return $oTemplate->render($aTemplateData);
 }
 function thumbnailsPlugin($sFilename = null)
 {
     $res = parent::KTPlugin($sFilename);
     $this->sFriendlyName = _kt('Thumbnail Generator');
     $this->sSQLDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
     return $res;
 }
 public function __construct()
 {
     $config = KTConfig::getSingleton();
     $params = $config->get('extractorParameters/pstotext', '"{source}" > "{target}"');
     $this->ignorePS = $config->get('indexer/ignorePS', false);
     parent::__construct('externalBinary', 'pstotext', 'pstotext', _kt('PostScript Text Extractor'), $params);
 }
Exemple #4
0
 function do_main()
 {
     $notifications = (array) KTNotification::getList(array("user_id = ?", $this->oUser->getId()));
     $num_notifications = count($notifications);
     $PAGE_SIZE = 5;
     $page = (int) KTUtil::arrayGet($_REQUEST, 'page', 0);
     $page_count = ceil($num_notifications / $PAGE_SIZE);
     if ($page >= $page_count) {
         $page = $page_count - 1;
     }
     if ($page < 0) {
         $page = 0;
     }
     // slice the notification array.
     $notifications = array_slice($notifications, $page * $PAGE_SIZE, $PAGE_SIZE);
     // prepare the batch html.  easier to do this here than in the template.
     $batch = array();
     for ($i = 0; $i < $page_count; $i++) {
         if ($i == $page) {
             $batch[] = sprintf("<strong>%d</strong>", $i + 1);
         } else {
             $batch[] = sprintf('<a href="%s">%d</a>', KTUtil::addQueryStringSelf($this->meldPersistQuery(array("page" => $i), "main", true)), $i + 1);
         }
     }
     $batch_html = implode(' &middot; ', $batch);
     $count_string = sprintf(_kt("Showing Notifications %d - %d of %d"), $page * $PAGE_SIZE + 1, min(($page + 1) * $PAGE_SIZE, $num_notifications), $num_notifications);
     $this->oPage->setTitle(_kt("Items that require your attention"));
     $oTemplate =& $this->oValidator->validateTemplate("ktcore/misc/notification_overflow");
     $oTemplate->setData(array('count_string' => $count_string, 'batch_html' => $batch_html, 'notifications' => $notifications));
     return $oTemplate->render();
 }
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_migration');
     $config = KTConfig::getSingleton();
     $batchDocuments = $config->get('indexer/batchMigrateDocuments');
     $migratedDocuments = KTUtil::getSystemSetting('migratedDocuments', 0);
     $migratingDocuments = $this->migratingDocuments;
     $migrationStart = KTUtil::getSystemSetting('migrationStarted');
     if (is_null($migrationStart)) {
         $migrationStartString = _kt('Not started');
         $migrationPeriod = _kt('N/A');
         $estimatedTime = _kt('Unknown');
         $estimatedPeriod = $estimatedTime;
     } else {
         $migrationStartString = date('Y-m-d H:i:s', $migrationStart);
         $migrationTime = KTUtil::getSystemSetting('migrationTime', 0);
         $migrationPeriod = KTUtil::computePeriod($migrationTime, '');
         // Cannot divide by zero so make it 1
         $divMigratedDocuments = $migratedDocuments > 0 ? $migratedDocuments : 1;
         $timePerDocument = $migrationTime / $divMigratedDocuments;
         $estimatedPeriod = $timePerDocument * $migratingDocuments;
         $estimatedTime = date('Y-m-d H:i:s', $migrationStart + $estimatedPeriod);
         $estimatedPeriod = KTUtil::computePeriod($estimatedPeriod, '');
     }
     $aTemplateData = array('context' => $this, 'batchDocuments' => $batchDocuments, 'batchPeriod' => 'Periodically', 'migrationStart' => $migrationStartString, 'migrationPeriod' => $migrationPeriod, 'migratedDocuments' => $migratedDocuments, 'migratingDocuments' => $migratingDocuments, 'estimatedTime' => $estimatedTime, 'estimatedPeriod' => $estimatedPeriod);
     return $oTemplate->render($aTemplateData);
 }
 /**
  * Take care of getting rid of any active resources.
  */
 function close()
 {
     if (is_null($this->fh)) {
         return PEAR::raiseError(_kt('Not open'));
     }
     return fclose($this->fh);
 }
 public function diagnose()
 {
     if (!function_exists('exif_read_data')) {
         return sprintf(_kt('The Exif extractor requires the module exif php extension. Please include this in the php.ini.'));
     }
     return null;
 }
 public function __construct()
 {
     parent::__construct('modified_user_id', 'documents', _kt('Modified By'));
     $this->setAlias('ModifiedBy');
     $this->joinTo('users', 'id');
     $this->matchField('name');
 }
 protected function exec($cmd)
 {
     global $default;
     $res = parent::exec($cmd);
     if (false === $res && (strpos($this->output, 'Copying of text from this document is not allowed') !== false || strpos($this->output, 'Incorrect password') !== false)) {
         $this->output = '';
         file_put_contents($this->targetfile, _kt('Security properties on the PDF document prevent text from being extracted.'));
         $default->log->info('Security properties on the PDF document prevent text from being extracted.');
         return true;
     }
     if (false === $res && strpos($this->output, 'PDF file is damaged') !== false) {
         $this->output = '';
         $default->log->info('PDF file is damaged');
         return true;
     }
     if (false === $res && strpos($this->output, '(continuing anyway)') !== false) {
         $this->output = '';
         return true;
     }
     if (false === $res && strpos($this->output, 'font') !== false) {
         $this->output = '';
         return true;
     }
     if (filesize($this->targetfile) > 0) {
         $this->output = '';
         return true;
     }
     return $res;
 }
 public function __construct()
 {
     parent::__construct('workflow_state_id', 'document_metadata_version', _kt('Workflow State'));
     $this->setAlias('WorkflowState');
     $this->joinTo('workflow_states', 'id');
     $this->matchField('name');
 }
 public function __construct()
 {
     parent::__construct('checked_out_user_id', 'documents', _kt('Checked Out By'));
     $this->setAlias('CheckedOutBy');
     $this->joinTo('users', 'id');
     $this->matchField('name');
 }
 public function __construct()
 {
     parent::__construct('document_type_id', 'document_metadata_version', _kt('Document Type'));
     $this->setAlias('DocumentType');
     $this->joinTo('document_types_lookup', 'id');
     $this->matchField('name');
 }
 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator()) {
         return false;
     }
     $indexerDiagnosis = KTUtil::getSystemSetting('indexerDiagnostics');
     $extractorDiagnosis = KTUtil::getSystemSetting('extractorDiagnostics');
     if (!empty($indexerDiagnosis)) {
         $indexerDiagnosis = unserialize($indexerDiagnosis);
     }
     if (!empty($extractorDiagnosis)) {
         $extractorDiagnosis = unserialize($extractorDiagnosis);
     }
     if (empty($indexerDiagnosis) && empty($extractorDiagnosis)) {
         return false;
     }
     $this->indexerDiagnosis = $indexerDiagnosis;
     $this->extractorDiagnosis = array();
     $result = array();
     foreach ($extractorDiagnosis as $class => $diagnosis) {
         $name = $diagnosis['name'];
         $diag = $diagnosis['diagnosis'];
         $result[$diag][] = $name;
     }
     foreach ($result as $problem => $indexers) {
         if (empty($problem)) {
             continue;
         }
         $this->extractorDiagnosis[] = array('problem' => $problem, 'indexers' => $indexers);
     }
     $this->indexerDiagnosis = str_replace(array("\n", 'Administrator Guide'), array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $this->indexerDiagnosis);
     return true;
 }
 public function __construct()
 {
     parent::__construct('mime_id', 'document_content_version', _kt('Mime Type'));
     $this->setAlias('MimeType');
     $this->joinTo('mime_types', 'id');
     $this->matchField('mimetypes');
 }
 public function __construct()
 {
     parent::__construct('full_path', 'documents', _kt('Folder'));
     $this->setAlias('Folder');
     // do want values quoted for folder db search
     /*$this->isValueQuoted(false);*/
 }
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("transactions"));
     $this->oPage->setTitle(_kt('Folder transactions'));
     $folder_data = array();
     $folder_data["folder_id"] = $this->oFolder->getId();
     $this->oPage->setSecondaryTitle($this->oFolder->getName());
     $aTransactions = array();
     // FIXME do we really need to use a raw db-access here?  probably...
     $sQuery = "SELECT DTT.name AS transaction_name, FT.transaction_namespace, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC";
     $aParams = array($this->oFolder->getId());
     $res = DBUtil::getResultArray(array($sQuery, $aParams));
     if (PEAR::isError($res)) {
         var_dump($res);
         // FIXME be graceful on failure.
         exit(0);
     }
     // FIXME roll up view transactions
     $aTransactions = $res;
     // Set the namespaces where not in the transactions lookup
     foreach ($aTransactions as $key => $transaction) {
         if (empty($transaction['transaction_name'])) {
             $aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']);
         }
     }
     // render pass.
     $this->oPage->title = _kt("Folder History");
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history");
     $aTemplateData = array("context" => $this, "folder_id" => $folder_id, "folder" => $this->oFolder, "transactions" => $aTransactions);
     return $oTemplate->render($aTemplateData);
 }
 /**
  * Method to get help associated with Document Indexer Service
  * @return string help message
  */
 private function __DocumentIndexer()
 {
     $str = _kt('This could be due to the indexer not having been started, OR not configured correctly');
     $str .= '</li><li>';
     $str .= _kt('For more information, please see');
     $str .= ': <a href="http://wiki.knowledgetree.com/Troubleshooting_the_Document_Indexer">http://wiki.knowledgetree.com/Troubleshooting_the_Document_Indexer</a>';
     return $str;
 }
 function pdfConverterPlugin($sFilename = null)
 {
     $res = parent::KTPlugin($sFilename);
     $this->sFriendlyName = _kt('Document PDF Converter');
     $this->dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     $this->sSQLDir = $this->dir . 'sql' . DIRECTORY_SEPARATOR;
     return $res;
 }
 function getDiagnostic()
 {
     $sCommand = $this->findLocalCommand();
     // can't find the local command.
     if (empty($sCommand)) {
         return sprintf(_kt('Unable to find required command for indexing.  Please ensure that <strong>%s</strong> is installed and in the %s Path.  For more information on indexers and helper applications, please <a href="%s">visit the %s site</a>.'), $this->command, APP_NAME, $this->support_url, APP_NAME);
     }
     return null;
 }
Exemple #20
0
 function &retrieveList($sCode)
 {
     $sList = KTUtil::arrayGet($_SESSION['ktentitylists'], $sCode, False);
     if ($sList === False) {
         return PEAR::raiseError(_kt('No such KTEntityList'));
     }
     $oList = unserialize($sList);
     return $oList;
 }
 function setup()
 {
     $this->registerTrigger('add', 'postValidate', 'KTWADAddTrigger', 'ktstandard.triggers.workflowassociation.addDocument');
     $this->registerTrigger('moveDocument', 'postValidate', 'KTWADMoveTrigger', 'ktstandard.triggers.workflowassociation.moveDocument');
     $this->registerTrigger('copyDocument', 'postValidate', 'KTWADCopyTrigger', 'ktstandard.triggers.workflowassociation.copyDocument');
     $this->registerTrigger('edit', 'postValidate', 'KTWADEditTrigger', 'ktstandard.triggers.workflowassociation.editDocument');
     $this->registerAdminPage('workflow_allocation', 'WorkflowAllocationSelection', 'documents', _kt('Automatic Workflow Assignments'), _kt('Configure how documents are allocated to workflows.'), 'workflow/adminpage.php');
     $this->registeri18n('knowledgeTree', KT_DIR . '/i18n');
 }
 function renderDocumentLink($aDataRow)
 {
     $aOptions = $this->getOptions();
     $fParentDocId = KTUtil::arrayGet(KTUtil::arrayGet($aOptions, 'qs_params', array()), 'fDocumentId', False);
     if ((int) $aDataRow["document"]->getId() === (int) $fParentDocId) {
         return htmlentities($aDataRow["document"]->getName(), ENT_QUOTES, 'UTF-8') . ' <span class="descriptiveText">(' . _kt('you cannot link to the source document') . ')';
     } else {
         return parent::renderDocumentLink($aDataRow);
     }
 }
 /**
  * Dispatch function
  */
 function do_main()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Indexer Statistics'));
     $indexer = Indexer::get();
     $stats = $indexer->getIndexStatistics();
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_statistics');
     $aTemplateData = array('context' => $this, 'stats' => $stats);
     return $oTemplate->render($aTemplateData);
 }
 /**
  * Dispatch function
  */
 function do_main()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Indexer Statistics'));
     $stats = KTUtil::getSystemSetting('indexerStats');
     $this->stats = unserialize($stats);
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_statistics');
     $aTemplateData = array('context' => $this, 'stats' => $this->stats);
     return $oTemplate->render($aTemplateData);
 }
 function do_main()
 {
     if (!$this->oDocument->getIsCheckedOut()) {
         $this->oDocument->setImmutable(true);
         $this->oDocument->update();
         controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
     } else {
         $this->addErrorMessage(_kt('Document is checked out and cannot be made immutable'));
         controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
     }
 }
 function &getValidatorByNamespace($sNamespace)
 {
     $aInfo = KTUtil::arrayGet($this->validators, $sNamespace);
     if (empty($aInfo)) {
         return PEAR::raiseError(sprintf(_kt('No such validator: %s'), $sNamespace));
     }
     if (!empty($aInfo['file'])) {
         require_once $aInfo['file'];
     }
     return new $aInfo['class']();
 }
 public function __construct()
 {
     /*
      * Constructing the object like this allows for easy multiple joins
      * on the same column in the same table
      */
     parent::__construct('id', 'document_metadata_version', _kt('Any Metadata'));
     $this->setAlias('Metadata');
     $this->joinTo('document_fields_link', 'metadata_version_id');
     $this->matchField('value');
 }
 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 TagCloudPortlet($oUser = NULL, $sTag = NULL)
 {
     if (empty($oUser)) {
         $iUserId = $_SESSION['userID'];
         $oUser = User::get($iUserId);
     }
     $this->oUser = $oUser;
     $this->sTag = $sTag;
     $title = _kt('Tag Cloud');
     parent::KTPortlet($title);
 }
 private static function init()
 {
     // this isn't really called, but used to help with translation.
     _kt('is');
     _kt('contains');
     _kt('between');
     _kt('start with');
     _kt('ends with');
     _kt('like');
     _kt('AND');
     _kt('OR');
     _kt('is not');
 }