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

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - constant cvs_version="$Id: graphic_text.pike,v 1.103 1998/02/19 19:40:59 noring Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.104 1998/02/20 11:16:39 per Exp $";   constant thread_safe=1;      #include <module.h>   #include <stat.h>   inherit "module";   inherit "roxenlib";      #ifndef VAR_MORE   #define VAR_MORE 0   #endif /* VAR_MORE */
Roxen.git/server/modules/graphics/graphic_text.pike:250:   {    if(last_image_name == f && last_image) return last_image->copy();    string data;    object file;    object img   #if !constant(Image.PNM)    =Image.image()   #endif    ;    -  +     if(!(data=roxen->try_get_file(fix_relative(f, id),id)))    if(!(file=open(f,"r")) || (!(data=file->read())))    return 0;   //werror("Read "+strlen(data)+" bytes.\n");   #if constant(Image.PNM.decode)    catch { if(!img) img = Image.PNM.decode( data ); };   #endif   #if constant(Image.GIF.decode)    catch { if(!img) img = Image.GIF.decode( data ); };   #endif
Roxen.git/server/modules/graphics/graphic_text.pike:999:   // werror("done! < "+_args+" <"+text+">\n");    cache_set(key, text, data);    if(size) return data[1];    return data[0];    };   // werror("Got error < "+_args+" <"+text+">\n");    cache_set(key, text, 0);    throw(err);   }    + array stat_file(string f, object rid) + { +  if(f[-1]=='/') f = f[..strlen(f)-2]; +  if(sizeof(f/"/")==1) return ({ 509,-3,time(),time(),time(),0,0 }); +  int len=4711; +  catch(len= strlen(find_file(f,rid)->data)); +  return ({ 33204,len,time(),time(),time(),0,0 }); + }    -  + array find_dir(string f, object rid) + { +  if(!strlen(f)) +  { +  restore_cached_args(); +  return Array.map(indices(cached_args), lambda(mixed m){return (string)m;}); +  } +  return ({"Example"}); + } +  +    mapping find_file(string f, object rid)   {    int id; -  +  if(rid->method != "GET") return 0;    sscanf(f,"%d/%s", id, f);       if( query("gif") ) //Remove .gif    f = f[..strlen(f)-5];       if (sizeof(f)) {    object g;    if (f[0] == '$') { // Illegal in BASE64    f = f[1..];    } else if (sizeof(indices(g=Gz))) {
Roxen.git/server/modules/graphics/graphic_text.pike:1150:   }         string magic_image(string url, int xs, int ys, string sn,    string image_1, string image_2, string alt,    string mess,object id,string input,string extra_args)   {    if(!id->supports->images) return alt;    if(!id->supports->netscape_javascript)    return (!input)? -  ("<a "+extra_args+"href=\""+url+"\"><img _parsed=1 src=\""+image_1+"\" name="+sn+" border=0 "+ +  ("<a "+extra_args+"href=\""+url+"\"><img src=\""+image_1+"\" name="+sn+" border=0 "+    "alt=\""+alt+"\"></a>\n"):    ("<input type=image "+extra_args+" src=\""+image_1+"\" name="+input+">");       return    ("<script>\n"    " "+sn+"l = new Image("+xs+", "+ys+");"+sn+"l.src = \""+image_1+"\";\n"    " "+sn+"h = new Image("+xs+", "+ys+");"+sn+"h.src = \""+image_2+"\";\n"    "</script>\n"+    ("<a "+extra_args+"href=\""+url+"\" "+    (input?"onClick='document.forms[0].submit();' ":"")    +"onMouseover=\"i('"+sn+"',"+sn+"h,'"+(mess||url)+"'); return true;\"\n" -  "onMouseout='document.images[\""+sn+"\"].src = "+sn+"l.src;'><img " -  "_parsed=1 width="+xs+" height="+ys+" src=\""+image_1+"\" name="+sn+ +  "onMouseout='top.window.status=\"\";document.images[\""+sn+"\"].src = "+sn+"l.src;'><img " +  "width="+xs+" height="+ys+" src=\""+image_1+"\" name="+sn+    " border=0 alt=\""+alt+"\" ></a>\n"));   }         string extra_args(mapping in)   {    string s="";    foreach(indices(in), string i)    {    switch(i)
Roxen.git/server/modules/graphics/graphic_text.pike:1256:    return "";   }      string tag_graphicstext(string t, mapping arg, string contents,    object id, object foo, mapping defines)   {   //Allow <accessed> and others inside <gtext>.    if(arg->help)    return register_module()[2];    +  if(arg->background) +  arg->background = fix_relative(arg->background,id); +  if(arg->texture) +  arg->texture = fix_relative(arg->texture,id); +  if(arg->magic_texture) +  arg->magic_texture=fix_relative(arg->magic_texture,id); +  if(arg->magic_background) +  arg->magic_background=fix_relative(arg->magic_background,id); +  if(arg->magicbg) +  arg->magicbg = fix_relative(arg->magicbg,id); +     string gif="";    if(query("gif")) gif=".gif";      #if efun(_static_modules)    contents = parse_rxml(contents, id, foo, defines);   #else    contents = parse_rxml(contents, id, foo);   #endif       string lp, url, ea;
Roxen.git/server/modules/graphics/graphic_text.pike:1426:    array arr = word/split;    int i;    for (i = sizeof(arr)-1; i--;) {    arr[i] += split;    }    if (arr[-1] == "") {    arr = arr[..sizeof(arr)-2];    }    foreach (arr, word) {    array size = write_text(num,word,1,id); -  res += ({ "<img _parsed=1 border=0 alt=\"" + +  res += ({ "<img border=0 alt=\"" +    replace(arg->alt || word, "\"", "'") +    "\" src=\"" + pre + quote(word) + gif + "\" width=" +    size[0] + " height=" + size[1] + " " + ea + ">"    });    }    res += ({"\n"});    } else {    array size = write_text(num,word,1,id); -  res += ({ "<img _parsed=1 border=0 alt=\"" + +  res += ({ "<img border=0 alt=\"" +    replace(arg->alt || word, "\"", "'") +    "\" src=\"" + pre + quote(word) + gif + "\" width=" +    size[0] + " height=" + size[1] + " " + ea + ">\n"    });    }    }    if(lp) res += ({ "</a>"+post });    return res*"";    }   
Roxen.git/server/modules/graphics/graphic_text.pike:1496:    "</script>\n<script>","");    }    if(input)    return (pre+"<input type=image name=\""+na+"\" border=0 alt=\""+    (arg->alt?arg->alt:replace(gt,"\"","'"))+    "\" src="+query_location()+num+"/"+quote(gt)+gif    +" align="+(al || defalign)+ea+    " width="+size[0]+" height="+size[1]+">"+rest+post);       return (pre+(lp?lp:"") -  + "<img _parsed=1 border=0 alt=\"" +  + "<img border=0 alt=\""    + (arg->alt?arg->alt:replace(gt,"\"","'"))    + "\" src=\""    + query_location()+num+"/"+quote(gt)+gif+"\" "+ea    + " align="+(al || defalign)    + " width="+size[0]+" height="+size[1]+">"+rest+(lp?"</a>":"")+post);   }      inline string ns_color(array (int) col)   {    if(!arrayp(col)||sizeof(col)!=3)
Roxen.git/server/modules/graphics/graphic_text.pike:1524:    array a=indices(in), b=values(in);    for(int i=0; i<sizeof(a); i++)    if(lower_case(b[i])!=a[i])    if(search(b,"\"")==-1)    a[i]+="=\""+b[i]+"\"";    else    a[i]+="='"+b[i]+"'";    return a*" ";   }    - string tag_body(string t, mapping args, object id, object file, + array (string) tag_body(string t, mapping args, object id, object file,    mapping defines)   {    int cols,changed;    if(args->bgcolor||args->text||args->link||args->alink    ||args->background||args->vlink)    cols=1;      #define FIX(Y,Z,X) do{if(!args->Y || args->Y==""){if(cols){defines->X=Z;args->Y=Z;changed=1;}}else{defines->X=args->Y;if(args->Y[0]!='#'){args->Y=ns_color(parse_color(args->Y));changed=1;}}}while(0)       if(!search(id->client*"","Mosaic"))
Roxen.git/server/modules/graphics/graphic_text.pike:1548:    FIX(link, "#0000b0",link);    FIX(alink, "#3f0f7b",alink);    FIX(vlink, "#ff0000",vlink);    } else {    FIX(bgcolor,"#c0c0c0",bg);    FIX(text, "#000000",fg);    FIX(link, "#0000ee",link);    FIX(alink, "#ff0000",alink);    FIX(vlink, "#551a8b",vlink);    } -  if(changed) return ("<body "+make_args(args)+">"); +  if(changed) return ({"<body "+make_args(args)+">"});   }       - string tag_fix_color(string tagname, mapping args, object id, object file, + array (string) tag_fix_color(string tagname, mapping args, object id, object file,    mapping defines)   {    int changed;       if(!id->misc->colors)    id->misc->colors = ({ ({ defines->fg, defines->bg, tagname }) });    else    id->misc->colors += ({ ({ defines->fg, defines->bg, tagname }) });   #undef FIX   #define FIX(X,Y) if(args->X && args->X!=""){defines->Y=args->X;if(args->X[0]!='#'){args->X=ns_color(parse_color(args->X));changed = 1;}}       FIX(bgcolor,bg);    FIX(text,fg);    FIX(color,fg); -  if(changed) return ("<"+tagname+" "+make_args(args)+">"); +  if(changed) return ({"<"+tagname+" "+make_args(args)+">"});    return 0;   }    - string pop_color(string tagname,mapping args,object id,object file, + void pop_color(string tagname,mapping args,object id,object file,    mapping defines)   {    array c = id->misc->colors;    sscanf(tagname, "/%s", tagname);    while(c && sizeof(c))    {    if(c[-1][2]==tagname)    {    defines->fg = c[-1][0];    defines->bg = c[-1][1];