From 0a97d35f7ece46b563d2b35bbceeaea763e24a76 Mon Sep 17 00:00:00 2001
From: Kevin G Fourie
Date: Tue, 21 Jul 2009 14:50:22 +0200
Subject: [PATCH] Applied large text and date metadata fields patch from Wasiq. Thanks Wasiq!
---
lib/documentmanagement/DocumentField.inc | 14 +++++++++++++-
lib/metadata/fieldsetregistry.inc.php | 33 +++++++++++++++++++++++++++++++++
plugins/ktcore/KTCorePlugin.php | 11 +++++++++++
plugins/ktcore/KTWidgets.php | 23 ++++++++++++++++++++++-
plugins/ktcore/admin/fieldsets/basic.inc.php | 45 +++++++++++++++++++++++++++++++++++++++++----
plugins/ktcore/document/edit.php | 8 ++++++++
search2/search/expr.inc.php | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------
sql/mysql/install/data.sql | 12 ++++++++----
sql/mysql/install/structure.sql | 2 ++
sql/mysql/upgrade/3.6.2/data_types.sql | 5 +++++
templates/kt3/fieldsets/simple.smarty | 0
templates/ktcore/forms/widgets/textarea.smarty | 33 +++++++++++++++++++++++++++++++++
templates/ktcore/metadata/admin/manage_field.smarty | 37 +++++++++++++++++++++++++++++++++++++
13 files changed, 419 insertions(+), 46 deletions(-)
mode change 100644 => 100755 lib/documentmanagement/DocumentField.inc
mode change 100644 => 100755 lib/metadata/fieldsetregistry.inc.php
mode change 100644 => 100755 plugins/ktcore/KTCorePlugin.php
mode change 100644 => 100755 plugins/ktcore/KTWidgets.php
mode change 100644 => 100755 plugins/ktcore/admin/fieldsets/basic.inc.php
mode change 100644 => 100755 plugins/ktcore/document/edit.php
create mode 100755 sql/mysql/upgrade/3.6.2/data_types.sql
mode change 100644 => 100755 templates/kt3/fieldsets/simple.smarty
create mode 100755 templates/ktcore/forms/widgets/textarea.smarty
mode change 100644 => 100755 templates/ktcore/metadata/admin/manage_field.smarty
diff --git a/lib/documentmanagement/DocumentField.inc b/lib/documentmanagement/DocumentField.inc
old mode 100644
new mode 100755
index 2ab6499..9e2a5ba
--- a/lib/documentmanagement/DocumentField.inc
+++ b/lib/documentmanagement/DocumentField.inc
@@ -70,6 +70,8 @@ class DocumentField extends KTEntity {
var $bHasLookupTree;
var $bIsMandatory;
var $iPosition;
+ var $bIsHTML;
+ var $iMax;
var $_aFieldToSelect = array(
'iId' => 'id',
@@ -82,10 +84,12 @@ class DocumentField extends KTEntity {
'iParentFieldset' => 'parent_fieldset',
'bIsMandatory' => 'is_mandatory',
'iPosition' => 'position',
+ 'bIsHTML' => 'is_html',
+ 'iMax' => 'max_length',
);
// FIXME deprecate constructor use. Use DocumentField::createFromArray instead.
- function DocumentField($sNewName = null, $sNewDataType = null, $bNewIsGeneric = null, $bNewHasLookup = null, $iParentFieldset = null, $bHasLookupTree = null) {
+ function DocumentField($sNewName = null, $sNewDataType = null, $bNewIsGeneric = null, $bNewHasLookup = null, $iParentFieldset = null, $bHasLookupTree = null, $bNewIsHTML = null, $iNewMaxLength = null) {
$this->iId = -1;
$this->sName = $sNewName;
@@ -95,6 +99,8 @@ class DocumentField extends KTEntity {
$this->iParentFieldset = $iParentFieldset;
$this->bHasLookupTree = $bHasLookupTree;
$this->iPosition = $this->getNextFieldPosition($iParentFieldset);
+ $this->bIsHTML = $bNewIsHTML;
+ $this->iMax = $iNewMaxLength;
}
function getID() { return $this->iId; }
@@ -118,6 +124,10 @@ class DocumentField extends KTEntity {
function setIsMandatory($iNewValue) { $this->bIsMandatory = KTUtil::anyToBool($iNewValue); }
function getPosition() { return $this->iPosition; }
function setPosition($iNewValue) { $this->iPosition = $iNewValue; }
+ function getIsHTML() { return $this->bIsHTML; }
+ function setIsHTML($iNewValue) { $this->bIsHTML = $iNewValue; }
+ function getMaxLength() { return $this->iMax; }
+ function setMaxLength($iNewValue) { $this->iMax = $iNewValue; }
function _fieldValues () {
return array(
@@ -130,6 +140,8 @@ class DocumentField extends KTEntity {
'has_lookuptree' => KTUtil::anyToBool($this->bHasLookupTree),
'is_mandatory' => KTUtil::anyToBool($this->bIsMandatory),
'position' => $this->iPosition,
+ 'is_html' => KTUtil::anyToBool($this->bIsHTML),
+ 'max_length' => $this->iMax,
);
}
diff --git a/lib/metadata/fieldsetregistry.inc.php b/lib/metadata/fieldsetregistry.inc.php
old mode 100644
new mode 100755
index 23827c9..b88362e
--- a/lib/metadata/fieldsetregistry.inc.php
+++ b/lib/metadata/fieldsetregistry.inc.php
@@ -172,6 +172,16 @@ class KTFieldsetRegistry {
} else {
$type = 'ktcore.fields.string';
}
+
+ /* ------------------------------------
+ ---- Changes for Custom Fields -----
+ ------------------------------------ */
+
+ if ($oField->getDataType() == 'LARGE TEXT') {
+ $type = 'ktcore.fields.largetext';
+ } else if ($oField->getDataType() == 'DATE') {
+ $type = 'ktcore.fields.date';
+ }
if ($type == 'ktcore.fields.string') {
$widgets[] = $this->oWF->get('ktcore.widgets.string', array(
@@ -204,6 +214,29 @@ class KTFieldsetRegistry {
'vocab' => MetaData::getEnabledByDocumentField($oField),
'field_id' => $oField->getId(),
));
+ } else if ($type == 'ktcore.fields.largetext') {
+ /* ------------------------------------
+ ---- Changes for Custom Fields -----
+ ------------------------------------ */
+ $widgets[] = $this->oWF->get('ktcore.widgets.textarea', array(
+ 'label' => $oField->getName(),
+ 'required' => $oField->getIsMandatory(),
+ 'name' => $fname,
+ 'value' => $value,
+ 'description' => $oField->getDescription(),
+ 'field' => $oField,
+ ));
+ } else if ($type == 'ktcore.fields.date') {
+ /* ------------------------------------
+ ---- Changes for Custom Fields -----
+ ------------------------------------ */
+ $widgets[] = $this->oWF->get('ktcore.widgets.date', array(
+ 'label' => $oField->getName(),
+ 'required' => $oField->getIsMandatory(),
+ 'name' => $fname,
+ 'value' => $value,
+ 'description' => $oField->getDescription(),
+ ));
}
}
diff --git a/plugins/ktcore/KTCorePlugin.php b/plugins/ktcore/KTCorePlugin.php
old mode 100644
new mode 100755
index 2d09771..071a673
--- a/plugins/ktcore/KTCorePlugin.php
+++ b/plugins/ktcore/KTCorePlugin.php
@@ -190,6 +190,10 @@ class KTCorePlugin extends KTPlugin {
$this->registerWidget('KTCoreTreeMetadataWidget', 'ktcore.widgets.treemetadata', 'KTWidgets.php');
$this->registerWidget('KTDescriptorSelectionWidget', 'ktcore.widgets.descriptorselection', 'KTWidgets.php');
$this->registerWidget('KTCoreFolderCollectionWidget', 'ktcore.widgets.foldercollection', 'KTWidgets.php');
+ $this->registerWidget('KTCoreFolderCollectionWidget', 'ktcore.widgets.foldercollection', 'KTWidgets.php');
+
+ $this->registerWidget('KTCoreTextAreaWidget', 'ktcore.widgets.textarea', 'KTWidgets.php');
+ $this->registerWidget('KTCoreDateWidget', 'ktcore.widgets.date', 'KTWidgets.php');
$this->registerWidget('KTCoreConditionalSelectionWidget', 'ktcore.widgets.conditionalselection', 'KTWidgets.php');
@@ -280,6 +284,13 @@ class KTCorePlugin extends KTPlugin {
_kt('Document Fieldsets'),
_kt('Manage the different types of information that can be associated with classes of documents.'),
'admin/documentFieldsv2.php', null);
+ if(KTPluginUtil::pluginIsActive('ktdms.wintools'))
+ {
+ $this->registerAdminPage('emailtypemanagement', 'KTEmailDocumentTypeDispatcher', 'documents',
+ _kt('Email Document Types'),
+ _kt('Manage the addition of Email document types to the system.'),
+ '../wintools/email/emailDocumentTypes.php', null);
+ }
$this->registerAdminPage('workflows_2', 'KTWorkflowAdminV2', 'documents',
_kt('Workflows'), _kt('Configure automated Workflows that map to document life-cycles.'),
'admin/workflowsv2.php', null);
diff --git a/plugins/ktcore/KTWidgets.php b/plugins/ktcore/KTWidgets.php
old mode 100644
new mode 100755
index b4e30a9..adeebf9
--- a/plugins/ktcore/KTWidgets.php
+++ b/plugins/ktcore/KTWidgets.php
@@ -927,9 +927,30 @@ class KTCoreConditionalSelectionWidget extends KTCoreSelectionWidget {
);
return $oTemplate->render($aTemplateData);
}
+}
+class KTCoreTextAreaWidget extends KTWidget {
+ var $sNamespace = 'ktcore.widgets.textarea';
+ var $sTemplate = 'ktcore/forms/widgets/textarea';
+ function configure($aOptions) {
+ $res = parent::configure($aOptions);
+ if (PEAR::isError($res)) {
+ return $res;
+ }
-}
+ // FIXME make required *either* per-action property
+ // FIXME or a global pref.
+ $global_required_default = true;
+ $this->bRequired = KTUtil::arrayGet($aOptions, 'required', $global_required_default, false);
+ $this->aOptions['cols'] = KTUtil::arrayGet($aOptions, 'cols', 60);
+ $this->aOptions['rows'] = KTUtil::arrayGet($aOptions, 'rows', 3);
+ $this->aOptions['field'] = KTUtil::arrayGet($aOptions, 'field');
+ }
+}
+class KTCoreDateWidget extends KTWidget {
+ var $sNamespace = 'ktcore.widgets.date';
+ var $sTemplate = 'ktcore/forms/widgets/date';
+}
\ No newline at end of file
diff --git a/plugins/ktcore/admin/fieldsets/basic.inc.php b/plugins/ktcore/admin/fieldsets/basic.inc.php
old mode 100644
new mode 100755
index 04c31c8..b951a2d
--- a/plugins/ktcore/admin/fieldsets/basic.inc.php
+++ b/plugins/ktcore/admin/fieldsets/basic.inc.php
@@ -84,6 +84,8 @@ class BasicFieldsetManagementDispatcher extends KTAdminDispatcher {
'normal' => _kt("Normal (String)"),
'lookup' => _kt("Lookup"),
'tree' => _kt("Tree"),
+ 'largetextbox' => _kt("Large Textbox"),
+ 'date' => _kt("Date"),
);
return $types;
}
@@ -185,17 +187,27 @@ class BasicFieldsetManagementDispatcher extends KTAdminDispatcher {
$lookup = false;
$tree = false;
+ //$largeField = false;
+
+ $DataType = 'STRING';
+
if ($data['field_type'] == 'lookup') {
$lookup = true;
} else if ($data['field_type'] == 'tree') {
$lookup = true;
$tree = true;
- }
-
+ } else if ($data['field_type'] == 'largetextbox') {
+ //$largeField = true;
+ $DataType = 'LARGE TEXT';
+ } else if ($data['field_type'] == 'date') {
+ //$largeField = true;
+ $DataType = 'DATE';
+ }
+
$oField = DocumentField::createFromArray(array(
'Name' => $data['name'],
'Description' => $data['description'],
- 'DataType' => 'STRING',
+ 'DataType' => $DataType,
'IsGeneric' => false,
'HasLookup' => $lookup,
'HasLookupTree' => $tree,
@@ -276,6 +288,31 @@ class BasicFieldsetManagementDispatcher extends KTAdminDispatcher {
));
return $oTemplate->render();
}
+
+ function do_updatelargetextoptions() {
+
+ $this->oField = DocumentField::get(KTUtil::arrayGet($_REQUEST, 'fFieldId'));
+
+ $oValues = KTUtil::arrayGet($_REQUEST, 'largefield');
+
+ if($oValues['size'] != "")
+ $this->oField->setMaxLength($oValues['size']);
+
+ $this->oField->setIsHTML($oValues['html']);
+ //$this->oField->setIsHTML(true);
+
+ //$oValue = $this->oField->_fieldValues();
+ //$this->successRedirectTo('managefield',_kt("Field updated. -> ") . $this->oField->getMaxLength() . " -> " . $oValue['max_length']);
+
+ //$this->successRedirectTo('managefield',_kt("Field updated. -> ") . $oValues['html']);
+
+ $res = $this->oField->update();
+ if (PEAR::isError($res)) {
+ return $oForm->handleError(sprintf(_kt("Failed to update field: %s"), $res->getMessage()));
+ }
+
+ $this->successRedirectTo('managefield',_kt("Field updated."));
+ }
function do_updatefield() {
$oForm = $this->form_editfield($this->oField);
@@ -287,7 +324,7 @@ class BasicFieldsetManagementDispatcher extends KTAdminDispatcher {
// check that the field name either hasn't changed, or doesn't exist.
if ($data['name'] != $this->oField->getName()) {
$oOldField = DocumentField::getByFieldsetAndName($this->oFieldset, $data['name']);
- // If the field exists throw an error. Mysql doesn't distinguish between Ž and e so check the names are different in php.
+ // If the field exists throw an error. Mysql doesn't distinguish between é and e so check the names are different in php.
if (!PEAR::isError($oOldField) && $oOldField->getName() == $data['name']) {
$extra_errors['name'] = _kt("That name is already in use in this fieldset. Please specify a unique name.");
}
diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php
old mode 100644
new mode 100755
index b840acf..27d5479
--- a/plugins/ktcore/document/edit.php
+++ b/plugins/ktcore/document/edit.php
@@ -217,6 +217,14 @@ class KTDocumentEditAction extends KTDocumentAction {
foreach ($fields as $oField) {
$val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId());
+ if($oField->getDataType() == "LARGE TEXT")
+ {
+ if(strlen(strip_tags($val)) > $oField->getMaxLength())
+ {
+ $oForm->handleError(sprintf(_kt("Value exceeds max allowed length of %d characters for %s. Current value is %d characters."), $oField->getMaxLength(), $oField->getName(), strlen(strip_tags($val))));
+ }
+ }
+
// FIXME "null" has strange meanings here.
if (!is_null($val)) {
$MDPack[] = array(
diff --git a/search2/search/expr.inc.php b/search2/search/expr.inc.php
index 780953d..5aa01ae 100755
--- a/search2/search/expr.inc.php
+++ b/search2/search/expr.inc.php
@@ -298,6 +298,10 @@ class Expr
return $this instanceof MetadataField;
}
+
+
+
+
public function toViz(&$str, $phase)
{
throw new Exception('To be implemented' . get_class($this));
@@ -494,6 +498,7 @@ class DBFieldExpr extends FieldExpr
protected $matchfield;
protected $quotedvalue;
+
/**
* Constructor for the database field
*
@@ -546,6 +551,7 @@ class DBFieldExpr extends FieldExpr
return $value;
}
+
public function getJoinTable() { return $this->jointable; }
public function getJoinField() { return $this->joinfield; }
public function getMatchingField() { return $this->matchfield; }
@@ -679,6 +685,9 @@ class ValueExpr extends Expr
}
}
+
+
+
public function getSQL($field, $fieldname, $op, $not=false)
{
$val = $this->getValue();
@@ -761,7 +770,7 @@ class ValueExpr extends Expr
default:
throw new Exception(sprintf(_kt('Unknown op: %s'), $op));
}
-
+
return $sql;
}
@@ -792,6 +801,7 @@ class ValueListExpr extends Expr
$this->values[] = $value;
}
+
public function getValue($param=null)
{
if (!empty($param))
@@ -837,6 +847,8 @@ class ValueListExpr extends Expr
}
}
+
+
public function rewrite(&$left, &$op, &$right, &$not)
{
if (count($this->values) == 1)
@@ -866,6 +878,7 @@ class ValueListExpr extends Expr
}
+
class BetweenValueExpr extends ValueExpr
{
protected $endvalue;
@@ -1018,7 +1031,7 @@ class TextQueryBuilder implements QueryBuilder
else
$query .= "$not$fieldname:$value";
}
-
+
return $query;
}
@@ -1089,7 +1102,7 @@ class SQLQueryBuilder implements QueryBuilder
'tag_words'=>'tw',
'document_fields_link'=>'pdfl'
);
- break;
+ break;
case ExprContext::FOLDER:
$this->used_tables = array(
'folders'=>1,
@@ -1098,7 +1111,7 @@ class SQLQueryBuilder implements QueryBuilder
$this->aliases = array(
'folders'=>'f',
);
- break;
+ break;
default:
throw new Exception('This was not expected - Context = ' . $context);
}
@@ -1123,7 +1136,7 @@ class SQLQueryBuilder implements QueryBuilder
/**
* This looks up a table name to find the appropriate alias.
*
- * @access private
+ * @access private
* @param string $tablename
* @return string
*/
@@ -1147,7 +1160,7 @@ class SQLQueryBuilder implements QueryBuilder
*/
private function exploreExprs($expr, $parent=null)
{
- if ($expr->isMetadataField())
+ if ($expr->isMetadataField())
{
$this->metadata[] = & $parent;
}
@@ -1180,7 +1193,6 @@ class SQLQueryBuilder implements QueryBuilder
}
}
}
-
/**
* Determine table usage for a simple (metadata) query
*
@@ -1284,7 +1296,6 @@ class SQLQueryBuilder implements QueryBuilder
$query = $right->getSQL($left, $left->modifyName($fieldname), $expr->op(), $isNot);
}
}
-
return $query;
}
@@ -1374,11 +1385,10 @@ class SQLQueryBuilder implements QueryBuilder
// . 'ON dmv.id=pdfl' . $counter . '.metadata_version_id ' . "\n";
// }
// }
-
if ($this->used_tables['tag_words'] > 0)
{
- $sql .= ' LEFT OUTER JOIN document_tags dt ON dt.document_id=d.id ' . "\n"
- . ' LEFT OUTER JOIN tag_words tw ON dt.tag_id = tw.id ' . "\n";
+ $sql .= ' LEFT OUTER JOIN document_tags dt ON dt.document_id=d.id ' . "\n" .
+ ' LEFT OUTER JOIN tag_words tw ON dt.tag_id = tw.id ' . "\n";
}
}
else
@@ -1452,7 +1462,7 @@ class SQLQueryBuilder implements QueryBuilder
$sql .= "f.linked_folder_id is null";
}
$sql .= ' AND ';
-
+
return $sql;
}
@@ -1515,7 +1525,7 @@ class SQLQueryBuilder implements QueryBuilder
$query = 'false';
}
}
-
+
return $query;
}
@@ -1537,7 +1547,7 @@ class SQLQueryBuilder implements QueryBuilder
{
return '';
}
-
+
$expr = $this->buildCoreSQLExpr($expr);
$sql .= $expr;
@@ -1546,7 +1556,7 @@ class SQLQueryBuilder implements QueryBuilder
$sql .= " limit $maxSqlResults";
- return $sql;
+ return $sql;
}
/**
@@ -1573,17 +1583,18 @@ class SQLQueryBuilder implements QueryBuilder
$field = $expr->left();
if (is_null($field->getJoinTable()))
- {
- $alias = $this->resolveTableToAlias($field->getTable());
- $fieldname = $alias . '.' . $field->getField();
- }
- else
- {
- $offset = $this->resolveJoinOffset($expr);
- $matching = $field->getMatchingField();
- $tablename = $field->getJoinTable();
- $fieldname = "$tablename$offset.$matching";
- }
+ {
+ $alias = $this->resolveTableToAlias($field->getTable());
+ $fieldname = $alias . '.' . $field->getField();
+ }
+ else
+ {
+ $offset = $this->resolveJoinOffset($expr);
+ $matching = $field->getMatchingField();
+ $tablename = $field->getJoinTable();
+ $fieldname = "$tablename$offset.$matching";
+ }
+
$value = $expr->right();
$sql .= $value->getSQL($field, $left->modifyName($fieldname), $expr->op(), $expr->not());
@@ -1688,6 +1699,8 @@ class SQLQueryBuilder implements QueryBuilder
}
}
+
+
class OpExpr extends Expr
{
/**
@@ -2323,6 +2336,107 @@ class OpExpr extends Expr
$this->exploreItem($right, $group, $interest);
}
+ public function checkComplexQuery($expr)
+ {
+ $left = $expr->left();
+ $right = $expr->right();
+
+ $oCriteria = array();
+
+ if (DefaultOpCollection::isBoolean($expr))
+ {
+ //$query = '(' . $this->buildComplexQuery($left) . ' ' . $expr->op() . ' ' . $this->buildComplexQuery($right) . ')';
+ $iCriteria = $this->checkComplexQuery($left);
+ if(!empty($iCriteria))
+ //$oCriteria = $iCriteria;
+ $oCriteria[] = $iCriteria;
+
+ $iCriteria = $this->checkComplexQuery($right);
+ if(!empty($iCriteria))
+ //$oCriteria = array_merge($oCriteria, $iCriteria);
+ $oCriteria[] = $iCriteria;
+
+ /*if ($expr->not())
+ {
+ $query = "NOT $query";
+ }*/
+ }
+ else
+ {
+ $fieldname = $left->getField();
+ $value = addslashes($right->getValue());
+
+ //$not = $expr->not()?' NOT ':'';
+ if (empty($value))
+ {
+ // minor hack to prevent the case of 'field:'. results are no 'field:""'
+ $value = ' ';
+ }
+
+ $rsField = DBUtil::getResultArray("SELECT * FROM document_fields WHERE name = \"$fieldname\";");
+
+ if($rsField[0]['data_type'] == 'LARGE TEXT')
+ {
+ $iCriteria = array();
+
+ $iCriteria[0] = array();
+
+ $iCriteria[0]['field'] = $fieldname;
+ $iCriteria[0]['value'] = $value;
+ $iCriteria[0]['not'] = $expr->not();
+
+ $oCriteria[] = $iCriteria[0];
+ }
+
+ //global $default;
+ //$default->log->debug("FIELD-TYPE: " . $iCriteria[0]['field']);
+ //$default->log->debug("FIELD-TYPE: " . $oCriteria[0]['field']);
+
+ /*if (strpos($value, ' ') === false)
+ {
+ $query = "$not$fieldname:$value";
+ }
+ else
+ {
+ $query = "$not$fieldname:\"$value\"";
+ }*/
+ }
+
+ return $oCriteria;
+ }
+
+ public function checkValues($document_id, $oColumns)
+ {
+
+ foreach($oColumns as $column)
+ {
+ $rsField = DBUtil::getResultArray("SELECT df.name, dfl.value FROM documents d
+ INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
+ INNER JOIN document_fields_link dfl ON dfl.metadata_version_id=d.metadata_version_id
+ INNER JOIN document_fields df ON df.id = dfl.document_field_id AND df.name = '" . $column['field'] . "'
+ WHERE d.id = $document_id;");
+
+ /*global $default;
+ $default->log->debug("MATCH QUERY: SELECT df.name, dfl.value FROM documents d
+ INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id
+ INNER JOIN document_fields_link dfl ON dfl.metadata_version_id=d.metadata_version_id
+ INNER JOIN document_fields df ON df.id = dfl.document_field_id AND df.name = '" . $column['field'] . "'
+ WHERE d.id = $document_id;");
+
+ $default->log->debug("MATCH: $document_id, " . $column['field'] . ", " . $rsField[0]['value'] . ", " . $column['value'] . " - "
+ . strip_tags($rsField[0]['value']));*/
+
+ $position = strpos(strtolower(strip_tags($rsField[0]['value'])), strtolower($column['value']));
+
+ //$default->log->debug("POSITION: " . $position);
+
+ if($position === false)
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Executes a database query
*
@@ -2337,7 +2451,7 @@ class OpExpr extends Expr
if (empty($group)) { return array(); }
$exprbuilder = new SQLQueryBuilder($this->getContext());
- $exprbuilder->setIncludeStatus($this->incl_status);
+ $exprbuilder->setIncludeStatus($this->incl_status);
if (count($group) == 1)
{
@@ -2363,15 +2477,66 @@ class OpExpr extends Expr
throw new Exception($rs->getMessage());
}
+ if (count($group) == 1)
+ {
+ //$default->log->debug("CASE 1");
+
+ $oCriteria = $this->checkComplexQuery($group[0]);
+ }
+ else
+ {
+ //$default->log->debug("CASE 2");
+
+ foreach($group as $expr)
+ {
+ $left = $expr->left();
+ $right = $expr->right();
+
+ $default->log->debug("FIELD-IS: " . $left->isOpExpr());
+
+ $fieldname = $left->getField();
+ $value = addslashes($right->getValue());
+
+ $rsField = DBUtil::getResultArray("SELECT * FROM document_fields WHERE name = \"$fieldname\";");
+
+ if($rsField[0]['data_type'] == 'LARGE TEXT')
+ {
+ $iCriteria = array();
+
+ $iCriteria[0] = array();
+
+ $iCriteria[0]['field'] = $fieldname;
+ $iCriteria[0]['value'] = $value;
+ $iCriteria[0]['not'] = $expr->not();
+
+ $oCriteria[] = $iCriteria[0];
+
+ /*$not = $expr->not()?' NOT ':'';
+
+ if (strpos($value, ' ') !== false)
+ $default->log->debug("CRITERION: $not$fieldname:\"$value\"");
+ else
+ $default->log->debug("CRITERION: $not$fieldname:$value");*/
+ }
+
+ //$default->log->debug("FIELD-TYPE: " . $oCriteria[0]['field']);
+ }
+ }
+
+ //$default->log->debug("TOTAL CRITERIA: " . count($oCriteria));
+
foreach($rs as $item)
{
$id = $item['id'];
$rank = $exprbuilder->getRanking($item);
if (!array_key_exists($id, $results) || $rank > $results[$id]->Rank)
{
- if ($this->context == ExprContext::DOCUMENT)
+ if ($this->context == ExprContext::DOCUMENT)
{
- $results[$id] = new DocumentResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item), null, $this->incl_status);
+ if((count($oCriteria) > 0 && $this->checkValues($id, $oCriteria)) || count($oCriteria) == 0)
+ {
+ $results[$id] = new DocumentResultItem($id, $rank, $item['title'], $exprbuilder->getResultText($item), null, $this->incl_status);
+ }
}
else
{
@@ -2379,9 +2544,8 @@ class OpExpr extends Expr
}
}
}
-
+
return $results;
-
}
/**
@@ -2425,6 +2589,7 @@ class OpExpr extends Expr
$indexer = Indexer::get();
$indexer->setIncludeStatus($this->incl_status);
+ global $default;
$default->log->debug("SEARCH LUCENE: $query");
$results = $indexer->query($query);
@@ -2446,8 +2611,12 @@ class OpExpr extends Expr
*/
public function evaluate($context = ExprContext::DOCUMENT_AND_FOLDER)
{
- if ($context == ExprContext::DOCUMENT_AND_FOLDER)
- {
+
+ global $default;
+ $default->log->debug("START EVALUATE");
+
+ if ($context == ExprContext::DOCUMENT_AND_FOLDER)
+ {
$docs = $this->evaluate(ExprContext::DOCUMENT);
$folders = $this->evaluate(ExprContext::FOLDER);
@@ -2455,7 +2624,8 @@ class OpExpr extends Expr
'docs' => $docs['docs'],
'folders' => $folders['folders']);
}
- $this->setContext($context);
+
+ $this->setContext($context);
$left = $this->left();
$left->setIncludeStatus($this->incl_status);
@@ -2469,7 +2639,7 @@ class OpExpr extends Expr
$point = 'point';
}
$resultContext = ($this->getContext() == ExprContext::DOCUMENT)?'docs':'folders';
-
+
if ($point == 'merge')
{
$leftres = $left->evaluate($context);
@@ -2572,4 +2742,4 @@ class OpExpr extends Expr
}
}
-?>
+?>
\ No newline at end of file
diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql
index 2a44e0a..704de48 100644
--- a/sql/mysql/install/data.sql
+++ b/sql/mysql/install/data.sql
@@ -313,7 +313,9 @@ INSERT INTO `data_types` VALUES
(2,'CHAR'),
(3,'TEXT'),
(4,'INT'),
-(5,'FLOAT');
+(5,'FLOAT'),
+(6,'LARGE TEXT'),
+(7,'DATE');
/*!40000 ALTER TABLE `data_types` ENABLE KEYS */;
UNLOCK TABLES;
@@ -1758,8 +1760,10 @@ INSERT INTO `upgrades` VALUES
(219,'upgrade*3.6.0*99*upgrade3.6.0','Upgrade from version 3.5.4a to 3.6.0','2009-01-01 00:00:00',1,'upgrade*3.6.0*99*upgrade3.6.0'),
(220, 'sql*3.6.1*0*3.6.1/search_ranking.sql', 'Database upgrade to version 3.6.1: Search ranking','2009-04-01 00:00:00',1,'upgrade*3.6.1*99*upgrade3.6.1'),
(221,'upgrade*3.6.1*99*upgrade3.6.1','Upgrade from version 3.6.0 to 3.6.1','2009-04-01 00:00:00',1,'upgrade*3.6.1*99*upgrade3.6.1'),
-(222,'upgrade*3.6.2*99*upgrade3.6.2','Upgrade from version 3.6.1 to 3.6.2','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
-(223,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3');
+(222, 'sql*3.6.2*0*3.6.2/folders.sql', 'Folder created and modified timestamp fix','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
+(223, 'sql*3.6.2*0*3.6.2/data_types.sql', 'Add large text and date fields','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
+(224,'upgrade*3.6.2*99*upgrade3.6.2','Upgrade from version 3.6.1 to 3.6.2','2009-05-01 00:00:00',1,'upgrade*3.6.2*99*upgrade3.6.2'),
+(225,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3');
/*!40000 ALTER TABLE `upgrades` ENABLE KEYS */;
UNLOCK TABLES;
@@ -2690,7 +2694,7 @@ UNLOCK TABLES;
LOCK TABLES `zseq_upgrades` WRITE;
/*!40000 ALTER TABLE `zseq_upgrades` DISABLE KEYS */;
INSERT INTO `zseq_upgrades` VALUES
-(223);
+(225);
/*!40000 ALTER TABLE `zseq_upgrades` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql
index a85f90b..0557fdb 100644
--- a/sql/mysql/install/structure.sql
+++ b/sql/mysql/install/structure.sql
@@ -314,6 +314,8 @@ CREATE TABLE `document_fields` (
`is_mandatory` tinyint(1) NOT NULL default '0',
`description` mediumtext NOT NULL,
`position` int(11) NOT NULL default '0',
+ `is_html` tinyint(1) default null,
+ `max_length` int default null,
PRIMARY KEY (`id`),
KEY `parent_fieldset` (`parent_fieldset`),
CONSTRAINT `document_fields_ibfk_1` FOREIGN KEY (`parent_fieldset`) REFERENCES `fieldsets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
diff --git a/sql/mysql/upgrade/3.6.2/data_types.sql b/sql/mysql/upgrade/3.6.2/data_types.sql
new file mode 100755
index 0000000..6fe1001
--- /dev/null
+++ b/sql/mysql/upgrade/3.6.2/data_types.sql
@@ -0,0 +1,5 @@
+INSERT INTO data_types VALUES(6, 'LARGE TEXT');
+INSERT INTO data_types VALUES(7, 'DATE');
+
+ALTER TABLE document_fields ADD COLUMN is_html tinyint(1) default null;
+ALTER TABLE document_fields ADD COLUMN max_length int default null;
\ No newline at end of file
diff --git a/templates/kt3/fieldsets/simple.smarty b/templates/kt3/fieldsets/simple.smarty
old mode 100644
new mode 100755
index 6a1c265..6a1c265
--- a/templates/kt3/fieldsets/simple.smarty
+++ b/templates/kt3/fieldsets/simple.smarty
diff --git a/templates/ktcore/forms/widgets/textarea.smarty b/templates/ktcore/forms/widgets/textarea.smarty
new file mode 100755
index 0000000..6567563
--- /dev/null
+++ b/templates/ktcore/forms/widgets/textarea.smarty
@@ -0,0 +1,33 @@
+
+
+
+{literal}
+
+
+
+
+
+
+{/literal}
\ No newline at end of file
diff --git a/templates/ktcore/metadata/admin/manage_field.smarty b/templates/ktcore/metadata/admin/manage_field.smarty
old mode 100644
new mode 100755
index a0a935c..a92eb15
--- a/templates/ktcore/metadata/admin/manage_field.smarty
+++ b/templates/ktcore/metadata/admin/manage_field.smarty
@@ -24,6 +24,9 @@ aspects of this particular field.{/i18n}
{if ($field->getHasLookup())}
{/if}
+{if ($field->getDataType() == "LARGE TEXT")}
+
+{/if}
{$form->render()}
{if ($field->getHasLookup())}
@@ -48,4 +51,38 @@ available.{/i18n}
{/if}
+{if ($field->getDataType() == "LARGE TEXT")}
+
+
+
+
+{/if}
--
libgit2 0.21.4