Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-04-2012, 10:55 AM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to make the CKeditor return BBCODE and count caracters

Edit because i said some wrong things :

So here is how to get a message from the ckeditor, convert it from html to bbcode, and count caracters in the message without bbcode :

PHP Code:
    require_once(DIR '/includes/class_wysiwygparser.php');
    
$html_parser = new vB_WysiwygHtmlParser($vbulletin);
    
$contenu $html_parser->parse_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], FALSE);

    require_once(
'includes/class_bbcode_alt.php');
    
$bbcodeparser_plain = new vB_BbCodeParser_PlainText($vbulletinfetch_tag_list());
    
$message_plain $bbcodeparser_plain->do_parse($contenu);
    
    
$count vbstrlen($message_plain);
    if(
$count $maximum){
        
//Is too big
    

Reply With Quote
  #2  
Old 07-04-2012, 11:22 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's what I would have suggested - can you give us a sample of bbcde that results in html?
Reply With Quote
  #3  
Old 07-04-2012, 12:20 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm i should be a little bit stupid, i wanted to answer "Yes" to you but during test to be sure i can see my editor return directly html, no bbcode, that's why the PlainText parser does nothing.
I don't understand, my editor returned BBcode yesterday

So that's not really the thread, but maybe you could tell me how to construct an edit which return bbcode and not HTML ?
I actually do this :
PHP Code:
$editorid construct_edit_toolbar('',FALSE,'nonforum',FALSE,FALSEFALSE'fe'); 
Reply With Quote
  #4  
Old 07-04-2012, 01:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, the editor has a button in the upper left corner that sort of looks like "A/A", that toggles wysiwyg mode, and I think you get either html or bbcode depending on how that is set. I don't know a lot about the editor so I don't know how to tell you to force a certain mode, but looking at newreply.php, it does this (after "cleaning" the wysiwyg parameter):

Code:
	if ($vbulletin->GPC['wysiwyg'])
	{
		require_once(DIR . '/includes/class_wysiwygparser.php');
		$html_parser = new vB_WysiwygHtmlParser($vbulletin);
		$newpost['message'] = $html_parser->parse_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $foruminfo['allowhtml']);
	}
	else
	{
		$newpost['message'] = $vbulletin->GPC['message'];
	}
Reply With Quote
  #5  
Old 07-04-2012, 01:48 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for help,

About the "A/a" button : in every case it's bbcode which is shown, but $vbulletin->GPC['message'] returns html.

Thank you for the parse_wysiwyg_html_to_bbcode, it works as expected (and the PlainText parser too)

But there should be an other way to make the ckeditor return bbcode and not HTML : i did it yesterday but i don't know how

Thank you !
Reply With Quote
  #6  
Old 07-04-2012, 05:23 PM
Badshah93 Badshah93 is offline
 
Join Date: Jun 2010
Location: India
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Create New Plugin

Hook: newpost_process
Code:

Code:
if ($type == 'thread') 
{
   $temp_msg = strip_bbcode($post['message']);
   $count = vbstrlen($temp_msg);
}
Reply With Quote
  #7  
Old 08-16-2012, 11:58 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am looking for a plugin to convert HTML posts to BBCode posts and came across this thread but I'm not sure I understand what you guys here are trying to do.

In particular, is the first post supposed to be a plugin or a separate PHP file? And what is the plugin in post #6 doing?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:18 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08728 seconds
  • Memory Usage 2,225KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete