|
From: Jon O. <jon...@us...> - 2006-06-25 21:52:47
|
Update of /cvsroot/mxbb/core/modules/mx_textblocks/admin In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25772/modules/mx_textblocks/admin Modified Files: mx_module_defs.php Log Message: Implementing a new mx_post class, to handle all kind of html, bbcode, smilies, links, images etc Index: mx_module_defs.php =================================================================== RCS file: /cvsroot/mxbb/core/modules/mx_textblocks/admin/mx_module_defs.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** mx_module_defs.php 17 Jun 2006 20:09:07 -0000 1.17 --- mx_module_defs.php 25 Jun 2006 21:52:42 -0000 1.18 *************** *** 50,54 **** function submit_module_parameters( $parameter_data, $block_id ) { ! global $HTTP_POST_VARS, $db, $board_config, $mx_cache, $mx_blockcp, $mx_root_path, $phpEx; global $html_entities_match, $html_entities_replace; --- 50,54 ---- function submit_module_parameters( $parameter_data, $block_id ) { ! global $HTTP_POST_VARS, $db, $board_config, $mx_cache, $mx_blockcp, $mx_root_path, $phpbb_root_path, $phpEx; global $html_entities_match, $html_entities_replace; *************** *** 63,76 **** $smilies_on = $board_config['allow_smilies'] ? true : false; - if( $bbcode_on ) - { - $bbcode_uid = make_bbcode_uid(); - } - break; case 'CustomizedTextBlock': - // - // "Hasty" code to find text format settings. Could be wrong... - // $bbcode_on = isset($HTTP_POST_VARS[$mx_blockcp->block_parameters['allow_bbcode']['parameter_id']]) ? $HTTP_POST_VARS[$mx_blockcp->block_parameters['allow_bbcode']['parameter_id']] == 'TRUE' : $mx_blockcp->block_parameters['allow_bbcode']['parameter_value'] == 'TRUE'; $html_on = isset($HTTP_POST_VARS[$mx_blockcp->block_parameters['allow_html']['parameter_id']]) ? $HTTP_POST_VARS[$mx_blockcp->block_parameters['allow_html']['parameter_id']] == 'TRUE' : $mx_blockcp->block_parameters['allow_html']['parameter_value'] == 'TRUE'; --- 63,68 ---- *************** *** 78,86 **** $board_config['allow_html_tags'] = isset($HTTP_POST_VARS[$mx_blockcp->block_parameters['html_tags']['parameter_id']]) ? $HTTP_POST_VARS[$mx_blockcp->block_parameters['html_tags']['parameter_id']] : $mx_blockcp->block_parameters['html_tags']['parameter_value']; - if( $bbcode_on ) - { - $bbcode_uid = make_bbcode_uid(); - } - break; case 'WysiwygTextBlock': --- 70,73 ---- *************** *** 88,103 **** $html_on = true; $smilies_on = false; ! $bbcode_uid = 0; ! ! // Remove allowed html tags ! $html_entities_match = array(); ! $html_entities_replace = array(); ! break; } ! $parameter_value = prepare_message(trim($parameter_value), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); ! $parameter_opt = $bbcode_uid; // --- 75,96 ---- $html_on = true; $smilies_on = false; ! $bbcode_uid = ''; break; } ! // ! // Instantiate the mx_text class ! // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); ! $mx_text->allow_all_html_tags = $parameter_data['parameter_type'] = 'WysiwygTextBlock' ? true : false; ! ! // ! // Encode for db storage ! // ! $parameter_value = $mx_text->encode($parameter_value); ! $parameter_opt = $mx_text->bbcode_uid; // *************** *** 112,116 **** mx_admin::mx_add_search_words('single', $block_id, $parameter_value, $block_title); - return array('parameter_value' => $parameter_value, 'parameter_opt' => $parameter_opt); } --- 105,108 ---- *************** *** 139,160 **** function display_edit_phpBBTextBlock( $block_id, $parameter_id, $parameter_data ) { ! global $template, $board_config, $db, $theme, $lang, $images, $mx_blockcp, $mx_root_path, $phpEx, $mx_table_prefix, $table_prefix; global $HTTP_POST_VARS; ! $parameter_value = isset($HTTP_POST_VARS['preview']) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS[$parameter_data['parameter_name']]))) : $parameter_data['parameter_value']; $bbcode_on = $board_config['allow_bbcode'] ? true : false; $html_on = $board_config['allow_html'] ? true : false; $smilies_on = $board_config['allow_smilies'] ? true : false; ! $bbcode_uid = $parameter_data['parameter_opt']; if ( isset($HTTP_POST_VARS['preview']) ) { ! $this->preview($parameter_value, $html_on, $bbcode_on, $smilies_on); $template->assign_block_vars('preview', array()); } else { ! $parameter_value = $this->decode($parameter_value, $bbcode_uid); } --- 131,179 ---- function display_edit_phpBBTextBlock( $block_id, $parameter_id, $parameter_data ) { ! global $template, $board_config, $db, $theme, $lang, $images, $mx_blockcp, $mx_root_path, $phpbb_root_path, $phpEx, $mx_table_prefix, $table_prefix; global $HTTP_POST_VARS; ! $parameter_value = isset($HTTP_POST_VARS['preview']) ? $HTTP_POST_VARS[$parameter_data['parameter_name']] : $parameter_data['parameter_value']; ! $bbcode_uid = isset($HTTP_POST_VARS['preview']) ? '' : $parameter_data['parameter_opt']; + // + // Toggles + // $bbcode_on = $board_config['allow_bbcode'] ? true : false; $html_on = $board_config['allow_html'] ? true : false; $smilies_on = $board_config['allow_smilies'] ? true : false; ! ! // ! // Instantiate the mx_text class ! // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); if ( isset($HTTP_POST_VARS['preview']) ) { ! // ! // Encode for preview ! // ! $preview_text = $mx_text->encode_preview($parameter_value); ! ! $template->assign_vars(array( ! 'TEXT' => $preview_text ! )); ! $template->assign_block_vars('preview', array()); + + // + // Decode for form editing + // + $parameter_value = $mx_text->decode($parameter_value, '', true); } else { ! // ! // Decode for form editing ! // ! $parameter_value = $mx_text->decode($parameter_value, $bbcode_uid); ! } *************** *** 248,275 **** function display_edit_CustomizedTextBlock( $block_id, $parameter_id, $parameter_data ) { ! global $template, $board_config, $db, $theme, $lang, $images, $mx_blockcp, $mx_root_path, $phpEx, $mx_table_prefix, $table_prefix, $html_entities_match, $html_entities_replace; global $HTTP_POST_VARS; ! $parameter_value = isset($HTTP_POST_VARS['preview']) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS[$parameter_data['parameter_name']]))) : $parameter_data['parameter_value']; ! // Extract customized textblock settings $bbcode_on = true? true : false; $html_on = true? true : false; $smilies_on = true? true : false; ! // Remove allowed html tags ! $html_entities_match = array(); ! $html_entities_replace = array(); ! ! $bbcode_uid = $parameter_data['parameter_opt']; if ( isset($HTTP_POST_VARS['preview']) ) { ! $this->preview($parameter_value, $html_on, $bbcode_on, $smilies_on); $template->assign_block_vars('preview', array()); } else { ! $parameter_value = $this->decode($parameter_value, $bbcode_uid); } --- 267,314 ---- function display_edit_CustomizedTextBlock( $block_id, $parameter_id, $parameter_data ) { ! global $template, $board_config, $db, $theme, $lang, $images, $mx_blockcp, $mx_root_path, $phpbb_root_path, $phpEx, $mx_table_prefix, $table_prefix, $html_entities_match, $html_entities_replace; global $HTTP_POST_VARS; ! $parameter_value = isset($HTTP_POST_VARS['preview']) ? $HTTP_POST_VARS[$parameter_data['parameter_name']] : $parameter_data['parameter_value']; ! $bbcode_uid = isset($HTTP_POST_VARS['preview']) ? '' : $parameter_data['parameter_opt']; ! // ! // Toggles ????????????????? ! // $bbcode_on = true? true : false; $html_on = true? true : false; $smilies_on = true? true : false; ! // ! // Instantiate the mx_text class ! // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); if ( isset($HTTP_POST_VARS['preview']) ) { ! // ! // Encode for preview ! // ! $preview_text = $mx_text->encode_preview($parameter_value); ! ! $template->assign_vars(array( ! 'TEXT' => $preview_text ! )); ! $template->assign_block_vars('preview', array()); + + // + // Decode for form editing + // + $parameter_value = $mx_text->decode($parameter_value, '', true); } else { ! // ! // Decode for form editing ! // ! $parameter_value = $mx_text->decode($parameter_value, $bbcode_uid); } *************** *** 365,391 **** global $HTTP_POST_VARS; ! $parameter_value = $parameter_data['parameter_value']; ! // Extract customized textblock settings $bbcode_on = false; $html_on = true; $smilies_on = false; ! // Remove allowed html tags ! $html_entities_match = array(); ! $html_entities_replace = array(); // ! // HTML, BBCode & Smilies toggle selection // ! $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; ! $bbcode_status = ( $bbcode_on ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF']; ! $smilies_status = ( $smilies_on ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF']; if ( isset($HTTP_POST_VARS['preview']) ) { ! $this->preview($parameter_value, $html_on, $bbcode_on, $smilies_on, true); $template->assign_block_vars('preview', array()); } $template->set_filenames(array( --- 404,463 ---- global $HTTP_POST_VARS; ! $parameter_value = isset($HTTP_POST_VARS['preview']) ? $HTTP_POST_VARS[$parameter_data['parameter_name']] : $parameter_data['parameter_value']; ! $bbcode_uid = isset($HTTP_POST_VARS['preview']) ? '' : $parameter_data['parameter_opt']; ! // ! // Toggles ! // $bbcode_on = false; $html_on = true; $smilies_on = false; ! // ! // Instantiate the mx_text class ! // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); // ! // Allow all html tags ! // Fix: Setting 'emtpy' enables all // ! $mx_text->allow_all_html_tags = true; if ( isset($HTTP_POST_VARS['preview']) ) { ! // ! // Encode for preview ! // ! $preview_text = $mx_text->encode_preview($parameter_value); ! ! $template->assign_vars(array( ! 'TEXT' => $preview_text ! )); ! $template->assign_block_vars('preview', array()); + + // + // Decode for form editing + // + $parameter_value = $mx_text->decode($parameter_value, '', true); } + else + { + // + // Decode for form editing + // + $parameter_value = $mx_text->decode($parameter_value, $bbcode_uid); + + } + + // + // HTML, BBCode & Smilies toggle selection + // + $html_status = ( $html_on ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF']; + $bbcode_status = ( $bbcode_on ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF']; + $smilies_status = ( $smilies_on ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF']; $template->set_filenames(array( *************** *** 401,407 **** $langcode = mx_get_langcode(); $template->assign_block_vars( "tinyMCE", array( ! 'PATH' => $mx_root_path, ! 'LANG' => !empty($langcode) ? $langcode : $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'], ! 'TEMPLATE' => $phpbb_root_path . 'templates/'. $theme['template_name'] . '/' . $theme['head_stylesheet'] )); } --- 473,479 ---- $langcode = mx_get_langcode(); $template->assign_block_vars( "tinyMCE", array( ! 'PATH' => $mx_root_path, ! 'LANG' => !empty($langcode) ? $langcode : $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'], ! 'TEMPLATE' => $phpbb_root_path . 'templates/'. $theme['template_name'] . '/' . $theme['head_stylesheet'] )); } *************** *** 415,419 **** --- 487,493 ---- 'L_PREVIEW' => $lang['Preview'], + // // To sync script and textarea select field + // 'SELECT_NAME' => $parameter_data['parameter_name'], )); *************** *** 428,495 **** $template->pparse('parameter'); } - - function decode($text = '', $bbcode_uid = '') - { - if( $bbcode_uid != '' ) - { - $text = preg_replace('/\:(([a-z0-9]:)?)' . $bbcode_uid . '/s', '', $text); - } - - $text = str_replace('<', '<', $text); - $text = str_replace('>', '>', $text); - $text = str_replace('<br />', "\n", $text); - - return $text; - } - - // =================================================== - // Preview Textblock - // =================================================== - function preview($text, $html_on, $bbcode_on, $smilies_on, $is_html_textblock = false) - { - global $board_config, $template, $lang, $html_entities_match, $html_entities_replace; - - $preview_text = $text; - - $orig_word = array(); - $replacement_word = array(); - obtain_word_list($orig_word, $replacement_word); - - if (!$is_html_textblock) - { - $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; - $preview_text = stripslashes(prepare_message(addslashes(unprepare_message($preview_text)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); - - if( $bbcode_on ) - { - $preview_text = bbencode_second_pass($preview_text, $bbcode_uid); - } - - if( count($orig_word) ) - { - $preview_text = preg_replace($orig_word, $replacement_word, $preview_text); - } - - if( $smilies_on ) - { - $preview_text = mx_smilies_pass($preview_text); - } - - $preview_text = make_clickable($preview_text); - - $preview_text = str_replace("\n", '<br />', $preview_text); - } - else - { - $preview_text = str_replace("\n", '', $preview_text); - } - - $template->assign_vars(array( - 'TEXT' => $preview_text - )); - - return $preview_text; - } - } ?> \ No newline at end of file --- 502,505 ---- |