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 - 2009, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.307 2009/05/07 14:15:54 mast Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.308 2009/11/24 15:17:33 grubba 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:770:   }      mapping find_internal(string f, RequestID id)   {    if( strlen(f)>4 && query("ext") && f[-4]=='.') // Remove .ext    f = f[..strlen(f)-5];    if( strlen(f) && f[0]=='$' )    {    array id_text = f/"/";    if( sizeof(id_text)==2 ) -  { // It's a gtext-id -  string second_key = roxen->argcache->store( (["":id_text[1]]) ); -  return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, id ); +  { // It's a gtext-id, let it live for an hour. +  string second_key = roxen->argcache->store( (["":id_text[1]]), 3600 ); +  return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, +  id, UNDEFINED, 3600 );    }    }    return image_cache->http_file_answer( f, id );   }         // -------------- helpfunctions to gtext tags and containers -----------------      private constant filearg = ({    "background",
Roxen.git/server/modules/graphics/graphic_text.pike:1039:    constant flags = RXML.FLAG_DONT_REPORT_ERRORS;       class Frame {    inherit RXML.Frame;    array do_return(RequestID id) {    content=fix_text(content||"",args,id);    mapping p=mk_gtext_arg(args,id);    if(args->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";    string ext="";    if(query("ext")) ext="."+(p->format || "gif"); +  int timeout = UNDEFINED; +  if (args["unix-time"]) { +  timeout = (int)args["unix-time"] - time(1); +  } +  timeout = Roxen.time_dequantifier(args, timeout);    if(!args->short)    return ({ query_absolute_internal_location(id) + -  image_cache->store( ({p,content}), id )+ext }); -  return ({ "+"+image_cache->store( ({p,content}), id )+ext }); +  image_cache->store( ({p,content}), id, timeout )+ext }); +  return ({ "+"+image_cache->store( ({p,content}), id, timeout )+ext });    }    }   }      class TagGTextJS {    inherit RXML.Tag;    constant name = "gtext-js";    constant flags = RXML.FLAG_EMPTY_ELEMENT;       class Frame {
Roxen.git/server/modules/graphics/graphic_text.pike:1072:    inherit RXML.Tag;    constant name = "gtext-id";    constant flags = RXML.FLAG_EMPTY_ELEMENT;       class Frame {    inherit RXML.Frame;       array do_return(RequestID id) {    mapping p=mk_gtext_arg(args,id);    if(args->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff"; +  int timeout = UNDEFINED; +  if (args["unix-time"]) { +  timeout = (int)args["unix-time"] - time(1); +  } +  timeout = Roxen.time_dequantifier(args, timeout);    if(!args->short)    return ({ query_absolute_internal_location(id) + -  "$"+image_cache->store(p, id)+"/" }); -  return ({ "+"+image_cache->store(p, id )+"/foo" }); +  "$"+image_cache->store(p, id, timeout)+"/" }); +  return ({ "+"+image_cache->store(p, id, timeout)+"/foo" });    }    }   }      class TagGText {    inherit RXML.Tag;    constant name = "gtext";    constant flags = RXML.FLAG_DONT_REPORT_ERRORS;       class Frame {
Roxen.git/server/modules/graphics/graphic_text.pike:1158:    m_delete(arg, name);    }       int xml=!m_delete(arg, "noxml");       // No border should be used for <img>. Force CSS declaration to avoid    // borders when gtext is clickable.    m_delete(arg, "border");    arg->style = "border: none;" + (arg->style || "");    +  int timeout = UNDEFINED; +  if (arg["unix-time"]) { +  timeout = (int)arg["unix-time"] - time(1); +  } +  timeout = Roxen.time_dequantifier(arg, timeout); +  if (!zero_type(timeout)) { +  // Clean up the args mapping. +  foreach(({ "unix-time", "seconds", "minutes", "beats", "hours", +  "days", "weeks", "months", "years" }), string a) { +  m_delete(arg, a); +  } +  // Make sure the timeout is positive (and reasonable). +  if (timeout < 60) timeout = 60; +  }    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 ); +  string fn = image_cache->store( ({ p, word }), id, timeout );    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 ); +  string num = image_cache->store( ({ p, c }), id, timeout );    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:1209:       if(p->bevel) p->pressed=1;       m_delete(p, "fgcolor");    foreach(glob("magic-*", indices(arg)), string q)    p[q[6..]]=m_delete(arg, q);       if(!p->fgcolor) p->fgcolor=id->misc->defines->theme_alink||    id->misc->defines->alink||"#ff0000";    -  string num2 = image_cache->store( ({ p, c }),id ); +  string num2 = image_cache->store( ({ p, c }), id, timeout );    size = image_cache->metadata( num2, id );    if(size) {    arg->width=(string)max(arg->xsize,size->xsize);    arg->height=(string)max(arg->ysize,size->ysize);    }      #ifdef GTEXT_RANDOM_PREFIX    string sn = "gtext" + get_gtext_pfx(id) + id->root_id->misc->gtext_mi++;   #else    string sn = "gtext" + id->root_id->misc->gtext_mi++;