public function admin_form(&$qa_content) { // Process form input $saved = false; if (qa_clicked('event_logger_save_button')) { qa_opt('event_logger_to_database', (int) qa_post_text('event_logger_to_database_field')); qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field')); qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field')); qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field')); $saved = true; } // Check the validity of the currently entered directory (if any) $directory = qa_opt('event_logger_directory'); $note = null; $error = null; if (!strlen($directory)) { $note = 'Please specify a directory that is writable by the web server.'; } elseif (!file_exists($directory)) { $error = 'This directory cannot be found. Please enter the full path.'; } elseif (!is_dir($directory)) { $error = 'This is a file. Please enter the full path of a directory.'; } elseif (!is_writable($directory)) { $error = 'This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.'; } // Create the form for display qa_set_display_rules($qa_content, array('event_logger_directory_display' => 'event_logger_to_files_field', 'event_logger_hide_header_display' => 'event_logger_to_files_field')); return array('ok' => $saved && !isset($error) ? 'Event log settings saved' : null, 'fields' => array(array('label' => 'Log events to <code>' . QA_MYSQL_TABLE_PREFIX . 'eventlog</code> database table', 'tags' => 'name="event_logger_to_database_field"', 'value' => qa_opt('event_logger_to_database'), 'type' => 'checkbox'), array('label' => 'Log events to daily log files', 'tags' => 'name="event_logger_to_files_field" id="event_logger_to_files_field"', 'value' => qa_opt('event_logger_to_files'), 'type' => 'checkbox'), array('id' => 'event_logger_directory_display', 'label' => 'Directory for log files - enter full path:', 'value' => qa_html($directory), 'tags' => 'name="event_logger_directory_field"', 'note' => $note, 'error' => qa_html($error)), array('id' => 'event_logger_hide_header_display', 'label' => 'Include header lines at top of each log file', 'type' => 'checkbox', 'tags' => 'name="event_logger_hide_header_field"', 'value' => !qa_opt('event_logger_hide_header'))), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="event_logger_save_button"'))); }
function admin_form(&$qa_content) { // Process form input $saved = false; if (qa_clicked('event_logger_save_button')) { qa_opt('event_logger_to_database', (int) qa_post_text('event_logger_to_database_field')); qa_opt('event_logger_to_files', qa_post_text('event_logger_to_files_field')); qa_opt('event_logger_directory', qa_post_text('event_logger_directory_field')); qa_opt('event_logger_hide_header', !qa_post_text('event_logger_hide_header_field')); $saved = true; // Create the database table if database logging was switched on if (qa_opt('event_logger_to_database')) { require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-maxima.php'; qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^eventlog (' . 'datetime DATETIME NOT NULL,' . 'ipaddress VARCHAR (15) CHARACTER SET ascii,' . 'userid ' . qa_get_mysql_user_column_type() . ',' . 'handle VARCHAR(' . QA_DB_MAX_HANDLE_LENGTH . '),' . 'cookieid BIGINT UNSIGNED,' . 'event VARCHAR (20) CHARACTER SET ascii NOT NULL,' . 'params VARCHAR (800) NOT NULL,' . 'KEY datetime (datetime),' . 'KEY ipaddress (ipaddress),' . 'KEY userid (userid),' . 'KEY event (event)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8'); } } // Check the validity of the currently entered directory (if any) $directory = qa_opt('event_logger_directory'); $note = null; $error = null; if (!strlen($directory)) { $note = 'Please specify a directory that is writable by the web server.'; } elseif (!file_exists($directory)) { $error = 'This directory cannot be found. Please enter the full path.'; } elseif (!is_dir($directory)) { $error = 'This is a file. Please enter the full path of a directory.'; } elseif (!is_writable($directory)) { $error = 'This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.'; } // Create the form for display qa_set_display_rules($qa_content, array('event_logger_directory_display' => 'event_logger_to_files_field', 'event_logger_hide_header_display' => 'event_logger_to_files_field')); return array('ok' => $saved && !isset($error) ? 'Event log settings saved' : null, 'fields' => array(array('label' => 'Log events to <code>' . QA_MYSQL_TABLE_PREFIX . 'eventlog</code> database table', 'tags' => 'NAME="event_logger_to_database_field"', 'value' => qa_opt('event_logger_to_database'), 'type' => 'checkbox'), array('label' => 'Log events to daily log files', 'tags' => 'NAME="event_logger_to_files_field" ID="event_logger_to_files_field"', 'value' => qa_opt('event_logger_to_files'), 'type' => 'checkbox'), array('id' => 'event_logger_directory_display', 'label' => 'Directory for log files (enter full path):', 'value' => qa_html($directory), 'tags' => 'NAME="event_logger_directory_field"', 'note' => $note, 'error' => $error), array('id' => 'event_logger_hide_header_display', 'label' => 'Include header lines at top of each log file', 'type' => 'checkbox', 'tags' => 'NAME="event_logger_hide_header_field"', 'value' => !qa_opt('event_logger_hide_header'))), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'NAME="event_logger_save_button"'))); }
function admin_form(&$qa_content) { // process config change $saved_msg = ''; if (qa_clicked('tag_synonyms_save_button')) { qa_opt('tag_synonyms', trim(qa_post_text('tag_synonyms_text'))); qa_opt('tag_synonyms_prevent', (int) qa_post_text('tag_synonyms_prevent')); qa_opt('tag_synonyms_rep', (int) qa_post_text('tag_synonyms_rep')); $saved_msg = 'Tag Synonyms settings saved'; // convert all old tags based on synonyms if (qa_post_text('tag_synonyms_convert')) { $synonyms = $this->_synonyms_to_array(qa_opt('tag_synonyms')); $edited = 0; qa_suspend_event_reports(true); // avoid infinite loop foreach ($synonyms as $syn) { list($questions, $qcount) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec(null, $syn['from'], 0, false, 500), qa_db_tag_count_qs_selectspec($syn['from'])); foreach ($questions as $q) { $oldtags = qa_tagstring_to_tags($q['tags']); $newtags = $this->_convert_tags($oldtags, $synonyms); qa_post_set_content($q['postid'], null, null, null, $newtags); $edited++; } } qa_suspend_event_reports(false); $saved_msg .= ' (and ' . $edited . ' tags edited)'; } } // set fields to show/hide when checkbox is clicked qa_set_display_rules($qa_content, array('tag_synonyms_rep' => 'tag_synonyms_prevent')); return array('ok' => $saved_msg, 'fields' => array(array('label' => 'Tag Synonyms', 'tags' => 'name="tag_synonyms_text" id="tag_synonyms_text"', 'value' => qa_opt('tag_synonyms'), 'type' => 'textarea', 'rows' => 20, 'note' => 'Put each pair of synonyms on a new line. <code>q2a,question2answer</code> means that a tag of <code>q2a</code> will be replaced by <code>question2answer</code>, while <code>help</code> on its own means that tag will be removed.'), array('label' => 'Also convert existing tags using above rules', 'tags' => 'name="tag_synonyms_convert" id="tag_synonyms_convert"', 'value' => '', 'type' => 'checkbox'), array('type' => 'blank'), array('label' => 'Prevent new users from creating new tags', 'tags' => 'name="tag_synonyms_prevent" id="tag_synonyms_prevent"', 'value' => qa_opt('tag_synonyms_prevent'), 'type' => 'checkbox'), array('id' => 'tag_synonyms_rep', 'label' => 'Minimum reputation to create new tags', 'value' => qa_opt('tag_synonyms_rep'), 'tags' => 'name="tag_synonyms_rep"', 'type' => 'number')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="tag_synonyms_save_button"'))); }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked(self::SAVE_BUTTON)) { qa_opt(self::FACEBOOK_PAGE_URL, qa_post_text(self::FACEBOOK_PAGE_URL)); // for like box qa_opt(self::SHOW_FB_LIKE_BOX, !!qa_post_text(self::SHOW_FB_LIKE_BOX)); qa_opt(self::LIKE_BOX_COLOR_SCHEME, qa_post_text(self::LIKE_BOX_COLOR_SCHEME)); qa_opt(self::LIKE_BOX_SHOW_HEADER, qa_post_text(self::LIKE_BOX_SHOW_HEADER)); qa_opt(self::LIKE_BOX_SHOW_BORDER, qa_post_text(self::LIKE_BOX_SHOW_BORDER)); qa_opt(self::LIKE_BOX_SHOW_FACES, qa_post_text(self::LIKE_BOX_SHOW_FACES)); qa_opt(self::LIKE_BOX_SHOW_DATA_STREAM, qa_post_text(self::LIKE_BOX_SHOW_DATA_STREAM)); qa_opt(self::LIKE_BOX_HEIGHT, qa_post_text(self::LIKE_BOX_HEIGHT)); qa_opt(self::LIKE_BOX_WIDTH, qa_post_text(self::LIKE_BOX_WIDTH)); // for modal qa_opt(self::SHOW_FB_LIKE_MODAL, !!qa_post_text(self::SHOW_FB_LIKE_MODAL)); qa_opt(self::MODAL_COLOR_SCHEME, qa_post_text(self::MODAL_COLOR_SCHEME)); qa_opt(self::MODAL_SHOW_HEADER, qa_post_text(self::MODAL_SHOW_HEADER)); qa_opt(self::MODAL_SHOW_BORDER, qa_post_text(self::MODAL_SHOW_BORDER)); qa_opt(self::MODAL_SHOW_FACES, qa_post_text(self::MODAL_SHOW_FACES)); qa_opt(self::MODAL_SHOW_DATA_STREAM, qa_post_text(self::MODAL_SHOW_DATA_STREAM)); qa_opt(self::MODAL_HEIGHT, qa_post_text(self::MODAL_HEIGHT)); qa_opt(self::MODAL_WIDTH, qa_post_text(self::MODAL_WIDTH)); qa_opt(self::MODAL_COOKIE_EXPIRE, qa_post_text(self::MODAL_COOKIE_EXPIRE)); qa_opt(self::MODAL_HEADER_MAIN_TEXT, qa_post_text(self::MODAL_HEADER_MAIN_TEXT)); qa_opt(self::MODAL_FOOTER_TEXT, qa_post_text(self::MODAL_FOOTER_TEXT)); qa_opt(self::MODAL_USE_CSS_FROM_THEME, !!qa_post_text(self::MODAL_USE_CSS_FROM_THEME)); qa_opt(self::MODAL_COSTUM_CSS, qa_post_text(self::MODAL_COSTUM_CSS)); qa_opt(self::MODAL_DISPLAY_EVERY_TIME, !!qa_post_text(self::MODAL_DISPLAY_EVERY_TIME)); qa_opt(self::MODAL_DELAY, (int) qa_post_text(self::MODAL_DELAY)); $saved = true; } qa_set_display_rules($qa_content, array(self::LIKE_BOX_COLOR_SCHEME => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_HEADER => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_BORDER => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_FACES => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_DATA_STREAM => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_HEIGHT => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_WIDTH => self::SHOW_FB_LIKE_BOX, self::MODAL_COLOR_SCHEME => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_HEADER => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_BORDER => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_FACES => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_DATA_STREAM => self::SHOW_FB_LIKE_MODAL, self::MODAL_HEIGHT => self::SHOW_FB_LIKE_MODAL, self::MODAL_WIDTH => self::SHOW_FB_LIKE_MODAL, self::MODAL_COOKIE_EXPIRE => self::SHOW_FB_LIKE_MODAL, self::MODAL_HEADER_MAIN_TEXT => self::SHOW_FB_LIKE_MODAL, self::MODAL_FOOTER_TEXT => self::SHOW_FB_LIKE_MODAL, self::MODAL_USE_CSS_FROM_THEME => self::SHOW_FB_LIKE_MODAL, self::MODAL_COSTUM_CSS => self::SHOW_FB_LIKE_MODAL, self::MODAL_DISPLAY_EVERY_TIME => self::SHOW_FB_LIKE_MODAL, self::MODAL_DELAY => self::SHOW_FB_LIKE_MODAL)); return array('ok' => $saved ? qa_lang('flb_like_box/settings_saved') : null, 'fields' => array(self::FACEBOOK_PAGE_URL => array('label' => qa_lang('flb_like_box/ur_fb_page_url'), 'type' => 'text', 'tags' => 'name="' . self::FACEBOOK_PAGE_URL . '"', 'value' => qa_opt(self::FACEBOOK_PAGE_URL), 'note' => qa_lang('flb_like_box/ur_fb_page_url_note')), self::SHOW_FB_LIKE_BOX => array('label' => qa_lang('flb_like_box/b_show_fb_like_box'), 'tags' => 'name="' . self::SHOW_FB_LIKE_BOX . '" id="' . self::SHOW_FB_LIKE_BOX . '"', 'value' => qa_opt(self::SHOW_FB_LIKE_BOX), 'type' => 'checkbox'), self::LIKE_BOX_COLOR_SCHEME => array('id' => self::LIKE_BOX_COLOR_SCHEME, 'label' => qa_lang('flb_like_box/b_colorscheme_label'), 'type' => 'select', 'tags' => 'name="' . self::LIKE_BOX_COLOR_SCHEME . '"', 'value' => qa_opt(self::LIKE_BOX_COLOR_SCHEME), 'options' => array('light' => 'light', 'dark' => 'dark')), self::LIKE_BOX_SHOW_HEADER => array('id' => self::LIKE_BOX_SHOW_HEADER, 'label' => qa_lang('flb_like_box/b_box_header_label'), 'type' => 'select', 'tags' => 'name="' . self::LIKE_BOX_SHOW_HEADER . '"', 'value' => qa_opt(self::LIKE_BOX_SHOW_HEADER), 'options' => array('false' => 'false', 'true' => 'true')), self::LIKE_BOX_SHOW_BORDER => array('id' => self::LIKE_BOX_SHOW_BORDER, 'label' => qa_lang('flb_like_box/b_show_border_label'), 'type' => 'select', 'tags' => 'name="' . self::LIKE_BOX_SHOW_BORDER . '"', 'value' => qa_opt(self::LIKE_BOX_SHOW_BORDER), 'options' => array('false' => 'false', 'true' => 'true')), self::LIKE_BOX_SHOW_FACES => array('id' => self::LIKE_BOX_SHOW_FACES, 'label' => qa_lang('flb_like_box/b_show_faces_label'), 'type' => 'select', 'tags' => 'name="' . self::LIKE_BOX_SHOW_FACES . '"', 'value' => qa_opt(self::LIKE_BOX_SHOW_FACES), 'options' => array('true' => 'true', 'false' => 'false')), self::LIKE_BOX_SHOW_DATA_STREAM => array('id' => self::LIKE_BOX_SHOW_DATA_STREAM, 'label' => qa_lang('flb_like_box/b_show_stream_label'), 'type' => 'select', 'tags' => 'name="' . self::LIKE_BOX_SHOW_DATA_STREAM . '"', 'value' => qa_opt(self::LIKE_BOX_SHOW_DATA_STREAM), 'options' => array('false' => 'false', 'true' => 'true')), self::LIKE_BOX_HEIGHT => array('id' => self::LIKE_BOX_HEIGHT, 'label' => qa_lang('flb_like_box/b_like_box_height_label'), 'type' => 'text', 'tags' => 'name="' . self::LIKE_BOX_HEIGHT . '"', 'value' => qa_opt(self::LIKE_BOX_HEIGHT)), self::LIKE_BOX_WIDTH => array('id' => self::LIKE_BOX_WIDTH, 'label' => qa_lang('flb_like_box/b_like_box_width_label'), 'type' => 'text', 'tags' => 'name="' . self::LIKE_BOX_WIDTH . '"', 'value' => !!qa_opt(self::LIKE_BOX_WIDTH) ? qa_opt(self::LIKE_BOX_WIDTH) : 200), self::SHOW_FB_LIKE_MODAL => array('label' => qa_lang('flb_like_box/m_show_fb_like_modal'), 'tags' => 'name="' . self::SHOW_FB_LIKE_MODAL . '" id="' . self::SHOW_FB_LIKE_MODAL . '"', 'value' => qa_opt(self::SHOW_FB_LIKE_MODAL), 'type' => 'checkbox'), self::MODAL_USE_CSS_FROM_THEME => array('id' => self::MODAL_USE_CSS_FROM_THEME, 'label' => qa_lang('flb_like_box/m_use_css_from_theme_file'), 'tags' => 'name="' . self::MODAL_USE_CSS_FROM_THEME . '"', 'value' => qa_opt(self::MODAL_USE_CSS_FROM_THEME), 'type' => 'checkbox'), self::MODAL_DISPLAY_EVERY_TIME => array('id' => self::MODAL_DISPLAY_EVERY_TIME, 'label' => qa_lang('flb_like_box/m_display_on_every_load'), 'tags' => 'name="' . self::MODAL_DISPLAY_EVERY_TIME . '"', 'value' => qa_opt(self::MODAL_DISPLAY_EVERY_TIME), 'type' => 'checkbox'), self::MODAL_COLOR_SCHEME => array('id' => self::MODAL_COLOR_SCHEME, 'label' => qa_lang('flb_like_box/m_colorscheme_label'), 'type' => 'select', 'tags' => 'name="' . self::MODAL_COLOR_SCHEME . '"', 'value' => qa_opt(self::MODAL_COLOR_SCHEME), 'options' => array('light' => 'light', 'dark' => 'dark')), self::MODAL_SHOW_HEADER => array('id' => self::MODAL_SHOW_HEADER, 'label' => qa_lang('flb_like_box/m_box_header_label'), 'type' => 'select', 'tags' => 'name="' . self::MODAL_SHOW_HEADER . '"', 'value' => qa_opt(self::MODAL_SHOW_HEADER), 'options' => array('false' => 'false', 'true' => 'true')), self::MODAL_SHOW_BORDER => array('id' => self::MODAL_SHOW_BORDER, 'label' => qa_lang('flb_like_box/m_show_border_label'), 'type' => 'select', 'tags' => 'name="' . self::MODAL_SHOW_BORDER . '"', 'value' => qa_opt(self::MODAL_SHOW_BORDER), 'options' => array('false' => 'false', 'true' => 'true')), self::MODAL_SHOW_FACES => array('id' => self::MODAL_SHOW_FACES, 'label' => qa_lang('flb_like_box/m_show_faces_label'), 'type' => 'select', 'tags' => 'name="' . self::MODAL_SHOW_FACES . '"', 'value' => qa_opt(self::MODAL_SHOW_FACES), 'options' => array('true' => 'true', 'false' => 'false')), self::MODAL_SHOW_DATA_STREAM => array('id' => self::MODAL_SHOW_DATA_STREAM, 'label' => qa_lang('flb_like_box/m_show_stream_label'), 'type' => 'select', 'tags' => 'name="' . self::MODAL_SHOW_DATA_STREAM . '"', 'value' => qa_opt(self::MODAL_SHOW_DATA_STREAM), 'options' => array('false' => 'false', 'true' => 'true')), self::MODAL_HEIGHT => array('id' => self::MODAL_HEIGHT, 'label' => qa_lang('flb_like_box/m_like_modal_height_label'), 'type' => 'text', 'tags' => 'name="' . self::MODAL_HEIGHT . '"', 'value' => qa_opt(self::MODAL_HEIGHT)), self::MODAL_WIDTH => array('id' => self::MODAL_WIDTH, 'label' => qa_lang('flb_like_box/m_like_modal_width_label'), 'type' => 'text', 'tags' => 'name="' . self::MODAL_WIDTH . '"', 'value' => qa_opt(self::MODAL_WIDTH)), self::MODAL_DELAY => array('id' => self::MODAL_DELAY, 'label' => qa_lang('flb_like_box/m_like_modal_delay'), 'type' => 'text', 'tags' => 'name="' . self::MODAL_DELAY . '"', 'value' => qa_opt(self::MODAL_DELAY), 'note' => qa_lang('flb_like_box/m_like_modal_delay_note')), self::MODAL_COOKIE_EXPIRE => array('id' => self::MODAL_COOKIE_EXPIRE, 'label' => qa_lang('flb_like_box/m_like_modal_cookie_expire'), 'type' => 'text', 'tags' => 'name="' . self::MODAL_COOKIE_EXPIRE . '"', 'value' => qa_opt(self::MODAL_COOKIE_EXPIRE), 'note' => qa_lang('flb_like_box/m_like_modal_cookie_expire_note')), self::MODAL_HEADER_MAIN_TEXT => array('id' => self::MODAL_HEADER_MAIN_TEXT, 'label' => qa_lang('flb_like_box/m_pop_up_header_text'), 'type' => 'textarea', 'rows' => 4, 'tags' => 'name="' . self::MODAL_HEADER_MAIN_TEXT . '"', 'value' => qa_opt(self::MODAL_HEADER_MAIN_TEXT)), self::MODAL_FOOTER_TEXT => array('id' => self::MODAL_FOOTER_TEXT, 'label' => qa_lang('flb_like_box/m_pop_up_footer_text'), 'type' => 'textarea', 'rows' => 4, 'tags' => 'name="' . self::MODAL_FOOTER_TEXT . '"', 'value' => qa_opt(self::MODAL_FOOTER_TEXT)), self::MODAL_COSTUM_CSS => array('id' => self::MODAL_COSTUM_CSS, 'label' => qa_lang('flb_like_box/m_costum_css'), 'type' => 'textarea', 'rows' => 4, 'tags' => 'name="' . self::MODAL_COSTUM_CSS . '"', 'value' => qa_opt(self::MODAL_COSTUM_CSS), 'note' => qa_lang_html('flb_like_box/m_costum_css_note'))), 'buttons' => array(array('label' => qa_lang('flb_like_box/save_changes'), 'tags' => 'name="' . self::SAVE_BUTTON . '"'))); }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked(self::SAVE_BUTTON)) { qa_opt(self::FACEBOOK_PAGE_URL, qa_post_text(self::FACEBOOK_PAGE_URL)); // for like box qa_opt(self::SHOW_FB_LIKE_BOX, !!qa_post_text(self::SHOW_FB_LIKE_BOX)); qa_opt(self::LIKE_BOX_COLOR_SCHEME, qa_post_text(self::LIKE_BOX_COLOR_SCHEME)); qa_opt(self::LIKE_BOX_SHOW_HEADER, qa_post_text(self::LIKE_BOX_SHOW_HEADER)); qa_opt(self::LIKE_BOX_SHOW_BORDER, qa_post_text(self::LIKE_BOX_SHOW_BORDER)); qa_opt(self::LIKE_BOX_SHOW_FACES, qa_post_text(self::LIKE_BOX_SHOW_FACES)); qa_opt(self::LIKE_BOX_SHOW_DATA_STREAM, qa_post_text(self::LIKE_BOX_SHOW_DATA_STREAM)); qa_opt(self::LIKE_BOX_HEIGHT, qa_post_text(self::LIKE_BOX_HEIGHT)); qa_opt(self::LIKE_BOX_WIDTH, qa_post_text(self::LIKE_BOX_WIDTH)); // for modal qa_opt(self::SHOW_FB_LIKE_MODAL, !!qa_post_text(self::SHOW_FB_LIKE_MODAL)); qa_opt(self::MODAL_COLOR_SCHEME, qa_post_text(self::MODAL_COLOR_SCHEME)); qa_opt(self::MODAL_SHOW_HEADER, qa_post_text(self::MODAL_SHOW_HEADER)); qa_opt(self::MODAL_SHOW_BORDER, qa_post_text(self::MODAL_SHOW_BORDER)); qa_opt(self::MODAL_SHOW_FACES, qa_post_text(self::MODAL_SHOW_FACES)); qa_opt(self::MODAL_SHOW_DATA_STREAM, qa_post_text(self::MODAL_SHOW_DATA_STREAM)); qa_opt(self::MODAL_HEIGHT, qa_post_text(self::MODAL_HEIGHT)); qa_opt(self::MODAL_WIDTH, qa_post_text(self::MODAL_WIDTH)); qa_opt(self::MODAL_COOKIE_EXPIRE, qa_post_text(self::MODAL_COOKIE_EXPIRE)); qa_opt(self::MODAL_HEADER_MAIN_TEXT, qa_post_text(self::MODAL_HEADER_MAIN_TEXT)); qa_opt(self::MODAL_FOOTER_TEXT, qa_post_text(self::MODAL_FOOTER_TEXT)); qa_opt(self::MODAL_USE_CSS_FROM_THEME, !!qa_post_text(self::MODAL_USE_CSS_FROM_THEME)); qa_opt(self::MODAL_COSTUM_CSS, qa_post_text(self::MODAL_COSTUM_CSS)); qa_opt(self::MODAL_DISPLAY_EVERY_TIME, !!qa_post_text(self::MODAL_DISPLAY_EVERY_TIME)); qa_opt(self::MODAL_DELAY, (int) qa_post_text(self::MODAL_DELAY)); $saved = true; } qa_set_display_rules($qa_content, array(self::LIKE_BOX_COLOR_SCHEME => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_HEADER => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_BORDER => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_FACES => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_SHOW_DATA_STREAM => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_HEIGHT => self::SHOW_FB_LIKE_BOX, self::LIKE_BOX_WIDTH => self::SHOW_FB_LIKE_BOX, self::MODAL_COLOR_SCHEME => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_HEADER => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_BORDER => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_FACES => self::SHOW_FB_LIKE_MODAL, self::MODAL_SHOW_DATA_STREAM => self::SHOW_FB_LIKE_MODAL, self::MODAL_HEIGHT => self::SHOW_FB_LIKE_MODAL, self::MODAL_WIDTH => self::SHOW_FB_LIKE_MODAL, self::MODAL_COOKIE_EXPIRE => self::SHOW_FB_LIKE_MODAL, self::MODAL_HEADER_MAIN_TEXT => self::SHOW_FB_LIKE_MODAL, self::MODAL_FOOTER_TEXT => self::SHOW_FB_LIKE_MODAL, self::MODAL_USE_CSS_FROM_THEME => self::SHOW_FB_LIKE_MODAL, self::MODAL_COSTUM_CSS => self::SHOW_FB_LIKE_MODAL, self::MODAL_DISPLAY_EVERY_TIME => self::SHOW_FB_LIKE_MODAL, self::MODAL_DELAY => self::SHOW_FB_LIKE_MODAL)); return array('ok' => $saved ? qa_lang('flb_like_box/settings_saved') : null, 'fields' => array(self::FACEBOOK_PAGE_URL => $this->get_fb_page_url_field(), self::SHOW_FB_LIKE_BOX => $this->get_show_likebox_field(), self::LIKE_BOX_COLOR_SCHEME => $this->get_lokebox_color_scheme_field(), self::LIKE_BOX_SHOW_HEADER => $this->get_likebox_show_header_field(), self::LIKE_BOX_SHOW_BORDER => $this->get_likebox_show_border_field(), self::LIKE_BOX_SHOW_FACES => $this->get_likebox_show_faces_field(), self::LIKE_BOX_SHOW_DATA_STREAM => $this->get_likebox_show_data_stream(), self::LIKE_BOX_HEIGHT => $this->get_likebox_height_field(), self::LIKE_BOX_WIDTH => $this->get_likebox_width_field(), self::SHOW_FB_LIKE_MODAL => $this->get_show_like_modal_field(), self::MODAL_USE_CSS_FROM_THEME => $this->get_like_modal_use_css_from_theme_field(), self::MODAL_DISPLAY_EVERY_TIME => $this->get_like_modal_display_every_time_field(), self::MODAL_COLOR_SCHEME => $this->get_like_modal_color_scheme_field(), self::MODAL_SHOW_HEADER => $this->get_like_modal_show_header_field(), self::MODAL_SHOW_BORDER => $this->get_like_modal_show_border_field(), self::MODAL_SHOW_FACES => $this->get_like_modal_show_faces_field(), self::MODAL_SHOW_DATA_STREAM => $this->get_like_modal_show_data_stream_field(), self::MODAL_HEIGHT => $this->get_like_modal_height_field(), self::MODAL_WIDTH => $this->get_like_modal_width_field(), self::MODAL_DELAY => $this->get_like_modal_delay_field(), self::MODAL_COOKIE_EXPIRE => $this->get_like_modal_cookie_expire_field(), self::MODAL_HEADER_MAIN_TEXT => $this->get_like_modal_header_main_text_field(), self::MODAL_FOOTER_TEXT => $this->get_like_modal_footer_text_field(), self::MODAL_COSTUM_CSS => $this->get_like_modal_custom_css_field()), 'buttons' => $this->get_admin_buttons()); }
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"'))); }
public function admin_form(&$qa_content) { $saved = qa_clicked('mouseover_save_button'); if ($saved) { qa_opt('mouseover_content_on', (int) qa_post_text('mouseover_content_on_field')); qa_opt('mouseover_content_max_len', (int) qa_post_text('mouseover_content_max_len_field')); } qa_set_display_rules($qa_content, array('mouseover_content_max_len_display' => 'mouseover_content_on_field')); return array('ok' => $saved ? 'Mouseover settings saved' : null, 'fields' => array(array('label' => 'Show content preview on mouseover in question lists', 'type' => 'checkbox', 'value' => qa_opt('mouseover_content_on'), 'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"'), array('id' => 'mouseover_content_max_len_display', 'label' => 'Maximum length of preview:', 'suffix' => 'characters', 'type' => 'number', 'value' => (int) qa_opt('mouseover_content_max_len'), 'tags' => 'name="mouseover_content_max_len_field"')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="mouseover_save_button"'))); }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked('mouseover_save_button')) { qa_opt('mouseover_content_on', (int) qa_post_text('mouseover_content_on_field')); qa_opt('mouseover_content_max_len', (int) qa_post_text('mouseover_content_max_len_field')); $saved = true; } qa_set_display_rules($qa_content, array('mouseover_content_max_len_display' => 'mouseover_content_on_field')); return array('ok' => $saved ? 'Mouseover settings saved' : null, 'fields' => array(array('label' => 'Show content on mouseover in question lists', 'type' => 'checkbox', 'value' => qa_opt('mouseover_content_on'), 'tags' => 'NAME="mouseover_content_on_field" ID="mouseover_content_on_field"'), array('id' => 'mouseover_content_max_len_display', 'label' => 'Maximum number of characters to show:', 'type' => 'number', 'value' => (int) qa_opt('mouseover_content_max_len'), 'tags' => 'NAME="mouseover_content_max_len_field"')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'NAME="mouseover_save_button"'))); }
function admin_form(&$qa_content) { // load styles $real_plugin_path = $this->directory; $s_path = $real_plugin_path . 'styles'; if (is_dir($s_path) == false) { //in case it could not read directory content try this to get absolute & real path of directories $site_path = getcwd(); $path = $real_plugin_path; $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); foreach ($parts as $part) { if ('.' == $part) { continue; } if ('..' == $part) { array_pop($absolutes); } else { $absolutes[] = $part; } } $plugin_path = implode(DIRECTORY_SEPARATOR, $absolutes); $real_plugin_path = $site_path . '/' . $plugin_path; $s_path = $real_plugin_path . '/styles'; } // List of styles $styles = array(); $files = scandir($s_path, 1); $styles[] = "NO Costume Style"; foreach ($files as $file) { if (!(empty($file) or $file == '.' or $file == '..')) { $styles[] = preg_replace("/\\.[^.]*\$/", "", $file); } } $saved = false; if (qa_clicked('tw_save_button')) { qa_opt('tw_custom_css', $styles[(int) qa_post_text('tw_custom_css')]); qa_opt('tw_custom_css_index', (int) qa_post_text('tw_custom_css')); qa_opt('tw_thumbnail_enable', (int) qa_post_text('tw_thumbnail_enable')); qa_opt('tw_thumbnail', qa_post_text('tw_thumbnail')); qa_opt('tw_popular_number', (int) qa_post_text('tw_popular_number')); qa_opt('tw_recent_number', (int) qa_post_text('tw_recent_number')); qa_opt('tw_recent_lable', qa_post_text('tw_recent_lable')); qa_opt('tw_popular_lable', qa_post_text('tw_popular_lable')); qa_opt('tw_ads', qa_post_text('tw_ads_field')); qa_opt('tw_ads_pos', (int) qa_post_text('tw_ads_pos_field')); $saved = true; } qa_set_display_rules($qa_content, array('tw_thumbnail' => 'tw_thumbnail_enable')); return array('ok' => $saved ? 'Tag cloud settings saved' : null, 'fields' => array(array('label' => 'CSS Styles', 'tags' => 'NAME="tw_custom_css" ID="tw_custom_css"', 'type' => 'select', 'options' => @$styles, 'value' => @$styles[qa_opt('tw_custom_css_index')]), array('label' => 'Enable thumbnail image', 'type' => 'checkbox', 'value' => qa_opt('tw_thumbnail_enable'), 'tags' => 'NAME="tw_thumbnail_enable" ID="tw_thumbnail_enable"', 'note' => 'read first image inside question content and show it as thumbnail image'), array('label' => 'Default thumbnail image URL', 'value' => qa_opt('tw_thumbnail'), 'tags' => 'NAME="tw_thumbnail" ID="tw_thumbnail"', 'suffix' => 'leave empty to load no thumbnails', 'id' => 'tw_thumbnail', 'tags' => 'name="tw_thumbnail"'), array('label' => 'Lable of popular questions:', 'value' => qa_opt('tw_popular_lable'), 'tags' => 'NAME="tw_popular_lable" ID="tw_popular_lable"'), array('label' => 'Number of popular questions:', 'type' => 'number', 'value' => (int) qa_opt('tw_popular_number'), 'suffix' => 'tags', 'tags' => 'name="tw_popular_number"'), array('label' => 'Lable of recent questions:', 'value' => qa_opt('tw_recent_lable'), 'tags' => 'NAME="tw_recent_lable" ID="tw_recent_lable"'), array('label' => 'Number of recent questions:', 'type' => 'number', 'value' => (int) qa_opt('tw_recent_number'), 'tags' => 'name="tw_recent_number"'), array('label' => 'Advertisment box', 'type' => 'textbox', 'value' => qa_opt('tw_ads'), 'tags' => 'NAME="tw_ads_field" ID="tw_ads_field"', 'suffix' => 'HTML is supported', 'rows' => 3), array('label' => 'Advertisment position', 'value' => qa_opt('tw_ads_pos'), 'tags' => 'NAME="tw_ads_pos_field" ID="tw_ads_pos_field"', 'suffix' => 'Show Advertisment box after this number of questions')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="tw_save_button"'))); }
function admin_form(&$qa_content) { require_once QA_INCLUDE_DIR . 'qa-app-upload.php'; $saved = false; if (qa_clicked('wysiwyg_editor_save_button')) { qa_opt('wysiwyg_editor_upload_images', (int) qa_post_text('wysiwyg_editor_upload_images_field')); qa_opt('wysiwyg_editor_upload_all', (int) qa_post_text('wysiwyg_editor_upload_all_field')); qa_opt('wysiwyg_editor_upload_max_size', min(qa_get_max_upload_size(), 1048576 * (double) qa_post_text('wysiwyg_editor_upload_max_size_field'))); $saved = true; } qa_set_display_rules($qa_content, array('wysiwyg_editor_upload_all_display' => 'wysiwyg_editor_upload_images_field', 'wysiwyg_editor_upload_max_size_display' => 'wysiwyg_editor_upload_images_field')); return array('ok' => $saved ? 'WYSIWYG editor settings saved' : null, 'fields' => array(array('label' => 'Allow images to be uploaded', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_images'), 'tags' => 'name="wysiwyg_editor_upload_images_field" id="wysiwyg_editor_upload_images_field"'), array('id' => 'wysiwyg_editor_upload_all_display', 'label' => 'Allow other content to be uploaded, e.g. Flash, PDF', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_all'), 'tags' => 'name="wysiwyg_editor_upload_all_field"'), array('id' => 'wysiwyg_editor_upload_max_size_display', 'label' => 'Maximum size of uploads:', 'suffix' => 'MB (max ' . $this->bytes_to_mega_html(qa_get_max_upload_size()) . ')', 'type' => 'number', 'value' => $this->bytes_to_mega_html(qa_opt('wysiwyg_editor_upload_max_size')), 'tags' => 'name="wysiwyg_editor_upload_max_size_field"')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="wysiwyg_editor_save_button"'))); }
public function admin_form(&$qa_content) { require_once QA_INCLUDE_DIR . 'app/upload.php'; $saved = false; if (qa_clicked('wysiwyg_editor_save_button')) { qa_opt('wysiwyg_editor_upload_images', (int) qa_post_text('wysiwyg_editor_upload_images_field')); qa_opt('wysiwyg_editor_upload_all', (int) qa_post_text('wysiwyg_editor_upload_all_field')); qa_opt('wysiwyg_editor_upload_max_size', min(qa_get_max_upload_size(), 1048576 * (double) qa_post_text('wysiwyg_editor_upload_max_size_field'))); $saved = true; } qa_set_display_rules($qa_content, array('wysiwyg_editor_upload_all_display' => 'wysiwyg_editor_upload_images_field', 'wysiwyg_editor_upload_max_size_display' => 'wysiwyg_editor_upload_images_field')); // handle AJAX requests to 'wysiwyg-editor-ajax' $js = array('function wysiwyg_editor_ajax(totalEdited) {', ' $.ajax({', ' url: ' . qa_js(qa_path('wysiwyg-editor-ajax')) . ',', ' success: function(response) {', ' var postsEdited = parseInt(response, 10);', ' var $btn = $("#wysiwyg_editor_ajax");', ' if (isNaN(postsEdited)) {', ' $btn.text("ERROR");', ' }', ' else if (postsEdited < 5) {', ' $btn.text("All posts converted.");', ' }', ' else {', ' totalEdited += postsEdited;', ' $btn.text("Updating posts... " + totalEdited)', ' window.setTimeout(function() {', ' wysiwyg_editor_ajax(totalEdited);', ' }, 1000);', ' }', ' }', ' });', '}', '$("#wysiwyg_editor_ajax").click(function() {', ' wysiwyg_editor_ajax(0);', ' return false;', '});'); $ajaxHtml = 'Update broken images from old CKeditor Smiley plugin: ' . '<button id="wysiwyg_editor_ajax">click here</button> ' . '<script>' . implode("\n", $js) . '</script>'; return array('ok' => $saved ? 'WYSIWYG editor settings saved' : null, 'fields' => array(array('label' => 'Allow images to be uploaded', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_images'), 'tags' => 'name="wysiwyg_editor_upload_images_field" id="wysiwyg_editor_upload_images_field"'), array('id' => 'wysiwyg_editor_upload_all_display', 'label' => 'Allow other content to be uploaded, e.g. Flash, PDF', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_all'), 'tags' => 'name="wysiwyg_editor_upload_all_field"'), array('id' => 'wysiwyg_editor_upload_max_size_display', 'label' => 'Maximum size of uploads:', 'suffix' => 'MB (max ' . $this->bytes_to_mega_html(qa_get_max_upload_size()) . ')', 'type' => 'number', 'value' => $this->bytes_to_mega_html(qa_opt('wysiwyg_editor_upload_max_size')), 'tags' => 'name="wysiwyg_editor_upload_max_size_field"'), array('type' => 'custom', 'html' => $ajaxHtml)), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="wysiwyg_editor_save_button"'))); }
function admin_form(&$qa_content) { // Process form input $ok = null; if (qa_clicked('embed_save')) { qa_opt('embed_enable', (bool) qa_post_text('embed_enable')); qa_opt('embed_video_width', qa_post_text('embed_video_width')); qa_opt('embed_video_height', qa_post_text('embed_video_height')); qa_opt('embed_enable_img', (bool) qa_post_text('embed_enable_img')); qa_opt('embed_image_width', qa_post_text('embed_image_width')); qa_opt('embed_image_height', qa_post_text('embed_image_height')); qa_opt('embed_enable_thickbox', (bool) qa_post_text('embed_enable_thickbox')); qa_opt('embed_enable_mp3', (bool) qa_post_text('embed_enable_mp3')); qa_opt('embed_enable_gmap', (bool) qa_post_text('embed_enable_gmap')); qa_opt('embed_mp3_player_code', qa_post_text('embed_mp3_player_code')); $ok = qa_lang('admin/options_saved'); } else { if (qa_clicked('embed_reset')) { foreach ($_POST as $i => $v) { $def = $this->option_default($i); if ($def !== null) { qa_opt($i, $def); } } $ok = qa_lang('admin/options_reset'); } } qa_set_display_rules($qa_content, array('embed_video_height' => 'embed_enable', 'embed_video_width' => 'embed_enable')); // Create the form for display $fields = array(); $fields[] = array('label' => 'Enable video embedding', 'tags' => 'NAME="embed_enable"', 'value' => qa_opt('embed_enable'), 'type' => 'checkbox'); $fields[] = array('label' => 'Embeded video width', 'type' => 'number', 'value' => qa_opt('embed_video_width'), 'tags' => 'NAME="embed_video_width"'); $fields[] = array('label' => 'Embeded video height', 'type' => 'number', 'value' => qa_opt('embed_video_height'), 'tags' => 'NAME="embed_video_height"'); $fields[] = array('type' => 'blank'); $fields[] = array('label' => 'Enable image embedding', 'tags' => 'NAME="embed_enable_img"', 'value' => qa_opt('embed_enable_img'), 'type' => 'checkbox'); $fields[] = array('label' => 'Image width', 'type' => 'number', 'value' => qa_opt('embed_image_width'), 'tags' => 'NAME="embed_image_width"'); $fields[] = array('label' => 'Image height', 'type' => 'number', 'value' => qa_opt('embed_image_height'), 'tags' => 'NAME="embed_image_height"'); $fields[] = array('label' => 'Enable thickbox image effect', 'tags' => 'NAME="embed_enable_thickbox"', 'value' => qa_opt('embed_enable_thickbox'), 'type' => 'checkbox'); $fields[] = array('type' => 'blank'); $fields[] = array('label' => 'Enable mp3 embedding', 'tags' => 'NAME="embed_enable_mp3"', 'value' => qa_opt('embed_enable_mp3'), 'type' => 'checkbox'); $fields[] = array('label' => 'mp3 flash player code', 'tags' => 'NAME="embed_mp3_player_code"', 'value' => qa_opt('embed_mp3_player_code'), 'type' => 'textarea', 'rows' => '5'); $fields[] = array('type' => 'blank'); $fields[] = array('label' => 'Enable Google maps embedding', 'tags' => 'NAME="embed_enable_gmap"', 'value' => qa_opt('embed_enable_gmap'), 'type' => 'checkbox'); $fields[] = array('label' => 'Map width', 'type' => 'number', 'value' => qa_opt('embed_gmap_width'), 'tags' => 'NAME="embed_gmap_width"'); $fields[] = array('label' => 'Map height', 'type' => 'number', 'value' => qa_opt('embed_gmap_height'), 'tags' => 'NAME="embed_gmap_height"'); return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="embed_save"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="embed_reset"'))); }
function doctype() { if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $permits[] = 'signature_allow'; $permits[] = 'signature_edit_allow'; foreach ($permits as $optionname) { $value = qa_opt($optionname); $optionfield = array('id' => $optionname, 'label' => qa_lang_html('signature_plugin/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, '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') . ' ', '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); } if (qa_opt('signatures_enable')) { // add user signature if ($this->template == 'user' && isset($this->content['form_activity']) && !qa_get('tab')) { $sig_form = $this->content['user_signature_form']; // from overrides // insert our form if (isset($this->content['q_list'])) { // array splicing kungfu thanks to Stack Exchange // This adds form-signature before q_list $keys = array_keys($this->content); $vals = array_values($this->content); $insertBefore = array_search('q_list', $keys); $keys2 = array_splice($keys, $insertBefore); $vals2 = array_splice($vals, $insertBefore); $keys[] = 'form-signature'; $vals[] = $sig_form; $this->content = array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2)); } else { $this->content['form-signature'] = $sig_form; } } } qa_html_theme_base::doctype(); }
function admin_form(&$qa_content) { $saved = false; $error = ''; if (qa_clicked(self::SAVE_BUTTON)) { if (qa_post_text(self::ENABLE . '_field')) { if (trim(qa_post_text(self::REQUEST . '_field')) == '') { $error = qa_lang_html(self::PLUGIN . '/' . self::REQUEST . '_error'); } } if ($error == '') { qa_opt(self::ENABLE, (bool) qa_post_text(self::ENABLE . '_field')); qa_opt(self::REQUEST, qa_post_text(self::REQUEST . '_field')); $saved = true; } } if (qa_clicked(self::DFL_BUTTON)) { qa_opt(self::ENABLE, self::ENABLE_DFL); qa_opt(self::REQUEST, self::REQUEST_DFL); $saved = true; } $rules = array(); $rules[self::REQUEST] = self::ENABLE . '_field'; qa_set_display_rules($qa_content, $rules); $ret = array(); if ($saved) { $ret['ok'] = qa_lang_html(self::PLUGIN . '/' . self::SAVED_MESSAGE); } else { if ($error != '') { $ret['ok'] = '<SPAN STYLE="color:#F00;">' . $error . '</SPAN>'; } } $fields = array(); $fields[] = array('id' => self::ENABLE, 'label' => qa_lang_html(self::PLUGIN . '/' . self::ENABLE . '_label'), 'type' => 'checkbox', 'value' => qa_opt(self::ENABLE), 'tags' => 'NAME="' . self::ENABLE . '_field" ID="' . self::ENABLE . '_field"'); $fields[] = array('id' => self::REQUEST, 'label' => qa_lang_html(self::PLUGIN . '/' . self::REQUEST . '_label'), 'value' => qa_opt(self::REQUEST), 'tags' => 'NAME="' . self::REQUEST . '_field" ID="' . self::REQUEST . '_field"'); $ret['fields'] = $fields; $buttons = array(); $buttons[] = array('label' => qa_lang_html(self::PLUGIN . '/' . self::SAVE_BUTTON), 'tags' => 'NAME="' . self::SAVE_BUTTON . '" ID="' . self::SAVE_BUTTON . '"'); $buttons[] = array('label' => qa_lang_html(self::PLUGIN . '/' . self::DFL_BUTTON), 'tags' => 'NAME="' . self::DFL_BUTTON . '" ID="' . self::DFL_BUTTON . '"'); $ret['buttons'] = $buttons; return $ret; }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked('tos_save_button')) { qa_opt('tos_enable', (int) qa_post_text('tos_enable')); qa_opt('tos_checkbox_label', qa_post_text('tos_checkbox_label')); qa_opt('tos_error', qa_post_text('tos_error')); qa_opt('tos_content', qa_post_text('tos_content')); qa_opt('tos_serverside', (int) qa_post_text('tos_serverside')); $saved = true; } qa_set_display_rules($qa_content, array('tos_checkbox_label' => 'tos_enable', 'tos_content' => 'tos_enable', 'tos_serverside' => 'tos_enable', 'tos_static' => 'tos_enable', 'tos_error' => 'tos_enable')); qa_set_display_rules($qa_content, array('tos_static' => 'tos_serverside')); if (qa_opt('tos_serverside')) { $warning = 'Warning: activating This option overrides PHP file responsible for handling registration page. it\'s tested with Q2A 1.6 but might not work on other versions.'; } else { $warning = ''; } return array('ok' => $saved ? 'TOS settings saved' : null, 'fields' => array(array('label' => 'Enable Terms of Service on registration form', 'type' => 'checkbox', 'value' => qa_opt('tos_enable'), 'tags' => 'name="tos_enable" id="tos_enable"'), array('id' => 'tos_checkbox_label', 'label' => 'Terms of Service checkbox label:', 'type' => 'textarea', 'rows' => '2', 'suffix' => 'HTML is enabled, so you can add a link to TOS in this field', 'value' => qa_opt('tos_checkbox_label'), 'tags' => 'name="tos_checkbox_label"'), array('id' => 'tos_error', 'label' => 'Error Message if validation fails', 'value' => qa_opt('tos_error'), 'tags' => 'name="tos_error"'), array('id' => 'tos_content', 'label' => 'Terms of Service content', 'suffix' => 'you can leave this empty, so textbox with content of Terms of Service won\'t show up.', 'type' => 'textarea', 'rows' => '6', 'value' => qa_opt('tos_content'), 'tags' => 'name="tos_content"'), array('id' => 'tos_serverside', 'label' => 'Check validation in server side instead of using JavaScript', 'type' => 'checkbox', 'value' => qa_opt('tos_serverside'), 'tags' => 'name="tos_serverside"', 'error' => $warning)), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="tos_save_button"'))); }
function admin_form(&$qa_content) { require_once QA_INCLUDE_DIR . 'qa-app-upload.php'; $saved = false; if (qa_clicked('wysiwyg_editor_save_button')) { qa_opt('wysiwyg_editor_ui_color', qa_post_text('wysiwyg_editor_ui_color_field')); qa_opt('wysiwyg_editor_ace_theme', qa_post_text('wysiwyg_editor_ace_theme')); qa_opt('wysiwyg_editor_upload_images', (int) qa_post_text('wysiwyg_editor_upload_images_field')); qa_opt('wysiwyg_editor_upload_all', (int) qa_post_text('wysiwyg_editor_upload_all_field')); qa_opt('wysiwyg_editor_upload_max_size', min(qa_get_max_upload_size(), 1048576 * (double) qa_post_text('wysiwyg_editor_upload_max_size_field'))); $saved = true; } qa_set_display_rules($qa_content, array('wysiwyg_editor_upload_all_display' => 'wysiwyg_editor_upload_images_field', 'wysiwyg_editor_upload_max_size_display' => 'wysiwyg_editor_upload_images_field')); $editor_themes = array('ambiance', 'chaos', 'chrome', 'clouds', 'clouds_midnight', 'cobalt', 'crimson_editor', 'dawn', 'dreamweaver', 'eclipse', 'github', 'idle_fingers', 'katzenmilch', 'kr', 'kuroir', 'merbivore', 'merbivore_soft', 'monokai', 'mono_industrial', 'pastel_on_dark', 'solarized_dark', 'solarized_light', 'terminal', 'textmate', 'tomorrow', 'tomorrow_night', 'tomorrow_night_blue', 'tomorrow_night_bright', 'tomorrow_night_eighties', 'twilight', 'vibrant_ink', 'xcode'); $theme_arr = array(); foreach ($editor_themes as $theme) { $theme_arr[$theme] = ucwords(preg_replace('/[^a-zA-Z0-9]+/', ' ', $theme)); } return array('ok' => $saved ? 'WYSIWYG editor settings saved' : null, 'fields' => array(array('label' => 'UI Color', 'type' => 'number', 'value' => qa_opt('wysiwyg_editor_ui_color'), 'tags' => 'name="wysiwyg_editor_ui_color_field" id="wysiwyg_editor_ui_color_field"'), array('label' => 'Allow images to be uploaded', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_images'), 'tags' => 'name="wysiwyg_editor_upload_images_field" id="wysiwyg_editor_upload_images_field"'), array('id' => 'wysiwyg_editor_upload_all_display', 'label' => 'Allow other content to be uploaded, e.g. Flash, PDF', 'type' => 'checkbox', 'value' => (int) qa_opt('wysiwyg_editor_upload_all'), 'tags' => 'name="wysiwyg_editor_upload_all_field"'), array('id' => 'wysiwyg_editor_upload_max_size_display', 'label' => 'Maximum size of uploads:', 'suffix' => 'MB (max ' . $this->bytes_to_mega_html(qa_get_max_upload_size()) . ')', 'type' => 'number', 'value' => $this->bytes_to_mega_html(qa_opt('wysiwyg_editor_upload_max_size')), 'tags' => 'name="wysiwyg_editor_upload_max_size_field"'), array('id' => 'wysiwyg_editor_ace_theme', 'label' => 'Choose a theme for ACE Editor', 'type' => 'select', 'value' => $theme_arr[qa_opt('wysiwyg_editor_ace_theme')], 'tags' => 'name="wysiwyg_editor_ace_theme"', 'options' => $theme_arr)), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="wysiwyg_editor_save_button"'))); }
function doctype() { if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $permits[] = 'xmlrpc_access'; foreach ($permits as $optionname) { $value = qa_opt($optionname); $optionfield = array('id' => $optionname, 'label' => qa_lang_html('xmlrpc/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, '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') . ' ', '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); } qa_html_theme_base::doctype(); }
function admin_form(&$qa_content) { // Process form input $ok = null; if (qa_clicked('close_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 NULL, meta_value longtext, PRIMARY KEY (meta_id), KEY post_id (post_id), KEY meta_key (meta_key) ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); qa_opt('close_enable', (bool) qa_post_text('close_enable')); qa_opt('close_enable_own', (bool) qa_post_text('close_enable_own')); qa_opt('close_selected', (bool) qa_post_text('close_selected')); qa_opt('closed_question_title', qa_post_text('closed_question_title')); qa_opt('closed_question_text', qa_post_text('closed_question_text')); qa_opt('close_button_text', qa_post_text('close_button_text')); qa_opt('reopen_button_text', qa_post_text('reopen_button_text')); qa_opt('close_auto_close', (int) qa_post_text('close_auto_close')); qa_opt('close_auto_close_reason', qa_post_text('close_auto_close_reason')); $ok = 'Settings Saved.'; } qa_set_display_rules($qa_content, array('close_enable_own' => 'close_enable')); // Create the form for display $fields = array(); $fields[] = array('label' => 'Enable question closing', 'tags' => 'NAME="close_enable"', 'value' => qa_opt('close_enable'), 'type' => 'checkbox', 'note' => '<i>by default, only moderators and admin can close questions.</i>'); $fields[] = array('label' => 'Allow closing own questions', 'tags' => 'NAME="close_enable_own"', 'value' => qa_opt('close_enable_own'), 'type' => 'checkbox'); $fields[] = array('label' => 'Automatically close questions with selected answers', 'tags' => 'NAME="close_selected"', 'value' => qa_opt('close_selected'), 'type' => 'checkbox'); $fields[] = array('label' => 'Text to add to closed question title', 'tags' => 'NAME="closed_question_title"', 'value' => qa_opt('closed_question_title')); $fields[] = array('label' => 'Closed question notice text', 'tags' => 'NAME="closed_question_text"', 'note' => '<i>$ will be replaced by the reason and # by the closing user.</i>', 'value' => qa_opt('closed_question_text')); $fields[] = array('label' => 'Close button text', 'tags' => 'NAME="close_button_text"', 'value' => qa_opt('close_button_text')); $fields[] = array('label' => 'Reopen button text', 'tags' => 'NAME="reopen_button_text"', 'value' => qa_opt('reopen_button_text')); $fields[] = array('type' => 'blank'); $fields[] = array('label' => 'Autoclose after # of questions', 'tags' => 'NAME="close_auto_close"', 'value' => qa_opt('close_auto_close'), 'type' => 'number'); $fields[] = array('label' => 'Reason text for autoclose', 'tags' => 'NAME="close_auto_close_reason"', 'value' => qa_opt('close_auto_close_reason')); return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="close_save"'))); }
function admin_form(&$qa_content) { $saved = false; if (qa_clicked('ldap_login_save_button')) { qa_opt('ldap_login_hostname', qa_post_text('ldap_login_hostname_field')); qa_opt('ldap_login_port', (int) qa_post_text('ldap_login_port_field')); qa_opt('ldap_login_filter', qa_post_text('ldap_login_filter_field')); qa_opt('ldap_login_fname', qa_post_text('ldap_login_fname_field')); qa_opt('ldap_login_sname', qa_post_text('ldap_login_sname_field')); qa_opt('ldap_login_mail', qa_post_text('ldap_login_mail_field')); qa_opt('ldap_login_ad', (bool) qa_post_text('ldap_login_ad_field')); qa_opt('ldap_login_ad_bind', qa_post_text('ldap_login_ad_bind_field')); qa_opt('ldap_login_ad_pwd', qa_post_text('ldap_login_ad_pwd_field')); qa_opt('ldap_login_ad_basedn', qa_post_text('ldap_login_ad_basedn_field')); qa_opt('ldap_login_generic_search', qa_post_text('ldap_login_generic_search_field')); qa_opt('ldap_authentication_attribute', qa_post_text('ldap_authentication_attribute_field')); qa_opt('ldap_login_allow_normal', (bool) qa_post_text('ldap_login_allow_normal_field')); qa_opt('ldap_login_allow_registration', (bool) qa_post_text('ldap_login_allow_registration_field')); $saved = true; } qa_set_display_rules($qa_content, array('ldap_login_allow_registration_display' => 'ldap_login_allow_normal_field', 'ldap_login_ad_bind_display' => 'ldap_login_ad_field', 'ldap_login_ad_pwd_display' => 'ldap_login_ad_field', 'ldap_login_ad_basedn_display' => 'ldap_login_ad_field', 'ldap_login_generic_search_display' => '!ldap_login_ad_field')); return array('ok' => $saved ? 'LDAP settings saved' : null, 'fields' => array(array('label' => 'Hostname for LDAP Server (ldap://x.y.z for non-SSL, ldaps://x.y.x for SSL)', 'type' => 'text', 'value' => qa_opt('ldap_login_hostname'), 'tags' => 'name="ldap_login_hostname_field"'), array('label' => 'Port for LDAP Server (389 for non-SSL, 636 for SSL)', 'type' => 'number', 'value' => qa_opt('ldap_login_port'), 'tags' => 'name="ldap_login_port_field"'), array('label' => 'LDAP filter', 'type' => 'text', 'value' => qa_opt('ldap_login_filter'), 'tags' => 'name="ldap_login_filter_field"'), array('label' => 'LDAP Firstname field', 'type' => 'text', 'value' => qa_opt('ldap_login_fname'), 'tags' => 'name="ldap_login_fname_field"'), array('label' => 'LDAP Surname field', 'type' => 'text', 'value' => qa_opt('ldap_login_sname'), 'tags' => 'name="ldap_login_sname_field"'), array('label' => 'LDAP Email field', 'type' => 'text', 'value' => qa_opt('ldap_login_mail'), 'tags' => 'name="ldap_login_mail_field"'), array('label' => 'Use Active Directory Server (unchecked: use generic LDAP)', 'type' => 'checkbox', 'value' => qa_opt('ldap_login_ad'), 'tags' => 'name="ldap_login_ad_field" id="ldap_login_ad_field"'), array('id' => 'ldap_login_ad_bind_display', 'label' => 'Binding account for AD', 'type' => 'text', 'value' => qa_opt('ldap_login_ad_bind'), 'tags' => 'name="ldap_login_ad_bind_field"'), array('id' => 'ldap_login_ad_pwd_display', 'label' => 'Password for AD binging accout', 'type' => 'text', 'value' => qa_opt('ldap_login_ad_pwd'), 'tags' => 'name="ldap_login_ad_pwd_field"'), array('id' => 'ldap_login_ad_basedn_display', 'label' => 'Base DN for AD (Usually default user OU in the Active Directory, otherwise top of the tree)', 'type' => 'text', 'value' => qa_opt('ldap_login_ad_basedn'), 'tags' => 'name="ldap_login_ad_basedn_field"'), array('id' => 'ldap_login_generic_search_display', 'label' => 'Generic LDAP search strings (at login the plugin will replace USERNAME with the user\'s username. Separate each query string with \'/\')', 'type' => 'text', 'value' => qa_opt('ldap_login_generic_search'), 'tags' => 'name="ldap_login_generic_search_field"'), array('id' => 'ldap_authentication_attribute_display', 'label' => 'Generic LDAP search authenticate attribute (e.g. sAMAccountName, sn, mail, givenName etc.)', 'type' => 'text', 'value' => qa_opt('ldap_authentication_attribute'), 'tags' => 'name="ldap_authentication_attribute_field"'), array('label' => 'Allow normal logins as a fallback to LDAP', 'type' => 'checkbox', 'value' => qa_opt('ldap_login_allow_normal'), 'tags' => 'name="ldap_login_allow_normal_field" id="ldap_login_allow_normal_field"'), array('id' => 'ldap_login_allow_registration_display', 'label' => 'Allow registration when normal logins are allowed', 'type' => 'checkbox', 'value' => qa_opt('ldap_login_allow_registration'), 'tags' => 'name="ldap_login_allow_registration_field"')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="ldap_login_save_button"'))); }
function admin_form(&$qa_content) { // Process form input $ok = null; if (qa_clicked('smilies_save')) { qa_opt('embed_smileys', (bool) qa_post_text('embed_smileys')); qa_opt('embed_smileys_animated', (bool) qa_post_text('embed_smileys_animated')); qa_opt('embed_smileys_editor_button', (bool) qa_post_text('embed_smileys_editor_button')); qa_opt('embed_smileys_markdown_button', (bool) qa_post_text('embed_smileys_markdown_button')); qa_opt('embed_smileys_css', qa_post_text('embed_smileys_css')); $ok = 'Settings Saved.'; } qa_set_display_rules($qa_content, array('embed_smileys_animated' => 'embed_smileys')); // Create the form for display $fields = array(); $fields[] = array('label' => 'Enable smiley embedding', 'tags' => 'NAME="embed_smileys"', 'value' => qa_opt('embed_smileys'), 'type' => 'checkbox'); $fields[] = array('label' => 'Use animated smilies where available', 'tags' => 'NAME="embed_smileys_animated"', 'value' => qa_opt('embed_smileys_animated'), 'type' => 'checkbox', 'note' => 'For a complete list of smilies, visit <a href="http://www.skype-emoticons.com/">this page</a>.'); $fields[] = array('label' => 'Add smiley button to ordinary editor', 'tags' => 'NAME="embed_smileys_editor_button"', 'value' => qa_opt('embed_smileys_editor_button'), 'type' => 'checkbox'); $fields[] = array('label' => 'Add smiley button to markdown editor', 'tags' => 'NAME="embed_smileys_markdown_button"', 'value' => qa_opt('embed_smileys_markdown_button'), 'type' => 'checkbox', 'note' => 'Requires markdown editor plugin, available <a href="http://codelair.co.uk/2011/markdown-editor-plugin-q2a/">here</a>.'); $fields[] = array('type' => 'blank'); $fields[] = array('label' => 'Smiley CSS', 'tags' => 'NAME="embed_smileys_css"', 'value' => qa_opt('embed_smileys_css'), 'type' => 'textarea', 'rows' => '20'); return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="smilies_save"'))); }
} } $positionvalue = @$positionoptions[$editpage['nav'] . $editpage['position']]; $permitoptions = qa_admin_permit_options(QA_PERMIT_ALL, QA_PERMIT_ADMINS, false, false); $permitvalue = @$permitoptions[isset($inpermit) ? $inpermit : $editpage['permit']]; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"', 'style' => 'tall', 'fields' => array('name' => array('tags' => 'name="name" id="name"', 'label' => qa_lang_html($isexternal ? 'admin/link_name' : 'admin/page_name'), 'value' => qa_html(isset($inname) ? $inname : @$editpage['title']), 'error' => qa_html(@$errors['name'])), 'delete' => array('tags' => 'name="dodelete" id="dodelete"', 'label' => qa_lang_html($isexternal ? 'admin/delete_link' : 'admin/delete_page'), 'value' => 0, 'type' => 'checkbox'), 'position' => array('id' => 'position_display', 'tags' => 'name="position"', 'label' => qa_lang_html('admin/position'), 'type' => 'select', 'options' => $positionoptions, 'value' => $positionvalue), 'permit' => array('id' => 'permit_display', 'tags' => 'name="permit"', 'label' => qa_lang_html('admin/permit_to_view'), 'type' => 'select', 'options' => $permitoptions, 'value' => $permitvalue), 'slug' => array('id' => 'slug_display', 'tags' => 'name="slug"', 'label' => qa_lang_html('admin/page_slug'), 'value' => qa_html(isset($inslug) ? $inslug : @$editpage['tags']), 'error' => qa_html(@$errors['slug'])), 'url' => array('id' => 'url_display', 'tags' => 'name="url"', 'label' => qa_lang_html('admin/link_url'), 'value' => qa_html(isset($inurl) ? $inurl : @$editpage['tags']), 'error' => qa_html(@$errors['url'])), 'newwindow' => array('id' => 'newwindow_display', 'tags' => 'name="newwindow"', 'label' => qa_lang_html('admin/link_new_window'), 'value' => isset($innewwindow) ? $innewwindow : @$editpage['flags'] & QA_PAGE_FLAGS_NEW_WINDOW ? 1 : 0, 'type' => 'checkbox'), 'heading' => array('id' => 'heading_display', 'tags' => 'name="heading"', 'label' => qa_lang_html('admin/page_heading'), 'value' => qa_html(isset($inheading) ? $inheading : @$editpage['heading']), 'error' => qa_html(@$errors['heading'])), 'content' => array('id' => 'content_display', 'tags' => 'name="content"', 'label' => qa_lang_html('admin/page_content_html'), 'value' => qa_html(isset($incontent) ? $incontent : @$editpage['content']), 'error' => qa_html(@$errors['content']), 'rows' => 16)), 'buttons' => array('save' => array('label' => qa_lang_html(isset($editpage['pageid']) ? 'main/save_button' : ($isexternal ? 'admin/add_link_button' : 'admin/add_page_button'))), 'saveview' => array('tags' => 'name="dosaveview"', 'label' => qa_lang_html('admin/save_view_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('dosavepage' => '1', 'edit' => @$editpage['pageid'], 'external' => (int) $isexternal, 'code' => qa_get_form_security_code('admin/pages'))); if ($isexternal) { unset($qa_content['form']['fields']['slug']); unset($qa_content['form']['fields']['heading']); unset($qa_content['form']['fields']['content']); } else { unset($qa_content['form']['fields']['url']); unset($qa_content['form']['fields']['newwindow']); } if (isset($editpage['pageid'])) { qa_set_display_rules($qa_content, array('position_display' => '!dodelete', 'permit_display' => '!dodelete', $isexternal ? 'url_display' : 'slug_display' => '!dodelete', $isexternal ? 'newwindow_display' : 'heading_display' => '!dodelete', 'content_display' => '!dodelete')); } else { unset($qa_content['form']['fields']['slug']); unset($qa_content['form']['fields']['delete']); } if ($isexternal || !isset($editpage['pageid'])) { unset($qa_content['form']['buttons']['saveview']); } $qa_content['focusid'] = 'name'; } else { // List of standard navigation links $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(), 'buttons' => array('save' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang_html('main/save_button')), 'addpage' => array('tags' => 'name="doaddpage"', 'label' => qa_lang_html('admin/add_page_button')), 'addlink' => array('tags' => 'name="doaddlink"', 'label' => qa_lang_html('admin/add_link_button'))), 'hidden' => array('code' => qa_get_form_security_code('admin/pages'))); $qa_content['form']['fields']['navlinks'] = array('label' => qa_lang_html('admin/nav_links_explanation'), 'type' => 'static', 'tight' => true); foreach ($navoptions as $optionname => $langkey) { $qa_content['form']['fields'][$optionname] = array('label' => '<a href="' . qa_path_html($navpaths[$optionname]) . '">' . qa_lang_html($langkey) . '</a>', 'tags' => 'name="option_' . $optionname . '"', 'type' => 'checkbox', 'value' => qa_opt($optionname)); }
function qa_page_q_edit_a_form(&$qa_content, $id, $answer, $question, $answers, $commentsfollows, $in, $errors) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $answerid = $answer['postid']; $prefix = 'a' . $answerid . '_'; $content = isset($in['content']) ? $in['content'] : $answer['content']; $format = isset($in['format']) ? $in['format'] : $answer['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_as'); $editor = qa_load_editor($content, $format, $editorname); $hascomments = false; foreach ($commentsfollows as $commentfollow) { if ($commentfollow['parentid'] == $answerid) { $hascomments = true; } } $form = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_a_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 12), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script($prefix . 'content') : '') . '"', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1', $prefix . 'code' => qa_get_form_security_code('edit-' . $answerid))); // Show option to convert this answer to a comment, if appropriate $commentonoptions = array(); $lastbeforeid = $question['postid']; // used to find last post created before this answer - this is default given $lastbeforetime = $question['created']; if ($question['commentable']) { $commentonoptions[$question['postid']] = qa_lang_html('question/comment_on_q') . qa_html(qa_shorten_string_line($question['title'], 80)); } foreach ($answers as $otheranswer) { if ($otheranswer['postid'] != $answerid && $otheranswer['created'] < $answer['created'] && $otheranswer['commentable'] && !$otheranswer['hidden']) { $commentonoptions[$otheranswer['postid']] = qa_lang_html('question/comment_on_a') . qa_html(qa_shorten_string_line(qa_viewer_text($otheranswer['content'], $otheranswer['format']), 80)); if ($otheranswer['created'] > $lastbeforetime) { $lastbeforeid = $otheranswer['postid']; $lastebeforetime = $otheranswer['created']; } } } if (count($commentonoptions)) { $form['fields']['tocomment'] = array('tags' => 'name="' . $prefix . 'dotoc" id="' . $prefix . 'dotoc"', 'label' => '<span id="' . $prefix . 'toshown">' . qa_lang_html('question/a_convert_to_c_on') . '</span>' . '<span id="' . $prefix . 'tohidden" style="display:none;">' . qa_lang_html('question/a_convert_to_c') . '</span>', 'type' => 'checkbox', 'tight' => true); $form['fields']['commenton'] = array('tags' => 'name="' . $prefix . 'commenton"', 'id' => $prefix . 'commenton', 'type' => 'select', 'note' => qa_lang_html($hascomments ? 'question/a_convert_warn_cs' : 'question/a_convert_warn'), 'options' => $commentonoptions, 'value' => @$commentonoptions[$lastbeforeid]); qa_set_display_rules($qa_content, array($prefix . 'commenton' => $prefix . 'dotoc', $prefix . 'toshown' => $prefix . 'dotoc', $prefix . 'tohidden' => '!' . $prefix . 'dotoc')); } // Show name and notification field if appropriate if ($answer['isbyuser']) { if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$answer['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'A', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($answer['notify']), isset($in['email']) ? $in['email'] : @$answer['notify'], @$errors['email'], $prefix); } if (!qa_user_post_permit_error('permit_edit_silent', $answer)) { $form['fields']['silent'] = array('type' => 'checkbox', 'label' => qa_lang_html('question/save_silent_label'), 'tags' => 'name="' . $prefix . 'silent"', 'value' => qa_html(@$in['silent'])); } return $form; }
function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email, $innotify, $inemail, $errors_email, $fieldprefix = '') { $fields['notify'] = array('tags' => 'name="' . $fieldprefix . 'notify"', 'type' => 'checkbox', 'value' => qa_html($innotify)); switch ($basetype) { case 'Q': $labelaskemail = qa_lang_html('question/q_notify_email'); $labelonly = qa_lang_html('question/q_notify_label'); $labelgotemail = qa_lang_html('question/q_notify_x_label'); break; case 'A': $labelaskemail = qa_lang_html('question/a_notify_email'); $labelonly = qa_lang_html('question/a_notify_label'); $labelgotemail = qa_lang_html('question/a_notify_x_label'); break; case 'C': $labelaskemail = qa_lang_html('question/c_notify_email'); $labelonly = qa_lang_html('question/c_notify_label'); $labelgotemail = qa_lang_html('question/c_notify_x_label'); break; } if (empty($login_email)) { $fields['notify']['label'] = '<span id="' . $fieldprefix . 'email_shown">' . $labelaskemail . '</span>' . '<span id="' . $fieldprefix . 'email_hidden" style="display:none;">' . $labelonly . '</span>'; $fields['notify']['tags'] .= ' id="' . $fieldprefix . 'notify" onclick="if (document.getElementById(\'' . $fieldprefix . 'notify\').checked) document.getElementById(\'' . $fieldprefix . 'email\').focus();"'; $fields['notify']['tight'] = true; $fields['email'] = array('id' => $fieldprefix . 'email_display', 'tags' => 'name="' . $fieldprefix . 'email" id="' . $fieldprefix . 'email"', 'value' => qa_html($inemail), 'note' => qa_lang_html('question/notify_email_note'), 'error' => qa_html($errors_email)); qa_set_display_rules($qa_content, array($fieldprefix . 'email_display' => $fieldprefix . 'notify', $fieldprefix . 'email_shown' => $fieldprefix . 'notify', $fieldprefix . 'email_hidden' => '!' . $fieldprefix . 'notify')); } else { $fields['notify']['label'] = str_replace('^', qa_html($login_email), $labelgotemail); } }
if ($startmailing) { unset($qa_content['form']['hidden']['dosaveoptions']); foreach ($showoptions as $optionname) { $qa_content['form']['fields'][$optionname]['type'] = 'static'; } $qa_content['form']['fields']['mailing_body']['value'] = qa_html(qa_opt('mailing_body'), true); $qa_content['form']['buttons']['stop'] = array('tags' => 'name="domailingpause" id="domailingpause"', 'label' => qa_lang_html('admin/pause_mailing_button')); } else { $qa_content['form']['buttons']['resume'] = array('tags' => 'name="domailingresume"', 'label' => qa_lang_html('admin/resume_mailing_button')); $qa_content['form']['buttons']['cancel'] = array('tags' => 'name="domailingcancel"', 'label' => qa_lang_html('admin/cancel_mailing_button')); } } else { $qa_content['form']['buttons']['spacer'] = array(); $qa_content['form']['buttons']['test'] = array('tags' => 'name="domailingtest" id="domailingtest"', 'label' => qa_lang_html('admin/send_test_button')); $qa_content['form']['buttons']['start'] = array('tags' => 'name="domailingstart" id="domailingstart"', 'label' => qa_lang_html('admin/start_mailing_button')); } if (!$startmailing) { $qa_content['form']['fields']['mailing_enabled']['note'] = qa_lang_html('admin/mailing_explanation'); $qa_content['form']['fields']['mailing_body']['rows'] = 12; $qa_content['form']['fields']['mailing_body']['note'] = qa_lang_html('admin/mailing_unsubscribe'); } break; } if (isset($checkboxtodisplay)) { qa_set_display_rules($qa_content, $checkboxtodisplay); } $qa_content['navigation']['sub'] = qa_admin_sub_navigation(); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
$qa_content['form']['fields']['name']['note'] = qa_lang_html('admin/category_no_delete_subs'); unset($qa_content['form']['fields']['delete']); unset($qa_content['form']['fields']['reassign']); } else { $qa_content['form']['fields']['delete'] = array('tags' => 'name="dodelete" id="dodelete"', 'label' => '<span id="reassign_shown">' . qa_lang_html('admin/delete_category_reassign') . '</span>' . '<span id="reassign_hidden" style="display:none;">' . qa_lang_html('admin/delete_category') . '</span>', 'value' => 0, 'type' => 'checkbox'); $qa_content['form']['fields']['reassign'] = array('id' => 'reassign_display', 'tags' => 'name="reassign"'); qa_set_up_category_field($qa_content, $qa_content['form']['fields']['reassign'], 'reassign', $categories, $editcategory['parentid'], true, true, null, $editcategory['categoryid']); } $qa_content['form']['fields']['questions'] = array('label' => qa_lang_html('admin/total_qs'), 'type' => 'static', 'value' => '<a href="' . qa_path_html('questions/' . qa_category_path_request($categories, $editcategory['categoryid'])) . '">' . ($editcategory['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', number_format($editcategory['qcount']))) . '</a>'); if ($hassubcategory && !qa_opt('allow_no_sub_category')) { $nosubcount = qa_db_count_categoryid_qs($editcategory['categoryid']); if ($nosubcount) { $qa_content['form']['fields']['questions']['error'] = strtr(qa_lang_html('admin/category_no_sub_error'), array('^q' => number_format($nosubcount), '^1' => '<a href="' . qa_path_html(qa_request(), array('edit' => $editcategory['categoryid'], 'missing' => 1)) . '">', '^2' => '</a>')); } } qa_set_display_rules($qa_content, array('position_display' => '!dodelete', 'slug_display' => '!dodelete', 'content_display' => '!dodelete', 'parent_display' => '!dodelete', 'children_display' => '!dodelete', 'reassign_display' => 'dodelete', 'reassign_shown' => 'dodelete', 'reassign_hidden' => '!dodelete')); } else { // new category unset($qa_content['form']['fields']['delete']); unset($qa_content['form']['fields']['reassign']); unset($qa_content['form']['fields']['slug']); unset($qa_content['form']['fields']['questions']); $qa_content['focusid'] = 'name'; } if (!$setparent) { $pathhtml = qa_category_path_html($categories, @$editcategory['parentid']); if (count($categories)) { $qa_content['form']['fields']['parent'] = array('id' => 'parent_display', 'label' => qa_lang_html('admin/category_parent'), 'type' => 'static', 'value' => strlen($pathhtml) ? $pathhtml : qa_lang_html('admin/category_top_level')); $qa_content['form']['fields']['parent']['value'] = '<a href="' . qa_path_html(qa_request(), array('edit' => @$editcategory['parentid'])) . '">' . $qa_content['form']['fields']['parent']['value'] . '</a>'; if (isset($editcategory['categoryid'])) { $qa_content['form']['fields']['parent']['value'] .= ' - ' . '<a href="' . qa_path_html(qa_request(), array('edit' => $editcategory['categoryid'], 'setparent' => 1)) . '" style="white-space: nowrap;">' . qa_lang_html('admin/category_move_parent') . '</a>';
function admin_form(&$qa_content) { $saved = false; $error = array(); if (qa_clicked(self::SAVE_BUTTON)) { qa_opt(self::ENABLE, (int) qa_post_text(self::ENABLE . '_field')); qa_opt(self::FILE, (int) qa_post_text(self::FILE . '_field')); qa_opt(self::PATH, qa_post_text(self::PATH . '_field')); self::check_number(self::EXPIRATION_TIME, self::EXPIRATION_TIME_MIN, self::EXPIRATION_TIME_MAX, $error); qa_opt(self::EXPIRATION_EVENTS, qa_post_text(self::EXPIRATION_EVENTS . '_field')); qa_opt(self::EXCLUDED_METHOD, qa_post_text(self::EXCLUDED_METHOD . '_field')); qa_opt(self::EXCLUDED_REQUESTS, qa_post_text(self::EXCLUDED_REQUESTS . '_field')); qa_opt(self::COMPRESS, (int) qa_post_text(self::COMPRESS . '_field')); qa_opt(self::DEBUG, (int) qa_post_text(self::DEBUG . '_field')); if (!count($error)) { $saved = qa_lang(self::PLUGIN . '/' . self::SAVED_MESSAGE); } else { $saved = qa_lang(self::PLUGIN . '/' . self::ERROR_MESSAGE); } } if (qa_clicked(self::RESET_BUTTON)) { qa_opt(self::ENABLE, $this->option_default(self::ENABLE)); qa_opt(self::FILE, $this->option_default(self::FILE)); qa_opt(self::PATH, $this->option_default(self::PATH)); qa_opt(self::EXPIRATION_TIME, $this->option_default(self::EXPIRATION_TIME)); qa_opt(self::EXPIRATION_EVENTS, $this->option_default(self::EXPIRATION_EVENTS)); qa_opt(self::EXCLUDED_METHOD, $this->option_default(self::EXCLUDED_METHOD)); qa_opt(self::EXCLUDED_REQUESTS, $this->option_default(self::EXCLUDED_REQUESTS)); qa_opt(self::COMPRESS, $this->option_default(self::COMPRESS)); qa_opt(self::DEBUG, $this->option_default(self::DEBUG)); $saved = qa_lang(self::PLUGIN . '/' . self::RESET_MESSAGE); } if (qa_clicked(self::CLEAR_BUTTON)) { qa_caching_main::clear_cache(); $saved = qa_lang(self::PLUGIN . '/' . self::CLEAR_MESSAGE); } $rules = array(); $rules[self::FILE] = self::ENABLE . '_field'; $rules[self::PATH] = self::ENABLE . '_field' . ' && ' . self::FILE . '_field'; $rules[self::EXPIRATION_TIME] = self::ENABLE . '_field'; $rules[self::EXPIRATION_EVENTS] = self::ENABLE . '_field'; $rules[self::EXCLUDED_METHOD] = self::ENABLE . '_field'; $rules[self::EXCLUDED_REQUESTS] = self::ENABLE . '_field'; $rules[self::COMPRESS] = self::ENABLE . '_field'; $rules[self::DEBUG] = self::ENABLE . '_field'; qa_set_display_rules($qa_content, $rules); $form = array(); //$form['style'] = 'wide'; if ($saved != '' && !$error) { $form['ok'] = $saved; } $form['fields'][] = self::form_field_check(self::ENABLE, $error); $form['fields'][] = self::form_field_check(self::FILE, $error); $form['fields'][] = self::form_field_text(self::PATH, $error); $form['fields'][] = self::form_field_number(self::EXPIRATION_TIME, $error); $form['fields'][] = self::form_field_textarea(self::EXPIRATION_EVENTS, self::EXPIRATION_EVENTS_ROWS, $error, ''); $form['fields'][] = self::form_field_text(self::EXCLUDED_METHOD, $error); $form['fields'][] = self::form_field_textarea(self::EXCLUDED_REQUESTS, self::EXCLUDED_REQUESTS_ROWS, $error); $form['fields'][] = self::form_field_check(self::COMPRESS, $error); $form['fields'][] = self::form_field_check(self::DEBUG, $error); $form['buttons'][] = array('label' => qa_lang(self::PLUGIN . '/' . self::SAVE_BUTTON), 'tags' => 'NAME="' . self::SAVE_BUTTON . '" ID="' . self::SAVE_BUTTON . '"'); $form['buttons'][] = array('label' => qa_lang(self::PLUGIN . '/' . self::RESET_BUTTON), 'tags' => 'NAME="' . self::RESET_BUTTON . '" ID="' . self::RESET_BUTTON . '" onClick="javascript:return confirm(\'' . qa_lang(self::PLUGIN . '/' . self::RESET_CONFIRM) . '\')"'); $form['buttons'][] = array('label' => qa_lang(self::PLUGIN . '/' . self::CLEAR_BUTTON), 'tags' => 'NAME="' . self::CLEAR_BUTTON . '" ID="' . self::CLEAR_BUTTON . '" onClick="javascript:return confirm(\'' . qa_lang(self::PLUGIN . '/' . self::CLEAR_CONFIRM) . '\')"'); return $form; }
$positionhtml .= ' - ' . qa_lang_html_sub('admin/after_x', $previous['title']); } $positionoptions[$place . (isset($previous) ? 1 + $maxposition : 1)] = $positionhtml; } } } $positionvalue = @$positionoptions[$editwidget['place'] . $editwidget['position']]; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('admin/widget_name') . ' ' . qa_html($editwidget['title']), 'type' => 'static', 'tight' => true), 'position' => array('id' => 'position_display', 'tags' => 'name="position"', 'label' => qa_lang_html('admin/position'), 'type' => 'select', 'options' => $positionoptions, 'value' => $positionvalue), 'delete' => array('tags' => 'name="dodelete" id="dodelete"', 'label' => qa_lang_html('admin/delete_widget_position'), 'value' => 0, 'type' => 'checkbox'), 'all' => array('id' => 'all_display', 'label' => qa_lang_html('admin/widget_all_pages'), 'type' => 'checkbox', 'tags' => 'name="template_all" id="template_all"', 'value' => is_numeric(strpos(',' . @$editwidget['tags'] . ',', ',all,'))), 'templates' => array('id' => 'templates_display', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'type' => 'custom', 'html' => '')), 'buttons' => array('save' => array('label' => qa_lang_html(isset($editwidget['widgetid']) ? 'main/save_button' : 'admin/add_widget_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('dosavewidget' => '1', 'edit' => @$editwidget['widgetid'], 'title' => @$editwidget['title'], 'code' => qa_get_form_security_code('admin/widgets'))); foreach ($templateoptions as $template => $optionhtml) { $qa_content['form']['fields']['templates']['html'] .= '<input type="checkbox" name="template_' . qa_html($template) . '"' . (is_numeric(strpos(',' . @$editwidget['tags'] . ',', ',' . $template . ',')) ? ' checked' : '') . '/> ' . $optionhtml . '<br/>'; } if (isset($editwidget['widgetid'])) { qa_set_display_rules($qa_content, array('templates_display' => '!(dodelete||template_all)', 'all_display' => '!dodelete')); } else { unset($qa_content['form']['fields']['delete']); qa_set_display_rules($qa_content, array('templates_display' => '!template_all')); } if (!$widgetfound) { unset($qa_content['form']['fields']['title']['tight']); $qa_content['form']['fields']['title']['error'] = qa_lang_html('admin/widget_not_available'); unset($qa_content['form']['fields']['position']); unset($qa_content['form']['fields']['all']); unset($qa_content['form']['fields']['templates']); if (!isset($editwidget['widgetid'])) { unset($qa_content['form']['buttons']['save']); } } elseif (!count($positionoptions)) { unset($qa_content['form']['fields']['title']['tight']); $qa_content['form']['fields']['title']['error'] = qa_lang_html('admin/widget_no_positions'); unset($qa_content['form']['fields']['position']); unset($qa_content['form']['fields']['all']);
$pointstitle[$inpoints] = $intitle; } } // Save the new option value krsort($pointstitle, SORT_NUMERIC); $option = ''; foreach ($pointstitle as $points => $title) { $option .= (strlen($option) ? ',' : '') . $points . ' ' . $title; } qa_set_option('points_to_titles', $option); if (empty($errors)) { qa_redirect('admin/users'); } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/users_title'); $qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error(); $qa_content['form'] = array('tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"', 'style' => 'tall', 'fields' => array('title' => array('tags' => 'name="title" id="title"', 'label' => qa_lang_html('admin/user_title'), 'value' => qa_html(isset($intitle) ? $intitle : @$pointstitle[$oldpoints]), 'error' => qa_html(@$errors['title'])), 'delete' => array('tags' => 'name="dodelete" id="dodelete"', 'label' => qa_lang_html('admin/delete_title'), 'value' => 0, 'type' => 'checkbox'), 'points' => array('id' => 'points_display', 'tags' => 'name="points"', 'label' => qa_lang_html('admin/points_required'), 'type' => 'number', 'value' => qa_html(isset($inpoints) ? $inpoints : @$oldpoints), 'error' => qa_html(@$errors['points']))), 'buttons' => array('save' => array('label' => qa_lang_html(isset($pointstitle[$oldpoints]) ? 'main/save_button' : 'admin/add_title_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('dosavetitle' => '1', 'edit' => @$oldpoints, 'code' => qa_get_form_security_code('admin/usertitles'))); if (isset($pointstitle[$oldpoints])) { qa_set_display_rules($qa_content, array('points_display' => '!dodelete')); } else { unset($qa_content['form']['fields']['delete']); } $qa_content['focusid'] = 'title'; $qa_content['navigation']['sub'] = qa_admin_sub_navigation(); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function process_request($request) { // double check we are admin if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) { return; } if (qa_clicked('docancel')) { qa_redirect('admin/plugins'); } $qa_content = qa_content_prepare(); $qa_content['title'] = 'Widget Anywhere'; $qa_content['custom'] = '<p><a href="' . qa_path('admin/plugins') . '#' . qa_html($this->anchor) . '">« back to plugin options</a></p>'; $saved_msg = null; $editid = qa_get('editid'); if (qa_post_text('dodelete')) { $this->delete_widget(); qa_redirect('admin/plugins'); } else { if (qa_clicked('save_button')) { // save widget $widget = $this->save_widget(); $saved_msg = 'Widget saved.'; } else { if (empty($editid)) { // display blank form $widget = array('id' => 0, 'title' => '', 'pages' => '', 'position' => '', 'ordering' => 1, 'content' => ''); } else { // load specified widget $sql = 'SELECT * FROM ^' . $this->pluginkey . ' WHERE id=#'; $result = qa_db_query_sub($sql, $editid); $widget = qa_db_read_one_assoc($result); } } } $sel_position = empty($widget['position']) ? null : @$this->positionlangs[$widget['position']]; // set up page (template) list $widget_pages = explode(',', $widget['pages']); $sel_pages = array(); $custom_pages = array(); foreach ($widget_pages as $page) { if (strpos($page, 'custom:') === 0) { $custom_pages[] = substr($page, 7); } else { $sel_pages[] = $page; } } // $chkd = in_array('all', $sel_pages) ? 'checked' : ''; // $pages_html = '<label><input type="checkbox" name="wpages_all" ' . $chkd . '> ' . qa_lang_html('admin/widget_all_pages') . '</label><br><br>'; $pages_html = ''; foreach ($this->templatelangkeys as $tmpl => $langkey) { $chkd = in_array($tmpl, $sel_pages) ? 'checked' : ''; $pages_html .= '<label><input type="checkbox" name="wpages_' . $tmpl . '" ' . $chkd . '> ' . qa_lang_html($langkey) . '</label><br>'; } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $saved_msg, 'fields' => array('title' => array('label' => 'Title', 'tags' => 'NAME="wtitle"', 'value' => qa_html($widget['title'])), 'position' => array('type' => 'select', 'label' => 'Position', 'tags' => 'NAME="wposition"', 'options' => $this->positionlangs, 'value' => $sel_position), 'all_pages' => array('type' => 'checkbox', 'id' => 'tb_pages_all', 'label' => qa_lang_html('admin/widget_all_pages'), 'tags' => 'NAME="wpages_all" ID="wpages_all"', 'value' => in_array('all', $sel_pages)), 'pages' => array('type' => 'custom', 'id' => 'tb_pages_list', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'html' => $pages_html), 'show_custom_pages' => array('type' => 'checkbox', 'id' => 'tb_show_custom_pages', 'label' => 'Show on custom page(s)', 'tags' => 'NAME="cb_custom_pages" ID="cb_custom_pages"', 'value' => count($custom_pages) > 0), 'custom_pages' => array('id' => 'tb_custom_pages', 'label' => 'Page slugs', 'tags' => 'NAME="wpages_custom"', 'value' => qa_html(implode(',', $custom_pages)), 'note' => 'Separate multiple page slugs (URL fragments) with commas, e.g. <code>custom-page,other-page</code>'), 'ordering' => array('type' => 'number', 'label' => 'Order', 'tags' => 'NAME="wordering"', 'value' => qa_html($widget['ordering'])), 'content' => array('type' => 'textarea', 'label' => 'Content (HTML)', 'tags' => 'NAME="wcontent"', 'value' => qa_html($widget['content']), 'rows' => 12)), 'hidden' => array('wid' => $widget['id']), 'buttons' => array('save' => array('tags' => 'NAME="save_button"', 'label' => 'Save widget', 'value' => '1'), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button')))); if ($widget['id'] > 0) { $qa_content['form']['fields']['delete'] = array('tags' => 'NAME="dodelete"', 'label' => 'Delete widget', 'value' => 0, 'type' => 'checkbox'); } qa_set_display_rules($qa_content, array('tb_pages_list' => '!wpages_all', 'tb_show_custom_pages' => '!wpages_all', 'tb_custom_pages' => 'cb_custom_pages && !wpages_all')); return $qa_content; }
$positionhtml = qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($passedself ? $userfield : $previous))); } else { $positionhtml = qa_lang_html('admin/first'); } $positionoptions[$userfield['position']] = $positionhtml; if ($userfield['fieldid'] == @$editfield['fieldid']) { $passedself = true; } $previous = $userfield; } if (isset($editfield['position'])) { $positionvalue = $positionoptions[$editfield['position']]; } else { $positionvalue = isset($previous) ? qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($previous))) : qa_lang_html('admin/first'); $positionoptions[1 + @max(array_keys($positionoptions))] = $positionvalue; } $typeoptions = array(0 => qa_lang_html('admin/field_single_line'), QA_FIELD_FLAGS_MULTI_LINE => qa_lang_html('admin/field_multi_line'), QA_FIELD_FLAGS_LINK_URL => qa_lang_html('admin/field_link_url')); $permitoptions = qa_admin_permit_options(QA_PERMIT_ALL, QA_PERMIT_ADMINS, false, false); $permitvalue = @$permitoptions[isset($inpermit) ? $inpermit : $editfield['permit']]; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"', 'style' => 'tall', 'fields' => array('name' => array('tags' => 'name="name" id="name"', 'label' => qa_lang_html('admin/field_name'), 'value' => qa_html(isset($inname) ? $inname : qa_user_userfield_label($editfield)), 'error' => qa_html(@$errors['name'])), 'delete' => array('tags' => 'name="dodelete" id="dodelete"', 'label' => qa_lang_html('admin/delete_field'), 'value' => 0, 'type' => 'checkbox'), 'type' => array('id' => 'type_display', 'tags' => 'name="type"', 'label' => qa_lang_html('admin/field_type'), 'type' => 'select', 'options' => $typeoptions, 'value' => @$typeoptions[isset($intype) ? $intype : @$editfield['flags'] & (QA_FIELD_FLAGS_MULTI_LINE | QA_FIELD_FLAGS_LINK_URL)]), 'permit' => array('id' => 'permit_display', 'tags' => 'name="permit"', 'label' => qa_lang_html('admin/permit_to_view'), 'type' => 'select', 'options' => $permitoptions, 'value' => $permitvalue), 'position' => array('id' => 'position_display', 'tags' => 'name="position"', 'label' => qa_lang_html('admin/position'), 'type' => 'select', 'options' => $positionoptions, 'value' => $positionvalue), 'onregister' => array('id' => 'register_display', 'tags' => 'name="onregister"', 'label' => qa_lang_html('admin/show_on_register_form'), 'type' => 'checkbox', 'value' => isset($inonregister) ? $inonregister : @$editfield['flags'] & QA_FIELD_FLAGS_ON_REGISTER)), 'buttons' => array('save' => array('label' => qa_lang_html(isset($editfield['fieldid']) ? 'main/save_button' : 'admin/add_field_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('dosavefield' => '1', 'edit' => @$editfield['fieldid'], 'code' => qa_get_form_security_code('admin/userfields'))); if (isset($editfield['fieldid'])) { qa_set_display_rules($qa_content, array('type_display' => '!dodelete', 'position_display' => '!dodelete', 'register_display' => '!dodelete', 'permit_display' => '!dodelete')); } else { unset($qa_content['form']['fields']['delete']); } $qa_content['focusid'] = 'name'; $qa_content['navigation']['sub'] = qa_admin_sub_navigation(); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */