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.229 2000/05/03 14:48:31 nilsson Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.230 2000/06/03 04:10:56 nilsson Exp $";      #include <module.h>   inherit "module"; - inherit "roxenlib"; +          // ------------------- Module registration ---------------------      constant module_type = MODULE_PARSER;   constant module_name = "Graphic text";   constant module_doc =   #"Provides the <tt>&lt;gtext&gt;&lt;/gtext&gt;</tt> tag that is used   to generate text into graphical images.";   constant thread_safe = 1;
Roxen.git/server/modules/graphics/graphic_text.pike:425: Inside #if defined(manual)
   will highlight the image when the mouse is moved over it. The message    is shown in the browser's status bar.    <ex type=vert>   <gtext href=\"http://www.roxen.com\" magic=\"Roxen\">www.roxen.com</gtext>    </ex>   </attr>      <attr name=magic-attribute value=value> Same as for any    <tag>gtext</tag> attribute, except for the highlighted image.    <ex type=vert> - <gtext fgcolor=\"blue\" magic-glow=\"yellow\" magic=\"\">Magic_attribute</gtext> + <gtext fgcolor=\"blue\" magic-glow=\"yellow\" magic=\"\">Magic attribute</gtext>    </ex>   </attr>      <attr name=noxml>    Do not terminate the image tag with \"/\".   </attr>      <attr name=split>    <gtext scale=0.4 split>Make each word into a separate gif image.    Useful if you are writing a large text, and word wrap at the edges of
Roxen.git/server/modules/graphics/graphic_text.pike:484:   <noex>"+gtextargs+"</noex>",]);   #endif         // -------------------- Image cache functions --------------------      roxen.ImageCache image_cache;      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]/2, sizetostring(s[1])); +  return sprintf("<b>Images in cache:</b> %d images<br />\n<b>Cache size:</b> %s", +  s[0]/2, Roxen.sizetostring(s[1]));   }      mapping(string:function) query_action_buttons() { -  return ([ "Clear cache":image_cache->flush ]); +  return ([ "Clear cache":flush_cache ]);   }    -  + 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" }) );   }    - constant nbsp = iso88591["&nbsp;"]; - constant replace_from = indices( iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",}); - constant replace_to = values( iso88591 ) + ({ nbsp, "<", ">", "&", }); + constant nbsp = Roxen.iso88591["&nbsp;"]; + constant replace_from = indices( Roxen.iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",}); + 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)   {    array data;    Image.Font font;    Image.Image img;       if( objectp( text ) )
Roxen.git/server/modules/graphics/graphic_text.pike:741:   {    mapping p=([]); //Picture rendering arguments.       m_delete(arg,"src");    m_delete(arg,"width");    m_delete(arg,"height");       foreach(filearg, string tmp)    if(arg[tmp])    { -  p[tmp]=fix_relative(arg[tmp],id); +  p[tmp]=Roxen.fix_relative(arg[tmp],id);    m_delete(arg,tmp);    }      // if(arg->border && (search(arg->border,",")!=-1))   // {   // p->border=arg->border;   // m_delete(arg,"border");   // }       array i = indices( arg );
Roxen.git/server/modules/graphics/graphic_text.pike:790:       if(m->nowhitespace)    {    c=String.trim_all_whites(c);    m_delete(m, "nowhitespace");    }       m_delete(m, "noparse");    m_delete(m, "preparse");    -  c=replace(c, replace_entities+({" "," ", "\n\n\n", "\n\n", "\r"}), -  replace_values+({" ", " ", "\n", "\n", ""})); +  c=replace(c, Roxen.replace_entities+({" "," ", "\n\n\n", "\n\n", "\r"}), +  Roxen.replace_values+({" ", " ", "\n", "\n", ""}));       if(m->maxlen) {    c = c[..(((int)m->maxlen||QUERY(deflen))-1)];    m_delete(m, "maxlen");    }       return c;   }      
Roxen.git/server/modules/graphics/graphic_text.pike:845:    int input=0;    if(arg->submit)    {    input=1;    m_delete(arg,"submit");    }       if(arg->href)    {    url = arg->href; -  lp = replace(make_tag("a",arg-hreffilter),"%","%%")+"%s</a>"; +  lp = replace(Roxen.make_tag("a",arg-hreffilter),"%","%%")+"%s</a>";    if(!p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";    m_delete(arg, "href");    }       if(!arg->noxml) { arg["/"]="/"; m_delete(arg, "noxml"); }    if(!arg->border) arg->border=arg->border||"0";       if(arg->split)    {    string res="",split=arg->split;
Roxen.git/server/modules/graphics/graphic_text.pike:871:    {    string fn = image_cache->store( ({ p, word }),id );    mapping size = image_cache->metadata( fn, id, 1 );    if(setalt) arg->alt=word;    arg->src=query_internal_location()+fn+ext;    if( size )    {    arg->width = (string)size->xsize;    arg->height = (string)size->ysize;    } -  res+=make_tag( "img", arg )+" "; +  res+=Roxen.make_tag( "img", arg )+" ";    }    return sprintf(lp,res);    }       string num = image_cache->store( ({ p, c }), id );    mapping size = image_cache->metadata( num, id, 1 );    if(!arg->alt) arg->alt=replace(c,"\"","'");       arg->src=query_internal_location()+num+ext;    if(size) {
Roxen.git/server/modules/graphics/graphic_text.pike:915:    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="i"+id->misc->gtext_mi++;    if(!id->supports->js_image_object) {    return (!input)? -  ("<a "+ea+"href=\""+url+"\">"+make_tag("img",arg+(["name":sn]))+"</a>"): -  make_tag("input",arg+(["type":"image"])); +  ("<a "+ea+"href=\""+url+"\">"+Roxen.make_tag("img",arg+(["name":sn]))+"</a>"): +  Roxen.make_tag("input",arg+(["type":"image"]));    }       arg->name=sn;    string res="\n<script>\n";    if(!id->misc->gtext_magic_java) {    res += "function i(ri,hi,txt)\n"    "{\n"    " document.images[ri].src = hi.src;\n"    " if( txt != 0 )\n"    " setTimeout(\"top.window.status = '\"+txt+\"'\", 100);\n"
Roxen.git/server/modules/graphics/graphic_text.pike:942:    res+    " "+sn+"l = new Image("+arg->width+", "+arg->height+");"+sn+"l.src = \""+arg->src+"\";\n"    " "+sn+"h = new Image("+arg->width+", "+arg->height+");"+sn+"h.src = \""+query_internal_location()+num2+ext+"\";\n"    "</script>\n"+    "<a "+ea+"href=\""+url+"\" "+    (input?"onClick='document.forms[0].submit();' ":"")    +"onMouseover=\"i('"+sn+"',"+sn+"h,"+((strlen(magic) && magic != "magic")?    "'"+replace(magic,"'","`")+"'":    "0")+"); return true;\" "    "onMouseout=\"document.images['"+sn+"'].src = "+sn+"l.src;\">" -  +make_tag("img",arg)+"</a>"; +  +Roxen.make_tag("img",arg)+"</a>";    }       if(input) -  return make_tag("input",arg+(["type":"image"])); +  return Roxen.make_tag("input",arg+(["type":"image"]));    -  return sprintf(lp,make_tag("img",arg)); +  return sprintf(lp,Roxen.make_tag("img",arg));   }      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>"+simpletag_gtext("",m,c,id)+"</p><br />" });   }