コード例 #1
0
ファイル: galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * Show subgalleries belonging to member.
  *
  * @param  ID_TEXT		Gallery name
  * @param  tempcode		The output goes in here (passed by reference)
  */
 function attach_gallery_subgalleries($gallery_name, &$galleries)
 {
     $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('parent_id' => $gallery_name), 'ORDER BY add_date DESC');
     foreach ($rows as $i => $row) {
         $galleries->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => show_gallery_box($row, 'root', false, get_module_zone('galleries')))));
         $this->attach_gallery_subgalleries($row['name'], $galleries);
     }
 }
コード例 #2
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('galleries');
     require_lang('galleries');
     $number = array_key_exists('param', $map) ? intval($map['param']) : 10;
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries');
     $out = new ocp_tempcode();
     $rows1 = $GLOBALS['SITE_DB']->query('SELECT DISTINCT g.name,g.add_date FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries g JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images i ON g.name=i.cat WHERE i.add_date IS NOT NULL AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\' ORDER BY g.add_date DESC', $number);
     $rows2 = $GLOBALS['SITE_DB']->query('SELECT DISTINCT g.name,g.add_date FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries g JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos i ON g.name=i.cat WHERE i.add_date IS NOT NULL AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\' ORDER BY g.add_date DESC', $number);
     $galleries = array_unique(collapse_2d_complexity('name', 'add_date', array_merge($rows1, $rows2)));
     arsort($galleries);
     if (count($galleries) == 0) {
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'e6d16782037d35949646f95656382783', 'HIGH' => false, 'TITLE' => do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('GALLERIES')), 'MESSAGE' => do_lang_tempcode('NO_CATEGORIES'), 'ADD_NAME' => '', 'SUBMIT_URL' => ''));
     } else {
         foreach (array_keys($galleries) as $i => $gallery) {
             if ($i == $number) {
                 break;
             }
             $row = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $gallery), '', 1);
             $out->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => show_gallery_box($row[0], 'root', true, $zone, false, true))));
         }
     }
     return do_template('BLOCK_MAIN_RECENT_GALLERIES', array('_GUID' => 'a7fca7d625a3d3af362735dad670f6eb', 'CONTENT' => $out, 'NUMBER' => integer_format($number)));
 }
コード例 #3
0
ファイル: galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
     }
 }
コード例 #4
0
ファイル: galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     require_code('galleries');
     $tpl = show_gallery_box($row, 'root', true, get_module_zone('galleries'), false, false);
     $tree = gallery_breadcrumbs($row['name']);
     if (!$tree->is_empty()) {
         $tpl->attach(paragraph(do_lang_tempcode('LOCATED_IN', $tree)));
     }
     return put_in_standard_box($tpl, do_lang_tempcode('GALLERY'));
 }
コード例 #5
0
ファイル: gallery.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function for award hooks. Renders a content box for an award/randomisation.
  *
  * @param  array		The database row for the content
  * @param  ID_TEXT	The zone to display in
  * @return tempcode	Results
  */
 function run($row, $zone)
 {
     require_css('galleries');
     require_code('galleries');
     return put_in_standard_box(show_gallery_box($row, 'root', false, $zone, false, false));
 }
コード例 #6
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('galleries');
     require_lang('galleries');
     require_css('galleries');
     $number = array_key_exists('param', $map) ? intval($map['param']) : 10;
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries');
     $rows_all = collapse_2d_complexity('rating_for_id', 'sum_rating', $GLOBALS['SITE_DB']->query('SELECT rating_for_id,AVG(rating) AS sum_rating FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'galleries') . ' GROUP BY rating_for_id'));
     arsort($rows_all);
     $rows = array();
     $highest = NULL;
     foreach ($rows_all as $id => $avg) {
         if (is_null($highest)) {
             $highest = $avg;
         }
         if ($avg == $highest) {
             $rows[] = $id;
             unset($rows_all[$id]);
         } else {
             break;
         }
     }
     shuffle($rows);
     $rows += array_keys($rows_all);
     $out = new ocp_tempcode();
     $galleries = NULL;
     if (count($rows) == 0) {
         $galleries = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('download\\_%') . '\'', $number);
         foreach ($galleries as $gallery) {
             $rows[] = $gallery['name'];
         }
     }
     if (count($rows) == 0) {
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '29a81617f7d4ce3384d519e9fe239178', 'HIGH' => false, 'TITLE' => do_lang_tempcode('TOP', make_string_tempcode(integer_format($number)), do_lang_tempcode('GALLERIES')), 'MESSAGE' => do_lang_tempcode('NO_CATEGORIES'), 'ADD_NAME' => '', 'SUBMIT_URL' => ''));
     } else {
         if (is_null($galleries)) {
             $i = 0;
             $or_list = '';
             foreach ($rows as $id) {
                 if ($or_list != '') {
                     $or_list .= ' OR ';
                 }
                 $or_list .= db_string_equal_to('name', $id);
                 if ($i == $number) {
                     break;
                 }
                 $i++;
             }
             $galleries = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'galleries WHERE (' . $or_list . ') AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\'');
         }
         $i = 0;
         foreach ($rows as $id) {
             $row = NULL;
             foreach ($galleries as $gallery) {
                 if ($gallery['name'] == $id) {
                     $row = $gallery;
                     break;
                 }
             }
             if (!is_null($row)) {
                 $out->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => show_gallery_box($row, 'root', true, $zone, false, true))));
                 if ($i == $number) {
                     break;
                 }
                 $i++;
             }
         }
     }
     return do_template('BLOCK_MAIN_TOP_GALLERIES', array('_GUID' => 'f95e3288fe9bee2bcdd62b46cff15208', 'CONTENT' => $out, 'NUMBER' => integer_format($number)));
 }