Ejemplo n.º 1
0
function qa_shorten_string_line($string, $length)
{
    $string = strtr($string, "\r\n\t", '   ');
    if (qa_strlen($string) > $length) {
        $remaining = $length - 5;
        $words = qa_string_to_words($string, false, true);
        $countwords = count($words);
        $prefix = '';
        $suffix = '';
        for ($addword = 0; $addword < $countwords; $addword++) {
            $tosuffix = $addword % 3 == 1;
            // order: prefix, suffix, prefix, prefix, suffix, prefix, ...
            if ($tosuffix) {
                $word = array_pop($words);
            } else {
                $word = array_shift($words);
            }
            if (qa_strlen($word) > $remaining) {
                break;
            }
            if ($tosuffix) {
                $suffix = $word . $suffix;
            } else {
                $prefix .= $word;
            }
            $remaining -= qa_strlen($word);
        }
        $string = $prefix . ' ... ' . $suffix;
    }
    return $string;
}
Ejemplo n.º 2
0
 public function test__qa_string_to_words()
 {
     $test1 = qa_string_to_words($this->strBasic);
     $expected1 = array('so', 'i', 'tied', 'an', 'onion', 'to', 'my', 'belt', 'which', 'was', 'the', 'style', 'at', 'the', 'time');
     $test2 = qa_string_to_words($this->strBasic, false);
     $expected2 = array('So', 'I', 'tied', 'an', 'onion', 'to', 'my', 'belt', 'which', 'was', 'the', 'style', 'at', 'the', 'time');
     $this->assertEquals($expected1, $test1);
     $this->assertEquals($expected2, $test2);
 }
Ejemplo n.º 3
0
 } elseif (qa_strlen($inname) > QA_DB_MAX_CAT_PAGE_TITLE_LENGTH) {
     $errors['name'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
 } else {
     foreach ($incategories as $category) {
         if (!strcmp($category['parentid'], $inparentid) && strcmp($category['categoryid'], @$editcategory['categoryid']) && qa_strtolower($category['title']) == qa_strtolower($inname)) {
             $errors['name'] = qa_lang('admin/category_already_used');
         }
     }
 }
 //	Verify the slug is legitimate for that parent ID
 for ($attempt = 0; $attempt < 100; $attempt++) {
     switch ($attempt) {
         case 0:
             $inslug = qa_post_text('slug');
             if (!isset($inslug)) {
                 $inslug = implode('-', qa_string_to_words($inname));
             }
             break;
         case 1:
             $inslug = qa_lang_sub('admin/category_default_slug', $inslug);
             break;
         default:
             $inslug = qa_lang_sub('admin/category_default_slug', $attempt - 1);
             break;
     }
     $matchcategoryid = qa_db_category_slug_to_id($inparentid, $inslug);
     // query against DB since MySQL ignores accents, etc...
     if (!isset($inparentid)) {
         $matchpage = qa_db_single_select(qa_db_page_full_selectspec($inslug, false));
     } else {
         $matchpage = null;
Ejemplo n.º 4
0
/**
 * Converts a string to a single line and removes words from it until it fits in the given length. Words are removed
 * from a position around two thirds of the string and are replaced by the given ellipsis string
 *
 * @param string $string Text that will be turned into a single line and cut, if necessary
 * @param int $length Maximum allowed length of the returned string. This value can be overriden by the length of the
 * ellipsis if it is higher than the maximum allowed length
 * @param string $ellipsis Text used to replace the removed words from the original text
 * @return string The string turned into a single line and cut to fit the given length
 */
function qa_shorten_string_line($string, $length, $ellipsis = ' ... ')
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $string = strtr($string, "\r\n\t", '   ');
    if (qa_strlen($string) > $length) {
        $remaining = $length - qa_strlen($ellipsis);
        $words = qa_string_to_words($string, false, true);
        $countwords = count($words);
        $prefix = '';
        $suffix = '';
        for ($addword = 0; $addword < $countwords; $addword++) {
            $tosuffix = $addword % 3 == 1;
            // order: prefix, suffix, prefix, prefix, suffix, prefix, ...
            $word = $tosuffix ? array_pop($words) : array_shift($words);
            $wordLength = qa_strlen($word);
            if ($wordLength > $remaining) {
                break;
            }
            if ($tosuffix) {
                $suffix = $word . $suffix;
            } else {
                $prefix .= $word;
            }
            $remaining -= $wordLength;
        }
        $string = $prefix . $ellipsis . $suffix;
    }
    return $string;
}
         if (empty($errors)) {
             qa_redirect('admin/users');
         } else {
             $userfields = qa_db_select_with_pending(qa_db_userfields_selectspec());
             // reload after changes
             foreach ($userfields as $userfield) {
                 if ($userfield['fieldid'] == $editfield['fieldid']) {
                     $editfield = $userfield;
                 }
             }
         }
     } elseif (empty($errors)) {
         // creating a new user field
         for ($attempt = 0; $attempt < 1000; $attempt++) {
             $suffix = $attempt ? '-' . (1 + $attempt) : '';
             $newtag = qa_substr(implode('-', qa_string_to_words($inname)), 0, QA_DB_MAX_PROFILE_TITLE_LENGTH - strlen($suffix)) . $suffix;
             $uniquetag = true;
             foreach ($userfields as $userfield) {
                 if (qa_strtolower(trim($newtag)) == qa_strtolower(trim($userfield['title']))) {
                     $uniquetag = false;
                 }
             }
             if ($uniquetag) {
                 $fieldid = qa_db_userfield_create($newtag, $inname, $inflags);
                 qa_db_userfield_move($fieldid, $inposition);
                 qa_redirect('admin/users');
             }
         }
         qa_fatal_error('Could not create a unique database tag');
     }
 }
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
	More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
// report that we entered this page
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
//	Perform the search if appropriate
if (strlen(qa_get('q'))) {
    require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $inquery = trim(qa_get('q'));
    $words = qa_string_to_words($inquery);
    $retrieve = 2 * QA_DB_RETRIEVE_QS_AS + 1;
    // get enough results to be able to give some idea of how many pages of search results there are
    $questions = qa_db_select_with_pending(qa_db_search_posts_selectspec($qa_login_userid, $words, $words, $words, $words, $inquery, $qa_start, false, $retrieve));
    $pagesize = qa_opt('page_size_search');
    $gotcount = count($questions);
    $questions = array_slice($questions, 0, $pagesize);
    $usershtml = qa_userids_handles_html($questions);
    qa_report_event('search', $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, array('query' => $inquery, 'start' => $qa_start));
}
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
    $qa_content['search']['value'] = qa_html($inquery);
}
if (isset($questions)) {
Ejemplo n.º 8
0
function qa_q_request($questionid, $title)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $title = qa_block_words_replace($title, qa_get_block_words_preg());
    $words = qa_string_to_words($title, true, false, false);
    $wordlength = array();
    foreach ($words as $index => $word) {
        $wordlength[$index] = qa_strlen($word);
    }
    $remaining = qa_opt('q_urls_title_length');
    if (array_sum($wordlength) > $remaining) {
        arsort($wordlength, SORT_NUMERIC);
        // sort with longest words first
        foreach ($wordlength as $index => $length) {
            if ($remaining > 0) {
                $remaining -= $length;
            } else {
                unset($words[$index]);
            }
        }
    }
    $title = implode('-', $words);
    if (qa_opt('q_urls_remove_accents')) {
        $title = qa_string_remove_accents($title);
    }
    return (int) $questionid . '/' . $title;
}
Ejemplo n.º 9
0
function qa_post_index($postid, $type, $questionid, $title, $text, $tagstring, $skipcounts = false)
{
    global $qa_post_indexing_suspended;
    if ($qa_post_indexing_suspended > 0) {
        return;
    }
    //	Get words from each textual element
    $titlewords = array_unique(qa_string_to_words($title));
    $contentcount = array_count_values(qa_string_to_words($text));
    $tagwords = array_unique(qa_string_to_words($tagstring));
    $wholetags = array_unique(qa_tagstring_to_tags($tagstring));
    //	Map all words to their word IDs
    $words = array_unique(array_merge($titlewords, array_keys($contentcount), $tagwords, $wholetags));
    $wordtoid = qa_db_word_mapto_ids_add($words);
    //	Add to title words index
    $titlewordids = qa_array_filter_by_keys($wordtoid, $titlewords);
    qa_db_titlewords_add_post_wordids($postid, $titlewordids);
    //	Add to content words index (including word counts)
    $contentwordidcounts = array();
    foreach ($contentcount as $word => $count) {
        if (isset($wordtoid[$word])) {
            $contentwordidcounts[$wordtoid[$word]] = $count;
        }
    }
    qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $contentwordidcounts);
    //	Add to tag words index
    $tagwordids = qa_array_filter_by_keys($wordtoid, $tagwords);
    qa_db_tagwords_add_post_wordids($postid, $tagwordids);
    //	Add to whole tags index
    $wholetagids = qa_array_filter_by_keys($wordtoid, $wholetags);
    qa_db_posttags_add_post_wordids($postid, $wholetagids);
    //	Update counts cached in database
    if (!$skipcounts) {
        qa_db_word_titlecount_update($titlewordids);
        qa_db_word_contentcount_update(array_keys($contentwordidcounts));
        qa_db_word_tagwordcount_update($tagwordids);
        qa_db_word_tagcount_update($wholetagids);
        qa_db_tagcount_update();
    }
}
Ejemplo n.º 10
0
 function ajaxPostComment($text, $aid = false)
 {
     if ($aid) {
         $answer = qa_db_single_select(qa_db_full_post_selectspec(null, $aid));
     }
     require_once QA_INCLUDE_DIR . 'qa-page-question-post.php';
     global $qa_login_userid, $qa_cookieid, $question, $questionid, $formtype, $formpostid, $errors, $reloadquestion, $pageerror, $qa_request, $ineditor, $incomment, $informat, $innotify, $inemail, $commentsfollows, $jumptoanchor, $usecaptcha;
     $parent = isset($answer) ? $answer : $question;
     switch (qa_user_permit_error('permit_post_c', 'C')) {
         case 'login':
             $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_login'), $qa_request);
             break;
         case 'confirm':
             $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), $qa_request);
             break;
         case 'limit':
             $pageerror = qa_lang_html('question/comment_limit');
             break;
         default:
             $pageerror = qa_lang_html('users/no_permission');
             break;
         case false:
             $incomment = qa_post_text('ajax_comment_content');
             if (!isset($incomment)) {
                 $pageerror = qa_lang_html('bork');
             } else {
                 $innotify = qa_post_text('notify') ? true : false;
                 $inemail = qa_post_text('email');
                 $this->ajaxEditor($ineditor, $incomment, $informat, $intext);
                 // use our own format types
                 $formats = array();
                 $formats[] = '';
                 $editors = qa_list_modules('viewer');
                 if (in_array('Markdown Viewer', $editors)) {
                     $formats[] = 'markdown';
                 }
                 $formats[] = 'html';
                 $informat = $formats[qa_opt('ajax_comment_format')];
                 $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail);
                 if ($usecaptcha) {
                     qa_captcha_validate($_POST, $errors);
                 }
                 if (empty($errors)) {
                     $isduplicate = false;
                     foreach ($commentsfollows as $comment) {
                         if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) {
                             if (implode(' ', qa_string_to_words($comment['content'])) == implode(' ', qa_string_to_words($incomment))) {
                                 $isduplicate = true;
                             }
                         }
                     }
                     if (!$isduplicate) {
                         if (!isset($qa_login_userid)) {
                             $qa_cookieid = qa_cookie_get_create();
                         }
                         // create a new cookie if necessary
                         // get editor format
                         $commentid = qa_comment_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incomment, $informat, $intext, $innotify, $inemail, $question, @$answer, $commentsfollows);
                         qa_report_write_action($qa_login_userid, $qa_cookieid, 'c_post', $questionid, @$answer['postid'], $commentid);
                     } else {
                         $pageerror = qa_lang_html('question/duplicate_content');
                     }
                 }
             }
             break;
     }
     if ($pageerror) {
         $this->output_raw('### ' . $pageerror);
     } else {
         if (!empty($errors)) {
             $this->output_raw('### ' . implode(',', $errors));
         } else {
             // return c_item
             $c_item = $this->ajaxCommentCreate($parent, $commentid);
             if (isset($c_item['classes'])) {
                 $c_item['classes'] .= ' ajax-comment-hidden';
             } else {
                 $c_item['classes'] = ' ajax-comment-hidden';
             }
             $this->c_list_item($c_item);
         }
     }
 }
Ejemplo n.º 11
0
    function cs_relative_post_list($limit, $slug, $type, $return = false, $avatar_size)
    {
        require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
        if (!empty($slug)) {
            if ($type == 'Category') {
                $post_type = 'Q';
                $categories = explode("/", $slug);
                if (count($categories)) {
                    $category_bread_crup = implode(" > ", $categories);
                    $category_link = implode("/", $categories);
                    $categories = array_reverse($categories);
                    $slug = implode("/", $categories);
                }
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
							AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) 
							ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, $limit));
                //refresh every 15 minutes
                $title = 'Questions in <a href="' . qa_path_html('questions/' . qa_strtolower($category_link)) . '">' . $category_bread_crup . '</a>';
            } elseif ($type == 'Tags') {
                $post_type = 'Q';
                $title = 'Questions in <a href="' . qa_path_html('tag/' . qa_strtolower($slug)) . '">' . $slug . '</a>';
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
						AND ^posts.postid IN (SELECT postid FROM ^posttags WHERE 
							wordid=(SELECT wordid FROM ^words WHERE word=$ OR word=$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC)
						ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, qa_strtolower($slug), $limit));
            } else {
                // Relative to Keyword
                require_once QA_INCLUDE_DIR . 'qa-app-search.php';
                $keyword = $slug;
                $userid = qa_get_logged_in_userid();
                $title = 'Posts About <a href="' . qa_path_html('search/' . qa_strtolower($keyword)) . '">' . $keyword . '</a>';
                //$post=qa_get_search_results($keyword, 0, $limit, $userid , false, false);
                $words = qa_string_to_words($keyword);
                $posts = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($keyword), 0, false, $limit));
                $output = '<h3 class="widget-title">' . $title . '</h3>';
                $output .= '<ul class="question-list">';
                foreach ($posts as $post) {
                    $post_type = $post['type'];
                    if ($post_type == 'Q') {
                        $what = qa_lang('cleanstrap/asked');
                    } elseif ($post_type == 'A') {
                        $what = qa_lang('cleanstrap/answered');
                    } elseif ('C') {
                        $what = qa_lang('cleanstrap/commented');
                    }
                    $handle = qa_post_userid_to_handle($post['userid']);
                    $avatar = cs_get_post_avatar($post, $avatar_size);
                    $output .= '<li id="q-list-' . $post['postid'] . '" class="question-item">';
                    $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . $post['userid'] . '">' . $avatar . '</div>';
                    $output .= '<div class="list-right">';
                    if ($post_type == 'Q') {
                        $output .= '<a class="title" href="' . qa_q_path_html($post['postid'], $post['title']) . '" title="' . $post['title'] . '">' . cs_truncate(strip_tags($post['title']), 70) . '</a>';
                    } elseif ($post_type == 'A') {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#a' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    } else {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#c' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    }
                    $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
                    if ($post_type == 'Q') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                        $output .= ' <span class="ans-count">' . $post['acount'] . ' ans</span>';
                    } elseif ($post_type == 'A') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                    }
                    $output .= '</div></div>';
                    $output .= '</li>';
                }
                $output .= '</ul>';
                if ($return) {
                    return $output;
                }
                echo $output;
                return;
            }
        } else {
            return;
        }
        $output = '<h3 class="widget-title">' . $title . '</h3>';
        $output .= '<ul class="question-list">';
        foreach ($posts as $p) {
            if (empty($p['userid'])) {
                $p['userid'] = NULL;
            }
            // to prevent error for anonymous posts while calling qa_post_userid_to_handle()
            if ($post_type == 'Q') {
                $what = qa_lang_html('cleanstrap/asked');
            } elseif ($post_type == 'A') {
                $what = qa_lang_html('cleanstrap/answered');
            } elseif ('C') {
                $what = qa_lang_html('cleanstrap/commented');
            }
            $handle = qa_post_userid_to_handle($p['userid']);
            $avatar = cs_get_avatar($handle, 35, false);
            $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
            $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . (isset($avatar) ? '<img src="' . $avatar . '" />' : '') . '</div>';
            $output .= '<div class="list-right">';
            if ($post_type == 'Q') {
                $output .= '<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate(qa_html($p['title']), 70) . '</a>';
            } elseif ($post_type == 'A') {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            } else {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            }
            $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
            if ($post_type == 'Q') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
                $output .= ' <span class="ans-count">' . $p['acount'] . ' ans</span>';
            } elseif ($post_type == 'A') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
            }
            $output .= '</div></div>';
            $output .= '</li>';
        }
        $output .= '</ul>';
        if ($return) {
            return $output;
        }
        echo $output;
    }
 function doctype()
 {
     //qa_error_log($this->content);
     if ($this->request == 'admin/permissions' && function_exists('qa_register_plugin_phrases') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'expert_question_ask';
         $permits[] = 'expert_question_roles';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('expert_question/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     $this->expert_user = $this->is_expert_user();
     if (!$this->expert_user) {
         foreach ($this->content['navigation']['main'] as $key => $nav) {
             if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) {
                 unset($this->content['navigation']['main'][$key]);
             }
         }
     }
     if (qa_clicked('do_expert_answeradd') && ($this->expert_user || $this->content['q_view']['raw']['userid'] === qa_get_logged_in_userid())) {
         global $qa_login_userid, $questionid, $question, $answers, $question, $qa_request;
         $innotify = qa_post_text('notify') ? true : false;
         $inemail = qa_post_text('email');
         qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext);
         $isduplicate = false;
         foreach ($answers as $answer) {
             if (!$answer['hidden']) {
                 if (implode(' ', qa_string_to_words($answer['content'])) == implode(' ', qa_string_to_words($incontent))) {
                     $isduplicate = true;
                 }
             }
         }
         if (!$isduplicate) {
             if (!isset($qa_login_userid)) {
                 $qa_cookieid = qa_cookie_get_create();
             }
             // create a new cookie if necessary
             $answerid = qa_answer_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incontent, $informat, $intext, $innotify, $inemail, $question);
             qa_report_write_action($qa_login_userid, $qa_cookieid, 'a_post', $questionid, $answerid, null);
             qa_redirect($qa_request, null, null, null, qa_anchor('A', $answerid));
         } else {
             $pageerror = qa_lang_html('question/duplicate_content');
         }
         qa_page_q_load_q();
         // reload since we may have changed something
     }
     if (qa_opt('expert_question_enable')) {
         if ($this->expert_user && qa_opt('expert_question_show_count')) {
             $this->expertcount = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='is_expert_question' AND ^postmeta.post_id=^posts.postid AND ^posts.acount=0" . (is_array($this->expert_user) ? " AND ^posts.categoryid IN (#)" : " AND \$"), $this->expert_user), true);
             if ($this->expertcount) {
                 foreach ($this->content['navigation']['main'] as $key => $nav) {
                     if ($nav['url'] == qa_path_html(qa_opt('expert_question_page_url'))) {
                         $this->content['navigation']['main'][$key]['label'] .= ' (' . $this->expertcount . ')';
                     }
                 }
             }
         }
         global $qa_request;
         if ($qa_request == qa_opt('expert_question_page_url')) {
             $this->content['navigation']['sub'] = array('special' => 1);
         }
         if ($this->template == 'ask' && in_array(qa_opt('expert_question_type'), array(0, 2)) && !qa_user_permit_error('permit_post_q') && !qa_permit_value_error(qa_opt('expert_question_ask'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags()) && !qa_opt('site_maintenance')) {
             $this->content['form']['fields'][] = array('tags' => 'NAME="is_expert_question" ID="is_expert_question"', 'value' => qa_get(qa_opt('expert_question_page_url')) == 'true' ? qa_opt('expert_question_yes') : qa_opt('expert_question_no'), 'type' => 'select-radio', 'options' => array('no' => qa_opt('expert_question_no'), 'yes' => qa_opt('expert_question_yes')));
         }
         if ($this->template == 'user' && qa_get_logged_in_handle() === $this->_user_handle()) {
             if (!isset($this->content['navigation']['sub'])) {
                 $this->content['navigation']['sub'] = array('profile' => array('url' => qa_path_html('user/' . $this->_user_handle(), null, qa_opt('site_url')), 'label' => $this->_user_handle(), 'selected' => !qa_get('tab') ? true : false), qa_opt('expert_question_page_url') => array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false));
             } else {
                 $this->content['navigation']['sub'][qa_opt('expert_question_page_url')] = array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => qa_opt('expert_question_page_url')), qa_opt('site_url')), 'label' => qa_opt('expert_question_page_title'), 'selected' => qa_get('tab') == qa_opt('expert_question_page_url') ? true : false);
             }
         }
         if ($this->template == 'question') {
             $qid = $this->content['q_view']['raw']['postid'];
             $expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true);
             if ($expert) {
                 // is expert question
                 $this->expert_question = 1;
                 // modify post elements
                 // title
                 $this->content['title'] .= ' ' . qa_opt('expert_question_title');
                 // css class
                 $this->content['q_view']['tags'] .= ' class="qa-expert-question"';
                 // remove hidden stuff
                 unset($this->content['q_view']['hidden']);
                 unset($this->content['hidden']);
             }
         }
     }
     qa_html_theme_base::doctype();
 }
Ejemplo n.º 13
0
function qa_q_request($questionid, $title)
{
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $words = qa_string_to_words($title, true, false, false);
    $wordlength = array();
    foreach ($words as $index => $word) {
        $wordlength[$index] = qa_strlen($word);
    }
    $remaining = qa_opt('q_urls_title_length');
    if (array_sum($wordlength) > $remaining) {
        arsort($wordlength, SORT_NUMERIC);
        // sort with longest words first
        foreach ($wordlength as $index => $length) {
            if ($remaining > 0) {
                $remaining -= $length;
            } else {
                unset($words[$index]);
            }
        }
    }
    $title = implode('-', $words);
    if (qa_opt('q_urls_remove_accents')) {
        $title = qa_string_remove_accents($title);
    }
    return (int) $questionid . '/' . $title;
}
Ejemplo n.º 14
0
function qa_get_tags_field_value($fieldname)
{
    require_once QA_INCLUDE_DIR . 'util/string.php';
    $text = qa_remove_utf8mb4(qa_post_text($fieldname));
    if (qa_opt('tag_separator_comma')) {
        return array_unique(preg_split('/\\s*,\\s*/', trim(qa_strtolower(strtr($text, '/', ' '))), -1, PREG_SPLIT_NO_EMPTY));
    } else {
        return array_unique(qa_string_to_words($text, true, false, false, false));
    }
}
Ejemplo n.º 15
0
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
//	Collect the information we need from the database
$intitle = qa_post_text('title');
$doaskcheck = qa_opt('do_ask_check_qs');
$doexampletags = qa_using_tags() && qa_opt('do_example_tags');
if ($doaskcheck || $doexampletags) {
    $countqs = max($doexampletags ? QA_DB_RETRIEVE_ASK_TAG_QS : 0, $doaskcheck ? qa_opt('page_size_ask_check_qs') : 0);
    $relatedquestions = qa_db_select_with_pending(qa_db_search_posts_selectspec(null, qa_string_to_words($intitle), null, null, null, null, 0, false, $countqs));
}
//	Collect example tags if appropriate
if ($doexampletags) {
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $tagweight = array();
    foreach ($relatedquestions as $question) {
        $tags = qa_tagstring_to_tags($question['tags']);
        foreach ($tags as $tag) {
            @($tagweight[$tag] += exp($question['score']));
        }
    }
    arsort($tagweight, SORT_NUMERIC);
    $exampletags = array();
    $minweight = exp(qa_match_to_min_score(qa_opt('match_example_tags')));
    $maxcount = qa_opt('page_size_ask_tags');
Ejemplo n.º 16
0
 public function process_search($query, $start, $count, $userid, $absoluteurls, $fullcontent)
 {
     require_once QA_INCLUDE_DIR . 'db/selects.php';
     require_once QA_INCLUDE_DIR . 'util/string.php';
     $words = qa_string_to_words($query);
     $questions = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($query), $start, $fullcontent, $count));
     $results = array();
     foreach ($questions as $question) {
         qa_search_set_max_match($question, $type, $postid);
         // to link straight to best part
         $results[] = array('question' => $question, 'match_type' => $type, 'match_postid' => $postid);
     }
     return $results;
 }
