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

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1:   // This is a ChiliMoon module. Copyright © 1996 - 2001, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.297 2002/11/17 17:55:44 mani Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.298 2004/05/22 19:52:24 _cvs_stephen 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:30:    TYPE_INT|VAR_MORE|VAR_NOT_CFIF,    "Per default, it will not be possible to render texts longer than "    "this. This is a safeguard so that a simple RXML error doesn't "    "cause a huge image to be generated. It can be turned of at a per "    "tag bases, with the <i>maxlen</i> attribute.");       defvar("ext", 0, "Append format to generated images",    TYPE_FLAG|VAR_MORE|VAR_NOT_CFIF,    "Append the image format (.gif, .png, .jpg, etc) to the generated "    "images. This is not necessary, but might seem nicer."); +  defvar("honor_supports", 1, "Honor supports", +  TYPE_FLAG|VAR_MORE, +  "Normally javascript tags generated by the 'magic' attribute are not " +  "sent to clients that don't support javascript image objects. " +  "This check can be disabled to always output those javascript tags.");   }      TAGDOCUMENTATION;   #ifdef manual   constant gtextargs=#"   <attr name='verbatim'><p>    By default the gtext tag will try to make typographical enhancements to the    text to make the resulting image as eye pleasing as possible. If you want to    turn this feature off, add this attribute to the tag.</p>   </attr>
Roxen.git/server/modules/graphics/graphic_text.pike:555: Inside #if defined(manual)
  </p>   </attr>   <noex>"+gtextargs+"</noex>",]);   #endif         // -------------------- Image cache functions --------------------      private roxen.ImageCache image_cache;   private string compat_level; + private int honor_supports;      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], String.int2size(s[1]));   }      mapping(string:function) query_action_buttons() {    return ([ "Clear cache":flush_cache ]);
Roxen.git/server/modules/graphics/graphic_text.pike:577:   void flush_cache() {    image_cache->flush();   }      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"); +  honor_supports = query("honor_supports");   }      private constant nbsp = Roxen.iso88591["&nbsp;"];      private Image.Image|mapping draw_callback(mapping args, string text, RequestID id)   {    array data;    Image.Font font;    Image.Image img;   
Roxen.git/server/modules/graphics/graphic_text.pike:1049:    if(!has_value(arg[name], "\"")) ea+="\""+arg[name]+"\" ";    else if(!has_value(arg[name], "'")) ea+="'"+arg[name]+"' ";    else ea+="\""+replace(arg[name], "'", "&#39;")+"\" ";    m_delete(arg, name);    }       int xml=!m_delete(arg, "noxml");       if(!arg->border) arg->border="0";    +  int no_draw = !id->misc->generate_images;    if(arg->split)    {    string res="",split=arg->split;    if(lower_case(split)=="split") split=" ";    m_delete(arg,"split");    c=replace(c, "\n", " ");    int setalt=!arg->alt;    foreach(c/split-({""}), string word)    {    string fn = image_cache->store( ({ p, word }),id ); -  mapping size = image_cache->metadata( fn, id, 1 ); +  mapping size = image_cache->metadata( fn, id, no_draw);    if(setalt) arg->alt=word;    arg->src=query_absolute_internal_location(id)+fn+ext;    if( size )    {    arg->width = (string)size->xsize;    arg->height = (string)size->ysize;    }    else {    m_delete (arg, "width");    m_delete (arg, "height");    }    res+=Roxen.make_tag( "img", arg, xml )+" ";    }    return sprintf(lp,res);    }       string num = image_cache->store( ({ p, c }), id ); -  mapping size = image_cache->metadata( num, id, 1 ); +  mapping size = image_cache->metadata( num, id, no_draw );    if(!arg->alt) arg->alt=replace(c,"\"","'");       arg->src=query_absolute_internal_location(id)+num+ext;    if(size) {    arg->width=(string)size->xsize;    arg->height=(string)size->ysize;    }       if(arg->magic)    {
Roxen.git/server/modules/graphics/graphic_text.pike:1107:    id->misc->defines->alink||"#ff0000";       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);    }       string sn = "gtext" + id->root_id->misc->gtext_mi++; -  if(!id->supports->js_image_object) { +  RXML_CONTEXT->set_root_id_misc("gtext_mi", id->root_id->misc->gtext_mi); +  +  if(honor_supports && !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 type='text/javascript'>\n";    if(!id->root_id->misc->gtext_magic_java) {    res += "function gtext_mo(ri,hi,txt)\n"    "{\n"