View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01278 seconds
  • Memory Usage 1,823KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete