本文整理汇总了PHP中qa_tags_to_tagstring函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_tags_to_tagstring函数的具体用法?PHP qa_tags_to_tagstring怎么用?PHP qa_tags_to_tagstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_tags_to_tagstring函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_question
public function filter_question(&$question, &$errors, $oldquestion)
{
if ($oldquestion === null) {
// a new post requires these fields be set
$question['title'] = isset($question['title']) ? $question['title'] : '';
$question['content'] = isset($question['content']) ? $question['content'] : '';
$question['text'] = isset($question['text']) ? $question['text'] : '';
$question['tags'] = isset($question['tags']) ? $question['tags'] : array();
}
$qminlength = qa_opt('min_len_q_title');
$qmaxlength = max($qminlength, min(qa_opt('max_len_q_title'), QA_DB_MAX_TITLE_LENGTH));
$this->validate_field_length($errors, $question, 'title', $qminlength, $qmaxlength);
$this->validate_field_length($errors, $question, 'content', 0, QA_DB_MAX_CONTENT_LENGTH);
// for storage
$this->validate_field_length($errors, $question, 'text', qa_opt('min_len_q_content'), null);
// for display
if (isset($question['tags'])) {
$counttags = count($question['tags']);
$maxtags = qa_opt('max_num_q_tags');
$mintags = min(qa_opt('min_num_q_tags'), $maxtags);
if ($counttags < $mintags) {
$errors['tags'] = qa_lang_sub('question/min_tags_x', $mintags);
} elseif ($counttags > $maxtags) {
$errors['tags'] = qa_lang_sub('question/max_tags_x', $maxtags);
} else {
$tagstring = qa_tags_to_tagstring($question['tags']);
if (qa_strlen($tagstring) > QA_DB_MAX_TAGS_LENGTH) {
// for storage
$errors['tags'] = qa_lang_sub('main/max_length_x', $maxlength);
}
}
}
$this->validate_post_email($errors, $question);
}
示例2: filter_question
function filter_question(&$question, &$errors, $oldquestion)
{
$this->validate_length($errors, 'title', @$question['title'], qa_opt('min_len_q_title'), max(qa_opt('min_len_q_title'), min(qa_opt('max_len_q_title'), QA_DB_MAX_TITLE_LENGTH)));
$this->validate_length($errors, 'content', @$question['content'], 0, QA_DB_MAX_CONTENT_LENGTH);
// for storage
$this->validate_length($errors, 'content', @$question['text'], qa_opt('min_len_q_content'), null);
// for display
if (isset($question['tags'])) {
$counttags = count($question['tags']);
$mintags = min(qa_opt('min_num_q_tags'), qa_opt('max_num_q_tags'));
if ($counttags < $mintags) {
$errors['tags'] = qa_lang_sub('question/min_tags_x', $mintags);
} elseif ($counttags > qa_opt('max_num_q_tags')) {
$errors['tags'] = qa_lang_sub('question/max_tags_x', qa_opt('max_num_q_tags'));
} else {
$this->validate_length($errors, 'tags', qa_tags_to_tagstring($question['tags']), 0, QA_DB_MAX_TAGS_LENGTH);
}
// for storage
}
$this->validate_post_email($errors, $question);
}
示例3: qa_update_post_text
$filtermodule->filter_question($in, $errors, null);
qa_update_post_text($in, $oldin);
}
if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($in['categoryid'])) {
$errors['categoryid'] = qa_lang_html('question/category_required');
} elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) {
$errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed');
}
if ($captchareason) {
require_once 'qa-app-captcha.php';
qa_captcha_validate_post($errors);
}
if (empty($errors)) {
$cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
// create a new cookie if necessary
$questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']);
qa_redirect(qa_q_request($questionid, $in['title']));
// our work is done here
}
}
}
// Prepare content for theme
$qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid'])));
$qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title');
$qa_content['error'] = @$errors['page'];
$editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs');
$editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
$field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false);
$field['label'] = qa_lang_html('question/q_content_label');
$field['error'] = qa_html(@$errors['content']);
$custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : '';
示例4: qa_page_q_edit_q_submit
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;
}
示例5: qa_post_tags_to_tagstring
function qa_post_tags_to_tagstring($tags)
{
if (is_array($tags)) {
$tags = implode(',', $tags);
}
return qa_tags_to_tagstring(array_unique(preg_split('/\\s*[,,]\\s*/', qa_strtolower(strtr($tags, '/', ' ')), -1, PREG_SPLIT_NO_EMPTY)));
}
示例6: test__qa_tags_to_tagstring
public function test__qa_tags_to_tagstring()
{
$test = qa_tags_to_tagstring(array('Hello', 'World'));
$expected = 'Hello,World';
$this->assertEquals($expected, $test);
}
示例7: qa_page_q_edit_q_submit
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;
}
示例8: qa_user_use_captcha
break;
}
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);
示例9: qa_flags_clear_all
if (qa_clicked('doclearflagsq') && $question['clearflaggable']) {
require_once QA_INCLUDE_DIR . 'qa-app-votes.php';
qa_flags_clear_all($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid);
qa_redirect($qa_request);
}
// Process edit or save button for question
if ($question['editbutton']) {
if (qa_clicked('docancel')) {
qa_redirect($qa_request);
} elseif (qa_clicked('doeditq')) {
qa_redirect($qa_request, array('state' => 'edit-' . $questionid));
} elseif (qa_clicked('dosaveq') && qa_page_q_permit_edit($question, 'permit_edit_q')) {
$incategoryid = qa_get_category_field_value('category');
$inqtitle = qa_post_text('qtitle');
$inqtags = qa_get_tags_field_value('qtags');
$tagstring = qa_using_tags() ? qa_tags_to_tagstring($inqtags) : $question['tags'];
qa_get_post_content('editor', 'qcontent', $ineditor, $inqcontent, $inqformat, $inqtext);
$innotify = qa_post_text('notify') ? true : false;
$inemail = qa_post_text('email');
$qerrors = qa_question_validate($inqtitle, $inqcontent, $inqformat, $inqtext, $tagstring, $innotify, $inemail);
if (empty($qerrors)) {
$setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $innotify, $inemail) : $question['notify'];
if (qa_using_categories() && strcmp($incategoryid, $question['categoryid'])) {
qa_question_set_category($question, $incategoryid, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $answers, $commentsfollows);
}
qa_question_set_content($question, $inqtitle, $inqcontent, $inqformat, $inqtext, $tagstring, $setnotify, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid);
qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_edit', $questionid, null, null);
if (qa_q_request($questionid, $question['title']) != qa_q_request($questionid, $inqtitle)) {
qa_redirect(qa_q_request($questionid, $inqtitle));
} else {
qa_redirect($qa_request);