Commit d50fca6ae2d117ebd59029d6e0910f02754055c8
1 parent
88a0e0d0
Added size criteria
Added XML/HTML indexing to core Fixed wording on bulk import git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5867 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
112 additions
and
4 deletions
lib/browse/Criteria.inc
| @@ -630,11 +630,23 @@ class DateModifiedCriterion extends DateCreatedCriterion { | @@ -630,11 +630,23 @@ class DateModifiedCriterion extends DateCreatedCriterion { | ||
| 630 | 630 | ||
| 631 | class SizeCriterion extends BrowseCriterion { | 631 | class SizeCriterion extends BrowseCriterion { |
| 632 | var $sSearchTable = "DC"; | 632 | var $sSearchTable = "DC"; |
| 633 | - var $bVisible = false; | ||
| 634 | var $sDocumentField = 'size'; | 633 | var $sDocumentField = 'size'; |
| 635 | var $sSortField = 'size'; | 634 | var $sSortField = 'size'; |
| 636 | var $sNamespace = 'ktcore.criteria.size'; | 635 | var $sNamespace = 'ktcore.criteria.size'; |
| 637 | 636 | ||
| 637 | + var $aTypes = array('B'=>'Bytes', | ||
| 638 | + 'KB'=>'Kilobytes', | ||
| 639 | + 'M'=>'Megabytes'); | ||
| 640 | + | ||
| 641 | + var $aTypeAssocs = array('B' => 1, 'KB' => 1024, 'M' => 1048576); | ||
| 642 | + | ||
| 643 | + var $aCmps = array('LT'=>'Less than', | ||
| 644 | + 'GT'=>'Greater than', | ||
| 645 | + 'EQ'=>'Equal to', | ||
| 646 | + 'NEQ'=>'Not equal to'); | ||
| 647 | + | ||
| 648 | + var $aCmpAssocs = array('LT' => '<', 'GT' => '>', 'EQ' => '=', 'NEQ' => '!='); | ||
| 649 | + | ||
| 638 | function SizeCriterion() { | 650 | function SizeCriterion() { |
| 639 | $this->sDisplay = _kt('File Size'); | 651 | $this->sDisplay = _kt('File Size'); |
| 640 | } | 652 | } |
| @@ -646,6 +658,43 @@ class SizeCriterion extends BrowseCriterion { | @@ -646,6 +658,43 @@ class SizeCriterion extends BrowseCriterion { | ||
| 646 | function searchDisplay($aRequest) { | 658 | function searchDisplay($aRequest) { |
| 647 | return ""; | 659 | return ""; |
| 648 | } | 660 | } |
| 661 | + | ||
| 662 | + function searchWidget ($aRequest, $aPreValue = null) { | ||
| 663 | + $sBase = $this->getWidgetBase(); | ||
| 664 | + $sCmpWidget = $sBase . '_not'; | ||
| 665 | + $sNumWidget = $sBase . '_num'; | ||
| 666 | + $sTypeWidget = $sBase . '_type'; | ||
| 667 | + | ||
| 668 | + // build gt/lt/eq/neq widget | ||
| 669 | + $sCmpSelect = '<select name="'.$sCmpWidget.'">'; | ||
| 670 | + $sCmpSelect .= KTUtil::buildSelectOptions($this->aCmps, KTUtil::arrayGet($aPreValue, $sCmpWidget, 'LT')); | ||
| 671 | + $sCmpSelect .= '</select>'; | ||
| 672 | + | ||
| 673 | + // build number | ||
| 674 | + $sNumInput = sprintf('<input type="text" name="%s" value="%s"/>', $sNumWidget, KTUtil::arrayGet($aPreValue, $sNumWidget, '')); | ||
| 675 | + | ||
| 676 | + | ||
| 677 | + // build type selection widget | ||
| 678 | + $sTypeSelect = '<select name="'.$sTypeWidget.'">'; | ||
| 679 | + $sTypeSelect .= KTUtil::buildSelectOptions($this->aTypes, KTUtil::arrayGet($aPreValue, $sTypeWidget, 'M')); | ||
| 680 | + $sTypeWidget .= '</select>'; | ||
| 681 | + | ||
| 682 | + $sToRender = sprintf("%s %s %s", $sCmpSelect, $sNumInput, $sTypeSelect); | ||
| 683 | + return $sToRender; | ||
| 684 | + } | ||
| 685 | + | ||
| 686 | + function searchSQL ($aRequest) { | ||
| 687 | + $sCmp = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 688 | + $sNum = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_num'); | ||
| 689 | + $sType = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_type'); | ||
| 690 | + | ||
| 691 | + | ||
| 692 | + $sQry = sprintf("%s.%s %s ?", $this->getSearchTable(), $this->getSearchField(), $this->aCmpAssocs[$sCmp]); | ||
| 693 | + $val = array($sQry, (int)$sNum * $this->aTypeAssocs[$sType]); | ||
| 694 | + | ||
| 695 | + return $val; | ||
| 696 | + } | ||
| 697 | + | ||
| 649 | } | 698 | } |
| 650 | 699 | ||
| 651 | class ContentCriterion extends BrowseCriterion { | 700 | class ContentCriterion extends BrowseCriterion { |
lib/util/ktutil.inc
| @@ -690,6 +690,18 @@ class KTUtil { | @@ -690,6 +690,18 @@ class KTUtil { | ||
| 690 | return $aVersions; | 690 | return $aVersions; |
| 691 | } | 691 | } |
| 692 | 692 | ||
| 693 | + | ||
| 694 | + // this will have to move somewhere else | ||
| 695 | + function buildSelectOptions($aVocab, $cur = null) { | ||
| 696 | + $sRet = ''; | ||
| 697 | + foreach($aVocab as $k=>$v) { | ||
| 698 | + $sRet .= '<option value="' . $k . '"'; | ||
| 699 | + if($k == $cur) $sRet .= ' selected="selected"'; | ||
| 700 | + $sRet .= '>' . $v . '</option>'; | ||
| 701 | + } | ||
| 702 | + return $sRet; | ||
| 703 | + } | ||
| 704 | + | ||
| 693 | } | 705 | } |
| 694 | 706 | ||
| 695 | /** | 707 | /** |
plugins/ktstandard/KTIndexer.php
| @@ -54,6 +54,8 @@ class KTIndexerPlugin extends KTPlugin { | @@ -54,6 +54,8 @@ class KTIndexerPlugin extends KTPlugin { | ||
| 54 | 'ktstandard.indexer.triggers.ps', 'contents/PsIndexer.php'); | 54 | 'ktstandard.indexer.triggers.ps', 'contents/PsIndexer.php'); |
| 55 | $this->registerTrigger('content', 'transform', 'KTOpenDocumentIndexerTrigger', | 55 | $this->registerTrigger('content', 'transform', 'KTOpenDocumentIndexerTrigger', |
| 56 | 'ktstandard.indexer.triggers.opendocument', 'contents/OpenDocumentIndexer.php'); | 56 | 'ktstandard.indexer.triggers.opendocument', 'contents/OpenDocumentIndexer.php'); |
| 57 | + $this->registerTrigger('content', 'transform', 'KTXmlHtmlIndexerTrigger', | ||
| 58 | + 'ktstandard.indexer.triggers.xml', 'contents/XmlHtmlIndexer.php'); | ||
| 57 | } | 59 | } |
| 58 | } | 60 | } |
| 59 | 61 |
plugins/ktstandard/contents/XmlHtmlIndexer.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id: OpenDocumentIndexer.php 5758 2006-07-27 10:17:43Z bshuttle $ | ||
| 5 | + * | ||
| 6 | + * The contents of this file are subject to the KnowledgeTree Public | ||
| 7 | + * License Version 1.1 ("License"); You may not use this file except in | ||
| 8 | + * compliance with the License. You may obtain a copy of the License at | ||
| 9 | + * http://www.ktdms.com/KPL | ||
| 10 | + * | ||
| 11 | + * Software distributed under the License is distributed on an "AS IS" | ||
| 12 | + * basis, | ||
| 13 | + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
| 14 | + * for the specific language governing rights and limitations under the | ||
| 15 | + * License. | ||
| 16 | + * | ||
| 17 | + * The Original Code is: KnowledgeTree Open Source | ||
| 18 | + * | ||
| 19 | + * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 20 | + * (Pty) Ltd, trading as KnowledgeTree. | ||
| 21 | + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 22 | + * (C) 2006 The Jam Warehouse Software (Pty) Ltd; | ||
| 23 | + * All Rights Reserved. | ||
| 24 | + * | ||
| 25 | + */ | ||
| 26 | + | ||
| 27 | +require_once(KT_DIR . '/plugins/ktstandard/contents/BaseIndexer.php'); | ||
| 28 | + | ||
| 29 | +class KTXmlHtmlIndexerTrigger extends KTBaseIndexerTrigger { | ||
| 30 | + var $mimetypes = array( | ||
| 31 | + 'text/html' => true, | ||
| 32 | + 'text/xml' => true, | ||
| 33 | + ); | ||
| 34 | + | ||
| 35 | + function extract_contents($sFilename, $sTmpFilename) { | ||
| 36 | + $sContent = file_get_contents($sFilename); | ||
| 37 | + $sContent = preg_replace ("@(</?[^>]*>)+@", " ", $sContent); | ||
| 38 | + return $sContent; | ||
| 39 | + } | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +?> |
templates/ktcore/folder/bulkImport.smarty
| @@ -72,9 +72,12 @@ system.{/i18n}</p> | @@ -72,9 +72,12 @@ system.{/i18n}</p> | ||
| 72 | {/foreach} | 72 | {/foreach} |
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | -<p class="descriptiveText">{i18n}If you do not need to modify any the metadata | ||
| 76 | -for this document (see below), then you can simply click "Add" here to finish the | ||
| 77 | -process and add the document.{/i18n}</p> | 75 | +<p class="descriptiveText">{i18n}If there are metadata fields |
| 76 | +associated with this document type they will appear below and allow | ||
| 77 | +you to set metadata on all imported documents. If there is no metadata | ||
| 78 | +associated, or you do not wish to modify it, you can simply click | ||
| 79 | +"Add" here to finish the process and import the documents.{/i18n}</p> | ||
| 80 | + | ||
| 78 | <input type="submit" name="submit" value="{i18n}Add{/i18n}" /> | 81 | <input type="submit" name="submit" value="{i18n}Add{/i18n}" /> |
| 79 | 82 | ||
| 80 | <hr /> | 83 | <hr /> |