Source for file viewExif.act.php

Documentation is available at viewExif.act.php

  1. <?php
  2. /**
  3. * @since 11/27/06
  4. * @package polyphony.images
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: viewExif.act.php,v 1.4 2007/09/19 14:04:55 adamfranco Exp $
  10. */
  11. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  12. require_once(POLYPHONY."/main/library/RepositoryImporter/ExifRepositoryImporter.class.php");
  13. require_once(EXIF);
  14.  
  15. /**
  16. * This Action allows the user to upload a file and view the exif/iptc fields and
  17. * data that it contains
  18. *
  19. * @since 11/27/06
  20. * @package polyphony.images
  21. *
  22. * @copyright Copyright &copy; 2005, Middlebury College
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  24. *
  25. * @version $Id: viewExif.act.php,v 1.4 2007/09/19 14:04:55 adamfranco Exp $
  26. */
  27. class viewExifAction
  28. extends MainWindowAction
  29. {
  30. /**
  31. * Check Authorizations
  32. *
  33. * @return boolean
  34. * @access public
  35. * @since 6/08/05
  36. */
  37. function isAuthorizedToExecute () {
  38. return true;
  39. }
  40. function buildContent () {
  41. $harmoni = Harmoni::instance();
  42. $centerPane =$this->getActionRows();
  43. $centerPane->add(new Heading(_("Upload a file to view its EXIF/IPTC data"), 2), null, null, LEFT, TOP);
  44. ob_start();
  45. print "\n<form action='".$harmoni->request->quickURL()."' method='post' enctype='multipart/form-data'>";
  46. print "\n\t<input type='file' name='".RequestContext::name('image_file')."'/>";
  47. print "\n\t<input type='submit'/>";
  48. print "\n</form>";
  49. $centerPane->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, LEFT, TOP);
  50. if (isset($_FILES[RequestContext::name('image_file')])
  51. && !$_FILES[RequestContext::name('image_file')]['error'])
  52. {
  53. $fileArray = $_FILES[RequestContext::name('image_file')];
  54. ob_start();
  55. print "<h2>".$fileArray['name']."</h2>";
  56. $exifImporter = new ExifRepositoryImporter($fileArray['tmp_name'], null, false);
  57. $exifImporter->getSingleAssetInfo($fileArray['tmp_name']);
  58. // printpre($exifImporter->_photoshopIPTC);
  59. print "\n<h3>"._("IPTC Fields")."</h3>";
  60. $this->printFields($exifImporter->extractPhotoshopMetaData());
  61. print "\n<h3>"._("EXIF Fields")."</h3>";
  62. $this->printFields($exifImporter->extractExifMetadata($fileArray['tmp_name']));
  63. $centerPane->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, LEFT, TOP);
  64. }
  65. }
  66. /**
  67. * Print out a field list
  68. *
  69. * @param array $fields
  70. * @return void
  71. * @access public
  72. * @since 11/27/06
  73. */
  74. function printFields ($fields) {
  75. print "\n<table border='1'>";
  76. print "\n\t<tr>";
  77. print "\n\t\t<th>"._("Field Name")."</th>";
  78. print "\n\t\t<th>"._("Value")."</th>";
  79. print "\n\t</tr>";
  80. foreach ($fields as $name => $value) {
  81. print "\n\t<tr>";
  82. print "\n\t<td>".$name."</td>";
  83. print "\n\t<td>".$value."</td>";
  84. print "\n\t</tr>";
  85. }
  86. print "\n</table>";
  87. }
  88. }
  89.  
  90. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:45 -0400 by phpDocumentor 1.3.0RC3