예제 #1
0
 /**
  * The UI to show a gallery.
  *
  * @return tempcode		The UI
  */
 function do_gallery()
 {
     require_code('images');
     $cat = get_param('id', 'root');
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . $cat;
     $root = get_param('root', 'root');
     if (!has_category_access(get_member(), 'galleries', $cat)) {
         access_denied('CATEGORY_ACCESS');
     }
     // Info on our gallery
     $gallery_rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $cat), '', 1);
     $implied_existence = false;
     if (!array_key_exists(0, $gallery_rows)) {
         // Possibly we will 'imply' it's existence if this is a member gallery; allows normal rendering to finish, with add links
         $matches = array();
         if (preg_match('#^member\\_(\\d+)\\_(.*)$#', $cat, $matches) != 0) {
             $username = $GLOBALS['FORUM_DRIVER']->get_username(intval($matches[1]));
             if (!is_null($username)) {
                 $gallery_rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $matches[2]), '', 1);
             }
         }
         if (!array_key_exists(0, $gallery_rows)) {
             return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE'));
         }
         $myrow = $gallery_rows[0];
         $myrow['is_member_synched'] = 0;
         $fullname = do_lang('PERSONAL_GALLERY_OF', $username, get_translated_text($myrow['fullname']));
         $myrow['parent_id'] = $matches[2];
         $implied_existence = true;
     } else {
         $myrow = $gallery_rows[0];
         $fullname = get_translated_text($myrow['fullname']);
     }
     if ($fullname == '') {
         $fullname = $cat;
     }
     $description = get_translated_tempcode($myrow['description']);
     if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $cat))) {
         $submit_cat = $myrow['is_member_synched'] == 1 ? 'member_' . strval(get_member()) . '_' . $cat : $cat;
         $submit_image_url = $myrow['accept_images'] == 0 ? new ocp_tempcode() : build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $submit_cat), get_module_zone('cms_galleries'));
         $submit_video_url = $myrow['accept_videos'] == 0 ? new ocp_tempcode() : build_url(array('page' => 'cms_galleries', 'type' => 'av', 'cat' => $submit_cat), get_module_zone('cms_galleries'));
     } else {
         $submit_image_url = new ocp_tempcode();
         $submit_video_url = new ocp_tempcode();
     }
     if (!$implied_existence && has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('cat_mid', get_member(), get_member_id_from_gallery_name($cat), 'cms_galleries', array('galleries', $cat))) {
         $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ec', 'id' => $cat), get_module_zone('cms_galleries'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     if (!$implied_existence && has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('cat_mid', get_member(), get_ip_address(), 'cms_galleries')) {
         $add_gallery_url = build_url(array('page' => 'cms_galleries', 'type' => 'ac', 'cat' => $cat), get_module_zone('cms_galleries'));
     } else {
         $add_gallery_url = new ocp_tempcode();
     }
     $may_download_gallery = has_specific_permission(get_member(), 'may_download_gallery', 'galleries', array('galleries', $cat));
     $tree = gallery_breadcrumbs($cat, $root, true, get_module_zone('galleries'));
     if (!$tree->is_empty()) {
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
     }
     if (has_specific_permission(get_member(), 'open_virtual_roots')) {
         $url = get_self_url(false, false, array('root' => $cat));
         $tree->attach(hyperlink($url, escape_html($fullname), false, false, do_lang_tempcode('VIRTUAL_ROOT')));
     } else {
         $tree->attach('<span>' . escape_html($fullname) . '</span>');
     }
     $myrow['flow_mode_interface'] = get_param_integer('flow_mode_interface', $myrow['flow_mode_interface']);
     // Allow override via URL
     // Flow mode puts emphasis on subgalleries, rather than entries; it is subgalleries that there are a lot of, rather than entries
     if ($myrow['flow_mode_interface'] == 1) {
         $max = get_param_integer('max', get_default_gallery_max());
         if ($max < 1) {
             $max = 1;
         }
         $start = get_param_integer('start', 0);
     } else {
         $max = NULL;
         $start = NULL;
     }
     // Subgalleries
     $order = 'add_date DESC';
     if (get_option('gallery_name_order') == '1') {
         $order = 'name ASC';
     }
     $rows_children = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('parent_id' => $cat), 'ORDER BY ' . $order, 200);
     $children = new ocp_tempcode();
     $num_galleries = 0;
     if (count($rows_children) == 200) {
         $rows_children = array();
     }
     // Lots of personal galleries. Will need to be reached via member profiles
     foreach ($rows_children as $child) {
         if (substr($child['name'], 0, 9) == 'download_') {
             continue;
         }
         if (!has_category_access(get_member(), 'galleries', $child['name'])) {
             continue;
         }
         if (get_option('show_empty_galleries') == '1' || gallery_has_content($child['name'])) {
             if (is_null($max) || $num_galleries >= $start && $num_galleries < $start + $max) {
                 $content = show_gallery_box($child, $root, true, get_zone_name(), get_option('show_empty_galleries') != '1');
                 if (!$content->is_empty()) {
                     $children->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => $content)));
                 }
             }
             $num_galleries++;
         }
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['gallery_views']++;
         $GLOBALS['SITE_DB']->query_update('galleries', array('gallery_views' => $myrow['gallery_views']), array('name' => $cat), '', 1, NULL, false, true);
     }
     // Page title
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('gallery', $cat);
     } else {
         $awards = array();
     }
     $title_to_use = do_lang_tempcode('_GALLERY', escape_html($fullname));
     $title_to_use_2 = do_lang('_GALLERY', $fullname);
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('gallery', $cat, $title_to_use_2);
     $rep_image = $myrow['rep_image'];
     if (post_param_integer('rating_' . $cat, -1) != -1) {
         decache('main_top_galleries');
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), $cat, $myrow['allow_rating'], $myrow['allow_comments'], 0, 1, NULL, build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true), $title_to_use_2, get_value('comment_forum__galleries'));
     breadcrumb_add_segment($tree);
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => is_null($myrow['g_owner']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($myrow['g_owner']), 'publisher' => '', 'modified' => '', 'type' => 'Gallery', 'title' => $fullname, 'identifier' => '_SEARCH:galleries:misc:' . $cat, 'description' => get_translated_text($myrow['description']));
     if ($rep_image != '') {
         $GLOBALS['META_DATA'] += array('image' => (url_is_local($rep_image) ? get_custom_base_url() . '/' : '') . $rep_image);
     }
     // Sorting
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     if (get_option('is_on_rating') == '1') {
         $_selectors['compound_rating DESC'] = 'POPULARITY';
     }
     $_selectors = array_merge($_selectors, array('url ASC' => 'FILENAME', 'add_date ASC' => 'OLDEST_FIRST', 'add_date DESC' => 'NEWEST_FIRST', 'title ASC' => 'TITLE'));
     $selectors = new ocp_tempcode();
     foreach ($_selectors as $selector_value => $selector_name) {
         $selected = $sort == $selector_value;
         $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('SELECTED' => $selected, 'NAME' => do_lang_tempcode($selector_name), 'VALUE' => $selector_value)));
     }
     $sort_url = get_self_url(false, false, array('sort' => NULL), false, true);
     $sorting = do_template('RESULTS_BROWSER_SORT', array('SORT' => 'sort', 'RAND' => uniqid(''), 'URL' => $sort_url, 'SELECTORS' => $selectors));
     if ($myrow['flow_mode_interface'] == 1) {
         return $this->do_gallery_flow_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download_gallery, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $rep_image, $start, $max, $num_galleries, $fullname, $sorting);
     } else {
         return $this->do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download_gallery, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting);
     }
 }
예제 #2
0
 /**
  * Show a group of subgalleries for use in a compact tree structure.
  *
  * @param  ID_TEXT			The zone our gallery module is in
  * @param  array				A list of gallery rows
  * @param  ID_TEXT			The template to use to show each subgallery
  * @param  boolean			Whether to show empty galleries
  * @return tempcode			The shown galleries
  */
 function inside($zone, $galleries, $tpl, $show_empty)
 {
     $content = new ocp_tempcode();
     foreach ($galleries as $gallery) {
         if ($show_empty || gallery_has_content($gallery['name'])) {
             $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'id' => $gallery['name']), $zone);
             $content->attach(do_template($tpl, array('TITLE' => get_translated_text($gallery['fullname']), 'URL' => $url)));
         }
     }
     return $content;
 }