$permalink = get_permalink();
$post_meta = get_post_custom();
$visible_gallery_categories = array();
$gallery_category_slug="";
if(isset($_GET) && isset($_GET['category'])) $gallery_category_slug=$_GET['category'];
if($gallery_category_slug=="") $gallery_category_slug = $post_meta['dsframework-root-gallery-category'][0];
if($gallery_category_slug=="" && isset($post_meta['dsframework-visible-gallery-categories'][0])) $visible_gallery_categories = explode(",", $post_meta['dsframework-visible-gallery-categories'][0]);
if(count($visible_gallery_categories)>0){
foreach ( $visible_gallery_categories as $subgallery_category_slug ){
$category=get_gallery_category_by_slug( trim( $subgallery_category_slug) );
if($category!=null) $categories[]=$category;
}
}else if($gallery_category_slug!=""){
$gallery_category=get_gallery_category_by_slug($gallery_category_slug);
$categories = get_gallery_categories(array('hide_empty' => 0, 'parent' => $gallery_category->term_id));
}else{
$categories = get_gallery_categories(array('hide_empty' => 0));
}
?>