Error in functions.lib.php (SVN 1555)

Posts from previous Beta sessions

Error in functions.lib.php (SVN 1555)

Postby Teta68 » Mon Jan 21, 2008 6:04 pm

While making a port for the MissingRecipes addon, I discovered a problem with the urlgrabber function in functions.lib.php.

Line 1182
Code: Select all
if( preg_match('/(?:Set-Cookie: (.+)/', $resHeader, $tmp) )

gives a warning that a ")" is missing.
After changing the line in
Code: Select all
if( preg_match('/(?:Set-Cookie: (.+))/', $resHeader, $tmp) )

the warning goes away.

Thanks to Nefuh for helping me correct it.

Teta

EDIT: added which SVN I used
Last edited by Teta68 on Mon Jan 21, 2008 6:11 pm, edited 1 time in total.
I break for giant Cyber-Hamsters.
User avatar
Teta68
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 72
Joined: Fri Jan 19, 2007 12:15 pm
Location: Sweden

Error in functions.lib.php (SVN 1555)

Postby zanix » Thu Jan 24, 2008 4:26 am

Fixed svn[1591]
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby Subxero » Sun Jan 27, 2008 8:32 pm

On functions.lib.php function "socketColorEn"
-still working or using ?
-because only take care of DE and US ?

A complete language support will be something like that
Code: Select all
/**
 * Helper function that returns the localized gem color in english
 *
 * @param string $socket_color
 * @return string $color
 */
function socketColorEn( $socket_color, $locale )
{
   global $roster;

   if( $locale == 'enUS' )
   {
      return strtolower($socket_color);
   }
   elseif( $locale == 'deDE' )
   {
      switch( trim($socket_color) )
      {
         case 'Roter':
            return 'red';
         case 'Blauer':
            return 'blue';
         case 'Gelber':
            return 'yellow';
         default:
            break;
      }
   }
   elseif( $locale == 'frFR' )
   {
      switch( trim($socket_color) )
      {
         case 'rouge':
            return 'red';
         case 'bleue':
            return 'blue';
         case 'jaune':
            return 'yellow';
         default:
            break;
      }
   }
   elseif( $locale == 'esES' )
   {
      switch( trim($socket_color) )
      {
         case 'roja':
            return 'red';
         case 'azul':
            return 'blue';
         case 'amarilla':
            return 'yellow';
         default:
            break;
      }
   }

   $colorArr = array_flip($roster->locale->wordings[$locale]['gem_colors']);
   return (string)strtolower($colorArr[$socket_color]);
}
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby zanix » Mon Jan 28, 2008 1:26 am

Naw, get rid of all that hard coded locale translation

