# =========================
sub handleDrawing
{
    my( $attributes ) = @_;
    my $nameVal = extractNameValuePair( $attributes );
    if( ! $nameVal ) {
        $nameVal = "untitled";
    }
    $nameVal =~ s/[^A-Za-z0-9_\.\-]//go; # delete special characters
    return "<a href=\"%SCRIPTURLPATH%/oops%SCRIPTSUFFIX%/%WEB%/%TOPIC%?template=oopstwikidraw\&param1=$nameVal\" onMouseOver=\"window.status='Edit drawing [$nameVal] using TWiki Draw applet (requires a Java 1.1 enabled browser)'; return true;\" onMouseOut=\"window.status=''; return true;\"><img src=\"%ATTACHURLPATH%/$nameVal.gif\" alt=\"Edit drawing '$nameVal' (requires a Java enabled browser)\"></a>";
}


# =========================
sub extendHandleCommonTags
{
    # This is the place to define customized tags and variables
    # Called by sub handleCommonTags, after %INCLUDE:"..."%

    my( $text, $topic ) = @_;

    # for compatibility for earlier TWiki versions:
    $text=~ s/%INCLUDE:"(.*?)"%/&handleIncludeFile($1)/geo;
    $text=~ s/%INCLUDE:"(.*?)"%/&handleIncludeFile($1)/geo;  # allow two level includes

    # do custom extension rule, like for example:
    # $text=~ s/%WIKIWEB%/$wikiToolName.$webName/go;

    # TWikiDraw rule: Change %DRAWING{"name"}% to applet
    $text =~ s/%DRAWING{(.*?)}%/&handleDrawing($1)/geo;
    $text =~ s/%DRAWING%/&handleDrawing("untitled")/geo;

    return $text;
}
