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 - 2004, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.305 2008/08/14 09:41:27 erik Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.306 2009/04/29 15:16:49 jonasw 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:697:    lower_case(args->talign||"left"),    xpad,    ypad);    }       if (!font)    error("gtext: No font (tried "+    (args->afont||args->font||args->nfont)+ ")!\n");       // Fonts and such are now initialized. -  [img, Image.Image alpha] = GText.make_text_image(args, font, text, id); +  array|mapping make_res = GText.make_text_image(args, font, text, id); +  if (mappingp(make_res)) +  return make_res; +  [img, Image.Image alpha] = make_res;       // Now we have the image in 'img'.       if( !args->scroll && !args->fadein )    {    if(!args->notrans)    {    return ([ "img":img, "alpha":alpha ]);    }    return img;
Roxen.git/server/modules/graphics/graphic_text.pike:773:    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 );    }    }    return image_cache->http_file_answer( f, id ); -  return 0; +    }         // -------------- helpfunctions to gtext tags and containers -----------------      private constant filearg = ({    "background",    "texture",    "alpha",    "magic-texture",
Roxen.git/server/modules/graphics/graphic_text.pike:867:    "{\n"    " document.images[ri].src = hi.src;\n"    " if( txt != 0 )\n"    " setTimeout(\"top.window.status = '\"+txt+\"'\", 100);\n"    "}";    id->root_id->misc->gtext_magic_java="yes";    }    return res;   }    + private int get_file_stat( string f, RequestID id ) + { +  int res; +  mapping stat_cache; +  +  // -1 is used to cache negative results. When SiteBuilder crawler runs +  // we must let the stat_file() run unconditionally to register +  // dependencies properly. +  if (stat_cache = id->misc->gtext_statcache) { +  if (!id->misc->persistent_cache_crawler) +  if (res = stat_cache[f]) +  return (res > 0) && res; +  } else +  stat_cache = id->misc->gtext_statcache = ([ ]); +  +  int was_internal = id->misc->internal_get; +  id->misc->internal_get = 1; +  res = stat_cache[ f ] = (id->conf->stat_file( f,id ) || +  ({ 0,0,0,0 }) )[ST_MTIME] || -1; +  if (!was_internal) +  m_delete(id->misc, "internal_get"); +  return (res > 0) && res; + } +    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:898:    // Make format selection explicit since fallback may vary depending on    // encoders present in this installation.    if (!arg->format)   #if constant(Image.GIF) && constant(Image.GIF.encode)    arg->format = "gif";   #else    arg->format = "jpg";   #endif       foreach(filearg, string tmp) -  if(arg[tmp]) +  if(string path = arg[tmp])    { -  if(tmp[0..5]!="magic-") { -  p[tmp]=Roxen.fix_relative(arg[tmp],id); -  m_delete(arg,tmp); +  if (!has_prefix(tmp, "magic-")) { +  p[tmp] = Roxen.fix_relative(path, id); +  p[tmp + "_stat"] = get_file_stat(path, id); + #if constant(Sitebuilder) +  // The file we called get_file_stat() on above may be a SiteBuilder +  // file. If so we need to extend the argument data with e.g. +  // current language fork. +  if (Sitebuilder.sb_prepare_imagecache) +  p = Sitebuilder.sb_prepare_imagecache(p, path, id); + #endif +  m_delete(arg, tmp);    } else {    // The magic-* attributes will be removed later.    arg[tmp]=Roxen.fix_relative(arg[tmp],id);    }    }      // if(arg->border && (search(arg->border,",")!=-1))   // {   // p->border=arg->border;   // m_delete(arg,"border");