if ($global_perms & GPERM_INSERTABLE) { $xoopsTpl->assign('lang_add_photo', _ALBM_ADDPHOTO); } $xoopsTpl->assign('lang_album_main', _ALBM_MAIN); if ($cid > 0) { // GIJ TODO append error check! $rs = $xoopsDB->query("SELECT title FROM {$table_cat} WHERE cid='{$cid}'"); list($cat_title) = $xoopsDB->fetchRow($rs); $xoopsTpl->assign('xoops_pagetitle', $myts->makeTboxData4show($cat_title)); // Category Specified $xoopsTpl->assign('category_id', $cid); $xoopsTpl->assign('subcategories', myalbum_get_sub_categories($cid, $cattree)); $xoopsTpl->assign('category_options', myalbum_get_cat_options()); $cids = $cattree->getAllChildId($cid); array_push($cids, $cid); $photo_total_sum = myalbum_get_photo_total_sum_from_cats($cids, "status>0"); $sub_title = preg_replace("/\\'\\>/", "'><img src='{$mod_url}/images/folder16.gif' alt='' />", $cattree->getNicePathFromId($cid, 'title', "viewcat.php?num={$num}")); $sub_title = preg_replace("/^(.+)folder16/", '$1folder_open', $sub_title); $xoopsTpl->assign('album_sub_title', $sub_title); $where = "cid={$cid}"; $get_append = "cid={$cid}"; $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);
function myalbum_get_sub_categories($parent_id, $cattree) { global $xoopsDB, $table_cat; $myts =& MyTextSanitizer::getInstance(); $ret = array(); $crs = $xoopsDB->query("SELECT cid, title, imgurl FROM {$table_cat} WHERE pid={$parent_id} ORDER BY title") or die("Error: Get Category."); while (list($cid, $title, $imgurl) = $xoopsDB->fetchRow($crs)) { // Show first child of this category $subcat = array(); $arr = $cattree->getFirstChild($cid, "title"); foreach ($arr as $child) { $subcat[] = array('cid' => $child['cid'], 'title' => $myts->makeTboxData4Show($child['title']), 'photo_small_sum' => myalbum_get_photo_small_sum_from_cat($child['cid'], "status>0"), 'number_of_subcat' => sizeof($cattree->getFirstChildId($child['cid']))); } // Category's banner default if ($imgurl == "http://") { $imgurl = ''; } // Total sum of photos $cids = $cattree->getAllChildId($cid); array_push($cids, $cid); $photo_total_sum = myalbum_get_photo_total_sum_from_cats($cids, "status>0"); $ret[] = array('cid' => $cid, 'imgurl' => $myts->makeTboxData4Edit($imgurl), 'photo_small_sum' => myalbum_get_photo_small_sum_from_cat($cid, "status>0"), 'photo_total_sum' => $photo_total_sum, 'title' => $myts->makeTboxData4Show($title), 'subcategories' => $subcat); } return $ret; }