PHP-Code:
$GLOBALS['TL_DCA']['tl_linkscollection'] = array
(
// Config
'config' => array
(
'label' => $GLOBALS['TL_LANG']['tl_linkscollection']['maintitle'],
'dataContainer' => 'Table',
'ctable' => array('tl_linkscollection_links'),
'enableVersioning' => true,
'sql' => array
(
'keys' => array
(
'id' => 'primary',
'pid' => 'index',
'alias' => 'index'
)
)
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 5,
'fields' => array('sorting'),
'icon' => 'pagemounts.gif',
'panelLayout' => 'filter,search'
),
'label' => array
(
'fields' => array('title'),
'format' => '%s',
),
'global_operations' => array
(
'toggleNodes' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['toggleAll'],
'href' => 'ptg=all',
'class' => 'header_toggle',
'showOnSelect' => true
),
'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_linkscollection']['edit'],
'href' => 'table=tl_linkscollection_links',
'icon' => 'edit.gif',
),
'editheader' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['editheader'],
'href' => 'act=edit',
'icon' => 'header.gif',
),
)
),
// Palettes
'palettes' => array
(
'__selector__' => array('protected'),
'default' => '{title_legend},title,alias;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{published_legend},published,start,stop'
),
// Subpalettes
'subpalettes' => array
(
'protected' => 'groups'
),
// Fields
'fields' => array
(
'id' => array
(
'label' => array('ID'),
'search' => true,
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'pid' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'sorting' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'tstamp' => array
(
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['title'],
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>255, 'decodeEntities'=>true),
'sql' => "varchar(255) NOT NULL default ''"
),
'alias' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['alias'],
'exclude' => true,
'inputType' => 'text',
'search' => true,
'eval' => array('rgxp'=>'folderalias', 'doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varbinary(128) NOT NULL default ''",
'save_callback' => array
(
array('tl_linkscollection', 'generateAlias')
),
),
'protected' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['protected'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'eval' => array('submitOnChange'=>true),
'sql' => "char(1) NOT NULL default ''"
),
'groups' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['groups'],
'exclude' => true,
'inputType' => 'checkbox',
'foreignKey' => 'tl_member_group.name',
'eval' => array('mandatory'=>true, 'multiple'=>true),
'sql' => "blob NULL",
'relation' => array('type'=>'hasMany', 'load'=>'lazy')
),
'guests' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['guests'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'eval' => array('tl_class'=>'w50'),
'sql' => "char(1) NOT NULL default ''"
),
'cssID' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['cssID'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('multiple'=>true, 'size'=>2, 'tl_class'=>'w50 clr'),
'sql' => "varchar(255) NOT NULL default ''"
),
'space' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['space'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50'),
'sql' => "varchar(64) NOT NULL default ''"
),
'published' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['published'],
'exclude' => true,
'inputType' => 'checkbox',
'eval' => array('doNotCopy'=>true),
'sql' => "char(1) NOT NULL default ''"
),
'start' => array
(
'exclude' => true,
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['start'],
'inputType' => 'text',
'eval' => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
'sql' => "varchar(10) NOT NULL default ''"
),
'stop' => array
(
'exclude' => true,
'label' => &$GLOBALS['TL_LANG']['tl_linkscollection']['stop'],
'inputType' => 'text',
'eval' => array('rgxp'=>'datim', 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
'sql' => "varchar(10) NOT NULL default ''"
)
)
);
/**
* Class tl_linkscollection
*
* Provide miscellaneous methods that are used by the data configuration array.
* @copyright Leo Feyer 2005-2013
* @author Leo Feyer <https://contao.org>
* @package Core
*/
class tl_linkscollection extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
}
/**
* Auto-generate a page 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 an alias if there is none
if ($varValue == '')
{
$autoAlias = true;
$varValue = standardize(String::restoreBasicEntities($dc->activeRecord->title));
}
$objAlias = $this->Database->prepare("SELECT id FROM tl_linkscollection WHERE id=? OR alias=?")
->execute($dc->id, $varValue);
// Check whether the page alias exists
if ($objAlias->numRows > 1)
{
if (!$autoAlias)
{
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
$varValue .= '-' . $dc->id;
}
return $varValue;
}
}
Lesezeichen