<commit_before><?php
namespace wcf\acp\form;
use wcf\data\box\BoxAction;
use wcf\data\menu\Menu;
use wcf\data\menu\MenuAction;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
use wcf\system\language\I18nHandler;
use wcf\system\WCF;

/**
 * Shows the menu edit form.
 * 
 * @author	<NAME>
 * @copyright	2001-2015 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	acp.form
 * @category	Community Framework
 * @since	2.2
 */
class MenuEditForm extends MenuAddForm {
	/**
	 * @inheritDoc
	 */
	public $activeMenuItem = 'wcf.acp.menu.link.cms.menu.list';
	
	/**
	 * menu id
	 * @var	integer
	 */
	public $menuID = 0;
	
	/**
	 * menu object
	 * @var	Menu
	 */
	public $menu = null;
	
	/**
	 * @inheritDoc
	 */
	public function readParameters() {
		parent::readParameters();
	
		if (isset($_REQUEST['id'])) $this->menuID = intval($_REQUEST['id']);
		$this->menu = new Menu($this->menuID);
		if (!$this->menu->menuID) {
			throw new IllegalLinkException();
		}
	}
	
	/**
	 * @inheritDoc
	 */
	protected function validatePosition() {
		if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
			parent::validatePosition();
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function save() {
		AbstractForm::save();
	
		$this->title = 'wcf.menu.menu'.$this->menu->menuID;
		if (I18nHandler::getInstance()->isPlainValue('title')) {
			I18nHandler::getInstance()->remove($this->title);
			$this->title = I18nHandler::getInstance()->getValue('title');
		}
		else {
			I18nHandler::getInstance()->save('title', $this->title, 'wcf.menu', 1);
		}
	
		// update menu
		$this->objectAction = new MenuAction(array($this->menuID), 'update', array('data' => array_merge($this->additionalFields, array(
			'title' => $this->title
		))));
		$this->objectAction->executeAction();
		
		// update box
		if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
			$boxAction = new BoxAction(array($this->menu->getBox()->boxID), 'update', array('data' => array_merge($this->additionalFields, array(
				'position' => $this->position,
				'visibleEverywhere' => ($this->visibleEverywhere) ? 1 : 0,
				'showHeader' => ($this->showHeader) ? 1 : 0,
				'showOrder' => $this->showOrder,
				'cssClassName' => $this->cssClassName
			))));
			$boxAction->executeAction();
		}
		
		$this->saved();
	
		// show success
		WCF::getTPL()->assign(array(
			'success' => true
		));
	}
	
	/**
	 * @inheritDoc
	 */
	public function readData() {
		parent::readData();
		
		if (empty($_POST)) {
			I18nHandler::getInstance()->setOptions('title', 1, $this->menu->title, 'wcf.menu.menu\d+');
			
			$this->title = $this->menu->title;
			$this->position = $this->menu->getBox()->position;
			$this->cssClassName = $this->menu->getBox()->cssClassName;
			$this->cssClassName = $this->menu->getBox()->cssClassName;
			$this->showOrder = $this->menu->getBox()->showOrder;
			$this->visibleEverywhere = $this->menu->getBox()->visibleEverywhere;
			$this->showHeader = $this->menu->getBox()->showHeader;
		}
	}
	
	/**<commit_msg>Removed obsolete code<commit_after><?php
namespace wcf\acp\form;
use wcf\data\box\BoxAction;
use wcf\data\menu\Menu;
use wcf\data\menu\MenuAction;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
use wcf\system\language\I18nHandler;
use wcf\system\WCF;

/**
 * Shows the menu edit form.
 * 
 * @author	<NAME>
 * @copyright	2001-2015 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	acp.form
 * @category	Community Framework
 * @since	2.2
 */
class MenuEditForm extends MenuAddForm {
	/**
	 * @inheritDoc
	 */
	public $activeMenuItem = 'wcf.acp.menu.link.cms.menu.list';
	
	/**
	 * menu id
	 * @var	integer
	 */
	public $menuID = 0;
	
	/**
	 * menu object
	 * @var	Menu
	 */
	public $menu = null;
	
	/**
	 * @inheritDoc
	 */
	public function readParameters() {
		parent::readParameters();
	
		if (isset($_REQUEST['id'])) $this->menuID = intval($_REQUEST['id']);
		$this->menu = new Menu($this->menuID);
		if (!$this->menu->menuID) {
			throw new IllegalLinkException();
		}
	}
	
	/**
	 * @inheritDoc
	 */
	protected function validatePosition() {
		if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
			parent::validatePosition();
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function save() {
		AbstractForm::save();
	
		$this->title = 'wcf.menu.menu'.$this->menu->menuID;
		if (I18nHandler::getInstance()->isPlainValue('title')) {
			I18nHandler::getInstance()->remove($this->title);
			$this->title = I18nHandler::getInstance()->getValue('title');
		}
		else {
			I18nHandler::getInstance()->save('title', $this->title, 'wcf.menu', 1);
		}
	
		// update menu
		$this->objectAction = new MenuAction(array($this->menuID), 'update', array('data' => array_merge($this->additionalFields, array(
			'title' => $this->title
		))));
		$this->objectAction->executeAction();
		
		// update box
		if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
			$boxAction = new BoxAction(array($this->menu->getBox()->boxID), 'update', array('data' => array_merge($this->additionalFields, array(
				'position' => $this->position,
				'visibleEverywhere' => ($this->visibleEverywhere) ? 1 : 0,
				'showHeader' => ($this->showHeader) ? 1 : 0,
				'showOrder' => $this->showOrder,
				'cssClassName' => $this->cssClassName
			))));
			$boxAction->executeAction();
		}
		
		$this->saved();
	
		// show success
		WCF::getTPL()->assign(array(
			'success' => true
		));
	}
	
	/**
	 * @inheritDoc
	 */
	public function readData() {
		parent::readData();
		
		if (empty($_POST)) {
			I18nHandler::getInstance()->setOptions('title', 1, $this->menu->title, 'wcf.menu.menu\d+');
			
			$this->title = $this->menu->title;
			$this->position = $this->menu->getBox()->position;
			$this->cssClassName = $this->menu->getBox()->cssClassName;
			$this->showOrder = $this->menu->getBox()->showOrder;
			$this->visibleEverywhere = $this->menu->getBox()->visibleEverywhere;
			$this->showHeader = $this->menu->getBox()->showHeader;
		}
	}
	
	/**
{'fraction_non_alphanumeric': 0.19909061383566093, 'fraction_numerical': 0.009418642416368951, 'mean_word_length': 3.8457907159716758, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 155, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6437637', 'n_tokens_mistral': 2386, 'n_tokens_neox': 2088, 'n_words': 356}