fix: News View add, index and Controller (flash messages i18n bug

pull/4293/head
4ekin 2019-03-12 17:26:44 +03:00
parent f79a18040b
commit e7a66859e8
3 changed files with 8 additions and 8 deletions

12
app/Controller/NewsController.php Normal file → Executable file
View File

@ -48,10 +48,10 @@ class NewsController extends AppController
$this->request->data['News']['user_id'] = 0;
}
if ($this->News->save($this->request->data)) {
$this->Flash->success('News item added.');
$this->Flash->success(__('News item added.'));
$this->redirect(array('action' => 'index'));
} else {
$this->Flash->error('The news item could not be added.');
$this->Flash->error(__('The news item could not be added.'));
}
}
}
@ -65,10 +65,10 @@ class NewsController extends AppController
if ($this->request->is('post') || $this->request->is('put')) {
$this->request->data['News']['id'] = $id;
if ($this->News->save($this->request->data)) {
$this->Flash->success('News item updated.');
$this->Flash->success(__('News item updated.'));
$this->redirect(array('action' => 'index'));
} else {
$this->Flash->error('Could not update news item.');
$this->Flash->error(__('Could not update news item.'));
}
} else {
$this->request->data = $this->News->read(null, $id);
@ -86,10 +86,10 @@ class NewsController extends AppController
throw new NotFoundException('Invalid news item');
}
if ($this->News->delete()) {
$this->Flash->success('News item deleted.');
$this->Flash->success(__('News item deleted.'));
$this->redirect(array('action' => 'index'));
}
$this->Flash->error('News item could not be deleted.');
$this->Flash->error(__('News item could not be deleted.'));
$this->redirect(array('action' => 'index'));
}
}

2
app/View/News/add.ctp Normal file → Executable file
View File

@ -30,7 +30,7 @@
?>
</fieldset>
<?php
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
echo $this->Form->button(__('Submit'), array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
</div>

2
app/View/News/index.ctp Normal file → Executable file
View File

@ -21,7 +21,7 @@
?>
<br /><a href="<?php echo $baseurl; ?>/news/edit/<?php echo h($newsItem['News']['id']);?>" class="icon-edit" title="<?php echo __('Edit news message');?>"></a>
<?php
echo $this->Form->postLink('', array('action' => 'delete', $newsItem['News']['id']), array('class' => 'icon-trash', 'title' => 'Delete'), __('Are you sure you want to delete news item # %s?', $newsItem['News']['id']));
echo $this->Form->postLink('', array('action' => 'delete', $newsItem['News']['id']), array('class' => 'icon-trash', 'title' => __('Delete')), __('Are you sure you want to delete news item # %s?', $newsItem['News']['id']));
endif;
?>
</div>