1 : <?php
2 :
3 : /**
4 : * Dictionaries of Old French and Latin
5 : *
6 : * PHP 5
7 : *
8 : * @category Application
9 : * @package DicFro
10 : * @author Michel Corne <mcorne@yahoo.com>
11 : * @copyright 2008-2010 Michel Corne
12 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
13 : * @link http://www.micmap.org/dicfro
14 : */
15 :
16 : require_once 'Model/Query.php';
17 :
18 : /**
19 : * Queries the Tcaf database
20 : *
21 : * @category Application
22 : * @package DicFro
23 : * @author Michel Corne <mcorne@yahoo.com>
24 : * @copyright 2008-2010 Michel Corne
25 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
26 : */
27 :
28 : class Model_Query_Tcaf extends Model_Query
29 : {
30 : /**
31 : * Constructor
32 : *
33 : * @param string $directory the dictionaries directory
34 : * @return void
35 : */
36 : public function __construct($directory = '.')
37 : {
38 10 : parent::__construct($directory . '/tcaf');
39 10 : }
40 :
41 : /**
42 : * Searches the conjugation tables of a verb
43 : *
44 : * @param string $word the verb to search for in any of its forms
45 : * @return array the conjugation tables
46 : */
47 : public function searchVerbConjugation($word)
48 : {
49 3 : $ascii = $this->string->utf8toASCII($word);
50 :
51 3 : $query = "SELECT tense, conjugation, original FROM entry ";
52 3 : $query .= "WHERE ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense <> 'comp.') ";
53 3 : $query .= "AND tense <> 'comp.' ";
54 3 : $query .= "ORDER BY ascii";
55 :
56 3 : $result = $this->execute($query, array(':ascii' => $ascii));
57 :
58 3 : return $result;
59 : }
60 :
61 : /**
62 : * Searches the conjugation models of a verb
63 : *
64 : * @param string $word the verb to search for in any of its forms
65 : * @return array the conjugation tables of model verbs
66 : */
67 : public function searchModelConjugation($word)
68 : {
69 2 : $ascii = $this->string->utf8toASCII($word);
70 :
71 2 : $query = "SELECT tense, conjugation, original FROM entry ";
72 2 : $query .= "WHERE ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense = 'comp.') ";
73 2 : $query .= "AND tense <> 'comp.' ";
74 2 : $query .= "ORDER BY ascii";
75 :
76 2 : $result = $this->execute($query, array(':ascii' => $ascii));
77 :
78 2 : return $result;
79 : }
80 :
81 : /**
82 : * Searches the verbs composed on a verb
83 : *
84 : * @param string $word the verb to search for in any of its forms
85 : * @return array the list of composed verbs
86 : */
87 : public function searchComposedVerbs($word)
88 : {
89 3 : $ascii = $this->string->utf8toASCII($word);
90 :
91 3 : $query = "SELECT DISTINCT original, infinitive, composed FROM word ";
92 3 : $query .= "WHERE infinitive_ascii IN (SELECT DISTINCT infinitive_ascii FROM word WHERE ascii = :ascii AND tense <> 'comp.') ";
93 3 : $query .= "AND tense = 'comp.' ";
94 3 : $query .= "ORDER BY ascii";
95 :
96 3 : $result = $this->execute($query, array(':ascii' => $ascii));
97 :
98 3 : return $result;
99 : }
100 :
101 : /**
102 : * Searches the forms of any verb same as a given form
103 : *
104 : * @param string $word the form to search for
105 : * @return array the list forms
106 : */
107 : public function searchVerbs($word)
108 : {
109 4 : $ascii = $this->string->utf8toASCII($word);
110 :
111 4 : $query = "SELECT original, infinitive, tense, person FROM word ";
112 4 : $query .= "WHERE ascii = :ascii AND tense <> 'comp.' ";
113 4 : $query .= "ORDER BY ascii";
114 :
115 4 : $result = $this->execute($query, array(':ascii' => $ascii));
116 :
117 4 : return $result;
118 : }
|