Fixed time zone calculation issue
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / acp / form / SmileyEditForm.class.php
1 <?php
2 namespace wcf\acp\form;
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
14 * @copyright 2001-2014 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package com.woltlab.wcf
17 * @subpackage acp.form
18 * @category Community Framework
19 */
20 class SmileyEditForm extends SmileyAddForm {
21 /**
22 * @see \wcf\page\AbstractPage::$activeMenuItem
23 */
24 public $activeMenuItem = 'wcf.acp.menu.link.smiley';
25
26 /**
27 * @see \wcf\page\AbstractPage::$neededPermissions
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
39 * @var \wcf\data\smiley\Smiley
40 */
41 public $smiley = null;
42
43 /**
44 * @see \wcf\page\IPage::readParameters()
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 /**
57 * @see \wcf\form\IForm::save()
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 {
68 I18nHandler::getInstance()->save('smileyTitle', $this->smileyTitle, 'wcf.smiley', 1);
69 }
70
71 // update bbcode
72 $this->objectAction = new SmileyAction(array($this->smileyID), 'update', array('data' => array_merge($this->additionalFields, array(
73 'smileyTitle' => $this->smileyTitle,
74 'smileyCode' => $this->smileyCode,
75 'aliases' => $this->aliases,
76 'smileyPath' => $this->smileyPath,
77 'showOrder' => $this->showOrder,
78 'categoryID' => $this->categoryID ?: null
79 ))));
80 $this->objectAction->executeAction();
81
82 $this->saved();
83
84 // show success
85 WCF::getTPL()->assign(array(
86 'success' => true
87 ));
88 }
89
90 /**
91 * @see \wcf\page\IPage::readData()
92 */
93 public function readData() {
94 parent::readData();
95
96 if (empty($_POST)) {
97 I18nHandler::getInstance()->setOptions('smileyTitle', 1, $this->smiley->smileyTitle, 'wcf.smiley.title\d+');
98 $this->smileyTitle = $this->smiley->smileyTitle;
99
100 $this->smileyCode = $this->smiley->smileyCode;
101 $this->aliases = $this->smiley->aliases;
102 $this->smileyPath = $this->smiley->smileyPath;
103 $this->showOrder = $this->smiley->showOrder;
104 $this->categoryID = $this->smiley->categoryID;
105 }
106 }
107
108 /**
109 * @see \wcf\page\IPage::assignVariables()
110 */
111 public function assignVariables() {
112 parent::assignVariables();
113
114 I18nHandler::getInstance()->assignVariables(!empty($_POST));
115
116 WCF::getTPL()->assign(array(
117 'smiley' => $this->smiley,
118 'action' => 'edit'
119 ));
120 }
121 }