Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1:   // This is a roxen module. Copyright © 1996 - 2000, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.267 2001/07/08 17:03:39 nilsson Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.268 2001/07/10 18:46:18 nilsson Exp $";      #include <module.h>   inherit "module";         // ------------------- Module registration ---------------------      constant module_type = MODULE_TAG;   constant module_name = "Graphics: Graphic text";   constant module_doc =
Roxen.git/server/modules/graphics/graphic_text.pike:558: Inside #if defined(manual)
  <attr name='short'><p>    Returns a relative path to the image, i.e. a shorter one.   </p>   </attr>   <noex>"+gtextargs+"</noex>",]);   #endif         // -------------------- Image cache functions --------------------    - roxen.ImageCache image_cache; - string compat_level; + private roxen.ImageCache image_cache; + private string compat_level; + private int magic_counter;      string status() {    array s=image_cache->status();    return sprintf("<b>Images in cache:</b> %d images<br />\n"    "<b>Cache size:</b> %s",    s[0], Roxen.sizetostring(s[1]));   }      mapping(string:function) query_action_buttons() {    return ([ "Clear cache":flush_cache ]);
Roxen.git/server/modules/graphics/graphic_text.pike:584:   }      void start(int num, Configuration conf)   {    image_cache = roxen.ImageCache( "gtext", draw_callback );    roxen.dump( "etc/modules/GText.pmod" );    if(query("colorparse")) module_dependencies(conf, ({ "wiretap" }) );    compat_level = conf->query("compat_level");   }    - constant nbsp = Roxen.iso88591["&nbsp;"]; - constant replace_from = indices( Roxen.iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",}); - constant replace_to = values( Roxen.iso88591 ) + ({ nbsp, "<", ">", "&", }); + private constant nbsp = Roxen.iso88591["&nbsp;"]; + private constant replace_from = indices( Roxen.iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",}); + private constant replace_to = values( Roxen.iso88591 ) + ({ nbsp, "<", ">", "&", });      #define simplify_text( from ) replace(from,replace_from,replace_to)    - mixed draw_callback(mapping args, string text, RequestID id) + private Image.Image|mapping draw_callback(mapping args, string text, RequestID id)   {    array data;    Image.Font font;    Image.Image img;       if( objectp( text ) )    {    if( !args->text )    error("Failed miserably to find a text to draw. That's not"    " good.\n");
Roxen.git/server/modules/graphics/graphic_text.pike:767:    return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, id );    }    }    return image_cache->http_file_answer( f, id );    return 0;   }         // -------------- helpfunctions to gtext tags and containers -----------------    - constant filearg=({"background","texture","alpha","magic-texture","magic-background","magic-alpha"}); - constant textarg=({"afont", + private constant filearg = ({ +  "background", +  "texture",    "alpha", -  +  "magic-texture", +  "magic-background", +  "magic-alpha" + }); +  + private constant textarg = ({ +  "afont", +  "alpha",    "bevel",    "bgcolor",    "bgturbulence",    "black",    "bold",    "bshadow",    "chisel",    "encoding",    "fadein",    "fgcolor",
Roxen.git/server/modules/graphics/graphic_text.pike:815:    "textscale",    "verbatim",    "xpad",    "xsize",    "xspacing",    "ypad",    "ysize",    "yspacing",    "border",    -  /* generic argcache arguments */ +  // generic argcache arguments    "crop",    "format",    "quant",    "dither",    "fs",    "*-*",    "gamma", -  +    });    - constant theme=({"fgcolor","bgcolor","font"}); + private constant theme = ({ "fgcolor", "bgcolor", "font" });    - constant hreffilter=(["split":1,"magic":1,"noxml":1,"alt":1]); + private constant hreffilter = ([ "split":1, "magic":1, "noxml":1, "alt":1 ]);    - mapping mk_gtext_arg(mapping arg, RequestID id) + private mapping mk_gtext_arg(mapping arg, RequestID id)   {    mapping p=([]); //Picture rendering arguments.      #if ROXEN_COMPAT < 2.2    if(compat_level < "2.2") {    p->compat = compat_level;    p->font = m_delete(arg, "nfont");    }   #endif   
Roxen.git/server/modules/graphics/graphic_text.pike:914:    }    else {    string font = p->font;    p->font = roxen->fonts->verify_font(p->font, p->fontsize||32);    if(!p->font) RXML.parse_error("Font "+font+" could not be loaded.\n");    }       return p;   }    - string fix_text(string c, mapping m, RequestID id) { + private string fix_text(string c, mapping m, RequestID id) {       if(m->nowhitespace)    {    c=String.trim_all_whites(c);    m_delete(m, "nowhitespace");    }       m_delete(m, "noparse");    m_delete(m, "preparse");   
Roxen.git/server/modules/graphics/graphic_text.pike:991:       class Frame {    inherit RXML.Frame;       array do_return(RequestID id) {    return ({ do_gtext(args, (string) content, id) });    }    }   }    - string do_gtext(mapping arg, string c, RequestID id) + private string do_gtext(mapping arg, string c, RequestID id)   {    if((c-" ")=="") return "";       c=fix_text(c,arg,id);    mapping p=mk_gtext_arg(arg,id);       string ext="";    if(query("ext")) ext="."+(p->format || "gif");       string lp="%s", url="", ea=" ";
Roxen.git/server/modules/graphics/graphic_text.pike:1088:       string num2 = image_cache->store( ({ p, c }),id );    size = image_cache->metadata( num2, id );    if(size) {    arg->width=(string)max(arg->xsize,size->xsize);    arg->height=(string)max(arg->ysize,size->ysize);    }       if(!id->supports->images) return sprintf(lp,arg->alt);    -  string sn="gtext"+id->misc->gtext_mi++; +  string sn = "gtext" + (magic_counter++ % 65535);    if(!id->supports->js_image_object) {    return (!input)?    ("<a"+ea+"href=\""+url+"\">"+Roxen.make_tag("img",arg+(["name":sn]),xml)+"</a>"):    Roxen.make_tag("input",arg+(["type":"image"]),xml);    }       arg->name=sn;    string res="<script>\n";    if(!id->misc->gtext_magic_java) {    res += "function gtext_mo(ri,hi,txt)\n"
Roxen.git/server/modules/graphics/graphic_text.pike:1128:    "onMouseout=\"document.images['"+sn+"'].src = "+sn+"l.src;\">"    +Roxen.make_tag("img",arg,xml)+"</a>";    }       if(input)    return Roxen.make_tag("input",arg+(["type":"image"]),xml);       return sprintf(lp,Roxen.make_tag("img",arg,xml));   }    - array(string) simpletag_gh(string t, mapping m, string c, RequestID id) { + private array(string) simpletag_gh(string t, mapping m, string c, RequestID id) {    int i;    if(sscanf(t, "%s%d", t, i)==2 && i>1)    m->scale = (string)(1.0 / ((float)i*0.6));    if(!m->valign) m->valign="top";    return ({ "<p>"+do_gtext(m,c,id)+"</p><br />" });   }      class TagAnfang {    inherit RXML.Tag;    constant name = "anfang";