// this is a pike script for roxen. // it takes a few arguments: // // template: the name of a template file to use to generate a pdf. // action: the action we want to perform; by default, we return the pdf data. // force: force the pdf to be regenerated, even if it's cached on disk. // // the template file should have a tag that generates some pdf. // any other arguments to this script will be passed on to the pdf generation template. // mixed parse(RequestID id) { // first, let's get some variables string template = id->variables->template; string action = id->variables->action; // do we want to force regeneration string force = id->variables->force; // something we can use to look and see if we've already built it. string unique_identifier = id->variables->unique_identifier; // now, we generate the real template path on disk. template = "/tmp/" + template + ".rxml"; // okay, if we decide we need to generate the pdf, we can do that. string data; if(!force) data = get_pdf(unique_identifier); if(!data || force) { data = parse_rxml(Stdio.read_file(template), id); put_pdf(unique_identifier, data); } if(!data) return "an error occurred."; // the default action is to return the data. if(!action || action=="return") { // we might want to do other things, like set the filename. return http_string_answer(data, "application/pdf"); } else if(action =="email") { // some code to mail the file. } return "done."; } // this function should be filled out to look for a pre-saved pdf with this unique identifer. // right now, it doesn't do anything and will cause the pdf to be generated as though it weren't saved at all. string get_pdf(string unique_identifier) { return 0; } // this function should store the pdf somewhere using a unique identifier that can be used later to get it back. void put_pdf(string unique_identifer, string data) { return; }