Exemplo n.º 1
0
 /**
  * The UI to show a video.
  *
  * @param  ?string		Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries.
  * @param  ?tempcode		Breadcrumbs (NULL: derive in this function).
  * @return tempcode		The UI
  */
 function show_video($category_name = NULL, $tree = NULL)
 {
     $id = get_param_integer('id');
     if (get_param_integer('ajax', 0) == 1) {
         header('Content-type: text/xml');
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('video', strval($id));
     } else {
         $awards = array();
     }
     // Pic up some info
     $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $url = $myrow['url'];
     if (url_is_local($url)) {
         $url = get_custom_base_url() . '/' . $url;
     }
     $cat = $myrow['cat'];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat);
     if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') {
         require_code('site2');
         assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0);
     }
     $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat)));
     if (is_null($category_name)) {
         $category_name = $true_category_name;
     }
     if (get_param_integer('slideshow', 0) == 1) {
         $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name)));
         global $EXTRA_HEAD;
         $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
         // XHTMLXHTML
     } else {
         $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards);
     }
     $root = get_param('root', 'root');
     seo_meta_load_for('video', strval($id));
     $thumb_url = $myrow['thumb_url'];
     if (url_is_local($thumb_url)) {
         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
     }
     if (!has_category_access(get_member(), 'galleries', $cat)) {
         access_denied('CATEGORY_ACCESS');
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['video_views']++;
         $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos'));
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     // Comments
     $comments = get_translated_tempcode($myrow['comments']);
     if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) {
         $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     $add_date = get_timezoned_date($myrow['add_date']);
     $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']);
     // Video HTML
     $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']);
     $extension = get_file_extension($url);
     require_code('mime_types');
     $mime_type = get_mime_type($extension);
     list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*'));
     $member_id = get_member_id_from_gallery_name($cat, NULL, true);
     if (get_forum_type() == 'ocf') {
         require_code('ocf_members');
         require_code('ocf_members2');
     }
     $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id);
     $video_details = show_video_details($myrow);
     if (is_null($tree)) {
         $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries'));
     }
     breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO'));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type);
     return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details));
 }
Exemplo n.º 2
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('galleries');
     require_code('galleries');
     require_css('galleries');
     $content = new ocp_tempcode();
     $parent_id = array_key_exists('param', $map) ? $map['param'] : 'root';
     require_code('ocfiltering');
     $parent_ids = ocfilter_to_idlist_using_db($parent_id, 'name', 'galleries', 'galleries', 'parent_id', 'parent_id', 'name', false, false);
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $max = get_param_integer('max', 5);
     if ($max < 1) {
         $max = 1;
     }
     $start = get_param_integer('start', 0);
     // For all galleries off the given gallery
     $where = '';
     foreach ($parent_ids as $parent_id) {
         if ($where != '') {
             $where .= ' OR ';
         }
         $where .= db_string_equal_to('parent_id', $parent_id);
     }
     $query = 'FROM ' . get_table_prefix() . 'galleries WHERE (' . $where . ') AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\'';
     $galleries = $GLOBALS['SITE_DB']->query('SELECT * ' . $query . ' ORDER BY add_date DESC', $max, $start);
     foreach ($galleries as $child) {
         $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'id' => $child['name']), $zone);
         $member_id = get_member_id_from_gallery_name($child['name'], $child, true);
         $is_member = !is_null($member_id);
         $_title = get_translated_text($child['fullname']);
         $pic = $child['rep_image'];
         if ($pic == '' && $is_member) {
             $pic = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_avatar_url');
         }
         $teaser = get_translated_text($child['teaser']);
         if ($is_member && get_forum_type() == 'ocf') {
             require_code('ocf_members');
             require_code('ocf_members2');
             $member_info = ocf_show_member_box($member_id, true);
         } else {
             $member_info = new ocp_tempcode();
         }
         list($num_children, $num_images, $num_videos) = get_recursive_gallery_details($child['name']);
         if ($num_images == 0 && $num_videos == 0) {
             continue;
         }
         $thumb_order = 'ORDER BY id ASC';
         if (array_key_exists('reverse_thumb_order', $map) && $map['reverse_thumb_order'] == '1') {
             $thumb_order = 'ORDER BY id DESC';
         }
         if ($pic == '') {
             $pic = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'thumb_url', array('cat' => $child['name']), $thumb_order);
         }
         if (is_null($pic)) {
             $pic = $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'thumb_url', array('cat' => $child['name']), $thumb_order);
         }
         if (is_null($pic)) {
             $pic = '';
         }
         if ($pic != '' && url_is_local($pic)) {
             $pic = get_custom_base_url() . '/' . $pic;
         }
         $add_date = get_timezoned_date($child['add_date'], false);
         $sub = do_template('GALLERY_TEASE_PIC', array('_GUID' => '37cd5f3fc64ac1c76f85980e69a50154', 'TEASER' => $teaser, 'ADD_DATE' => $add_date, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_IMAGES' => integer_format($num_images), 'NUM_VIDEOS' => integer_format($num_videos), 'MEMBER_INFO' => $member_info, 'URL' => $url, 'PIC' => $pic, 'TITLE' => $_title));
         $content->attach($sub);
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
     $num_pages = intval(ceil(floatval($count) / floatval($max)));
     if ($num_pages == 0) {
         $page_num = 0;
     }
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max), '_SELF');
     $next_url = $page_num == $num_pages ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '6fb2def18957c246ddb2f19bf74abf9a', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('BLOCK_MAIN_GALLERY_TEASE', array('_GUID' => '0e7f84042ab0c873155998eae41b8a16', 'CONTENT' => $content, 'BROWSE' => $browse));
 }
