vendor/contao/core-bundle/src/Resources/contao/helper/functions.php line 410

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Contao.
  4.  *
  5.  * (c) Leo Feyer
  6.  *
  7.  * @license LGPL-3.0-or-later
  8.  */
  9. use Contao\ArrayUtil;
  10. use Contao\Folder;
  11. use Contao\StringUtil;
  12. use Contao\System;
  13. use Symfony\Component\String\UnicodeString;
  14. /**
  15.  * Add a log entry
  16.  *
  17.  * @param string $strMessage
  18.  * @param string $strLog
  19.  *
  20.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  21.  *             Use the logger service instead.
  22.  */
  23. function log_message($strMessage$strLog=null)
  24. {
  25.     trigger_deprecation('contao/core-bundle''4.0''Using "log_message()" has been deprecated and will no longer work in Contao 5.0. Use the logger service instead.');
  26.     if ($strLog === null)
  27.     {
  28.         $strLog 'prod-' date('Y-m-d') . '.log';
  29.     }
  30.     $strLogsDir null;
  31.     if (($container System::getContainer()) !== null)
  32.     {
  33.         $strLogsDir $container->getParameter('kernel.logs_dir');
  34.     }
  35.     if (!$strLogsDir)
  36.     {
  37.         $strLogsDir $container->getParameter('kernel.project_dir') . '/var/logs';
  38.     }
  39.     error_log(sprintf("[%s] %s\n"date('d-M-Y H:i:s'), $strMessage), 3$strLogsDir '/' $strLog);
  40. }
  41. /**
  42.  * Scan a directory and return its files and folders as array
  43.  *
  44.  * @param string  $strFolder
  45.  * @param boolean $blnUncached
  46.  *
  47.  * @return array
  48.  *
  49.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  50.  */
  51. function scan($strFolder$blnUncached=false)
  52. {
  53.     trigger_deprecation('contao/core-bundle''4.10''Using "scan()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\Folder::scan()" instead.');
  54.     return Folder::scan($strFolder$blnUncached);
  55. }
  56. /**
  57.  * Convert special characters to HTML entities and make sure that
  58.  * entities are never double converted.
  59.  *
  60.  * @param string  $strString
  61.  * @param boolean $blnStripInsertTags
  62.  *
  63.  * @return string
  64.  *
  65.  * @deprecated Using specialchars() has been deprecated and will no longer work in Contao 5.0.
  66.  *             Use StringUtil::specialchars() instead.
  67.  */
  68. function specialchars($strString$blnStripInsertTags=false)
  69. {
  70.     trigger_deprecation('contao/core-bundle''4.0''Using "specialchars()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::specialchars()" instead.');
  71.     if ($blnStripInsertTags)
  72.     {
  73.         $strString strip_insert_tags($strString);
  74.     }
  75.     return htmlspecialchars($strStringENT_QUOTESSystem::getContainer()->getParameter('kernel.charset'), false);
  76. }
  77. /**
  78.  * Standardize a parameter (strip special characters and convert spaces)
  79.  *
  80.  * @param string  $strString
  81.  * @param boolean $blnPreserveUppercase
  82.  *
  83.  * @return string
  84.  *
  85.  * @deprecated Using standardize() has been deprecated and will no longer work in Contao 5.0.
  86.  *             Use StringUtil::standardize() instead.
  87.  */
  88. function standardize($strString$blnPreserveUppercase=false)
  89. {
  90.     trigger_deprecation('contao/core-bundle''4.0''Using "standardize()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::standardize()" instead.');
  91.     $arrSearch = array('/[^\pN\pL \.\&\/_-]+/u''/[ \.\&\/-]+/');
  92.     $arrReplace = array('''-');
  93.     $strString html_entity_decode($strStringENT_QUOTESSystem::getContainer()->getParameter('kernel.charset'));
  94.     $strString strip_insert_tags($strString);
  95.     $strString preg_replace($arrSearch$arrReplace$strString);
  96.     if (is_numeric(substr($strString01)))
  97.     {
  98.         $strString 'id-' $strString;
  99.     }
  100.     if (!$blnPreserveUppercase)
  101.     {
  102.         $strString mb_strtolower($strString);
  103.     }
  104.     return trim($strString'-');
  105. }
  106. /**
  107.  * Remove Contao insert tags from a string
  108.  *
  109.  * @param string $strString
  110.  *
  111.  * @return string
  112.  *
  113.  * @deprecated Using strip_insert_tags() has been deprecated and will no longer work in Contao 5.0.
  114.  *             Use StringUtil::stripInsertTags() instead.
  115.  */
  116. function strip_insert_tags($strString)
  117. {
  118.     trigger_deprecation('contao/core-bundle''4.0''Using "strip_insert_tags()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::stripInsertTags()" instead.');
  119.     $count 0;
  120.     do
  121.     {
  122.         $strString preg_replace('/{{[^{}]*}}/'''$strString, -1$count);
  123.     }
  124.     while ($count 0);
  125.     return $strString;
  126. }
  127. /**
  128.  * Return an unserialized array or the argument
  129.  *
  130.  * @param mixed   $varValue
  131.  * @param boolean $blnForceArray
  132.  *
  133.  * @return mixed
  134.  *
  135.  * @deprecated Using deserialize() has been deprecated and will no longer work in Contao 5.0.
  136.  *             Use StringUtil::deserialize() instead.
  137.  */
  138. function deserialize($varValue$blnForceArray=false)
  139. {
  140.     trigger_deprecation('contao/core-bundle''4.0''Using "deserialize()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::deserialize()" instead.');
  141.     // Already an array
  142.     if (is_array($varValue))
  143.     {
  144.         return $varValue;
  145.     }
  146.     // Null
  147.     if ($varValue === null)
  148.     {
  149.         return $blnForceArray ? array() : null;
  150.     }
  151.     // Not a string
  152.     if (!is_string($varValue))
  153.     {
  154.         return $blnForceArray ? array($varValue) : $varValue;
  155.     }
  156.     // Empty string
  157.     if (trim($varValue) === '')
  158.     {
  159.         return $blnForceArray ? array() : '';
  160.     }
  161.     // Potentially including an object (see #6724)
  162.     if (preg_match('/[OoC]:\+?[0-9]+:"/'$varValue))
  163.     {
  164.         trigger_error('The deserialize() function does not allow serialized objects'E_USER_WARNING);
  165.         return $blnForceArray ? array($varValue) : $varValue;
  166.     }
  167.     $varUnserialized = @unserialize($varValue, array('allowed_classes' => false));
  168.     if (is_array($varUnserialized))
  169.     {
  170.         $varValue $varUnserialized;
  171.     }
  172.     elseif ($blnForceArray)
  173.     {
  174.         $varValue = array($varValue);
  175.     }
  176.     return $varValue;
  177. }
  178. /**
  179.  * Split a string into fragments, remove whitespace and return fragments as array
  180.  *
  181.  * @param string $strPattern
  182.  * @param string $strString
  183.  *
  184.  * @return array
  185.  *
  186.  * @deprecated Using trimsplit() has been deprecated and will no longer work in Contao 5.0.
  187.  *             Use StringUtil::trimsplit() instead.
  188.  */
  189. function trimsplit($strPattern$strString)
  190. {
  191.     trigger_deprecation('contao/core-bundle''4.0''Using "trimsplit()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::trimsplit()" instead.');
  192.     // Split
  193.     if (strlen($strPattern) == 1)
  194.     {
  195.         $arrFragments array_map('trim'explode($strPattern$strString));
  196.     }
  197.     else
  198.     {
  199.         $arrFragments array_map('trim'preg_split('/' $strPattern '/ui'$strString));
  200.     }
  201.     // Empty array
  202.     if (count($arrFragments) < && !strlen($arrFragments[0]))
  203.     {
  204.         $arrFragments = array();
  205.     }
  206.     return $arrFragments;
  207. }
  208. /**
  209.  * Convert all ampersands into their HTML entity (default) or unencoded value
  210.  *
  211.  * @param string  $strString
  212.  * @param boolean $blnEncode
  213.  *
  214.  * @return string
  215.  *
  216.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  217.  */
  218. function ampersand($strString$blnEncode=true)
  219. {
  220.     trigger_deprecation('contao/core-bundle''4.10''Using "ampersand()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::ampersand()" instead.');
  221.     return StringUtil::ampersand($strString$blnEncode);
  222. }
  223. /**
  224.  * Replace line breaks with HTML5-style <br> tags
  225.  *
  226.  * @param string  $str
  227.  * @param boolean $xhtml
  228.  *
  229.  * @return string
  230.  *
  231.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  232.  */
  233. function nl2br_html5($str$xhtml=false)
  234. {
  235.     trigger_deprecation('contao/core-bundle''4.0''Using "nl2br_html5()" has been deprecated and will no longer work in Contao 5.0.');
  236.     return nl2br($str$xhtml);
  237. }
  238. /**
  239.  * Replace line breaks with XHTML-style <br /> tags
  240.  *
  241.  * @param string $str
  242.  *
  243.  * @return string
  244.  *
  245.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  246.  */
  247. function nl2br_xhtml($str)
  248. {
  249.     trigger_deprecation('contao/core-bundle''4.0''Using "nl2br_xhtml()" has been deprecated and will no longer work in Contao 5.0.');
  250.     return nl2br($str);
  251. }
  252. /**
  253.  * Replace line breaks with <br> tags preserving preformatted text
  254.  *
  255.  * @param string  $str
  256.  * @param boolean $xhtml
  257.  *
  258.  * @return string
  259.  *
  260.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  261.  */
  262. function nl2br_pre($str$xhtml=false)
  263. {
  264.     trigger_deprecation('contao/core-bundle''4.0''Using "nl2br_pre()" has been deprecated and will no longer work in Contao 5.0.');
  265.     return preg_replace('/\r?\n/'$xhtml '<br />' '<br>'$str);
  266. }
  267. /**
  268.  * Compare two file names using a case-insensitive "natural order" algorithm
  269.  *
  270.  * @param string $a
  271.  * @param string $b
  272.  *
  273.  * @return integer
  274.  *
  275.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  276.  */
  277. function basename_natcasecmp($a$b)
  278. {
  279.     trigger_deprecation('contao/core-bundle''4.0''Using "basename_natcasecmp()" has been deprecated and will no longer work in Contao 5.0.');
  280.     return strnatcasecmp(basename($a), basename($b));
  281. }
  282. /**
  283.  * Compare two file names using a case-insensitive, reverse "natural order" algorithm
  284.  *
  285.  * @param string $a
  286.  * @param string $b
  287.  *
  288.  * @return integer
  289.  *
  290.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  291.  */
  292. function basename_natcasercmp($a$b)
  293. {
  294.     trigger_deprecation('contao/core-bundle''4.0''Using "basename_natcasercmp()" has been deprecated and will no longer work in Contao 5.0.');
  295.     return -strnatcasecmp(basename($a), basename($b));
  296. }
  297. /**
  298.  * Sort an array by keys using a case-insensitive "natural order" algorithm
  299.  *
  300.  * @param array $arrArray
  301.  *
  302.  * @return array
  303.  *
  304.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  305.  */
  306. function natcaseksort($arrArray)
  307. {
  308.     trigger_deprecation('contao/core-bundle''4.10''Using "natcaseksort()" has been deprecated and will no longer work in Contao 5.0. Use "uksort()" with "strnatcasecmp" instead.');
  309.     uksort($arrArray'strnatcasecmp');
  310.     return $arrArray;
  311. }
  312. /**
  313.  * Compare two values based on their length (ascending)
  314.  *
  315.  * @param integer $a
  316.  * @param integer $b
  317.  *
  318.  * @return integer
  319.  *
  320.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  321.  */
  322. function length_sort_asc($a$b)
  323. {
  324.     trigger_deprecation('contao/core-bundle''4.0''Using "length_sort_asc()" has been deprecated and will no longer work in Contao 5.0. Use a closure instead.');
  325.     return strlen($a) - strlen($b);
  326. }
  327. /**
  328.  * Compare two values based on their length (descending)
  329.  *
  330.  * @param integer $a
  331.  * @param integer $b
  332.  *
  333.  * @return integer
  334.  *
  335.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  336.  */
  337. function length_sort_desc($a$b)
  338. {
  339.     trigger_deprecation('contao/core-bundle''4.0''Using "length_sort_desc()" has been deprecated and will no longer work in Contao 5.0. Use a closure instead.');
  340.     return strlen($b) - strlen($a);
  341. }
  342. /**
  343.  * Insert a parameter or array into an existing array at a particular index
  344.  *
  345.  * @param array   $arrCurrent
  346.  * @param integer $intIndex
  347.  * @param mixed   $arrNew
  348.  *
  349.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  350.  */
  351. function array_insert(&$arrCurrent$intIndex$arrNew)
  352. {
  353.     trigger_deprecation('contao/core-bundle''4.0''Using "array_insert()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\ArrayUtil::arrayInsert()" instead.');
  354.     ArrayUtil::arrayInsert($arrCurrent$intIndex$arrNew);
  355. }
  356. /**
  357.  * Duplicate a particular element of an array
  358.  *
  359.  * @param array   $arrStack
  360.  * @param integer $intIndex
  361.  *
  362.  * @return array
  363.  *
  364.  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  365.  */
  366. function array_duplicate($arrStack$intIndex)
  367. {
  368.     trigger_deprecation('contao/core-bundle''4.0''Using "array_duplicate()" has been deprecated and will no longer work in Contao 5.0.');
  369.     $arrBuffer $arrStack;
  370.     $arrStack = array();
  371.     for ($i=0$i<=$intIndex$i++)
  372.     {
  373.         $arrStack[] = $arrBuffer[$i];
  374.     }
  375.     for ($i=$intIndex$c=count($arrBuffer); $i<$c$i++)
  376.     {
  377.         $arrStack[] = $arrBuffer[$i];
  378.     }
  379.     return $arrStack;
  380. }
  381. /**
  382.  * Move an array element one position up
  383.  *
  384.  * @param array   $arrStack
  385.  * @param integer $intIndex
  386.  *
  387.  * @return array
  388.  *
  389.  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  390.  */
  391. function array_move_up($arrStack$intIndex)
  392. {
  393.     trigger_deprecation('contao/core-bundle''4.0''Using "array_move_up()" has been deprecated and will no longer work in Contao 5.0.');
  394.     if ($intIndex 0)
  395.     {
  396.         $arrBuffer $arrStack[$intIndex];
  397.         $arrStack[$intIndex] = $arrStack[($intIndex-1)];
  398.         $arrStack[($intIndex-1)] = $arrBuffer;
  399.     }
  400.     else
  401.     {
  402.         $arrStack[] = $arrStack[$intIndex];
  403.         array_shift($arrStack);
  404.     }
  405.     return $arrStack;
  406. }
  407. /**
  408.  * Move an array element one position down
  409.  *
  410.  * @param array   $arrStack
  411.  * @param integer $intIndex
  412.  *
  413.  * @return array
  414.  *
  415.  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  416.  */
  417. function array_move_down($arrStack$intIndex)
  418. {
  419.     trigger_deprecation('contao/core-bundle''4.0''Using "array_move_down()" has been deprecated and will no longer work in Contao 5.0.');
  420.     if (($intIndex+1) < count($arrStack))
  421.     {
  422.         $arrBuffer $arrStack[$intIndex];
  423.         $arrStack[$intIndex] = $arrStack[($intIndex+1)];
  424.         $arrStack[($intIndex+1)] = $arrBuffer;
  425.     }
  426.     else
  427.     {
  428.         array_unshift($arrStack$arrStack[$intIndex]);
  429.         array_pop($arrStack);
  430.     }
  431.     return $arrStack;
  432. }
  433. /**
  434.  * Delete a particular element of an array
  435.  *
  436.  * @param array   $arrStack
  437.  * @param integer $intIndex
  438.  *
  439.  * @return array
  440.  *
  441.  * @deprecated Deprecated since Contao 4.3, to be removed in Contao 5.0.
  442.  */
  443. function array_delete($arrStack$intIndex)
  444. {
  445.     trigger_deprecation('contao/core-bundle''4.0''Using "array_delete()" has been deprecated and will no longer work in Contao 5.0.');
  446.     unset($arrStack[$intIndex]);
  447.     return array_values($arrStack);
  448. }
  449. /**
  450.  * Return true if an array is associative
  451.  *
  452.  * @param array $arrArray
  453.  *
  454.  * @return boolean
  455.  *
  456.  * @deprecated Deprecated since Contao 4.10, to be removed in Contao 5.0.
  457.  */
  458. function array_is_assoc($arrArray)
  459. {
  460.     trigger_deprecation('contao/core-bundle''4.0''Using "array_is_assoc()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\ArrayUtil::isAssoc()" instead.');
  461.     return ArrayUtil::isAssoc($arrArray);
  462. }
  463. /**
  464.  * Return a specific character
  465.  *
  466.  * Unicode version of chr() that handles UTF-8 characters.
  467.  *
  468.  * @param integer $dec
  469.  *
  470.  * @return string
  471.  *
  472.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  473.  *             Use mb_chr() instead.
  474.  */
  475. function utf8_chr($dec)
  476. {
  477.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_chr()" has been deprecated and will no longer work in Contao 5.0. Use "mb_chr()" instead.');
  478.     return mb_chr($dec);
  479. }
  480. /**
  481.  * Return the ASCII value of a character
  482.  *
  483.  * Unicode version of ord() that handles UTF-8 characters.
  484.  *
  485.  * @param string $str
  486.  *
  487.  * @return integer
  488.  *
  489.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  490.  *             Use mb_ord() instead.
  491.  */
  492. function utf8_ord($str)
  493. {
  494.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_ord()" has been deprecated and will no longer work in Contao 5.0. Use "mb_ord()" instead.');
  495.     return mb_ord($str);
  496. }
  497. /**
  498.  * Convert character encoding
  499.  *
  500.  * @param string $str
  501.  * @param string $to
  502.  * @param string $from
  503.  *
  504.  * @return string
  505.  *
  506.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  507.  *             Use StringUtil::convertEncoding() instead.
  508.  */
  509. function utf8_convert_encoding($str$to$from=null)
  510. {
  511.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_convert_encoding()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\StringUtil::convertEncoding()" instead.');
  512.     if (!$str)
  513.     {
  514.         return '';
  515.     }
  516.     if (!$from)
  517.     {
  518.         $from mb_detect_encoding($str);
  519.     }
  520.     if ($from == $to)
  521.     {
  522.         return $str;
  523.     }
  524.     if ($from == 'UTF-8' && $to == 'ISO-8859-1')
  525.     {
  526.         return utf8_decode($str);
  527.     }
  528.     if ($from == 'ISO-8859-1' && $to == 'UTF-8')
  529.     {
  530.         return utf8_encode($str);
  531.     }
  532.     return mb_convert_encoding($str$to$from);
  533. }
  534. /**
  535.  * Convert all unicode entities to their applicable characters
  536.  *
  537.  * Calls mb_chr() to convert unicode entities. HTML entities like '&nbsp;'
  538.  * or '&quot;' will not be decoded.
  539.  *
  540.  * @param string $str
  541.  *
  542.  * @return string
  543.  *
  544.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  545.  *             Use html_entity_decode() instead.
  546.  */
  547. function utf8_decode_entities($str)
  548. {
  549.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_decode_entities()" has been deprecated and will no longer work in Contao 5.0. Use "html_entity_decode()" instead.');
  550.     $str preg_replace_callback('~&#x([0-9a-f]+);~i', static function ($matches) { return mb_chr(hexdec($matches[1])); }, $str);
  551.     $str preg_replace_callback('~&#([0-9]+);~', static function ($matches) { return mb_chr($matches[1]); }, $str);
  552.     return $str;
  553. }
  554. /**
  555.  * Callback function for utf8_decode_entities
  556.  *
  557.  * @param array $matches
  558.  *
  559.  * @return string
  560.  *
  561.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  562.  */
  563. function utf8_chr_callback($matches)
  564. {
  565.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_chr_callback()" has been deprecated and will no longer work in Contao 5.0.');
  566.     return mb_chr($matches[1]);
  567. }
  568. /**
  569.  * Callback function for utf8_decode_entities
  570.  *
  571.  * @param array $matches
  572.  *
  573.  * @return string
  574.  *
  575.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  576.  */
  577. function utf8_hexchr_callback($matches)
  578. {
  579.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_hexchr_callback()" has been deprecated and will no longer work in Contao 5.0.');
  580.     return mb_chr(hexdec($matches[1]));
  581. }
  582. /**
  583.  * Detect the encoding of a string
  584.  *
  585.  * @param string $str
  586.  *
  587.  * @return string
  588.  *
  589.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  590.  *             Use mb_detect_encoding() instead.
  591.  */
  592. function utf8_detect_encoding($str)
  593. {
  594.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_detect_encoding()" has been deprecated and will no longer work in Contao 5.0. Use "mb_detect_encoding()" instead.');
  595.     return mb_detect_encoding($str, array('ASCII''ISO-2022-JP''UTF-8''EUC-JP''ISO-8859-1'));
  596. }
  597. /**
  598.  * Romanize a string
  599.  *
  600.  * @param string $str
  601.  *
  602.  * @return string
  603.  *
  604.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  605.  *             Use the symfony/string component instead.
  606.  */
  607. function utf8_romanize($str)
  608. {
  609.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_romanize()" has been deprecated and will no longer work in Contao 5.0. Use the "symfony/string" component instead.');
  610.     return (new UnicodeString($str))->ascii()->toString();
  611. }
  612. /**
  613.  * Determine the number of characters of a string
  614.  *
  615.  * @param string $str
  616.  *
  617.  * @return integer
  618.  *
  619.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  620.  *             Use mb_strlen() instead.
  621.  */
  622. function utf8_strlen($str)
  623. {
  624.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strlen()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strlen()" instead.');
  625.     return mb_strlen($str);
  626. }
  627. /**
  628.  * Find the position of the first occurrence of a string in another string
  629.  *
  630.  * @param string  $haystack
  631.  * @param string  $needle
  632.  * @param integer $offset
  633.  *
  634.  * @return integer
  635.  *
  636.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  637.  *             Use mb_strpos instead.
  638.  */
  639. function utf8_strpos($haystack$needle$offset=0)
  640. {
  641.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strpos()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strpos()" instead.');
  642.     return mb_strpos($haystack$needle$offset);
  643. }
  644. /**
  645.  * Find the last occurrence of a character in a string
  646.  *
  647.  * @param string $haystack
  648.  * @param string $needle
  649.  *
  650.  * @return string
  651.  *
  652.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  653.  *             Use mb_strrchr() instead.
  654.  */
  655. function utf8_strrchr($haystack$needle)
  656. {
  657.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strrchr()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strrchr()" instead.');
  658.     return mb_strrchr($haystack$needle);
  659. }
  660. /**
  661.  * Find the position of the last occurrence of a string in another string
  662.  *
  663.  * @param string $haystack
  664.  * @param string $needle
  665.  *
  666.  * @return mixed
  667.  *
  668.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  669.  *             Use mb_strrpos() instead.
  670.  */
  671. function utf8_strrpos($haystack$needle)
  672. {
  673.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strrpos()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strrpos()" instead.');
  674.     return mb_strrpos($haystack$needle);
  675. }
  676. /**
  677.  * Find the first occurrence of a string in another string
  678.  *
  679.  * @param string $haystack
  680.  * @param string $needle
  681.  *
  682.  * @return string
  683.  *
  684.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  685.  *             Use mb_strstr() instead.
  686.  */
  687. function utf8_strstr($haystack$needle)
  688. {
  689.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strstr()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strstr()" instead.');
  690.     return mb_strstr($haystack$needle);
  691. }
  692. /**
  693.  * Make a string lowercase
  694.  *
  695.  * @param string $str
  696.  *
  697.  * @return string
  698.  *
  699.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  700.  *             Use mb_strtolower() instead.
  701.  */
  702. function utf8_strtolower($str)
  703. {
  704.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strtolower()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strtolower()" instead.');
  705.     return mb_strtolower($str);
  706. }
  707. /**
  708.  * Make a string uppercase
  709.  *
  710.  * @param string $str
  711.  *
  712.  * @return string
  713.  *
  714.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  715.  *             Use mb_strtoupper() instead.
  716.  */
  717. function utf8_strtoupper($str)
  718. {
  719.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_strtoupper()" has been deprecated and will no longer work in Contao 5.0. Use "mb_strtoupper()" instead.');
  720.     return mb_strtoupper($str);
  721. }
  722. /**
  723.  * Return substring of a string
  724.  *
  725.  * @param string  $str
  726.  * @param integer $start
  727.  * @param integer $length
  728.  *
  729.  * @return string
  730.  *
  731.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  732.  *             Use mb_substr() instead.
  733.  */
  734. function utf8_substr($str$start$length=null)
  735. {
  736.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_substr()" has been deprecated and will no longer work in Contao 5.0. Use "mb_substr()" instead.');
  737.     return mb_substr($str$start$length);
  738. }
  739. /**
  740.  * Make sure the first letter is uppercase
  741.  *
  742.  * @param string $str
  743.  *
  744.  * @return string
  745.  *
  746.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  747.  *             Use the symfony/string component instead.
  748.  */
  749. function utf8_ucfirst($str)
  750. {
  751.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_ucfirst()" has been deprecated and will no longer work in Contao 5.0. Use the "symfony/string" component instead.');
  752.     return (new UnicodeString($str))->title()->toString();
  753. }
  754. /**
  755.  * Convert a string to an array
  756.  *
  757.  * @param string $str
  758.  *
  759.  * @return array
  760.  *
  761.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  762.  *             Use mb_str_split() instead.
  763.  */
  764. function utf8_str_split($str)
  765. {
  766.     trigger_deprecation('contao/core-bundle''4.0''Using "utf8_str_split()" has been deprecated and will no longer work in Contao 5.0. Use "mb_str_split()" instead.');
  767.     return mb_str_split($str);
  768. }
  769. /**
  770.  * Replace line breaks with <br> tags (to be used with preg_replace_callback)
  771.  *
  772.  * @param array $matches
  773.  *
  774.  * @return string
  775.  *
  776.  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  777.  */
  778. function nl2br_callback($matches)
  779. {
  780.     trigger_deprecation('contao/core-bundle''4.0''Using "nl2br_callback()" has been deprecated and will no longer work in Contao 5.0.');
  781.     return str_replace("\n"'<br>'$matches[0]);
  782. }