~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to search/Zend/Search/Lucene/Field.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * @category   Zend
16
16
 * @package    Zend_Search_Lucene
17
17
 * @subpackage Document
18
 
 * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
 
18
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20
20
 */
21
21
 
31
31
 * @category   Zend
32
32
 * @package    Zend_Search_Lucene
33
33
 * @subpackage Document
34
 
 * @copyright  Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
 
34
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
35
35
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
36
36
 */
37
37
class Zend_Search_Lucene_Field
38
38
{
39
 
    public $kind;
40
 
 
41
 
    public $name        = 'body';
42
 
    public $stringValue = null;
 
39
    /**
 
40
     * Field name
 
41
     *
 
42
     * @var string
 
43
     */
 
44
    public $name;
 
45
 
 
46
 
 
47
    public $value;
43
48
    public $isStored    = false;
44
49
    public $isIndexed   = true;
45
50
    public $isTokenized = true;
47
52
 
48
53
    public $storeTermVector = false;
49
54
 
 
55
    /**
 
56
     * Field boos factor
 
57
     * It's not stored directly in the index, but affects on normalizetion factor
 
58
     *
 
59
     * @var float
 
60
     */
50
61
    public $boost = 1.0;
51
62
 
52
 
    public function __construct($name, $stringValue, $isStored, $isIndexed, $isTokenized, $isBinary = false)
 
63
    /**
 
64
     * Field value encoding.
 
65
     *
 
66
     * @var string
 
67
     */
 
68
    public $encoding;
 
69
 
 
70
    /**
 
71
     * Object constructor
 
72
     *
 
73
     * @param string $name
 
74
     * @param string $value
 
75
     * @param string $encoding
 
76
     * @param boolean $isStored
 
77
     * @param boolean $isIndexed
 
78
     * @param boolean $isTokenized
 
79
     * @param boolean $isBinary
 
80
     */
 
81
    public function __construct($name, $value, $encoding, $isStored, $isIndexed, $isTokenized, $isBinary = false)
53
82
    {
54
 
        $this->name        = $name;
 
83
        $this->name  = $name;
 
84
        $this->value = $value;
55
85
 
56
86
        if (!$isBinary) {
57
 
            /**
58
 
             * @todo Correct UTF-8 string should be required in future
59
 
             * Until full UTF-8 support is not completed, string should be normalized to ANSII encoding
60
 
             */
61
 
            $this->stringValue = iconv(mb_detect_encoding($stringValue), 'ASCII//TRANSLIT', $stringValue);
62
 
            //$this->stringValue = iconv('', 'ASCII//TRANSLIT', $stringValue);
 
87
            $this->encoding    = $encoding;
 
88
            $this->isTokenized = $isTokenized;
63
89
        } else {
64
 
            $this->stringValue = $stringValue;
 
90
            $this->encoding    = '';
 
91
            $this->isTokenized = false;
65
92
        }
66
 
        $this->isStored    = $isStored;
67
 
        $this->isIndexed   = $isIndexed;
68
 
        $this->isTokenized = $isTokenized;
69
 
        $this->isBinary    = $isBinary;
 
93
 
 
94
        $this->isStored  = $isStored;
 
95
        $this->isIndexed = $isIndexed;
 
96
        $this->isBinary  = $isBinary;
70
97
 
71
98
        $this->storeTermVector = false;
72
99
        $this->boost           = 1.0;
79
106
     *
80
107
     * @param string $name
81
108
     * @param string $value
 
109
     * @param string $encoding
82
110
     * @return Zend_Search_Lucene_Field
83
111
     */
84
 
    static public function Keyword($name, $value)
 
112
    public static function Keyword($name, $value, $encoding = '')
85
113
    {
86
 
        return new self($name, $value, true, true, false);
 
114
        return new self($name, $value, $encoding, true, true, false);
87
115
    }
88
116
 
89
117
 
93
121
     *
94
122
     * @param string $name
95
123
     * @param string $value
 
124
     * @param string $encoding
96
125
     * @return Zend_Search_Lucene_Field
97
126
     */
98
 
    static public function UnIndexed($name, $value)
 
127
    public static function UnIndexed($name, $value, $encoding = '')
99
128
    {
100
 
        return new self($name, $value, true, false, false);
 
129
        return new self($name, $value, $encoding, true, false, false);
101
130
    }
102
131
 
103
132
 
107
136
     *
108
137
     * @param string $name
109
138
     * @param string $value
 
139
     * @param string $encoding
110
140
     * @return Zend_Search_Lucene_Field
111
141
     */
112
 
    static public function Binary($name, $value)
 
142
    public static function Binary($name, $value)
113
143
    {
114
 
        return new self($name, $value, true, false, false, true);
 
144
        return new self($name, $value, '', true, false, false, true);
115
145
    }
116
146
 
117
147
    /**
121
151
     *
122
152
     * @param string $name
123
153
     * @param string $value
 
154
     * @param string $encoding
124
155
     * @return Zend_Search_Lucene_Field
125
156
     */
126
 
    static public function Text($name, $value)
 
157
    public static function Text($name, $value, $encoding = '')
127
158
    {
128
 
        return new self($name, $value, true, true, true);
 
159
        return new self($name, $value, $encoding, true, true, true);
129
160
    }
130
161
 
131
162
 
135
166
     *
136
167
     * @param string $name
137
168
     * @param string $value
 
169
     * @param string $encoding
138
170
     * @return Zend_Search_Lucene_Field
139
171
     */
140
 
    static public function UnStored($name, $value)
 
172
    public static function UnStored($name, $value, $encoding = '')
141
173
    {
142
 
        return new self($name, $value, false, true, true);
 
174
        return new self($name, $value, $encoding, false, true, true);
143
175
    }
144
176
 
 
177
    /**
 
178
     * Get field value in UTF-8 encoding
 
179
     *
 
180
     * @return string
 
181
     */
 
182
    public function getUtf8Value()
 
183
    {
 
184
        if (strcasecmp($this->encoding, 'utf8' ) == 0  ||
 
185
            strcasecmp($this->encoding, 'utf-8') == 0 ) {
 
186
                return $this->value;
 
187
        } else {
 
188
            return iconv($this->encoding, 'UTF-8', $this->value);
 
189
        }
 
190
    }
145
191
}
146
192