18 require_once SQ_CORE_PACKAGE_PATH.
'/files/file/file_edit_fns.inc';
50 parent::paintFileUpload($asset, $o, $prefix);
52 if ((!$asset->id) && file_exists(SQ_FUDGE_PATH.
'/image_editor/imagej.jar')) {
55 normal_button($prefix.
'_use_editor_button', translate(
'core_use_image_editor_button'),
'this.parentNode.parentNode.parentNode.style.display=\'none\'; document.getElementById(\''.$prefix.
'_hide_editor_button\').parentNode.parentNode.style.display=\'\';',
'style=display:none;');
57 <script type=
"text/javascript">
58 if (!(navigator.userAgent.match(/Windows/i) && navigator.userAgent.match(/Safari/i))) {
59 document.getElementById(
'<?php echo $prefix; ?>_use_editor_button').style.display =
'inline';
83 $embedded_data = $asset->attr(
'embedded_data');
85 if (empty($embedded_data)) {
86 $o->note(
'Not found');
90 echo
'<table class="sq-backend-table">';
91 echo
'<tr><th>'.translate(
'name').
'</th>';
92 echo
'<th>'.translate(
'keyword').
'</th>';
93 echo
'<th>'.translate(
'value').
'</th></tr>';
94 foreach ($embedded_data as $keyword => $value_set) {
95 $code = array_get_index($value_set,
'name');
101 echo
'%image_embedded_'.$keyword.
'%';
104 foreach (array_get_index($value_set,
'value', Array()) as $data_item) {
136 function processFileUpload(&$asset, &$o, $prefix, $info=Array(),$redirect_in_limbo=TRUE, $asset_cloned=FALSE)
138 if (!parent::processFileUpload($asset, $o, $prefix, $info,$redirect_in_limbo, $asset_cloned)) {
143 if (!$asset->id)
return TRUE;
145 $info = $asset->getExistingFile();
147 if (!$asset->setAttrValue(
'width', $info[
'width'])) {
150 if (!$asset->setAttrValue(
'height', $info[
'height'])) {
153 if (!$asset->setAttrValue(
'size', $info[
'size'])) {
163 if (!$asset->setAttrValue(
'embedded_data', $meta)) {
167 if (!$asset->saveAttributes()) {
168 trigger_localised_error(
'CORE0052', E_USER_WARNING);
191 normal_button($prefix.
'_hide_editor_button', translate(
'core_use_simple_upload_button'),
'this.parentNode.parentNode.style.display=\'none\'; document.getElementById(\''.$prefix.
'_use_editor_button\').parentNode.parentNode.parentNode.style.display=\'\';',
'style="margin-bottom: 5px"');
212 if (isset($_POST[$prefix.
'_applet_temp_filename']) && !empty($_POST[$prefix.
'_applet_temp_filename'])) {
213 $_POST[$prefix.
'_server_file'] = $_POST[$prefix.
'_applet_temp_filename'];
234 if ($asset->writeAccess(
'attributes')) {
238 $asset_url = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL($asset->id);
239 $root_url = $GLOBALS[
'SQ_SYSTEM']->am->getRootURL(strip_url($asset_url, TRUE));
241 <img src=
"<?php echo current_protocol().'://'.$root_url['url'].'?a='.$asset->id; ?>&t=<?php echo time(); ?>" />
262 if (isset($_POST[$prefix.
'_applet_temp_filename'])) {
263 $_POST[$prefix.
'_server_file'] = $_POST[$prefix.
'_applet_temp_filename'];
284 $varieties = $asset->attr(
'varieties');
285 return (!empty($varieties[
'data']));
303 $wa = $asset->writeAccess(
'attributes');
305 $varieties = $asset->attr(
'varieties');
306 if (!empty($varieties)) {
307 foreach ($varieties[
'data'] as $varid => $data) {
308 $variety = $asset->getAsset($asset->id.
':'.$varid);
309 if (is_null($variety))
continue;
310 $edit_fns = $variety->getEditFns();
312 $o->openSection($variety->name);
313 $edit_fns->paintInlineInterface($variety, $o, $prefix.
'_'.$variety->id);
315 $o->openField(translate(
'delete_question'));
316 check_box($prefix.
'_delete[]', $variety->id);
342 if (!$asset->writeAccess(
'attributes'))
return FALSE;
344 $changes_made = FALSE;
346 if (!empty($_POST[$prefix.
'_delete']) && is_array($_POST[$prefix.
'_delete'])) {
347 foreach ($_POST[$prefix.
'_delete'] as $assetid) {
348 list(, $varid) = explode(
':', $assetid, 2);
349 if ($asset->deleteVariety($assetid)) {
350 $changes_made = TRUE;
355 $varieties = $asset->attr(
'varieties');
356 if (!empty($varieties)) {
357 foreach ($varieties[
'data'] as $varid => $data) {
358 $variety = $asset->getAsset($asset->id.
':'.$varid);
359 if (is_null($variety))
continue;
360 $edit_fns = $variety->getEditFns();
363 if (!isset($_FILES[$prefix.
'_'.$variety->id]) && !isset($_POST[$prefix.
'_'.$variety->id.
'_variety_type_posted']))
continue;
364 if ($edit_fns->processInlineInterface($variety, $o, $prefix.
'_'.$variety->id) && !($asset->status & SQ_SC_STATUS_SAFE_EDITING)) {
366 if ($variety->checkFileState($asset->effectiveUnrestricted() && $asset->attr(
'allow_unrestricted'))) {
367 $changes_made = TRUE;
373 return $changes_made;
391 $wa = $asset->writeAccess(
'attributes');
393 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'image_variety');
396 $edit_fns = $variety->getEditFns();
398 $o->openSection(translate(
'new_variety'));
399 $edit_fns->paintInlineInterface($variety, $o, $prefix.
'_new');
420 if (!$asset->writeAccess(
'attributes'))
return FALSE;
421 if (!isset($_POST[$prefix.
'_new_name']) || trim($_POST[$prefix.
'_new_name']) ==
'') {
424 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'image_variety');
427 $edit_fns = $variety->getEditFns();
428 if (!$edit_fns->processInlineInterface($variety, $o, $prefix.
'_new')) {
432 return (
bool) $asset->saveVariety($variety);
450 parent::printExistingFileInfo($asset);
451 $existing = $asset->getExistingFile();
452 if (!empty($existing)) {
453 echo translate(
'core_dimensions', $existing[
'width'], $existing[
'height'])?><br/><?php
472 $info = parent::getChosenFileInfo($prefix);
473 if (isset($_POST[$prefix.
'_applet_filename']) && !empty($_POST[$prefix.
'_applet_filename'])) {
474 $info[
'name'] = $_POST[$prefix.
'_applet_filename'];
475 $info[
'tmp_name'] = SQ_TEMP_PATH.
'/'.$_POST[$prefix.
'_applet_temp_filename'];
495 require_once(SQ_FUDGE_PATH.
'/general/file_system.inc');
497 foreach (list_files(SQ_TEMP_PATH) as $filename) {
498 if (in_array(get_file_type($filename), $asset->allowed_extensions)) {
499 $options[$filename] = $filename;
523 if (!file_exists(SQ_FUDGE_PATH.
'/image_editor/imagej.jar')) {
527 $open_url = $asset->getURL();
528 if (empty($open_url)) {
529 $open_url = current_url(TRUE, TRUE).
'?a='.$asset->id;
531 $open_url .= ((strpos($open_url,
'?') === FALSE) ?
'?' :
'&').
'SESSION_ID='.session_id().
'&SESSION_KEY='.$GLOBALS[
'SQ_SYSTEM']->getUniqueSessionKey().
'&t='.$time;
534 <script type=
"text/javascript"><!--
536 function getAppletName()
538 var applet = document.getElementById(
'<?php echo $prefix; ?>_image_editor');
539 if (applet.parentNode.parentNode.style.display !=
'none') {
540 var tempNameFile = applet.getFilename();
541 if (tempNameFile.length < 5 ){
550 function getAppletResult()
552 var applet = document.getElementById(
'<?php echo $prefix; ?>_image_editor');
553 if (applet.parentNode.parentNode.style.display !=
'none') {
554 var tempFilename = applet.doUpload();
555 if ((tempFilename !== null) && (tempFilename !=
'')) {
556 document.getElementById(
'<?php echo $prefix; ?>_applet_temp_filename').value = tempFilename;
557 document.getElementById(
'<?php echo $prefix; ?>_applet_filename').value = applet.getFilename();
566 forms = document.getElementsByTagName(
'FORM');
567 if (forms[0].onsubmit) {
568 var otherOnSubmit = forms[0].onsubmit;
572 if (getAppletName()) {
574 return getAppletResult();
576 window.alert(
"You must give a filename before committing");
580 forms[0].onsubmit =
function() {
return getAppletResult(); }
586 <input type=
"hidden" name=
"<?php echo $prefix; ?>_applet_temp_filename" id=
"<?php echo $prefix; ?>_applet_temp_filename" value=
"" />
587 <input type=
"hidden" name=
"<?php echo $prefix; ?>_applet_filename" id=
"<?php echo $prefix; ?>_applet_filename" value=
"" />
589 <applet
id=
"<?php echo $prefix; ?>_image_editor" name=
"<?php echo $prefix; ?>_image_editor" archive=
"<?php echo sq_web_path('fudge'); ?>/image_editor/imagej.jar?t=<?php echo $time; ?>" code=
"ij.ImageJ.class" width=
"90%" height=
"350">
590 <param name=
"SUBMIT_URL"
591 value=
"<?php echo sq_web_path('lib'); ?>/web/accept_file_upload.php?SESSION_ID=<?php echo session_id(); ?>&SESSION_KEY=<?php echo $GLOBALS['SQ_SYSTEM']->getUniqueSessionKey(); ?>" />
592 <param name=
"FILE_FIELD_NAME" value=
"<?php echo $prefix; ?>" />
596 <param name=
"OPEN_URL" value=
"<?php echo $open_url; ?>" />
602 <script type=
"text/javascript"><!--
605 if (navigator.userAgent.match(/Windows/i) && navigator.userAgent.match(/Safari/i) && !navigator.userAgent.match(/Chrome/i)) {
606 var applet = document.getElementById(
'<?php echo $prefix; ?>_image_editor');
608 applet.style.width =
'0';
609 applet.style.height =
'0';
610 var element = document.createElement(
'div');
611 element.innerHTML = js_translate(
'image_editor_disabled');
612 applet.parentNode.appendChild(element);
633 $varieties = $asset->attr(
'varieties');
634 if (!empty($varieties)) {
635 foreach ($varieties[
'data'] as $varid => $data) {
636 $variety = $asset->getAsset($asset->id.
':'.$varid);
637 if (is_null($variety))
continue;
638 $asset->saveVariety($variety, TRUE, FALSE);
657 if (!SQ_TOOL_JPEG_TOOLKIT_ENABLED)
return $meta;
659 if (!defined(
'META_TOOLKIT_DIR')) {
660 define (
'META_TOOLKIT_DIR', SQ_TOOL_JPEG_TOOLKIT_PATH);
663 if (!file_exists(META_TOOLKIT_DIR.
'/JPEG.php')) {
664 trigger_error(
'JPEG Metadata Toolkit Path is invalid', E_USER_WARNING);
668 include_once META_TOOLKIT_DIR.
'/JPEG.php';
669 include_once META_TOOLKIT_DIR.
'/JFIF.php';
670 include_once META_TOOLKIT_DIR.
'/PictureInfo.php';
671 include_once META_TOOLKIT_DIR.
'/XMP.php';
672 include_once META_TOOLKIT_DIR.
'/Photoshop_IRB.php';
673 include_once META_TOOLKIT_DIR.
'/EXIF.php';
674 include_once META_TOOLKIT_DIR.
'/Photoshop_File_Info.php';
678 $jpeg_header_data = get_jpeg_header_data($filename);
679 $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) );
682 if (empty($XMP_array))
return $meta;
685 foreach ($XMP_array as $xmp_item) {
686 if ($xmp_item[
'tag'] !=
'x:xmpmeta')
continue;
687 if (!isset($xmp_item[
'children']))
continue;
689 foreach ($xmp_item[
'children'] as $xmp_meta_item) {
690 if ($xmp_meta_item[
'tag'] !=
'rdf:RDF')
continue;
691 if (!isset($xmp_meta_item[
'children']))
continue;
693 foreach ($xmp_meta_item[
'children'] as $rdf_data) {
694 if ($rdf_data[
'tag'] ==
'rdf:Description') {
695 if (!isset($rdf_data[
'children']))
continue;
697 foreach ($rdf_data[
'children'] as $description_data) {
698 $tag_name = $description_data[
'tag'];
699 if (strpos($tag_name,
'dc:') !== 0)
continue;
701 if (!isset($description_data[
'children']))
continue;
705 $current_tag = substr($tag_name, 3);
706 $keyword = $ns.
'--'.$current_tag;
708 foreach ($description_data[
'children'] as $tag_value_list) {
709 if (!isset($tag_value_list[
'children']))
continue;
711 $meta[$keyword][
'name'] = $tag_name;
712 foreach ($tag_value_list[
'children'] as $tag_value) {
714 if (!isset($tag_value[
'value'])) {
715 $meta[$keyword][
'value'][] =
'';
717 $meta[$keyword][
'value'][] = $tag_value[
'value'];