private static function get_media($readAuth) { iform_load_helpers(array('data_entry_helper')); $media = data_entry_helper::get_population_data(array('table' => 'occurrence_medium', 'extraParams' => $readAuth + array('occurrence_id' => $_GET['occurrence_id']), 'nocache' => true, 'sharing' => 'verification')); $r = ''; if (count($media) === 0) { $r .= lang::get('No media found for this record'); } else { $path = data_entry_helper::get_uploaded_image_folder(); $r .= '<ul class="gallery">'; foreach ($media as $file) { if (preg_match('/^http(s)?:\\/\\/(www\\.)?([a-z]+)/', $file['path'], $matches)) { $media = "<a href=\"{$file['path']}\" class=\"social-icon {$matches['3']}\"></a>"; } elseif (preg_match('/.(wav|mp3)$/', $file['path'])) { $media = "<audio controls src=\"{$path}{$file['path']}\" type=\"audio/mpeg\"/>"; } else { $media = "<a href=\"{$path}{$file['path']}\" class=\"fancybox\"><img src=\"{$path}thumb-" . "{$file['path']}\"/><br/>{$file['caption']}</a>"; } $r .= "<li>{$media}</li>"; } $r .= '</ul>'; $r .= '<p>' . lang::get('Click on thumbnails to view full size') . '</p>'; } return $r; }
private static function get_images($readAuth) { iform_load_helpers(array('data_entry_helper')); $images = data_entry_helper::get_population_data(array('table' => 'occurrence_image', 'extraParams' => $readAuth + array('occurrence_id' => $_GET['occurrence_id']), 'nocache' => true, 'sharing' => 'verification')); $r = ''; if (count($images) === 0) { $r .= lang::get('No images found for this record'); } else { $path = data_entry_helper::get_uploaded_image_folder(); $r .= '<ul class="gallery">'; foreach ($images as $image) { $r .= '<li><a href="' . $path . $image['path'] . '" class="fancybox"><img src="' . $path . 'thumb-' . $image['path'] . '"/>' . '<br/>' . $image['caption'] . '</a></li>'; } $r .= '</ul>'; $r .= '<p>' . lang::get('Click on image thumbnails to view full size') . '</p>'; } return $r; }
private static function get_images($website_id, $password) { iform_load_helpers(array('data_entry_helper')); $auth = data_entry_helper::get_read_auth($website_id, $password); $images = data_entry_helper::get_population_data(array('table' => 'occurrence_image', 'extraParams' => $auth + array('occurrence_id' => $_GET['occurrence_id']), 'nocache' => true)); $r = ''; if (count($images) === 0) { $r .= lang::get('No images found for this record ' . $_GET['occurrence_id']); } else { $path = data_entry_helper::get_uploaded_image_folder(); $r .= '<ul class="gallery">'; foreach ($images as $image) { $r .= '<li><a href="' . $path . $image['path'] . '" class="fancybox"><img src="' . $path . 'thumb-' . $image['path'] . '"/>' . '<br/>' . $image['caption'] . '</a></li>'; } $r .= '</ul>'; } $r .= '<script type="text/javascript">$("a.fancybox").fancybox();</script>'; return $r; }
private static function taxa_image_to_link($options, $habitats, $diveDurationAttrId, $habitatColours, $numberOfHabitats) { iform_load_helpers(array('report_helper')); global $user; //Use this report to return the photos $reportName = 'reports_for_prebuilt_forms/seasearch/get_media_for_all_sub_samples'; $reportOptions = array('readAuth' => $options['readAuth'], 'dataSource' => $reportName, 'extraParams' => array('media_type_id' => $options['imageMediaTypeId'])); if (!empty($_GET['sample_id'])) { $reportOptions['extraParams']['sample_id'] = $_GET['sample_id']; $photoResults = data_entry_helper::get_report_data($reportOptions); //Order using exif $photoResults = self::set_photo_order($photoResults); //NOTE: This function collects the path from configuration file, so that file needs to be setup correctly $uploadFolder = data_entry_helper::get_uploaded_image_folder(); $r = '<div>'; $photoCountPerRow = 0; //Also display a splitter for the user to drag habitats onto foreach ($photoResults as $idx => $photoData) { //If there is only 1 habitat, that means for each time we draw a photo to the screen, we can //set the sample_id for that photo to be that habitat if ($numberOfHabitats === 1) { $photoData['sample_id'] = $habitats[0]['id']; } //New row if too many items in the row if ($photoCountPerRow > 5) { $r .= '<br>'; $photoCountPerRow = 0; } $mediaItemNumber = $idx + 1; if (!empty($photoData['sample_id'])) { if ($photoData['sample_id'] == $_GET['sample_id']) { //Don't use colours if photos not allocated to habitat yet (first time page is opened) $style = 'border: 1px solid ; display: inline-block;'; $habColour = 'black'; } else { //Add a new colour to a photo border if is isn't assigned to the same habitat as the previous photo. //Otherwise the border will be same as previous habitat when loading page. if (empty($previousPhotoSampleId) || $previousPhotoSampleId != $photoData['sample_id']) { foreach ($habitats as $habIdx => $habitat) { if ($habitat['id'] == $photoData['sample_id']) { $style = 'border: 5px solid; display: inline-block; color: #' . $habitatColours[$habIdx] . ';'; $habColour = $habitatColours[$habIdx]; } } } } $previousPhotoSampleId = $photoData['sample_id']; //Photos could be attached to second or third level samples if ($photoData['media_table'] === 'sample_medium') { $sampleIdHolderControlName = $photoData['media_table'] . ':' . $photoData['id'] . ':sample_id'; } else { $sampleIdHolderControlName = $photoData['media_table'] . ':' . $photoData['id'] . ':sample_id:' . $photoData['level_three_sample_id']; } //Used when loading existing habitats $r .= '<input id="sub-sample-holder-for-media-number-' . $mediaItemNumber . '" type="hidden" name="' . $sampleIdHolderControlName . '" value="' . $photoData['sample_id'] . '">'; $r .= '<input id="' . $photoData['media_table'] . ':' . $photoData['id'] . ':image_path" type="hidden" name="' . $photoData['media_table'] . ':' . $photoData['id'] . ':image_path" value="' . $photoData['path'] . '">'; } //Note we need a specific "color" attribute as well as a style, this is because if we use .css('color') jquery to retrieve a colour, it converts the hex to rgb(<val>,<val>,<val>) automatically. To get the raw hex when we need it, we need to store it in a separate attribute as well $r .= '<span id="media-item-for-habitat-' . $photoData['id'] . '" number="' . $mediaItemNumber . '" style="' . $style . '" color="' . $habColour . '"/><a href="' . $uploadFolder . '' . $photoData['path'] . '}"><img src="' . $uploadFolder . 'thumb-' . $photoData['path'] . '" title="' . $photoData['caption'] . '" alt="' . $photoData['caption'] . '"/><br>' . $photoData['caption'] . '</a></span><span id="droppable-splitter-' . $mediaItemNumber . '" class="droppable-splitter" style="border: 1px solid ; height: 100px; width: 10px; display: inline-block;"></span>'; $photoCountPerRow++; } if (!empty($photoResults)) { $photoResultDecoded1 = json_decode($photoResults[0]['exif'], true); $photoResultDecoded2 = json_decode($photoResults[count($photoResults) - 1]['exif'], true); } //The duration attribute should default to the difference between first and last photos (in minutes) //Although the dive duration is not displayed on this tab, it is easiest to calculate it here as this tab processes photos as well. if (!empty($photoResultDecoded1['EXIF']['DateTimeOriginal']) && !empty($photoResultDecoded2['EXIF']['DateTimeOriginal'])) { $difference = strtotime($photoResultDecoded2['EXIF']['DateTimeOriginal']) - strtotime($photoResultDecoded1['EXIF']['DateTimeOriginal']); //Default the duration using minutes. $difference = (int) ($difference / 60); data_entry_helper::$javascript .= "\n if (!\$('#smpAttr\\\\:" . $diveDurationAttrId . "').val()) {\n \$('#smpAttr\\\\:" . $diveDurationAttrId . "').val('" . $difference . "');\n }\n"; } //TODO //Perhaps handle photos without EXIF in a separate gallery? /* foreach ($photosWithoutExif as $unsortedPhotoId) { foreach ($photoResults as $photoData) { if ($photoData['id']==$unsortedPhotoId) { $r.='<div style="width:120px;"><div id="gallery-item-'.$photoData['id'].'" style="float:left" class="gallery-item"><a href="'.$uploadFolder.''.$photoData['the_text'].'}"><img src="'.$uploadFolder.'thumb-'.$photoData['the_text'].'" title="'.$photoData['caption'].'" alt="'.$photoData['caption'].'"/><br>'.$photoData['caption'].'</a></div><div id="splitter-'.$photoData['id'].'" class="splitter" style="border: 1px solid ; height: 100px; width: 10px; float:right;"></div></div>'; } } }*/ $r .= '</div>'; return '<h3>Photos</h3>' . $r; } }
/** * Draw Photes section of the page. * @return string The output report grid. * * @package Client * @subpackage PrebuiltForms */ protected static function get_control_photos($auth, $args, $tabalias, $options) { iform_load_helpers(array('data_entry_helper')); data_entry_helper::add_resource('fancybox'); $options = array_merge(array('itemsPerPage' => 20, 'imageSize' => 'thumb', 'class' => 'detail-gallery'), $options); $images = data_entry_helper::get_population_data(array('table' => 'occurrence_image', 'extraParams' => $auth['read'] + array('occurrence_id' => $_GET['occurrence_id'], 'sharing' => 'reporting', 'limit' => $options['itemsPerPage']))); $r = '<div class="detail-panel" id="detail-panel-photos"><h3>Photos and media</h3><div class="' . $options['class'] . '">'; if (empty($images)) { $r .= '<p>No photos or media files available</p>'; } else { $r .= '<ul>'; $imageFolder = data_entry_helper::get_uploaded_image_folder(); foreach ($images as $idx => $image) { if ($idx === 0) { // first image can be flagged as the main content image. Used for FB OpenGraph for example. global $iform_page_metadata; if (!isset($iform_page_metadata)) { $iform_page_metadata = array(); } $iform_page_metadata['image'] = "{$imageFolder}{$image['path']}"; } $r .= "<li class=\"gallery-item\"><a href=\"{$imageFolder}{$image['path']}\" class=\"fancybox single\">" . "<img src=\"{$imageFolder}{$options['imageSize']}-{$image['path']}\" /></a><br/>{$image['caption']}</li>"; } $r .= '</ul>'; } $r .= '</div></div>'; return $r; }