contact; } } return $arr; } /** * @brief Construnct a widget with last uploaded photos * * It displays the last 9 photos * * @param array $profile_data *......'profile_uid'...=> The user.id of the profile (owner of the photos) *......'nickname'......=> Nick of the owner of the profile *......'page-flags'....=> Account type of the profile * * @return string *......formatted html * * @template widget_photos.tpl */ function widget_photos($profile_data) { $community_page = (($profile_data['page-flags'] == PAGE_COMMUNITY) ? true : false); $nickname = $profile_data['nickname']; $owner_id = $profile_data['profile_uid']; $phototypes = Photo::supportedTypes(); $photos_perms = photos_permissions($owner_id, $community_page); $sql_extra = permissions_sql($owner_id, $photos_perms['remote_contact'], $photos_perms['groups']); $r = q("SELECT `resource-id`, `id`, `filename`, `type`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT 9", intval($owner_id), dbesc('Contact Photos'), dbesc( t('Contact Photos')), dbesc( t('Profile Photos')) ); $photos = array(); if(count($r)) { foreach($r as $rr) { $ext = $phototypes[$rr['type']]; $photos[] = array( 'id' => $rr['id'], 'src' => z_root() . '/photos/' . $nickname . '/image/' . $rr['resource-id'], 'photo' => z_root() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'alt_text' => $rr['filename'], ); } $tpl = get_markup_template('widget_photos.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Photos'), '$photos' => $photos, '$photo_albums_page' => z_root() . '/photos/' . $nickname, '$photo_albums_page_title' => t('Vist the Photo Albums'), )); return $o; } } function getGps($exifCoord, $hemi) { $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0; $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0; $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1; return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600))); } function gps2Num($coordPart) { $parts = explode('/', $coordPart); if (count($parts) <= 0) return 0; if (count($parts) == 1) return $parts[0]; return floatval($parts[0]) / floatval($parts[1]); }