コード例 #1
0
ファイル: downloads.php プロジェクト: erico-deh/ocPortal
 /**
  * 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));
 }
コード例 #2
0
ファイル: galleries.php プロジェクト: erico-deh/ocPortal
 /**
  * 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));
 }
コード例 #3
0
ファイル: quiz.php プロジェクト: erico-deh/ocPortal
 /**
  * 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)));
 }
コード例 #4
0
ファイル: catalogues.php プロジェクト: erico-deh/ocPortal
/**
 * 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');
}
コード例 #5
0
ファイル: calendar.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
 }
コード例 #6
0
ファイル: site.php プロジェクト: erico-deh/ocPortal
/**
 * 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;
}
コード例 #7
0
ファイル: authors.php プロジェクト: erico-deh/ocPortal
 /**
  * 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));
 }
コード例 #8
0
ファイル: catalogues.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI to show a catalogue category.
  *
  * @return tempcode		The UI
  */
 function view_catalogue_category()
 {
     require_code('feedback');
     require_code('images');
     $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');
     }
     if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $catalogue_name = $category['c_name'];
     $root = get_param_integer('root', NULL);
     $_title = get_translated_text($category['cc_title']);
     $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];
     $tpl_set = $catalogue_name;
     if (is_ecommerce_catalogue($catalogue_name)) {
         $is_ecommerce = true;
         $tpl_set = 'products';
     } else {
         $is_ecommerce = false;
     }
     $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_CATEGORY', escape_html($_title));
     $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_CATEGORY', $_title, NULL, NULL, NULL, false);
     if (is_null($title_to_use_2)) {
         $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_CATEGORY', escape_html($_title));
         $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_CATEGORY', $_title);
     }
     $awards = array();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = array_merge($awards, find_awards_for('catalogue', $catalogue_name));
         $awards = array_merge($awards, find_awards_for('catalogue_category', strval($id)));
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     if (is_object($title_to_use_2)) {
         $title_to_use_2 = $title_to_use_2->evaluate();
     }
     seo_meta_load_for('catalogue_category', strval($id), $title_to_use_2);
     $max = get_param_integer('max', 30);
     $start = get_param_integer('start', 0);
     list($entry_buildup, $sorting, $entries, $max_rows) = get_catalogue_category_entry_buildup($id, $catalogue_name, $catalogue, 'CATEGORY', $tpl_set, $max, $start, NULL, $root);
     // Build up subcategories
     $rows_subcategories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('cc_parent_id' => $id), '', 600);
     if (count($rows_subcategories) == 300) {
         $rows_subcategories = array();
     }
     // Performance issue, manual browsing will be needed
     foreach ($rows_subcategories as $i => $subcategory) {
         $rows_subcategories[$i]['cc_title'] = get_translated_text($subcategory['cc_title']);
     }
     for ($i = 0; $i < count($rows_subcategories); $i++) {
         for ($j = $i + 1; $j < count($rows_subcategories); $j++) {
             if ($rows_subcategories[$i]['cc_title'] > $rows_subcategories[$j]['cc_title']) {
                 $temp = $rows_subcategories[$j];
                 $rows_subcategories[$j] = $rows_subcategories[$i];
                 $rows_subcategories[$i] = $temp;
             }
         }
     }
     $subcategories = new ocp_tempcode();
     $uses_rep_image = false;
     foreach ($rows_subcategories as $sc) {
         if ($sc['rep_image'] != '') {
             $uses_rep_image = true;
         }
     }
     foreach ($rows_subcategories as $sc) {
         if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($sc['id']))) {
             continue;
         }
         $child_counts = count_catalogue_category_children($sc['id']);
         $num_children = $child_counts['num_children'];
         $num_entries = $child_counts['num_entries_children'];
         $map = array('page' => '_SELF', 'id' => $sc['id'], 'type' => 'category');
         if (!is_null($root)) {
             $map['root'] = $root;
         }
         $url = build_url($map, '_SELF');
         if ($uses_rep_image || $is_ecommerce) {
             $display_string = do_lang_tempcode($catalogue['c_is_tree'] == 1 ? 'CATEGORY_SUBORDINATE' : 'CATEGORY_SUBORDINATE_2', integer_format($num_entries), integer_format($num_children));
             if ($sc['rep_image']) {
                 $rep_image = do_image_thumb($sc['rep_image'], $sc['cc_title'], $sc['cc_title'], false);
             } else {
                 $rep_image = new ocp_tempcode();
             }
             $description = $sc['cc_description'];
             $description = get_translated_tempcode($description);
             $ajax_edit_url = '_SEARCH:cms_catalogues:type=__edit_category:id=' . strval($sc['id']);
             $subcategories->attach(do_template('CATEGORY_' . $tpl_set . '_ENTRY', array('_GUID' => '871f5f5195fcb426fac716e35569d6a3', 'ID' => strval($sc['id']), 'NAME_FIELD' => 'title', 'AJAX_EDIT_URL' => $ajax_edit_url, 'URL' => $url, 'REP_IMAGE' => $rep_image, 'CHILDREN' => $display_string, 'NAME' => $sc['cc_title'], 'NAME_PLAIN' => $sc['cc_title'], 'DESCRIPTION' => $description, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_CHILDREN_RECURSIVE' => integer_format($child_counts['num_children_children']), 'NUM_ENTRIES' => integer_format($num_entries), 'NUM_ENTRIES_DIRECT' => integer_format($child_counts['num_entries'])), NULL, false, 'CATEGORY_ENTRY'));
         } else {
             $subcategories->attach(do_template('CATALOGUE_' . $tpl_set . '_SUBCATEGORY', array('ID' => strval($sc['id']), 'CATALOGUE' => $catalogue_name, 'URL' => $url, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_CHILDREN_RECURSIVE' => integer_format($child_counts['num_children_children']), 'NUM_ENTRIES' => integer_format($num_entries), 'NUM_ENTRIES_DIRECT' => integer_format($child_counts['num_entries']), 'NAME' => $sc['cc_title']), NULL, false, 'CATALOGUE_DEFAULT_SUBCATEGORY'));
         }
     }
     if (!$subcategories->is_empty()) {
         if ($uses_rep_image) {
             $subcategories = do_template('CATEGORY_LIST', array('_GUID' => '3041620a953e52229f752b1bccfbeee3', 'CONTENT' => $subcategories));
         } else {
             $subcategories = do_template('CATALOGUE_' . $tpl_set . '_SUBCATEGORY_WRAP', array('CATALOGUE' => $catalogue_name, 'CONTENT' => $subcategories), NULL, false, 'CATALOGUE_DEFAULT_SUBCATEGORY_WRAP');
         }
     }
     // Links to add to catalogue category etc
     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();
     }
     require_code('templates_results_browser');
     $browser = results_browser(do_lang_tempcode('ENTRIES'), $id, $start, 'start', $max, 'max', $max_rows, $root, 'category', true);
     if ($catalogue['c_is_tree'] == 1) {
         $tree = catalogue_category_breadcrumbs($id, $root);
         if (!$tree->is_empty()) {
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         }
         if (has_specific_permission(get_member(), 'open_virtual_roots')) {
             $url = get_self_url(false, false, is_null(get_param('root', NULL)) ? array('root' => $id) : array('root' => $id == -1 ? NULL : $id));
             $tree->attach(hyperlink($url, escape_html($_title), false, false, do_lang_tempcode('VIRTUAL_ROOT')));
         } else {
             $tree->attach('<span>' . escape_html($_title) . '</span>');
         }
     } else {
         $tree = new ocp_tempcode();
         $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF');
         $catalogue_title = get_translated_text($catalogue['c_title']);
         $tree->attach(hyperlink($url, escape_html($catalogue_title), false, false, do_lang_tempcode('GO_BACKWARDS_TO', escape_html($catalogue_name))));
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         $tree->attach(escape_html($_title));
     }
     breadcrumb_add_segment($tree);
     if (is_null($root)) {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($is_ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES'))));
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $category['cc_add_date']), 'creator' => '', 'publisher' => '', 'modified' => '', 'type' => get_translated_text($catalogue['c_title']) . ' category', 'title' => $_title, 'identifier' => '_SEARCH:catalogues:category:' . strval($id), 'description' => get_translated_text($category['cc_description']));
     $rep_image_str = $category['rep_image'];
     if ($rep_image_str != '') {
         $GLOBALS['META_DATA'] += array('image' => (url_is_local($rep_image_str) ? get_custom_base_url() . '/' : '') . $rep_image_str);
     }
     $cart_link = new ocp_tempcode();
     if ($is_ecommerce) {
         if (get_forum_type() != 'ocf') {
             warn_exit(do_lang_tempcode('NO_OCF'));
         }
         require_code('shopping');
         require_lang('shopping');
         $cart_link = show_cart_image();
     }
     return do_template('CATALOGUE_' . $tpl_set . '_CATEGORY_SCREEN', array('ID' => strval($id), 'ADD_DATE_RAW' => strval($category['cc_add_date']), 'TITLE' => $title, '_TITLE' => $_title, 'TAGS' => get_loaded_tags('catalogue_categories'), 'CATALOGUE' => $catalogue_name, 'BROWSER' => $browser, 'SORTING' => $sorting, 'ADD_LINK' => $add_link, 'ADD_CAT_URL' => $add_cat_url, 'EDIT_CAT_URL' => $edit_cat_url, 'EDIT_CATALOGUE_URL' => $edit_catalogue_url, 'ENTRIES' => $entry_buildup, 'SUBCATEGORIES' => $subcategories, 'DESCRIPTION' => get_translated_tempcode($category['cc_description']), 'CART_LINK' => $cart_link, 'TREE' => $tree), NULL, false, 'CATALOGUE_DEFAULT_CATEGORY_SCREEN');
 }
コード例 #9
0
ファイル: news.php プロジェクト: erico-deh/ocPortal
 /**
  * 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));
 }