1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua) |
4
|
|
|
* @author Aleksandr Torosh <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Cms\Controller; |
8
|
|
|
|
9
|
|
|
use Application\Mvc\Controller; |
10
|
|
|
use Cms\Model\Javascript; |
11
|
|
|
use Cms\Form\JavascriptForm; |
12
|
|
|
|
13
|
|
|
class JavascriptController extends Controller |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
public function initialize() |
17
|
|
|
{ |
18
|
|
|
$this->setAdminEnvironment(); |
19
|
|
|
$this->helper->activeMenu()->setActive('admin-javascript'); |
20
|
|
|
$this->view->languages_disabled = true; |
|
|
|
|
21
|
|
|
|
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function indexAction() |
25
|
|
|
{ |
26
|
|
|
$head = Javascript::findFirst("id = 'head'"); |
|
|
|
|
27
|
|
|
$body = Javascript::findFirst("id = 'body'"); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$form = new JavascriptForm(); |
30
|
|
|
|
31
|
|
|
if ($this->request->isPost()) { |
32
|
|
|
if ($form->isValid($this->request->getPost())) { |
33
|
|
|
$head->setText($this->request->getPost('head')); |
|
|
|
|
34
|
|
|
$body->setText($this->request->getPost('body')); |
|
|
|
|
35
|
|
|
if ($head->save() && $body->save()) { |
|
|
|
|
36
|
|
|
$this->flash->success($this->helper->at('Updated has been successful')); |
37
|
|
|
return $this->redirect($this->url->get() . 'cms/javascript'); |
38
|
|
|
} else { |
39
|
|
|
$this->flash->error($this->helper->at('Errors saving')); |
40
|
|
|
} |
41
|
|
|
} else { |
42
|
|
|
$this->flashErrors($form); |
43
|
|
|
} |
44
|
|
|
} else { |
45
|
|
|
$form->get('head')->setDefault($head->getText()); |
|
|
|
|
46
|
|
|
$form->get('body')->setDefault($body->getText()); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$title = htmlentities('<head>, <body> javascript'); |
50
|
|
|
$this->helper->title($title); |
51
|
|
|
$this->view->title = $title; |
|
|
|
|
52
|
|
|
|
53
|
|
|
$this->view->form = $form; |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
} |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: