/** * Standard modular run function for award hooks. Renders a content box for an award/randomisation. * * @param array The database row for the content * @param ID_TEXT The zone to display in * @return tempcode Results */ function run($row, $zone) { $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), $zone); $title = get_translated_tempcode($row['title']); $title_plain = get_translated_text($row['title']); $news_cat_rows = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title', 'nc_img'), array('id' => $row['news_category']), '', 1); if (!array_key_exists(0, $news_cat_rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $news_cat_row = $news_cat_rows[0]; $category = get_translated_text($news_cat_row['nc_title']); $img = find_theme_image($news_cat_row['nc_img']); if ($row['news_image'] != '') { $img = $row['news_image']; if (url_is_local($img)) { $img = get_base_url() . '/' . $img; } } $news = get_translated_tempcode($row['news']); if ($news->is_empty()) { $news = get_translated_tempcode($row['news_article']); $truncate = true; } else { $truncate = false; } $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $row['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $row['author']; require_css('news'); $seo_bits = seo_meta_get_for('news', strval($row['id'])); $map = array('_GUID' => 'jd89f893jlkj9832gr3uyg2u', 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'AUTHOR' => $author, 'BLOG' => false, 'AUTHOR_URL' => $author_url, 'CATEGORY' => $category, 'IMG' => $img, 'NEWS' => $news, 'ID' => strval($row['id']), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'FULL_URL' => $url, 'NEWS_TITLE' => $title, 'NEWS_TITLE_PLAIN' => $title_plain); if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) { $map['COMMENT_COUNT'] = '1'; } return put_in_standard_box(do_template('NEWS_PIECE_SUMMARY', $map)); }
/** * 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)); }
/** * The UI to view a download. * * @return tempcode The UI */ function dloadinfo_screen() { $id = get_param_integer('id'); $root = get_param_integer('root', db_get_first_id(), true); // Basic Init $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']); if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { access_denied('CATEGORY_ACCESS'); } $name = get_translated_text($myrow['name']); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads')); // Views if (get_db_type() != 'xml') { $myrow['download_views']++; $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true); } // Tree $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name()); $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name)); $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('download', strval($id)); } else { $awards = array(); } $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('downloads_download', strval($id), $title_to_use_2); $warning_details = new ocp_tempcode(); // Validation if ($myrow['validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')))); } // Cost warning if ($myrow['download_cost'] != 0 && addon_installed('points')) { require_lang('points'); $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost']))))); } // Admin functions $edit_url = new ocp_tempcode(); $add_img_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) { $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads')); } if (addon_installed('galleries')) { if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { require_lang('galleries'); $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries')); } } // Outmoding if (!is_null($myrow['out_mode_id'])) { $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF'); } else { $outmode_url = new ocp_tempcode(); } // Stats $add_date = get_timezoned_date($myrow['add_date'], false); // Additional information $additional_details = get_translated_tempcode($myrow['comments']); // Edit date if (!is_null($myrow['edit_date'])) { $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false)); } else { $edit_date = new ocp_tempcode(); } $images_details = new ocp_tempcode(); $image_url = ''; $counter = 0; if (addon_installed('galleries')) { // Images require_lang('galleries'); $cat = 'download_' . strval($id); $map = array('cat' => $cat); if (!has_specific_permission(get_member(), 'see_unvalidated')) { $map['validated'] = 1; } $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200); $div = 2; $_out = new ocp_tempcode(); $_row = new ocp_tempcode(); require_code('images'); while (array_key_exists($counter, $rows)) { $row = $rows[$counter]; // $view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries')); $view_url = $row['url']; if ($image_url == '') { $image_url = $row['url']; } if (url_is_local($view_url)) { $view_url = get_custom_base_url() . '/' . $view_url; } $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']); $comment = get_translated_tempcode($row['comments']); $thumb = do_image_thumb($thumb_url, ''); if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) { $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries')); } else { $iedit_url = new ocp_tempcode(); } $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment)); $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content))); if ($counter % $div == 1 && $counter != 0) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row))); $_row = new ocp_tempcode(); } $counter++; } if (!$_row->is_empty()) { $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row))); } $images_details = $_out; } // Download link $author = $myrow['author']; $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode(); // Licence $licence_title = NULL; $licence_url = NULL; $licence_hyperlink = NULL; $licence = $myrow['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 } } breadcrumb_add_segment($tree, $title_to_use); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url); return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details)); }
/** * Display a catalogue entry * * @param AUTO_LINK Entry ID * @param boolean Whether to skip rendering a title * @return tempcode Tempcode interface to display an entry */ function render_catalogue_entry_screen($id, $no_title = false) { require_code('feedback'); if (addon_installed('ecommerce')) { require_code('ecommerce'); } require_code('images'); require_css('catalogues'); require_lang('catalogues'); $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $entries)) { return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE')); } $entry = $entries[0]; $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $entry['cc_id']), '', 1); if (!array_key_exists(0, $categories)) { warn_exit(do_lang_tempcode('CAT_NOT_FOUND', strval($entry['cc_id']))); } $category = $categories[0]; $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($entry['cc_id']); $catalogue_name = $category['c_name']; $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1); if (!array_key_exists(0, $catalogues)) { warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name)); } $catalogue = $catalogues[0]; // Permission for here? if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) { access_denied('CATALOGUE_ACCESS'); } if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($entry['cc_id']))) { access_denied('CATEGORY_ACCESS'); } $ecommerce = is_ecommerce_catalogue($catalogue_name); if ($ecommerce) { $tpl_set = 'products'; } else { $tpl_set = $catalogue_name; } $root = get_param_integer('root', NULL); $map = get_catalogue_entry_map($entry, $catalogue, 'PAGE', $tpl_set, $root, NULL, NULL, true, true); if (get_db_type() != 'xml') { $entry['ce_views']++; $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views' => $entry['ce_views']), array('id' => $id), '', 1, NULL, false, true); } // Validation if ($entry['ce_validated'] == 0) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $map['WARNINGS'] = do_template('WARNING_TABLE', array('_GUID' => 'bf604859a572ca53e969bec3d91f9cfb', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $map['WARNINGS'] = ''; } //Finding any hook exists for this product-------------------- if (addon_installed('ecommerce')) { $object = find_product(strval($id)); if (is_object($object) && method_exists($object, 'get_custom_product_map_fields')) { $object->get_custom_product_map_fields($id, $map); } } //------------------------------------------------------------ $map['ENTRY'] = do_template('CATALOGUE_' . $tpl_set . '_ENTRY', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY'); $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']); $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']); $map['EDIT_DATE'] = is_null($entry['ce_edit_date']) ? '' : get_timezoned_date($entry['ce_edit_date']); $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']); $map['VIEWS'] = integer_format($entry['ce_views']); $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN'], NULL, NULL, NULL, false); if (is_null($title_to_use_2)) { $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0']); $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN']); } if ($no_title) { $map['TITLE'] = new ocp_tempcode(); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('catalogue_entry', strval($id)); } else { $awards = array(); } $map['TITLE'] = get_page_title($title_to_use, false, NULL, NULL, $awards); } $map['SUBMITTER'] = strval($entry['ce_submitter']); require_code('seo2'); if (is_object($title_to_use_2)) { $title_to_use_2 = $title_to_use_2->evaluate(); } seo_meta_load_for('catalogue_entry', strval($id), strip_tags($title_to_use_2)); if ($map['TREE'] === '') { $map['TREE'] = new ocp_tempcode(); $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($catalogue['c_title'])), false, false, do_lang('INDEX'))); $map['TREE']->attach(do_template('BREADCRUMB_ESCAPED')); $url = build_url(array('page' => '_SELF', 'type' => 'category', 'id' => $category['id']), '_SELF'); $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($category['cc_title'])), false, false, do_lang('GO_BACKWARDS_TO', get_translated_text($category['cc_title'])), NULL, NULL, 'up')); } $map['CATEGORY_TITLE'] = get_translated_text($category['cc_title']); $map['CAT'] = strval($entry['cc_id']); $map['TAGS'] = get_loaded_tags('catalogue_entries'); breadcrumb_add_segment($map['TREE'], $title_to_use); if (is_null($root)) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES')))); } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $entry['ce_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($entry['ce_submitter']), 'publisher' => '', 'modified' => is_null($entry['ce_edit_date']) ? '' : date('Y-m-d', $entry['ce_edit_date']), 'type' => get_translated_text($catalogue['c_title']) . ' entry', 'title' => comcode_escape($title_to_use_2), 'identifier' => '_SEARCH:catalogues:entry:' . strval($id), 'description' => ''); return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_SCREEN', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_SCREEN'); }
/** * The UI for doing a quiz. * * @return tempcode The result of execution. */ function do_quiz() { $id = get_param_integer('id'); $quizzes = $GLOBALS['SITE_DB']->query_select('quizzes', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $quizzes)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $quiz = $quizzes[0]; $this->enforcement_checks($quiz); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('quiz', strval($id)); } else { $awards = array(); } $quiz_name = get_translated_text($quiz['q_name']); $title_to_use = do_lang_tempcode('THIS_WITH', do_lang_tempcode($quiz['q_type']), make_string_tempcode(escape_html($quiz_name))); $title_to_use_2 = do_lang('THIS_WITH_SIMPLE', do_lang($quiz['q_type']), $quiz_name); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('quiz', strval($id), $title_to_use_2); $last_visit_time = $GLOBALS['SITE_DB']->query_value_null_ok('quiz_member_last_visit', 'v_time', array('v_quiz_id' => $id, 'v_member_id' => get_member()), 'ORDER BY v_time DESC'); if (!is_null($last_visit_time)) { $timer_offset = time() - $last_visit_time; if (is_null($quiz['q_timeout']) || $timer_offset >= $quiz['q_timeout'] * 60) { $GLOBALS['SITE_DB']->query_delete('quiz_member_last_visit', array('v_member_id' => get_member(), 'v_quiz_id' => $id)); $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member())); $timer_offset = 0; } } else { $GLOBALS['SITE_DB']->query_insert('quiz_member_last_visit', array('v_quiz_id' => $id, 'v_time' => time(), 'v_member_id' => get_member())); $timer_offset = 0; } $questions = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY q_order'); // If a test/quiz, randomly order questions // if ($quiz['q_type']!='SURVEY') shuffle($questions); No, could cause problems foreach ($questions as $i => $question) { $answers = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $question['id']), 'ORDER BY q_order'); // If a test/quiz, randomly order answers if ($quiz['q_type'] != 'SURVEY') { shuffle($answers); } $questions[$i]['answers'] = $answers; } require_code('quiz'); $fields = render_quiz($questions); breadcrumb_set_self(make_string_tempcode(escape_html(get_translated_text($quiz['q_name'])))); // Validation if ($quiz['q_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('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $type = 'Quiz'; switch ($quiz['q_type']) { case 'COMPETITION': $type = 'Competition'; break; case 'SURVEY': $type = 'Survey'; break; case 'TEST': $type = 'Test'; break; } $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $quiz['q_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($quiz['q_submitter']), 'publisher' => '', 'modified' => '', 'type' => $type, 'title' => get_translated_text($quiz['q_name']), 'identifier' => '_SEARCH:quiz:do:' . strval($id), 'description' => get_translated_text($quiz['q_start_text']), 'image' => find_theme_image('bigicons/quiz')); $edit_url = new ocp_tempcode(); if (has_actual_page_access(NULL, 'cms_quiz', NULL, NULL) && has_edit_permission('mid', get_member(), $quiz['q_submitter'], 'cms_quiz', array('quiz', $id))) { $edit_url = build_url(array('page' => 'cms_quiz', 'type' => '_ed', 'id' => $id), get_module_zone('cms_quiz')); } // Display UI: start text, questions. Including timeout $start_text = get_translated_tempcode($quiz['q_start_text']); $post_url = build_url(array('page' => '_SELF', 'type' => '_do', 'id' => $id), '_SELF'); return do_template('QUIZ_SCREEN', array('_GUID' => 'f390877672938ba62f79f9528bef742f', 'EDIT_URL' => $edit_url, 'TAGS' => get_loaded_tags('quiz'), 'ID' => strval($id), 'WARNING_DETAILS' => $warning_details, 'URL' => $post_url, 'TITLE' => $title, 'START_TEXT' => $start_text, 'FIELDS' => $fields, 'TIMEOUT' => is_null($quiz['q_timeout']) ? '' : strval($quiz['q_timeout'] * 60 - $timer_offset))); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { require_lang('news'); $title = do_lang_tempcode('BLOG'); $order = 50; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_css('news'); $max_rows = 0; $max = get_param_integer('blogs_max', 5); $start = get_param_integer('blogs_start', 0); // Show recent blog posts $recent_blog_posts = new ocp_tempcode(); $rss_url = new ocp_tempcode(); $news_cat = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => $member_id_of), '', 1); if (array_key_exists(0, $news_cat) && has_category_access($member_id_viewing, 'news', strval($news_cat[0]['id']))) { $rss_url = make_string_tempcode(find_script('backend') . '?type=rss2&mode=news&filter=' . strval($news_cat[0]['id'])); // How many results? (not 100% accurate, if a news item is in a primary cat and same secondary cat) $max_rows += $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)', array('news_category' => $news_cat[0]['id'])); $max_rows += $GLOBALS['SITE_DB']->query_value('news n LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries c ON n.id=c.news_entry', 'COUNT(*)', array('news_category' => $news_cat[0]['id'])); // Fetch and sort $news1 = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('news_category' => $news_cat[0]['id']), 'ORDER BY date_and_time DESC', $max + $start); $news2 = $GLOBALS['SITE_DB']->query_select('news n LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries c ON n.id=c.news_entry', array('n.*'), array('news_category' => $news_cat[0]['id']), 'ORDER BY date_and_time DESC', $max + $start); $news = array(); foreach ($news1 as $row) { $news[$row['id']] = $row; } foreach ($news2 as $row) { $news[$row['id']] = $row; } unset($news1); unset($news2); global $M_SORT_KEY; $M_SORT_KEY = 'date_and_time'; usort($news, 'multi_sort'); $news = array_reverse($news); // Output $done = 0; foreach ($news as $i => $myrow) { if ($i < $start) { continue; } if ($done == $max) { break; } $news_id = $myrow['id']; $news_date = get_timezoned_date($myrow['date_and_time']); $author_url = ''; $author = $myrow['author']; $news_title = get_translated_tempcode($myrow['title']); $news_summary = get_translated_tempcode($myrow['news']); if ($news_summary->is_empty()) { $news_summary = get_translated_tempcode($myrow['news_article']); $truncate = true; } else { $truncate = false; } $news_full_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $news_id, 'filter' => $news_cat[0]['id'], 'blog' => 1), get_module_zone('news')); $news_img = find_theme_image($news_cat[0]['nc_img']); if (is_null($news_img)) { $news_img = ''; } if ($myrow['news_image'] != '') { $news_img = $myrow['news_image']; if (url_is_local($news_img)) { $news_img = get_custom_base_url() . '/' . $news_img; } } $news_category = get_translated_text($news_cat[0]['nc_title']); $seo_bits = seo_meta_get_for('news', strval($news_id)); $map2 = array('TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'BLOG' => false, 'ID' => strval($news_id), 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $news_category, 'IMG' => $news_img, 'DATE' => $news_date, 'DATE_RAW' => strval($myrow['date_and_time']), 'NEWS_TITLE' => $news_title, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS' => $news_summary, 'FULL_URL' => $news_full_url); if (get_option('is_on_comments') == '1' && !has_no_forum() && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } $recent_blog_posts->attach(do_template('NEWS_PIECE_SUMMARY', $map2)); $done++; } } // Add link if ($member_id_of == $member_id_viewing) { $add_blog_post_url = build_url(array('page' => 'cms_blogs', 'type' => 'ad'), get_module_zone('cms_blogs')); } else { $add_blog_post_url = new ocp_tempcode(); } // Pagination require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('BLOGS_POSTS'), NULL, $start, 'blogs_start', $max, 'blogs_max', $max_rows, NULL, 'view', true, false, 7, NULL, 'tab__blog'); // Wrap it all up $content = do_template('OCF_MEMBER_PROFILE_BLOG', array('RESULTS_BROWSER' => $results_browser, 'RSS_URL' => $rss_url, 'ADD_BLOG_POST_URL' => $add_blog_post_url, 'MEMBER_ID' => strval($member_id_of), 'RECENT_BLOG_POSTS' => $recent_blog_posts)); return array($title, $content, $order); }
/** * View an event. * * @return tempcode The UI */ function view_event() { check_specific_permission('view_calendar'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'back'; $id = get_param_integer('id'); $filter = $this->get_filter(); $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=calendar&filter=' . implode(',', $this->get_and_filter()); $rows = $GLOBALS['SITE_DB']->query_select('calendar_events e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'calendar_types t ON t.id=e.e_type', array('*'), array('e.id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $event = $rows[0]; if ($event['e_is_public'] == 0) { enforce_personal_access($event['e_submitter'], 'view_personal_events'); } if (!has_category_access(get_member(), 'calendar', strval($event['e_type']))) { access_denied('CATEGORY_ACCESS'); } // Validation $warning_details = new ocp_tempcode(); if ($event['validated'] == 0 && $event['e_is_public'] == 1) { if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '332faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')))); } if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('event', strval($id)); } else { $awards = array(); } $_title = get_translated_text($event['e_title']); $title_to_use = do_lang_tempcode('CALENDAR_EVENT_VCAL', escape_html($_title)); $title_to_use_2 = do_lang('CALENDAR_EVENT', $_title); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('event', strval($id), $title_to_use_2); $content = $event['e_type'] == db_get_first_id() ? make_string_tempcode(get_translated_text($event['e_content'])) : get_translated_tempcode($event['e_content']); $type = get_translated_text($event['t_title']); $subscribed = new ocp_tempcode(); if (has_specific_permission(get_member(), 'view_event_subscriptions') && cron_installed()) { $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('DISTINCT n_member_id'), array('e_id' => $id), '', 100); if (count($subscriptions) < 100) { foreach ($subscriptions as $subscription) { $username = $GLOBALS['FORUM_DRIVER']->get_username($subscription['n_member_id']); if (!is_null($username)) { $member_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($subscription['n_member_id'], false, true); $subscribed->attach(do_template('CALENDAR_SCREEN_SUBSCRIPTION', array('_GUID' => 'c756b8b3f0c57494fd46a94e9abce029', 'MEMBER_URL' => $member_url, 'USERNAME' => $username))); } } } } $__first_date = mktime($event['e_start_hour'], $event['e_start_minute'], 0, $event['e_start_month'], $event['e_start_day'], $event['e_start_year']); $_first_date = cal_utctime_to_usertime($__first_date, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $first_date = date('Y-m-d', $_first_date); $date = get_param('date', $first_date); // It's year 10,000 compliant when it comes to year display ;). $back_type = get_param('back', 'day'); $map = array_merge($filter, array('page' => '_SELF', 'type' => 'misc', 'view' => $back_type, 'id' => $date)); if (get_param_integer('member_id', get_member()) != get_member()) { $map['member_id'] = get_param_integer('member_id'); } $back_url = build_url($map, '_SELF'); list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('events', strval($id) . ($event['e_seg_recurrences'] == 1 ? '_' . $date : ''), $event['allow_rating'], $event['allow_comments'], $event['allow_trackbacks'], get_option('is_on_strong_forum_tie') == '0' || $event['e_is_public'] == 1 ? 1 : 0, $event['e_submitter'], build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF', NULL, false, false, true), $_title, get_value('comment_forum__calendar')); $_subscriptions = new ocp_tempcode(); if (is_guest() || !cron_installed()) { $subscribe_url = new ocp_tempcode(); } else { $subscriptions = $GLOBALS['SITE_DB']->query_select('calendar_reminders', array('id', 'n_seconds_before'), array('e_id' => $id, 'n_member_id' => get_member())); foreach ($subscriptions as $subscription) { $time = display_time_period(intval($subscription['n_seconds_before'])); $unsubscribe_url = build_url(array('page' => '_SELF', 'type' => 'unsubscribe_event', 'id' => $id, 'reminder_id' => $subscription['id']), '_SELF'); $_subscriptions->attach(do_template('CALENDAR_SCREEN_PERSONAL_SUBSCRIPTION', array('_GUID' => 'cc36c75ea516abfab1c65328c0e290fc', 'UNSUBSCRIBE_URL' => $unsubscribe_url, 'TIME' => $time))); } $subscribe_url = build_url(array('page' => '_SELF', 'type' => 'subscribe_event', 'id' => $id), '_SELF'); } if (has_actual_page_access(NULL, 'cms_calendar', NULL, NULL) && has_edit_permission($event['e_is_public'] == 0 ? 'low' : 'mid', get_member(), $event['e_submitter'], 'cms_calendar', array('calendar', $event['e_type']))) { $edit_url = build_url(array('page' => 'cms_calendar', 'type' => '_ed', 'id' => $id), get_module_zone('cms_calendar')); } else { $edit_url = new ocp_tempcode(); } if ($event['e_seg_recurrences'] == 0) { $NON_CANONICAL_PARAMS[] = 'day'; $NON_CANONICAL_PARAMS[] = 'date'; } $day = get_param('day', ''); if ($day != '') { $explode = explode('-', $day); if (count($explode) == 3) { if (is_null($event['e_start_hour'])) { if (is_null($event['e_end_year']) || is_null($event['e_end_month']) || is_null($event['e_end_day'])) { $event['e_end_day'] = $event['e_start_day']; $event['e_end_month'] = $event['e_start_month']; $event['e_end_year'] = $event['e_start_year']; } } if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) { $event['e_end_year'] += intval($explode[0]) - $event['e_start_year']; $event['e_end_month'] += intval($explode[1]) - $event['e_start_month']; $event['e_end_day'] += intval($explode[2]) - $event['e_start_day']; } $event['e_start_year'] = intval($explode[0]); $event['e_start_month'] = intval($explode[1]); $event['e_start_day'] = intval($explode[2]); } } $time_raw = cal_get_start_utctime_for_event($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], $event['e_start_hour'], $event['e_start_minute'], $event['e_do_timezone_conv'] == 1); $from = cal_utctime_to_usertime($time_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $day_formatted = locale_filter(date(do_lang('calendar_date'), $from)); if (!is_null($event['e_end_year']) && !is_null($event['e_end_month']) && !is_null($event['e_end_day'])) { $to_raw = cal_get_end_utctime_for_event($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], $event['e_end_hour'], $event['e_end_minute'], $event['e_do_timezone_conv'] == 1); $to = cal_utctime_to_usertime($to_raw, $event['e_timezone'], $event['e_do_timezone_conv'] == 1); $to_day_formatted = locale_filter(date(do_lang('calendar_date'), $to)); $time2 = date_range($from, $to, !is_null($event['e_start_hour'])); } else { $to_raw = NULL; $time2 = is_null($event['e_start_hour']) ? '' : locale_filter(my_strftime(do_lang('calendar_minute'), $from)); $to = NULL; $to_day_formatted = NULL; } $priority = $event['e_priority']; $is_public = $event['e_is_public'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'); $recurrence = do_lang_tempcode('NA_EM'); if ($event['e_recurrence'] != 'none' && $event['e_recurrence'] != '') { $l_code = explode(' ', strtoupper($event['e_recurrence'])); $recurrence = do_lang_tempcode($l_code[0]); if (!is_null($event['e_recurrences'])) { $recurrence = do_lang_tempcode('RECURRENCE_ITERATION', $recurrence, make_string_tempcode(integer_format($event['e_recurrences']))); } } elseif ($day == '') { $day = $first_date; } $priority_lang = do_lang_tempcode('PRIORITY_' . strval($priority)); // Views if (get_db_type() != 'xml') { $event['e_views']++; $GLOBALS['SITE_DB']->query_update('calendar_events', array('e_views' => $event['e_views']), array('id' => $id), '', 1, NULL, false, true); } breadcrumb_set_parents(array(array($back_url, do_lang_tempcode('CALENDAR')))); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $event['e_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($event['e_submitter']), 'publisher' => '', 'modified' => is_null($event['e_edit_date']) ? '' : date('Y-m-d', $event['e_edit_date']), 'type' => 'Calendar event', 'title' => get_translated_text($event['e_title']), 'identifier' => '_SEARCH:calendar:view:' . strval($id), 'description' => get_translated_text($event['e_content']), 'image' => find_theme_image('bigicons/calendar')); $map = array('TITLE' => $title, '_TITLE' => get_translated_text($event['e_title']), 'ID' => strval($id), 'TAGS' => get_loaded_tags('calendar'), 'WARNING_DETAILS' => $warning_details, 'SUBMITTER' => strval($event['e_submitter']), 'ADD_DATE' => get_timezoned_date($event['e_add_date']), 'ADD_DATE_RAW' => strval($event['e_add_date']), 'EDIT_DATE_RAW' => is_null($event['e_edit_date']) ? '' : strval($event['e_edit_date']), 'VIEWS' => integer_format($event['e_views']), 'LOGO' => $event['t_logo'], 'DAY' => $day_formatted, 'TO_DAY' => $to_day_formatted, 'RECURRENCE' => $recurrence, 'IS_PUBLIC' => $is_public, 'PRIORITY' => strval($priority), 'PRIORITY_LANG' => $priority_lang, 'TYPE' => $type, 'TIME' => $time2, 'TIME_RAW' => strval($time_raw), 'TIME_VCAL' => date('Y-m-d', $time_raw) . ' ' . date('H:i:s', $time_raw), 'TO_TIME_VCAL' => is_null($to_raw) ? NULL : date('Y-m-d', $to_raw) . ' ' . date('H:i:s', $to_raw), 'EDIT_URL' => $edit_url, 'SUBSCRIPTIONS' => $_subscriptions, 'SUBSCRIBE_URL' => $subscribe_url, 'BACK_URL' => $back_url, 'CONTENT' => $content, 'SUBSCRIBED' => $subscribed, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, '_GUID' => '602e6f86f586ef0a24efed950eafd426'); if ($event['e_do_timezone_conv'] == 0) { $timezone_map = get_timezone_list(); $map['TIMEZONE'] = $timezone_map[$event['e_timezone']]; } return do_template('CALENDAR_SCREEN', $map); }
/** * Get the parsed contents of a comcode page. * * @param PATH The relative (to ocPortal's base directory) path to the page (e.g. pages/comcode/EN/start.txt) * @param ID_TEXT The zone the page is being loaded from * @param ID_TEXT The codename of the page * @param ?PATH The file base to load from (NULL: standard) * @param boolean Whether the page is being included from another * @return tempcode The page */ function load_comcode_page($string, $zone, $codename, $file_base = NULL, $being_included = false) { if ($file_base === NULL) { $file_base = get_file_base(); } if (!$being_included) { $GLOBALS['TITLE_CALLED'] = true; } $is_panel = substr($codename, 0, 6) == 'panel_' || strpos($codename, 'panel_') !== false && get_param_integer('keep_theme_test', 0) == 1; if ($zone == '' && $codename == '404') { global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML $GLOBALS['HTTP_STATUS_CODE'] = '404'; if (!headers_sent()) { if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) { header('HTTP/1.0 404 Not Found'); } } } if (($is_panel || $codename[0] == '_') && get_page_name() == $codename) { global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML } if ($zone == 'adminzone') { require_code('site_adminzone'); adminzone_special_cases($codename); } if ($codename == 'sitemap') { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=comcode_pages&filter=' . $zone; } global $PAGE_STRING, $COMCODE_PARSE_TITLE, $LAST_COMCODE_PARSED_TITLE; $COMCODE_PARSE_TITLE = NULL; if ($PAGE_STRING === NULL && !$being_included && !$is_panel) { $PAGE_STRING = $string; } $new_comcode_page_row = array('the_zone' => $zone, 'the_page' => $codename, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => NULL, 'p_submitter' => NULL, 'p_show_as_edit' => 0); if ((get_option('is_on_comcode_page_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1 || get_param_integer('cache_blocks', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache_blocks', NULL) !== 0 && get_param_integer('cache', NULL) !== 0 && get_param_integer('keep_print', 0) == 0) { global $SITE_INFO; $support_smart_decaching = !isset($SITE_INFO['disable_smart_decaching']) || $SITE_INFO['disable_smart_decaching'] == '0'; if (is_browser_decacheing()) { $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index', 'cc_page_title'), array('the_page' => $codename, 'the_zone' => $zone, 'the_theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), '', 1, 0, false, array()); if (array_key_exists(0, $comcode_page)) { if ($comcode_page[0]['string_index'] !== NULL) { delete_lang($comcode_page[0]['string_index']); } $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $codename, 'the_zone' => $zone)); } } $theme = $GLOBALS['FORUM_DRIVER']->get_theme(); if ($GLOBALS['MEM_CACHE'] !== NULL) { if ($support_smart_decaching) { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), $mtime); } else { $pcache = persistant_cache_get(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang())); } } else { $pcache = NULL; } if ($pcache === NULL) { $comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages a JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'comcode_pages b ON (a.the_page=b.the_page AND a.the_zone=b.the_zone)', array('*'), array('a.the_page' => $codename, 'a.the_zone' => $zone, 'the_theme' => $theme), '', 1, NULL, false, array('string_index', 'cc_page_title')); if (array_key_exists(0, $comcode_page)) { if ($support_smart_decaching) { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. } if (!$support_smart_decaching || ($comcode_page[0]['p_edit_date'] !== NULL && $comcode_page[0]['p_edit_date'] >= $mtime || $comcode_page[0]['p_edit_date'] === NULL && $comcode_page[0]['p_add_date'] !== NULL && $comcode_page[0]['p_add_date'] >= $mtime)) { $comcode_page_row = $comcode_page[0]; $db_set = get_translated_tempcode($comcode_page[0]['string_index'], NULL, user_lang(), true, true, true); unset($GLOBALS['RECORDED_LANG_STRINGS_CONTENT'][$comcode_page[0]['string_index']]); } else { $mtime = filemtime($file_base . '/' . $string); if ($mtime > time()) { $mtime = time(); } // Timezone error, we have to assume that cache is ok rather than letting us get in a loop decacheing the file. It'll get fixed automatically in a few hours when the hours of the timezone difference passes. $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_edit_date' => $mtime), array('the_page' => $codename, 'the_zone' => $zone), '', 1); $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename)); delete_lang($comcode_page[0]['string_index']); $db_set = NULL; $comcode_page_row = NULL; } } else { $db_set = NULL; $comcode_page_row = NULL; } if ($db_set !== NULL) { $index = $comcode_page[0]['string_index']; $title_to_use = $comcode_page[0]['cc_page_title']; if ($title_to_use !== NULL) { $title_to_use = get_translated_text($title_to_use, NULL, NULL, true); if ($title_to_use === NULL) { $title_to_use = $codename; } } $html = $db_set; } else { $comcode_page = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_page' => $codename, 'the_zone' => $zone), '', 1); if (array_key_exists(0, $comcode_page)) { $comcode_page_row = $comcode_page[0]; } require_code('site2'); $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string); list($html, $title_to_use, $comcode_page_row) = _load_comcode_page_not_cached($string, $zone, $codename, $file_base, $comcode_page_row, $new_comcode_page_row, $being_included); } persistant_cache_set(array('COMCODE_PAGE', $codename, $zone, $theme, user_lang()), array($html, $title_to_use, $comcode_page_row)); } else { list($html, $title_to_use, $comcode_page_row) = $pcache; } } else { require_code('site2'); $new_comcode_page_row['p_add_date'] = filectime($file_base . '/' . $string); list($html, $comcode_page_row, $title_to_use) = _load_comcode_page_cache_off($string, $zone, $codename, $file_base, $new_comcode_page_row, $being_included); } $filtered_title_to_use = mixed(); if (!$is_panel && !$being_included) { if ($title_to_use !== NULL && $title_to_use != '') { get_page_title($title_to_use, false); // Little hack - this gets shift encoded, but shift encoding can't survive a tempcode cache. This will force it to reshift. It'll also make sure DISPLAYED_TITLE gets set. $filtered_title_to_use = @html_entity_decode(strip_tags($title_to_use), ENT_QUOTES, get_charset()); } seo_meta_load_for('comcode_page', $zone . ':' . $codename, $filtered_title_to_use); } $LAST_COMCODE_PARSED_TITLE = $title_to_use; if ($html->is_definitely_empty() && $being_included) { return $html; } if (has_actual_page_access(get_member(), 'cms_comcode_pages', NULL, NULL, $comcode_page_row['p_submitter'] == get_member() && !is_guest() ? 'edit_own_highrange_content' : 'edit_highrange_content')) { $redirect = get_self_url(true, false, array('redirect' => NULL, 'redirected' => NULL)); if (($codename == 'panel_left' || $codename == 'panel_right') && has_js() && has_actual_page_access(get_member(), 'admin_zones')) { $edit_url = build_url(array('page' => 'admin_zones', 'type' => '_editor', 'id' => get_zone_name(), 'redirect' => $redirect, 'wide' => 1), get_module_zone('admin_zones')); } else { $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $zone . ':' . $codename, 'redirect' => $redirect), get_module_zone('cms_comcode_pages')); } $add_child_url = get_option('is_on_comcode_page_children') == '1' ? build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'parent_page' => $codename, 'page_link' => $zone . ':'), get_module_zone('cms_comcode_pages')) : new ocp_tempcode(); } else { $edit_url = new ocp_tempcode(); $add_child_url = new ocp_tempcode(); } $warning_details = new ocp_tempcode(); if ($comcode_page_row['p_validated'] !== NULL && $comcode_page_row['p_validated'] == 0) { require_code('site2'); $warning_details = get_page_warning_details($zone, $codename, $edit_url); } if (!$is_panel && $title_to_use !== NULL && !$being_included) { global $PT_PAIR_CACHE_CP; $PT_PAIR_CACHE_CP[$codename]['cc_page_title'] = $title_to_use === NULL ? do_lang_tempcode('NA_EM') : make_string_tempcode($title_to_use); $PT_PAIR_CACHE_CP[$codename]['p_parent_page'] = $comcode_page_row['p_parent_page']; $comcode_breadcrumbs = comcode_breadcrumbs($codename, $zone, get_param('root', ''), $comcode_page_row['p_parent_page'] == '' || !has_specific_permission(get_member(), 'open_virtual_roots')); breadcrumb_add_segment($comcode_breadcrumbs); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $comcode_page_row['p_add_date']), 'creator' => is_guest($comcode_page_row['p_submitter']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($comcode_page_row['p_submitter']), 'publisher' => '', 'modified' => $comcode_page_row['p_edit_date'] === NULL ? '' : date('Y-m-d', $comcode_page_row['p_edit_date']), 'type' => 'Comcode page', 'title' => $title_to_use, 'identifier' => $zone . ':' . $codename, 'description' => ''); } if ($html->is_definitely_empty() && $is_panel) { return $html; } global $SCREEN_TEMPLATE_CALLED; $st = $SCREEN_TEMPLATE_CALLED; $ret = do_template('COMCODE_PAGE_SCREEN', array('_GUID' => '0fc4fe4f27e54aaaa2b7e4848c02bacb', 'IS_PANEL' => $is_panel, 'BEING_INCLUDED' => $being_included, 'SUBMITTER' => strval($comcode_page_row['p_submitter']), 'TAGS' => get_loaded_tags('comcode_pages'), 'WARNING_DETAILS' => $warning_details, 'EDIT_DATE_RAW' => $comcode_page_row['p_edit_date'] === NULL ? '' : strval($comcode_page_row['p_edit_date']), 'SHOW_AS_EDIT' => $comcode_page_row['p_show_as_edit'] == 1, 'CONTENT' => $html, 'EDIT_URL' => $edit_url, 'ADD_CHILD_URL' => $add_child_url, 'NAME' => $codename)); if ($is_panel || $being_included) { $SCREEN_TEMPLATE_CALLED = $st; } return $ret; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('news'); require_lang('ocf'); require_css('news'); $days = array_key_exists('param', $map) ? intval($map['param']) : 14; $multiplier = array_key_exists('multiplier', $map) ? floatval($map['multiplier']) : 0.5; $fallback_full = array_key_exists('fallback_full', $map) ? intval($map['fallback_full']) : 3; $fallback_archive = array_key_exists('fallback_archive', $map) ? intval($map['fallback_archive']) : 6; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('news'); $historic = array_key_exists('historic', $map) ? $map['historic'] : ''; $filter_and = array_key_exists('filter_and', $map) ? $map['filter_and'] : ''; $blogs = array_key_exists('blogs', $map) ? intval($map['blogs']) : -1; $member_based = array_key_exists('member_based', $map) && $map['member_based'] == '1'; global $NEWS_CATS; if (!isset($NEWS_CATS)) { $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } $days_full = floatval($days) * $multiplier; $days_outline = floatval($days) - $days_full; // News Query require_code('ocfiltering'); $filter = array_key_exists('filter', $map) ? $map['filter'] : get_param('news_filter', '*'); $filters_1 = ocfilter_to_sqlfragment($filter, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters_2 = ocfilter_to_sqlfragment($filter, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $q_filter = '(' . $filters_1 . ' OR ' . $filters_2 . ')'; if ($blogs === 0) { if ($q_filter != '') { $q_filter .= ' AND '; } $q_filter .= 'nc_owner IS NULL'; } elseif ($blogs === 1) { if ($q_filter != '') { $q_filter .= ' AND '; } $q_filter .= '(nc_owner IS NOT NULL)'; } if ($blogs != -1) { $join = ' LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_categories c ON c.id=p.news_category'; } else { $join = ''; } if ($filter_and != '') { $filters_and_1 = ocfilter_to_sqlfragment($filter_and, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters_and_2 = ocfilter_to_sqlfragment($filter_and, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $q_filter .= ' AND (' . $filters_and_1 . ' OR ' . $filters_and_2 . ')'; } if ($historic == '') { $rows = $days_full == 0.0 ? array() : $GLOBALS['SITE_DB']->query('SELECT *,p.id AS p_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id' . $join . ' WHERE ' . $q_filter . ' AND validated=1 AND date_and_time>=' . strval(time() - 60 * 60 * 24 * intval($days_full)) . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY p.date_and_time DESC', 300); if (!array_key_exists(0, $rows)) { $rows = $GLOBALS['SITE_DB']->query('SELECT *,p.id AS p_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries d ON p.id=d.news_entry' . $join . ' WHERE ' . $q_filter . ' AND validated=1' . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY p.date_and_time DESC', $fallback_full); $rows2 = $GLOBALS['SITE_DB']->query('SELECT *,p.id AS p_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries d ON p.id=d.news_entry' . $join . ' WHERE ' . $q_filter . ' AND validated=1' . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY p.date_and_time DESC', $fallback_archive, $fallback_full); } else { $rows2 = $GLOBALS['SITE_DB']->query('SELECT *,p.id AS p_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries d ON p.id=d.news_entry' . $join . ' WHERE ' . $q_filter . ' AND validated=1 AND date_and_time>=' . strval(time() - 60 * 60 * 24 * intval($days_full + $days_outline)) . ' AND date_and_time<' . strval(time() - 60 * 60 * 24 * intval($days_full)) . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY p.date_and_time DESC', 300); } } else { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; do { $_rows = $GLOBALS['SITE_DB']->query('SELECT *,p.id AS p_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news_category_entries d ON p.id=d.news_entry' . $join . ' WHERE ' . $q_filter . ' AND validated=1' . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY p.date_and_time DESC', 200, $start); $rows = array(); $rows2 = array(); foreach ($_rows as $row) { $ok = false; switch ($historic) { case 'month': if (date('m', utctime_to_usertime($row['date_and_time'])) == date('m', utctime_to_usertime()) && date('Y', utctime_to_usertime($row['date_and_time'])) != date('Y', utctime_to_usertime())) { $ok = true; } break; case 'week': if (date('W', utctime_to_usertime($row['date_and_time'])) == date('W', utctime_to_usertime()) && date('Y', utctime_to_usertime($row['date_and_time'])) != date('Y', utctime_to_usertime())) { $ok = true; } break; case 'day': if (date('d', utctime_to_usertime($row['date_and_time'])) == date('d', utctime_to_usertime()) && date('m', utctime_to_usertime($row['date_and_time'])) == date('m', utctime_to_usertime()) && date('Y', utctime_to_usertime($row['date_and_time'])) != date('Y', utctime_to_usertime())) { $ok = true; } break; } if ($ok) { if (count($rows) < $fallback_full) { $rows[] = $row; } elseif (count($rows2) < $fallback_archive) { $rows2[] = $row; } else { break 2; } } } $start += 200; } while (count($_rows) == 200); unset($_rows); } $rows = remove_duplicate_rows($rows, 'p_id'); $i = 0; $news_text = new ocp_tempcode(); while (array_key_exists($i, $rows)) { $myrow = $rows[$i]; // $categories=$GLOBALS['SITE_DB']->query_select('news_category_entries',array('news_entry_category'),array('news_entry'=>$myrow['p_id'])); if (has_category_access(get_member(), 'news', strval($myrow['news_category']))) { $id = $myrow['p_id']; $date = get_timezoned_date($myrow['date_and_time']); $author_url = addon_installed('authors') && !$member_based ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $myrow['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $myrow['author']; $news_title = get_translated_tempcode($myrow['title']); if (array_key_exists('show_in_full', $map) && $map['show_in_full'] == '1') { $news = get_translated_tempcode($myrow['news_article']); $truncate = false; if ($news->is_empty()) { $news = get_translated_tempcode($myrow['news']); } } else { $news = get_translated_tempcode($myrow['news']); if ($news->is_empty()) { $news = get_translated_tempcode($myrow['news_article']); $truncate = true; } else { $truncate = false; } } $tmp = array('page' => 'news', 'type' => 'view', 'id' => $id); if ($filter != '*') { $tmp['filter'] = $filter; } if ($filter_and != '*' && $filter_and != '') { $tmp['filter_and'] = $filter_and; } if ($blogs != -1) { $tmp['blog'] = $blogs; } $full_url = build_url($tmp, $zone); if (!array_key_exists($myrow['news_category'], $NEWS_CATS)) { $_news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('id' => $myrow['news_category']), '', 1); if (array_key_exists(0, $_news_cats)) { $NEWS_CATS[$myrow['news_category']] = $_news_cats[0]; } } if (!array_key_exists($myrow['news_category'], $NEWS_CATS) || !array_key_exists('nc_title', $NEWS_CATS[$myrow['news_category']])) { $myrow['news_category'] = db_get_first_id(); } $img = find_theme_image($NEWS_CATS[$myrow['news_category']]['nc_img']); if (is_null($img)) { $img = ''; } if ($myrow['news_image'] != '') { $img = $myrow['news_image']; if (url_is_local($img)) { $img = get_custom_base_url() . '/' . $img; } } $category = get_translated_text($NEWS_CATS[$myrow['news_category']]['nc_title']); $seo_bits = seo_meta_get_for('news', strval($id)); $map2 = array('TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'ID' => strval($id), 'TRUNCATE' => $truncate, 'BLOG' => $blogs === 1, 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $category, 'IMG' => $img, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'NEWS_TITLE' => $news_title, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS' => $news, 'FULL_URL' => $full_url); if (get_option('is_on_comments') == '1' && !has_no_forum() && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } $news_text->attach(do_template('NEWS_PIECE_SUMMARY', $map2)); } $i++; } $j = 0; $news_text2 = new ocp_tempcode(); while (array_key_exists($j, $rows2)) { $myrow = $rows2[$j]; // $categories=$GLOBALS['SITE_DB']->query_select('news_category_entries',array('news_entry_category'),array('news_entry'=>$myrow['id'])); if (has_category_access(get_member(), 'news', strval($myrow['news_category']))) { $date = get_timezoned_date($myrow['date_and_time']); $tmp = array('page' => 'news', 'type' => 'view', 'id' => $myrow['p_id']); if ($filter != '*') { $tmp['filter'] = $filter; } if ($filter_and != '*' && $filter_and != '') { $tmp['filter_and'] = $filter_and; } if ($blogs != -1) { $tmp['blog'] = $blogs; } $url = build_url($tmp, $zone); $title = get_translated_tempcode($myrow['title']); $title_plain = get_translated_text($myrow['title']); $seo_bits = seo_meta_get_for('news', strval($myrow['p_id'])); $map2 = array('_GUID' => 'd81bda3a0912a1e708af6bb1f503b296', 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'BLOG' => $blogs === 1, 'ID' => strval($myrow['p_id']), 'SUBMITTER' => strval($myrow['submitter']), 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'URL' => $url, 'TITLE_PLAIN' => $title_plain, 'TITLE' => $title); if (get_option('is_on_comments') == '1' && !has_no_forum() && $myrow['allow_comments'] >= 1) { $map2['COMMENT_COUNT'] = '1'; } $news_text2->attach(do_template('NEWS_BRIEF', $map2)); } $j++; } $tmp = array('page' => 'news', 'type' => 'misc'); if ($filter != '*') { $tmp[is_numeric($filter) ? 'id' : 'filter'] = $filter; } if ($filter_and != '*' && $filter_and != '') { $tmp['filter_and'] = $filter_and; } if ($blogs != -1) { $tmp['blog'] = $blogs; } $archive_url = build_url($tmp, $zone); $_is_on_rss = get_option('is_rss_advertised', true); $is_on_rss = is_null($_is_on_rss) ? 0 : intval($_is_on_rss); // Set to zero if we don't want to show RSS links $submit_url = new ocp_tempcode(); if (($blogs !== 1 || has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) && has_actual_page_access(NULL, $blogs === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), $blogs === 1 ? 'cms_blogs' : 'cms_news')) { $map2 = array('page' => $blogs === 1 ? 'cms_blogs' : 'cms_news', 'type' => 'ad', 'redirect' => SELF_REDIRECT); if (is_numeric($filter)) { $map2['cat'] = $filter; // select news cat by default, if we are only showing one news cat in this block } elseif ($filter != '*') { $pos_a = strpos($filter, ','); $pos_b = strpos($filter, '-'); if ($pos_a !== false) { $first_cat = substr($filter, 0, $pos_a); } elseif ($pos_b !== false) { $first_cat = substr($filter, 0, $pos_b); } else { $first_cat = ''; } if (is_numeric($first_cat)) { $map2['cat'] = $first_cat; } } $submit_url = build_url($map2, get_module_zone($blogs === 1 ? 'cms_blogs' : 'cms_news')); } $_title = do_lang_tempcode($blogs == 1 ? 'BLOGS_POSTS' : 'NEWS'); if (array_key_exists('title', $map) && $map['title'] != '') { $_title = protect_from_escaping(escape_html($map['title'])); } if ($i == 0 && $j == 0) { return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '9d7065af4dd4026ffb34243fd931f99d', 'HIGH' => false, 'TITLE' => $_title, 'MESSAGE' => do_lang_tempcode($blogs == 1 ? 'BLOG_NO_NEWS' : 'NO_NEWS'), 'ADD_NAME' => do_lang_tempcode($blogs == 1 ? 'ADD_NEWS_BLOG' : 'ADD_NEWS'), 'SUBMIT_URL' => $submit_url)); } $atom_url = new ocp_tempcode(); $rss_url = new ocp_tempcode(); if ($is_on_rss == 1) { $atom_url = make_string_tempcode(find_script('backend') . '?type=atom&mode=news&filter=' . $filter); $atom_url->attach(symbol_tempcode('KEEP')); $rss_url = make_string_tempcode(find_script('backend') . '?type=rss2&mode=news&filter=' . $filter); $rss_url->attach(symbol_tempcode('KEEP')); } return do_template('BLOCK_MAIN_NEWS', array('_GUID' => '01f5fbd2b0c7c8f249023ecb4254366e', 'BLOG' => $blogs === 1, 'TITLE' => $_title, 'CONTENT' => $news_text, 'BRIEF' => $news_text2, 'FILTER' => $filter, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url, 'RSS_URL' => $rss_url, 'ATOM_URL' => $atom_url)); }
/** * The UI to view an author. * * @return tempcode The UI */ function show_author() { $author = get_param('id', NULL); if (is_null($author)) { if (is_guest()) { global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML warn_exit(do_lang_tempcode('USER_NO_EXIST')); } $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } if (is_null($author) || $author == '') { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } // Really don't want to have to search on this if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('author', $author); } else { $awards = array(); } $title = get_page_title('_AUTHOR', true, array(escape_html($author)), NULL, $awards); seo_meta_load_for('authors', $author); $rows = $GLOBALS['SITE_DB']->query_select('authors', array('url', 'description', 'skills'), array('author' => $author), '', 1); if (!array_key_exists(0, $rows)) { if (has_actual_page_access(get_member(), 'cms_authors') && has_edit_author_permission(get_member(), $author)) { $GLOBALS['HTTP_STATUS_CODE'] = '404'; if (!headers_sent()) { if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) { header('HTTP/1.0 404 Not Found'); } } $_author_add_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors')); $author_add_url = $_author_add_url->evaluate(); $message = do_lang_tempcode('NO_SUCH_AUTHOR_CONFIGURE_ONE', escape_html($author), escape_html($author_add_url)); attach_message($message, 'inform'); } else { $message = do_lang_tempcode('NO_SUCH_AUTHOR', escape_html($author)); } $details = array('author' => $author, 'url' => '', 'forum_handle' => $GLOBALS['FORUM_DRIVER']->get_member_from_username($author), 'description' => NULL, 'skills' => NULL); //return inform_screen($title,$message); } else { $details = $rows[0]; } // Links associated with the mapping between the author and a forum member $handle = get_author_id_from_name($author); if (!is_null($handle)) { $forum_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($GLOBALS['FORUM_DRIVER']->member_profile_url($handle, true, true), do_lang_tempcode('AUTHOR_PROFILE'), false, false, '', NULL, NULL, 'me'))); if (addon_installed('points')) { $give_points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $handle), get_module_zone('points')); $point_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($give_points_url, do_lang_tempcode('AUTHOR_POINTS')))); } else { $point_details = new ocp_tempcode(); } } else { $forum_details = new ocp_tempcode(); $point_details = new ocp_tempcode(); } // Homepage $url = $details['url']; if (strlen($url) > 0) { $url_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($url, do_lang_tempcode('AUTHOR_HOMEPAGE'), false, false, '', NULL, NULL, 'me'))); } else { $url_details = new ocp_tempcode(); } // (Self?) description $description = is_null($details['description']) ? new ocp_tempcode() : get_translated_tempcode($details['description']); // Skills $skills = is_null($details['skills']) ? new ocp_tempcode() : get_translated_tempcode($details['skills']); // Edit link, for staff if (has_edit_author_permission(get_member(), $author)) { $edit_author_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'author' => $author), get_module_zone('cms_authors')); $staff_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($edit_author_url, do_lang_tempcode('DEFINE_AUTHOR'), false))); } else { $staff_details = new ocp_tempcode(); } // Search link if (addon_installed('search')) { $search_url = build_url(array('page' => 'search', 'author' => $author), get_module_zone('search')); $search_details = do_template('AUTHOR_SCREEN_POTENTIAL_ACTION_ENTRY', array('ACTION' => hyperlink($search_url, do_lang_tempcode('SEARCH'), false))); } else { $search_details = new ocp_tempcode(); } // Downloads $downloads_released = new ocp_tempcode(); if (addon_installed('downloads')) { require_code('downloads'); require_lang('downloads'); $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('author' => $author, 'validated' => 1)); if ($count > 50) { $downloads_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } else { $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('author' => $author, 'validated' => 1)); require_code('downloads'); foreach ($rows as $i => $myrow) { if ($i != 0) { $downloads_released->attach(do_template('BLOCK_SEPARATOR', array('_GUID' => 'ea789367b15bsddsdsdsc586e6e6536'))); } if (has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { $downloads_released->attach(get_download_html($myrow)); } } } } // News $news_released = new ocp_tempcode(); if (addon_installed('news')) { require_lang('news'); $count = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)', array('author' => $author, 'validated' => 1)); if ($count > 50) { $news_released = paragraph(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } else { $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('author' => $author, 'validated' => 1)); foreach ($rows as $i => $row) { if (has_category_access(get_member(), 'news', strval($row['news_category']))) { $url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news')); $_title = get_translated_tempcode($row['title']); $title_plain = get_translated_text($row['title']); $seo_bits = seo_meta_get_for('news', strval($row['id'])); $map = array('ID' => strval($row['id']), 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'SUBMITTER' => strval($row['submitter']), 'DATE' => get_timezoned_date($row['date_and_time']), 'DATE_RAW' => strval($row['date_and_time']), 'URL' => $url, 'TITLE_PLAIN' => $title_plain, 'TITLE' => $_title); if (get_option('is_on_comments') == '1' && !has_no_forum() && $row['allow_comments'] >= 1) { $map['COMMENT_COUNT'] = '1'; } $tpl = do_template('NEWS_BRIEF', $map); $news_released->attach($tpl); } } } } // Edit link $edit_url = new ocp_tempcode(); if (has_edit_author_permission(get_member(), $author)) { $edit_url = build_url(array('page' => 'cms_authors', 'type' => '_ad', 'id' => $author), 'cms'); } return do_template('AUTHOR_SCREEN', array('_GUID' => 'ea789367b15bc90fc28d1c586e6e6536', 'TAGS' => get_loaded_tags(), 'TITLE' => $title, 'EDIT_URL' => $edit_url, 'AUTHOR' => $author, 'NEWS_RELEASED' => $news_released, 'DOWNLOADS_RELEASED' => $downloads_released, 'STAFF_DETAILS' => $staff_details, 'POINT_DETAILS' => $point_details, 'SEARCH_DETAILS' => $search_details, 'URL_DETAILS' => $url_details, 'FORUM_DETAILS' => $forum_details, 'SKILLS' => $skills, 'DESCRIPTION' => $description)); }
/** * Standard modular run function for rendering a search result. * * @param array The data row stored when we retrieved the result * @return tempcode The output */ function render($myrow) { global $NEWS_CATS; if (!isset($NEWS_CATS)) { $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } $id = $myrow['id']; $date = get_timezoned_date($myrow['date_and_time']); $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $myrow['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $myrow['author']; $news_title = get_translated_tempcode($myrow['title']); $news = get_translated_tempcode($myrow['news']); if ($news->is_empty()) { $news = get_translated_tempcode($myrow['news_article']); $truncate = true; } else { $truncate = false; } $tmp = array('page' => 'news', 'type' => 'view', 'id' => $id); $full_url = build_url($tmp, get_module_zone('news')); if (!array_key_exists($myrow['news_category'], $NEWS_CATS)) { $_news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('id' => $myrow['news_category']), '', 1); if (array_key_exists(0, $_news_cats)) { $NEWS_CATS[$myrow['news_category']] = $_news_cats[0]; } } if (!array_key_exists($myrow['news_category'], $NEWS_CATS) || !array_key_exists('nc_title', $NEWS_CATS[$myrow['news_category']])) { $myrow['news_category'] = db_get_first_id(); } $img = find_theme_image($NEWS_CATS[$myrow['news_category']]['nc_img']); if (is_null($img)) { $img = ''; } if ($myrow['news_image'] != '') { $img = $myrow['news_image']; if (url_is_local($img)) { $img = get_base_url() . '/' . $img; } } $category = get_translated_text($NEWS_CATS[$myrow['news_category']]['nc_title']); $seo_bits = seo_meta_get_for('news', strval($id)); $map = array('ID' => strval($id), 'TAGS' => get_loaded_tags('news', explode(',', $seo_bits[0])), 'TRUNCATE' => $truncate, 'BLOG' => false, 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $category, 'IMG' => $img, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'NEWS_TITLE' => $news_title, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS' => $news, 'FULL_URL' => $full_url); $tpl = do_template('NEWS_PIECE_SUMMARY', $map); return put_in_standard_box($tpl, do_lang_tempcode('NEWS_ARTICLE')); }
/** * The UI to show a catalogue A-Z screen. * * @return tempcode The UI */ function view_catalogue_category_entries() { $id = get_param_integer('id', -1); if ($id == -1) { $id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => get_param('catalogue_name'), 'cc_parent_id' => NULL)); } $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($id); $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $categories)) { return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE')); } $category = $categories[0]; // Permission for here? if (!has_category_access(get_member(), 'catalogues_catalogue', $category['c_name'])) { access_denied('CATALOGUE_ACCESS'); } $catalogue_name = $category['c_name']; $root = get_param_integer('root', NULL); $category = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'cc_title', array('id' => $id)); $category_name = get_translated_text($category); $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1); if (!array_key_exists(0, $catalogues)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $catalogue = $catalogues[0]; $tpl_set = $catalogue_name; $category_buildup = new ocp_tempcode(); $max = NULL; $start = NULL; require_code('ocfiltering'); $sql_filter = ocfilter_to_sqlfragment(strval($id) . '*', 'cc_id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'catalogue_entries p WHERE ce_validated=1 AND (' . $sql_filter . ')') > 1000) { warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM')); } $cats = array(); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'catalogue_entries p WHERE ce_validated=1 AND (' . $sql_filter . ')'); foreach ($rows as $row) { $entry_map = get_catalogue_entry_map($row, $catalogue, 'CATEGORY', 'DEFAULT', $root, NULL, array(0), false, false); $letter = strtoupper(substr(is_object($entry_map['FIELD_0_PLAIN']) ? $entry_map['FIELD_0_PLAIN']->evaluate() : $entry_map['FIELD_0_PLAIN'], 0, 1)); if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($row['id']))) { continue; } if (!array_key_exists($letter, $cats)) { $cats[$letter] = array(); } $cats[$letter][] = $row; } unset($rows); ksort($cats); foreach ($cats as $letter => $entries) { list($entry_buildup) = get_catalogue_category_entry_buildup(NULL, $catalogue_name, $catalogue, 'CATEGORY', $tpl_set, $max, $start, NULL, $root, NULL, true, $entries); $category_buildup->attach(do_template('CATALOGUE_CATEGORY_HEADING', array('LETTER' => is_integer($letter) ? strval($letter) : $letter, 'ENTRIES' => escape_html($entry_buildup)), NULL, false, 'CATALOGUE_CATEGORY_HEADING')); } $_title = get_translated_text($category); $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_CATEGORY_ATOZ', escape_html($_title)); $title = get_page_title($title_to_use, false); //Link to add to catalogue category if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'submit_midrange_content')) { $add_link = build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue_name, 'category_id' => $id), get_module_zone('cms_catalogues')); } else { $add_link = new ocp_tempcode(); } if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'submit_cat_midrange_content')) { $add_cat_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_category', 'catalogue_name' => $catalogue_name, 'parent_id' => $id), get_module_zone('cms_catalogues')); } else { $add_cat_url = new ocp_tempcode(); } if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'edit_cat_midrange_content')) { $edit_cat_url = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_category', 'catalogue_name' => $catalogue_name, 'id' => $id), get_module_zone('cms_catalogues')); } else { $edit_cat_url = new ocp_tempcode(); } if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name), 'edit_cat_highrange_content')) { $edit_catalogue_url = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_catalogue', 'id' => $catalogue_name), get_module_zone('cms_catalogues')); } else { $edit_catalogue_url = new ocp_tempcode(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($catalogue['c_ecommerce'] == 1 ? ':ecommerce=1' : ''), do_lang_tempcode('CATALOGUES')))); return do_template('CATALOGUE_' . $tpl_set . '_CATEGORY_SCREEN', array('TITLE' => $title, 'CART_LINK' => '', '_TITLE' => $_title, 'TAGS' => get_loaded_tags('catalogue_categories'), 'CATALOGUE' => $catalogue_name, 'BROWSER' => '', 'SORTING' => '', 'ADD_LINK' => $add_link, 'ADD_CAT_URL' => $add_cat_url, 'EDIT_CAT_URL' => $edit_cat_url, 'EDIT_CATALOGUE_URL' => $edit_catalogue_url, 'ENTRIES' => $category_buildup, 'SUBCATEGORIES' => '', 'DESCRIPTION' => ''), NULL, false, 'CATALOGUE_DEFAULT_CATEGORY_SCREEN'); }
/** * The UI to view a news entry. * * @return tempcode The UI */ function view_news() { $id = get_param_integer('id'); $blog = get_param_integer('blog', NULL); $filter = get_param('filter', '*'); $filter_and = get_param('filter_and', '*'); if ($blog === 1) { $first_bc = array('_SELF:_SELF:blog_select', do_lang_tempcode('BLOGS')); } elseif ($blog === 0) { $first_bc = array('_SELF:_SELF:cat_select', do_lang_tempcode('JUST_NEWS_CATEGORIES')); } else { $first_bc = array('_SELF:_SELF:select', do_lang_tempcode('NEWS_CATEGORIES')); } if ($blog === 1) { $parent_title = do_lang_tempcode('BLOG_NEWS_ARCHIVE'); } else { if (is_numeric($filter)) { $news_cat_title = $GLOBALS['SITE_DB']->query_select('news_categories', array('nc_title'), array('id' => intval($filter)), '', 1); if (array_key_exists(0, $news_cat_title)) { $news_cat_title[0]['text_original'] = get_translated_text($news_cat_title[0]['nc_title']); $parent_title = make_string_tempcode(escape_html($news_cat_title[0]['text_original'])); } else { $parent_title = do_lang_tempcode('NEWS_ARCHIVE'); } } else { $parent_title = do_lang_tempcode('NEWS_ARCHIVE'); } } breadcrumb_set_parents(array($first_bc, array('_SELF:_SELF:misc' . ($blog === 1 ? ':blog=1' : ($blog === 0 ? ':blog=0' : '')) . ($filter == '*' ? '' : (is_numeric($filter) ? ':id=' . $filter : ':filter=' . $filter)) . ($filter_and == '*' ? '' : ':filter_and=' . $filter_and), $parent_title))); $rows = $GLOBALS['SITE_DB']->query_select('news', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen(get_page_title('NEWS'), do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; if (!has_category_access(get_member(), 'news', strval($myrow['news_category']))) { access_denied('CATEGORY_ACCESS'); } if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('news', strval($id)); } else { $awards = array(); } $_title = get_translated_tempcode($myrow['title']); $title_to_use = do_lang_tempcode($blog === 1 ? 'BLOG__NEWS' : '_NEWS', $_title); $title = get_page_title($title_to_use, false, NULL, NULL, $awards); seo_meta_load_for('news', strval($id), do_lang($blog === 1 ? 'BLOG__NEWS' : '_NEWS', get_translated_text($myrow['title']))); // Rating and comments $self_url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $id); /*if ($filter!='*') $self_url_map['filter']=$filter; Potentially makes URL too long for content topic to store, and we probably don't want to store this assumptive context anyway if (($filter_and!='*') && ($filter_and!='')) $self_url_map['filter_and']=$filter_and;*/ if (!is_null($blog)) { $self_url_map['blog'] = $blog; } list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url($self_url_map, '_SELF', NULL, false, false, true), get_translated_text($myrow['title']), get_value('comment_forum__news')); $date = get_timezoned_date($myrow['date_and_time']); $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $myrow['author']), get_module_zone('authors')) : new ocp_tempcode(); $author = $myrow['author']; $news_full = get_translated_tempcode($myrow['news_article']); $news_full_plain = get_translated_text($myrow['news_article']); if ($news_full->is_empty()) { $news_full = get_translated_tempcode($myrow['news']); $news_full_plain = get_translated_text($myrow['news']); } if (has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_edit_permission('high', get_member(), $myrow['submitter'], $blog === 1 ? 'cms_blogs' : 'cms_news', array('news', $myrow['news_category']))) { $edit_url = build_url(array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => '_ed', 'id' => $id), get_module_zone($blog === 1 ? 'cms_blogs' : 'cms_news')); } else { $edit_url = new ocp_tempcode(); } $tmp = array('page' => '_SELF', 'type' => 'misc'); if ($filter != '*') { $tmp[is_numeric($filter) ? 'id' : 'filter'] = $filter; } if ($filter_and != '*' && $filter_and != '') { $tmp['filter_and'] = $filter_and; } if (!is_null($blog)) { $tmp['blog'] = $blog; } $archive_url = build_url($tmp, '_SELF'); // 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' => '5fd82328dc2ac9695dc25646237065b0', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } // Views if (get_db_type() != 'xml') { $myrow['news_views']++; $GLOBALS['SITE_DB']->query_update('news', array('news_views' => $myrow['news_views']), array('id' => $id), '', 1, NULL, false, true); } if (($blog !== 1 || has_specific_permission(get_member(), 'have_personal_category', 'cms_news')) && has_actual_page_access(NULL, $blog === 1 ? 'cms_blogs' : 'cms_news', NULL, NULL) && has_submit_permission('high', get_member(), get_ip_address(), 'cms_news', array('news', $myrow['news_category']))) { $map = array('page' => $blog === 1 ? 'cms_blogs' : 'cms_news', 'type' => 'ad'); if (is_numeric($filter)) { $map['cat'] = $filter; } $submit_url = build_url($map, get_module_zone('cms_news')); } else { $submit_url = new ocp_tempcode(); } $news_cats = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'news_categories WHERE nc_owner IS NULL OR id=' . strval($myrow['news_category'])); $news_cats = list_to_map('id', $news_cats); $img = find_theme_image($news_cats[$myrow['news_category']]['nc_img']); if (is_null($img)) { $img = ''; } if ($myrow['news_image'] != '') { $img = $myrow['news_image']; if (url_is_local($img)) { $img = get_custom_base_url() . '/' . $img; } } $category = get_translated_text($news_cats[$myrow['news_category']]['nc_title']); $categories = array(strval($myrow['news_category']) => $category); $all_categories_for_this = $GLOBALS['SITE_DB']->query_select('news_category_entries', array('*'), array('news_entry' => $id)); $NEWS_CATS = array(); foreach ($all_categories_for_this as $category_for_this) { if (!array_key_exists($category_for_this['news_entry_category'], $news_cats)) { $_news_cats = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('id' => $category_for_this['news_entry_category']), '', 1); if (array_key_exists(0, $_news_cats)) { $NEWS_CATS[$category_for_this['news_entry_category']] = $_news_cats[0]; } } if (array_key_exists($category_for_this['news_entry_category'], $news_cats)) { $categories[strval($category_for_this['news_entry_category'])] = get_translated_text($news_cats[$category_for_this['news_entry_category']]['nc_title']); } } $newsletter_url = new ocp_tempcode(); if (addon_installed('newsletter')) { require_lang('newsletter'); if (has_actual_page_access(get_member(), 'admin_newsletter')) { $newsletter_url = build_url(array('page' => 'admin_newsletter', 'type' => 'new', 'from_news' => $id), get_module_zone('admin_newsletter')); } } breadcrumb_set_self(get_translated_tempcode($myrow['title'])); $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['date_and_time']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'News article', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:news:view:' . strval($id), 'image' => $img, 'description' => strip_comcode(get_translated_text($myrow['news']))); return do_template('NEWS_FULL_SCREEN', array('_GUID' => '7686b23934e22c493d4ac10ba6c475c4', 'ID' => strval($id), 'CATEGORY_ID' => strval($myrow['news_category']), 'BLOG' => $blog === 1, '_TITLE' => $_title, 'TAGS' => get_loaded_tags('news'), 'CATEGORIES' => $categories, 'NEWSLETTER_URL' => $newsletter_url, 'ADD_DATE_RAW' => strval($myrow['date_and_time']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'SUBMITTER' => strval($myrow['submitter']), 'CATEGORY' => $category, 'IMG' => $img, 'TITLE' => $title, 'VIEWS' => integer_format($myrow['news_views']), 'COMMENT_DETAILS' => $comment_details, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'DATE' => $date, 'AUTHOR' => $author, 'AUTHOR_URL' => $author_url, 'NEWS_FULL' => $news_full, 'NEWS_FULL_PLAIN' => $news_full_plain, 'EDIT_URL' => $edit_url, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url, 'WARNING_DETAILS' => $warning_details)); }