Commit 1263444b1909b4aeec3fba60285a7c3455a9eede
1 parent
ce58047a
Added additional comments to search code
Committed by: Paul Barrett
Showing
9 changed files
with
32 additions
and
40 deletions
search2.php
search2/search/expr.inc.php
| ... | ... | @@ -49,8 +49,6 @@ require_once('search/fieldRegistry.inc.php'); |
| 49 | 49 | require_once('search/exprConstants.inc.php'); |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * | |
| 53 | - * | |
| 54 | 52 | * This class handles the ranking of search results |
| 55 | 53 | * |
| 56 | 54 | * @author KnowledgeTree Team |
| ... | ... | @@ -794,7 +792,6 @@ class ValueListExpr extends Expr |
| 794 | 792 | $this->values[] = $value; |
| 795 | 793 | } |
| 796 | 794 | |
| 797 | - | |
| 798 | 795 | public function getValue($param=null) |
| 799 | 796 | { |
| 800 | 797 | if (!empty($param)) |
| ... | ... | @@ -950,6 +947,7 @@ interface QueryBuilder |
| 950 | 947 | |
| 951 | 948 | /** |
| 952 | 949 | * This class builds queries for text content searches |
| 950 | + * which are run through the Lucene service | |
| 953 | 951 | * |
| 954 | 952 | * @author KnowledgeTree Team |
| 955 | 953 | * @package Search |
| ... | ... | @@ -1111,8 +1109,7 @@ class SQLQueryBuilder implements QueryBuilder |
| 1111 | 1109 | } |
| 1112 | 1110 | |
| 1113 | 1111 | /** |
| 1114 | - * Sets the value which determines whether archived/deleted documents | |
| 1115 | - * are to be included in search results | |
| 1112 | + * Sets the value which determines whether status must be 1 to return results | |
| 1116 | 1113 | * |
| 1117 | 1114 | * @author KnowledgeTree Team |
| 1118 | 1115 | * @access public | ... | ... |
search2/search/fields/AnyMetadataField.inc.php
| ... | ... | @@ -39,46 +39,21 @@ |
| 39 | 39 | |
| 40 | 40 | class AnyMetadataField extends DBFieldExpr |
| 41 | 41 | { |
| 42 | + // declare as part of GeneralText search | |
| 42 | 43 | public $general_op = ExprOp::CONTAINS; |
| 43 | -// public $references = 0; | |
| 44 | 44 | |
| 45 | 45 | public function __construct() |
| 46 | 46 | { |
| 47 | -// parent::__construct('value', 'document_fields_link', _kt('Any Metadata')); | |
| 47 | + /* | |
| 48 | + * Constructing the object like this allows for easy multiple joins | |
| 49 | + * on the same column in the same table | |
| 50 | + */ | |
| 48 | 51 | parent::__construct('id', 'document_metadata_version', _kt('Any Metadata')); |
| 49 | 52 | $this->setAlias('Metadata'); |
| 50 | 53 | $this->joinTo('document_fields_link', 'metadata_version_id'); |
| 51 | 54 | $this->matchField('value'); |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | - /* | |
| 55 | - * Overridden function to adjust table alias in cases of | |
| 56 | - * the document_fields_link table being included more than once | |
| 57 | - * | |
| 58 | - * NOTE this only works in conjunction with code in expr.inc.php which adds the left joins to the db query. | |
| 59 | - * I don't like this and think we should look for a way to make the table joining more generic | |
| 60 | - * such that it can be controlled via these classes and thereby contained as a unit. | |
| 61 | - */ | |
| 62 | -// public function modifyName($name) | |
| 63 | -// { | |
| 64 | -// if ($this->references > 0) | |
| 65 | -// { | |
| 66 | -// static $count = 0; | |
| 67 | -// if ($count >= $this->references) | |
| 68 | -// { | |
| 69 | -// $count = 0; | |
| 70 | -// } | |
| 71 | -// | |
| 72 | -// if ((($pos = strpos($name, '.')) !== false) && ($count != 0)) | |
| 73 | -// { | |
| 74 | -// $name = substr($name, 0, $pos) . $count . substr($name, $pos); | |
| 75 | -// } | |
| 76 | -// ++$count; | |
| 77 | -// } | |
| 78 | -// | |
| 79 | -// return $name; | |
| 80 | -// } | |
| 81 | - | |
| 82 | 57 | public function getInputRequirements() |
| 83 | 58 | { |
| 84 | 59 | return array('value'=>array('type'=>FieldInputType::TEXT)); | ... | ... |
search2/search/fields/DiscussionTextField.inc.php
search2/search/fields/DocumentIdField.inc.php
search2/search/fields/FilenameField.inc.php
| ... | ... | @@ -39,9 +39,9 @@ |
| 39 | 39 | |
| 40 | 40 | class FilenameField extends DBFieldExpr |
| 41 | 41 | { |
| 42 | + // declare as part of GeneralText search | |
| 42 | 43 | public $general_op = ExprOp::CONTAINS; |
| 43 | 44 | |
| 44 | - | |
| 45 | 45 | public function __construct() |
| 46 | 46 | { |
| 47 | 47 | parent::__construct('filename', 'document_content_version', _kt('Filename')); | ... | ... |
search2/search/fields/FullPathField.inc.php
search2/search/fields/GeneralTextField.inc.php
| ... | ... | @@ -37,6 +37,26 @@ |
| 37 | 37 | * |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | +/** | |
| 41 | + * Class to combine multiple search fields under the heading of GeneralText search | |
| 42 | + * | |
| 43 | + * Fields are added to the GeneralText search by declaring and initialising the | |
| 44 | + * ${fieldclass}->general_op variable within the field class you would like to | |
| 45 | + * include in the GeneralText search. To do this, add the following class variable | |
| 46 | + * declaration: | |
| 47 | + * | |
| 48 | + * public $general_op = ExprOp::CONTAINS; | |
| 49 | + * | |
| 50 | + * At the time of writing (2009/05/15) the following field classes are included: | |
| 51 | + * | |
| 52 | + * AnyMetadataField | |
| 53 | + * DiscussionTextField | |
| 54 | + * DocumentIdField | |
| 55 | + * FilenameField | |
| 56 | + * FullPathField | |
| 57 | + * TitleField | |
| 58 | + * | |
| 59 | + */ | |
| 40 | 60 | class GeneralTextField extends SearchableText |
| 41 | 61 | { |
| 42 | 62 | public function __construct() |
| ... | ... | @@ -83,10 +103,7 @@ class GeneralTextField extends SearchableText |
| 83 | 103 | $right = new OpExpr($right, ExprOp::OP_OR, $newexpr); |
| 84 | 104 | } |
| 85 | 105 | } |
| 86 | - | |
| 87 | 106 | } |
| 88 | - | |
| 89 | - | |
| 90 | 107 | } |
| 91 | 108 | |
| 92 | 109 | ?> | ... | ... |