Exemplo n.º 1
0
    function admin_form(&$qa_content)
    {
        // Process form input
        $ok = null;
        if (qa_clicked('theme_switch_save')) {
            if (!qa_post_text('theme_switch_enable')) {
                qa_opt('site_theme', qa_opt('theme_switch_default'));
            }
            qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usermeta (
					meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
					user_id bigint(20) unsigned NOT NULL,
					meta_key varchar(255) DEFAULT NULL,
					meta_value longtext,
					PRIMARY KEY (meta_id),
					UNIQUE (user_id,meta_key)
					) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
            qa_opt('theme_switch_enable', (bool) qa_post_text('theme_switch_enable'));
            qa_opt('theme_switch_default', qa_post_text('theme_switch_default'));
            qa_opt('theme_switch_title', qa_post_text('theme_switch_title'));
            qa_opt('theme_switch_text', qa_post_text('theme_switch_text'));
            qa_opt('theme_switch_enable_mobile', (bool) qa_post_text('theme_switch_enable_mobile'));
            qa_opt('theme_switch_mobile', qa_post_text('theme_switch_mobile'));
            global $qa_request;
            qa_redirect($qa_request, array('ok' => qa_lang_html('admin/options_saved')));
        }
        // Create the form for display
        $themes = qa_admin_theme_options();
        $fields = array();
        $fields[] = array('label' => 'Enable theme switching', 'tags' => 'NAME="theme_switch_enable"', 'value' => qa_opt('theme_switch_enable'), 'type' => 'checkbox');
        $fields[] = array('label' => 'Default theme', 'tags' => 'NAME="theme_switch_default"', 'type' => 'select', 'options' => qa_admin_theme_options(), 'value' => @$themes[qa_opt('theme_switch_default')]);
        $fields[] = array('label' => 'Theme switch title', 'type' => 'text', 'value' => qa_html(qa_opt('theme_switch_title')), 'tags' => 'NAME="theme_switch_title"');
        $fields[] = array('label' => 'Theme switch text', 'type' => 'text', 'value' => qa_html(qa_opt('theme_switch_text')), 'tags' => 'NAME="theme_switch_text"');
        if (!function_exists('qa_register_plugin_overrides')) {
            // 1.4
            $fields[] = array('label' => 'Enable mobile theme', 'tags' => 'NAME="theme_switch_enable_mobile"', 'value' => qa_opt('theme_switch_enable_mobile'), 'type' => 'checkbox');
            $fields[] = array('label' => 'Mobile theme', 'tags' => 'NAME="theme_switch_mobile"', 'type' => 'select', 'options' => qa_admin_theme_options(), 'value' => @$themes[qa_opt('theme_switch_mobile')]);
        }
        return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="theme_switch_save"')));
    }
         $optionfield['error'] = qa_lang_html('admin/no_multibyte');
     }
     break;
 case 'neat_urls':
     $neatoptions = array();
     $rawoptions = array(QA_URL_FORMAT_NEAT, QA_URL_FORMAT_INDEX, QA_URL_FORMAT_PARAM, QA_URL_FORMAT_PARAMS, QA_URL_FORMAT_SAFEST);
     foreach ($rawoptions as $rawoption) {
         $neatoptions[$rawoption] = '<iframe src="' . qa_path_html('url/test/' . QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption) . '" width="20" height="16" style="vertical-align:middle; border:0" scrolling="no" frameborder="0"></iframe>&nbsp;' . '<small>' . qa_html(urldecode(qa_path('123/why-do-birds-sing', null, '/', $rawoption))) . ($rawoption == QA_URL_FORMAT_NEAT ? strtr(qa_lang_html('admin/neat_urls_note'), array('^1' => '<a href="http://www.question2answer.org/htaccess.php" target="_blank">', '^2' => '</a>')) : '') . '</small>';
     }
     qa_optionfield_make_select($optionfield, $neatoptions, $value, QA_URL_FORMAT_SAFEST);
     $optionfield['type'] = 'select-radio';
     $optionfield['note'] = qa_lang_html_sub('admin/url_format_note', '<span style=" ' . qa_admin_url_test_html() . '/span>');
     break;
 case 'site_theme':
 case 'site_theme_mobile':
     $themeoptions = qa_admin_theme_options();
     if (!isset($themeoptions[$value])) {
         $value = 'Classic';
     }
     // check here because we also need $value for qa_admin_addon_metadata()
     qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic');
     $contents = file_get_contents(QA_THEME_DIR . $value . '/qa-styles.css');
     $metadata = qa_admin_addon_metadata($contents, array('uri' => 'Theme URI', 'version' => 'Theme Version', 'date' => 'Theme Date', 'author' => 'Theme Author', 'author_uri' => 'Theme Author URI', 'license' => 'Theme License', 'update' => 'Theme Update Check URI'));
     if (strlen(@$metadata['version'])) {
         $namehtml = 'v' . qa_html($metadata['version']);
     } else {
         $namehtml = '';
     }
     if (strlen(@$metadata['uri'])) {
         if (!strlen($namehtml)) {
             $namehtml = qa_html($value);
Exemplo n.º 3
0
 function theme_switch_form()
 {
     // displays signature form in user profile
     global $qa_request;
     $handle = preg_replace('/^[^\\/]+\\/([^\\/]+).*/', "\$1", $qa_request);
     $userid = $this->getuserfromhandle($handle);
     if (!$userid) {
         return;
     }
     if (qa_get_logged_in_handle() && qa_get_logged_in_handle() == $handle) {
         if (qa_clicked('theme_switch_save')) {
             qa_db_query_sub('INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES (#,$,$) ON DUPLICATE KEY UPDATE meta_value=$', $userid, 'custom_theme', qa_post_text('theme_choice'), qa_post_text('theme_choice'));
             qa_redirect($this->request, array('ok' => qa_lang_html('admin/options_saved')));
         } else {
             if (qa_clicked('theme_switch_user_reset')) {
                 qa_db_query_sub('DELETE FROM ^usermeta WHERE user_id=# AND meta_key=$', $userid, 'custom_theme');
                 qa_redirect($this->request, array('ok' => qa_lang_html('admin/options_reset')));
             }
         }
         require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
         $ok = qa_get('ok') ? qa_get('ok') : null;
         $theme_choice = qa_db_read_one_value(qa_db_query_sub('SELECT meta_value FROM ^usermeta WHERE user_id=# AND meta_key=$', $userid, 'custom_theme'), true);
         $themes = qa_admin_theme_options();
         $fields['themes'] = array('label' => qa_opt('theme_switch_text'), 'tags' => 'NAME="theme_choice"', 'type' => 'select', 'options' => qa_admin_theme_options(), 'value' => @$themes[$theme_choice]);
         $form = array('ok' => $ok && !isset($error) ? $ok : null, 'style' => 'tall', 'title' => '<a name="theme_text"></a>' . qa_opt('theme_switch_title'), 'tags' => 'action="' . qa_self_html() . '#theme_text" method="POST"', 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="theme_switch_user_reset"'), array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="theme_switch_save"')));
         return $form;
     }
 }
Exemplo n.º 4
0
     if (!qa_has_multibyte()) {
         $optionfield['error'] = qa_lang_html('admin/no_multibyte');
     }
     break;
 case 'neat_urls':
     $neatoptions = array();
     $rawoptions = array(QA_URL_FORMAT_NEAT, QA_URL_FORMAT_INDEX, QA_URL_FORMAT_PARAM, QA_URL_FORMAT_PARAMS, QA_URL_FORMAT_SAFEST);
     foreach ($rawoptions as $rawoption) {
         $neatoptions[$rawoption] = '<IFRAME SRC="' . qa_path_html('url/test/' . QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption) . '" WIDTH="20" HEIGHT="16" STYLE="vertical-align:middle; border:0" SCROLLING="no" FRAMEBORDER="0"></IFRAME>&nbsp;' . '<SMALL>' . qa_html(urldecode(qa_path('123/why-do-birds-sing', null, '/', $rawoption))) . ($rawoption == QA_URL_FORMAT_NEAT ? strtr(qa_lang_html('admin/neat_urls_note'), array('^1' => '<A HREF="http://www.question2answer.org/htaccess.php" TARGET="_blank">', '^2' => '</A>')) : '') . '</SMALL>';
     }
     qa_optionfield_make_select($optionfield, $neatoptions, $value, QA_URL_FORMAT_SAFEST);
     $optionfield['type'] = 'select-radio';
     $optionfield['note'] = qa_lang_html_sub('admin/url_format_note', '<SPAN STYLE=" ' . qa_admin_url_test_html() . '/SPAN>');
     break;
 case 'site_theme':
     qa_optionfield_make_select($optionfield, qa_admin_theme_options(), $value, 'Default');
     break;
 case 'tags_or_categories':
     qa_optionfield_make_select($optionfield, array('' => qa_lang_html('admin/no_classification'), 't' => qa_lang_html('admin/tags'), 'c' => qa_lang_html('admin/categories'), 'tc' => qa_lang_html('admin/tags_and_categories')), $value, 'tc');
     $optionfield['error'] = '';
     if (qa_opt('cache_tagcount') && !qa_using_tags()) {
         $optionfield['error'] .= qa_lang_html('admin/tags_not_shown') . ' ';
     }
     if (!qa_using_categories()) {
         foreach ($categories as $category) {
             if ($category['qcount']) {
                 $optionfield['error'] .= qa_lang_html('admin/categories_not_shown');
                 break;
             }
         }
     }