Exemplo n.º 3
0
/**
 * Get preview detailing for a gallery.
 *
 * @param  array			The database row of the gallery
 * @param  ID_TEXT		The virtual root of the gallery
 * @param  boolean		Whether to show member stats if it is a member owned gallery
 * @param  ID_TEXT		The zone that the gallery module we are linking to is in
 * @param  boolean		Whether to not show anything if the gallery is empty
 * @param  boolean		Whether only to show 'preview' details
 * @return tempcode		The preview
 */
function show_gallery_box($child, $root = 'root', $show_member_stats_if_appropriate = false, $zone = '_SEARCH', $quit_if_empty = true, $preview = false)
{
    $member_id = get_member_id_from_gallery_name($child['name'], $child, true);
    $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'root' => $root == 'root' ? NULL : $root, 'id' => $child['name']), $zone);
    $_title = get_translated_text($child['fullname']);
    $pic = $child['rep_image'];
    $is_member = !is_null($member_id);
    if ($pic == '' && $is_member) {
        $pic = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id);
    }
    $add_date = get_timezoned_date($child['add_date'], false);
    $comments = get_translated_tempcode($child['description']);
    if ($show_member_stats_if_appropriate) {
        if ($is_member && get_forum_type() == 'ocf') {
            require_code('ocf_members');
            require_code('ocf_members2');
            $member_info = ocf_show_member_box($member_id, true);
        } else {
            $member_info = new ocp_tempcode();
        }
    } else {
        $member_info = new ocp_tempcode();
    }
    list($num_children, $num_images, $num_videos) = get_recursive_gallery_details($child['name']);
    if ($quit_if_empty && $num_images == 0 && $num_videos == 0 && $num_children == 0) {
        return new ocp_tempcode();
    }
    $thumb_order = 'ORDER BY id ASC';
    if (get_option('reverse_thumb_order') == '1') {
        $thumb_order = 'ORDER BY id DESC';
    }
    if ($pic == '') {
        $pic = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order);
        if ($pic === '') {
            require_code('images');
            $temp = $GLOBALS['SITE_DB']->query_select('images', array('id', 'url'), array('cat' => $child['name'], 'validated' => 1), $thumb_order, 1);
            $thumb_url = ensure_thumbnail($temp[0]['url'], '', 'galleries', 'images', $temp[0]['id']);
        }
    }
    if (is_null($pic)) {
        $pic = $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order);
    }
    if (is_null($pic)) {
        $pic = '';
    }
    if ($pic != '' && url_is_local($pic)) {
        $pic = get_custom_base_url() . '/' . $pic;
    }
    if ($pic != '') {
        require_code('images');
        $thumb = do_image_thumb($pic, '');
    } else {
        $thumb = new ocp_tempcode();
    }
    if ($num_children == 0) {
        if ($child['accept_videos'] == 0) {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS_IMAGES', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        } elseif ($child['accept_images'] == 0) {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS_VIDEOS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        } else {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        }
    } else {
        if ($child['accept_videos'] == 0) {
            $lang = do_lang_tempcode('SUBGALLERY_BITS_IMAGES', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        } elseif ($child['accept_images'] == 0) {
            $lang = do_lang_tempcode('SUBGALLERY_BITS_VIDEOS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        } else {
            $lang = do_lang_tempcode('SUBGALLERY_BITS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        }
    }
    $tpl = do_template('GALLERY_SUBGALLERY', array('_GUID' => '0dbec2f11de63b0402471fe5c8b32865', 'NUM_VIDEOS' => strval($num_videos), 'NUM_IMAGES' => strval($num_images), 'NUM_CHILDREN' => strval($num_children), 'ID' => $child['name'], 'LANG' => $lang, 'ADD_DATE' => $add_date, 'ADD_DATE_RAW' => strval($child['add_date']), 'MEMBER_INFO' => $member_info, 'URL' => $url, 'THUMB' => $thumb, 'PIC' => $pic, 'TITLE' => $_title, 'COMMENTS' => $comments));
    return $tpl;
}
Exemplo n.º 4
0
 /**
  * Standard aed_module submitter getter.
  *
  * @param  ID_TEXT		The entry for which the submitter is sought
  * @return array			The submitter, and the time of submission (null submission time implies no known submission time)
  */
 function get_submitter($id)
 {
     $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('add_date', 'g_owner'), array('name' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return array(get_member_id_from_gallery_name($id), NULL);
     }
     return array(get_member_id_from_gallery_name($id, $rows[0]), $rows[0]['add_date']);
 }