From d50fca6ae2d117ebd59029d6e0910f02754055c8 Mon Sep 17 00:00:00 2001
From: bryndivey
Date: Fri, 18 Aug 2006 11:39:14 +0000
Subject: [PATCH] Added size criteria Added XML/HTML indexing to core Fixed wording on bulk import
---
lib/browse/Criteria.inc | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
lib/util/ktutil.inc | 12 ++++++++++++
plugins/ktstandard/KTIndexer.php | 2 ++
plugins/ktstandard/contents/XmlHtmlIndexer.php | 42 ++++++++++++++++++++++++++++++++++++++++++
templates/ktcore/folder/bulkImport.smarty | 9 ++++++---
5 files changed, 112 insertions(+), 4 deletions(-)
create mode 100644 plugins/ktstandard/contents/XmlHtmlIndexer.php
diff --git a/lib/browse/Criteria.inc b/lib/browse/Criteria.inc
index ecc0e15..262c484 100644
--- a/lib/browse/Criteria.inc
+++ b/lib/browse/Criteria.inc
@@ -630,11 +630,23 @@ class DateModifiedCriterion extends DateCreatedCriterion {
class SizeCriterion extends BrowseCriterion {
var $sSearchTable = "DC";
- var $bVisible = false;
var $sDocumentField = 'size';
var $sSortField = 'size';
var $sNamespace = 'ktcore.criteria.size';
+ var $aTypes = array('B'=>'Bytes',
+ 'KB'=>'Kilobytes',
+ 'M'=>'Megabytes');
+
+ var $aTypeAssocs = array('B' => 1, 'KB' => 1024, 'M' => 1048576);
+
+ var $aCmps = array('LT'=>'Less than',
+ 'GT'=>'Greater than',
+ 'EQ'=>'Equal to',
+ 'NEQ'=>'Not equal to');
+
+ var $aCmpAssocs = array('LT' => '<', 'GT' => '>', 'EQ' => '=', 'NEQ' => '!=');
+
function SizeCriterion() {
$this->sDisplay = _kt('File Size');
}
@@ -646,6 +658,43 @@ class SizeCriterion extends BrowseCriterion {
function searchDisplay($aRequest) {
return "";
}
+
+ function searchWidget ($aRequest, $aPreValue = null) {
+ $sBase = $this->getWidgetBase();
+ $sCmpWidget = $sBase . '_not';
+ $sNumWidget = $sBase . '_num';
+ $sTypeWidget = $sBase . '_type';
+
+ // build gt/lt/eq/neq widget
+ $sCmpSelect = '';
+ $sCmpSelect .= KTUtil::buildSelectOptions($this->aCmps, KTUtil::arrayGet($aPreValue, $sCmpWidget, 'LT'));
+ $sCmpSelect .= ' ';
+
+ // build number
+ $sNumInput = sprintf(' ', $sNumWidget, KTUtil::arrayGet($aPreValue, $sNumWidget, ''));
+
+
+ // build type selection widget
+ $sTypeSelect = '';
+ $sTypeSelect .= KTUtil::buildSelectOptions($this->aTypes, KTUtil::arrayGet($aPreValue, $sTypeWidget, 'M'));
+ $sTypeWidget .= ' ';
+
+ $sToRender = sprintf("%s %s %s", $sCmpSelect, $sNumInput, $sTypeSelect);
+ return $sToRender;
+ }
+
+ function searchSQL ($aRequest) {
+ $sCmp = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not');
+ $sNum = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_num');
+ $sType = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_type');
+
+
+ $sQry = sprintf("%s.%s %s ?", $this->getSearchTable(), $this->getSearchField(), $this->aCmpAssocs[$sCmp]);
+ $val = array($sQry, (int)$sNum * $this->aTypeAssocs[$sType]);
+
+ return $val;
+ }
+
}
class ContentCriterion extends BrowseCriterion {
diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc
index 587dd69..29bd9cd 100644
--- a/lib/util/ktutil.inc
+++ b/lib/util/ktutil.inc
@@ -690,6 +690,18 @@ class KTUtil {
return $aVersions;
}
+
+ // this will have to move somewhere else
+ function buildSelectOptions($aVocab, $cur = null) {
+ $sRet = '';
+ foreach($aVocab as $k=>$v) {
+ $sRet .= '';
+ }
+ return $sRet;
+ }
+
}
/**
diff --git a/plugins/ktstandard/KTIndexer.php b/plugins/ktstandard/KTIndexer.php
index 0685b59..72aed07 100644
--- a/plugins/ktstandard/KTIndexer.php
+++ b/plugins/ktstandard/KTIndexer.php
@@ -54,6 +54,8 @@ class KTIndexerPlugin extends KTPlugin {
'ktstandard.indexer.triggers.ps', 'contents/PsIndexer.php');
$this->registerTrigger('content', 'transform', 'KTOpenDocumentIndexerTrigger',
'ktstandard.indexer.triggers.opendocument', 'contents/OpenDocumentIndexer.php');
+ $this->registerTrigger('content', 'transform', 'KTXmlHtmlIndexerTrigger',
+ 'ktstandard.indexer.triggers.xml', 'contents/XmlHtmlIndexer.php');
}
}
diff --git a/plugins/ktstandard/contents/XmlHtmlIndexer.php b/plugins/ktstandard/contents/XmlHtmlIndexer.php
new file mode 100644
index 0000000..8767baa
--- /dev/null
+++ b/plugins/ktstandard/contents/XmlHtmlIndexer.php
@@ -0,0 +1,42 @@
+ true,
+ 'text/xml' => true,
+ );
+
+ function extract_contents($sFilename, $sTmpFilename) {
+ $sContent = file_get_contents($sFilename);
+ $sContent = preg_replace ("@(?[^>]*>)+@", " ", $sContent);
+ return $sContent;
+ }
+}
+
+?>
diff --git a/templates/ktcore/folder/bulkImport.smarty b/templates/ktcore/folder/bulkImport.smarty
index bd0ee4b..e9407e7 100644
--- a/templates/ktcore/folder/bulkImport.smarty
+++ b/templates/ktcore/folder/bulkImport.smarty
@@ -72,9 +72,12 @@ system.{/i18n}
{/foreach}
-{i18n}If you do not need to modify any the metadata
-for this document (see below), then you can simply click "Add" here to finish the
-process and add the document.{/i18n}
+{i18n}If there are metadata fields
+associated with this document type they will appear below and allow
+you to set metadata on all imported documents. If there is no metadata
+associated, or you do not wish to modify it, you can simply click
+"Add" here to finish the process and import the documents.{/i18n}
+
--
libgit2 0.21.4