function admin_form(&$qa_content) { // Process form input $ok = null; if (qa_clicked('ajax_comment_save')) { qa_opt('ajax_comment_enable', (bool) qa_post_text('ajax_comment_enable')); qa_opt('ajax_comment_format', (int) qa_post_text('ajax_comment_format')); qa_opt('ajax_comment_username', (bool) qa_post_text('ajax_comment_username')); qa_opt('ajax_comment_flash_star', (bool) qa_post_text('ajax_comment_flash_star')); qa_opt('ajax_comment_answer_reminder', (bool) qa_post_text('ajax_comment_answer_reminder')); qa_opt('ajax_comment_answer_reminder_text', qa_post_text('ajax_comment_answer_reminder_text')); qa_opt('ajax_comment_popup_notice', (bool) qa_post_text('ajax_comment_popup_notice')); qa_opt('ajax_comment_popup_notice_text', qa_post_text('ajax_comment_popup_notice_text')); $ok = 'Settings Saved.'; } $formats = array(); $formats[] = 'plain text'; $editors = qa_list_modules('viewer'); if (in_array('Markdown Viewer', $editors)) { $formats[] = 'markdown'; } $formats[] = 'html'; // Create the form for display $fields = array(); $fields[] = array('label' => 'Enable ajax comment form', 'tags' => 'NAME="ajax_comment_enable"', 'value' => qa_opt('ajax_comment_enable'), 'type' => 'checkbox'); $fields[] = array('label' => 'Comment format', 'tags' => 'NAME="ajax_comment_format"', 'type' => 'select', 'options' => $formats, 'value' => @$formats[qa_opt('ajax_comment_format')]); $fields[] = array('label' => 'Add @username to comment box', 'tags' => 'NAME="ajax_comment_username"', 'value' => (int) qa_opt('ajax_comment_username'), 'type' => 'checkbox'); $fields[] = array('label' => 'Show reminder text if commenting on answer to own question', 'tags' => 'NAME="ajax_comment_answer_reminder" onclick="if(this.checked) jQuery(\'#ajax_comment_answer_reminder_text\').fadeIn(); else jQuery(\'#ajax_comment_answer_reminder_text\').fadeOut();"', 'value' => (int) qa_opt('ajax_comment_answer_reminder'), 'type' => 'checkbox'); $fields[] = array('tags' => 'id="ajax_comment_answer_reminder_text" name="ajax_comment_answer_reminder_text" style="display:' . (qa_opt('ajax_comment_answer_reminder') ? 'block' : 'none') . '"', 'value' => qa_html(qa_opt('ajax_comment_answer_reminder_text')), 'type' => 'text'); $fields[] = array('label' => 'Flash select star if commenting on answer to own question', 'tags' => 'NAME="ajax_comment_flash_star"', 'value' => (int) qa_opt('ajax_comment_flash_star'), 'type' => 'checkbox'); $fields[] = array('label' => 'Show reminder pop-up if if voting up answer to own question', 'tags' => 'NAME="ajax_comment_popup_notice" onclick="if(this.checked) jQuery(\'#ajax_comment_popup_notice_text\').fadeIn(); else jQuery(\'#ajax_comment_popup_notice_text\').fadeOut();"', 'value' => (int) qa_opt('ajax_comment_popup_notice'), 'type' => 'checkbox'); $fields[] = array('tags' => 'id="ajax_comment_popup_notice_text" name="ajax_comment_popup_notice_text" style="display:' . (qa_opt('ajax_comment_popup_notice') ? 'block' : 'none') . '"', 'value' => qa_html(qa_opt('ajax_comment_popup_notice_text')), 'type' => 'text'); return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="ajax_comment_save"'))); }
function head_css() { qa_html_theme_base::head_css(); $this->output('<link rel="stylesheet" href="' . qa_html(QA_HTML_THEME_LAYER_URLTOROOT . 'notification.css') . '"/>'); $this->content['style'][] = '<link rel="stylesheet" href="' . qa_html(QA_HTML_THEME_LAYER_URLTOROOT . 'notification.css') . '" />'; qa_html_theme_base::head_css(); }
function process_request($request) { $userid = qa_get_logged_in_userid(); $categoryoptions = array(); $qa_content = qa_content_prepare(); // check if we have done a post of the page if (qa_post_text('okthen')) { // update the current category $newcategory = qa_post_text('category'); if (isset($newcategory)) { mp_set_categoryid($newcategory); // redirect to main page qa_redirect(''); } else { $qa_content['error'] = 'You must select a course to continue.'; } } // retrieve list of categories user is associated with // populate category options $results = mp_get_categories_for_user($userid); foreach ($results as $row) { $categoryoptions[$row['categoryid']] = $row['title']; } $qa_content['title'] = 'Registered courses'; $qa_content['custom'] = 'The following list displays all courses your account is associated with. Select a course from the list below and click <B>Select</B> to change to the new course<br /><br />'; $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('courses' => array('type' => 'select-radio', 'label' => 'Courses', 'tags' => 'NAME="category"', 'options' => $categoryoptions, 'value' => mp_get_categoryid(), 'error' => qa_html(@$errors['course']))), 'buttons' => array('ok' => array('tags' => 'NAME="okthen"', 'label' => 'Select', 'value' => '1'))); return $qa_content; }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $out = ''; require_once QA_INCLUDE_DIR . 'qa-app-users.php'; if (qa_is_logged_in()) { $out = ' <button id="adchattoggle" class="adchattoggle">Show/Hide Chat </button>'; $out .= '<div class="adchat" id="adchat" style="display:'; if (@$_COOKIE['showadchat'] == 'block') { $out .= "block"; } else { $out .= "none"; } $out .= '">'; $out .= ' <iframe src="' . $this->urltoroot . 'chat/" style="border:0; width:100%; height:480px;"></iframe> </div>'; } else { $out = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="' . qa_html(qa_opt("adsense_publisher_id")) . '" data-ad-slot="' . qa_html(qa_opt("adsense_adunit_id")) . '" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>'; } $output = '<div class="adchat-widget-container">' . $out . '</div>'; $themeobject->output($output); }
public function q_list($q_list) { if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (!empty($postids)) { // Retrieve the content for these questions from the database $maxlength = qa_opt('mouseover_content_max_len'); $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { if (isset($postinfo[$question['raw']['postid']])) { $thispost = $postinfo[$question['raw']['postid']]; $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = preg_replace('/\\s+/', ' ', $text); // Remove duplicated blanks, new line characters, tabs, etc $text = qa_shorten_string_line($text, $maxlength); $title = isset($question['title']) ? $question['title'] : ''; $q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title); } } } } parent::q_list($q_list); // call back through to the default function }
public function q_list($q_list) { if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (!empty($postids)) { // Retrieve the content for these questions from the database and put into an array fetching // the minimal amount of characters needed to determine the string should be shortened or not $maxlength = qa_opt('mouseover_content_max_len'); $result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { if (isset($postinfo[$question['raw']['postid']])) { $thispost = $postinfo[$question['raw']['postid']]; $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $title = isset($question['title']) ? $question['title'] : ''; $q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title); } } } } qa_html_theme_base::q_list($q_list); // call back through to the default function }
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) { foreach ($navigation as $key => $navlink) { $category = $categories[$navlink['categoryid']]; if (!$category['childcount']) { unset($navigation[$key]['url']); } elseif ($navlink['selected']) { $navigation[$key]['state'] = 'open'; $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid'])); } else { $navigation[$key]['state'] = 'closed'; } if (@$favoritemap[$navlink['categoryid']]) { $navigation[$key]['favorited'] = true; } $navigation[$key]['note'] = ''; $navigation[$key]['note'] .= ' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . ($category['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))) . '</a>'; if (strlen($category['content'])) { $navigation[$key]['note'] .= qa_html(' - ' . $category['content']); } if (isset($navlink['subnav'])) { qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap); } } }
public function admin_form(&$qa_content) { // Process form input $saved = false; if (qa_clicked('event_logger_save_button')) { qa_opt('event_logger_to_database', (int) qa_post_text('event_logger_to_database_field')); qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field')); qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field')); qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field')); $saved = true; } // Check the validity of the currently entered directory (if any) $directory = qa_opt('event_logger_directory'); $note = null; $error = null; if (!strlen($directory)) { $note = 'Please specify a directory that is writable by the web server.'; } elseif (!file_exists($directory)) { $error = 'This directory cannot be found. Please enter the full path.'; } elseif (!is_dir($directory)) { $error = 'This is a file. Please enter the full path of a directory.'; } elseif (!is_writable($directory)) { $error = 'This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.'; } // Create the form for display qa_set_display_rules($qa_content, array('event_logger_directory_display' => 'event_logger_to_files_field', 'event_logger_hide_header_display' => 'event_logger_to_files_field')); return array('ok' => $saved && !isset($error) ? 'Event log settings saved' : null, 'fields' => array(array('label' => 'Log events to <code>' . QA_MYSQL_TABLE_PREFIX . 'eventlog</code> database table', 'tags' => 'name="event_logger_to_database_field"', 'value' => qa_opt('event_logger_to_database'), 'type' => 'checkbox'), array('label' => 'Log events to daily log files', 'tags' => 'name="event_logger_to_files_field" id="event_logger_to_files_field"', 'value' => qa_opt('event_logger_to_files'), 'type' => 'checkbox'), array('id' => 'event_logger_directory_display', 'label' => 'Directory for log files - enter full path:', 'value' => qa_html($directory), 'tags' => 'name="event_logger_directory_field"', 'note' => $note, 'error' => qa_html($error)), array('id' => 'event_logger_hide_header_display', 'label' => 'Include header lines at top of each log file', 'type' => 'checkbox', 'tags' => 'name="event_logger_hide_header_field"', 'value' => !qa_opt('event_logger_hide_header'))), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="event_logger_save_button"'))); }
function q_list($q_list) { if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) { // first check it is not an empty list and the feature is turned on // Collect the question ids of all items in the question list (so we can do this in one DB query) $postids = array(); foreach ($q_list['qs'] as $question) { if (isset($question['raw']['postid'])) { $postids[] = $question['raw']['postid']; } } if (count($postids)) { // Retrieve the content for these questions from the database and put into an array $result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids); $postinfo = qa_db_read_all_assoc($result, 'postid'); // Get the regular expression fragment to use for blocked words and the maximum length of content to show $blockwordspreg = qa_get_block_words_preg(); $maxlength = qa_opt('mouseover_content_max_len'); // Now add the popup to the title for each question foreach ($q_list['qs'] as $index => $question) { $thispost = @$postinfo[$question['raw']['postid']]; if (isset($thispost)) { $text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg)); $text = qa_shorten_string_line($text, $maxlength); $q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>'; } } } } qa_html_theme_base::q_list($q_list); // call back through to the default function }
function admin_form(&$qa_content) { // Process form input $saved = false; if (qa_clicked('event_logger_save_button')) { qa_opt('event_logger_to_database', (int) qa_post_text('event_logger_to_database_field')); qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field')); qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field')); qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field')); $saved = true; // Create the database table if database logging was switched on if (qa_opt('event_logger_to_database')) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-maxima.php'; qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^eventlog (' . 'datetime DATETIME NOT NULL,' . 'ipaddress VARCHAR (15) CHARACTER SET ascii,' . 'userid ' . qa_get_mysql_user_column_type() . ',' . 'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' . 'cookieid BIGINT UNSIGNED,' . 'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' . 'params VARCHAR (800) NOT NULL,' . 'KEY datetime (datetime),' . 'KEY ipaddress (ipaddress),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8'); } } // Check the validity of the currently entered directory (if any) $directory = qa_opt('event_logger_directory'); $note = null; $error = null; if (!strlen($directory)) { $note = 'Please specify a directory that is writable by the web server.'; } elseif (!file_exists($directory)) { $error = 'This directory cannot be found. Please enter the full path.'; } elseif (!is_dir($directory)) { $error = 'This is a file. Please enter the full path of a directory.'; } elseif (!is_writable($directory)) { $error = 'This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.'; } // Create the form for display qa_set_display_rules($qa_content, array('event_logger_directory_display' => 'event_logger_to_files_field', 'event_logger_hide_header_display' => 'event_logger_to_files_field')); return array('ok' => $saved && !isset($error) ? 'Event log settings saved' : null, 'fields' => array(array('label' => 'Log events to <code>' . QA_MYSQL_TABLE_PREFIX . 'eventlog</code> database table', 'tags' => 'NAME="event_logger_to_database_field"', 'value' => qa_opt('event_logger_to_database'), 'type' => 'checkbox'), array('label' => 'Log events to daily log files', 'tags' => 'NAME="event_logger_to_files_field" ID="event_logger_to_files_field"', 'value' => qa_opt('event_logger_to_files'), 'type' => 'checkbox'), array('id' => 'event_logger_directory_display', 'label' => 'Directory for log files (enter full path):', 'value' => qa_html($directory), 'tags' => 'NAME="event_logger_directory_field"', 'note' => $note, 'error' => $error), array('id' => 'event_logger_hide_header_display', 'label' => 'Include header lines at top of each log file', 'type' => 'checkbox', 'tags' => 'NAME="event_logger_hide_header_field"', 'value' => !qa_opt('event_logger_hide_header'))), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'NAME="event_logger_save_button"'))); }
function qa_fatal_error($message) { $message .= ' (' . $_SERVER['REMOTE_ADDR'] . ')'; echo 'Question2Answer fatal error:<P><FONT COLOR="red">' . qa_html($message, true) . '</FONT></P>'; echo '<P><FONT COLOR="red">Your IP address has been logged.</FONT></P>'; @error_log('PHP Question2Answer fatal error: ' . $message); }
function get_field(&$qa_content, $content, $format, $fieldname, $rows, $autofocus) { if ($autofocus) { $qa_content['focusid'] = $fieldname; } return array('type' => 'textarea', 'tags' => 'NAME="' . $fieldname . '" ID="' . $fieldname . '"', 'value' => qa_html($content), 'rows' => $rows); }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'db/selects.php'; $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags'))); $maxcount = reset($populartags); // $themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags'))); // $themeobject->output('<div style="font-size: 10px;">'); $themeobject->output(sprintf('<div class="panel panel-primary" style="padding: 0;"><div class="panel-heading"><h3 class="panel-title">%s</h3></div>', qa_lang_html('main/popular_tags'))); $themeobject->output('<div class="panel-body">'); $maxsize = qa_opt('tag_cloud_font_size'); $minsize = qa_opt('tag_cloud_minimal_font_size'); $scale = qa_opt('tag_cloud_size_popular'); $blockwordspreg = qa_get_block_words_preg(); foreach ($populartags as $tag => $count) { $matches = qa_block_words_match_all($tag, $blockwordspreg); if (empty($matches)) { if ($scale) { $size = number_format($maxsize * $count / $maxcount, 1); if ($size < $minsize) { $size = $minsize; } } else { $size = $maxsize; } $themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag))); } } // $themeobject->output('</div>'); $themeobject->output('</div></div>'); }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { if (!qa_opt('event_logger_to_database')) { return; } $badges = qa_db_read_all_assoc(qa_db_query_sub('SELECT event,handle,params, UNIX_TIMESTAMP(datetime) AS datetime FROM ^eventlog WHERE event=$' . (qa_opt('badge_widget_date_max') ? ' AND DATE_SUB(CURDATE(),INTERVAL ' . (int) qa_opt('badge_widget_date_max') . ' DAY) <= datetime' : '') . ' ORDER BY datetime DESC' . (qa_opt('badge_widget_list_max') ? ' LIMIT ' . (int) qa_opt('badge_widget_list_max') : ''), 'badge_awarded')); if (empty($badges)) { return; } $themeobject->output('<h2>' . qa_lang('badges/badge_widget_title') . '</h2>'); foreach ($badges as $badge) { $params = array(); $paramsa = explode("\t", $badge['params']); foreach ($paramsa as $param) { $parama = explode('=', $param); $params[$parama[0]] = $parama[1]; } $slug = $params['badge_slug']; $typea = qa_get_badge_type_by_slug($slug); $types = $typea['slug']; $typed = $typea['name']; $badge_name = qa_lang('badges/' . $slug); if (!qa_opt('badge_' . $slug . '_name')) { qa_opt('badge_' . $slug . '_name', $badge_name); } $var = qa_opt('badge_' . $slug . '_var'); $name = qa_opt('badge_' . $slug . '_name'); $desc = qa_badge_desc_replace($slug, $var, $name); $string = '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '<br/>- ' . $badge['handle'] . ' -</span>'; $themeobject->output('<div class="badge-widget-entry" style="padding-top:8px;">', $string, '</div>'); } }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { /* $requestparts=qa_request_parts(); $requestlower=strtolower(qa_request()); $firstlower=strtolower($requestparts[0]); $routing=qa_page_routing(); // unanswered & questions pages may contain categories. unset($routing['activity/']); unset($routing['unanswered/']); unset($routing['questions/']); if ( (isset($routing[$requestlower])) or (isset($routing[$firstlower.'/'])) or (is_numeric($requestparts[0])) ) return; $explicitqa=(strtolower($requestparts[0])=='qa' or strtolower($requestparts[0])=='unanswered' or strtolower($requestparts[0])=='questions' or strtolower($requestparts[0])=='activity'); if ($explicitqa) $slugs=array_slice($requestparts, 1); elseif (strlen($requestparts[0])) $slugs=$requestparts; else $slugs=array(); */ $slugs = useo_get_current_category_slug(); $countslugs = count($slugs); list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null); if ($countslugs && isset($categoryid)) { /* $categoryid is current categories ID $backpath = implode('/', array_reverse($slugs)); echo "countslugs: <pre>"; var_dump($countslugs); echo "</pre>"; $fullcategory=qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true)); echo "fullcategory: <pre>"; var_dump($fullcategory); echo "</pre>"; echo "categoryid: <pre>"; var_dump($categoryid); echo "</pre>"; echo "slugs: <pre>"; var_dump($slugs); echo "</pre>"; echo "template: <pre>"; var_dump($template); echo "</pre>"; echo "request: <pre>"; var_dump($request); echo "</pre>"; */ require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $description = qa_db_categorymeta_get($categoryid, 'useo_cat_description'); if (!qa_opt('useo_cat_desc_format')) { $description = qa_html($description); } $editurlhtml = qa_path_html('category-edit/' . $categoryid); $allowediting = !qa_user_permit_error('useo_cat_desc_permit_edit'); if (strlen($description)) { echo '<SPAN CLASS="entry-content qa-category-description">'; echo $description; echo '</SPAN>'; if ($allowediting) { echo ' - <A HREF="' . $editurlhtml . '">edit</A>'; } } elseif ($allowediting) { echo '<A HREF="' . $editurlhtml . '">' . qa_lang_html('useo/create_desc_link') . '</A>'; } } }
function logged_in() { qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<SPAN CLASS="qa-logged-in-points">', '(' . $pointshtml . ')', '</SPAN>'); } }
public function admin_form() { $saved = false; if (qa_clicked('nkconnect_save_button')) { qa_opt(Q2ANKConnect::NKCONNECT_SECRET, qa_post_text(self::FIELD_SECRET)); qa_opt(Q2ANKConnect::NKCONNECT_KEY, qa_post_text(self::FIELD_KEY)); $saved = true; } return array('ok' => $saved ? 'ustawienia nkConnect zapisane' : null, 'fields' => array(array('label' => 'nkConnect sekret:', 'value' => qa_html(qa_opt(Q2ANKConnect::NKCONNECT_SECRET)), 'tags' => 'NAME="' . self::FIELD_SECRET . '"'), array('label' => 'nkConnect klucz:', 'value' => qa_html(qa_opt(Q2ANKConnect::NKCONNECT_KEY)), 'tags' => 'NAME="' . self::FIELD_KEY . '"')), 'buttons' => array(array('label' => 'Zapisz zmiany', 'tags' => 'NAME="nkconnect_save_button"'))); }
function process_request($request) { $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('example_page/page_title'); $qa_content['error'] = 'An example error'; $qa_content['custom'] = 'Some <B>custom html</B>'; $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'wide', 'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null, 'title' => 'Form title', 'fields' => array('request' => array('label' => 'The request', 'tags' => 'NAME="request"', 'value' => qa_html($request), 'error' => qa_html('Another error'))), 'buttons' => array('ok' => array('tags' => 'NAME="okthen"', 'label' => 'OK then', 'value' => '1')), 'hidden' => array('hiddenfield' => '1')); $qa_content['custom_2'] = '<P><BR>More <I>custom html</I></P>'; return $qa_content; }
function admin_form() { $saved = false; if (qa_clicked('google_analytics_save_button')) { qa_opt('google_analytics_UA', qa_post_text('google_analytics_UA_field')); qa_opt('google_analytics_show_for_admin', (bool) qa_post_text('google_analytics_show_for_admin_field')); $saved = true; } return array('ok' => $saved ? 'Google Analytics settings saved.' : null, 'fields' => array(array('label' => 'Enter Google UA id (should be like UA-xxxxxxx-x):', 'value' => qa_html(qa_opt('google_analytics_UA')), 'tags' => 'NAME="google_analytics_UA_field"'), array('label' => 'Check to exclude Super Admin visits from tracking.', 'type' => 'checkbox', 'value' => qa_opt('google_analytics_show_for_admin'), 'tags' => 'NAME="google_analytics_show_for_admin_field"')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'NAME="google_analytics_save_button"'))); }
function qa_send_email($params) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; if (!$params['html'] || qa_opt('email_formating_overrule')) { $body = "<p>" . strtr($params['html'] ? $params['body'] : qa_html($params['body']), array("\n" => "</p><p>")) . "</p>"; $params['body'] = strtr(qa_opt('email_formating_body'), array("^body" => $body, "^title" => $params['subject'], "^site_title" => qa_opt('site_title'), "^site_url" => qa_opt('site_url'), "^logo_url" => qa_opt('logo_show') ? qa_opt('site_url') . qa_opt('logo_url') : ' ')); $params['html'] = true; } return qa_send_email_base($params); }
function process_request($request) { $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('example_page/page_title'); $qa_content['error'] = 'An example error'; $qa_content['custom'] = 'Some <b>custom html</b>'; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'ok' => qa_post_text('okthen') ? 'You clicked OK then!' : null, 'title' => 'Form title', 'fields' => array('request' => array('label' => 'The request', 'tags' => 'name="request"', 'value' => qa_html($request), 'error' => qa_html('Another error'))), 'buttons' => array('ok' => array('tags' => 'name="okthen"', 'label' => 'OK then', 'value' => '1')), 'hidden' => array('hiddenfield' => '1')); $qa_content['custom_2'] = '<p><br>More <i>custom html</i></p>'; return $qa_content; }
function recaptcha_error_html() { if (!function_exists('fsockopen')) { return 'To use reCAPTCHA, the fsockopen() PHP function must be enabled on your server. Please check with your system administrator.'; } elseif (!strlen(trim(qa_opt('recaptcha_public_key'))) || !strlen(trim(qa_opt('recaptcha_private_key')))) { require_once $this->directory . 'recaptchalib.php'; $url = recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title')); return 'To use reCAPTCHA, you must <a href="' . qa_html($url) . '">sign up</a> to get these keys.'; } return null; }
public function body_tags() { $class = 'qa-template-qa'; // qa-template-'.qa_html($this->template); if (isset($this->content['categoryids'])) { foreach ($this->content['categoryids'] as $categoryid) { $class .= ' qa-category-' . qa_html($categoryid); } } $this->output('class="' . $class . ' qa-body-js-off"'); }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked('adsense_save_button')) { $trimchars = "=;\"\\' \t\r\n"; // prevent common errors by copying and pasting from Javascript qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars)); $saved = true; } return array('ok' => $saved ? 'AdSense settings saved' : null, 'fields' => array(array('label' => 'AdSense Publisher ID:', 'value' => qa_html(qa_opt('adsense_publisher_id')), 'tags' => 'name="adsense_publisher_id_field"', 'note' => 'Example: <i>pub-1234567890123456</i>')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="adsense_save_button"'))); }
function qa_captcha_error() { if (qa_captcha_possible()) { return null; } elseif (!function_exists('fsockopen')) { return qa_lang_html('admin/recaptcha_fsockopen'); } else { require_once QA_INCLUDE_DIR . 'qa-recaptchalib.php'; $url = recaptcha_get_signup_url(@$_SERVER['HTTP_HOST'], qa_opt('site_title')); return strtr(qa_lang_html('admin/recaptcha_get_keys'), array('^1' => '<A HREF="' . qa_html($url) . '">', '^2' => '</A>')); } }
function carousel_item($type, $limit, $col_item = 1) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $post = qa_db_query_sub('SELECT * FROM ^postmetas, ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ( ^postmetas.postid = ^posts.postid and ^postmetas.title = "featured_question" ) ORDER BY ^posts.created DESC LIMIT #', $type, $limit); $output = '<div class="item"><div class="row">'; $i = 1; while ($p = mysql_fetch_array($post)) { if ($type == 'Q') { $what = qa_lang('cleanstrap/asked'); } elseif ($type == 'A') { $what = qa_lang('cleanstrap/answered'); } elseif ('C') { $what = qa_lang('cleanstrap/commented'); } $handle = $p['handle']; if ($type == 'Q') { $link_header = '<a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">'; } elseif ($type == 'A') { $link_header = '<a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">'; } else { $link_header = '<a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">'; } $output .= '<div class="slider-item col-sm-' . 12 / $col_item . '">'; $output .= '<div class="slider-item-inner">'; $featured_img = get_featured_thumb($p['postid']); if ($featured_img) { $output .= $link_header . '<div class="featured-image">' . $featured_img . '</div></a>'; } if ($type == 'Q') { $output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span> ans</span></div>'; } elseif ($type == 'A') { $output .= '<div class="big-ans-count pull-left vote">' . $p['netvotes'] . '<span>' . qa_lang('cleanstrap/vote') . '</span></div>'; } $output .= '<h5>' . $link_header . cs_truncate(qa_html($p['title']), 50) . '</a></h5>'; $output .= '<div class="meta">'; $when = qa_when_to_html(strtotime($p['created']), 7); $avatar = cs_get_avatar($handle, 15, false); if ($avatar) { $output .= '<img src="' . $avatar . '" />'; } $output .= '<span class="icon-time">' . implode(' ', $when) . '</span>'; $output .= '<span class="vote-count">' . $p['netvotes'] . ' ' . qa_lang('cleanstrap/votes') . '</span></div>'; $output .= '</div>'; $output .= '</div>'; if ($col_item == $i) { $output .= '</div></div><div class="item active"><div class="row">'; } $i++; } $output .= '</div></div>'; return $output; }
function cs_user_post_list($handle, $type, $limit) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $post = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ^posts.userid=# ORDER BY ^posts.created DESC LIMIT #', $type, $userid, $limit)); $output = '<ul class="question-list users-post-widget post-type-' . $type . '">'; if (count($post) > 0) { foreach ($post as $p) { if ($type == 'Q') { $what = qa_lang_html('cleanstrap/asked'); } elseif ($type == 'A') { $what = qa_lang_html('cleanstrap/answered'); } elseif ('C') { $what = qa_lang_html('cleanstrap/commented'); } $handle = $p['handle']; $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">'; if ($type == 'Q') { $output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span>' . qa_lang_html('cleanstrap/ans') . '</span></div>'; } elseif ($type == 'A') { $output .= '<div class="big-ans-count pull-left icon-answer"></div>'; } elseif ($type == 'C') { $output .= '<div class="big-ans-count pull-left icon-comment icon-comments"></div>'; } $output .= '<div class="list-right">'; $timeCode = qa_when_to_html(strtotime($p['created']), 7); $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; if ($type == 'Q') { $output .= '<h5><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></h5>'; } elseif ($type == 'A') { $output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>'; } else { $output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>'; } $output .= '<div class="list-date"><span class="icon-clock">' . $when . '</span>'; $output .= '<span class="icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span></div>'; $output .= '</div>'; $output .= '</li>'; } } else { if ($type == 'Q') { $what = 'questions'; } elseif ($type == 'A') { $what = 'answers'; } elseif ('C') { $what = 'comments'; } $output .= '<li class="no-post-found">' . qa_lang('cleanstrap/no_' . $what) . ' </li>'; } $output .= '</ul>'; echo $output; }
function get_field(&$qa_content, $content, $format, $fieldname, $rows, $autofocus) { $uploadimages = qa_opt('wysiwyg_editor_upload_images'); $uploadall = $uploadimages && qa_opt('wysiwyg_editor_upload_all'); $qa_content['script_src'][] = $this->urltoroot . 'ckeditor.js?' . QA_VERSION; $qa_content['script_onloads'][] = "CKEDITOR.replace(" . qa_js($fieldname) . ", {toolbar:[" . "['Bold','Italic','Underline','Strike']," . "['Font','FontSize']," . "['TextColor','BGColor']," . "['Link','Unlink']," . "'/'," . "['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']," . "['NumberedList','BulletedList','-','Outdent','Indent','Blockquote']," . "['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar']," . "['RemoveFormat', 'Maximize']" . "]" . ", defaultLanguage:" . qa_js(qa_opt('site_language')) . ", skin:'v2'" . ", toolbarCanCollapse:false" . ", removePlugins:'elementspath'" . ", resize_enabled:false" . ", autogrow:false" . ", startupFocus:" . ($autofocus ? 'true' : 'false') . ", entities:false" . ($uploadimages ? ", filebrowserImageUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload', array('qa_only_image' => true))) : "") . ($uploadall ? ", filebrowserUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload')) : "") . "})"; if ($format == 'html') { $html = $content; } else { $html = qa_html($content, true); } return array('tags' => 'NAME="' . $fieldname . '"', 'value' => qa_html($html), 'rows' => $rows); }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $parts = explode('/', $request); $tag = $parts[1]; $description = qa_db_tagmeta_get($tag, 'description'); $editurlhtml = qa_path_html('tag-edit/' . $tag); if (strlen($description)) { echo qa_html($description); echo ' - <A HREF="' . $editurlhtml . '">edit</A>'; } else { echo '<A HREF="' . $editurlhtml . '">Create tag description</A>'; } }
function logged_in() { if (qa_is_logged_in()) { // output user avatar to login bar $this->output('<div class="qa-logged-in-avatar">', QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html(qa_get_logged_in_userid(), 24, true) : qa_get_user_avatar_html(qa_get_logged_in_flags(), qa_get_logged_in_email(), qa_get_logged_in_handle(), qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'), 24, true), '</div>'); } qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { // adds points count after logged in username $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<span class="qa-logged-in-points">', '(' . $pointshtml . ')', '</span>'); } }