本文整理汇总了PHP中qa_opt函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_opt函数的具体用法?PHP qa_opt怎么用?PHP qa_opt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_opt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
global $qa_login_userid, $questionid, $relatedcount, $question, $relatedquestions, $qa_cookieid, $usershtml;
list($question, $relatedquestions) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid));
if ($relatedcount > 1 && !$question['hidden']) {
$minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
foreach ($relatedquestions as $key => $related) {
if ($related['postid'] == $questionid || $related['score'] < $minscore) {
unset($relatedquestions[$key]);
}
}
if (count($relatedquestions)) {
$themeobject->output('<h2>' . qa_lang('main/related_qs_title') . '</h2>');
} else {
$themeobject->output('<h2>' . qa_lang('main/no_related_qs_title') . '</h2>');
}
$upper = qa_opt('related_qs_num') < count($relatedquestions) ? qa_opt('related_qs_num') : count($relatedquestions);
foreach ($relatedquestions as $related) {
if ($upper <= 0) {
break;
}
$themeobject->output('<p style="margin:0 0 10px 0; font-weight:bold;"><a href="' . qa_path_html(qa_q_request($related['postid'], $related['title'])) . '">' . $related['title'] . '</a></p>');
$upper--;
}
}
}
示例2: q_list
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
}
示例3: doctype
function doctype()
{
$this->content['navigation']['footer']['feedback']['label'] = '<div class="feedback-image"></div>';
$this->content['search']['button_label'] = '';
$this->content['logo'] = '<A HREF="../" CLASS="qa-logo-link">' . qa_opt('site_title') . '</A>';
qa_html_theme_base::doctype();
}
示例4: head_custom
function head_custom()
{
parent::head_custom();
$tmpl = array('ask', 'question');
if (!in_array($this->template, $tmpl)) {
return;
}
$hidecss = qa_opt($this->cssopt) === '1';
$usehljs = qa_opt($this->hljsopt) === '1';
$wmd_buttons = QA_HTML_THEME_LAYER_URLTOROOT . 'pagedown/wmd-buttons.png';
$this->output_raw("<style>\n" . ".wmd-button > span { background-image: url('{$wmd_buttons}') }\n");
// display CSS for Markdown Editor
if (!$hidecss) {
$cssWMD = file_get_contents(QA_HTML_THEME_LAYER_DIRECTORY . 'pagedown/wmd.css');
$this->output_raw($cssWMD);
// display CSS for HighlightJS
if ($usehljs) {
$cssHJS = file_get_contents(QA_HTML_THEME_LAYER_DIRECTORY . 'pagedown/highlightjs.css');
$this->output_raw($cssHJS);
}
}
$this->output_raw("</style>\n\n");
// set up HighlightJS
if ($usehljs) {
$this->output_raw("<script src=\"" . QA_HTML_THEME_LAYER_URLTOROOT . "pagedown/highlight.min.js\"></script>\n" . "<script type=\"text/javascript\">\n" . "\$(function(){\n" . "\t\$('.wmd-input').keypress(function(){\n" . "\t\twindow.clearTimeout(hljs.Timeout);\n" . "\t\thljs.Timeout = window.setTimeout(function() {\n" . "\t\t\thljs.initHighlighting.called = false;\n" . "\t\t\thljs.initHighlighting();\n" . "\t\t}, 500);\n" . "\t});\n" . "\twindow.setTimeout(function() {\n" . "\t\thljs.initHighlighting.called = false;\n" . "\t\thljs.initHighlighting();\n" . "\t}, 500);\n" . "});\n" . "</script>\n\n");
}
//by hoangweb
//$cssHJS = file_get_contents( QA_HTML_THEME_LAYER_DIRECTORY . 'pagedown/hoangweb/dropzone.css' ); //print css
/*$this->output_raw("<style>\n");
$this->output_raw($cssHJS);
$this->output_raw("</style>\n\n");*/
$this->output_raw("<link rel=\"stylesheet\" type=\"text/css\" href=\"" . QA_HTML_THEME_LAYER_URLTOROOT . "pagedown/hoangweb/dropzone.css\"/>");
$this->output_raw("<link rel=\"stylesheet\" type=\"text/css\" href=\"" . QA_HTML_THEME_LAYER_URLTOROOT . "pagedown/hoangweb/style.css\"/>");
$this->output_raw("<script src=\"" . QA_HTML_THEME_LAYER_URLTOROOT . "pagedown/hoangweb/dropzone.js\"></script>");
}
示例5: admin_form
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('adchat_save_button')) {
qa_opt('adchat_plugin_css', qa_post_text('adchat_plugin_css'));
if (qa_post_text('adchat-expand-categories') == 1) {
qa_opt('adchat-expand-categories', "1");
} else {
qa_opt('adchat-expand-categories', "0");
}
$ok = qa_lang('admin/options_saved');
} else {
if (qa_clicked('adchat_reset_button')) {
foreach ($_POST as $i => $v) {
$def = $this->option_default($i);
if ($def !== null) {
qa_opt($i, $def);
}
}
$ok = qa_lang('admin/options_reset');
}
}
// Create the form for display
$fields = array();
$fields[] = array('type' => 'blank');
$fields[] = array('label' => 'Adchat custom css', 'tags' => 'NAME="adchat_plugin_css"', 'value' => qa_opt('adchat_plugin_css'), 'type' => 'textarea', 'rows' => 20);
$fields[] = array('label' => 'Make all categories into chat room', 'note' => 'Otherwise only top level categories are made to chat room', 'tags' => 'NAME="adchat-expand-categories"', 'value' => qa_opt('adchat-expand-categories'), 'type' => 'checkbox');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="adchat_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="adchat_reset_button"')));
}
示例6: qa_permit_check
function qa_permit_check($opt)
{
if (qa_opt($opt) == QA_PERMIT_POINTS) {
return qa_get_logged_in_points() >= qa_opt($opt . '_points');
}
return !qa_permit_value_error(qa_opt($opt), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags());
}
示例7: qa_share_buttons
function qa_share_buttons($q_view)
{
if (qa_opt('expert_question_enable')) {
$qid = $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) {
return;
}
}
$url = qa_path_html(qa_q_request($q_view['raw']['postid'], $q_view['raw']['title']), null, qa_opt('site_url'));
$code = array('facebook' => '<iframe src="//www.facebook.com/plugins/like.php?href=' . qa_path_html(qa_q_request($this->content['q_view']['raw']['postid'], $this->content['q_view']['raw']['title']), null, qa_opt('site_url')) . '&send=false&layout=standard&width=53&layout=button_count&show_faces=false&action=like&colorscheme=light&font&height=20&appId=170382616390886" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:53px; height:20px;" allowTransparency="true"></iframe>', 'twitter' => '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>', 'google' => '<g:plusone size="medium" count="false"></g:plusone>', 'linkedin' => '<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script>', 'email' => '<a title="Share this question via email" id="share-button-email" href="mailto:?subject=' . rawurlencode('[' . qa_opt('site_title') . '] ' . $q_view['raw']['title']) . '&body=' . rawurlencode($url) . '"><img height="24" src="' . QA_HTML_THEME_LAYER_URLTOROOT . 'qa-share-mail.png' . '"/></a>');
// sort by weight
$weight = array('facebook' => qa_opt('share_plugin_facebook_weight'), 'twitter' => qa_opt('share_plugin_twitter_weight'), 'google' => qa_opt('share_plugin_google_weight'), 'linkedin' => qa_opt('share_plugin_linkedin_weight'), 'email' => qa_opt('share_plugin_email_weight'));
asort($weight);
// output
foreach ($weight as $key => $val) {
if (qa_opt('share_plugin_' . $key)) {
$shares[] = $code[$key];
}
}
if (empty($shares)) {
return null;
}
$output = implode(' ', $shares);
return $output;
}
示例8: qa_priv_notification
function qa_priv_notification($uid, $oid, $badge_slug)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
if (QA_FINAL_EXTERNAL_USERS) {
$publictohandle = qa_get_public_from_userids(array($uid));
$handle = @$publictohandle[$uid];
} else {
$user = qa_db_single_select(qa_db_user_account_selectspec($uid, true));
$handle = @$user['handle'];
}
$subject = qa_opt('badge_email_subject');
$body = qa_opt('badge_email_body');
$body = preg_replace('/\\^if_post_text="([^"]*)"/', $oid ? '$1' : '', $body);
// if post text
$site_url = qa_opt('site_url');
$profile_url = qa_path_html('user/' . $handle, null, $site_url);
if ($oid) {
$post = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $oid), true);
if ($post['parentid']) {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $post['parentid']), true);
}
if (isset($parent)) {
$anchor = urlencode(qa_anchor($post['basetype'], $oid));
$post_title = $parent['title'];
$post_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
} else {
$post_title = $post['title'];
$post_url = qa_path_html(qa_q_request($post['postid'], $post['title']), null, qa_opt('site_url'));
}
}
$subs = array('^badge_name' => qa_opt('badge_' . $badge_slug . '_name'), '^post_title' => @$post_title, '^post_url' => @$post_url, '^profile_url' => $profile_url, '^site_url' => $site_url);
qa_send_notification($uid, '@', $handle, $subject, $body, $subs);
}
示例9: output_widget
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>');
}
}
示例10: admin_form
function admin_form(&$qa_content)
{
// process the admin form if admin hit Save-Changes-button
$ok = null;
if (qa_clicked('qa_blog_save')) {
qa_opt('qa_blog_enabled', (bool) qa_post_text('qa_blog_enabled'));
qa_opt('qa_blog_title', qa_post_text('qa_blog_title'));
qa_opt('qa_blog_tagline', qa_post_text('qa_blog_tagline'));
qa_opt('qa_blog_cat_1', qa_post_text('qa_blog_cat_1'));
qa_opt('qa_blog_cat_2', qa_post_text('qa_blog_cat_2'));
qa_opt('qa_blog_cat_3', qa_post_text('qa_blog_cat_3'));
qa_opt('qa_blog_cat_4', qa_post_text('qa_blog_cat_4'));
qa_opt('qa_blog_cat_5', qa_post_text('qa_blog_cat_5'));
qa_opt('qa_blog_rules', qa_post_text('qa_blog_rules'));
qa_opt('qa_blog_content_max', (int) qa_post_text('qa_blog_content_max_field'));
$ok = qa_lang('qa_blog_lang/blog_save');
}
qa_set_display_rules($qa_content, array('field_2' => 'field_1', 'field_3' => 'field_1', 'field_5' => 'field_1', 'field_6' => 'field_1', 'field_7' => 'field_1', 'field_8' => 'field_1', 'field_9' => 'field_1', 'field_10' => 'field_1', 'field_11' => 'field_1'));
// form fields to display frontend for admin
$fields = array();
$fields[] = array('label' => qa_lang('qa_blog_lang/enable_plugin'), 'type' => 'checkbox', 'value' => qa_opt('qa_blog_enabled'), 'tags' => 'name="qa_blog_enabled" id="field_1"');
$fields[] = array('id' => 'field_2', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/blog_title'), 'value' => qa_opt('qa_blog_title'), 'tags' => 'name="qa_blog_title"');
$fields[] = array('id' => 'field_3', 'type' => 'textarea', 'label' => qa_lang('qa_blog_lang/blog_tagline'), 'value' => qa_opt('qa_blog_tagline'), 'rows' => 4, 'tags' => 'name="qa_blog_tagline"');
$fields[] = array('id' => 'field_5', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_1'), 'value' => qa_opt('qa_blog_cat_1'), 'tags' => 'name="qa_blog_cat_1"');
$fields[] = array('id' => 'field_6', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_2'), 'value' => qa_opt('qa_blog_cat_2'), 'tags' => 'name="qa_blog_cat_2"');
$fields[] = array('id' => 'field_7', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_3'), 'value' => qa_opt('qa_blog_cat_3'), 'tags' => 'name="qa_blog_cat_3"');
$fields[] = array('id' => 'field_8', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_4'), 'value' => qa_opt('qa_blog_cat_4'), 'tags' => 'name="qa_blog_cat_4"');
$fields[] = array('id' => 'field_9', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_5'), 'value' => qa_opt('qa_blog_cat_5'), 'tags' => 'name="qa_blog_cat_5"');
$fields[] = array('id' => 'field_10', 'type' => 'textarea', 'label' => qa_lang('qa_blog_lang/blog_rules'), 'value' => qa_opt('qa_blog_rules'), 'tags' => 'name="qa_blog_rules"', 'rows' => 4);
$fields[] = array('id' => 'field_11', 'label' => qa_lang('qa_blog_lang/content_max'), 'suffix' => qa_lang('qa_blog_lang/suffix'), 'type' => 'number', 'value' => (int) qa_opt('qa_blog_content_max'), 'tags' => 'name="qa_blog_content_max_field"');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="qa_blog_save"')));
}
示例11: admin_form
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('cp_save')) {
// Save
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT \'\',
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
qa_opt('cp_enable', (bool) qa_post_text('cp_enable'));
$ok = qa_lang('admin/options_saved');
} else {
if (qa_clicked('cp_reset')) {
// Reset
foreach ($_POST as $i => $v) {
$def = $this->option_default($i);
if ($def !== null) {
qa_opt($i, $def);
}
}
qa_opt('cp_enable', true);
$ok = qa_lang('admin/options_reset');
}
}
// Create the form for display
$fields = array();
$fields[] = array('label' => qa_lang('cp/enable_community_posts'), 'tags' => 'NAME="cp_enable"', 'value' => qa_opt('cp_enable'), 'type' => 'checkbox');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="cp_save"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="cp_reset"')));
}
示例12: output_widget
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);
}
示例13: mp_announcement_create
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid)
{
/*
* Proceeds to create an announcement
*
*/
require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'mp-app-users.php';
// persist data to database
$postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid);
qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null);
// update new post with category path hierarchy
qa_db_posts_calc_category_path($postid);
// send notifications
if ($notify && isset($postid)) {
$category = mp_get_categoryinfo($categoryid);
$recipients = mp_get_category_userids($categoryid);
foreach ($recipients as $recipient) {
// retrieve the user flags
$userflags = mp_get_user_flags($recipient['userid']);
// check user flags to determine whether user should be notified or not
// of the new answer post
if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) {
qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null)));
}
}
}
// report announcement create event
qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify));
return $postid;
}
示例14: embed_replace
function embed_replace($text)
{
$w = qa_opt('embed_video_width');
$h = qa_opt('embed_video_height');
$w2 = qa_opt('embed_image_width');
$h2 = qa_opt('embed_image_height');
$types = array('youtube' => array(array('https{0,1}:\\/\\/w{0,3}\\.*youtube\\.com\\/watch\\?\\S*v=([A-Za-z0-9_-]+)[^< ]*', '<iframe width="' . $w . '" height="' . $h . '" src="http://www.youtube.com/embed/$1?wmode=transparent" frameborder="0" allowfullscreen></iframe>'), array('https{0,1}:\\/\\/w{0,3}\\.*youtu\\.be\\/([A-Za-z0-9_-]+)[^< ]*', '<iframe width="' . $w . '" height="' . $h . '" src="http://www.youtube.com/embed/$1?wmode=transparent" frameborder="0" allowfullscreen></iframe>')), 'vimeo' => array(array('https{0,1}:\\/\\/w{0,3}\\.*vimeo\\.com\\/([0-9]+)[^< ]*', '<iframe src="http://player.vimeo.com/video/$1?title=0&byline=0&portrait=0&wmode=transparent" width="' . $w . '" height="' . $h . '" frameborder="0"></iframe>')), 'metacafe' => array(array('https{0,1}:\\/\\/w{0,3}\\.*metacafe\\.com\\/watch\\/([0-9]+)\\/([a-z0-9_]+)[^< ]*', '<embed flashVars="playerVars=showStats=no|autoPlay=no" src="http://www.metacafe.com/fplayer/$1/$2.swf" width="' . $w . '" height="' . $h . '" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_$1" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>')), 'dailymotion' => array(array('https{0,1}:\\/\\/w{0,3}\\.*dailymotion\\.com\\/video\\/([A-Za-z0-9]+)[^< ]*', '<iframe frameborder="0" width="' . $w . '" height="' . $h . '" src="http://www.dailymotion.com/embed/video/$1?wmode=transparent"></iframe>')), 'image' => array(array('(https*:\\/\\/[-\\%_\\/.a-zA-Z0-9+]+\\.(png|jpg|jpeg|gif|bmp))[^< ]*', '<img src="$1" style="max-width:' . $w2 . 'px;max-height:' . $h2 . 'px" />', 'img')), 'mp3' => array(array('(https*:\\/\\/[-\\%_\\/.a-zA-Z0-9]+\\.mp3)[^< ]*', qa_opt('embed_mp3_player_code'), 'mp3')), 'gmap' => array(array('(https*:\\/\\/maps.google.com\\/?[^< ]+)', '<iframe width="' . qa_opt('embed_gmap_width') . '" height="' . qa_opt('embed_gmap_height') . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="$1&ie=UTF8&output=embed"></iframe><br /><small><a href="$1&ie=UTF8&output=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>', 'gmap')));
foreach ($types as $t => $ra) {
foreach ($ra as $r) {
if (!isset($r[2]) && !qa_opt('embed_enable') || isset($r[2]) && !qa_opt('embed_enable_' . $r[2])) {
continue;
}
if (isset($r[2]) && @$r[2] == 'img' && qa_opt('embed_enable_thickbox') && preg_match('/MSIE [5-7]/', $_SERVER['HTTP_USER_AGENT']) == 0) {
preg_match_all('/' . $r[0] . '/', $text, $imga);
if (!empty($imga)) {
foreach ($imga[1] as $img) {
$replace = '<a href="' . $img . '" class="thickbox"><img src="' . $img . '" style="max-width:' . $w2 . 'px;max-height:' . $h2 . 'px" /></a>';
$text = preg_replace('|<a[^>]+>' . $img . '</a>|i', $replace, $text);
$text = preg_replace('|(?<![\'"=])' . $img . '|i', $replace, $text);
}
}
continue;
}
$text = preg_replace('/<a[^>]+>' . $r[0] . '<\\/a>/i', $r[1], $text);
$text = preg_replace('/(?<![\'"=])' . $r[0] . '/i', $r[1], $text);
}
}
return $text;
}
示例15: admin_form
function admin_form(&$qa_content)
{
$ok = null;
if (qa_clicked('short_url_save_button')) {
qa_opt('short_url_content_on', (bool) qa_post_text('short_url_content_on'));
qa_opt('short_url_bitly_username', (string) qa_post_text('short_url_bitly_username'));
qa_opt('short_url_bitly_api_key', (string) qa_post_text('short_url_bitly_api_key'));
$ok = qa_lang('admin/options_saved');
} else {
if (qa_clicked('short_url_reset_button')) {
foreach ($_POST as $i => $v) {
$def = $this->option_default($i);
if ($def !== null) {
qa_opt($i, $def);
}
}
$ok = qa_lang('admin/options_reset');
}
}
$fields = array();
$ready = strlen(qa_opt('short_url_bitly_username')) && strlen(qa_opt('short_url_bitly_api_key'));
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
$fields[] = array('label' => 'You cannot enable when in localhost', 'tags' => 'NAME="short_url_content_on"', 'value' => qa_opt('short_url_content_on'), 'type' => 'checkbox', 'disabled' => 'disabled');
} else {
$fields[] = array('label' => 'Enable Short Url', 'tags' => 'NAME="short_url_content_on"', 'value' => qa_opt('short_url_content_on'), 'type' => 'checkbox');
}
$fields[] = array('label' => 'Your Bitly username', 'tags' => 'NAME="short_url_bitly_username"', 'value' => qa_opt('short_url_bitly_username'), 'type' => 'string');
$fields[] = array('label' => 'Your Bitly api key', 'tags' => 'NAME="short_url_bitly_api_key"', 'value' => qa_opt('short_url_bitly_api_key'), 'type' => 'string', 'error' => $ready ? null : 'You can find your api key <a href="https://bitly.com/a/your_api_key">here</a>');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="short_url_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="short_url_reset_button"')));
}