Code:
<?php
/**
*
* @package Diagnostik
* @license GNU/LGPL
*/
/**
* Table tl_genes
*/
$GLOBALS['TL_DCA']['tl_genes'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
'enableVersioning' => true,
'sql' => array
(
'keys' => array
(
'id' => 'primary'
)
)
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 2,
'fields' => array('title'),
'flag' => 1,
'panelLayout' => 'filter,search;limit'
),
'label' => array
(
'fields' => array('title'),
'format' => '%s'
),
'global_operations' => array
(
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();" accesskey="e"'
)
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Edit
'edit' => array
(
'buttons_callback' => array()
),
// Palettes
'palettes' => array
(
'__selector__' => array(''),
'default' => '{title_legend},title,title_en,omim,alias,is_gene;{methode_legend},methode;{material_legend},material_id;{period_legend},period_id;{panel_legend},panel_id;'
),
// Subpalettes
'subpalettes' => array
(
'' => ''
),
// Fields
'fields' => array
(
'id' => array
(
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'tstamp' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'alias' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['alias'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('rgxp'=>'alnum', 'unique'=>true, 'spaceToUnderscore'=>true, 'tl_class'=>'w50'),
'save_callback' => array
(
array('GenHelper', 'generateAlias')
),
'sql' => "text NULL"
),
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['title'],
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'title_en' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['title_en'],
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>false, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'omim' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['omim'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('mandatory'=>false, 'maxlength'=>255, 'tl_class'=>'w50'),
'sql' => "varchar(255) NOT NULL default ''"
),
'is_gene' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['is_gene'],
'default' => '1',
'inputType' => 'radio',
'options' => array('1'=>'Gen', '2'=>'Erkrankung'),
'filter' => true,
'eval' => array('tl_class'=>'w50'),
'sql' => "int(1) unsigned NOT NULL default '0'"
),
'methode' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['methode'],
'inputType' => 'select',
'foreignKey' => 'tl_methods.title',
'filter' => true,
'eval' => array('multiple'=>true, 'mandatory'=>false, 'chosen'=>true, 'tl_class'=>'long'),
'sql' => "text NULL",
'relation' => array("type" => 'hasMany','load' => 'eager')
),
'material_id' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['material_id'],
'inputType' => 'select',
'foreignKey' => 'tl_material.title',
'search' => true,
'eval' => array('multiple'=>true, 'mandatory'=>false, 'chosen'=>true, 'tl_class'=>'long'),
'sql' => "text NULL",
'relation' => array('type' => 'hasMany','load' => 'eager')
),
'period_id' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['period_id'],
'inputType' => 'select',
'foreignKey' => 'tl_period.title',
'search' => true,
'eval' => array('multiple'=>false, 'mandatory'=>true),
'sql' => "text NULL",
'relation' => array('type' => 'hasMany','load' => 'eager')
),
'panel_id' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_genes']['panel_id'],
'inputType' => 'select',
'foreignKey' => 'tl_subpanels.title',
'search' => true,
'eval' => array('multiple'=>true, 'mandatory'=>false, 'chosen'=>true, 'tl_class'=>'long'),
'sql' => "text NULL",
'relation' => array('type' => 'hasMany','load' => 'eager')
),
'gen_id' => array(
'sql' => "varchar(255) NOT NULL unique default ''"
),
)
);
class GenHelper extends Backend{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
}
/**
* Auto-generate an article alias if it has not been set yet
* @param mixed
* @param \DataContainer
* @return string
* @throws \Exception
*/
public function generateAlias($varValue, DataContainer $dc)
{
$autoAlias = false;
// Generate alias if there is none
if ($varValue == '')
{
$autoAlias = true;
$varValue = standardize(StringUtilrestoreBasicEntities($dc->activeRecord->title));
}
$objAlias = $this->Database->prepare("SELECT id FROM tl_genes WHERE alias=?")
->execute($varValue);
// Check whether the alias exists
if ($objAlias->numRows > 1 && !$autoAlias)
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
// Add ID to alias
if ($objAlias->numRows && $autoAlias)
{
$varValue .= '-' . $dc->id;
}
return $varValue;
}
}
Lesezeichen