Replace the entire function with this
Code: Select all
function socketColorEn$socket_color$locale )
{
    global 
$roster;

    
$colorArr array_flip($roster->locale->wordings[$locale]['gem_colors']);
    return (string)
strtolower($colorArr[$socket_color]);


And make sure this is correct in your locale
Line 632
Code: Select all
//Gems color Array
$lang['gem_colors'] = array( 
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby Subxero » Mon Jan 28, 2008 2:22 am

Mmmm gem_colors are for gems or for ranures ?

Because spanish its more complex than english xD
The colors have female/male translations ...

Then "red" can be "rojo" and "roja" depends of subject of phrase.
Same with yellow can be "amarillo" and "amarilla".

-On ranures "Red Socket & Yellow Socket" its "roja" and "amarilla" (Ranura roja & Ranura amarilla).
-But on gems "Matches a Red or Yellow Socket." its "rojo" and "amarillo" (Encaja en una ranura de color amarillo o rojo).

gem_colors are used on function.lib to get ranure color and on update.lib to get multicolor names of gems.

Can these array inversed and modify on both libs?

Code: Select all
$lang['gem_colors'] = array(
   'roja' => 'red',
   'rojo' => 'red',
   'azul' => 'blue',
   'amarilla' => 'yellow',
   'amarillo' => 'yellow',
   'verde' => 'green',
   'naranja' => 'orange',
   'morada' => 'purple',
   'centelleante' => 'prismatic',
   'meta' => 'meta'
   );


On array flip you get correct names for red and blue for GEMS... and normal use get correct names for ranures or gems TO english.
Last edited by Subxero on Mon Jan 28, 2008 2:49 am, edited 2 times in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby zanix » Mon Jan 28, 2008 3:44 am

The $lang['gem_colors'] array is only used in update.lib.php

This array only needs to be able to handle this part of the code

Line 1224
Code: Select all
    /**
     * Formats gem data to be inserted into the database
     *
     * @param array $gem_data
     * @param int $socket_id
     * @return array $gem if successful else returns false
     */
    
function make_gem($gem_data$socket_id)
    {
        global 
$roster;

        
$gemtt explode'<br>'$gem_data['Tooltip'] );

        if( 
$gemtt[0] !== '' )
        {
            foreach( 
$gemtt as $line )
            {
                
$colors = array();
                
$line preg_replace('/\|c[a-f0-9]{8}(.+?)\|r/i','$1',$line); // CP error? strip out color
                // -- start the parsing
                
if( eregi'\%|\+|'.$roster->locale->wordings[$this->locale]['tooltip_chance'], $line))  // if the line has a + or % or the word Chance assume it's bonus line.
                
{
                    
$gem_bonus $line;
                }
                elseif( 
preg_match$roster->locale->wordings[$this->locale]['gem_preg_meta'], $line ) )
                {
                    
$gem_color 'meta';
                }
                elseif( 
preg_match$roster->locale->wordings[$this->locale]['gem_preg_multicolor'], $line$colors ) )
                {
                    if( 
$colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['red'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['blue'] || $colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['blue'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['red'] )
                    {
                        
$gem_color 'purple';
                    }
                    elseif( 
$colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['yellow'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['red'] || $colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['red'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['yellow'] )
                    {
                        
$gem_color 'orange';
                    }
                    elseif( 
$colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['yellow'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['blue'] || $colors[1] == $roster->locale->wordings[$this->locale]['gem_colors']['blue'] && $colors[2] == $roster->locale->wordings[$this->locale]['gem_colors']['yellow'] )
                    {
                        
$gem_color 'green';
                    }
                }
                elseif( 
preg_match$roster->locale->wordings[$this->locale]['gem_preg_singlecolor'], $line$colors ) )
                {
                    
$tmp array_flip($roster->locale->wordings[$this->locale]['gem_colors']);
                    
$gem_color $tmp[$colors[1]];
                }
                elseif( 
preg_match$roster->locale->wordings[$this->locale]['gem_preg_prismatic'], $line ) )
                {
                    
$gem_color 'prismatic';
                }
            }
            
//get gemid and remove the junk
            
list($gemid) = explode(':'$gem_data['Item']);

            
$gem = array();
            
$gem['gem_name']     = $gem_data['Name'];
            
$gem['gem_tooltip'] = $this->tooltip($gem_data['Tooltip']);
            
$gem['gem_bonus']     = $gem_bonus;
            
$gem['gem_socketid']= $socket_id;  // the ID the gem holds when socketed in an item.
            
$gem['gem_id']         = $gemid// the ID of gem when not socketed.
            
$gem['gem_texture'] = $this->fix_icon($gem_data['Icon']);
            
$gem['gem_color']     = $gem_color;  //meta, prismatic, red, blue, yellow, purple, green, orange.

            
return $gem;
        }
        else
        {
            return 
false;
        }
    } 
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby Subxero » Mon Jan 28, 2008 3:51 am

Still the same problem...

Red GEM = rojo
Red SOCKET = roja
Yellow GEM = amarillo
Yellow SOCKET = amaria
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby zanix » Mon Jan 28, 2008 5:32 am

Spanish is dumb, lol

We need to figure out how to handle it
Code: Select all
//CP v2.1.1+ Gems info
//uses preg_match() to find the type and color of the gem
$lang['gem_preg_singlecolor'] = '/Matches a (\w+) Socket/';
$lang['gem_preg_multicolor'] = '/Matches a (\w+) or (\w+) Socket/';
$lang['gem_preg_meta'] = '/Only fits in a meta gem slot/';
$lang['gem_preg_prismatic'] = '/Matches a Red, Yellow or Blue Socket/';

//Gems color Array
$lang['gem_colors'] = array(
    
'red' => 'Red',
    
'blue' => 'Blue',
    
'yellow' => 'Yellow',
    
'green' => 'Green',
    
'orange' => 'Orange',
    
'purple' => 'Purple',
    
'prismatic' => 'Prismatic',
    
'meta' => 'Meta'
    
);
// -- end tooltip parsing 

All of these strings contribute to gem color matching

So only the top 4 strings need to be accounted for

Only the color names seen in these strings need to be listed and it will be ok as long we we label this section that the 'gem_colors' array should only be used for this matching

I think these strings are also only found on the gems themselves, unsocketed

Now, if both spellings are present in these strings, then we have a problem and need to rewrite this section


This line matches a meta gem
Code: Select all
elseif( preg_match$roster->locale->wordings[$this->locale]['gem_preg_meta'], $line ) ) 

'/Only fits in a meta gem slot/'



This line matches a multi color gem: such as purple, orange, and green
Code: Select all
elseif( preg_match$roster->locale->wordings[$this->locale]['gem_preg_multicolor'], $line$colors ) ) 

'/Matches a (\w+) or (\w+) Socket/'



This line matches a single color gem
Code: Select all
elseif( preg_match$roster->locale->wordings[$this->locale]['gem_preg_singlecolor'], $line$colors ) ) 

'/Matches a (\w+) Socket/



This matches a prismatic
Code: Select all
elseif( preg_match$roster->locale->wordings[$this->locale]['gem_preg_prismatic'], $line ) ) 

'/Matches a Red, Yellow or Blue Socket/'
Last edited by zanix on Mon Jan 28, 2008 5:33 am, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby PleegWat » Mon Jan 28, 2008 3:16 pm

Zanix: This is not the issue.

The issue is that gem colors and socket colors have different spelling.
I think the logical solution is having a separate translation array for sockets.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Error in functions.lib.php (SVN 1555)

Postby poetter » Tue Jan 29, 2008 8:48 pm

@devs

I had to implement a new array called gem_colors_to_en for the item parser. May be you want to use it.
Image
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg

Error in functions.lib.php (SVN 1555)

Postby Subxero » Thu Jan 31, 2008 5:33 am

As I say before ... with SVN 1614

lib/functions.lib.php
Notice line 1490: Undefined index: amarilla
Notice line 1490: Undefined index: roja

And yes "rojo" and "amarillo" its WORKING ON GEMS but not with sockets colors.

what diference its from gem_colors_to_en VS gem_colors ?

who its used on GEMS and who on SOCKETS ?

BR
Last edited by Subxero on Thu Jan 31, 2008 5:36 am, edited 1 time in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby poetter » Sat Feb 16, 2008 6:36 am

Please try out svn[1675] and let me know how its doing
Image
User avatar
poetter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 462
Joined: Sat Jun 30, 2007 9:41 pm
Location: Germany/Hamburg

Error in functions.lib.php (SVN 1555)

Postby Subxero » Sat Feb 16, 2008 7:02 pm

Now the problem its on english locale..

lib/functions.lib.php
Notice line 533: Undefined index: Red
Notice line 533: Undefined index: Yellow
Notice line 533: Undefined index: Blue
Notice line 533: Undefined index: Red
Notice line 533: Undefined index: Yellow
Notice line 533: Undefined index: Blue
Notice line 533: Undefined index: Red
Notice line 533: Undefined index: Yellow
Notice line 533: Undefined index: Blue
Notice line 533: Undefined index: Red
Notice line 533: Undefined index: Yellow

changing locale to:
Code: Select all
$lang['socket_colors_to_en'] = array(
   'Red' => 'red',
   'Blue' => 'blue',
   'Yellow' => 'yellow',
   'Meta' => 'meta',
   );

works.. but because before was lowercase ?
Last edited by Subxero on Sat Feb 16, 2008 7:09 pm, edited 1 time in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby Subxero » Sat Feb 16, 2008 7:16 pm

Another tip

Code: Select all
change:
. $roster->locale->act['socket_colors_to_en'][$matches[1]] . '.' . $roster->config['img_suffix'] . '">  ' . $matches[0];
to:
. $roster->locale->wordings[$locale]['socket_colors_to_en'][$matches[1]] . '.' . $roster->config['img_suffix'] . '" alt="'.$matches[1].'"/>  ' . $matches[0];


Because colorTooltip can be use with a specific locale.

Note: look the " alt='color' />" at end of img tag still missing! to set xhtml 1.0 compliant, because code tag not preserve the & nbsp ; ?
Last edited by Subxero on Sat Feb 16, 2008 10:51 pm, edited 5 times in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Error in functions.lib.php (SVN 1555)

Postby Subxero » Sat Feb 16, 2008 7:47 pm

Another problem

http://www.wowhead.com/?item=3474

As you can see these item can be crafted will have a "<Random enchantment>"

To take care of it:
Code: Select all
            elseif( ereg('^' . $roster->locale->wordings[$locale]['tooltip_random'], $line) )
            {
               $line = htmlspecialchars($line);
               $color = '00ff00';
            }

And add to locales
Code: Select all
$lang['tooltip_random']='<Random enchantment>';
Last edited by Subxero on Sat Feb 16, 2008 7:47 pm, edited 1 time in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Next

Return to Archived

Who is online

Users browsing this forum: No registered users and 1 guest

cron