Roxen.git / server / config_interface / sites / create_site_with_template.pike

version» Context lines:

Roxen.git/server/config_interface/sites/create_site_with_template.pike:1:   #include <config_interface.h>      constant base = #"<use file='/template'/><tmpl><topmenu base='../' selected='sites'/>   <content><cv-split><subtablist><st-page>    <input type='hidden' name='name' value='&form.name;' /> -  <table border='0' cellspacing='0' cellpadding='10'> -  <tr><td> +     %s    %s -  </td></tr> -  </table> +    </st-page></subtablist></cv-split></content></tmpl>   ";      string decode_site_name( string what )   {    if( (int)what && (search(what, ",") != -1))    return (string)((array(int))(what/","-({""})));    return what;   }   
Roxen.git/server/config_interface/sites/create_site_with_template.pike:31:   {    if( id->real_variables->site_template )    return id->real_variables->site_template[0];    return "&form.site_template;";   }      string|mapping parse( RequestID id )   {    if( !config_perm( "Create Site" ) )    error("No permission, dude!\n"); // This should not happen, really. -  if( !id->variables->name ) +  if( !id->variables->name ) { +  return Roxen.http_redirect("/sites/new_site.html");    error("No name for the site!\n"); // This should not happen either. -  +  }       id->variables->name = decode_site_name( id->variables->name );       if (!id->variables->site_template || -  search(id->variables->site_template, "site_templates")!=-1 ) { +  search(id->variables->site_template, "site_templates")!=-1 ) +  {    foreach( glob("*" SITE_TEMPLATES "*.x",    indices(id->variables) ), string t )    {    t = t[..sizeof(t)-3];    id->real_variables->site_template = ({ t });    id->variables->site_template = t;    }    }       License.LicenseVariable license =
Roxen.git/server/config_interface/sites/create_site_with_template.pike:110:    array(string) templates = ({});    foreach(({ "." }) + roxenloader->package_directories,    string pkg_dir) {    string template_dir = combine_path(pkg_dir, SITE_TEMPLATES);    array(string) sts = get_dir(template_dir);    if (!sts) continue;    templates += map(glob( "*.pike", sts),    lambda(string st, string template_dir) {    return template_dir + st;    }, template_dir); +  TRACE("templates: %O\n", templates);    }       foreach( templates, string st ) {    mixed err = catch {    program p;    object q;    p = (program)(st);    if(!p) {    report_error("Template \""+st+"\" failed to compile.\n");    continue;
Roxen.git/server/config_interface/sites/create_site_with_template.pike:143:    doc = q->doc;       if( q[ "group_"+id->misc->cf_locale ] )    group = q[ "group_"+id->misc->cf_locale ];    else    group = q->group;       string button;    if(q->locked && !(license->get_key() && q->unlocked(license->get_key())))    button = -  "<gbutton width='400' " -  " icon_src='&usr.padlock;' " -  " align_icon='right'" -  " state='disabled'>" +  "<disabled-gbutton width='400px' type='padlock'>"    + Roxen.html_encode_string(name) + -  "</gbutton>\n"; -  else -  button = -  "<cset variable='var.url'>" -  "<gbutton-url width='400' " -  " icon_src='&usr.next;' " -  " align_icon='right'>" -  + Roxen.html_encode_string(name) + -  "</gbutton-url></cset>" -  "<input border='0' type='image' src='&var.url;' name='"+st+"' />\n"; +  "</disabled-gbutton>"; +  else { +  button = "<submit-gbutton2 name='" + st + "' type='add' width='400px'>" + +  Roxen.html_encode_string(name) + +  "</submit-gbutton2>"; +  }       // Build a sort identifier on the form "999|Group name|template name"    // where 999 is a number which orders the groups. The group name is    // the only string which the user will see. All templates which don't    // contain a number will default to position 500.    string sort_id = group || "Roxen WebServer";    if (!has_value(sort_id, "|"))    sort_id = "500|" + sort_id;    sort_id += "|" + name;    sts += ({ ({ sort_id, name,    button + "<blockquote>" + doc + "</blockquote>" }) });    }    };    if (err) {    report_error(sprintf("Template %O failed:\n"    "%s\n",    st, describe_backtrace(err)));    }    }    -  +  int n;    string last_group;    sort( sts );    foreach( sts, array q ) {    // Extract group name and create divider if different from last one    string group = (q[0] / "|")[1];    if (group != last_group) { -  +  if (n++) { +  res += "<hr>"; +  }    res += -  "<br>" +     "<h3>" + group + "</h3>\n";    last_group = group;    }    res += q[2] + "\n\n\n";    }    -  res += "<cf-cancel href='./'/>\n" +  res += "<hr><cf-cancel href='./'/>\n"    "<input type='hidden' name='initialize_template' value='1' />\n";          if( strlen( e->get() ) ) {    res += ("Compile errors:<pre>"+    Roxen.html_encode_string(e->get())+    "</pre>");    report_error("Compile errors: "+e->get()+"\n");    }    master()->set_inhibit_compile_errors( 0 );          // License stuff    string render_variable(Variable.Variable var, RequestID id)    {    string pre = var->get_warnings();    -  if( pre ) -  pre = "<font size='+1' color='&usr.warncolor;'><pre>"+ +  if( pre ) { +  pre = "<div>"+    Roxen.html_encode_string( pre )+ -  "</pre></font>"; -  else +  "</div>"; +  } +  else {    pre = ""; -  +  }       string name = var->name()+""; -  return "<tr><td valign='center' width='20%' nowrap=''><b>"+ -  Roxen.html_encode_string(name)+"</b></td>\n" -  "<td valign='center' width='0'>"+pre+var->render_form(id, ([ "autosubmit":1 ]))+"</td>\n" -  "<td align='left' width='80%'><cset variable='var.url'>" -  "<gbutton-url>Set</gbutton-url></cset>" -  "<input border='0' type='image' src='&var.url;' name='set_license' />" -  "</td>\n" -  "</tr>\n" -  "<tr>\n" -  "<td colspan='3'>"+var->doc()+"</td>\n" -  "</tr>\n"; +  string ret = "<div class='margin-bottom'><label class='large bold'>"+ +  Roxen.html_encode_string(name)+": </label> " +  ""+var->render_form(id, ([ "autosubmit":1 ]))+" " +  "<submit-gbutton2 name='set_license'>Set</submit-gbutton2>" +  "</div>"; +  if (sizeof(pre)) { +  ret += "<div class='notify error margin-top'>" + pre + "</div>"; +  } +  ret += "<div>"+var->doc()+"</div>\n"; +  +  return ret;    };    string license_res = "";    if(license->check_visibility(id, 0, 0, 0, 0))    license_res = -  "<table border='0'>" + +     render_variable(license, id) + -  "</table>" +     "<hr>\n";       return sprintf(base, license_res, res);   }