diff options
Diffstat (limited to 'mod/photos.php')
-rw-r--r-- | mod/photos.php | 87 |
1 files changed, 73 insertions, 14 deletions
diff --git a/mod/photos.php b/mod/photos.php index c43beb8d4..f2df894c0 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -618,6 +618,12 @@ function photos_content(&$a) { if($datatype === 'album') { + if((strlen($datum) & 1) || (! ctype_xdigit($datum))) { + notice( t('Album name could not be decoded') . EOL); + logger('mod_photos: illegal album encoding: ' . $datum); + $datum = ''; + } + $album = hex2bin($datum); $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' @@ -629,7 +635,7 @@ function photos_content(&$a) { ); if(count($r)) { $a->set_pager_total(count($r)); - $a->set_pager_itemspage(40); + $a->set_pager_itemspage(60); } if($_GET['order'] === 'posted') @@ -691,9 +697,14 @@ function photos_content(&$a) { $o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album) . '" >' . t('Upload New Photos') . '</a></div>'; } + $ajaxout = ''; + $tpl = get_markup_template('photo_album.tpl'); - if(count($r)) + if(count($r)) { $twist = 'rotright'; + $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>"; + $o .= '<div id="photo-album-contents-' . $a->pager['page'] . '">'; + foreach($r as $rr) { if($twist == 'rotright') @@ -722,7 +733,8 @@ function photos_content(&$a) { $rel=("photo"); // } - $o .= replace_macros($tpl,array( + + $tmp = replace_macros($tpl,array( '$id' => $rr['id'], '$twist' => ' ' . $twist . rand(2,4), '$photolink' => $imagelink, @@ -734,10 +746,34 @@ function photos_content(&$a) { '$ext' => $ext, '$hash'=> $rr['resource_id'], )); + if($_REQUEST['aj']) + $ajaxout .= $tmp; + else + $o .= $tmp; + } + } + if($_REQUEST['aj']) { + if(! $r) { + $ajaxout .= '<div id="content-complete"></div>'; + echo $ajaxout; + killme(); + } + echo '<div id="photo-album-contents-' . $a->pager['page'] . '">'; + echo $ajaxout; + echo '</div>'; + echo '<script>justifyPhotos(' . $a->pager['page'] . ');</script>'; + killme(); } + + + $o .= '</div>'; // photo-album-contents + $o .= '<script>justifyPhotos(' . $a->pager['page'] . ');</script>'; + $o .= '<div id="page-end"></div>'; $o .= '<div id="photo-album-end"></div>'; - $o .= paginate($a); + $o .= '<script>$(document).ready(function() { loadingPage = false;});</script>'; + $o .= '<div id="page-spinner"></div>'; +// $o .= paginate($a); return $o; @@ -1132,7 +1168,7 @@ function photos_content(&$a) { ); if(count($r)) { $a->set_pager_total(count($r)); - $a->set_pager_itemspage(20); + $a->set_pager_itemspage(60); } $r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` @@ -1186,16 +1222,39 @@ function photos_content(&$a) { } } - $tpl = get_markup_template('photos_recent.tpl'); - $o .= replace_macros($tpl, array( - '$title' => t('Recent Photos'), - '$can_post' => $can_post, - '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'), - '$photos' => $photos, - )); + if($_REQUEST['aj']) { + if($photos) { + $o = replace_macros(get_markup_template('photosajax.tpl'),array( + '$photos' => $photos, + '$page' => $a->pager['page'] + )); + } + else { + $o = '<div id="content-complete"></div>'; + } + echo $o; + killme(); + } + else { + $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>"; + $tpl = get_markup_template('photos_recent.tpl'); + $o .= replace_macros($tpl, array( + '$title' => t('Recent Photos'), + '$can_post' => $can_post, + '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'), + '$photos' => $photos, + '$page' => $a->pager['page'] + )); - - $o .= paginate($a); + } + + if((! $photos) && ($_REQUEST['aj'])) { + $o .= '<div id="content-complete"></div>'; + echo $o; + killme(); + } + +// paginate($a); return $o; } |