PageRenderTime 45ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/themesettings.php

https://github.com/adamfranco/segue-1.x
PHP | 163 lines | 98 code | 30 blank | 35 comment | 11 complexity | 8ac3e8c742d8982c4177ac7bef71bda1 MD5 | raw file
  1. <? /* $Id$ */
  2. $content = '';
  3. session_start();
  4. include_once("includes.inc.php");
  5. if (!defined("CONFIGS_INCLUDED"))
  6. die("Error: improper application flow. Configuration must be included first.");
  7. db_connect($dbhost, $dbuser, $dbpass, $dbdb);
  8. /*
  9. vars passed to this script:
  10. $theme -- the theme to edit
  11. $updatemethod -- either "javascript" or "db".. how to update the theme
  12. $site -- the site for which we are editing the theme
  13. $themesettings -- existing theme settings
  14. */
  15. /* ------ debug ------- */
  16. // $themesettings = $HTTP_GET_VARS['themesettings'];
  17. // print "$themesettings<br />";
  18. // print_r(unserialize(stripslashes($themesettings)))."<br />";
  19. // print "$theme - $updatemethod - $site"."<br />";
  20. $themesettings = unserialize(stripslashes(($_REQUEST['themesettings'])));
  21. $theme = $_REQUEST['theme'];
  22. if (!preg_match('/^[a-z0-9_-]+$/i', $theme))
  23. die('Error: invalid theme name, "'.$theme.'"');
  24. $filename = "themes/$theme/themesettings.inc.php";
  25. if (file_exists($filename)) {
  26. ob_start();
  27. include($filename);
  28. $settings_form=ob_get_contents();
  29. ob_end_clean();
  30. } else
  31. printc("<b>There are no additional options available for this theme.</b>");
  32. if ($_REQUEST['submitted']) {
  33. $onLoad = ' onload="';
  34. $themesettings = encode_array($themesettings);
  35. if ($_REQUEST['updatemethod'] == 'javascript') {
  36. $onLoad .= 'update()';
  37. }
  38. if ($_REQUEST['updatemethod'] == 'db') {
  39. $onLoad .= 'window.close()';
  40. // update the database
  41. }
  42. $onLoad .= '"';
  43. } else {
  44. // print out theme form
  45. printc("<form action='$PHP_SELF?$sid' method='post' name='settings'>");
  46. printc("<input type='hidden' name='submitted' value='1' />");
  47. printc("<input type='hidden' name='updatemethod' value='".$_REQUEST['updatemethod']."' />");
  48. printc("<input type='hidden' name='site' value='".$_REQUEST['site']."' />");
  49. printc("<input type='hidden' name='theme' value='$theme' />");
  50. printc($settings_form);
  51. printc("<div align='right'>");
  52. // printc("<input type='submit' value='Update' class='button' />
  53. printc("<input type='button' value='Close' class='button' onclick=\"closeAll()\" /></div>");
  54. printc("</form>");
  55. }
  56. ?>
  57. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  58. <html>
  59. <head>
  60. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  61. <?php
  62. // include("themes/common/header.inc.php");
  63. ?>
  64. <script type='text/javascript'>
  65. // <![CDATA[
  66. function closeAll() {
  67. window.close();
  68. }
  69. function update() {
  70. var ts = '<?echo $themesettings ?>';
  71. opener.document.addform.themesettings.value = ts;
  72. opener.document.addform.submit();
  73. opener.doPreviewWin("<?echo $theme?>", "settings");
  74. preview.focus();
  75. window.close();
  76. }
  77. // ]]>
  78. </script>
  79. <style type='text/css'>
  80. .title {
  81. color: #555;
  82. font-size: 16px;
  83. font-weight: bold;
  84. padding: 5px 5px 5px 10px;
  85. border-bottom: 1px dashed #999;
  86. }
  87. .content {
  88. color: #333;
  89. font-size: 11px;
  90. padding-left: 20px;
  91. margin-top: 5px;
  92. margin-right: 10px;
  93. margin-bottom: 10px;
  94. }
  95. .title, .content {
  96. font-family: "Verdana";
  97. }
  98. .desc { margin-bottom: 8px; }
  99. body { background-color: white; }
  100. .button {
  101. margin-right: 40px;
  102. margin-bottom: 10px;
  103. font-size: 10px;
  104. margin-top: 20px;
  105. }
  106. select {font-size: 10px; }
  107. </style>
  108. <title>Theme Settings</title>
  109. </head>
  110. <body<?echo $onLoad?> style='margin: 0px'>
  111. <div class='title'>Theme Settings</div>
  112. <div class='content'>
  113. <? print $content ?>
  114. </div>
  115. </body>
  116. <? // debug output -- handy :)
  117. /* print "<pre>"; */
  118. /* print "session:\n"; */
  119. /* print_r($_SESSION); */
  120. /* print "\n\n"; */
  121. /* print "request:\n"; */
  122. /* print_r($_REQUEST); */
  123. /* if (is_object($thisSection)) { */
  124. /* print "\n\n"; */
  125. /* print "thisSection:\n"; */
  126. /* print_r($thisSection); */
  127. /* } else if (is_object($thisSite)) { */
  128. /* print "\n\n"; */
  129. /* print "thisSite:\n"; */
  130. /* print_r($thisSite); */
  131. /* } */
  132. /* print "</pre>"; */