<commit_before><?php

	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.textformattermanager.php');

	Class contentExtensionTemplatedTextFormattersIndex extends AdministrationPage {

		private $_driver;

		public function __construct(&$parent) {
			parent::__construct($parent);

			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Templated Text Formatters'))));

			$this->_driver = $this->_Parent->ExtensionManager->create('templatedtextformatters');
		}

		public function view() {
			$this->setPageType('table');
			$this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL.'/symphony/extension/templatedtextformatters/edit/', __('Create a new hub'), 'create button'));

			$aTableHead = array(
				array(__('Title'), 'col'),
				array(__('Type'), 'col'),
				array(__('Description'), 'col')
			);	

			$aTableBody = array();

			$formatters = $this->_driver->listAll();
			if (!is_array($formatters) || empty($formatters)) {
				$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
			}
			else {
				$tfm = new TextformatterManager($this->_Parent);
				foreach ($formatters as $id => $data) {
					$formatter = $tfm->create($id);
					$about = $formatter->about();

					$td1 = Widget::TableData(Widget::Anchor($about['name'], URL."/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name']));
					$td2 = Widget::TableData($about['templatedtextformatters-type']);
					$td3 = Widget::TableData($about['description']);

					$td1->appendChild(Widget::Input('items['.$id.']', NULL, 'checkbox'));

					// Add a row to the body array, assigning each cell to the row
					$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
				}
			}

			$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
			$this->Form->appendChild($table);

			$div = new XMLElement('div');
			$div->setAttribute('class', 'actions');

			$options = array(
				array(NULL, false, __('With Selected...')),
				array('delete', false, __('Delete'))
			);

			$div->appendChild(Widget::Select('with-selected', $options));
			$div->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));

			$this->Form->appendChild($div);
		}

		public function action() {
			if (!$_POST['action']['apply']) return;
			if ($_POST['with-selected'] == 'delete' && is_array($_POST['items'])) {
				foreach ($_POST['items'] as $id => $selected) {
					$this->delete($id);
				}
				redirect(URL . '/symphony/extension/templatedtextformatters/');
			}
		}

		public function delete($id) {
			$file = TEXTFORMATTERS . '/formatter.' . $id . '.php';
			if (!General::deleteFile($file))
				$this->pageAlert(__('Failed to delete <code>%s</code>. Please check permissions.', array($file)), Alert::ERROR);
		}
	}

<commit_msg>Fix very old leftover.<commit_after><?php

	require_once(TOOLKIT . '/class.administrationpage.php');
	require_once(TOOLKIT . '/class.textformattermanager.php');

	Class contentExtensionTemplatedTextFormattersIndex extends AdministrationPage {

		private $_driver;

		public function __construct(&$parent) {
			parent::__construct($parent);

			$this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Templated Text Formatters'))));

			$this->_driver = $this->_Parent->ExtensionManager->create('templatedtextformatters');
		}

		public function view() {
			$this->setPageType('table');
			$this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL.'/symphony/extension/templatedtextformatters/edit/', __('Create new formatter'), 'create button'));

			$aTableHead = array(
				array(__('Title'), 'col'),
				array(__('Type'), 'col'),
				array(__('Description'), 'col')
			);	

			$aTableBody = array();

			$formatters = $this->_driver->listAll();
			if (!is_array($formatters) || empty($formatters)) {
				$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
			}
			else {
				$tfm = new TextformatterManager($this->_Parent);
				foreach ($formatters as $id => $data) {
					$formatter = $tfm->create($id);
					$about = $formatter->about();

					$td1 = Widget::TableData(Widget::Anchor($about['name'], URL."/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name']));
					$td2 = Widget::TableData($about['templatedtextformatters-type']);
					$td3 = Widget::TableData($about['description']);

					$td1->appendChild(Widget::Input('items['.$id.']', NULL, 'checkbox'));

					// Add a row to the body array, assigning each cell to the row
					$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
				}
			}

			$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
			$this->Form->appendChild($table);

			$div = new XMLElement('div');
			$div->setAttribute('class', 'actions');

			$options = array(
				array(NULL, false, __('With Selected...')),
				array('delete', false, __('Delete'))
			);

			$div->appendChild(Widget::Select('with-selected', $options));
			$div->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));

			$this->Form->appendChild($div);
		}

		public function action() {
			if (!$_POST['action']['apply']) return;
			if ($_POST['with-selected'] == 'delete' && is_array($_POST['items'])) {
				foreach ($_POST['items'] as $id => $selected) {
					$this->delete($id);
				}
				redirect(URL . '/symphony/extension/templatedtextformatters/');
			}
		}

		public function delete($id) {
			$file = TEXTFORMATTERS . '/formatter.' . $id . '.php';
			if (!General::deleteFile($file))
				$this->pageAlert(__('Failed to delete <code>%s</code>. Please check permissions.', array($file)), Alert::ERROR);
		}
	}


{'fraction_non_alphanumeric': 0.20621903297454297, 'fraction_numerical': 0.0030753459764223477, 'mean_word_length': 4.773175542406312, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 55, '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': '4859900', 'n_tokens_mistral': 2149, 'n_tokens_neox': 1829, 'n_words': 332}