/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { if (get_option('is_on_rating') == '0') { return do_lang_tempcode('INTERNAL_ERROR'); } // Has there actually been any rating? if (strtoupper(ocp_srv('REQUEST_METHOD')) == 'POST' || ocp_srv('HTTP_REFERER') == '') { $rating = either_param_integer('rating', NULL); } else { $rating = post_param_integer('rating'); // Will fail } $content_type = get_param('content_type'); $type = get_param('type', ''); $content_id = get_param('id'); $content_url = get_param('content_url', '', true); $content_title = get_param('content_title', '', true); require_code('feedback'); actualise_specific_rating($rating, get_page_name(), get_member(), $content_type, $type, $content_id, $content_url, $content_title); actualise_give_rating_points(); $template = get_param('template', NULL); if ($template !== '') { if (is_null($template)) { $template = 'RATING_BOX'; } return display_rating($content_url, $content_title, $content_type, $content_id, $template); } return do_lang_tempcode('THANKYOU_FOR_RATING_SHORT'); }
function bsf_do_rating() { global $post; $ip = get_the_ip(); $ip_array = array(); $data = get_post_meta($post->ID, 'post-rating', false); if (!empty($data)) { foreach ($data as $d) { array_push($ip_array, $d['user_ip']); } if (!in_array($ip, $ip_array)) { return display_rating(); } else { if (in_array($ip, $ip_array)) { $rating = get_previous_rating($ip, $data); $stars = bsf_display_rating($rating); return $stars; } } } else { return display_rating(); } }
/** * Render posts. * * @param integer Maximum to load if non-threaded * @param array Tree structure of posts * @param boolean Whether the current user may reply to the topic (influences what buttons show) * @param ?AUTO_LINK Only show posts under here (NULL: show posts from root) * @param array Review ratings rows * @param AUTO_LINK ID of forum this topic in in * @return tempcode Rendered tree structure */ function _render_post_tree($num_to_show_limit, $tree, $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id) { list($rendered, ) = $tree; $sequence = new ocp_tempcode(); foreach ($rendered as $post) { if (get_forum_type() == 'ocf') { require_code('ocf_topicview'); require_code('ocf_posts'); $post += ocf_get_details_to_show_post($post); } // Misc details $datetime_raw = $post['date']; $datetime = get_timezoned_date($post['date']); $poster_url = is_guest($post['user']) ? new ocp_tempcode() : $GLOBALS['FORUM_DRIVER']->member_profile_url($post['user'], false, true); $poster_name = array_key_exists('username', $post) ? $post['username'] : $GLOBALS['FORUM_DRIVER']->get_username($post['user']); if (is_null($poster_name)) { $poster_name = do_lang('UNKNOWN'); } $highlight = $highlight_by_user === $post['user']; // Find review, if there is one $individual_review_ratings = array(); foreach ($all_individual_review_ratings as $potential_individual_review_rating) { if ($potential_individual_review_rating['r_post_id'] == $post['id']) { $individual_review_ratings[$potential_individual_review_rating['r_rating_type']] = array('REVIEW_TITLE' => $potential_individual_review_rating['r_rating_type'], 'REVIEW_RATING' => float_to_raw_string($potential_individual_review_rating['r_rating'])); } } // Edit URL $emphasis = new ocp_tempcode(); $buttons = new ocp_tempcode(); $last_edited = new ocp_tempcode(); $last_edited_raw = ''; $unvalidated = new ocp_tempcode(); $poster = mixed(); $poster_details = new ocp_tempcode(); $is_spacer_post = false; if (get_forum_type() == 'ocf') { // Spacer post fiddling if (!is_null($this->first_post_id) && !is_null($this->topic_title) && !is_null($this->topic_description) && !is_null($this->topic_description_link)) { $is_spacer_post = $post['id'] == $this->first_post_id && substr($post['message_comcode'], 0, strlen('[semihtml]' . do_lang('SPACER_POST_MATCHER'))) == '[semihtml]' . do_lang('SPACER_POST_MATCHER'); if ($is_spacer_post) { $c_prefix = do_lang('COMMENT') . ': #'; if (substr($this->topic_description, 0, strlen($c_prefix)) == $c_prefix && $this->topic_description_link != '') { list($linked_type, $linked_id) = explode('_', substr($this->topic_description, strlen($c_prefix)), 2); $linked_url = $this->topic_description_link; require_code('ocf_posts'); list($new_description, $new_post) = ocf_display_spacer_post($linked_type, $linked_id); //if (!is_null($new_description)) $this->topic_description=$new_description; Actually, it's a bit redundant if (!is_null($new_post)) { $post['message'] = $new_post; } $highlight = false; $this->topic_title = do_lang('SPACER_TOPIC_TITLE_WRAP', $this->topic_title); $post['title'] = do_lang('SPACER_TOPIC_TITLE_WRAP', $post['title']); $this->topic_description = ''; } } } // Misc meta details for post $emphasis = ocf_get_post_emphasis($post); $unvalidated = $post['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode(); if (array_key_exists('last_edit_time', $post)) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']), 'LAST_EDIT_DATE' => $post['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $post['last_edit_by_username'])); $last_edited_raw = is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']); } // Post buttons if (!$is_spacer_post) { if (!is_null($this->topic_id)) { if (is_null($this->topic_info)) { $this->topic_info = ocf_read_in_topic($this->topic_id, 0, 0, false, false); } require_lang('ocf'); $buttons = ocf_render_post_buttons($this->topic_info, $post, $may_reply); } } // OCF renderings of poster static $hooks = NULL; if (is_null($hooks)) { $hooks = find_all_hooks('modules', 'topicview'); } static $hook_objects = NULL; if (is_null($hook_objects)) { $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } } if (!$is_spacer_post) { if (!is_guest($post['poster'])) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($post, false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); if (array_key_exists('ip_address', $post) && addon_installed('ocf_forum')) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $post['ip_address']))); $poster_details = do_template('OCF_GUEST_DETAILS', array('CUSTOM_FIELDS' => $custom_fields)); } else { $poster_details = new ocp_tempcode(); } } } if (addon_installed('ocf_forum')) { if (!is_guest($post['poster'])) { $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($post['poster']), 'ID' => strval($post['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['poster'], false, true), 'POSTER_USERNAME' => $post['poster_username'])); } else { $ip_link = array_key_exists('ip_address', $post) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $post['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode(); $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $post['poster_username'])); } } else { $poster = make_string_tempcode(escape_html($post['poster_username'])); } } // Child posts $children = mixed(); // NULL $other_ids = array(); if (array_key_exists('children', $post)) { foreach ($post['children'][1] as $u) { $other_ids[] = strval($u['id']); } if ($this->is_threaded) { $children = $this->_render_post_tree($num_to_show_limit, $post['children'], $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id); } } if (get_forum_type() == 'ocf') { require_code('feedback'); actualise_rating(true, 'post', strval($post['id']), get_self_url(), $post['title']); $rating = display_rating(get_self_url(), $post['title'], 'post', strval($post['id']), 'RATING_INLINE_DYNAMIC', $post['user']); } else { $rating = new ocp_tempcode(); } if (array_key_exists('intended_solely_for', $post)) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } // Render $sequence->attach(static_evaluate_tempcode(do_template('POST', array('_GUID' => 'eb7df038959885414e32f58e9f0f9f39', 'INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $post['title'], 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_ID' => strval($post['user']), 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => strval($post['id']), 'POST' => $post['message'], 'POST_COMCODE' => isset($post['message_comcode']) ? $post['message_comcode'] : NULL, 'CHILDREN' => $children, 'OTHER_IDS' => count($other_ids) == 0 ? NULL : $other_ids, 'RATING' => $rating, 'EMPHASIS' => $emphasis, 'BUTTONS' => $buttons, 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'TOPIC_ID' => is_null($this->topic_id) ? '' : strval($this->topic_id), 'UNVALIDATED' => $unvalidated, 'IS_SPACER_POST' => $is_spacer_post, 'NUM_TO_SHOW_LIMIT' => strval($num_to_show_limit))))); } return $sequence; }
/** * The UI for an "regular mode" gallery. * * @param tempcode Rating area * @param tempcode Commenting area * @param ID_TEXT Our gallery ID * @param ID_TEXT Virtual root gallery * @param tempcode The description of the gallery * @param tempcode The tempcode for our visible child galleries * @param boolean Whether may "download this gallery" * @param tempcode The URL to "edit this gallery" * @param tempcode The URL to "add a gallery" * @param tempcode The URL to "submit an image to this gallery" * @param tempcode The URL to "submit a video to this gallery" * @param tempcode The title of the page (our of get_page_title) * @param string The gallery title * @param tempcode Sorting UI * @return tempcode The UI */ function do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting) { $max = get_param_integer('max', get_default_gallery_max()); $start = get_param_integer('start', 0); if ($max < 1) { $max = 1; } $page_num = $max == 0 ? 0 : intval(floor(floatval($start) / floatval($max))) + 1; // Work out totals $num_images = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $cat)); $num_videos = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $cat)); $total_rows = $num_images + $num_videos; $total_pages = $max == 0 ? 1 : intval(ceil(floatval($total_rows) / floatval($max))); if ($total_pages == 0) { $total_pages = 1; } list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order(); $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } if (get_param('days', '') != '') { $where .= ' AND add_date>' . strval(time() - get_param_integer('days') * 60 * 60 * 24); } $rows = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_videos . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $where . ' ORDER BY ' . $sort, $max, $start); if (count($rows) < $max) { $where = db_string_equal_to('cat', $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where .= ' AND validated=1'; } $rows2 = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_images . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $where . ' ORDER BY ' . $sort, $max - count($rows), max(0, $start - $num_videos)); } else { $rows2 = array(); } $entries = new ocp_tempcode(); $image_select = get_param('select', '*'); $video_select = get_param('video_select', '*'); // Display videos foreach ($rows as $row_video) { $view_url = build_url(array('page' => '_SELF', 'type' => 'video', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_video['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $start == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_video['url'], $row_video['thumb_url'], 'galleries', 'videos', $row_video['id']); if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_video['url']; if (url_is_local($this_full_url)) { $this_full_url = get_custom_base_url() . '/' . $this_full_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $map = array('_GUID' => '395f0aa1212e69da5752d228a6efe54d', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_video['id']), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']), 'SUBMITTER' => strval($row_video['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIDEO_DETAILS' => show_video_details($row_video)); $entry = do_template('GALLERY_VIDEO', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'bc0d3de5d0160b00e3250d78658888c1', 'ENTRY' => $entry) + $map)); } // Display images foreach ($rows2 as $row_image) { $view_url = build_url(array('page' => '_SELF', 'type' => 'image', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_image['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $max == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF'); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $this_full_url = $row_image['url']; if (url_is_local($this_full_url)) { $file_size = file_exists(get_custom_file_base() . '/' . rawurldecode($this_full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($this_full_url))) : ''; $this_full_url = get_custom_base_url() . '/' . $this_full_url; } else { $file_size = ''; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $map = array('_GUID' => 'aa70f543297e25379c49fa25d6dbcac0', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'FILE_SIZE' => $file_size, 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_image['id']), 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']), 'SUBMITTER' => strval($row_image['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url); $entry = do_template('GALLERY_IMAGE', $map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'ea12d7acf47eab493b6fb4658b3c0346', 'ENTRY' => $entry) + $map)); } // Member gallery? $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); // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'start', $max, 'max', $total_rows, $root, 'misc', true, false, 10, $_selectors); return do_template('GALLERY_REGULAR_MODE_SCREEN', array('_GUID' => 'cec405597f47f5079b7c7f581fa6b5c2', 'SORTING' => $sorting, '_TITLE' => $fullname, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'RESULTS_BROWSER' => $results_browser, 'TAGS' => get_loaded_tags('galleries'), 'CAT' => $cat, 'MEMBER_DETAILS' => $member_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'ADD_GALLERY_URL' => $add_gallery_url, 'EDIT_URL' => $edit_url, 'CHILDREN' => $children, 'TITLE' => $title, 'DESCRIPTION' => $description, 'IMAGE_URL' => $submit_image_url, 'VIDEO_URL' => $submit_video_url, 'MAY_DOWNLOAD' => $may_download, 'ENTRIES' => $entries)); }
/** * Show a post, isolated of the other posts in it's topic. * * @param array The post row. * @param boolean Whether to use the post title, as opposed to the post's topic's title. * @return tempcode The isolated post. */ function ocf_show_isolated_post($row, $use_post_title = false) { require_code('ocf_groups'); require_css('ocf'); // Poster title $primary_group = $GLOBALS['FORUM_DRIVER']->get_member_row_field($row['p_poster'], 'm_primary_group'); if (!is_null($primary_group)) { if (addon_installed('ocf_member_titles')) { $poster_title = $GLOBALS['OCF_DRIVER']->get_member_row_field($row['p_poster'], 'm_title'); if ($poster_title == '') { $poster_title = get_translated_text(ocf_get_group_property($primary_group, 'title'), $GLOBALS['FORUM_DB']); } } else { $poster_title = ''; } $avatar = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($row['p_poster']); $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($row['p_poster'], true); } else { $poster_title = ''; $avatar = ''; $posters_groups = array(); } // Avatar if (is_guest($row['p_poster'])) { if ($row['p_poster_name_if_guest'] == do_lang('SYSTEM')) { $avatar = find_theme_image('ocf_default_avatars/default_set/ocp_fanatic', true); } } if ($avatar != '') { $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('AVATAR' => $avatar)); } else { $post_avatar = new ocp_tempcode(); } // Rank images $rank_images = new ocp_tempcode(); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $primary_group)) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $row['p_poster']))); } } // Poster details if (!is_guest($row['p_poster']) && !is_null($primary_group)) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($row['p_poster'], false, NULL, NULL, false); } else { $custom_fields = new ocp_tempcode(); $poster_details = new ocp_tempcode(); } if (!is_guest($row['p_poster']) && !is_null($primary_group)) { $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($row['p_poster']), 'ID' => strval($row['p_poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_poster'], false, true), 'POSTER_USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'HIGHLIGHT_NAME' => NULL)); } else { $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $row['p_poster_name_if_guest'] != '' ? $row['p_poster_name_if_guest'] : do_lang('GUEST'))); } // Last edited if (!is_null($row['p_last_edit_time'])) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']), 'LAST_EDIT_DATE' => get_timezoned_date($row['p_last_edit_time']), 'LAST_EDIT_PROFILE_URL' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($row['p_last_edit_by']))); } else { $last_edited = new ocp_tempcode(); } $last_edited_raw = is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']); // Misc stuff $poster_id = $row['p_poster']; $tree = ocf_forum_breadcrumbs($row['p_cache_forum_id']); $post_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('topicview')); $post_url->attach('#post_' . strval($row['id'])); if (get_page_name() != 'search' && array_key_exists('text_parsed', $row) && !is_null($row['text_parsed']) && $row['text_parsed'] != '' && $row['p_post'] != 0) { $post = new ocp_tempcode(); if (!$post->from_assembly($row['text_parsed'], true)) { $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']); } } else { $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']); } $post_date = get_timezoned_date($row['p_time']); $post_date_raw = $row['p_time']; if ($use_post_title) { $post_title = $row['p_title']; } else { $post_title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $row['p_topic_id'])); if ($row['p_title'] != $post_title) { $post_title .= ': ' . $row['p_title']; } } //if ($post_title=='') $post_title=do_lang_tempcode('ISOLATED_POST_TITLE',strval($row['id'])); $emphasis = new ocp_tempcode(); if ($row['p_is_emphasised'] == 1) { $emphasis = do_lang_tempcode('IMPORTANT'); } elseif (!is_null($row['p_intended_solely_for'])) { $pp_to_username = $GLOBALS['FORUM_DRIVER']->get_username($row['p_intended_solely_for']); if (is_null($pp_to_username)) { $pp_to_username = do_lang('UNKNOWN'); } $emphasis = do_lang('PP_TO', $pp_to_username); } require_code('feedback'); actualise_rating(true, 'post', strval($row['id']), get_self_url(), $row['p_title']); $rating = display_rating(get_self_url(), $row['p_title'], 'post', strval($row['id']), 'RATING_INLINE_DYNAMIC', $row['p_poster']); // Render return do_template('OCF_ISOLATED_POST', array('_GUID' => '9456f4fe4b8fb1bf34f606fcb2bcc9d7', 'URL' => $post_url, 'ID' => strval($row['id']), 'TREE' => $tree, 'POST' => do_template('OCF_TOPIC_POST', array('ID' => strval($row['id']), 'TOPIC_FIRST_POST_ID' => '', 'TOPIC_FIRST_POSTER' => '', 'POST_ID' => strval($row['id']), 'URL' => $post_url, 'CLASS' => $row['p_is_emphasised'] == 1 ? 'ocf_post_emphasis' : (!is_null($row['p_intended_solely_for']) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => '', 'POSTER_TITLE' => $poster_title, 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($post_date_raw), 'POST_DATE' => $post_date, 'POST' => $post, 'TOPIC_ID' => is_null($row['p_topic_id']) ? '' : strval($row['p_topic_id']), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($poster_id), 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => '', 'SIGNATURE' => '', 'UNVALIDATED' => '', 'DESCRIPTION' => '', 'PREVIEWING' => true, 'RATING' => $rating)))); }
/** * Get tempcode for doing ratings (sits above get_rating_simple_array) * * @param mixed The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode) * @param ?string The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important) * @param ID_TEXT The type (download, etc) that this rating is for * @param ID_TEXT The ID of the type that this rating is for * @param boolean Whether this resource allows rating (if not, this function does nothing - but it's nice to move out this common logic into the shared function) * @param ?MEMBER Content owner (NULL: none) * @return tempcode Tempcode for complete rating box */ function get_rating_box($content_url, $content_title, $content_type, $content_id, $allow_rating, $submitter = NULL) { if ($allow_rating) { return display_rating($content_url, $content_title, $content_type, $content_id, 'RATING_BOX', $submitter); } return new ocp_tempcode(); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_topicview'); require_css('ocf'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $NON_CANONICAL_PARAMS[] = 'start'; $NON_CANONICAL_PARAMS[] = 'threaded'; $start = get_param_integer('start', 0); $default_max = intval(get_option('forum_posts_per_page')); $max = get_param_integer('max', $default_max); if ($max == 0) { $max = $default_max; } if ($max == 0) { $max = 1; } if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) { $max = $default_max; } $first_unread_id = -1; global $NON_CANONICAL_PARAMS; foreach (array_keys($_GET) as $key) { if (substr($key, 0, 3) == 'kfs') { $NON_CANONICAL_PARAMS[] = $key; } } $type = get_param('type', 'misc'); $id = get_param_integer('id', NULL); if (is_guest() && is_null($id)) { access_denied('NOT_AS_GUEST'); } if ($type == 'findpost') { $post_id = get_param_integer('id'); $redirect = find_post_id_url($post_id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } else { if ($type == 'first_unread') { $redirect = find_first_unread_url($id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } } if (!is_null($id)) { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id); } $view_poll_results = get_param_integer('view_poll_results', 0); // Mark as read if (!is_null($id)) { if (!is_guest()) { $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true); // race condition } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true); } // Load up topic info $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1); $GLOBALS['META_DATA'] += $topic_info['meta_data']; global $SEO_TITLE; $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']); // Render posts according to whether threaded or not $threaded = $topic_info['is_threaded'] == 1; $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info)); if (!$threaded) { $GLOBALS['META_DATA']['description'] = $topic_info['description']; // Poster detail hooks $hooks = find_all_hooks('modules', 'topicview'); $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } // Render non-threaded $posts = new ocp_tempcode(); $replied = false; if (is_null($topic_info['forum_id'])) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $second_poster = $topic_info['first_poster']; foreach ($topic_info['posts'] as $array_id => $_postdetails) { if ($array_id == 0) { $description = $topic_info['description']; } else { $description = NULL; } if ($_postdetails['poster'] == get_member()) { $replied = true; } if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) { $second_poster = $_postdetails['poster']; } if (array_key_exists('last_edit_time', $_postdetails)) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username'])); } else { $last_edited = new ocp_tempcode(); } $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0'; $is_spacer_post = $_postdetails['is_spacer_post']; // Post buttons $buttons = new ocp_tempcode(); if (!$is_spacer_post) { $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply); } // Avatar if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') { $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar'])); } else { $post_avatar = new ocp_tempcode(); } // Rank images $rank_images = new ocp_tempcode(); if (!$is_spacer_post) { $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster']))); } } } // Poster details if (!$is_spacer_post) { if (!is_guest($_postdetails['poster'])) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); if (array_key_exists('ip_address', $_postdetails)) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address']))); $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields)); } else { $poster_details = new ocp_tempcode(); } } } else { $poster_details = new ocp_tempcode(); } if (!is_guest($_postdetails['poster'])) { $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL)); } else { $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode(); $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username'])); } // Signature $signature = new ocp_tempcode(); if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) { $signature = $_postdetails['signature']; } $post_title = $_postdetails['title']; $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode(); $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode(); $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $emphasis = ocf_get_post_emphasis($_postdetails); require_code('feedback'); if (!array_key_exists('intended_solely_for', $_postdetails)) { actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']); $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']); } else { $rating = new ocp_tempcode(); } $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating)); $posts->attach($rendered_post); } $serialized_options = mixed(); $hash = mixed(); } else { require_code('topics'); $threaded_topic_ob = new OCP_Topic(); // Load some settings into the renderer $threaded_topic_ob->first_post_id = $topic_info['first_post_id']; $threaded_topic_ob->topic_description = $topic_info['description']; $threaded_topic_ob->topic_description_link = $topic_info['description_link']; $threaded_topic_ob->topic_title = $topic_info['title']; $threaded_topic_ob->topic_info = $topic_info; // Other settings we need $max_thread_depth = intval(get_option('max_thread_depth')); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); // Load posts $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true); $threaded_topic_ob->is_threaded = true; // Render posts list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false); $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description; // Get other gathered details $replied = $threaded_topic_ob->replied; if (!is_null($threaded_topic_ob->topic_title)) { // Updated topic title $topic_info['title'] = $threaded_topic_ob->topic_title; } $topic_info['max_rows'] = $threaded_topic_ob->total_posts; $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id(); // No definitive post orders } // Buttons for topic as whole $button_array = array(); if (!is_null($id)) { if (get_value('no_threaded_buttons') !== '1') { if ($threaded) { $view_as_linear_url = get_self_url(false, false, array('threaded' => 0)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear'); } else { $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded'); } } if (!is_guest()) { $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days')); if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) { $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $mark_unread_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread'); } } if ($may_reply && is_null(get_bot_type())) { $reply_prevented = false; // "Staff-only" reply for support tickets if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) { require_code('tickets'); if (is_ticket_forum($topic_info['forum_id'])) { if (is_guest($second_poster)) { $reply_prevented = true; } require_lang('tickets'); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id()); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply'); } } if (!$reply_prevented) { if ($topic_info['is_threaded'] == 0) { $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed'); } } else { unset($topic_info['may_use_quick_reply']); } } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) { $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']); $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1); if ($test != -1 && $test != 0) { $map['kfs' . strval($topic_info['forum_id'])] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend'); } if (!is_null($topic_info['forum_id'])) { if (get_value('disable_add_topic_btn_in_topic') !== '1') { if (ocf_may_post_topic($topic_info['forum_id'], get_member())) { $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic'); } } } else { $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member'); } } $buttons = ocf_screen_button_wrap($button_array); // Poll if (array_key_exists('poll', $topic_info)) { $_poll = $topic_info['poll']; $voted_already = $_poll['voted_already']; $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]); $answers = new ocp_tempcode(); $real_button = false; if ($_poll['is_open']) { if ($poll_results) { $button = new ocp_tempcode(); } elseif ($_poll['requires_reply'] && !$replied) { $button = do_lang_tempcode('POLL_REQUIRES_REPLY'); } else { if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) { $button = do_lang_tempcode('VOTE_DENIED'); } else { if (!is_null($voted_already)) { $button = do_lang_tempcode('NOVOTE'); } else { require_lang('polls'); $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $results_url = build_url($map, get_module_zone('topics')); $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url)); $real_button = true; } } } } else { $button = do_lang_tempcode('TOPIC_POLL_CLOSED'); } foreach ($_poll['answers'] as $answer) { if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) { $num_votes = $answer['num_votes']; $total_votes = $_poll['total_votes']; if ($total_votes != 0) { $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes))); } else { $width = 0; } $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } else { $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } $answers->attach($answer_tpl); } $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $vote_url = build_url($map, get_module_zone('topics')); if ($_poll['is_private']) { $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs'); } else { $private = new ocp_tempcode(); } if ($_poll['maximum_selections'] > 1) { $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs'); } else { $num_choices = new ocp_tempcode(); } $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections']))); } else { $poll = new ocp_tempcode(); } // Forum nav tree if (!is_null($topic_info['forum_id'])) { $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false); } else { $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); $tree->attach(do_template('BREADCRUMB_ESCAPED')); if (has_specific_permission(get_member(), 'view_other_pt')) { $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to']; } else { $of_member = get_member(); } $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member); if (is_null($of_username)) { $of_username = do_lang('UNKNOWN'); } $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); } // Quick reply if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) { $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_post_url = build_url($map, get_module_zone('topics')); $post_url = $_post_url->evaluate(); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $more_url = build_url($map, get_module_zone('topics')); $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode(); $first_post = $_postdetails; $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); $display = 'block'; $expand_type = 'contract'; if ($topic_info['max_rows'] > $start + $max) { $display = 'none'; $expand_type = 'expand'; } $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $post_warning = ''; if ($topic_info['is_really_threaded'] == 1) { $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning); } $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'))); } else { $quick_reply = new ocp_tempcode(); } $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics')); if (!is_null($id)) { // Moderation options $moderator_actions = ''; if (is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>'; } if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) { $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']); if (count($multi_moderations) != 0) { $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">'; foreach ($multi_moderations as $mm_id => $mm_name) { $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>'; } $moderator_actions .= '</optgroup>'; } } if (array_key_exists('may_move_topic', $topic_info)) { $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_topic', $topic_info)) { $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>'; } if (array_key_exists('may_delete_topic', $topic_info)) { $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>'; } if (array_key_exists('may_pin_topic', $topic_info)) { $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>'; } if (array_key_exists('may_unpin_topic', $topic_info)) { $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>'; } if (array_key_exists('may_sink_topic', $topic_info)) { $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>'; } if (array_key_exists('may_unsink_topic', $topic_info)) { $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>'; } if (array_key_exists('may_cascade_topic', $topic_info)) { $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_uncascade_topic', $topic_info)) { $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_open_topic', $topic_info)) { $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>'; } if (array_key_exists('may_close_topic', $topic_info)) { $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_poll', $topic_info)) { $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_delete_poll', $topic_info)) { $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_attach_poll', $topic_info)) { $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>'; } if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) { $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>'; } if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>'; } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } // Marked post actions $map = array('page' => 'topics', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics'), NULL, false, true); $marked_post_actions = ''; if (array_key_exists('may_move_posts', $topic_info)) { $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>'; $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>'; } if (array_key_exists('may_delete_posts', $topic_info)) { $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>'; } if (array_key_exists('may_validate_posts', $topic_info)) { $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>'; } if (get_value('disable_multi_quote') !== '1') { if ($may_reply) { $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>'; } } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($marked_post_actions); } } else { $moderator_actions = ''; $marked_post_actions = ''; } $max_rows = $topic_info['max_rows']; if ($max_rows > $max && !$threaded) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30)); } else { $results_browser = new ocp_tempcode(); } // Members viewing this topic $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true); $num_guests = 0; $num_members = 0; if (is_null($members)) { $members_viewing = new ocp_tempcode(); } else { $members_viewing = new ocp_tempcode(); foreach ($members as $member_id => $at_details) { $username = $at_details['mt_cache_username']; if (is_guest($member_id)) { $num_guests++; } else { $num_members++; $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username); if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) { $map['AT'] = escape_html($at_details['the_title']); } $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id)); $members_viewing->attach(do_template('OCF_USER_MEMBER', $map)); } } if ($members_viewing->is_empty()) { $members_viewing = do_lang_tempcode('NONE_EM'); } } if (!is_null($id)) { breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC')); } if (is_null($id)) { $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id())); $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO')); breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS')); } if ($topic_info['validated'] == 0) { $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded)); if (is_null($id)) { $title = get_page_title('INLINE_PERSONAL_POSTS'); } else { if (is_null($topic_info['forum_id'])) { $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC')); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('topic', strval($id)); } else { $awards = array(); } $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards); } } return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']); }
/** * Get tempcode for a download 'feature box' for the sgiven row * * @param array The database field row of this download * @param boolean Whether to show a picture * @param boolean Whether to show breadcrumbs * @param ?ID_TEXT The zone the download module we're using is in (NULL: find it) * @param ?string Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none) * @return tempcode A box for this download, linking to the full download page */ function get_download_html($row, $pic = true, $breadcrumbs = true, $zone = NULL, $text_summary = NULL) { require_css('downloads'); if (is_null($zone)) { $zone = get_module_zone('downloads'); } // Details $filesize = $row['file_size']; $filesize = $filesize > 0 ? clean_file_size($filesize) : do_lang('UNKNOWN'); $description = get_translated_tempcode($row['description']); $root = get_param_integer('root', db_get_first_id(), true); $download_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id'], 'root' => $root == db_get_first_id() ? NULL : $root), $zone); $date = get_timezoned_date($row['add_date'], false); $date_raw = $row['add_date']; $tree = get_option('show_dload_trees') == '1' && $breadcrumbs ? download_breadcrumbs($row['category_id'], NULL, false, $zone) : new ocp_tempcode(); $pic_suffix = ''; $thumb_url = ''; $full_img_url = ''; if (addon_installed('galleries') && $pic) { // Images $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url', 'id'), array('cat' => 'download_' . strval($row['id'])), '', 1, $row['default_pic'] - 1); if (array_key_exists(0, $rows)) { $pic_suffix = '_pic'; require_code('images'); $full_img_url = $rows[0]['url']; $thumb_url = ensure_thumbnail($rows[0]['url'], $rows[0]['thumb_url'], 'galleries', 'images', $rows[0]['id']); $imgcode = do_image_thumb($thumb_url, do_lang('DOWNLOAD_THUMBNAIL')); } else { $imgcode = new ocp_tempcode(); } } else { $imgcode = new ocp_tempcode(); } require_code('feedback'); $rating = $row['allow_rating'] == 1 ? display_rating($download_url, get_translated_text($row['name']), 'downloads', strval($row['id']), 'RATING_INLINE_STATIC', $row['submitter']) : NULL; if (!is_null($rating)) { if (trim($rating->evaluate()) == '') { $rating = NULL; } } $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $row['download_licence']; if (!is_null($licence)) { $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence)); if (!is_null($licence_title)) { $keep = symbol_tempcode('KEEP'); $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate(); $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license')); } else { $licence = NULL; // Orphaned } } // Final template if ($full_img_url != '' && url_is_local($full_img_url)) { $full_img_url = get_custom_base_url() . '/' . $full_img_url; } return do_template('DOWNLOAD_BOX', array('TEXT_SUMMARY' => $text_summary, 'AUTHOR' => $row['author'], 'ID' => strval($row['id']), 'RATING' => $rating, 'VIEWS' => integer_format($row['download_views']), 'SUBMITTER' => strval($row['submitter']), 'DESCRIPTION' => $description, 'FILE_SIZE' => $filesize, 'DOWNLOADS' => integer_format($row['num_downloads']), 'DATE_RAW' => strval($date_raw), 'DATE' => $date, 'EDIT_DATE_RAW' => is_null($row['edit_date']) ? '' : strval($row['edit_date']), 'SIZE' => $filesize, 'URL' => $download_url, 'NAME' => get_translated_text($row['name']), 'TREE' => $tree, 'IMG_URL' => $thumb_url, 'FULL_IMG_URL' => $full_img_url, 'IMGCODE' => $imgcode, 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink)); }
/** * Get a map of the fields for the given entry. * * @param array A database row of the entry we are working with * @param ?array A database row of the catalogue we are working with (NULL: read it in here) * @param ID_TEXT The view type we're doing * @set PAGE SEARCH CATEGORY * @param ID_TEXT The template set we are rendering this category using * @param ?AUTO_LINK The virtual root for display of this category (NULL: none) * @param ?array The database rows for the fields for this catalogue (NULL: find them) * @param ?array A list of fields that we are limiting ourselves to (NULL: get ALL fields) * @param boolean Whether to grab the feedback details * @param boolean Whether to grab the tree details * @param ?integer Field index to order by (NULL: none) * @return array A map of information relating to the entry. The map contains 'FIELDS' (tempcode for all accumulated fields), 'FIELD_x' (for each field x applying to the entry), STAFF_DETAILS, COMMENT_DETAILS, RATING_DETAILS, VIEW_URL, TREE (tempcode category tree to this entry) */ function get_catalogue_entry_map($entry, $catalogue, $view_type, $tpl_set, $root = NULL, $fields = NULL, $only_fields = NULL, $feedback_details = false, $tree_details = false, $order_by = NULL) { $id = $entry['id']; if (is_null($catalogue)) { $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $entry['c_name']), '', 1); if (!array_key_exists(0, $catalogue_rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $catalogue = $catalogue_rows[0]; } // Views if (get_db_type() != 'xml') { $entry['ce_views']++; } $catalogue_name = $catalogue['c_name']; $fields = get_catalogue_entry_field_values($catalogue_name, $entry, $only_fields, $fields, false, $view_type); $map = array(); $map['FIELDS'] = new ocp_tempcode(); $map['FIELDS_TABLE'] = new ocp_tempcode(); $map['fields'] = $fields; $fields_1d = array(); $fields_2d = array(); $all_visible = true; require_code('fields'); foreach ($fields as $i => $field) { if (!array_key_exists('effective_value', $field)) { $all_visible = false; continue; } $ev = $field['effective_value']; $dereference_ev = is_object($field['effective_value']) ? $field['effective_value']->evaluate() : $field['effective_value']; $use_ev = $dereference_ev; $ob = get_fields_hook($field['cf_type']); $use_ev = $ob->render_field_value($field, $ev, $i, $only_fields); if ($i == 0 && $catalogue['c_display_type'] == 1) { //$use_ev=hyperlink(build_url(array('page'=>'catalogues','type'=>'entry','id'=>$id,'root'=>$root),get_module_zone('catalogues')),$ev,false,!is_object($ev)); $use_ev = $ev; } //Set image thumbnail in to the map array if ($field['cf_type'] == 'picture') { if (!is_null($ev) && $dereference_ev != '') { require_code('images'); $map['FIELD_' . strval($i) . '_THUMB'] = do_image_thumb($dereference_ev, $i == 0 ? '' : (is_object($map['FIELD_0']) ? $map['FIELD_0']->evaluate() : $map['FIELD_0']), false, false, 100, 100); } else { $map['FIELD_' . strval($i) . '_THUMB'] = new ocp_tempcode(); } $map['_FIELD_' . strval($field['id']) . '_THUMB'] = $map['FIELD_' . strval($i) . '_THUMB']; } $map['FIELD_' . strval($i)] = $use_ev; $map['_FIELD_' . strval($field['id'])] = $use_ev; $map['FIELD_' . strval($i) . '_PLAIN'] = $ev; $map['_FIELD_' . strval($field['id']) . '_PLAIN'] = $ev; if (array_key_exists('effective_value_pure', $field)) { $map['FIELD_' . strval($i) . '_PURE'] = $field['effective_value_pure']; $map['_FIELD_' . strval($field['id']) . '_PURE'] = $field['effective_value_pure']; } $field_name = get_translated_text($field['cf_name']); $map['FIELDNAME_' . strval($i)] = $field_name; $fields_2d[] = array('NAME' => $field_name, 'VALUE' => $use_ev); $field_type = $field['cf_type']; $map['FIELDTYPE_' . strval($i)] = $field_type; if ($view_type == 'PAGE' || $field['cf_put_in_category'] == 1 && $view_type == 'CATEGORY' || $field['cf_put_in_search'] == 1 && $view_type == 'SEARCH') { $use_ev_enhanced = $use_ev; /*if (($view_type!='PAGE') && ($i==0) && (($field['cf_type']=='short_trans') || ($field['cf_type']=='short_text'))) { foreach ($fields as $field_temp) { if ((array_key_exists('effective_value',$field_temp)) && ($field_temp['cf_type']=='url') && (!((($field_temp['cf_put_in_category']==1) && ($view_type=='CATEGORY')) || (($field_temp['cf_put_in_search']==1) && ($view_type=='SEARCH')))) && ($field_temp['cf_visible']==1)) { if ($field_temp['effective_value']!='') { $use_ev_enhanced=hyperlink($field_temp['effective_value'],$use_ev,true); break; } } } }*/ if ($field['cf_visible'] == 1 || $i == 0) { $_field = do_template('CATALOGUE_' . $tpl_set . '_ENTRY_FIELD', array('ENTRYID' => strval($id), 'CATALOGUE' => $catalogue_name, 'TYPE' => $field['cf_type'], 'FIELD' => $field_name, 'FIELDID' => strval($i), '_FIELDID' => strval($field['id']), 'FIELDTYPE' => $field_type, 'VALUE_PLAIN' => $ev, 'VALUE' => $use_ev_enhanced), NULL, false, 'CATALOGUE_DEFAULT_ENTRY_FIELD'); if (!is_string($ev) || $ev != '') { $map['FIELDS']->attach($_field); } $_field = do_template('CATALOGUE_' . $tpl_set . '_TAB_FIELD', array('ENTRYID' => strval($id), 'CATALOGUE' => $catalogue_name, 'TYPE' => $field['cf_type'], 'FIELD' => $field_name, 'FIELDID' => strval($i), '_FIELDID' => strval($field['id']), 'FIELDTYPE' => $field_type, 'VALUE_PLAIN' => $ev, 'VALUE' => $use_ev_enhanced), NULL, false, 'CATALOGUE_DEFAULT_TAB_FIELD'); $map['FIELDS_TABLE']->attach($_field); } } else { $all_visible = false; } $fields_1d[] = $field; if (!($field['cf_visible'] == 1 || $i == 0 || $order_by === $i)) { $all_visible = false; } } $map['FIELDS_1D'] = $fields_1d; $map['FIELDS_2D'] = $fields_2d; // Admin functions if (has_actual_page_access(NULL, 'cms_catalogues', NULL, NULL) && has_edit_permission('mid', get_member(), $entry['ce_submitter'], 'cms_catalogues', array('catalogues_catalogue', $catalogue_name, 'catalogues_category', $entry['cc_id']))) { $map['EDIT_URL'] = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_entry', 'catalogue_name' => $catalogue_name, 'id' => $id), get_module_zone('cms_catalogues')); } else { $map['EDIT_URL'] = ''; } $map['SUBMITTER'] = strval($entry['ce_submitter']); $map['VIEWS'] = strval($entry['ce_views']); $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']); $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']); $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']); $map['EDIT_DATE'] = get_timezoned_date($entry['ce_edit_date']); $map['ID'] = strval($id); if (get_option('is_on_comments') == '1' && !has_no_forum() && $entry['allow_comments'] >= 1) { $map['COMMENT_COUNT'] = '1'; } // Feedback //Set basic rating display of item to the map array require_code('feedback'); $c_value = array_key_exists('FIELD_0_PLAIN_PURE', $map) ? $map['FIELD_0_PLAIN_PURE'] : $map['FIELD_0_PLAIN']; if (is_object($c_value)) { $c_value = $c_value->evaluate(); } $self_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id), get_module_zone('catalogues'), NULL, false, false, true); if ($feedback_details || $only_fields !== array(0)) { $map['RATING'] = $entry['allow_rating'] == 1 ? display_rating($self_url, $c_value, 'catalogues__' . $catalogue_name, strval($id), 'RATING_INLINE_STATIC', $entry['ce_submitter']) : new ocp_tempcode(); } if ($feedback_details) { list($map['RATING_DETAILS'], $map['COMMENT_DETAILS'], $map['TRACKBACK_DETAILS']) = embed_feedback_systems('catalogues__' . $catalogue_name, strval($id), $entry['allow_rating'], $entry['allow_comments'], $entry['allow_trackbacks'], $entry['ce_validated'], $entry['ce_submitter'], $self_url, $c_value, get_value('comment_forum__catalogues__' . $catalogue_name)); } if (get_option('is_on_comments') == '1' && $entry['allow_comments'] >= 1 || get_option('is_on_rating') == '1' && $entry['allow_rating'] == 1 || get_option('is_on_trackbacks') == '1' && $entry['allow_trackbacks'] == 1 || !$all_visible) { $map['VIEW_URL'] = $tpl_set == 'WML' ? make_string_tempcode('wap.php?page=catalogues&type=entry&id=' . strval($id)) : build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id, 'root' => $root == -1 ? NULL : $root), get_module_zone('catalogues')); } else { $map['VIEW_URL'] = ''; } if ($tree_details) { $map['TREE'] = ''; if ($catalogue['c_is_tree'] == 1 && is_null($only_fields)) { $tree = catalogue_category_breadcrumbs($entry['cc_id'], $root, false); $map['TREE'] = $tree; } } $map['CATALOGUE'] = $catalogue_name; $map['CAT'] = strval($entry['cc_id']); return $map; }
$context =context_user::instance($file->usermodified); $systemcontext =context_system::instance($file->usermodified); echo '<table class="maintable">'; if (has_capability('local/collegestructure:manage', $systemcontext, $file->usermodified) && is_siteadmin($file->usermodified)) echo '<tr><td class="rowtitle" colspan="3">Admin Generated Content</td></tr>'; else if (has_capability('local/collegestructure:manage', $systemcontext, $file->usermodified) && !is_siteadmin($file->usermodified)) echo '<tr><td class="rowtitle" colspan="3">Registrar Generated Content</td></tr>'; else if (has_capability('local/clclasses:enrollclass', $context, $file->usermodified) && !is_siteadmin($file->usermodified)) echo '<tr><td class="rowtitle" colspan="3">Student Generated Content</td></tr>'; else { if (has_capability('local/clclasses:submitgrades', $systemcontext, $file->usermodified) && !is_siteadmin($file->usermodified)) echo'<tr><td class="rowtitle" colspan="3">Faculty Uploaded Content</td></tr>'; } echo '<tr><td class="rowname" colspan="3"><a href="download.php?id=' . $file->id . '&course=' . $id . '">' . $file->title . '</a></td></td></tr>'; echo '<tr><td class="rowusername" colspan="3">by ' . $DB->get_field('user', 'firstname', array('id' => $file->usermodified)) . ' ' . $DB->get_field('user', 'lastname', array('id' => $file->usermodified)) . ' ' . date('l, d F Y, g:i A', $file->timecreated) . '</td></td></tr>'; echo '<tr><td class="rowintro" colspan="3">' . $file->description . '</td></tr>'; echo '<tr><td class="rowrating" id="rate' . $file->id . '". colspan="3">' . get_like_comment_rating($id, $file->id, $file->id) . '</td></tr>'; $a = display_like_unlike($id, $file->id, $file->id, 'Resource Central'); $b = display_rating($id, $file->id, $file->id, 'Resource Central', 'Rating'); $c = display_comment_area($id, $file->id, $file->id, 'Resource Central'); echo '<tr><td>' . $a . '</td><td>' . $b . '</td><td>' . $c . '</td></tr>'; echo '</table>'; } } } echo '<div id="myratings"></div>'; echo $OUTPUT->footer();
$topics = $DB->get_records_sql("select * from {local_townhall_topic} where courseid=$id and publish=1 limit $start2, $per_page2"); $course_name = $DB->get_field('course', 'fullname', array(id => $id)); echo '<h3>' . get_string('topics', 'local_townhall') . '</h3><hr>'; if (empty($topics)) { echo get_string('notopics', 'local_townhall'); } foreach ($topics as $topic) { $content = preg_replace("/<img[^>]+\>/i", "", $topic->description); preg_match('/(<img[^>]+>)/i', $topic->description, $matches); echo '<div class="town_list_bar">'; if ((count($matches)) == 0) { echo '<div class="town_topic_task_list1"><span>' . addslashes($topic->topic) . '</span><span>' . $content . '<span></div>'; } else { echo ' <div class="town_topic_task_list2"><span><font>' . addslashes($topic->topic) . '</font>' . $content . '</span><span>' . $matches[0] . '</span> </div>'; } echo '<div class="town_topic_ratings"> <div class="town_likes">' . display_like_unlike($id, 0, $topic->id, townhall) . '</div> <div class="town_rates">' . display_rating($id, 0, $topic->id, townhall, $course_name) . '</div> <div class="town_commnets">' . display_comment_area($id, 0, $topic->id, townhall) . '</div> </div> </div>'; } echo '<div id="myratings"></div>'; //$baseurl2 = new moodle_url('/local/townhall/view.php?id='.$id.''); $pagevar2 = 'mypage2'; echo '<div class="paging_bar">'; echo $OUTPUT->paging_bar($count2, $page2, $per_page2, $baseurl, $pagevar2); echo '</div>'; echo $OUTPUT->footer(); ?>
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_css('galleries'); require_lang('galleries'); require_code('galleries'); require_code('images'); require_code('feedback'); require_code('ocfiltering'); $cat = array_key_exists('param', $map) ? $map['param'] : 'root'; $cat_select = ocfilter_to_sqlfragment($cat, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); $title = array_key_exists('title', $map) ? $map['title'] : ''; /*if ((file_exists(get_custom_file_base().'/themes/default/templates_custom/JAVASCRIPT_GALLERIES.tpl')) || (file_exists(get_file_base().'/themes/default/templates/JAVASCRIPT_GALLERIES.tpl'))) require_javascript('javascript_galleries');*/ $max = get_param_integer('mge_max', array_key_exists('max', $map) ? intval($map['max']) : 30); $start = get_param_integer('mge_start', 0); if (!array_key_exists('select', $map)) { $map['select'] = '*'; } $image_select = ocfilter_to_sqlfragment($map['select'], 'id'); if (!array_key_exists('video_select', $map)) { $map['video_select'] = '*'; } $video_select = ocfilter_to_sqlfragment($map['video_select'], 'id'); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries'); $_days = array_key_exists('days', $map) ? $map['days'] : ''; $days = mixed(); $days = $_days == '' ? NULL : intval($_days); $where_sup = ''; if (!is_null($days)) { $where_sup .= ' AND add_date>=' . strval(time() - $days * 60 * 60 * 24); } $sort = array_key_exists('sort', $map) ? $map['sort'] : 'add_date DESC'; if ($sort != 'random ASC' && $sort != 'fixed_random ASC' && $sort != 'compound_rating DESC' && $sort != 'compound_rating ASC' && $sort != 'add_date DESC' && $sort != 'add_date ASC' && $sort != 'url DESC' && $sort != 'url ASC') { $sort = 'add_date DESC'; } list($_sort, $_dir) = explode(' ', $sort, 2); $total_images = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'images WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup); $total_videos = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'videos WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup); if ($_sort == 'random') { $start = 0; $max = min($total_images + $total_videos, $max); $done_images = '1=1'; $done_videos = '1=1'; $rows_images = array(); $rows_videos = array(); for ($i = 0; $i < $max; $i++) { if (mt_rand(0, 1) == 0 || $total_videos - count($rows_videos) == 0) { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' AND ' . $done_images, 1, mt_rand(0, $total_images - count($rows_images) - 1)); $rows_images[] = $rows[0]; $done_images .= ' AND '; $done_images .= 'id<>' . strval($rows[0]['id']); } else { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' AND ' . $done_videos, 1, mt_rand(0, $total_videos - count($rows_videos) - 1)); $rows_videos[] = $rows[0]; $done_videos .= ' AND '; $done_videos .= 'id<>' . strval($rows[0]['id']); } } } else { if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'images') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_images = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); if ($_sort == 'compound_rating') { $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'videos') . ' AND rating_for_id=e.id) AS compound_rating'; } elseif ($_sort == 'fixed_random') { $rating_sort = ',(MOD(id,3.142)) AS fixed_random'; } else { $rating_sort = ''; } $rows_videos = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' ORDER BY ' . $sort, $max + $start); } // Sort $combined = array(); foreach ($rows_images as $row_image) { $combined[] = array($row_image, 'image', $_sort == 'random' ? NULL : $row_image[$_sort]); } foreach ($rows_videos as $row_video) { $combined[] = array($row_video, 'video', $_sort == 'random' ? NULL : $row_video[$_sort]); } if ($_sort == 'random') { shuffle($combined); } else { global $M_SORT_KEY; $M_SORT_KEY = 2; usort($combined, 'multi_sort'); if ($_dir == 'DESC') { $combined = array_reverse($combined); } } // Display $entries = new ocp_tempcode(); foreach ($combined as $i => $c) { if ($i >= $start) { switch ($c[1]) { case 'image': // Display image $row_image = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'image', 'wide' => 1, 'id' => $row_image['id']), $zone); $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']); $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_image['url']; $file_size = url_is_local($full_url) ? file_exists(get_custom_file_base() . '/' . rawurldecode($full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($full_url))) : '' : ''; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_image['thumb_url']; if (url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL; $entry_map = array('_GUID' => '043ac7d15ce02715ac02309f6e8340ff', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'ID' => strval($row_image['id']), 'FILE_SIZE' => $file_size, 'SUBMITTER' => strval($row_image['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date'])); $entry = do_template('GALLERY_IMAGE', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => '13134830e1ebea158ab44885eeec0953', 'ENTRY' => $entry) + $entry_map)); break; case 'video': // Display video $row_video = $c[0]; $view_url = build_url(array('page' => 'galleries', 'type' => 'video', 'wide' => 1, 'id' => $row_video['id']), $zone); $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } if ($thumb_url == '') { $thumb_url = find_theme_image('na'); } $thumb = do_image_thumb($thumb_url, '', true); $full_url = $row_video['url']; if (url_is_local($full_url)) { $full_url = get_custom_base_url() . '/' . $full_url; } $thumb_url = $row_video['thumb_url']; if ($thumb_url != '' && url_is_local($thumb_url)) { $thumb_url = get_custom_base_url() . '/' . $thumb_url; } $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL; $entry_map = array('_GUID' => '66b7fb4d3b61ef79d6803c170d102cbf', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'ID' => strval($row_video['id']), 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'SUBMITTER' => strval($row_video['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'VIDEO_DETAILS' => show_video_details($row_video), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date'])); $entry = do_template('GALLERY_VIDEO', $entry_map); $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'a0ff010ae7fd1f7b3341993072ed23cf', 'ENTRY' => $entry) + $entry_map)); break; } } $i++; if ($i == $start + $max) { break; } } if (!isset($map['render_if_empty']) || $map['render_if_empty'] != '1') { if ($entries->is_empty()) { 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_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $cat, 'redirect' => SELF_REDIRECT), get_module_zone('cms_galleries')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'bf84d65b8dd134ba6cd7b1b7bde99de2', 'HIGH' => false, 'TITLE' => do_lang_tempcode('GALLERY'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IMAGE'), 'SUBMIT_URL' => $submit_url)); } } // Results browser require_code('templates_results_browser'); $_selectors = array_map('intval', explode(',', get_option('gallery_selectors'))); $root = get_param('root', 'root'); $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'mge_start', $max, 'mge_max', $total_videos + $total_images, $root, 'misc', true, false, 10, $_selectors); $tpl = do_template('BLOCK_MAIN_GALLERY_EMBED', array('_GUID' => 'b7b969c8fe8c398dd6e3af7ee06717ea', 'IMAGE_SELECT' => $map['select'], 'VIDEO_SELECT' => $map['video_select'], 'DAYS' => $_days, 'SORT' => $sort, 'BLOCK_PARAMS' => block_params_arr_to_str($map), 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CAT' => $cat, 'IMAGES' => $entries, 'MAX' => strval($max), 'ZONE' => $zone, 'TOTAL_VIDEOS' => strval($total_videos), 'TOTAL_IMAGES' => strval($total_images), 'TOTAL' => strval($total_videos + $total_images))); return $tpl; }