Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
Prev Previous Post   Next Post Next
  #11  
Old 04-23-2015, 06:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
    function parse_style_attribute($tagoptions, &$prependtags, &$appendtags)
    {
        
$searchlist = array(
            array(
'tag' => 'left''option' => false'regex' => '#text-align:\s*(left);?#i'),
            array(
'tag' => 'center''option' => false'regex' => '#text-align:\s*(center);?#i'),
            array(
'tag' => 'right''option' => false'regex' => '#text-align:\s*(right);?#i'),
            array(
'tag' => 'color''option' => true'regex' => '#(?<![a-z0-9-])color:\s*([^;]+);?#i''match' => 1),
            array(
'tag' => 'font''option' => true'regex' => '#font-family:\s*(\'|)([^;,\']+)\\1[^;]*;?#i''match' => 2),
            array(
'tag' => 'b''option' => false'regex' => '#font-weight:\s*(bold);?#i'),
            array(
'tag' => 'i''option' => false'regex' => '#font-style:\s*(italic);?#i'),
            array(
'tag' => 'u''option' => false'regex' => '#text-decoration:\s*(underline);?#i'),
         array(
'tag' => 'size''option' => true'regex' => '#font-size:\s*([0-9]+px;?)#i''match' => 1)
        );

        
$style parse_wysiwyg_tag_attribute('style='$tagoptions);
        
$style preg_replace(
            
'#(?<![a-z0-9-])color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)#ie',
            
'sprintf("color: #%02X%02X%02X$4", $1, $2, $3)',
            
$style
        
);
        foreach (
$searchlist AS $searchtag)
        {
            if (!
is_bbcode_tag_allowed($searchtag['tag']))
            {
                continue;
            }
              if (
preg_match($searchtag['regex'], $style$matches))
            {
            if (
strtoupper($searchtag['tag']) == 'SIZE')
            {
               
$sizes = array('12px'=>1'15px'=>2'18px'=>3'21px'=>4'24px'=>5'27px'=>6'30px'=>7);
               if (isset(
$sizes[$matches[$searchtag['match']]]))
               {
                  
$matches[$searchtag['match']] = $sizes[$matches[$searchtag['match']]];  
               }
               else
               {
                  
$matches[$searchtag['match']] = 2;
               }
            }
            
$prependtags .= '[' strtoupper($searchtag['tag']) . iif($searchtag['option'] == true'=' $matches["$searchtag[match]"]) . ']';
            
$appendtags '[/' strtoupper($searchtag['tag']) . "]$appendtags";
            }
        }
    } 
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.
Reply With Quote
 

Thread Tools
Display Modes

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 02:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06208 seconds
  • Memory Usage 2,927KB
  • 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
  • (8)bbcode_code
  • (11)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (17)post_thanks_box
  • (1)post_thanks_box_bit
  • (17)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (17)post_thanks_postbit_info
  • (17)postbit
  • (1)postbit_attachment
  • (17)postbit_onlinestatus
  • (17)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete