template.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /*
  13. * template.c: The actual HTML templates in a static variable
  14. *
  15. * All blame to Mike McCool
  16. */
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include "libadmin/libadmin.h"
  21. NSAPI_PUBLIC char *helpJavaScriptForTopic( char *topic )
  22. {
  23. char *tmp;
  24. char line[BIG_LINE];
  25. char *server="admserv";
  26. char *type;
  27. int typeLen;
  28. /* Get the server type, without the instance name into type */
  29. tmp = strchr( server, '-' );
  30. typeLen = tmp - server;
  31. type = (char *)MALLOC( typeLen + 1 );
  32. type[typeLen] = '\0';
  33. while ( typeLen-- ) {
  34. type[typeLen] = server[typeLen];
  35. }
  36. util_snprintf( line, BIG_LINE,
  37. "if ( top.helpwin ) {"
  38. " top.helpwin.focus();"
  39. " top.helpwin.infotopic.location='%s/%s/admin/tutor?!%s';"
  40. "} else {"
  41. " window.open('%s/%s/admin/tutor?%s', '"
  42. INFO_IDX_NAME"_%s', "
  43. HELP_WIN_OPTIONS");}",
  44. getenv("SERVER_URL"), server, topic,
  45. getenv("SERVER_URL"), server, topic,
  46. type );
  47. FREE(type);
  48. return(STRDUP(line));
  49. }
  50. NSAPI_PUBLIC char *helpJavaScript()
  51. {
  52. char *tmp, *sn;
  53. tmp=STRDUP(getenv("SCRIPT_NAME"));
  54. if(strlen(tmp) > (unsigned)BIG_LINE)
  55. tmp[BIG_LINE-2]='\0';
  56. sn=strrchr(tmp, '/');
  57. if( sn )
  58. *sn++='\0';
  59. FREE(tmp);
  60. return helpJavaScriptForTopic( sn );
  61. }