1 |
6daefa8c
|
Petr Lukašík
|
<?php
|
2 |
|
|
class Surface extends AppModel {
|
3 |
|
|
|
4 |
|
|
var $name = 'Surface';
|
5 |
|
|
var $useTable = 'surface';
|
6 |
|
|
var $primaryKey = 'id_surface';
|
7 |
|
|
/* var $validate = array(
|
8 |
|
|
'id_surface' => VALID_NOT_EMPTY,
|
9 |
|
|
);
|
10 |
|
|
*/
|
11 |
|
|
|
12 |
|
|
var $belongsTo = array(
|
13 |
|
|
'Transliteration' => array(
|
14 |
|
|
'className' => 'Transliteration',
|
15 |
|
|
'conditions' => '',
|
16 |
|
|
'order' => '',
|
17 |
|
|
'foreignKey' => 'id_transliteration'
|
18 |
|
|
)
|
19 |
|
|
);
|
20 |
|
|
|
21 |
|
|
function bindModelsForTables() {
|
22 |
|
|
|
23 |
|
|
$this->unbindModel( array('belongsTo' => array('Transliteration')));
|
24 |
|
|
|
25 |
|
|
$this->bindModel(
|
26 |
|
|
array(
|
27 |
|
|
'hasMany' => array(
|
28 |
|
|
'Line' => array(
|
29 |
|
|
'className' => 'Line',
|
30 |
|
|
'foreignKey' => 'id_surface',
|
31 |
|
|
)
|
32 |
|
|
),
|
33 |
|
|
'belongsTo' => array(
|
34 |
|
|
'SurfaceType' => array(
|
35 |
|
|
'className' => 'SurfaceType',
|
36 |
|
|
'foreignKey' => 'id_surface_type',
|
37 |
|
|
),
|
38 |
|
|
'ObjectType' => array(
|
39 |
|
|
'className' => 'ObjectType',
|
40 |
|
|
'foreignKey' => 'id_object_type',
|
41 |
|
|
)
|
42 |
|
|
),
|
43 |
|
|
)
|
44 |
|
|
);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
function organizeLines($surface) {
|
48 |
|
|
$ret = array();
|
49 |
|
|
$ret[$surface['ObjectType']['object_type']]
|
50 |
|
|
[$surface['SurfaceType']['surface_type']]
|
51 |
|
|
['id_surface'] = $surface['Surface']['id_surface'];
|
52 |
|
|
|
53 |
|
|
foreach ($surface['Line'] as $line) {
|
54 |
|
|
|
55 |
|
|
$ret[$surface['ObjectType']['object_type']]
|
56 |
|
|
[$surface['SurfaceType']['surface_type']]
|
57 |
|
|
['lines']
|
58 |
|
|
[$line['id_line']] =
|
59 |
|
|
array(
|
60 |
|
|
'line_number' => $line['line_number'],
|
61 |
|
|
'transliteration' => $line['transliteration'],
|
62 |
|
|
);
|
63 |
|
|
}
|
64 |
|
|
return $ret;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
function isEmpty($id_surface) {
|
68 |
|
|
|
69 |
|
|
}
|
70 |
|
|
}
|