forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminModel.php
33 lines (31 loc) · 1.2 KB
/
AdminModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
class Kwf_Component_Generator_Plugin_Tags_Trl_AdminModel extends Kwf_Model_Data_Abstract
{
protected $_translateFields = array('text');
protected $_primaryKey = 'id';
public function _init()
{
$model = Kwf_Model_Abstract::getInstance('Kwf_Component_Generator_Plugin_Tags_TagsModel');
foreach ($model->getRows() as $row) {
$trlRow = Kwf_Model_Abstract::getInstance('Kwf_Component_Generator_Plugin_Tags_Trl_Model')
->getRow($row->id);
$this->_data[$row->id] = array(
'id' => $row->id,
'original_text' => $row->text,
'text' => $trlRow ? $trlRow->text : null
);
}
parent::_init();
}
public function update(Kwf_Model_Row_Interface $row, $rowData)
{
parent::update($row, $rowData);
if ($row->text && $row->text != $row->original_text) {
$model = Kwf_Model_Abstract::getInstance('Kwf_Component_Generator_Plugin_Tags_Trl_Model');
$trlRow = $model->getRow($row->id);
if (!$trlRow) $trlRow = $model->createRow(array('id' => $row->id));
$trlRow->text = $row->text;
$trlRow->save();
}
}
}