Skip to content

Commit

Permalink
Fix up helper shim.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Mar 20, 2024
1 parent 8840bc2 commit c85cf96
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/Controller/TranslateAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function initialize(): void {
$this->loadComponent('Tools.Common');

$this->viewBuilder()->addHelper('Translate.Translation');
$this->viewBuilder()->addHelper('Tools.Format');
if (class_exists(TemplatingPlugin::class)) {
$this->viewBuilder()->addHelper('Templating.Icon');
$this->viewBuilder()->addHelper('Templating.IconSnippet');
Expand Down
4 changes: 2 additions & 2 deletions templates/Admin/TranslateDomains/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<?php foreach ($translateDomains as $translateDomain): ?>
<tr>
<td><?= h($translateDomain->name) ?></td>
<td><?= $this->Format->yesNo($translateDomain->active) ?></td>
<td><?= $this->Format->yesNo((bool)$translateDomain->path) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateDomain->active]) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => (bool)$translateDomain->path]) ?></td>
<td><?= $this->Time->nice($translateDomain->created) ?></td>
<td><?= $this->Time->nice($translateDomain->modified) ?></td>
<td class="actions">
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateDomains/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</tr>
<tr>
<th><?= __d('translate', 'Active') ?></th>
<td><?= $this->Format->yesNo($translateDomain->active) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateDomain->active]) ?></td>
</tr>
<tr>
<th><?= __d('translate', 'Path') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateLanguages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<?= $this->Number->format($translateLanguage->language_id) ?></td>
<td><?= h($translateLanguage->name) ?></td>
<td><?= h($translateLanguage->locale) ?></td>
<td><?= $this->Format->yesNo($translateLanguage->active) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateLanguage->active]) ?></td>
<td class="actions">
<?= $this->Html->link($this->Icon->render('view'), ['action' => 'view', $translateLanguage->id], ['escape' => false]); ?>
<?= $this->Html->link($this->Icon->render('edit'), ['action' => 'edit', $translateLanguage->id], ['escape' => false]); ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateLanguages/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</tr>
<tr>
<th><?= __d('translate', 'Active') ?></th>
<td><?= $this->Format->yesNo($translateLanguage->active) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateLanguage->active]) ?></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateProjects/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<tr>
<td><?= h($translateProject->name) ?></td>
<td><?= $translateProject::types($translateProject->type) ?></td>
<td><?= $this->Format->yesNo($translateProject->default) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateProject->default]) ?></td>
<td><?= $translateProject::statuses($translateProject->status) ?></td>
<td><?= $this->Time->nice($translateProject->created) ?></td>
<td><?= $this->Time->nice($translateProject->modified) ?></td>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateProjects/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</tr>
<tr>
<th><?= __d('translate', 'Default') ?></th>
<td><?= $this->Format->yesNo($translateProject->default) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateProject->default]) ?></td>
</tr>
<tr>
<th><?= __d('translate', 'Status') ?></th>
Expand Down
8 changes: 4 additions & 4 deletions templates/Admin/TranslateStrings/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
<td>
<?php echo h($this->Text->truncate($translateString['name'])); ?>
</td>
<td><?= $this->Format->yesNo($translateString->is_html) ?></td>
<td><?= $this->Format->yesNo($translateString->active) ?></td>
<td><?= $this->Format->yesNo($translateString->plural, ['title' => $translateString->plural]) ?></td>
<td><?= $this->Format->yesNo($translateString->context, ['title' => $translateString->context]) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->is_html]) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->active]) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->plural, 'title' => $translateString->plural]) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->context, 'title' => $translateString->context]) ?></td>
<td><?= $this->Time->nice($translateString->last_import) ?></td>
<td><?= $this->Time->nice($translateString->created) ?></td>
<td><?= $this->Time->nice($translateString->modified) ?></td>
Expand Down
4 changes: 2 additions & 2 deletions templates/Admin/TranslateStrings/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</tr>
<tr>
<th><?= __d('translate', 'Active') ?></th>
<td><?= $this->Format->yesNo($translateString->active) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->active]) ?></td>
</tr>
<tr>
<th><?= __d('translate', 'Is Html') ?></th>
<td><?= $this->Format->yesNo($translateString->is_html) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateString->is_html]) ?></td>
</tr>
<tr>
<th><?= __d('translate', 'Last Import') ?></th>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateTerms/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<?php echo $this->Text->truncate($translateTerm->content); ?>
</td>
<td><?= $translateTerm->has('translate_language') ? $this->Html->link($translateTerm->translate_language->name, ['controller' => 'TranslateLanguages', 'action' => 'view', $translateTerm->translate_language->id]) : '' ?></td>
<td><?= $this->Format->yesNo($translateTerm->confirmed) ?>
<td><?= $this->element('Translate.yes_no', ['value' => $translateTerm->confirmed]) ?>
<div>
<small><?= h($translateTerm->confirmed_by) ?></small>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/Admin/TranslateTerms/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</tr>
<tr>
<th><?= __d('translate', 'Confirmed') ?></th>
<td><?= $this->Format->yesNo($translateTerm->confirmed) ?></td>
<td><?= $this->element('Translate.yes_no', ['value' => $translateTerm->confirmed]) ?></td>
</tr>
<tr>
<th><?= __d('translate', 'Confirmed By') ?></th>
Expand Down
22 changes: 22 additions & 0 deletions templates/element/yes_no.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Overwrite this element snippet locally to customize if needed.
*
* @var \App\View\AppView $this
* @var bool $value
* @var string|null $title
*/
?>
<?php
$attr = [];
if (isset($title)) {
$attr['title'] = $title;
}

if ($this->helpers()->has('IconSnippet')) {
echo $this->IconSnippet->yesNo($value, [], $attr);
} elseif ($this->helpers()->has('Format')) {
echo $this->Format->yesNo($value, [], $attr);
} else {
echo $value ? '<span class="yes-no yes-no-yes">Yes</span>' : '<span class="yes-no yes-no-no">No</span>';
}
1 change: 0 additions & 1 deletion tests/test_app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public function initialize(): void {

$this->loadComponent('Flash');

$this->viewBuilder()->setHelpers(['Tools.Format']);
if (class_exists(TemplatingPlugin::class)) {
$this->viewBuilder()->addHelper('Templating.Icon');
$this->viewBuilder()->addHelper('Templating.IconSnippet');
Expand Down

0 comments on commit c85cf96

Please sign in to comment.