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 = ''; + + // build number + $sNumInput = sprintf('', $sNumWidget, KTUtil::arrayGet($aPreValue, $sNumWidget, '')); + + + // build type selection widget + $sTypeSelect = ''; + + $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 .= '