<commit_before><?php
defined('C5_EXECUTE') or die('Access Denied.');

class DashboardDataManagementController extends DataDashboardBaseController {

	public function view() {
		$DataType = new DataType;
		$this->set('dataTypes', $DataType->Find('1=1'));
	}

	/**
	 * @param dtID int DataType id
	 */
	public function create($dtID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}

		$this->set('dataType', $dataType);
		$this->set('attributes', DataAttributeKey::getListByDataTypeID($dataType->dtID));
		$this->set('ah', Loader::helper('form/attribute'));
		
		if ($this->isPost()) {
			$data = new Data;
			$data->dtID = $dtID;
			$data->Insert();
			foreach ($this->post('akID') as $akID => $values) {
				$dak = DataAttributeKey::getByID($akID);
				$dak->saveAttributeForm($data);
			}
			$this->flashSuccess(t('Data Created'));
			$this->redirect($this->path('search'), $dataType->dtID);
		}

		$this->render('create');
	}

	/**
	 * @param $dtID int
	 * @param $dID int
	 */
	public function edit($dtID, $dID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}
		$data = new Data;
		if (!$data->Load('dID=?', array($dID))) {
			$this->flashError('Data Not Found');
			$this->redirect($this->path(), $dataType->dtID);
		}

		$this->set('data', $data);
		$this->set('dataType', $dataType);

		$this->set('attributes', DataAttributeKey::getListByDataTypeID($dataType->dtID));

		$ah = Loader::helper('form/attribute');
		$ah->setAttributeObject($data);
		$this->set('ah', $ah);

		if ($this->isPost()) {
			foreach ($this->post('akID') as $akID => $values) {
				$dak = DataAttributeKey::getByID($akID);
				$dak->saveAttributeForm($data);
			}
			$this->flashSuccess(t('Data Updated'));
			$this->redirect($this->path('search'), $dataType->dtID);
		}

		$this->render('edit');
	}

	/**
	 * @param $dtID int
	 * @param $dID int
	 */
	public function delete($dtID, $dID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}
		$data = new Data;
		if (!$data->Load('dID=?', array($dID))) {
			$this->flashError('Data Not Found');
			$this->redirect($this->path(), $dataType->dtID);
		}

		if ($this->isPost()) {
			if ($data->Delete()) {
				$this->flashSuccess(t('Data Deleted'));
				$this->redirect($this->path());
			}
			$this->flashError(t('Unknown Error'));
		}

		$this->set('data', $data);
		$this->set('dataType', $dataType);

		$this->render('delete');
	}

	/**
	 * @param $dtID int
	 */
	public function search($dtID) {
		$dataType = new DataType;
		$dataType->Load('dtID=?', array($dtID));
		$DataList = new DataList;
		$DataList->filterByDataTypeID($dtID);
		$this->set('dataType', $dataType);
		$this->set('datas', $DataList->get(0));

		$this->render('search');
	}

}<commit_msg>Add not found redirect to search<commit_after><?php
defined('C5_EXECUTE') or die('Access Denied.');

class DashboardDataManagementController extends DataDashboardBaseController {

	public function view() {
		$DataType = new DataType;
		$this->set('dataTypes', $DataType->Find('1=1'));
	}

	/**
	 * @param dtID int DataType id
	 */
	public function create($dtID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}

		$this->set('dataType', $dataType);
		$this->set('attributes', DataAttributeKey::getListByDataTypeID($dataType->dtID));
		$this->set('ah', Loader::helper('form/attribute'));
		
		if ($this->isPost()) {
			$data = new Data;
			$data->dtID = $dtID;
			$data->Insert();
			foreach ($this->post('akID') as $akID => $values) {
				$dak = DataAttributeKey::getByID($akID);
				$dak->saveAttributeForm($data);
			}
			$this->flashSuccess(t('Data Created'));
			$this->redirect($this->path('search'), $dataType->dtID);
		}

		$this->render('create');
	}

	/**
	 * @param $dtID int
	 * @param $dID int
	 */
	public function edit($dtID, $dID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}
		$data = new Data;
		if (!$data->Load('dID=?', array($dID))) {
			$this->flashError('Data Not Found');
			$this->redirect($this->path(), $dataType->dtID);
		}

		$this->set('data', $data);
		$this->set('dataType', $dataType);

		$this->set('attributes', DataAttributeKey::getListByDataTypeID($dataType->dtID));

		$ah = Loader::helper('form/attribute');
		$ah->setAttributeObject($data);
		$this->set('ah', $ah);

		if ($this->isPost()) {
			foreach ($this->post('akID') as $akID => $values) {
				$dak = DataAttributeKey::getByID($akID);
				$dak->saveAttributeForm($data);
			}
			$this->flashSuccess(t('Data Updated'));
			$this->redirect($this->path('search'), $dataType->dtID);
		}

		$this->render('edit');
	}

	/**
	 * @param $dtID int
	 * @param $dID int
	 */
	public function delete($dtID, $dID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}
		$data = new Data;
		if (!$data->Load('dID=?', array($dID))) {
			$this->flashError('Data Not Found');
			$this->redirect($this->path(), $dataType->dtID);
		}

		if ($this->isPost()) {
			if ($data->Delete()) {
				$this->flashSuccess(t('Data Deleted'));
				$this->redirect($this->path());
			}
			$this->flashError(t('Unknown Error'));
		}

		$this->set('data', $data);
		$this->set('dataType', $dataType);

		$this->render('delete');
	}

	/**
	 * @param $dtID int
	 */
	public function search($dtID) {
		$dataType = new DataType;
		if (!$dataType->Load('dtID=?', array($dtID))) {
			$this->flashError('Data Type Not Found');
			$this->redirect($this->path());
		}
		$DataList = new DataList;
		$DataList->filterByDataTypeID($dtID);
		$this->set('dataType', $dataType);
		$this->set('datas', $DataList->get(0));

		$this->render('search');
	}

}
{'fraction_non_alphanumeric': 0.2349417098445596, 'fraction_numerical': 0.0012953367875647669, 'mean_word_length': 4.3388072601555745, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 144, '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': '2975467', 'n_tokens_mistral': 2474, 'n_tokens_neox': 2216, 'n_words': 385}