vendor/memo_development/contao-team-bundle/src/Resources/contao/dca/tl_memo_team.php line 470

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @package   Memo\MemoTeamBundle
  4.  * @author    Media Motion AG
  5.  * @license   LGPL-3.0+
  6.  * @copyright Media Motion AG
  7.  */
  8. use Memo\MemoFoundationBundle\Classes\FoundationBackend;
  9. use Memo\TeamBundle\Model\TeamModel;
  10. /**
  11.  * Table tl_memo_team
  12.  */
  13. $GLOBALS['TL_DCA']['tl_memo_team'] = array
  14. (
  15.     // Config
  16.     'config' => array
  17.     (
  18.         'dataContainer'                    => 'Table',
  19.         'ptable'                        => 'tl_memo_team_archive',
  20.         'switchToEdit'                    => true,
  21.         'enableVersioning'                => true,
  22.         'markAsCopy'                    => 'title',
  23.         'onsubmit_callback'                => array(array('tl_memo_team','generateTitle')),
  24.         'sql' => array
  25.         (
  26.             'keys' => array
  27.             (
  28.                 'id' => 'primary',
  29.                 'pid,sorting' => 'index'
  30.             )
  31.         )
  32.     ),
  33.     // List
  34.     'list' => array
  35.     (
  36.         'sorting' => array
  37.         (
  38.             'mode'                        => 4,
  39.             'fields'                    => array('sorting'),
  40.             'panelLayout'                => 'filter;sort,search,limit',
  41.             'headerFields'                => array('title''alias'),
  42.             'child_record_callback'        => array(
  43.                 'tl_memo_team''listLayout'
  44.             ),
  45.         ),
  46.         'label' => array
  47.         (
  48.             'fields'                    => array('title''alias'),
  49.             'showColumns'                => true,
  50.         ),
  51.         'global_operations' => array
  52.         (
  53.             'all' => array
  54.             (
  55.                 'label'                    => &$GLOBALS['TL_LANG']['MSC']['all'],
  56.                 'href'                    => 'act=select',
  57.                 'class'                    => 'header_edit_all',
  58.                 'attributes'            => 'onclick="Backend.getScrollOffset();" accesskey="e"'
  59.             )
  60.         ),
  61.         'operations' => array
  62.         (
  63.             'edit' => array
  64.             (
  65.                 'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['edit'],
  66.                 'href'                    => 'act=edit',
  67.                 'icon'                    => 'edit.gif'
  68.             ),
  69.             'copy' => array
  70.             (
  71.                 'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['copy'],
  72.                 'href'                    => 'act=copy',
  73.                 'icon'                    => 'copy.gif'
  74.             ),
  75.             'delete' => array
  76.             (
  77.                 'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['delete'],
  78.                 'href'                    => 'act=delete',
  79.                 'icon'                    => 'delete.gif',
  80.                 'attributes'            => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['MSC']['deleteConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"'
  81.             ),
  82.             'toggle' => array
  83.             (
  84.                 'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['toggle'],
  85.                 'icon'                    => 'visible.gif',
  86.                 'attributes'            => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
  87.                 'button_callback'        => array(
  88.                     'tl_memo_team''toggleIcon'
  89.                 )
  90.             ),
  91.             'show' => array
  92.             (
  93.                 'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['show'],
  94.                 'href'                    => 'act=show',
  95.                 'icon'                    => 'show.gif'
  96.             ),
  97.         )
  98.     ),
  99.     // Select
  100.     'select' => array
  101.     (
  102.         'buttons_callback' => array()
  103.     ),
  104.     // Edit
  105.     'edit' => array
  106.     (
  107.         'buttons_callback' => array()
  108.     ),
  109.     // Palettes
  110.     'palettes' => array
  111.     (
  112.         'default'                        => '{general_legend}, firstname, lastname, categories, subtitle, alias, description;{meta_legend},seo_title,seo_description,serpPreview; {contact_legend}, phone, mobile, email;{media_legend},singleSRC, multiSRC;{date_legend}, date; {publish_legend}, published, start, stop;',
  113.     ),
  114.     // Subpalettes
  115.     'subpalettes' => array
  116.     (
  117.         ''                    => '',
  118.     ),
  119.     // Fields
  120.     'fields' => array
  121.     (
  122.         'id' => array
  123.         (
  124.             'sql'                        => "int(10) unsigned NOT NULL auto_increment"
  125.         ),
  126.         'pid' => array
  127.         (
  128.             'foreignKey'                => 'tl_memo_team_archive.id',
  129.             'sql'                        => "int(10) unsigned NOT NULL",
  130.             'relation'                    => array('type'=>'belongsTo''load'=>'lazy')
  131.         ),
  132.         'sorting' => array
  133.         (
  134.             'label'                        => &$GLOBALS['TL_LANG']['MSC']['sorting'],
  135.             'sorting'                    => true,
  136.             'flag'                        => 11,
  137.             'sql'                        => "int(10) unsigned NOT NULL default '0'"
  138.         ),
  139.         'tstamp' => array
  140.         (
  141.             'sql'                        => "int(10) unsigned NOT NULL default '0'"
  142.         ),
  143.         'title' => array
  144.         (
  145.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['title'],
  146.             'translate'                    => false,
  147.             'exclude'                    => true,
  148.             'filter'                    => false,
  149.             'search'                    => false,
  150.             'sorting'                    => false,
  151.             'inputType'                    => 'text',
  152.             'eval'                        => array(
  153.                 'mandatory'=>true,
  154.                 'maxlength' => 255,
  155.                 'tl_class' => 'w50'
  156.             ),
  157.             'sql'                        => "varchar(255) NOT NULL default ''",
  158.         ),
  159.         'lastname' => array
  160.         (
  161.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['lastname'],
  162.             'translate'                    => false,
  163.             'exclude'                    => true,
  164.             'filter'                    => false,
  165.             'search'                    => true,
  166.             'sorting'                    => true,
  167.             'inputType'                    => 'text',
  168.             'eval'                        => array(
  169.                 'mandatory'=>true,
  170.                 'maxlength' => 255,
  171.                 'tl_class' => 'w50'
  172.             ),
  173.             'sql'                        => "varchar(255) NOT NULL default ''",
  174.         ),
  175.         'firstname' => array
  176.         (
  177.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['firstname'],
  178.             'translate'                    => false,
  179.             'exclude'                    => true,
  180.             'filter'                    => false,
  181.             'search'                    => true,
  182.             'sorting'                    => true,
  183.             'inputType'                    => 'text',
  184.             'eval'                        => array(
  185.                 'mandatory'=>true,
  186.                 'maxlength' => 255,
  187.                 'tl_class' => 'w50'
  188.             ),
  189.             'sql'                        => "varchar(255) NOT NULL default ''",
  190.         ),
  191.         'subtitle' => array
  192.         (
  193.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['subtitle'],
  194.             'translate'                    => true,
  195.             'exclude'                    => true,
  196.             'filter'                    => false,
  197.             'search'                    => true,
  198.             'sorting'                    => true,
  199.             'inputType'                    => 'text',
  200.             'eval'                        => array(
  201.                 'mandatory'=>true,
  202.                 'maxlength' => 255,
  203.                 'tl_class' => 'clr w50'
  204.             ),
  205.             'sql'                        => "varchar(255) NOT NULL default ''",
  206.         ),
  207.         'alias' => array
  208.         (
  209.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['alias'],
  210.             'translate'                    => true,
  211.             'exclude'                    => true,
  212.             'filter'                    => false,
  213.             'search'                    => true,
  214.             'sorting'                    => false,
  215.             'inputType'                    => 'text',
  216.             'eval'                        => array(
  217.                 'rgxp'=>'alias',
  218.                 'doNotCopy'=>true,
  219.                 'maxlength'=>255,
  220.                 'tl_class'=>'w50'
  221.             ),
  222.             'save_callback'             => array
  223.             (
  224.                 array('tl_memo_team''generateAlias')
  225.             ),
  226.             'sql'                     => "varchar(255) BINARY NOT NULL default ''"
  227.         ),
  228.         'phone' => array
  229.         (
  230.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['phone'],
  231.             'exclude'                    => true,
  232.             'filter'                    => false,
  233.             'search'                    => true,
  234.             'sorting'                    => true,
  235.             'inputType'                    => 'text',
  236.             'eval'                        => array(
  237.                 'maxlength' => 255,
  238.                 'tl_class' => 'w50 clr',
  239.                 'allowHtml' => true
  240.             ),
  241.             'sql'                        => "varchar(255) NOT NULL default ''",
  242.         ),
  243.         'mobile' => array
  244.         (
  245.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['mobile'],
  246.             'exclude'                    => true,
  247.             'filter'                    => false,
  248.             'search'                    => true,
  249.             'sorting'                    => true,
  250.             'inputType'                    => 'text',
  251.             'eval'                        => array(
  252.                 'maxlength' => 255,
  253.                 'tl_class' => 'w50',
  254.                 'allowHtml' => true
  255.             ),
  256.             'sql'                        => "varchar(255) NOT NULL default ''",
  257.         ),
  258.         'email' => array
  259.         (
  260.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['email'],
  261.             'exclude'                    => true,
  262.             'filter'                    => false,
  263.             'search'                    => true,
  264.             'sorting'                    => true,
  265.             'inputType'                    => 'text',
  266.             'eval'                        => array(
  267.                 'mandatory'=>true,
  268.                 'maxlength' => 255,
  269.                 'tl_class' => 'w50 clr'
  270.             ),
  271.             'sql'                        => "varchar(255) NOT NULL default ''",
  272.         ),
  273.         'description' => array
  274.         (
  275.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['description'],
  276.             'translate'                    => true,
  277.             'exclude'                    => true,
  278.             'filter'                    => false,
  279.             'search'                    => false,
  280.             'sorting'                    => false,
  281.             'inputType'                    => 'textarea',
  282.             'eval'                        => array(
  283.                 'mandatory' => false,
  284.                 'rte' => 'tinyMCE',
  285.                 'tl_class' => 'clr',
  286.             ),
  287.             'sql'                        => "mediumtext NULL"
  288.         ),
  289.         'singleSRC' => array
  290.         (
  291.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['singleSRC'],
  292.             'exclude'                    => true,
  293.             'filter'                    => false,
  294.             'search'                    => false,
  295.             'sorting'                    => false,
  296.             'inputType'                    => 'fileTree',
  297.             'eval'                        => array(
  298.                 'filesOnly' => true,
  299.                 'extensions' => Config::get('validImageTypes'),
  300.                 'fieldType' => 'radio'),
  301.             'sql'                        => "binary(16) NULL"
  302.         ),
  303.         'multiSRC' => array
  304.         (
  305.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['multiSRC'],
  306.             'exclude'                    => true,
  307.             'inputType'                    => 'fileTree',
  308.             'eval'                        => array(
  309.                 'multiple' => true,
  310.                 'fieldType' => 'checkbox',
  311.                 'orderField' => 'orderSRC',
  312.                 'files' => true,
  313.                 'extensions' => Config::get('validImageTypes'),
  314.                 'isGallery' => true,
  315.                 'tl_class' => 'clr m12'
  316.             ),
  317.             'sql'                        => "blob NULL"
  318.         ),
  319.         'orderSRC' => array
  320.         (
  321.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['orderSRC'],
  322.             'sql'                        => "blob NULL"
  323.         ),
  324.         'categories' => array
  325.         (
  326.             'label'                     => &$GLOBALS['TL_LANG']['tl_memo_team']['categories'],
  327.             'exclude'                    => true,
  328.             'inputType'                    => 'multiColumnWizard',
  329.             'eval'                        => array(
  330.                 'tl_class' => 'clr',
  331.                 'style' => 'width:710px; max-width: 100%;',
  332.                 'dragAndDrop' => false,
  333.                 'columnFields' => array(
  334.                     'category_id' => array(
  335.                         'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['category_id'],
  336.                         'exclude'                => true,
  337.                         'inputType'                => 'select',
  338.                         'options_callback'        => array('memo.foundation.category''getCategoriesByDC'),
  339.                         'eval' => array(
  340.                             'style' => 'width:250px',
  341.                             'includeBlankOption' => true,
  342.                             'multiple' => false,
  343.                         ),
  344.                     ),
  345.                     'category_fk_meta' => array(
  346.                         'label'                    => &$GLOBALS['TL_LANG']['tl_memo_team']['category_fk_meta'],
  347.                         'exclude'                => true,
  348.                         'inputType'                => 'text',
  349.                         'eval'    => array(
  350.                             'style' => 'width:400px'
  351.                         ),
  352.                     ),
  353.                 ),
  354.             ),
  355.             'sql'                        => "blob NULL"
  356.         ),
  357.         'date' => array
  358.         (
  359.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['date'],
  360.             'default'                    => time(),
  361.             'exclude'                    => true,
  362.             'filter'                    => false,
  363.             'sorting'                    => true,
  364.             'inputType'                    => 'text',
  365.             'eval'                        => array('rgxp'=>'date''mandatory'=>true'doNotCopy'=>true'datepicker'=>true'tl_class'=>'w50 wizard'),
  366.             'load_callback' => array
  367.             (
  368.                 array('memo.foundation.toolbox''loadDate')
  369.             ),
  370.             'sql'                        => "int(10) unsigned NOT NULL default 0"
  371.         ),
  372.         'seo_title' => array
  373.         (
  374.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['seo_title'],
  375.             'translate'                    => true,
  376.             'exclude'                    => true,
  377.             'filter'                    => false,
  378.             'search'                    => false,
  379.             'sorting'                    => false,
  380.             'inputType'                    => 'text',
  381.             'eval'                        => array('mandatory'=>false'maxlength'=>128'tl_class' => 'clr'),
  382.             'sql'                        => "varchar(128) NOT NULL default ''",
  383.         ),
  384.         'seo_description' => array
  385.         (
  386.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['seo_description'],
  387.             'translate'                    => true,
  388.             'exclude'                    => true,
  389.             'filter'                    => false,
  390.             'search'                    => false,
  391.             'sorting'                    => false,
  392.             'inputType'                    => 'textarea',
  393.             'eval'                        => array('mandatory'=>false'maxlength'=>255'tl_class' => 'clr'),
  394.             'sql'                        => "varchar(255) NOT NULL default ''",
  395.         ),
  396.         'serpPreview' => array
  397.         (
  398.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['serpPreview'],
  399.             'exclude'                    => true,
  400.             'inputType'                    => 'serpPreview',
  401.             'eval'                        => array('url_callback'=>array('tl_memo_team''getSerpUrl'), 'titleFields'=>array('seo_title''title''lastname'), 'descriptionFields'=>array('seo_description''description')),
  402.             'sql'                        => null
  403.         ),
  404.         'published' => array
  405.         (
  406.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['published'],
  407.             'exclude'                    => true,
  408.             'filter'                    => true,
  409.             'search'                    => false,
  410.             'sorting'                    => false,
  411.             'inputType'                    => 'checkbox',
  412.             'eval'                        => array(
  413.                 'doNotCopy'=>true,
  414.                 'tl_class'=>'w50'
  415.             ),
  416.             'sql'                        => "char(1) NOT NULL default ''",
  417.         ),
  418.         'start' => array
  419.         (
  420.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['start'],
  421.             'exclude'                    => true,
  422.             'filter'                    => false,
  423.             'search'                    => false,
  424.             'sorting'                    => false,
  425.             'inputType'                    => 'text',
  426.             'eval'                        => array('rgxp'=>'datim''datepicker'=>true'tl_class'=>'w50 wizard clr'),
  427.             'sql'                        => "varchar(10) NOT NULL default ''"
  428.         ),
  429.         'stop' => array
  430.         (
  431.             'label'                        => &$GLOBALS['TL_LANG']['tl_memo_team']['stop'],
  432.             'exclude'                    => true,
  433.             'filter'                    => false,
  434.             'search'                    => false,
  435.             'sorting'                    => false,
  436.             'inputType'                    => 'text',
  437.             'eval'                        => array('rgxp'=>'datim''datepicker'=>true'tl_class'=>'w50 wizard'),
  438.             'sql'                        => "varchar(10) NOT NULL default ''"
  439.         )
  440.     )
  441. );
  442. // Enable a hook to be loaded here
  443. if (isset($GLOBALS['TL_HOOKS']['generateTeamDCA']) && \is_array($GLOBALS['TL_HOOKS']['generateTeamDCA']))
  444. {
  445.     foreach ($GLOBALS['TL_HOOKS']['generateTeamDCA'] as $callback)
  446.     {
  447.         $this->import($callback[0]);
  448.         $GLOBALS['TL_DCA']['tl_memo_team'] = $this->{$callback[0]}->{$callback[1]}($GLOBALS['TL_DCA']['tl_memo_team'], $this);
  449.     }
  450. }
  451. // Add multi-lang fields automatically by checking for the translate field
  452. $objLanguageService \System::getContainer()->get('memo.foundation.language');
  453. $objLanguageService->generateTranslateDCA('tl_memo_team');
  454. $objToolboxService \System::getContainer()->get('memo.foundation.toolbox');
  455. $objToolboxService->toggleDetailFieldsFromPalette('tl_memo_team');
  456. // Enable a hook to be loaded here
  457. if (isset($GLOBALS['TL_HOOKS']['generateTeamDCAComplete']) && \is_array($GLOBALS['TL_HOOKS']['generateTeamDCAComplete']))
  458. {
  459.     foreach ($GLOBALS['TL_HOOKS']['generateTeamDCAComplete'] as $callback)
  460.     {
  461.         $this->import($callback[0]);
  462.         $GLOBALS['TL_DCA']['tl_memo_team'] = $this->{$callback[0]}->{$callback[1]}($GLOBALS['TL_DCA']['tl_memo_team'], $this);
  463.     }
  464. }
  465. /**
  466.  * Class tl_memo_team
  467.  */
  468. class tl_memo_team extends FoundationBackend
  469. {
  470.     public function getSerpUrl($objItem)
  471.     {
  472.         return $this->generateSerpUrl($objItem);
  473.     }
  474.     public function generateTitle(DataContainer $dc)
  475.     {
  476.         // Get the current item
  477.         $objItem TeamModel::findByPk($dc->activeRecord->id);
  478.         // Set the new title - based on firstname and lastname
  479.         $objItem->title $dc->activeRecord->firstname ' ' $dc->activeRecord->lastname;
  480.         // Save the title
  481.         $objItem->save();
  482.     }
  483.     public function listLayout($row)
  484.     {
  485.         return '<div class="tl_content_left">''<strong>' $row['firstname'] . ' ' $row['lastname'] . '</strong></div>';
  486.     }
  487.     public function generateAlias($varValueDataContainer $dc)
  488.     {
  489.         return $this->generateAliasFoundation($dc$varValue'tl_memo_team', array('title'));
  490.     }
  491.     public function toggleIcon($row$href$label$title$icon$attributes)
  492.     {
  493.         return $this->toggleIconFoundation($row'published''invisible'$icon$title$attributes$label);
  494.     }
  495.     public function toggleVisibility($intId$blnVisibleDataContainer $dc=null)
  496.     {
  497.         $this->toggleVisibilityFoundation($intId$blnVisible$dc'tl_memo_team''published');
  498.     }
  499. }