/** * Show/edit bbcodes * @version 1.0.12 */ function bbcodes_edit($id, $mode, $action, $bbcode = '') { global $user, $db, $cache, $template, $config, $phpbb_root_path, $phpEx; $user->add_lang(array('acp/posting', 'mods/info_acp_abbcodes', 'mods/abbcode')); // Is this ABBC3 is disabled if (!isset($config['ABBC3_MOD'])) { trigger_error($user->lang['ABBCODES_MOD_DISABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } $img_spacer = 'spacer.gif'; $img_noimg = 'no_image.png'; if ($this->submit && $bbcode) { // Get items to create/modify $abbcode_name = isset($_POST['name']) ? request_var('name', array('' => '')) : array(); $display_on_posting = isset($_POST['display_on_posting']) ? request_var('display_on_posting', array('' => 0)) : array(); $display_on_pm = isset($_POST['display_on_pm']) ? request_var('display_on_pm', array('' => 0)) : array(); $display_on_sig = isset($_POST['display_on_sig']) ? request_var('display_on_sig', array('' => 0)) : array(); $bbcode_image = utf8_normalize_nfc(request_var('image', array('' => ''), true)); $group_ids = implode(',', request_var('group_id', array(0))); $bbcode_sql = array('display_on_posting' => isset($display_on_posting[$bbcode]) ? 1 : 0, 'display_on_pm' => isset($display_on_pm[$bbcode]) ? 1 : 0, 'display_on_sig' => isset($display_on_sig[$bbcode]) ? 1 : 0, 'bbcode_image' => isset($bbcode_image[$bbcode]) ? $bbcode_image[$bbcode] : '', 'bbcode_group' => isset($group_ids) && trim($group_ids) != '' ? $group_ids : 0); // Fix for break line? if (substr($abbcode_name[$bbcode], 0, 14) == 'ABBCODES_BREAK') { $bbcode_sql['bbcode_image'] = $img_spacer; } if ($abbcode_name[$bbcode] == 'ABBC3_COLOR' || $abbcode_name[$bbcode] == 'ABBC3_HIGHLIGHT') { if ($abbc3_color_mode = request_var('abbc3_color', '')) { set_config('ABBC3_COLOR_MODE', $abbc3_color_mode); } if ($abbc3_highlight_mode = request_var('abbc3_highlight', '')) { set_config('ABBC3_HIGHLIGHT_MODE', $abbc3_highlight_mode); } } $sql = 'UPDATE ' . BBCODES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $bbcode_sql) . ' WHERE bbcode_id = ' . $bbcode; $result = $db->sql_query($sql); if ($result) { trigger_error($user->lang['LOG_CONFIG_ABBCODES'] . adm_back_link($this->u_action . "&last_id={$bbcode}")); } else { trigger_error($user->lang['LOG_CONFIG_ABBCODES_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); } $bbcode = ''; } $error = array(); // Exclude bots $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name IN ('BOTS')"; $result = $db->sql_query($sql); $exclude = array(); while ($row = $db->sql_fetchrow($result)) { $exclude[] = $row['group_id']; } $db->sql_freeresult($result); $sql = 'SELECT abbcode, bbcode_order, bbcode_id, bbcode_group, bbcode_tag, bbcode_helpline, bbcode_image, display_on_posting, display_on_pm, display_on_sig FROM ' . BBCODES_TABLE . ' ORDER BY bbcode_order'; $result = $db->sql_query($sql); $bbcode_id = request_var('bbcode_id', 0); $template->assign_vars(array('S_BBCODES' => true, 'LAST_ID' => request_var('last_id', $bbcode_id), 'L_TITLE_BBCODES' => $user->lang['ABBCODES_CONFIG'], 'L_EXPLAIN_BBCODES' => $user->lang['ABBCODES_CONFIG_EXPLAIN'], 'S_BBCODE_EDIT' => $bbcode ? true : false, 'ICON_BASEDIR' => $this->dir . '/images/', 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ABBC3' => $user->lang['ABBC3_HELP_ABOUT'], 'U_ACTION' => $this->u_action, 'F_ACTION' => $bbcode ? $this->u_action . '&mode=bbcodes&action=edit&bbcode_id=' . $bbcode : null, 'A_ACTION' => !$bbcode ? $this->u_action . '&mode=bbcodes&action=newdlb' : null, 'U_SYNC' => !$bbcode ? $this->u_action . '&mode=bbcodes&action=sync' : null, 'U_BACK' => $bbcode ? $this->u_back : null, 'U_AJAX_REQUEST' => append_sid($phpbb_root_path . 'abbcode_ajax.' . $phpEx))); $no_move = array('ABBC3_FONT', 'ABBC3_SIZE', 'ABBC3_HIGHLIGHT', 'ABBC3_COLOR'); $first_row_to_move = 0; while ($row = $db->sql_fetchrow($result)) { // Some fixes $bbcode_id = $row['bbcode_id']; $abbcode = $row['abbcode']; $abbcode_name = ($row['abbcode'] ? 'ABBC3_' : '') . strtoupper(str_replace('=', '', trim($row['bbcode_tag']))); $abbcode_name = $row['bbcode_helpline'] == 'ABBC3_ED2K_TIP' ? 'ABBC3_ED2K' : $abbcode_name; $abbcode_image = trim($row['bbcode_image']); $abbcode_tag = str_replace('=', '', trim($row['bbcode_tag'])); $is_a_bbcode = true; // is a break line or division ? if (strpos($abbcode_name, 'ABBC3_DIVISION') !== false || strpos($abbcode_name, 'ABBC3_BREAK') !== false || in_array($row['bbcode_tag'], array('imgshack', 'cut', 'copy', 'paste', 'plain'))) { $is_a_bbcode = false; if (strpos($abbcode_name, 'ABBC3_DIVISION') !== false) { if ($config['ABBC3_TAB']) { $abbcode_name = 'ABBCODES_DIVISION'; } else { continue; } } else { if (strpos($abbcode_name, 'ABBC3_BREAK') !== false) { $abbcode_name = 'ABBCODES_BREAK'; } } } if ($abbcode_name == 'ABBC3_COLOR') { $first_row_to_move = $row['bbcode_order'] + 1; } $abbcode_explain = ''; $bbcode_tagname = ''; if (!$abbcode) { $bbcode_tagname = '[' . $abbcode_tag . ']'; $abbcode_explain = $user->lang['ABBCODES_CUSTOM'] . ' <strong>' . $bbcode_tagname . '</strong>'; //$row['bbcode_helpline']; } else { $bbcode_tagname = !$is_a_bbcode ? '' : '[' . str_replace(array('listo', 'listb', 'listitem'), array('list=', 'list', '*'), $abbcode_tag) . ']'; $abbcode_explain = isset($user->lang[$abbcode_name . '_MOVER']) ? $user->lang[$abbcode_name . '_MOVER'] : ''; $abbcode_explain .= isset($user->lang[$abbcode_name . '_EXPLAIN']) ? '<br />' . $user->lang[$abbcode_name . '_EXPLAIN'] : ''; } if ($action != 'edit') { $template->assign_block_vars('items', array('ID' => $bbcode_id, 'ORDER' => $row['bbcode_order'], 'NAME' => str_replace('=', '', trim($row['bbcode_tag'])), 'TAG_NAME' => $bbcode_tagname, 'TAG_EXPLAIN' => $abbcode_explain, 'IMG_SRC' => $abbcode_image && $abbcode_image != $img_spacer ? $this->dir . '/images/' . $abbcode_image : '', 'ON_POST' => $row['display_on_posting'] ? $user->lang['ENABLED'] : '<em>' . $user->lang['DISABLED'] . '</em>', 'ON_PM' => $row['display_on_pm'] ? $user->lang['ENABLED'] : '<em>' . $user->lang['DISABLED'] . '</em>', 'ON_SIG' => $row['display_on_sig'] ? $user->lang['ENABLED'] : '<em>' . $user->lang['DISABLED'] . '</em>', 'S_NOMOVE' => in_array($abbcode_name, $no_move) ? true : false, 'S_FIRST_ROW' => $row['bbcode_order'] == $first_row_to_move ? true : false, 'U_EDIT' => $this->u_action . '&mode=bbcodes&action=edit&bbcode_id=' . $row['bbcode_id'], 'U_MOVE_UP' => $this->u_action . '&mode=bbcodes&action=move_up&bbcode_id=' . $row['bbcode_id'], 'U_MOVE_DOWN' => $this->u_action . '&mode=bbcodes&action=move_down&bbcode_id=' . $row['bbcode_id'])); } else { if ($action == 'edit' && $row['bbcode_id'] == $bbcode) { $radio = ''; if ($abbcode_name == 'ABBC3_COLOR' || $abbcode_name == 'ABBC3_HIGHLIGHT') { $radio = get_radio(strtolower($abbcode_name), $user->lang['ABBCODES_COLOUR_SELECTOR'], $config[$abbcode_name . '_MODE'], $abbcode_name); } $template->assign_block_vars('items', array('ID' => $bbcode_id, 'NAME' => $abbcode_name, 'TAG_NAME' => $bbcode_tagname, 'TAG_EXPLAIN' => $abbcode ? $abbcode_explain : $row['bbcode_helpline'], 'IMG_SRC' => $abbcode_image ? $abbcode_image != $img_spacer ? $this->dir . '/images/' . $abbcode_image : '' : $this->dir . '/images/' . $img_noimg, 'S_NOMOVE' => in_array($abbcode_name, $no_move) ? true : null, 'S_NEW_IMG' => image_select($this->dir . '/images', $abbcode_image, 'image[' . $bbcode_id . ']', false, $this->u_action), 'POSTING_CHECKED' => $row['display_on_posting'] ? ' checked="checked"' : '', 'PM_CHECKED' => $row['display_on_pm'] ? ' checked="checked"' : '', 'SIG_CHECKED' => $row['display_on_sig'] ? ' checked="checked"' : '', 'S_GROUP_OPTIONS' => groups_select_options(explode(',', $row['bbcode_group']), $exclude), 'S_RADIO_BUTTONS' => $radio ? $radio : '')); } } } $db->sql_freeresult($result); }
$radio = new Radio($name, $value, $label, $args); return $radio->render(); } /** * <pre>skip_radio( $name, $value, $args )</pre> * * Adding a Radiobutton field. * * <b>Default Usage</b> * <code> * skip_radio( 'value', '1' ); * </code> * This will create an automated saved checkbox field. * * <b>Parameters</b> * * <code> * $name // (string) (required) The name of the field. * $value // (string) (required) The value of the checkbox element which will be saved if Radiobutton is checked. * $args // (array/string) (optional) Values for further settings. * </code> * * <b>$args Settings</b> * * <ul> * <li>id (string) ID if the HTML Element.</li> * <li>label (string) Label for Element.</li> * <li>default (string) Default Value if no Value is set before ('checked' if value have to be checked on default).</li> * <li>classes (string) Name of CSS Classes which will be inserted into HTML seperated by empty space.</li> * <li>before_element (string) Content before the element.</li> * <li>after_element (string) Content after the element.</li> * <li>save (boolean) TRUE if value of field have to be saved in Database, FALSE if not (default TRUE).</li> * </ul> * * <b>Example</b> * * Creating a labeled Checkbox in an automatic saved form. * <code> * skip_form_start( 'myformname' ); * * skip_radio( 'myradiovalue', 'red', 'label=Red' ); * skip_radio( 'myradiovalue', 'green', 'label=Green' ); * * skip_form_end(); * </code> * * Getting back the saved data. * <code> * $value = skip_value( 'myformname', 'myradiovalue' ); * </code> * @package Skip\Forms * @since 1.0 * @param string $name Name of field. * @param string $value The value of the checkbox element which will be saved if Radiobutton is checked. * @param array/string $args List of Arguments. */ function radio($name, $value, $label = FALSE, $args = array())