OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
oxutilsstring.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
12  public function __construct()
13  {
14  }
15 
23  public function prepareCSVField($sInField)
24  {
25  $oStr = getStr();
26  if ($oStr->strstr($sInField, '"')) {
27  return '"' . str_replace('"', '""', $sInField) . '"';
28  } elseif ($oStr->strstr($sInField, ';')) {
29  return '"' . $sInField . '"';
30  }
31 
32  return $sInField;
33  }
34 
45  public function minimizeTruncateString($sString, $iLength)
46  {
47  //leading and ending whitespaces
48  $sString = trim($sString);
49  $oStr = getStr();
50 
51  //multiple whitespaces
52  $sString = $oStr->preg_replace("/[ \t\n\r]+/", " ", $sString);
53  if ($oStr->strlen($sString) > $iLength && $iLength != -1) {
54  $sString = $oStr->substr($sString, 0, $iLength);
55  }
56 
57  $sString = $oStr->preg_replace("/,+$/", "", $sString);
58 
59  return $sString;
60  }
61 
69  public function prepareStrForSearch($sSearchStr)
70  {
71  $oStr = getStr();
72  if ($oStr->hasSpecialChars($sSearchStr)) {
73  return $oStr->recodeEntities($sSearchStr, true, array('&amp;'), array('&'));
74  }
75 
76  return '';
77  }
78 }