Beispiel #1
0
function display_str($Str)
{
    if ($Str != '') {
        $Str = make_utf8($Str);
        $Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8');
        $Str = preg_replace("/&(?![A-Za-z]{0,4}\\w{2,3};|#[0-9]{2,5};)/m", '&', $Str);
        $Replace = array("'", '"', "<", ">", '&#128;', '&#130;', '&#131;', '&#132;', '&#133;', '&#134;', '&#135;', '&#136;', '&#137;', '&#138;', '&#139;', '&#140;', '&#142;', '&#145;', '&#146;', '&#147;', '&#148;', '&#149;', '&#150;', '&#151;', '&#152;', '&#153;', '&#154;', '&#155;', '&#156;', '&#158;', '&#159;');
        $With = array('&#39;', '&quot;', '&lt;', '&gt;', '&#8364;', '&#8218;', '&#402;', '&#8222;', '&#8230;', '&#8224;', '&#8225;', '&#710;', '&#8240;', '&#352;', '&#8249;', '&#338;', '&#381;', '&#8216;', '&#8217;', '&#8220;', '&#8221;', '&#8226;', '&#8211;', '&#8212;', '&#732;', '&#8482;', '&#353;', '&#8250;', '&#339;', '&#382;', '&#376;');
        $Str = str_replace($Replace, $With, $Str);
    }
    return $Str;
}
 /**
  * Given an array where the order matches the fieldNames,
  * create an object with propertie and values.
  *
  * @param <array> $fieldNames
  * @param <array> $record
  * @return stdClass
  */
 public function objectify($fieldNames, $record)
 {
     $obj = new stdClass();
     foreach ($fieldNames as $field => $title) {
         if (isset($record[$title])) {
             $value = trim($record[$title]);
             $value = make_utf8($value);
             $value = !is_bool($value) && empty($value) ? null : $value;
             $obj->{$field} = $value;
         }
     }
     return $obj;
 }
 public function schema_map_filter($field, $value, $schema = null)
 {
     if (is_json($value)) {
         $value = json_decode($value);
     } else {
         if ($field == 'keyword' | $field == 'language' | $field == 'references' | $field == 'theme' | $field == 'programCode' | $field == 'bureauCode') {
             $value = str_getcsv($value);
         } else {
             if ($field == 'dataQuality' && !empty($value)) {
                 $value = (bool) $value;
             }
         }
     }
     if (is_array($value)) {
         $value = array_map("make_utf8", $value);
         $value = array_map("trim", $value);
         $value = array_filter($value);
         // removes any empty elements in an array
         $value = array_values($value);
         // ensures array_filter doesn't create an associative array
     } else {
         if (is_string($value)) {
             $value = trim($value);
             $value = make_utf8($value);
         }
     }
     $value = !is_bool($value) && empty($value) ? null : $value;
     return $value;
 }