vendor/memo_development/contao-portfolio-bundle/src/Resources/contao/dca/tl_memo_portfolio.php line 484

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