function myalbum_get_array_for_photo_assign($fetched_result_array, $summary = false) { global $my_uid, $isadmin, $global_perms; global $photos_url, $thumbs_url, $thumbs_dir, $mod_url, $mod_path; global $myalbum_makethumb, $myalbum_thumbsize, $myalbum_popular, $myalbum_newdays, $myalbum_normal_exts; include_once "{$mod_path}/class/myalbum.textsanitizer.php"; $myts =& MyAlbumTextSanitizer::getInstance(); extract($fetched_result_array); if (in_array(strtolower($ext), $myalbum_normal_exts)) { $imgsrc_thumb = "{$thumbs_url}/{$lid}.{$ext}"; $imgsrc_photo = "{$photos_url}/{$lid}.{$ext}"; $ahref_photo = "{$photos_url}/{$lid}.{$ext}"; $is_normal_image = true; // Width of thumb $width_spec = "width='{$myalbum_thumbsize}'"; if ($myalbum_makethumb) { list($width, $height, $type) = getimagesize("{$thumbs_dir}/{$lid}.{$ext}"); // if thumb images was made, 'width' and 'height' will not set. if ($width <= $myalbum_thumbsize) { $width_spec = ''; } } } else { $imgsrc_thumb = "{$thumbs_url}/{$lid}.gif"; $imgsrc_photo = "{$thumbs_url}/{$lid}.gif"; $ahref_photo = "{$photos_url}/{$lid}.{$ext}"; $is_normal_image = false; $width_spec = ''; } // Voting stats if ($rating > 0) { if ($votes == 1) { $votestring = _ALBM_ONEVOTE; } else { $votestring = sprintf(_ALBM_NUMVOTES, $votes); } $info_votes = number_format($rating, 2) . " ({$votestring})"; } else { $info_votes = '0.00 (' . sprintf(_ALBM_NUMVOTES, 0) . ')'; } // Submitter's name $submitter_name = myalbum_get_name_from_uid($submitter); // Category's title $cat_title = empty($cat_title) ? '' : $cat_title; // Summarize description if ($summary) { $description = $myts->extractSummary($description); } return array('lid' => $lid, 'cid' => $cid, 'ext' => $ext, 'res_x' => $res_x, 'res_y' => $res_y, 'window_x' => $res_x + 16, 'window_y' => $res_y + 16, 'title' => $myts->makeTboxData4Show($title), 'datetime' => formatTimestamp($date, 'm'), 'description' => $myts->displayTarea($description, 0, 1, 1, 1, 1, 1), 'imgsrc_thumb' => $imgsrc_thumb, 'imgsrc_photo' => $imgsrc_photo, 'ahref_photo' => $ahref_photo, 'width_spec' => $width_spec, 'can_edit' => $global_perms & GPERM_EDITABLE && ($my_uid == $submitter || $isadmin), 'submitter' => $submitter, 'submitter_name' => $submitter_name, 'hits' => $hits, 'rating' => $rating, 'rank' => floor($rating - 0.001), 'votes' => $votes, 'info_votes' => $info_votes, 'comments' => $comments, 'is_normal_image' => $is_normal_image, 'is_newphoto' => $date > time() - 86400 * $myalbum_newdays && $status == 1, 'is_updatedphoto' => $date > time() - 86400 * $myalbum_newdays && $status == 2, 'is_popularphoto' => $hits >= $myalbum_popular, 'info_morephotos' => sprintf(_ALBM_MOREPHOTOS, $submitter_name), 'cat_title' => $myts->makeTboxData4Show($cat_title)); }
$width_spec = "width='{$myalbum_thumbsize}' height='{$myalbum_thumbsize}'"; $ahref = ''; } } else { if ($preview_name != '' && is_readable("{$photos_dir}/{$preview_name}")) { // old preview list($imgsrc, $width_spec, $ahref) = myalbum_get_img_attribs_for_preview($preview_name); } else { // preview without image $imgsrc = "{$mod_url}/images/pixel_trans.gif"; $width_spec = "width='{$myalbum_thumbsize}' height='{$myalbum_thumbsize}'"; $ahref = ''; } } // Display Preview $photo_for_tpl = array('description' => $myts->displayTarea($photo['description'], 0, 1, 1, 1, 1, 1), 'title' => $myts->makeTboxData4Show($photo['title']), 'width_spec' => $width_spec, 'submitter' => $my_uid, 'submitter_name' => myalbum_get_name_from_uid($my_uid), 'imgsrc_thumb' => $imgsrc, 'ahref_photo' => $ahref); $tpl = new XoopsTpl(); include 'include/assign_globals.php'; $tpl->assign($myalbum_assign_globals); $tpl->assign('photo', $photo_for_tpl); echo "<table class='outer' style='width:100%;'>"; $tpl->display("db:myalbum{$mydirnumber}_photo_in_list.html"); echo "</table>\n"; } else { $photo = array('cid' => empty($_GET['cid']) ? 0 : intval($_GET['cid']), 'description' => '', 'title' => ''); } // Show the form $form = new XoopsThemeForm(_ALBM_PHOTOUPLOAD, "uploadphoto", "submit.php?caller={$caller}"); $pixels_text = "{$myalbum_width} x {$myalbum_height}"; if ($myalbum_canresize) { $pixels_text .= " (auto resize)";
} else { if ($uid != 0) { // This means 'my photo' if ($uid < 0) { $where = "submitter={$my_uid}"; $get_append = "uid=-1"; $xoopsTpl->assign('uid', -1); $xoopsTpl->assign('album_sub_title', _ALBM_TEXT_SMNAME4); $xoopsTpl->assign('xoops_pagetitle', _ALBM_TEXT_SMNAME4); // uid Specified } else { $where = "submitter={$uid}"; $get_append = "uid={$uid}"; $xoopsTpl->assign('uid', $uid); $xoopsTpl->assign('album_sub_title', "<img src='{$mod_url}/images/myphotos.gif' alt='' />" . myalbum_get_name_from_uid($uid)); $xoopsTpl->assign('xoops_pagetitle', myalbum_get_name_from_uid($uid)); } $join_append = "LEFT JOIN {$table_cat} c ON l.cid=c.cid"; $select_append = ', c.title AS cat_title'; } else { $where = "cid=0"; $get_append = "cid=0"; $join_append = ''; $select_append = ''; $xoopsTpl->assign('album_sub_title', 'error: category id not specified'); } } $prs = $xoopsDB->query("SELECT COUNT(lid) FROM {$table_photos} WHERE {$where} AND status>0"); list($photo_small_sum) = $xoopsDB->fetchRow($prs); $xoopsTpl->assign('photo_small_sum', $photo_small_sum); $xoopsTpl->assign('photo_total_sum', empty($photo_total_sum) ? $photo_small_sum : $photo_total_sum);
$xoopsTpl->assign('lang_category', _ALBM_CATEGORY); $xoopsTpl->assign('lang_hits', _ALBM_HITS); $xoopsTpl->assign('lang_rating', _ALBM_RATING); $xoopsTpl->assign('lang_vote', _ALBM_VOTE); $crs = $xoopsDB->query("SELECT cid,title FROM {$table_cat} WHERE pid=0 ORDER BY title"); $rankings = array(); $i = 0; while (list($cid, $cat_title) = $xoopsDB->fetchRow($crs)) { $rankings[$i] = array('title' => sprintf(_ALBM_TOP10, $myts->htmlSpecialChars($cat_title)), 'count' => $i); // get all child cat ids for a given cat id $children = $cattree->getAllChildId($cid); $whr_cid = 'cid IN ('; foreach ($children as $child) { $whr_cid .= "{$child},"; } $whr_cid .= "{$cid})"; $sql = "SELECT lid, cid, title, submitter, hits, rating, votes FROM {$table_photos} WHERE status>0 AND ({$whr_cid}) ORDER BY {$odr}"; $prs = $xoopsDB->query($sql, 10, 0); $rank = 1; while (list($lid, $cid, $title, $submitter, $hits, $rating, $votes) = $xoopsDB->fetchRow($prs)) { $catpath = $cattree->getPathFromId($cid, "title"); $catpath = substr($catpath, 1); $catpath = str_replace("/", " <span class='fg2'>»»</span> ", $catpath); $title = $myts->makeTboxData4Show($title); $rankings[$i]['photo'][] = array('lid' => $lid, 'cid' => $cid, 'rank' => $rank, 'title' => $title, 'submitter' => $submitter, 'submitter_name' => myalbum_get_name_from_uid($submitter), 'category' => $catpath, 'hits' => $hits, 'rating' => number_format($rating, 2), 'votes' => $votes); $rank++; } $i++; } $xoopsTpl->assign_by_ref('rankings', $rankings); include XOOPS_ROOT_PATH . "/footer.php";
$join_append = ''; $select_append = ''; } else { if ($uid != 0) { // This means 'my photo' if ($uid < 0) { $where = "submitter={$my_uid}"; $get_append = "uid=-1"; $xoopsTpl->assign('uid', -1); $xoopsTpl->assign('album_sub_title', _ALBM_TEXT_SMNAME4); // uid Specified } else { $where = "submitter={$uid}"; $get_append = "uid={$uid}"; $xoopsTpl->assign('uid', $uid); $xoopsTpl->assign('album_sub_title', "<img src='{$mod_url}/images/myphotos.gif' alt='' />" . myalbum_get_name_from_uid($uid)); } $join_append = "LEFT JOIN {$table_cat} c ON l.cid=c.cid"; $select_append = ', c.title AS cat_title'; } else { $where = "cid=0"; $get_append = "cid=0"; $join_append = ''; $select_append = ''; $xoopsTpl->assign('album_sub_title', 'error: category id not specified'); } } $prs = $xoopsDB->query("SELECT COUNT(lid) FROM {$table_photos} WHERE {$where} AND status>0"); list($photo_small_sum) = $xoopsDB->fetchRow($prs); $xoopsTpl->assign('photo_small_sum', $photo_small_sum); $xoopsTpl->assign('photo_total_sum', empty($photo_total_sum) ? $photo_small_sum : $photo_total_sum);