Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 13 May 2012, 13:16
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Real name: Milk Pink
bbcode font-size semantics

Currently vb uses <font> for bbcode font-size and so I'm trying to replace it with <span>

So far I've edited class_bbcode.php
Example (color):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and output seems fine except for font-size ...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

as it calls the old <font> sizes 1 - 7

so my question is where can I find where to change "default" font sizes 1 - 7 to say 10 - 20 (px)?
Reply With Quote
  #2  
Old 14 May 2012, 11:52
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Someone asked that question on stackoverflow: http://stackoverflow.com/questions/8...-size-10-to-px . Someone there came up with a conversion to ems.
Reply With Quote
  #3  
Old 14 May 2012, 13:11
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Real name: Milk Pink
Thanks but that's not what I mean, converting sizes to Points/Pixels/Ems is the easy part, I'm needing to change how vbulletin converts the members bbcode choice:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Rather than:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now one way I guess would be to add a "1" before the replace var turning 1 into 11, 2 into 12 etc etc

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


..but I would still like to know where in vbulletin the font-size function, CSS or whatever is allowing me to choose specifically which font sizes I wish whether it be within a template or php file as I can't find where myself.

Last edited by PinkMilk; 14 May 2012 at 13:18.
Reply With Quote
  #4  
Old 14 May 2012, 15:48
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, OK. I think what you can do is change that code to use a callback like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Then write a function called handle_bbcode_size that takes the size number 1-7 as a parameter and returns the replacment html. That way you can write whatever php you want to do the conversion. (Edit: I think the function actually takes two parameters, the text between the tags and the font size number).

BTW, I haven't tried it, and looking at the other tags that have a callback I notice none of them have an option_regex so I don't know if that works with a callback or not.

Last edited by kh99; 14 May 2012 at 16:24.
Reply With Quote
  #5  
Old 15 Apr 2015, 06:38
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Hello... Can you please help me on this? How can i use %2$s and %1$s in the sample function below?

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #6  
Old 17 Apr 2015, 04:04
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Can you please say if it is possible or not please?
Reply With Quote
  #7  
Old 17 Apr 2015, 11:54
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Well, I never did actually try it, as I mentioned above. But did you make the change to $tag_list that I posted above? It's in includes/class_bbcode.php. And the handle_bbcode_size function should go in there too, somewhere before the final } so that it's part of the class.
Reply With Quote
  #8  
Old 23 Apr 2015, 05:33
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It's working But there is another problem now.

I enter some text in WYSIWYG text area and select the text, then i pick a size like 5.

It changes the font size perfectly. (in the page source code it still says <font*)

I click the preview button (in newreply), the page reloads and it still displays font size as "5".

I check the page source code both in the preview table cell and WYSIWYG text area and they both display "<span style***" which is correct.

I click the preview button once again and this time i notice the text's font size is converted to default size and the size tag is completely removed.

Then I opened vbulletin_textedit.js and changed the line below:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It didn't work. Something is still adding "<font size" tag...
Reply With Quote
  #9  
Old 23 Apr 2015, 11:53
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, right, I forgot about the fact that it has to be able to go back and forth between bbcode and html. There's a file includes/class_wysiwygparser.php that goes from html to bbcode, and it uses the <font> tag instead of the font-size attribute. So you could either change your replacement to use the font tag (which I know isn't the way it's done these days), or else figure out how to change the code in class_wysiwygparser.php. I only glanced at it, but there's a function parse_style_attribute(), and it currently doesn't parse out the font size. You might be able to add a line to the $searchlist array to make it find the font size and insert a size tag for it. Probably something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then you'd also need code to convert the matched text to your font number. If this isn't something you can do, I'll give it a try later.
Reply With Quote
  #10  
Old 23 Apr 2015, 12:42
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Originally Posted by kh99 View Post
Oh, right, I forgot about the fact that it has to be able to go back and forth between bbcode and html. There's a file includes/class_wysiwygparser.php that goes from html to bbcode, and it uses the <font> tag instead of the font-size attribute. So you could either change your replacement to use the font tag (which I know isn't the way it's done these days), or else figure out how to change the code in class_wysiwygparser.php. I only glanced at it, but there's a function parse_style_attribute(), and it currently doesn't parse out the font size. You might be able to add a line to the $searchlist array to make it find the font size and insert a size tag for it. Probably something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then you'd also need code to convert the matched text to your font number. If this isn't something you can do, I'll give it a try later.
It's beyond my knowledge Thank you for your time! I'll be waiting.

--------------- Added 23 Apr 2015 at 15:47 ---------------

Btw, my vb version is 3.8.8 and i don't see a file named class_wysiwygparser.php. Maybe it's a vb 4.x file? There is file named functions_wysiwyg.php though.



Is this the related section?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by NeutralizeR; 23 Apr 2015 at 12:50.
Reply With Quote
  #11  
Old 23 Apr 2015, 20:39
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Yeah, I forgot that you were using vb3, but they just changed the functions into a class, so it's pretty much the same thing. Here's the modified parse_style_attribute function I came up with:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It replaces the existing function (which I think is somewhere below the code you posted). I actually tried it on vb4, but I looked at the vb3 function and made a couple changes, so I think it might work (or if not, it's close).

Unfortunately, what doesn't work right is the font dropdown in the editor (at least in vb4). You can use the menu to set the size of selected text, but it won't showthe size of selected text or let you change the size if text already has a size (I think probably because it doesn't recognize the <span... way of doing it, so it just tries to add another on the outside, which does nothing). I don't know what to do about hat, or whether it needs to be fixed in js somewhere, but I don't have time to look at that. (Maybe it will work in vb3, or at least be an easier problem to fix).

Edit: No, same problem in vb3. But you've already looked at the js so maybe you have a head start. It looks like color, font, bold, italics, etc are done with attributes, so maybe you can find where those are handled and add font-size like we did in the php. I think the goal of the Op was to change the sizes associated with the numbers, so if that's true you might be able to go back to using <font> and get everything to work just using the changes to the tag list, but maybe you have a different goal.

Last edited by kh99; 23 Apr 2015 at 21:06.
Reply With Quote
  #12  
Old 25 Apr 2015, 09:18
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Thank you for your reply. It's working, but as you stated, dropdown problem and extra spans make it unusable at the moment. I'm still searching for the source of <font size="x"> tags (they are added when you select a text and choose a size for the first time, a refresh converts them to span).

I attached my uncompressed vbulletin_textedit.js. Two instances of font tags are converted to span and i really can't find where else <font size and <font face tags are generated.

I also noticed that <font face, <font color and <font size tags are merged into one tag like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I guess I'll need a span replacement, too.
Attached Files
File Type: txt vbulletin_textedit.txt (85.7 KB, 5 views)
Reply With Quote
  #13  
Old 25 Apr 2015, 11:43
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I think for the ckeditor it might be in clientscript\ckeplugins\enhancedsourcearea\plugin.js, but I'm not sure if that file is used directly, because I seem to remember that all the ckeditor plugins are combined into one file. But I tried to search for a section of the code and it was only found once, so I could be wrong about that. I suppose I should just try changing something in that file and see if it has any effect.
Reply With Quote
  #14  
Old 25 Apr 2015, 13:09
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
vBulletin 3 does not have a clientscript\ckeplugins\ folder It's really weird. I can't figure out what else building the WYSIWYG editor. I made a mass search in all *.js and *.php files but could not find any other <font tags.
Reply With Quote
  #15  
Old 25 Apr 2015, 13:20
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by NeutralizeR View Post
vBulletin 3 does not have a clientscript\ckeplugins\ folder It's really weird. I can't figure out what else building the WYSIWYG editor. I made a mass search in all *.js and *.php files but could not find any other <font tags.
Oops, of course you're right. Then it looks like you must be looking in the right place. Maybe I'll look a little if I get a chance later (although I don't know anything about how the editor works).
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 07:42.

Layout Options | Width: Wide Color: