1 | <?php |
||
13 | class TranslationsPresenter extends BasePresenter |
||
14 | { |
||
15 | 1 | public function renderDefault() |
|
19 | |||
20 | 1 | protected function createComponentTranslationGrid($name) |
|
21 | { |
||
22 | 1 | $grid = $this->createGrid($this, $name, "Translation"); |
|
23 | |||
24 | 1 | $langs = $this->getAllLanguages(); |
|
25 | |||
26 | $backend = array( |
||
27 | 1 | '' => $this->translation['Pick filter'], |
|
28 | 1 | 0 => $this->translation['No'], |
|
29 | 1 | 1 => $this->translation['Yes'], |
|
30 | 1 | ); |
|
31 | |||
32 | 1 | $grid->addColumnText('id', 'ID')->setSortable()->setFilterNumber(); |
|
33 | 1 | $grid->addColumnText('key', 'Key')->setSortable()->setFilterText(); |
|
34 | $grid->addColumnText('translation', 'Value')->setSortable()->setCustomRender(function ($item) { |
||
35 | 1 | return '<div class="translation" contentEditable>'.$item->getTranslation().'</div>'; |
|
36 | 1 | }); |
|
37 | 1 | $grid->addColumnText('backend', 'Backend')->setReplacement(array( |
|
38 | 1 | '1' => 'Yes', |
|
39 | 1 | NULL => 'No', |
|
40 | 1 | ))->setFilterSelect($backend); |
|
41 | |||
42 | 1 | $grid->addColumnText('translated', 'Translated')->setReplacement(array( |
|
43 | 1 | '1' => 'Yes', |
|
44 | 1 | NULL => 'No', |
|
45 | 1 | ))->setFilterSelect($backend); |
|
46 | |||
47 | 1 | $grid->addColumnText('language', 'Language')->setCustomRender(function ($item) { |
|
48 | 1 | return $item->getLanguage()->getName(); |
|
49 | 1 | })->setSortable(); |
|
50 | |||
51 | 1 | $grid->addFilterSelect('language', 'Language')->getControl()->setTranslator(null)->setItems($langs); |
|
52 | |||
53 | 1 | $grid->addActionHref("deleteTranslation", 'Delete')->getElementPrototype()->addAttributes(array('class' => array('btn', 'btn-danger'), 'data-confirm' => 'Are you sure you want to delete the item?')); |
|
54 | |||
55 | 1 | $grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); |
|
56 | |||
57 | 1 | return $grid; |
|
58 | } |
||
59 | |||
60 | public function actionDeleteTranslation($id) |
||
72 | |||
73 | public function handleUpdateTranslation($idTranslation, $value) |
||
89 | |||
90 | public function handleRegenerateTranslations() |
||
101 | } |
||
102 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: