public function index15Action() { echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>"; $filter = new \Zend\Filter\Word\CamelCaseToSeparator("-"); $input = "TrongleHandsomeTalent"; $output = $filter->filter($input); echo "<h2>Input: {$input}</h2><br>"; echo "<h2>Output : {$output}</h2>"; return false; }
/** * Process raw EXIF data by converting binary or hex information, replacing legend codes with their meanings, * fixing labels, etc. * * @param array $exifraw Array of raw EXIF data * * @return array $exif Array of processed EXIF data, including label, newval and suffix values * for each field */ function processRawData($exifraw) { $filter = new Zend\Filter\Word\CamelCaseToSeparator(); //array of tags to match exif array from file foreach ($exifraw as $group => $fields) { foreach ($fields as $name => $field) { if (isset($field)) { //store raw value $exif[$group][$name]['rawval'] = $field; //thumbnail and ifd0 groups share the same specifications $groupmask = $group == 'THUMBNAIL' ? 'IFD0' : $group; //get tag data from $specs array if (isset($this->specs[$groupmask][$name])) { //shorten the variable $specname = $this->specs[$groupmask][$name]; //convert binary values if (isset($specname['binary']) && $specname['binary']) { $exif[$group][$name]['rawval'] = bin2hex($exif[$group][$name]['rawval']); } //start processing rawval into newval if (is_array($exif[$group][$name]['rawval'])) { $exif[$group][$name]['newval'] = $this->processArray($exif[$group][$name]['rawval'], $name); //perform division for rational fields, but only if not an array } elseif (isset($specname['format']) && $specname['format'] == 'rational') { $exif[$group][$name]['newval'] = $this->divide($field); //move rest of rawvals into newvals } else { $exif[$group][$name]['newval'] = $exif[$group][$name]['rawval']; } //now determine display values using option values where they exist if (isset($specname['options'])) { //first handle special cases if ($name == 'ComponentsConfiguration') { $str = $exif[$group][$name]['newval']; $opt = $specname['options']; $disp = $opt[substr($str, 0, 2)] . ' ' . $opt[substr($str, 2, 2)] . ' ' . $opt[substr($str, 4, 2)] . ' ' . $opt[substr($str, 6, 2)]; $exif[$group][$name]['newval'] = $disp; } elseif ($name == 'CFAPattern') { $str = $exif[$group][$name]['newval']; $opt = $specname['options']; $disp = '[' . $opt[substr($str, 8, 2)] . ', ' . $opt[substr($str, 10, 2)] . '] [' . $opt[substr($str, 12, 2)] . ', ' . $opt[substr($str, 14, 2)] . ']'; $exif[$group][$name]['newval'] = $disp; } else { $exif[$group][$name]['newval'] = $specname['options'][$exif[$group][$name]['newval']]; } } //fix labels if (isset($specname['label'])) { $exif[$group][$name]['label'] = $specname['label']; } else { //create reading-friendly labels from camel case tags $exif[$group][$name]['label'] = $filter->filter($name); } if (isset($specname['suffix']) && !is_array($exif[$group][$name]['newval'])) { $exif[$group][$name]['suffix'] = $specname['suffix']; } } else { //those not covered in $specs $exif[$group][$name]['newval'] = $exif[$group][$name]['rawval']; //create reading-friendly labels from camel case tags $exif[$group][$name]['label'] = $filter->filter($name); } } } } //*******Special Handling*********// //file name is computed by PHP and is meaningless when file is stored in tiki, //and dialog box has real name in title so not needed unset($exif['FILE']['FileName']); //file date is also computed by PHP and represents the time the metadata was extracted. This data is included //elsewhere and is not needed here unset($exif['FILE']['FileDateTime']); //No processing of maker notes yet as specific code is needed for each manufacturer //Blank out field since it is very long and will distort the dialog box if (!empty($exif['EXIF']['MakerNote']['newval'])) { $exif['EXIF']['MakerNote']['newval'] = '(Not processed)'; unset($exif['EXIF']['MakerNote']['rawval']); } if (isset($exif['MAKERNOTE'])) { $exif['MAKERNOTE'] = ""; $exif['MAKERNOTE']['Note']['label'] = ""; $exif['MAKERNOTE']['Note']['newval'] = "(Not processed)"; } //Interpret GPSVersion field if (isset($exif['GPS']['GPSVersion'])) { $exif['GPS']['GPSVersion']['newval'] = ''; $len = strlen($exif['GPS']['GPSVersion']['rawval']); for ($i = 0; $i < $len; $i = $i + 2) { if ($i > 0) { $exif['GPS']['GPSVersion']['newval'] .= '.'; } $exif['GPS']['GPSVersion']['newval'] .= (int) substr($exif['GPS']['GPSVersion']['rawval'], $i, 2); } } //PHP already converts UserComment in the Computed group so use that value if (isset($exif['EXIF']['UserComment']) && isset($exif['COMPUTED']['UserComment'])) { $exif['EXIF']['UserComment']['newval'] = $exif['COMPUTED']['UserComment']['rawval']; unset($exif['COMPUTED']['UserComment']); } //PHP already converts the FNumber in the Computed group so use that value if (isset($exif['EXIF']['FNumber']) && isset($exif['COMPUTED']['ApertureFNumber'])) { $exif['EXIF']['FNumber']['newval'] = $exif['COMPUTED']['ApertureFNumber']['rawval']; unset($exif['COMPUTED']['ApertureFNumber']); } return $exif; }
/** \Zend\Filter\CamelCaseToSepareator() => Thêm dấu gạch dưới trước chữ in hoa*/ public function index17Action() { $filter = new \Zend\Filter\Word\CamelCaseToSeparator('++'); $input = 'ZendFrameworkIsEasy'; $output = $filter->filter($input); echo "<h3>" . $input . "</h3>"; echo "<h3>" . $output . "</h3>"; return false; }