News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Soporte enlaces ED2K para SMF 2RC3 y 2RC4

Started by EgAr, September 26, 2010, 09:20:57 PM

Previous topic - Next topic

EgAr

Existen 2 MODs para soporte de enlaces ed2k, pero son para SMF 1.1.X.  Basandome en lo que hizo lucas-ruroken en este tema, adapté para RC3 y RC4 el siguiente MOD:
http://custom.simplemachines.org/mods/index.php?mod=716
Todos los creditos son del autor del mod: tFF

(me gusta mas este mod porque permite el uso de BBC)



en ./Sources/Subs.php

buscar:
// Parse bulletin board code in a string, as well as smileys optionally.

Agregar antes:
// tFF - ed2k
function ed2k_readableSize ($ed2k_link) {
    preg_match('~(\s|^)(ed2k://\|file\|.+?\|(.+?)\|.+?)(\s|$)~i', $ed2k_link, $matches);
    $size=$matches[3];

    $loop    = 0;
    $suffix = array ("Bytes","KBytes","MBytes","GBytes","TBytes");    //TeraByte is max possible
    while ( ($size > 1024) && ($loop < 4) ) {    //loop shouldn't be > 4 so the TB is max
        $loop++;
        $size /= 1024;
    }
    return round($size, 2) . " " . $suffix[$loop];
}
// /tFF - ed2k



buscar:
            array(
                'tag' => 'email',
                'type' => 'unparsed_content',


agregar antes:
// tFF - ed2k
            array(
                'tag' => 'ed2k',           
                'type' => 'unparsed_content',
                'content' => '<img src="__ed2k_ico__" alt="ed2k: __ed2k_size__" title="ed2k: __ed2k_size__" />&nbsp;<a href="$1">__ed2k_name__</a>',
                'validate' => create_function('&$tag, &$data, $disabled', '
                        global $settings;
                        $humanSize = ed2k_readableSize($data);
                        $data = strtr($data, array(\'<br />\' => \'\', \' \' => \'\', \'&nbsp;\' => \'\'));
                        $ed2k_name = preg_replace(\'~(\s|^)(ed2k://\|file\|(.+?)\|.+?)(\s|$)~i\', \'$3\', $data );
                        $ed2k_ico = $settings[\'images_url\'] . \'/bbc/\' . \'ed2k.gif\';
                        $tag[\'content\'] = strtr($tag[\'content\'], array(\'__ed2k_name__\' => $ed2k_name, \'__ed2k_ico__\' => $ed2k_ico, \'__ed2k_size__\' => $humanSize));
                    '),
            ),
            array(
                'tag' => 'ed2k',
                'type' => 'unparsed_equals',
                'before' => '<img src="__ed2k_ico__" alt="ed2k: __ed2k_size__" title="ed2k: __ed2k_size__" />&nbsp;<a href="$1">',
                'after' => '</a>',
                'validate' => create_function('&$tag, &$data, $disabled', '
                        global $settings;
                        $humanSize = ed2k_readableSize($data);
                        $data = strtr($data, array(\'<br />\' => \'\', \' \' => \'\', \'&nbsp;\' => \'\'));
                        $ed2k_ico = $settings[\'images_url\'] . \'/bbc/\' . \'ed2k.gif\';
                        $tag[\'before\'] = strtr($tag[\'before\'], array(\'__ed2k_ico__\' => $ed2k_ico, \'__ed2k_size__\' => $humanSize));
                    '),
                'disabled_after' => ' ($1)',
            ),
// /tFF - ed2k



buscar:
        // Inside these tags autolink is not recommendable.
        $no_autolink_tags = array(


Agregar despues:
// tFF - ed2k
            'ed2k',
// /tFF - ed2k



Buscar:
        // Links are useless on paper... just show the link.
        $disabled['ftp'] = true;
        $disabled['url'] = true;
        $disabled['iurl'] = true;
        $disabled['email'] = true;
        $disabled['flash'] = true;


agregar despues:
// tFF - ed2k
        $disabled['ed2k'] = true;
// /tFF - ed2k




Buscar:
                }
            }

            $data = strtr($data, array("\t" => '&nbsp;&nbsp;&nbsp;'));

            if (!empty($modSettings['fixLongWords']) && $modSettings['fixLongWords'] > 5)


Agregar antes:
// tFF - ed2k
                    // eDonkey links then...
                    if (!isset($disabled['ed2k']) && strpos($data, 'ed2k://') !== false)
                    {
                        $data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);
                    }
// /tFF - ed2k




en ./Sources/Subs-Editor.php

Buscar:
            array(
                'image' => 'ftp',
                'code' => 'ftp',
                'before' => '[ftp]',
                'after' => '[/ftp]',
                'description' => $txt['ftp']
            ),
            array(),


agregar despues:
            array(
                'image' => 'ed2k',
                'code' => 'ed2k',
                'before' => '[ed2k]',
                'after' => '[/ed2k]',
                'description' => 'eMule'
            ),
            array(),




ademas copiar el archivo "ed2k.gif" a :

/themes/TU-THEME/images/bbc



Repito, todos los creditos son del autor del mod: tFF

Saludos.

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!


●[¤«HuGo»¤]●

Muy bueno egar, ese es el espiritu de compartir :) xD

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!

EgAr


polowest

#6
Hi,
exist a modification add all link with one button?

_-Caleb-_

Buenas :)

Me acabo de registrar en el foro (Cosa que debería haber hecho hace algún tiempo) y he decidido reflotar este hilo (Lo siento) ya que es el único que habla del tema de los enlaces ed2k...

He seguido el tutorial que pone Egar en el primer mensaje sin problemas y acepta los elinks (Esto es en la versión 2.0.2 de smf, pero tengo algunos problemillas derivados de esto:


  • No me deja usar el tag [ed2k=elink]descripción[/ed2k] me falla y no se muestra como es debido, haciendo el elink inutilizable
  • No sustituye los caracteres especiales (Por ejemplo %20 por espacio) con lo que quedan, muchas veces enlaces ilegibles.

Bueno esa es mi lista de problemas, a ver si alguien se pasa por aquí y me puede ayudar, como he dicho antes, siento el reflote.

Saludos!

Advertisement: