<commit_before><?php
/*
	Copyright 2002-2007 <NAME> <<EMAIL>>

	This file is part of LL.

	LL is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	LL is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with LL.  If not, see <http://www.gnu.org/licenses/>.
*/

class AdminForums extends AdminForm {

private $cat = 0;

protected function setForm()
	{
	try
		{
		$this->cat = $this->Input->Get->getInt('cat');
		}
	catch (RequestException $e)
		{
		$this->showFailure('Keine Kategorie angegeben');
		}

	$this->setTitle('Foren');

	$this->add(new SubmitButtonElement('Speichern'));

	try
		{
		$stm = $this->DB->prepare
			('
			SELECT
				forums.id,
				forums.name,
				forums.description,
				forums.boardid,
				forums.mods,
				forum_cat.position
			FROM
				forums,
				forum_cat,
				cats
			WHERE
				forum_cat.forumid = forums.id
				AND forum_cat.catid = cats.id
				AND forum_cat.catid = ?
				AND cats.boardid = ?
			ORDER BY
				forum_cat.position
			');
		$stm->bindInteger($this->cat);
		$stm->bindInteger($this->Board->getId());
		$forums = $stm->getRowSet();
		$totalForums = $stm->getNumRows();
		}
	catch (DBNoDataException $e)
		{
		$forums = array();
		$totalForums = 0;
		}

	foreach ($forums as $forum)
		{
		if ($forum['boardid'] == $this->Board->getId())
			{
			$nameInput = new TextInputElement('forums['.$forum['id'].'][name]', $forum['name'], 'Name')
			$nameInput->setRequired(false);
			$nameInput->setMinLength(0);
			$this->add($nameInput);
			$descInput = new TextareaInputElement('forums['.$forum['id'].'][description]', $forum['description'], 'Beschreibung');
			$descInput->setRequired(false);
			$descInput->setMinLength(0);
			$this->add($descInput);

			$positionMenu = new SelectInputElement('forums['.$forum['id'].'][position]', 'Position');
			for ($i = 1; $i <= $totalForums; $i++)
				{
				$positionMenu->addOption($i, $i);
				}
			$positionMenu->setSelected($forum['position']);
			$positionMenu->setSize(1);
			$positionMenu->setRequired(false);
			$positionMenu->setMinLength(0);
			$this->add($positionMenu);

			$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminForumsMove', array('forum' => $forum['id'])).'"><span class="button">verschieben</span></a>
				<a href="'.$this->Output->createUrl('AdminForumsDel', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC0000">löschen</span></a>'));

			if ($this->User->isLevel(User::ROOT))
				{
				$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminGlobalForumsMove', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC6600">global verschieben</span></a>'));
				}

			$this->add(new LabeledElement
				('', '	'.$this->getMods($forum['mods']).'
					<br />
					<a href="'.$this->Output->createUrl('AdminForumsMods', array('forum' => $forum['id'])).'"><span class="button">Moderatoren</span></a>'));
			}
		else
			{
			$this->add(new LabeledElement('Name', $forum['name']));
			$this->add(new LabeledElement('Beschreibung', $forum['description']));

			$positionMenu = new SelectInputElement('forums['.$forum['id'].'][position]', 'Position');
			for ($i = 1; $i <= $totalForums; $i++)
				{
				$positionMenu->addOption($i, $i);
				}
			$positionMenu->setSelected($forum['position']);
			$positionMenu->setSize(1);
			$positionMenu->setRequired(false);
			$positionMenu->setMinLength(0);
			$this->add($positionMenu);

			$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminForumsMove', array('forum' => $forum['id'])).'"><span class="button">verschieben</span></a>
				<a href="'.$this->Output->createUrl('AdminForumsDelEx', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC6600">löschen</span></a>'));


			$this->add(new LabeledElement
				('', '	'.$this->getMods($forum['mods']).' '));
			}
		}
	$stm->close();

	$nameInput = new TextInputElement('newname', '', 'Name');
	$nameInput->setRequired(false);
	$nameInput->setMinLength(0);
	$this->add($nameInput);
	
	$descInput = new TextareaInputElement('newdescription', '', 'Beschreibung');
	$descInput->setRequired(false);
	$descInput->setMinLength(0);
	$this->add($descInput);

	$positionMenu = new SelectInputElement('newposition', 'Position');
	for ($i = 1; $i <= $totalForums+1; $i++)
		{
		$positionMenu->addOption($i, $i);<commit_msg>AdminForums: fix typo; set size of textarea<commit_after><?php
/*
	Copyright 2002-2007 <NAME> <<EMAIL>>

	This file is part of LL.

	LL is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	LL is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with LL.  If not, see <http://www.gnu.org/licenses/>.
*/

class AdminForums extends AdminForm {

private $cat = 0;

protected function setForm()
	{
	try
		{
		$this->cat = $this->Input->Get->getInt('cat');
		}
	catch (RequestException $e)
		{
		$this->showFailure('Keine Kategorie angegeben');
		}

	$this->setTitle('Foren');

	$this->add(new SubmitButtonElement('Speichern'));

	try
		{
		$stm = $this->DB->prepare
			('
			SELECT
				forums.id,
				forums.name,
				forums.description,
				forums.boardid,
				forums.mods,
				forum_cat.position
			FROM
				forums,
				forum_cat,
				cats
			WHERE
				forum_cat.forumid = forums.id
				AND forum_cat.catid = cats.id
				AND forum_cat.catid = ?
				AND cats.boardid = ?
			ORDER BY
				forum_cat.position
			');
		$stm->bindInteger($this->cat);
		$stm->bindInteger($this->Board->getId());
		$forums = $stm->getRowSet();
		$totalForums = $stm->getNumRows();
		}
	catch (DBNoDataException $e)
		{
		$forums = array();
		$totalForums = 0;
		}

	foreach ($forums as $forum)
		{
		if ($forum['boardid'] == $this->Board->getId())
			{
			$nameInput = new TextInputElement('forums['.$forum['id'].'][name]', $forum['name'], 'Name');
			$nameInput->setRequired(false);
			$nameInput->setMinLength(0);
			$this->add($nameInput);
			$descInput = new TextareaInputElement('forums['.$forum['id'].'][description]', $forum['description'], 'Beschreibung');
			$descInput->setRequired(false);
			$descInput->setMinLength(0);
			$descInput->setRows(5);
			$this->add($descInput);

			$positionMenu = new SelectInputElement('forums['.$forum['id'].'][position]', 'Position');
			for ($i = 1; $i <= $totalForums; $i++)
				{
				$positionMenu->addOption($i, $i);
				}
			$positionMenu->setSelected($forum['position']);
			$positionMenu->setSize(1);
			$positionMenu->setRequired(false);
			$positionMenu->setMinLength(0);
			$this->add($positionMenu);

			$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminForumsMove', array('forum' => $forum['id'])).'"><span class="button">verschieben</span></a>
				<a href="'.$this->Output->createUrl('AdminForumsDel', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC0000">löschen</span></a>'));

			if ($this->User->isLevel(User::ROOT))
				{
				$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminGlobalForumsMove', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC6600">global verschieben</span></a>'));
				}

			$this->add(new LabeledElement
				('', '	'.$this->getMods($forum['mods']).'
					<br />
					<a href="'.$this->Output->createUrl('AdminForumsMods', array('forum' => $forum['id'])).'"><span class="button">Moderatoren</span></a>'));
			}
		else
			{
			$this->add(new LabeledElement('Name', $forum['name']));
			$this->add(new LabeledElement('Beschreibung', $forum['description']));

			$positionMenu = new SelectInputElement('forums['.$forum['id'].'][position]', 'Position');
			for ($i = 1; $i <= $totalForums; $i++)
				{
				$positionMenu->addOption($i, $i);
				}
			$positionMenu->setSelected($forum['position']);
			$positionMenu->setSize(1);
			$positionMenu->setRequired(false);
			$positionMenu->setMinLength(0);
			$this->add($positionMenu);

			$this->add(new LabeledElement
				('', '<a href="'.$this->Output->createUrl('AdminForumsMove', array('forum' => $forum['id'])).'"><span class="button">verschieben</span></a>
				<a href="'.$this->Output->createUrl('AdminForumsDelEx', array('forum' => $forum['id'])).'"><span class="button" style="background-color:#CC6600">löschen</span></a>'));


			$this->add(new LabeledElement
				('', '	'.$this->getMods($forum['mods']).' '));
			}
		}
	$stm->close();

	$nameInput = new TextInputElement('newname', '', 'Name');
	$nameInput->setRequired(false);
	$nameInput->setMinLength(0);
	$this->add($nameInput);
	
	$descInput = new TextareaInputElement('newdescription', '', 'Beschreibung');
	$descInput->setRequired(false);
	$descInput->setMinLength(0);
	$descInput->setRows(5);
	$this->add($descInput);

	$positionMenu = new SelectInputElement('newposition', 'Position');
	for ($i = 1; $i <= $totalForums+1; $i++)
		{
		$positionMenu->addOption($i, $i);
{'fraction_non_alphanumeric': 0.204247860604186, 'fraction_numerical': 0.007423445716053201, 'mean_word_length': 4.565117613310385, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 209, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2319580', 'n_tokens_mistral': 3807, 'n_tokens_neox': 3282, 'n_words': 625}