<commit_before><?php

use yii\helpers\Inflector;
use yii\helpers\StringHelper;

/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\crud\Generator */

$urlParams = $generator->generateUrlParams();

$controllerClass = StringHelper::basename($generator->controllerClass);
$modelClass = StringHelper::basename($generator->modelClass);
$label = Inflector::camel2words($modelClass);
$tableSchema = $generator->getTableSchema();

$primaryKey = $generator->getPrimaryKey($tableSchema);
$foreignKeys = $generator->getForeignKeys($tableSchema->foreignKeys);
$functionLabel = ucwords(Inflector::pluralize($generator->shortLabel($modelClass)));

$uploadCondition = 0;
$getFunctionCondition = 0;
$permissionCondition = 0;
$primaryKeyTriggerCondition = 0;
$relationCondition = 0;
$enumCondition = 0;
foreach ($tableSchema->columns as $column) {
	$commentArray = explode(',', $column->comment);
	if($column->type == 'text' && in_array('file', $commentArray)) 
		$uploadCondition = 1;
	if($column->comment != '' && $column->comment[0] == '"')
		$getFunctionCondition = 1;
	if($column->name == 'permission')
		$permissionCondition = 1;
	if (is_array($column->enumValues) && count($column->enumValues) > 0)
		$enumCondition = 1;
}
$primaryKeyColumn = $tableSchema->columns[$primaryKey];
if($primaryKeyColumn->comment == 'trigger')
	$primaryKeyTriggerCondition = 1;

foreach ($relations as $name => $relation) {
	if($relation[2])
		$relationCondition = 1;
}

$dropDownOptions = $generator->dropDownOptions($tableSchema);

$yaml = $generator->loadYaml('author.yaml');

echo "<?php\n";
?>
/**
 * <?php echo Inflector::pluralize($label); ?> (<?php echo Inflector::camel2id($modelClass); ?>)
 * @var $this app\components\View
 * @var $this <?php echo ltrim($generator->controllerClass)."\n"; ?>
 * @var $model <?php echo ltrim($generator->modelClass)."\n"; ?>
 *
 * @author <?php echo $yaml['author'];?> <?php echo '<'.$yaml['email'].'>'."\n";?>
 * @contact <?php echo $yaml['contact']."\n";?>
 * @copyright Copyright (c) <?php echo date('Y'); ?> <?php echo $yaml['copyright']."\n";?>
 * @created date <?php echo date('j F Y, H:i')." WIB\n"; ?>
<?php if($generator->useModified) {?>
 * @modified date <?php echo date('j F Y, H:i')." WIB\n"; ?>
 * @modified by <?php echo $yaml['author'];?> <?php echo '<'.$yaml['email'].'>'."\n";?>
 * @contact <?php echo $yaml['contact']."\n";?>
<?php }?>
 * @link <?php echo $generator->link."\n";?>
 *
 */

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\DetailView;
use yii\helpers\ArrayHelper;
<?php echo $uploadCondition || $getFunctionCondition || $permissionCondition || $enumCondition ? "use ".ltrim($generator->modelClass).";\n" : '';?>

$this->params['breadcrumbs'][] = ['label' => <?php echo $generator->generateString($functionLabel) ?>, 'url' => ['index']];
$this->params['breadcrumbs'][] = $model-><?php echo $generator->getNameAttribute(); ?>;

$this->params['menu']['content'] = [
	['label' => <?php echo $generator->generateString('Detail') ?>, 'url' => Url::to(['view', <?php echo $urlParams ?>]), 'icon' => 'eye'],
	['label' => <?php echo $generator->generateString('Update') ?>, 'url' => Url::to(['update', <?php echo $urlParams ?>]), 'icon' => 'pencil'],
	['label' => <?php echo $generator->generateString('Delete') ?>, 'url' => Url::to(['delete', <?php echo $urlParams ?>]), 'htmlOptions' => ['data-confirm'=><?php echo $generator->generateString('Are you sure you want to delete this item?') ?>, 'data-method'=>'post'], 'icon' => 'trash'],
];
?>

<div class="<?php echo Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-view">

<?php echo "<?php\n" ?>
$attributes = [
<?php
if (($tableSchema = $tableSchema) === false) {
	foreach ($generator->getColumnNames() as $name) {
		echo "\t\t'" . $name . "',\n";
	}
} else {
	foreach ($tableSchema->columns as $column) {
		if($column->name[0] == '_')
			continue;

		$foreignCondition = 0;
		$foreignUserCondition = 0;
		if(!empty($foreignKeys) && array_key_exists($column->name, $foreignKeys)) {
			$foreignCondition = 1;
			if($foreignKeys[$column->name] == 'ommu_users')
				$foreignUserCondition = 1;
		}

		$commentArray = explode(',', $column->comment);

if($foreignCondition || in_array('user', $commentArray) || ((!$column->autoIncrement || !$column->isPrimaryKey) && in_array($column->name, ['creation_id','modified_id','user_id','updated_id','tag_id','member_id']))) {
	$smallintCondition = 0;
	if(preg_match('/(smallint)/', $column->type))
		$smallintCondition = 1;
	$relationName = $generator->setRelation($column->name);
	$relationFixedName = $generator->setRelationFixed($relationName, $tableSchema->columns);
	$relationAttribute = $variableAttribute = 'displayname';
	$publicAttribute = $relationName.ucwords(Inflector::id2camel($variableAttribute, '_'));
	if(array_key_exists($column->name, $foreignKeys)) {
		$relationTable = trim($foreignKeys[$column->name]);
		$relationAttribute = $generator->getNameAttribute($relationTable);
		$relationSchema = $generator->getTableSchemaWithTableName($relationTable);
		$variableAttribute = key($generator->getNameAttributes($relationSchema));
		if(in_array($relationTable, ['ommu_users', 'ommu_members']))
			$relationAttribute = $variableAttribute = 'displayname';
		$publicAttribute = $relationName.ucwords(Inflector::id2camel($variableAttribute, '_'));
		if(preg_match('/('.$relationName.')/', $variableAttribute))
			$publicAttribute = lcfirst(Inflector::id2camel($variableAttribute, '_'));
	}
	if($column->name == 'tag_id') {
		$publicAttribute = $relationName.ucwords('body');
		$relationAttribute =  'body';
	}?>
	[
		'attribute' => '<?php echo $publicAttribute;?>',
<?php if($foreignCondition && !$foreignUserCondition):
	$controller = Inflector::singularize($relationName) != $generator->getModuleName() ? Inflector::singularize($relationName) : 'admin';?>
		'value' => function ($model) {
			$<?php echo $publicAttribute;?> = isset($model-><?php echo $relationFixedName;?>) ? $model-><?php echo $relationFixedName;?>-><?php echo $relationAttribute;?> : '-';
			if($<?php echo $publicAttribute;?> != '-')
				return Html::a($<?php echo $publicAttribute;?>, ['<?php echo $controller;?>/view', 'id'=>$model-><?php echo $column->name;?>], ['title'=>$<?php echo $publicAttribute;?>]);
			return $<?php echo $publicAttribute;?>;<commit_msg>commit<commit_after><?php

use yii\helpers\Inflector;
use yii\helpers\StringHelper;

/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\crud\Generator */

$urlParams = $generator->generateUrlParams();

$controllerClass = StringHelper::basename($generator->controllerClass);
$modelClass = StringHelper::basename($generator->modelClass);
$label = Inflector::camel2words($modelClass);
$tableSchema = $generator->getTableSchema();

$primaryKey = $generator->getPrimaryKey($tableSchema);
$foreignKeys = $generator->getForeignKeys($tableSchema->foreignKeys);
$functionLabel = ucwords(Inflector::pluralize($generator->shortLabel($modelClass)));

$uploadCondition = 0;
$getFunctionCondition = 0;
$permissionCondition = 0;
$primaryKeyTriggerCondition = 0;
$relationCondition = 0;
$enumCondition = 0;
foreach ($tableSchema->columns as $column) {
	$commentArray = explode(',', $column->comment);
	if($column->type == 'text' && in_array('file', $commentArray)) 
		$uploadCondition = 1;
	if($column->comment != '' && $column->comment[0] == '"')
		$getFunctionCondition = 1;
	if($column->name == 'permission')
		$permissionCondition = 1;
	if (is_array($column->enumValues) && count($column->enumValues) > 0)
		$enumCondition = 1;
}
$primaryKeyColumn = $tableSchema->columns[$primaryKey];
if($primaryKeyColumn->comment == 'trigger')
	$primaryKeyTriggerCondition = 1;

foreach ($relations as $name => $relation) {
	if($relation[2])
		$relationCondition = 1;
}

$dropDownOptions = $generator->dropDownOptions($tableSchema);

$yaml = $generator->loadYaml('author.yaml');

echo "<?php\n";
?>
/**
 * <?php echo Inflector::pluralize($label); ?> (<?php echo Inflector::camel2id($modelClass); ?>)
 * @var $this app\components\View
 * @var $this <?php echo ltrim($generator->controllerClass)."\n"; ?>
 * @var $model <?php echo ltrim($generator->modelClass)."\n"; ?>
 *
 * @author <?php echo $yaml['author'];?> <?php echo '<'.$yaml['email'].'>'."\n";?>
 * @contact <?php echo $yaml['contact']."\n";?>
 * @copyright Copyright (c) <?php echo date('Y'); ?> <?php echo $yaml['copyright']."\n";?>
 * @created date <?php echo date('j F Y, H:i')." WIB\n"; ?>
<?php if($generator->useModified) {?>
 * @modified date <?php echo date('j F Y, H:i')." WIB\n"; ?>
 * @modified by <?php echo $yaml['author'];?> <?php echo '<'.$yaml['email'].'>'."\n";?>
 * @contact <?php echo $yaml['contact']."\n";?>
<?php }?>
 * @link <?php echo $generator->link."\n";?>
 *
 */

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\DetailView;
use yii\helpers\ArrayHelper;
<?php echo $uploadCondition || $getFunctionCondition || $permissionCondition || $enumCondition ? "use ".ltrim($generator->modelClass).";\n" : '';?>

$this->params['breadcrumbs'][] = ['label' => <?php echo $generator->generateString($functionLabel) ?>, 'url' => ['index']];
$this->params['breadcrumbs'][] = $model-><?php echo $generator->getNameAttribute(); ?>;

$this->params['menu']['content'] = [
	['label' => <?php echo $generator->generateString('Detail') ?>, 'url' => Url::to(['view', <?php echo $urlParams ?>]), 'icon' => 'eye'],
	['label' => <?php echo $generator->generateString('Update') ?>, 'url' => Url::to(['update', <?php echo $urlParams ?>]), 'icon' => 'pencil'],
	['label' => <?php echo $generator->generateString('Delete') ?>, 'url' => Url::to(['delete', <?php echo $urlParams ?>]), 'htmlOptions' => ['data-confirm'=><?php echo $generator->generateString('Are you sure you want to delete this item?') ?>, 'data-method'=>'post'], 'icon' => 'trash'],
];
?>

<div class="<?php echo Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-view">

<?php echo "<?php\n" ?>
$attributes = [
<?php
if (($tableSchema = $tableSchema) === false) {
	foreach ($generator->getColumnNames() as $name) {
		echo "\t\t'" . $name . "',\n";
	}
} else {
	foreach ($tableSchema->columns as $column) {
		if($column->name[0] == '_')
			continue;

		$foreignCondition = 0;
		$foreignUserCondition = 0;
		if(!empty($foreignKeys) && array_key_exists($column->name, $foreignKeys)) {
			$foreignCondition = 1;
			if($foreignKeys[$column->name] == 'ommu_users')
				$foreignUserCondition = 1;
		}

		$commentArray = explode(',', $column->comment);

if($foreignCondition || in_array('user', $commentArray) || ((!$column->autoIncrement || !$column->isPrimaryKey) && in_array($column->name, ['creation_id','modified_id','user_id','updated_id','tag_id','member_id']))) {
	$smallintCondition = 0;
	if(preg_match('/(smallint)/', $column->type))
		$smallintCondition = 1;
	$relationName = $generator->setRelation($column->name);
	$relationFixedName = $generator->setRelationFixed($relationName, $tableSchema->columns);
	$relationAttribute = $variableAttribute = 'displayname';
	$publicAttribute = $relationName.ucwords(Inflector::id2camel($variableAttribute, '_'));
	if(array_key_exists($column->name, $foreignKeys)) {
		$relationTable = trim($foreignKeys[$column->name]);
		$relationAttribute = $generator->getNameAttribute($relationTable);
		$relationSchema = $generator->getTableSchemaWithTableName($relationTable);
		$variableAttribute = key($generator->getNameAttributes($relationSchema));
		if(in_array($relationTable, ['ommu_users', 'ommu_members']))
			$relationAttribute = $variableAttribute = 'displayname';
		$publicAttribute = $relationName.ucwords(Inflector::id2camel($variableAttribute, '_'));
		if(preg_match('/('.$relationName.')/', $variableAttribute))
			$publicAttribute = lcfirst(Inflector::id2camel($variableAttribute, '_'));
	}
	if($column->name == 'tag_id') {
		$publicAttribute = $relationName.ucwords('body');
		$relationAttribute =  'body';
	}?>
	[
		'attribute' => '<?php echo $publicAttribute;?>',
<?php if($foreignCondition && !$foreignUserCondition):
	$controller = Inflector::singularize($relationName) != $generator->getModuleName() ? Inflector::singularize($relationName) : 'admin';?>
		'value' => function ($model) {
			$<?php echo $publicAttribute;?> = isset($model-><?php echo $relationFixedName;?>) ? $model-><?php echo $relationFixedName;?>-><?php echo $relationAttribute;?> : '-';
			if($<?php echo $publicAttribute;?> != '-')
				return Html::a($<?php echo $publicAttribute;?>, ['<?php echo $controller;?>/view', 'id'=>$model-><?php echo $column->name;?>], ['title'=>$<?php echo $publicAttribute;?>, 'class'=>'modal-btn']);
			return $<?php echo $publicAttribute;?>;
{'fraction_non_alphanumeric': 0.22388884503039394, 'fraction_numerical': 0.004420936291150233, 'mean_word_length': 6.645141822570912, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 262, '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': '4023943', 'n_tokens_mistral': 4184, 'n_tokens_neox': 4044, 'n_words': 756}