Commit | Line | Data |
---|---|---|
dcc2332d MW |
1 | <?php |
2 | namespace wcf\acp\form; | |
dcc2332d MW |
3 | use wcf\data\smiley\Smiley; |
4 | use wcf\data\smiley\SmileyAction; | |
5 | use wcf\form\AbstractForm; | |
6 | use wcf\system\exception\IllegalLinkException; | |
7 | use wcf\system\language\I18nHandler; | |
8 | use wcf\system\WCF; | |
9 | ||
10 | /** | |
11 | * Shows the smiley edit form. | |
12 | * | |
13 | * @author Tim Duesterhus | |
ca4ba303 | 14 | * @copyright 2001-2014 WoltLab GmbH |
dcc2332d | 15 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
f4f05aa5 | 16 | * @package com.woltlab.wcf |
dcc2332d MW |
17 | * @subpackage acp.form |
18 | * @category Community Framework | |
19 | */ | |
20 | class SmileyEditForm extends SmileyAddForm { | |
21 | /** | |
0ad90fc3 | 22 | * @see \wcf\page\AbstractPage::$activeMenuItem |
dcc2332d MW |
23 | */ |
24 | public $activeMenuItem = 'wcf.acp.menu.link.smiley'; | |
25 | ||
26 | /** | |
0ad90fc3 | 27 | * @see \wcf\page\AbstractPage::$neededPermissions |
dcc2332d MW |
28 | */ |
29 | public $neededPermissions = array('admin.content.smiley.canManageSmiley'); | |
30 | ||
31 | /** | |
32 | * smiley id | |
33 | * @var integer | |
34 | */ | |
35 | public $smileyID = 0; | |
36 | ||
37 | /** | |
38 | * smiley object | |
0ad90fc3 | 39 | * @var \wcf\data\smiley\Smiley |
dcc2332d MW |
40 | */ |
41 | public $smiley = null; | |
42 | ||
43 | /** | |
0ad90fc3 | 44 | * @see \wcf\page\IPage::readParameters() |
dcc2332d MW |
45 | */ |
46 | public function readParameters() { | |
47 | parent::readParameters(); | |
48 | ||
49 | if (isset($_REQUEST['id'])) $this->smileyID = intval($_REQUEST['id']); | |
50 | $this->smiley = new Smiley($this->smileyID); | |
51 | if (!$this->smiley->smileyID) { | |
52 | throw new IllegalLinkException(); | |
53 | } | |
54 | } | |
55 | ||
56 | /** | |
0ad90fc3 | 57 | * @see \wcf\form\IForm::save() |
dcc2332d MW |
58 | */ |
59 | public function save() { | |
60 | AbstractForm::save(); | |
61 | ||
62 | $this->smileyTitle = 'wcf.smiley.title'.$this->smiley->smileyID; | |
63 | if (I18nHandler::getInstance()->isPlainValue('smileyTitle')) { | |
64 | I18nHandler::getInstance()->remove($this->smileyTitle); | |
65 | $this->smileyTitle = I18nHandler::getInstance()->getValue('smileyTitle'); | |
66 | } | |
67 | else { | |
a37b39b6 | 68 | I18nHandler::getInstance()->save('smileyTitle', $this->smileyTitle, 'wcf.smiley', 1); |
dcc2332d MW |
69 | } |
70 | ||
71 | // update bbcode | |
2935bc94 MS |
72 | $this->objectAction = new SmileyAction(array($this->smileyID), 'update', array( |
73 | 'data' => array_merge($this->additionalFields, array( | |
74 | 'smileyTitle' => $this->smileyTitle, | |
75 | 'smileyCode' => $this->smileyCode, | |
76 | 'aliases' => $this->aliases, | |
77 | 'smileyPath' => $this->smileyPath, | |
78 | 'showOrder' => $this->showOrder, | |
79 | 'categoryID' => $this->categoryID ?: null | |
80 | )), | |
81 | 'fileLocation' => $this->uploadedFilename ? WCF_DIR.'images/smilies/tmp/'.$this->uploadedFilename : '' | |
82 | )); | |
dcc2332d MW |
83 | $this->objectAction->executeAction(); |
84 | ||
2935bc94 MS |
85 | $this->uploadedFilename = ''; |
86 | ||
dcc2332d MW |
87 | $this->saved(); |
88 | ||
89 | // show success | |
90 | WCF::getTPL()->assign(array( | |
91 | 'success' => true | |
92 | )); | |
93 | } | |
94 | ||
95 | /** | |
0ad90fc3 | 96 | * @see \wcf\page\IPage::readData() |
dcc2332d MW |
97 | */ |
98 | public function readData() { | |
99 | parent::readData(); | |
100 | ||
101 | if (empty($_POST)) { | |
102 | I18nHandler::getInstance()->setOptions('smileyTitle', 1, $this->smiley->smileyTitle, 'wcf.smiley.title\d+'); | |
103 | $this->smileyTitle = $this->smiley->smileyTitle; | |
104 | ||
105 | $this->smileyCode = $this->smiley->smileyCode; | |
106 | $this->aliases = $this->smiley->aliases; | |
1aa8ebee | 107 | $this->smileyPath = $this->smiley->smileyPath; |
dcc2332d MW |
108 | $this->showOrder = $this->smiley->showOrder; |
109 | $this->categoryID = $this->smiley->categoryID; | |
110 | } | |
111 | } | |
112 | ||
113 | /** | |
0ad90fc3 | 114 | * @see \wcf\page\IPage::assignVariables() |
dcc2332d MW |
115 | */ |
116 | public function assignVariables() { | |
117 | parent::assignVariables(); | |
118 | ||
119 | I18nHandler::getInstance()->assignVariables(!empty($_POST)); | |
120 | ||
121 | WCF::getTPL()->assign(array( | |
122 | 'smiley' => $this->smiley, | |
123 | 'action' => 'edit' | |
124 | )); | |
125 | } | |
126 | } |