vendor/numero2/contao-opengraph3/src/Resources/contao/dca/tl_page.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3.  * Contao Open Source CMS
  4.  *
  5.  * Copyright (c) 2005-2021 Leo Feyer
  6.  *
  7.  * @package   Opengraph3
  8.  * @author    Benny Born <benny.born@numero2.de>
  9.  * @author    Michael Bösherz <michael.boesherz@numero2.de>
  10.  * @license   LGPL
  11.  * @copyright 2021 numero2 - Agentur für digitales Marketing GbR
  12.  */
  13. if( !empty($GLOBALS['TL_DCA']['tl_page']) ) {
  14.     \System::loadLanguageFile('opengraph_fields');
  15.     \Controller::loadDataContainer('opengraph_fields');
  16.     /**
  17.      * Modify palettes
  18.      */
  19.     $GLOBALS['TL_DCA']['tl_page']['palettes']['root'] = str_replace(
  20.         '{dns_legend'
  21.     ,   $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{dns_legend'
  22.     ,   $GLOBALS['TL_DCA']['tl_page']['palettes']['root']
  23.     );
  24.     if( version_compare(VERSION'4.9''==') ) {
  25.         $GLOBALS['TL_DCA']['tl_page']['palettes']['rootfallback'] = str_replace(
  26.             '{dns_legend'
  27.         ,   $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{dns_legend'
  28.         ,   $GLOBALS['TL_DCA']['tl_page']['palettes']['rootfallback']
  29.         );
  30.     } else if( version_compare(VERSION'4.9''>') ) {
  31.         $GLOBALS['TL_DCA']['tl_page']['palettes']['root'] = str_replace(
  32.             '{url_legend'
  33.         ,   $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{url_legend'
  34.         ,   $GLOBALS['TL_DCA']['tl_page']['palettes']['root']
  35.         );
  36.         $GLOBALS['TL_DCA']['tl_page']['palettes']['rootfallback'] = str_replace(
  37.             '{url_legend'
  38.         ,   $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{url_legend'
  39.         ,   $GLOBALS['TL_DCA']['tl_page']['palettes']['rootfallback']
  40.         );
  41.     }
  42.     $GLOBALS['TL_DCA']['tl_page']['palettes']['regular'] = str_replace(
  43.         '{protected_legend'
  44.     ,   $GLOBALS['TL_DCA']['opengraph_fields']['palettes']['default'].'{protected_legend'
  45.     ,   $GLOBALS['TL_DCA']['tl_page']['palettes']['regular']
  46.     );
  47.     /**
  48.      * Modify fields
  49.      */
  50.     $GLOBALS['TL_DCA']['tl_page']['fields'] = array_merge(
  51.         $GLOBALS['TL_DCA']['tl_page']['fields']
  52.     ,   $GLOBALS['TL_DCA']['opengraph_fields']['fields']
  53.     );
  54.     /**
  55.      * Add legends
  56.      */
  57.     array_walk(
  58.         $GLOBALS['TL_LANG']['opengraph_fields']['legends']
  59.     ,   function( $translation$key ) {
  60.             $GLOBALS['TL_LANG']['tl_page'][$key] = $translation;
  61.         }
  62.     );
  63. }