PHP-Code:
<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
/**
* Table tl_km_dokumente
*/
$GLOBALS['TL_DCA']['tl_km_dokumente'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
'ptable' => 'tl_km_tops',
'onsubmit_callback' => array(array('tl_km_dokumente','aendernDateiname'))
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 4,
'fields' => array('typ'),
'flag' => 12,
'headerFields' => array('pid','top_nr'),
'panelLayout' => 'search,limit',
'disableGrouping' => true,
'child_record_callback' => array('tl_km_dokumente', 'listDoks')
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif',
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif',
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['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_km_dokumente']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Palettes
'palettes' => array
(
'__selector__' => array('typ'),
'default' => 'datei,typ',
//s. Funktion getTypes: $types = ModuleSitzungen::$types[$objResult->datcont];
//$objResult->datcont = Value des Eltern-Elementes (0 oder 1)
/*$types = array(
'0' =>array(
'TO-Entwurf' => 'TO-Entwurf',
'Sachstand' => 'Sachstand',
'Anlage' => 'Anlage',
'Anhang' => 'Anhang',
'Präsentation' => 'Präsentation'
),
'1' =>array(
'Prot_VS' => 'Protokoll - Entwurf abgestimmt mit Vorsitz',
'Prot_TN' => 'Protokoll - Entwurf abgestimmt mit TeilnehmerInnen',
'Prot' => 'Protokoll - vollabgestimmter Entwurf ',
'Prot_final' => 'Protokoll - endgültige Version',
'ZIP-Archiv' => 'ZIP-Archiv'
)
);*/
'Prot_final' => 'datei,typ,datname,published',
'Sachstand' => 'datei,typ,published,up_datname'
),
// Fields
'fields' => array
(
'typ' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['typ'],
'inputType' => 'radio',
'eval' => array('mandatory'=>true, 'submitOnChange' => true),
'exclude' => true,
'options_callback' => array('tl_km_dokumente','getTypes')
),
'datname' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['datname'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('maxlength'=>255, 'tl_class'=>'long')
),
'published' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['published'],
'default' => true,
'exclude' => true,
'inputType' => 'checkbox'
),
'up_datname' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_km_dokumente']['up_datname'],
'exclude' => true,
'inputType' => 'text',
'eval' => array('maxlength'=>255)
),
)
);
class tl_km_dokumente extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
}
/**
* Ändern des Dateinamens
*/
public function aendernDateiname(DataContainer $dc)
{
// hier hat viel Programmtext gestanden. Gelöscht, weil für Problemstellung nicht relevant
return true;
}
/**
* Übergeben der Optionen für Feld "typ"
*/
public function getTypes(DataContainer $dc)
{
$objResult = $this->Database->prepare("SELECT datcont FROM tl_km_tops WHERE id=?")
->execute($dc->activeRecord->pid);
$types = ModuleSitzungen::$types[$objResult->datcont];
return $types;
}
/**
* Listet alle Dokumente eines TOPs
* @param array
* @return string
*/
public function listDoks($arrRow)
{
$datname = substr (strrchr ($arrRow['datei'], "/"), 1);
return '<div class="limit_height block"> <p><span style="display:block; float:left; font-weight: bold; width:90px;" class="top_nr">' . $arrRow['typ'] .':</span><span class="top_thema">'. $datname . '</span></p></div>' . "\n";
}
}
?>
in der Funktion "getTypes" werden die Options für das Feld "typ" entsprechend des Eltern-Elementes gesetzt und anhand der Auswahl im Feld "typ" werden die Paletten dann angezeigt. Wichtig ist auf jeden Fall auch, dass die default-Palette existiert und das Feld "typ" ein 'submitOnChange' => true erhält.
Lesezeichen