Removes sessionID from mention links
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / acp / form / TemplateEditForm.class.php
CommitLineData
12aa6f89
MW
1<?php
2namespace wcf\acp\form;
12aa6f89
MW
3use wcf\data\template\Template;
4use wcf\data\template\TemplateAction;
5use wcf\form\AbstractForm;
6use wcf\system\exception\IllegalLinkException;
12aa6f89 7use wcf\system\WCF;
12aa6f89
MW
8
9/**
10 * Shows the form for adding new templates.
e3369fd2 11 *
12aa6f89
MW
12 * @author Marcel Werk
13 * @copyright 2001-2013 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage acp.form
17 * @category Community Framework
18 */
19class TemplateEditForm extends TemplateAddForm {
20 /**
21 * @see wcf\page\AbstractPage::$activeMenuItem
22 */
23 public $activeMenuItem = 'wcf.acp.menu.link.template';
24
25 /**
26 * template id
06355ec3 27 * @var integer
12aa6f89
MW
28 */
29 public $templateID = 0;
30
31 /**
32 * template object
06355ec3 33 * @var wcf\data\template\Template
12aa6f89
MW
34 */
35 public $template = null;
36
37 /**
38 * @see wcf\page\IPage::readParameters()
39 */
40 public function readParameters() {
41 parent::readParameters();
e3369fd2 42
12aa6f89
MW
43 if (isset($_REQUEST['id'])) $this->templateID = intval($_REQUEST['id']);
44 $this->template = new Template($this->templateID);
45 if (!$this->template->templateID || !$this->template->templateGroupID) {
46 throw new IllegalLinkException();
47 }
48 $this->packageID = $this->template->packageID;
49 }
50
51 /**
06355ec3 52 * @see wcf\acp\form\TemplateAddForm::validateName()
12aa6f89
MW
53 */
54 protected function validateName() {
55 if ($this->tplName != $this->template->templateName) {
56 parent::validateName();
57 }
58 }
59
60 /**
06355ec3 61 * @see wcf\acp\form\TemplateAddForm::validateName()
12aa6f89
MW
62 */
63 protected function validateGroup() {
64 if ($this->templateGroupID != $this->template->templateGroupID) {
65 parent::validateName();
66 }
67 }
68
69 /**
70 * @see wcf\form\IForm::save()
71 */
72 public function save() {
73 AbstractForm::save();
74
75 $this->objectAction = new TemplateAction(array($this->template), 'update', array('data' => array(
76 'templateName' => $this->tplName,
77 'templateGroupID' => $this->templateGroupID,
78 'lastModificationTime' => TIME_NOW
79 ), 'source' => $this->templateSource));
80 $this->objectAction->executeAction();
81 $this->saved();
82
83 // show success
84 WCF::getTPL()->assign(array(
85 'success' => true
86 ));
87 }
88
89 /**
90 * @see wcf\page\IPage::readData()
91 */
92 public function readData() {
93 parent::readData();
e3369fd2 94
12aa6f89
MW
95 if (!count($_POST)) {
96 $this->tplName = $this->template->templateName;
97 $this->templateSource = $this->template->getSource();
98 $this->templateGroupID = $this->template->templateGroupID;
99 }
100 }
101
102 /**
103 * @see wcf\page\IPage::assignVariables()
104 */
105 public function assignVariables() {
106 parent::assignVariables();
107
108 WCF::getTPL()->assign(array(
109 'action' => 'edit',
110 'templateID' => $this->templateID,
111 'template' => $this->template
112 ));
113 }
114}