Ejemplo n.º 17
0
 function cs_ajax_get_question_suggestion()
 {
     $query = strip_tags($_REQUEST['start_with']);
     $relatedquestions = qa_db_select_with_pending(qa_db_search_posts_selectspec(null, qa_string_to_words($query), null, null, null, null, 0, false, 10));
     //print_r($relatedquestions);
     if (isset($relatedquestions) && !empty($relatedquestions)) {
         $data = array();
         foreach ($relatedquestions as $k => $q) {
             $data[$k]['title'] = $q['title'];
             $data[$k]['blob'] = cs_get_avatar($q['handle'], 30, false);
             $data[$k]['url'] = qa_q_path_html($q['postid'], $q['title']);
             $data[$k]['tags'] = $q['tags'];
             $data[$k]['answers'] = $q['acount'];
         }
         echo json_encode($data);
     }
     die;
 }
Ejemplo n.º 18
0
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors)
{
    $parentid = $parent['postid'];
    $prefix = 'c' . $parentid . '_';
    $in = array('name' => qa_post_text($prefix . 'name'), 'notify' => qa_post_text($prefix . 'notify') !== null, 'email' => qa_post_text($prefix . 'email'), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false);
    qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']);
    $errors = array();
    if (!qa_check_form_security_code('comment-' . $parent['postid'], qa_post_text($prefix . 'code'))) {
        $errors['content'] = qa_lang_html('misc/form_security_again');
    } else {
        $filtermodules = qa_load_modules_with('filter', 'filter_comment');
        foreach ($filtermodules as $filtermodule) {
            $oldin = $in;
            $filtermodule->filter_comment($in, $errors, $question, $parent, null);
            qa_update_post_text($in, $oldin);
        }
        if ($usecaptcha) {
            qa_captcha_validate_post($errors);
        }
        if (empty($errors)) {
            $testwords = implode(' ', qa_string_to_words($in['content']));
            foreach ($commentsfollows as $comment) {
                if ($comment['basetype'] == 'C' && $comment['parentid'] == $parentid && !$comment['hidden']) {
                    if (implode(' ', qa_string_to_words($comment['content'])) == $testwords) {
                        $errors['content'] = qa_lang_html('question/duplicate_content');
                    }
                }
            }
        }
        if (empty($errors)) {
            $userid = qa_get_logged_in_userid();
            $handle = qa_get_logged_in_handle();
            $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
            // create a new cookie if necessary
            $commentid = qa_comment_create($userid, $handle, $cookieid, $in['content'], $in['format'], $in['text'], $in['notify'], $in['email'], $question, $parent, $commentsfollows, $in['queued'], $in['name']);
            return $commentid;
        }
    }
    return null;
}
function qa_page_q_do_comment($answer)
{
    global $qa_login_userid, $qa_cookieid, $question, $questionid, $formtype, $formpostid, $errors, $reloadquestion, $pageerror, $qa_request, $ineditor, $incomment, $informat, $innotify, $inemail, $commentsfollows, $jumptoanchor, $usecaptcha;
    $parent = isset($answer) ? $answer : $question;
    switch (qa_user_permit_error('permit_post_c', 'C')) {
        case 'login':
            $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_login'), $qa_request);
            break;
        case 'confirm':
            $pageerror = qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), $qa_request);
            break;
        case 'limit':
            $pageerror = qa_lang_html('question/comment_limit');
            break;
        default:
            $pageerror = qa_lang_html('users/no_permission');
            break;
        case false:
            $incomment = qa_post_text('comment');
            if (!isset($incomment)) {
                $formtype = 'c_add';
                $formpostid = $parent['postid'];
                // show form first time
            } else {
                $innotify = qa_post_text('notify') ? true : false;
                $inemail = qa_post_text('email');
                qa_get_post_content('editor', 'comment', $ineditor, $incomment, $informat, $intext);
                $errors = qa_comment_validate($incomment, $informat, $intext, $innotify, $inemail);
                if ($usecaptcha) {
                    qa_captcha_validate($_POST, $errors);
                }
                if (empty($errors)) {
                    $isduplicate = false;
                    foreach ($commentsfollows as $comment) {
                        if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) {
                            if (implode(' ', qa_string_to_words($comment['content'])) == implode(' ', qa_string_to_words($incomment))) {
                                $isduplicate = true;
                            }
                        }
                    }
                    if (!$isduplicate) {
                        if (!isset($qa_login_userid)) {
                            $qa_cookieid = qa_cookie_get_create();
                        }
                        // create a new cookie if necessary
                        $commentid = qa_comment_create($qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $incomment, $informat, $intext, $innotify, $inemail, $question, $answer, $commentsfollows);
                        qa_report_write_action($qa_login_userid, $qa_cookieid, 'c_post', $questionid, @$answer['postid'], $commentid);
                        qa_redirect($qa_request, null, null, null, qa_anchor(isset($answer) ? 'A' : 'Q', $parent['postid']));
                    } else {
                        $pageerror = qa_lang_html('question/duplicate_content');
                    }
                } else {
                    $formtype = 'c_add';
                    $formpostid = $parent['postid'];
                    // show form again
                }
            }
            break;
    }
}