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

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