function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Prepare content for theme $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid))); $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); if (isset($categorypathprefix)) { $defaults['categorypathprefix'] = $categorypathprefix; } foreach ($questions as $question) { $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); if (!empty($fields['raw']['closedbyid'])) { $fields['closed'] = array('state' => qa_lang_html('main/closed')); } $qa_content['q_list']['qs'][] = $fields; } } else { $qa_content['title'] = $nonetitle; } if (isset($userid) && isset($categoryid)) { $favoritemap = qa_get_favorite_non_qs_map(); $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = $suggest; } if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) { $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams); } if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle)); } return $qa_content; }
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = array()) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; global $qa_login_userid, $qa_cookieid, $qa_request; // get globals from qa-page.php // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Prepare content for theme $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid))); $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'); $qa_content['q_list']['qs'] = array(); if (count($questions)) { $qa_content['title'] = $sometitle; $options = qa_post_html_defaults('Q'); if (isset($categorypathprefix)) { $options['categorypathprefix'] = $categorypathprefix; } foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, $options); } } else { $qa_content['title'] = $nonetitle; } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links($qa_request, $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = $suggest; } if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) { $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount); } if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle)); } return $qa_content; }
$qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/stats_title'); $qa_content['error'] = qa_admin_page_error(); $qa_content['form'] = array('style' => 'wide', 'fields' => array('q2a_version' => array('label' => qa_lang_html('admin/q2a_version'), 'value' => qa_html(QA_VERSION)), 'q2a_date' => array('label' => qa_lang_html('admin/q2a_build_date'), 'value' => qa_html(QA_BUILD_DATE)), 'q2a_latest' => array('label' => qa_lang_html('admin/q2a_latest_version'), 'type' => 'custom', 'html' => '<iframe src="http://www.question2answer.org/question2answer-latest.php?version=' . urlencode(QA_VERSION) . '&language=' . urlencode(qa_opt('site_language')) . '" width="100" height="16" style="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" scrolling="no" frameborder="0"></iframe>'), 'break0' => array('type' => 'blank'), 'db_version' => array('label' => qa_lang_html('admin/q2a_db_version'), 'value' => qa_html(qa_opt('db_version'))), 'db_size' => array('label' => qa_lang_html('admin/q2a_db_size'), 'value' => qa_html(number_format(qa_db_table_size() / 1048576, 1) . ' MB')), 'break1' => array('type' => 'blank'), 'php_version' => array('label' => qa_lang_html('admin/php_version'), 'value' => qa_html(phpversion())), 'mysql_version' => array('label' => qa_lang_html('admin/mysql_version'), 'value' => qa_html(qa_db_mysql_version())), 'break2' => array('type' => 'blank'), 'qcount' => array('label' => qa_lang_html('admin/total_qs'), 'value' => qa_html(number_format($qcount))), 'qcount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($qcount - $qcount_anon))), 'qcount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($qcount_anon))), 'break3' => array('type' => 'blank'), 'acount' => array('label' => qa_lang_html('admin/total_as'), 'value' => qa_html(number_format($acount))), 'acount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($acount - $acount_anon))), 'acount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($acount_anon))), 'break4' => array('type' => 'blank'), 'ccount' => array('label' => qa_lang_html('admin/total_cs'), 'value' => qa_html(number_format($ccount))), 'ccount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($ccount - $ccount_anon))), 'ccount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($ccount_anon))), 'break5' => array('type' => 'blank'), 'users' => array('label' => qa_lang_html('admin/users_registered'), 'value' => QA_FINAL_EXTERNAL_USERS ? '' : qa_html(number_format(qa_db_count_users()))), 'users_active' => array('label' => qa_lang_html('admin/users_active'), 'value' => qa_html(number_format((int) qa_opt('cache_userpointscount')))), 'users_posted' => array('label' => qa_lang_html('admin/users_posted'), 'value' => qa_html(number_format(qa_db_count_active_users('posts')))), 'users_voted' => array('label' => qa_lang_html('admin/users_voted'), 'value' => qa_html(number_format(qa_db_count_active_users('uservotes')))))); if (QA_FINAL_EXTERNAL_USERS) { unset($qa_content['form']['fields']['users']); } else { unset($qa_content['form']['fields']['users_active']); } foreach ($qa_content['form']['fields'] as $index => $field) { if (empty($field['type'])) { $qa_content['form']['fields'][$index]['type'] = 'static'; } } $qa_content['form_2'] = array('tags' => 'method="post" action="' . qa_path_html('admin/recalc') . '"', 'title' => qa_lang_html('admin/database_cleanup'), 'style' => 'basic', 'buttons' => array('recount_posts' => array('label' => qa_lang_html('admin/recount_posts'), 'tags' => 'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recount_posts_stop')) . ', \'recount_posts_note\');"', 'note' => '<span id="recount_posts_note">' . qa_lang_html('admin/recount_posts_note') . '</span>'), 'reindex_content' => array('label' => qa_lang_html('admin/reindex_content'), 'tags' => 'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/reindex_content_stop')) . ', \'reindex_content_note\');"', 'note' => '<span id="reindex_content_note">' . qa_lang_html('admin/reindex_content_note') . '</span>'), 'recalc_points' => array('label' => qa_lang_html('admin/recalc_points'), 'tags' => 'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_points_note\');"', 'note' => '<span id="recalc_points_note">' . qa_lang_html('admin/recalc_points_note') . '</span>'), 'refill_events' => array('label' => qa_lang_html('admin/refill_events'), 'tags' => 'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'refill_events_note\');"', 'note' => '<span id="refill_events_note">' . qa_lang_html('admin/refill_events_note') . '</span>'), 'recalc_categories' => array('label' => qa_lang_html('admin/recalc_categories'), 'tags' => 'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_categories_note\');"', 'note' => '<span id="recalc_categories_note">' . qa_lang_html('admin/recalc_categories_note') . '</span>'), 'delete_hidden' => array('label' => qa_lang_html('admin/delete_hidden'), 'tags' => 'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/delete_stop')) . ', \'delete_hidden_note\');"', 'note' => '<span id="delete_hidden_note">' . qa_lang_html('admin/delete_hidden_note') . '</span>')), 'hidden' => array('code' => qa_get_form_security_code('admin/recalc'))); if (!qa_using_categories()) { unset($qa_content['form_2']['buttons']['recalc_categories']); } if (defined('QA_BLOBS_DIRECTORY')) { if (qa_db_has_blobs_in_db()) { $qa_content['form_2']['buttons']['blobs_to_disk'] = array('label' => qa_lang_html('admin/blobs_to_disk'), 'tags' => 'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_disk_note\');"', 'note' => '<span id="blobs_to_disk_note">' . qa_lang_html('admin/blobs_to_disk_note') . '</span>'); } if (qa_db_has_blobs_on_disk()) { $qa_content['form_2']['buttons']['blobs_to_db'] = array('label' => qa_lang_html('admin/blobs_to_db'), 'tags' => 'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_db_note\');"', 'note' => '<span id="blobs_to_db_note">' . qa_lang_html('admin/blobs_to_db_note') . '</span>'); } } $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning'); $qa_content['navigation']['sub'] = qa_admin_sub_navigation(); return $qa_content; /*
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested) { $questionid = $question['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $htmloptions = qa_post_html_defaults('Q', true); $htmloptions['answersview'] = false; // answer count is displayed separately so don't show it here $htmloptions['avatarsize'] = qa_opt('avatar_q_page_q_size'); $q_view = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $htmloptions); $q_view['main_form_tags'] = 'METHOD="POST" ACTION="' . qa_self_html() . '"'; // Buttons for operating on the question if (!$formrequested) { // don't show if another form is currently being shown on page $clicksuffix = ' onClick="qa_show_waiting_after(this, false);"'; // add to operations that write to database $buttons = array(); if ($question['editbutton']) { $buttons['edit'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_q_popup')); } $hascategories = qa_using_categories(); if ($question['retagcatbutton']) { $buttons['retagcat'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html($hascategories ? 'question/recat_button' : 'question/retag_button'), 'popup' => qa_lang_html($hascategories ? qa_using_tags() ? 'question/retag_cat_popup' : 'question/recat_popup' : 'question/retag_popup')); } if ($question['flagbutton']) { $buttons['flag'] = array('tags' => 'NAME="q_doflag"' . $clicksuffix, 'label' => qa_lang_html($question['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_q_popup')); } if ($question['unflaggable']) { $buttons['unflag'] = array('tags' => 'NAME="q_dounflag"' . $clicksuffix, 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup')); } if ($question['clearflaggable']) { $buttons['clearflags'] = array('tags' => 'NAME="q_doclearflags"' . $clicksuffix, 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup')); } if ($question['closeable']) { $buttons['close'] = array('tags' => 'NAME="q_doclose"', 'label' => qa_lang_html('question/close_button'), 'popup' => qa_lang_html('question/close_q_popup')); } if ($question['reopenable']) { $buttons['reopen'] = array('tags' => 'NAME="q_doreopen"' . $clicksuffix, 'label' => qa_lang_html('question/reopen_button')); } if ($question['moderatable']) { $buttons['approve'] = array('tags' => 'NAME="q_doapprove"' . $clicksuffix, 'label' => qa_lang_html('question/approve_button')); $buttons['reject'] = array('tags' => 'NAME="q_doreject"' . $clicksuffix, 'label' => qa_lang_html('question/reject_button')); } if ($question['hideable']) { $buttons['hide'] = array('tags' => 'NAME="q_dohide"' . $clicksuffix, 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_q_popup')); } if ($question['reshowable']) { $buttons['reshow'] = array('tags' => 'NAME="q_doreshow"' . $clicksuffix, 'label' => qa_lang_html('question/reshow_button')); } if ($question['deleteable']) { $buttons['delete'] = array('tags' => 'NAME="q_dodelete"' . $clicksuffix, 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_q_popup')); } if ($question['claimable']) { $buttons['claim'] = array('tags' => 'NAME="q_doclaim"' . $clicksuffix, 'label' => qa_lang_html('question/claim_button')); } if ($question['answerbutton']) { // don't show if shown by default $buttons['answer'] = array('tags' => 'NAME="q_doanswer" ID="q_doanswer" onClick="return qa_toggle_element(\'anew\')"', 'label' => qa_lang_html('question/answer_button'), 'popup' => qa_lang_html('question/answer_q_popup')); } if ($question['commentbutton']) { $buttons['comment'] = array('tags' => 'NAME="q_docomment" onClick="return qa_toggle_element(\'c' . $questionid . '\')"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_q_popup')); } $q_view['form'] = array('style' => 'light', 'buttons' => $buttons, 'hidden' => array('qa_click' => '')); } // Information about the question of the answer that this question follows on from (or a question directly) if (isset($parentquestion)) { $q_view['follows'] = array('label' => qa_lang_html($question['parentid'] == $parentquestion['postid'] ? 'question/follows_q' : 'question/follows_a'), 'title' => qa_html(qa_block_words_replace($parentquestion['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($parentquestion['postid'], $parentquestion['title'], false, $question['parentid'] == $parentquestion['postid'] ? 'Q' : 'A', $question['parentid'])); } // Information about the question that this question is a duplicate of (if appropriate) if (isset($closepost)) { if ($closepost['basetype'] == 'Q') { $q_view['closed'] = array('label' => qa_lang_html('question/closed_as_duplicate'), 'content' => qa_html(qa_block_words_replace($closepost['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($closepost['postid'], $closepost['title'])); } elseif ($closepost['type'] == 'NOTE') { $viewer = qa_load_viewer($closepost['content'], $closepost['format']); $q_view['closed'] = array('label' => qa_lang_html('question/closed_with_note'), 'content' => $viewer->get_html($closepost['content'], $closepost['format'], array('blockwordspreg' => qa_get_block_words_preg()))); } } // Extra value display if (strlen(@$question['extra']) && qa_opt('extra_field_active') && qa_opt('extra_field_display')) { $q_view['extra'] = array('label' => qa_html(qa_opt('extra_field_label')), 'content' => qa_html(qa_block_words_replace($question['extra'], qa_get_block_words_preg()))); } return $q_view; }
case 'permit_retag_cat': case 'permit_edit_a': case 'permit_edit_c': case 'permit_edit_silent': case 'permit_flag': case 'permit_close_q': case 'permit_select_a': case 'permit_hide_show': case 'permit_moderate': case 'permit_delete_hidden': case 'permit_anon_view_ips': case 'permit_view_voters_flaggers': case 'permit_post_wall': $dopoints = true; if ($optionname == 'permit_retag_cat') { $optionfield['label'] = qa_lang_html(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag') . ':'; } else { $optionfield['label'] = qa_lang_html('profile/' . $optionname) . ':'; } if ($optionname == 'permit_view_q_page' || $optionname == 'permit_post_q' || $optionname == 'permit_post_a' || $optionname == 'permit_post_c' || $optionname == 'permit_anon_view_ips') { $widest = QA_PERMIT_ALL; } elseif ($optionname == 'permit_close_q' || $optionname == 'permit_select_a' || $optionname == 'permit_moderate' || $optionname == 'permit_hide_show') { $widest = QA_PERMIT_POINTS; } elseif ($optionname == 'permit_delete_hidden') { $widest = QA_PERMIT_EDITORS; } elseif ($optionname == 'permit_view_voters_flaggers' || $optionname == 'permit_edit_silent') { $widest = QA_PERMIT_EXPERTS; } else { $widest = QA_PERMIT_USERS; } if ($optionname == 'permit_view_q_page') {
function qa_get_permit_options() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $permits = array('permit_view_q_page', 'permit_post_q', 'permit_post_a'); if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) { $permits[] = 'permit_post_c'; } if (qa_opt('voting_on_qs')) { $permits[] = 'permit_vote_q'; } if (qa_opt('voting_on_as')) { $permits[] = 'permit_vote_a'; } if (qa_opt('voting_on_qs') || qa_opt('voting_on_as')) { $permits[] = 'permit_vote_down'; } if (qa_using_tags() || qa_using_categories()) { $permits[] = 'permit_retag_cat'; } array_push($permits, 'permit_edit_q', 'permit_edit_a'); if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) { $permits[] = 'permit_edit_c'; } if (qa_opt('allow_close_questions')) { $permits[] = 'permit_close_q'; } array_push($permits, 'permit_select_a', 'permit_anon_view_ips'); if (qa_opt('flagging_of_posts')) { $permits[] = 'permit_flag'; } $permits[] = 'permit_moderate'; array_push($permits, 'permit_hide_show', 'permit_delete_hidden'); return $permits; }
function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepost, &$in, &$errors) { $in = array(); if ($question['editable']) { $in['title'] = qa_post_text('q_title'); qa_get_post_content('q_editor', 'q_content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('q_extra') : null; } if ($question['retagcatable']) { if (qa_using_tags()) { $in['tags'] = qa_get_tags_field_value('q_tags'); } if (qa_using_categories()) { $in['categoryid'] = qa_get_category_field_value('q_category'); } } if (array_key_exists('categoryid', $in)) { // need to check if we can move it to that category, and if we need moderation $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec($in['categoryid'], true)); $categoryids = array_keys(qa_category_path($categories, $in['categoryid'])); $userlevel = qa_user_level_for_categories($categoryids); } else { $userlevel = null; } if ($question['isbyuser']) { $in['name'] = qa_post_text('q_name'); $in['notify'] = qa_post_text('q_notify') ? true : false; $in['email'] = qa_post_text('q_email'); } if (!qa_user_post_permit_error('permit_edit_silent', $question)) { $in['silent'] = qa_post_text('q_silent'); } // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters $errors = array(); if (!qa_check_form_security_code('edit-' . $question['postid'], qa_post_text('code'))) { $errors['page'] = qa_lang_html('misc/form_security_again'); } else { $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason($userlevel); $filtermodules = qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_question($in, $errors, $question); if ($question['editable']) { qa_update_post_text($in, $oldin); } } if (array_key_exists('categoryid', $in) && strcmp($in['categoryid'], $question['categoryid'])) { if (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); // now we fill in the missing values in the $in array, so that we have everything we need for qa_question_set_content() // we do things in this way to avoid any risk of a validation failure on elements the user can't see (e.g. due to admin setting changes) if (!$question['editable']) { $in['title'] = $question['title']; $in['content'] = $question['content']; $in['format'] = $question['format']; $in['text'] = qa_viewer_text($in['content'], $in['format']); $in['extra'] = $question['extra']; } if (!isset($in['tags'])) { $in['tags'] = qa_tagstring_to_tags($question['tags']); } if (!array_key_exists('categoryid', $in)) { $in['categoryid'] = $question['categoryid']; } if (!isset($in['silent'])) { $in['silent'] = false; } $setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify']; qa_question_set_content($question, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $setnotify, $userid, $handle, $cookieid, $in['extra'], @$in['name'], $in['queued'], $in['silent']); if (qa_using_categories() && strcmp($in['categoryid'], $question['categoryid'])) { qa_question_set_category($question, $in['categoryid'], $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost, $in['silent']); } return true; } } return false; }
unset($qa_content['form_profile']['fields']['avatar']); } // Private message form if (qa_opt('allow_private_messages') && isset($loginuserid) && $loginuserid != $userid && !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES)) { $qa_content['form_profile']['fields']['level']['value'] .= strtr(qa_lang_html('profile/send_private_message'), array('^1' => '<A HREF="' . qa_path_html('message/' . $handle) . '">', '^2' => '</A>')); } // Show any extra privileges due to user's level or their points $showpermits = array(); $permitoptions = qa_get_permit_options(); foreach ($permitoptions as $permitoption) { if (qa_opt($permitoption) < QA_PERMIT_CONFIRMED) { // if it's not available to all users (after they've confirmed their email address) if (!qa_permit_error($permitoption, $userid, $useraccount['level'], $useraccount['flags'], $userpoints['points'])) { // but this user can if ($permitoption == 'permit_retag_cat') { $showpermits[] = qa_lang(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag'); } else { $showpermits[] = qa_lang('profile/' . $permitoption); } // then show it as an extra priviliege } } } if (count($showpermits)) { $qa_content['form_profile']['fields']['permits'] = array('type' => 'static', 'label' => qa_lang_html('profile/extra_privileges'), 'value' => qa_html(implode("\n", $showpermits), true), 'rows' => count($showpermits)); } // Show email address only if we're an administrator if ($loginlevel >= QA_USER_LEVEL_ADMIN && !qa_user_permit_error()) { $doconfirms = qa_opt('confirm_user_emails') && $useraccount['level'] < QA_USER_LEVEL_EXPERT; $isconfirmed = $useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED ? true : false; $qa_content['form_profile']['fields']['email'] = array('type' => $userediting ? 'text' : 'static', 'label' => qa_lang_html('users/email_label'), 'tags' => 'NAME="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => qa_html(@$errors['email']), 'note' => ($doconfirms ? qa_lang_html($isconfirmed ? 'users/email_confirmed' : 'users/email_not_confirmed') . ' ' : '') . qa_lang_html('users/only_shown_admins'));
function header() { $this->cs_position('Top'); $this->output('<header id="site-header" class="clearfix">', '<div class="qa-navbar navbar-default' . (qa_opt('cs_nav_fixed') ? ' navbar-fixed-top ' : '') . '" role="navigation">'); $this->output('<a href="#" class="slide-mobile-menu icon-list"></a>'); $this->logo(); if (qa_opt('cs_enable_ask_button')) { $this->output('<a id="nav-ask-btn" href="' . qa_path_html('ask') . '" class="btn btn-sm">' . qa_lang_html('cleanstrap/ask_question') . '</a>'); $this->output('<a id="nav-ask-btn" href="' . qa_path_html('ask') . '" class="btn btn-sm header-ask-button icon-question-sign"></a>'); } if (qa_opt('cs_enable_category_nav') && qa_using_categories()) { $this->cat_drop_nav(); } $this->head_nav(); $this->user_drop_nav(); $this->search(); $this->output('</div>', '</header>'); }
function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepost, &$in, &$errors) { $in = array(); if ($question['editable']) { $in['title'] = qa_post_text('q_title'); qa_get_post_content('q_editor', 'q_content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('q_extra') : null; } if ($question['retagcatable']) { if (qa_using_tags()) { $in['tags'] = qa_get_tags_field_value('q_tags'); } if (qa_using_categories()) { $in['categoryid'] = qa_get_category_field_value('q_category'); } } if ($question['isbyuser']) { $in['notify'] = qa_post_text('q_notify') ? true : false; $in['email'] = qa_post_text('q_email'); } // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters $errors = array(); $filtermodules = qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_question($in, $errors, $question); if ($question['editable']) { qa_update_post_text($in, $oldin); } } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); // now we fill in the missing values in the $in array, so that we have everything we need for qa_question_set_content() // we do things in this way to avoid any risk of a validation failure on elements the user can't see (e.g. due to admin setting changes) if (!$question['editable']) { $in['title'] = $question['title']; $in['content'] = $question['content']; $in['format'] = $question['format']; $in['text'] = qa_viewer_text($in['content'], $in['format']); $in['extra'] = $question['extra']; } if (!isset($in['tags'])) { $in['tags'] = qa_tagstring_to_tags($question['tags']); } if (!array_key_exists('categoryid', $in)) { $in['categoryid'] = $question['categoryid']; } $setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify']; qa_question_set_content($question, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $setnotify, $userid, $handle, $cookieid, $in['extra']); if (qa_using_categories() && strcmp($in['categoryid'], $question['categoryid'])) { qa_question_set_category($question, $in['categoryid'], $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost); } return true; } return false; }
return $qa_content; } // Process input $usecaptcha = qa_user_use_captcha('captcha_on_anon_post'); $intitle = qa_post_text('title'); // allow title and tags to be posted by an external form $intags = qa_get_tags_field_value('tags'); if (qa_clicked('doask')) { require_once QA_INCLUDE_DIR . 'qa-app-post-create.php'; require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $innotify = qa_post_text('notify') ? true : false; $inemail = qa_post_text('email'); qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $tagstring = qa_tags_to_tagstring($intags); $errors = qa_question_validate($intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail); if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($incategoryid)) { $errors['category'] = qa_lang_html('question/category_required'); } if ($usecaptcha) { require_once 'qa-app-captcha.php'; qa_captcha_validate($_POST, $errors); } if (empty($errors)) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary $questionid = qa_question_create($followanswer, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail, $incategoryid); qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_post', $questionid, null, null); qa_redirect(qa_q_request($questionid, $intitle)); // our work is done here
function qa_content_prepare($voting = false, $categoryids = null) { global $qa_root_url_relative, $qa_request, $qa_template, $qa_login_userid, $qa_vote_error_html, $qa_nav_pages_cached, $qa_widgets_cached, $QA_CONST_ROUTING; if (QA_DEBUG_PERFORMANCE) { qa_usage_mark('control'); } if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $qa_content = array('content_type' => 'text/html; charset=utf-8', 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($qa_nav_pages_cached as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users')); } if (qa_user_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html(isset($_COOKIE['qa_admin_last']) && isset($QA_CONST_ROUTING[$_COOKIE['qa_admin_last']]) ? $_COOKIE['qa_admin_last'] : 'admin'), 'label' => qa_lang_html('main/nav_admin')); } $qa_content['search'] = array('form_tags' => 'METHOD="GET" ACTION="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'NAME="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($qa_nav_pages_cached as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($qa_widgets_cached as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template($qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link" TITLE="' . qa_html(qa_opt('site_title')) . '">' . '<IMG SRC="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : $qa_root_url_relative . $logourl) . '"' . ($logowidth ? ' WIDTH="' . $logowidth . '"' : '') . ($logoheight ? ' HEIGHT="' . $logoheight . '"' : '') . ' BORDER="0"/></A>'; } else { $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</A>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links($qa_root_url_relative, isset($topath) ? $topath : qa_path($qa_request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (isset($qa_login_userid)) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), $qa_root_url_relative, false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); if (!QA_FINAL_EXTERNAL_USERS) { $qa_content['navigation']['user']['account'] = array('url' => qa_path_html('account'), 'label' => qa_lang_html('main/nav_account')); } if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $modulenames = qa_list_modules('login'); foreach ($modulenames as $tryname) { $module = qa_load_module('login', $tryname); if (method_exists($module, 'match_source') && $module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } } else { $modulenames = qa_list_modules('login'); foreach ($modulenames as $tryname) { $module = qa_load_module('login', $tryname); if (method_exists($module, 'login_html')) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($qa_request, $_GET, qa_opt('site_url')), 'menu'); $qa_content['navigation']['user'][$tryname] = array('label' => ob_get_clean()); } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } $qa_content['script_rel'] = array('qa-content/jquery-1.6.1.min.js'); if ($voting) { $qa_content['error'] = @$qa_vote_error_html; $qa_content['script_rel'][] = 'qa-content/qa-votes.js?' . QA_VERSION; } $qa_content['script_var'] = array('qa_root' => $qa_root_url_relative, 'qa_request' => $qa_request); return $qa_content; }
function qa_admin_sub_navigation() { $navigation = array('admin$' => array('label' => qa_lang('admin/general_title'), 'url' => qa_path_html('admin')), 'admin/emails' => array('label' => qa_lang('admin/emails_title'), 'url' => qa_path_html('admin/emails')), 'admin/user' => array('label' => qa_lang('admin/users_title'), 'url' => qa_path_html('admin/users')), 'admin/layout' => array('label' => qa_lang('admin/layout_title'), 'url' => qa_path_html('admin/layout')), 'admin/lists' => array('label' => qa_lang('admin/lists_title'), 'url' => qa_path_html('admin/lists')), 'admin/viewing' => array('label' => qa_lang('admin/viewing_title'), 'url' => qa_path_html('admin/viewing')), 'admin/posting' => array('label' => qa_lang('admin/posting_title'), 'url' => qa_path_html('admin/posting')), 'admin/categories' => array('label' => qa_lang('admin/categories_title'), 'url' => qa_path_html('admin/categories')), 'admin/permissions' => array('label' => qa_lang('admin/permissions_title'), 'url' => qa_path_html('admin/permissions')), 'admin/pages' => array('label' => qa_lang('admin/pages_title'), 'url' => qa_path_html('admin/pages')), 'admin/feeds' => array('label' => qa_lang('admin/feeds_title'), 'url' => qa_path_html('admin/feeds')), 'admin/points' => array('label' => qa_lang('admin/points_title'), 'url' => qa_path_html('admin/points')), 'admin/spam' => array('label' => qa_lang('admin/spam_title'), 'url' => qa_path_html('admin/spam')), 'admin/hidden' => array('label' => qa_lang('admin/hidden_title'), 'url' => qa_path_html('admin/hidden')), 'admin/stats' => array('label' => qa_lang('admin/stats_title'), 'url' => qa_path_html('admin/stats')), 'admin/plugins' => array('label' => qa_lang('admin/plugins_title'), 'url' => qa_path_html('admin/plugins'))); if (!qa_using_categories()) { unset($navigation['admin/categories']); } return $navigation; }
$categoryslugs = null; } break; case 'search': if (strlen(@$feedparams[0])) { $feedoption = 'feed_for_search'; $categoryslugs = null; } break; } $countslugs = @count($categoryslugs); if (!isset($feedoption)) { qa_feed_not_found(); } // Check that all the appropriate options are in place to allow this feed to be retrieved if (!(qa_opt($feedoption) && ($countslugs ? qa_using_categories() && qa_opt('feed_per_category') : true))) { qa_feed_not_found(); } // Retrieve the appropriate questions and other information for this feed require_once QA_INCLUDE_DIR . 'db/selects.php'; $sitetitle = qa_opt('site_title'); $siteurl = qa_opt('site_url'); $full = qa_opt('feed_full_text'); $count = qa_opt('feed_number_items'); $showurllinks = qa_opt('show_url_links'); $linkrequest = $feedtype . ($countslugs ? '/' . implode('/', $categoryslugs) : ''); $linkparams = null; switch ($feedtype) { case 'questions': $questions = qa_feed_load_ifcategory($categoryslugs, 'main/recent_qs_title', 'main/recent_qs_in_x', $title, qa_db_qs_selectspec(null, 'created', 0, $categoryslugs, null, false, $full, $count)); break;
function qa_content_prepare($voting = false, $categoryids = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_template, $qa_page_error_html; if (QA_DEBUG_PERFORMANCE) { global $qa_usage; $qa_usage->mark('control'); } $request = qa_request(); $requestlower = qa_request(); $navpages = qa_db_get_pending_result('navpages'); $widgets = qa_db_get_pending_result('widgets'); if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $charset = 'utf-8'; $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($navpages as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/')); } // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/')); } $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($navpages as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($widgets as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>'; } else { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (qa_is_logged_in()) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates')); if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $loginmodules = qa_load_modules_with('login', 'match_source'); foreach ($loginmodules as $module) { if ($module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } $notices = qa_db_get_pending_result('notices'); foreach ($notices as $notice) { $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; if (!QA_FINAL_EXTERNAL_USERS) { $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); $label = ob_get_clean(); if (strlen($label)) { $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label); } } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) { if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) { $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor')); } } else { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); // don't show first-time notice if a user has logged in if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) { if ($requestlower != 'confirm' && $requestlower != 'account') { // let people finish registering in peace $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome')); } } } $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js'); $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION; if ($voting) { $qa_content['error'] = @$qa_page_error_html; } $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request); return $qa_content; }
function process_request($request) { //@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML if ($request == 'sitemap.xml') { $req = ''; } else { $req_str = substr($request, 8, strlen($request) - 12); // extract "X-Y-Z" from "sitemap-X-Y-Z.xml" $req = explode('-', $req_str); } $siteurl = qa_opt('site_url'); header('Content-type: text/xml; charset=utf-8'); // Index Pages // Indexed all XML sitemaps for question's lists // example: sitemap.xml if ($req == '') { $this->sitemap_index_header(); $q_sitemaps = qa_db_read_one_assoc(qa_db_query_sub("SELECT count(*) as total from ^posts WHERE type='Q'")); $count = qa_opt('useo_sitemap_question_count'); $q_sitemap_count = ceil($q_sitemaps['total'] / $count); for ($i = 0; $i < $q_sitemap_count; $i++) { $this->sitemap_index_output('sitemap-' . $i . '.xml'); } $this->sitemap_index_footer(); } // Indexed all important XML sitemaps // example: sitemap-index.xml if (count($req) == 1 && $req[0] == 'index') { $this->sitemap_index_header(); $this->sitemap_index(); $this->sitemap_index_footer(); } // Indexed all XML sitemaps, including categories question page // example: sitemap-index.xml if (count($req) == 1 && $req[0] == 'all') { $this->sitemap_index_header(); $this->sitemap_all(); $this->sitemap_index_footer(); } // Question pages // numbered question sitenaps // example: sitemap-1.xml, sitemap-12.xml if (count($req) == 1 && strval((int) $req[0]) == $req[0]) { $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'")); $count = qa_opt('useo_sitemap_question_count'); $start = (int) $req[0] * $count; $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE type='Q' ORDER BY postid LIMIT #,#", $start, $count)); if (count($questions)) { $this->sitemap_header(); foreach ($questions as $question) { $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread'])); } $this->sitemap_footer(); } } //User pages if ($req[0] == 'users' && !QA_FINAL_EXTERNAL_USERS && qa_opt('useo_sitemap_users_enable')) { // user's numbered sitemaps // example: sitemap-users-1.xml, sitemap-users-12.xml if (isset($req[1]) && strval((int) $req[1]) == $req[1] && (int) qa_opt('useo_sitemap_users_count') != 0) { $count = qa_opt('useo_sitemap_users_count'); $start = (int) $req[1] * $count; $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users ORDER BY userid LIMIT #,#", $start, $count)); if (count($users)) { $this->sitemap_header(); foreach ($users as $user) { $this->sitemap_output('user/' . $user['handle'], 0.25); } $this->sitemap_footer(); } } else { // All users sitemap // example: sitemap-users.xml if (!isset($req[1])) { $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users ORDER BY userid")); if (count($users)) { $this->sitemap_header(); foreach ($users as $user) { $this->sitemap_output('user/' . $user['handle'], 0.25); } $this->sitemap_footer(); } } } } // Tag pages if ($req[0] == 'tags' && qa_using_tags() && qa_opt('useo_sitemap_tags_enable')) { // link to each tag's page sitemaps // example: sitemap-tags-1.xml, sitemap-tags-12.xml if (isset($req[1]) && strval((int) $req[1]) == $req[1] && (int) qa_opt('useo_sitemap_tags_count') != 0) { $count = qa_opt('useo_sitemap_tags_count'); $start = (int) $req[1] * $count; $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE tagcount>0 ORDER BY wordid LIMIT #,#", $start, $count)); if (count($tagwords)) { $this->sitemap_header(); foreach ($tagwords as $tagword) { $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount'])); // priority between 0.25 and 0.5 depending on tag frequency } $this->sitemap_footer(); } } else { // link to all tags in sitemaps // example: sitemap-tags.xml if (!isset($req[1])) { $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE tagcount>0 ORDER BY wordid")); if (count($tagwords)) { $this->sitemap_header(); foreach ($tagwords as $tagword) { $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount'])); // priority between 0.25 and 0.5 depending on tag frequency } $this->sitemap_footer(); } } } } // link to all category pages if ($req[0] == 'category' && !isset($req[1]) && qa_using_categories() && qa_opt('useo_sitemap_categories_enable')) { $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT categoryid, backpath FROM ^categories WHERE qcount>0 ORDER BY categoryid")); if (count($categories)) { $this->sitemap_header(); foreach ($categories as $category) { $this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); } $this->sitemap_footer(); } } // sitemap for category questions if ($req[0] == 'category' && isset($req[1]) && qa_using_categories() && qa_opt('useo_sitemap_categoriy_q_enable')) { $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'")); if (count($req) >= 3) { //because: "category-x-x-x-x-1" | 1 category + 1 sount + at least 1 category = 3 // link to questions in a category or sub category // example: sitemap-category-RootCat-SubCat-2.xml // it's always numbered, "sitemap-category-RootCat-SubCat.xml" is NOT ALLOWED $slug_list = array_splice($req, 1, -1); $slug = implode("/", array_reverse($slug_list)); $count = qa_opt('useo_sitemap_categoriy_q_count'); $start = (int) $req[count($req) - 1] * $count; $questions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, hotness FROM ^posts WHERE ^posts.type=$ AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) ORDER BY ^posts.created DESC LIMIT #,#', 'Q', $slug, $start, $count)); } else { // link to all questions in a category // example: sitemap-category-RootCat.xml $slug = $req[1]; $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE ^posts.type=\$\n\t\t\t\t\t\tAND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=\$ LIMIT 1) \n\t\t\t\t\t\tORDER BY ^posts.created DESC", 'Q', $slug)); } if (count($questions)) { $this->sitemap_header(); } foreach ($questions as $question) { $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread'])); } $this->sitemap_footer(); } // Pages in category browser if (qa_using_categories() && qa_opt('useo_sitemap_categories_enable')) { $this->sitemap_output('categories', 0.5); $nextcategoryid = 0; $this->sitemap_header(); while (1) { // only find categories with a child $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " . "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", $nextcategoryid)); if (!count($categories)) { break; } foreach ($categories as $category) { $this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1); } } $this->sitemap_footer(); } // Finish up... return null; }
function user_priv_form() { // displays badge list in user profile global $qa_request; $handle = preg_replace('/^[^\\/]+\\/([^\\/]+).*/', "\$1", $qa_request); $userid = $this->priv_getuserfromhandle($handle); if (!$userid) { return; } $options = qa_get_permit_options(); $user = qa_db_select_with_pending(qa_db_user_points_selectspec($userid, true)); $upoints = (int) $user['points']; foreach ($options as $option) { if (qa_opt($option) == QA_PERMIT_POINTS) { $opoints = (int) qa_opt($option . '_points'); $popts[$option] = $opoints; } } if (!isset($popts)) { return; } arsort($popts); $fields = array(); foreach ($popts as $key => $val) { if ($upoints > $val) { $ppoints = 100; } else { $ppoints = round($upoints / $val * 100); } // shading if (qa_opt('priv_shading') == 0) { if ($ppoints <= 50) { $col = round($ppoints / 50 * 255); $col = dechex($col); if (strlen($col) == 1) { $col = '0' . $col; } $col = '#' . 'FF' . $col . '00'; } else { $col = round(($ppoints - 50) / 50 * 255) * -1 + 255; $col = dechex($col); if (strlen($col) == 1) { $col = '0' . $col; } $col = '#' . $col . 'FF' . '00'; } } else { $col = (255 - round($ppoints / 100 * 255)) * 3 / 4; $col = dechex($col); if (strlen($col) == 1) { $col = '0' . $col; } $col = '#' . $col . $col . $col; } // hover text if ($ppoints == 100) { $hover = str_replace('#', $val, qa_opt('priv_hover_earned')); } else { $hover = str_replace('#', $val, qa_opt('priv_hover')); $hover = str_replace('%', $ppoints, $hover); } // fudge if ($key == 'permit_retag_cat') { $name = qa_lang_html(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag'); } else { $name = qa_lang('profile/' . $key); } if ($name == '[profile/' . $key . ']') { global $qa_lang_file_pattern; foreach ($qa_lang_file_pattern as $k => $v) { if (qa_lang($k . '/' . $key) != '[' . $k . '/' . $key . ']') { $name = qa_lang($k . '/' . $key); break; } } } $text[] = ($ppoints == 100 ? '<b ' : '<font ') . 'title="' . $hover . '" style="color:' . $col . '; cursor:pointer">' . $name . '</td><td class="qa-form-tall-label">' . ($ppoints == 100 ? '<b ' : '<font ') . 'title="' . $hover . '" style="color:' . $col . '; cursor:pointer">' . $ppoints . '%'; } $fields[] = array('label' => implode('</td></tr><tr class="priv-row"><td class="qa-form-tall-label">', $text), 'type' => 'static'); $ok = null; $tags = null; $buttons = array(); return array('ok' => $ok && !isset($error) ? $ok : null, 'style' => 'tall', 'tags' => $tags, 'title' => qa_opt('priv_title'), 'fields' => $fields, 'buttons' => $buttons); }
public function process_request($request) { @ini_set('display_errors', 0); // we don't want to show PHP errors inside XML header('Content-type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; // Question pages if (qa_opt('xml_sitemap_show_questions')) { $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'")); $nextpostid = 0; while (1) { $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100", $nextpostid)); if (!count($questions)) { break; } foreach ($questions as $question) { $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread'])); $nextpostid = max($nextpostid, $question['postid'] + 1); } } } // User pages if (!QA_FINAL_EXTERNAL_USERS && qa_opt('xml_sitemap_show_users')) { $nextuserid = 0; while (1) { $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100", $nextuserid)); if (!count($users)) { break; } foreach ($users as $user) { $this->sitemap_output('user/' . $user['handle'], 0.25); $nextuserid = max($nextuserid, $user['userid'] + 1); } } } // Tag pages if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) { $nextwordid = 0; while (1) { $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100", $nextwordid)); if (!count($tagwords)) { break; } foreach ($tagwords as $tagword) { $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount'])); // priority between 0.25 and 0.5 depending on tag frequency $nextwordid = max($nextwordid, $tagword['wordid'] + 1); } } } // Question list for each category if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) { $nextcategoryid = 0; while (1) { $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2", $nextcategoryid)); if (!count($categories)) { break; } foreach ($categories as $category) { $this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1); } } } // Pages in category browser if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) { $this->sitemap_output('categories', 0.5); $nextcategoryid = 0; while (1) { // only find categories with a child $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " . "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", $nextcategoryid)); if (!count($categories)) { break; } foreach ($categories as $category) { $this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5); $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1); } } } echo "</urlset>\n"; return null; }
function qa_admin_sub_navigation() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $navigation = array(); $level = qa_get_logged_in_level(); if ($level >= QA_USER_LEVEL_ADMIN) { $navigation['admin/general'] = array('label' => qa_lang_html('admin/general_title'), 'url' => qa_path_html('admin/general')); $navigation['admin/emails'] = array('label' => qa_lang_html('admin/emails_title'), 'url' => qa_path_html('admin/emails')); $navigation['admin/users'] = array('label' => qa_lang_html('admin/users_title'), 'url' => qa_path_html('admin/users'), 'selected_on' => array('admin/users$', 'admin/userfields$', 'admin/usertitles$')); if ($level >= QA_USER_LEVEL_SUPER) { $navigation['admin/layout'] = array('label' => qa_lang_html('admin/layout_title'), 'url' => qa_path_html('admin/layout')); } $navigation['admin/posting'] = array('label' => qa_lang_html('admin/posting_title'), 'url' => qa_path_html('admin/posting')); $navigation['admin/viewing'] = array('label' => qa_lang_html('admin/viewing_title'), 'url' => qa_path_html('admin/viewing')); $navigation['admin/lists'] = array('label' => qa_lang_html('admin/lists_title'), 'url' => qa_path_html('admin/lists')); if (qa_using_categories()) { $navigation['admin/categories'] = array('label' => qa_lang_html('admin/categories_title'), 'url' => qa_path_html('admin/categories')); } $navigation['admin/permissions'] = array('label' => qa_lang_html('admin/permissions_title'), 'url' => qa_path_html('admin/permissions')); if ($level >= QA_USER_LEVEL_SUPER) { $navigation['admin/pages'] = array('label' => qa_lang_html('admin/pages_title'), 'url' => qa_path_html('admin/pages')); } $navigation['admin/feeds'] = array('label' => qa_lang_html('admin/feeds_title'), 'url' => qa_path_html('admin/feeds')); $navigation['admin/points'] = array('label' => qa_lang_html('admin/points_title'), 'url' => qa_path_html('admin/points')); $navigation['admin/spam'] = array('label' => qa_lang_html('admin/spam_title'), 'url' => qa_path_html('admin/spam')); if ($level >= QA_USER_LEVEL_SUPER) { $navigation['admin/stats'] = array('label' => qa_lang_html('admin/stats_title'), 'url' => qa_path_html('admin/stats')); } if (!QA_FINAL_EXTERNAL_USERS) { $navigation['admin/mailing'] = array('label' => qa_lang_html('admin/mailing_title'), 'url' => qa_path_html('admin/mailing')); } if ($level >= QA_USER_LEVEL_SUPER) { $navigation['admin/plugins'] = array('label' => qa_lang_html('admin/plugins_title'), 'url' => qa_path_html('admin/plugins')); } } if (!qa_user_maximum_permit_error('permit_moderate')) { $count = qa_user_permit_error('permit_moderate') ? null : qa_opt('cache_queuedcount'); // if only in some categories don't show cached count $navigation['admin/moderate'] = array('label' => qa_lang_html('admin/moderate_title') . ($count ? ' (' . $count . ')' : ''), 'url' => qa_path_html('admin/moderate')); } if (qa_opt('flagging_of_posts') && !qa_user_maximum_permit_error('permit_hide_show')) { $count = qa_user_permit_error('permit_hide_show') ? null : qa_opt('cache_flaggedcount'); // if only in some categories don't show cached count $navigation['admin/flagged'] = array('label' => qa_lang_html('admin/flagged_title') . ($count ? ' (' . $count . ')' : ''), 'url' => qa_path_html('admin/flagged')); } if (!qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $navigation['admin/hidden'] = array('label' => qa_lang_html('admin/hidden_title'), 'url' => qa_path_html('admin/hidden')); } if (!QA_FINAL_EXTERNAL_USERS && qa_opt('moderate_users') && $level >= QA_USER_LEVEL_MODERATOR) { $count = qa_opt('cache_uapprovecount'); $navigation['admin/approve'] = array('label' => qa_lang_html('admin/approve_users_title') . ($count ? ' (' . $count . ')' : ''), 'url' => qa_path_html('admin/approve')); } return $navigation; }
function qa_admin_sub_navigation() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $navigation = array(); if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $navigation['admin/general'] = array('label' => qa_lang_html('admin/general_title'), 'url' => qa_path_html('admin/general')); $navigation['admin/emails'] = array('label' => qa_lang_html('admin/emails_title'), 'url' => qa_path_html('admin/emails')); $navigation['admin/user'] = array('label' => qa_lang_html('admin/users_title'), 'url' => qa_path_html('admin/users')); $navigation['admin/layout'] = array('label' => qa_lang_html('admin/layout_title'), 'url' => qa_path_html('admin/layout')); $navigation['admin/posting'] = array('label' => qa_lang_html('admin/posting_title'), 'url' => qa_path_html('admin/posting')); $navigation['admin/viewing'] = array('label' => qa_lang_html('admin/viewing_title'), 'url' => qa_path_html('admin/viewing')); $navigation['admin/lists'] = array('label' => qa_lang_html('admin/lists_title'), 'url' => qa_path_html('admin/lists')); if (qa_using_categories()) { $navigation['admin/categories'] = array('label' => qa_lang_html('admin/categories_title'), 'url' => qa_path_html('admin/categories')); } $navigation['admin/permissions'] = array('label' => qa_lang_html('admin/permissions_title'), 'url' => qa_path_html('admin/permissions')); $navigation['admin/pages'] = array('label' => qa_lang_html('admin/pages_title'), 'url' => qa_path_html('admin/pages')); $navigation['admin/feeds'] = array('label' => qa_lang_html('admin/feeds_title'), 'url' => qa_path_html('admin/feeds')); $navigation['admin/points'] = array('label' => qa_lang_html('admin/points_title'), 'url' => qa_path_html('admin/points')); $navigation['admin/spam'] = array('label' => qa_lang_html('admin/spam_title'), 'url' => qa_path_html('admin/spam')); $navigation['admin/stats'] = array('label' => qa_lang_html('admin/stats_title'), 'url' => qa_path_html('admin/stats')); if (!QA_FINAL_EXTERNAL_USERS) { $navigation['admin/mailing'] = array('label' => qa_lang_html('admin/mailing_title'), 'url' => qa_path_html('admin/mailing')); } $navigation['admin/plugins'] = array('label' => qa_lang_html('admin/plugins_title'), 'url' => qa_path_html('admin/plugins')); } if (!qa_user_permit_error('permit_moderate')) { $navigation['admin/moderate'] = array('label' => qa_lang_html('admin/moderate_title'), 'url' => qa_path_html('admin/moderate')); } if (qa_opt('flagging_of_posts') && !qa_user_permit_error('permit_hide_show')) { $navigation['admin/flagged'] = array('label' => qa_lang_html('admin/flagged_title'), 'url' => qa_path_html('admin/flagged')); } if (!qa_user_permit_error('permit_hide_show') || !qa_user_permit_error('permit_delete_hidden')) { $navigation['admin/hidden'] = array('label' => qa_lang_html('admin/hidden_title'), 'url' => qa_path_html('admin/hidden')); } return $navigation; }
function filter_subs($text) { // text subs $subs = array('site_title' => qa_opt('site_title'), 'site_url' => qa_opt('site_url')); foreach ($subs as $i => $v) { $text = str_replace('^' . $i, $v, $text); } // function subs preg_match_all('/\\^qa_path\\(([^)]+)\\)/', $text, $qa_path, PREG_SET_ORDER); foreach ($qa_path as $match) { $text = str_replace($match[0], qa_path($match[1]), $text); } preg_match_all('/\\^qa_opt\\(([^)]+)\\)/', $text, $qa_opt, PREG_SET_ORDER); foreach ($qa_opt as $match) { // backwards compat if (in_array($match[1], array('points_per_q_voted_up', 'points_per_q_voted_down')) && !qa_opt('points_per_q_voted_up')) { $match[1] = 'points_per_q_voted'; } else { if (in_array($match[1], array('points_per_a_voted_up', 'points_per_a_voted_down')) && !qa_opt('points_per_a_voted_up')) { $match[1] = 'points_per_a_voted'; } } $text = str_replace($match[0], qa_opt($match[1]), $text); } // if subs if (qa_get_logged_in_userid()) { $text = preg_replace('/\\^if_logged_in=`([^`]+)`/', '$1', $text); $text = preg_replace('/\\^if_not_logged_in=`[^`]+`/', '', $text); $handle = qa_get_logged_in_handle(); $subs = array('profile_url' => qa_path('user/' . $handle), 'handle' => $handle); foreach ($subs as $i => $v) { $text = str_replace('^' . $i, $v, $text); } } else { global $qa_root_url_relative; $userlinks = qa_get_login_links($qa_root_url_relative, null); $subs = array('login' => $userlinks['login'], 'register' => $userlinks['register']); foreach ($subs as $i => $v) { $text = str_replace('^' . $i, $v, $text); } $text = preg_replace('/\\^if_not_logged_in=`([^`]+)`/', '$1', $text); $text = preg_replace('/\\^if_logged_in=`[^`]+`/', '', $text); } // table subs if (strpos($text, '^pointstable') !== false) { require_once QA_INCLUDE_DIR . 'qa-db-points.php'; $optionnames = qa_db_points_option_names(); $options = qa_get_options($optionnames); $table = ' <table class="qa-form-wide-table"> <tbody>'; $multi = (int) $options['points_multiple']; foreach ($optionnames as $optionname) { switch ($optionname) { case 'points_multiple': continue 2; case 'points_per_q_voted_up': case 'points_per_a_voted_up': $prefix = '+'; break; case 'points_per_q_voted_down': case 'points_per_a_voted_down': $prefix = '-'; break; case 'points_per_q_voted': case 'points_per_a_voted': $prefix = '±'; break; case 'points_q_voted_max_gain': case 'points_a_voted_max_gain': $prefix = '+'; break; case 'points_q_voted_max_loss': case 'points_a_voted_max_loss': $prefix = '–'; break; case 'points_base': $prefix = '+'; break; default: $prefix = '<SPAN STYLE="visibility:hidden;">+</SPAN>'; // for even alignment break; } $points = $optionname != 'points_base' ? (int) $options[$optionname] * $multi : (int) $options[$optionname]; if ($points != 0 && $points != -10000 && $points != 10000 && strpos($optionname, 'max') === false) { $table .= ' <tr> <td class="qa-form-wide-label"> ' . qa_lang_html('options/' . $optionname) . ' </td> <td class="qa-form-wide-data" style="text-align:right"> <span class="qa-form-wide-prefix"><span style="width: 1em; display: -moz-inline-stack;">' . $prefix . '</span></span> ' . qa_html($points) . ($optionname == 'points_multiple' ? '' : ' <span class="qa-form-wide-note">' . qa_lang_html('admin/points') . '</span>') . ' </td> </tr>'; } } $table .= ' </tbody> </table>'; $text = str_replace('^pointstable', $table, $text); } if (strpos($text, '^privilegestable') !== false) { $options = qa_get_permit_options(); foreach ($options as $option) { if (qa_opt($option) == QA_PERMIT_POINTS) { $popts[$option] = (int) qa_opt($option . '_points'); } } if (isset($popts)) { asort($popts); $table = ' <table class="qa-form-wide-table"> <tbody>'; foreach ($popts as $key => $val) { // fudge if ($key == 'permit_retag_cat') { $name = qa_lang_html(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag'); } else { $name = qa_lang('profile/' . $key); } if ($name == '[profile/' . $key . ']') { global $qa_lang_file_pattern; foreach ($qa_lang_file_pattern as $k => $v) { if (qa_lang($k . '/' . $key) != '[' . $k . '/' . $key . ']') { $name = qa_lang($k . '/' . $key); break; } } } $table .= ' <tr> <td class="qa-form-wide-label"> ' . $name . ' </td> <td class="qa-form-wide-data" style="text-align:right"> ' . qa_html($val) . ' <span class="qa-form-wide-note">' . qa_lang_html('admin/points') . '</span>' . ' </td> </tr>'; } $table .= ' </tbody> </table>'; $text = str_replace('^privilegestable', $table, $text); } else { $text = str_replace('^privilegestable', '', $text); } } return $text; }
if (!strlen($custom)) { unset($qa_content['form']['fields']['custom']); } if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) { $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION; $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) { $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');'; } } if (isset($followanswer)) { $viewer = qa_load_viewer($followanswer['content'], $followanswer['format']); $field = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg()))); qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field)); } if (qa_using_categories() && count($categories)) { $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])); qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category')); if (!qa_opt('allow_no_category')) { // don't auto-select a category even though one is required $field['options'][''] = ''; } qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field)); } if (qa_opt('extra_field_active')) { $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra'])); qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field)); } if (qa_using_tags()) { $field = array('error' => qa_html(@$errors['tags'])); qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags'));
function qa_page_q_edit_q_form() { global $qa_content, $question, $inqtitle, $inqcontent, $inqformat, $inqeditor, $inqtags, $qerrors, $innotify, $inemail, $completetags, $categories; $content = isset($inqcontent) ? $inqcontent : $question['content']; $format = isset($inqformat) ? $inqformat : $question['format']; $editorname = isset($inqeditor) ? $inqeditor : qa_opt('editor_for_qs'); $editor = qa_load_editor($content, $format, $editorname); $form = array('style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="qtitle"', 'value' => qa_html(isset($inqtitle) ? $inqtitle : $question['title']), 'error' => qa_html(@$qerrors['title'])), 'category' => array('label' => qa_lang_html('question/q_category_label')), 'content' => array_merge($editor->get_field($qa_content, $content, $format, 'qcontent', 12, true), array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$qerrors['content']))), 'tags' => array('error' => qa_html(@$qerrors['tags']))), 'buttons' => array('save' => array('label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'dosaveq' => '1')); if (qa_using_categories() && count($categories)) { qa_set_up_category_field($qa_content, $form['fields']['category'], 'category', $categories, isset($incategoryid) ? $incategoryid : $question['categoryid'], qa_opt('allow_no_category') || !isset($question['categoryid']), qa_opt('allow_no_sub_category')); } else { unset($form['fields']['category']); } if (qa_using_tags()) { qa_set_up_tag_field($qa_content, $form['fields']['tags'], 'qtags', isset($inqtags) ? $inqtags : qa_tagstring_to_tags($question['tags']), array(), $completetags, qa_opt('page_size_ask_tags')); } else { unset($form['fields']['tags']); } if ($question['isbyuser']) { qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(), isset($innotify) ? $innotify : !empty($question['notify']), isset($inemail) ? $inemail : @$question['notify'], @$qerrors['email']); } return $form; }