settings.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. if(!empty($args['conf_change_type'])) {
  3. $conf = $conf_obj->get($args['conf_change_type']);
  4. $model = $conf_obj->get_config_model($args['conf_change_type']);
  5. $saved = false;
  6. foreach( $model as $key => $item ) {
  7. if(!empty($args[$key])) {
  8. $conf[$key] = $args[$key];
  9. }
  10. $conf_obj->set($args['conf_change_type'], $conf);
  11. $saved = $conf_obj->save($args['conf_change_type']);
  12. }
  13. if($saved) {
  14. echo "<p>Successfully saved $saved bytes to " . $conf_obj->get_conf_dir() . '/' . $args['conf_change_type'] . ".json</p>";
  15. } else {
  16. echo '<p style="color:red;">Failed to save to ' . $conf_obj->get_conf_dir() . '/' . $args['conf_change_type'] . '.json!</p>';
  17. }
  18. }
  19. ?>
  20. <p class="title">
  21. General settings:
  22. </p>
  23. <hr />
  24. <form id="mainConfig" method="post" action="index.php">
  25. <input type="hidden" name="conf_change_type" value="main" />
  26. <table>
  27. <?php
  28. $conf = $conf_obj->get('main');
  29. $model = $conf_obj->get_config_model('main');
  30. $line = '';
  31. foreach ( $model as $key => $item ) {
  32. $line .= '<tr>';
  33. $line .= '<td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  34. if($item['form_field'] == 'select') {
  35. $line .= '<td><select class="cooltext" name="' . $key . '" id="' . $key . '">';
  36. foreach ( $item['select_opts'] as $option ) {
  37. $line .= '<option value="' . $option . '">' . $option . '</option>';
  38. }
  39. $line .= '</select></td>';
  40. } elseif($item['form_field'] == 'input') {
  41. $val = !empty($conf[$key]) ? $conf[$key] : '';
  42. $line .= '<td><input type="text" class="cooltext" name="' . $key . '" id="' . $key . '" placeholder="'.$item['default'].'" value="'.$val.'" />';
  43. }
  44. $line .= '</tr>';
  45. }
  46. echo "$line\n";
  47. ?>
  48. </table>
  49. <br />
  50. <input type="submit" class="coolbutton" value="Commit Changes" />
  51. </form>
  52. <hr />
  53. <p class="title">
  54. User management:
  55. </p>
  56. <hr />
  57. <form id="userConfig" method="post" action="index.php">
  58. <input type="hidden" name="conf_change_type" value="user" />
  59. <table>
  60. <?php
  61. $conf = $conf_obj->get('users');
  62. $model = $conf_obj->get_config_model('users');
  63. $line = '';
  64. foreach ( $conf as $user => $data ) {
  65. $line .= "<tr><td colspan=2><em>Manage user '$user'</em></td></tr>";
  66. foreach ( $model as $key => $item ) {
  67. $line .= '<tr><td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  68. $val = "";
  69. if( array_key_exists( $key, $data ) ) {
  70. $val = $data[$key];
  71. } else if( array_key_exists( 'masks', $item ) && $item['masks'] == 'parent' ) {
  72. $val = $user;
  73. }
  74. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="' . $val . '" /></td></tr>';
  75. }
  76. }
  77. echo "$line\n";
  78. ?>
  79. </table>
  80. <br />
  81. <input type="submit" class="coolbutton" value="Commit Changes" />
  82. </form>
  83. <br />
  84. <p class="title">
  85. Add User:
  86. </p>
  87. <form id="addUser" method="post" action="index.php">
  88. <input type="hidden" name="conf_change_type" value="user" />
  89. <table>
  90. <?php
  91. $line = '';
  92. foreach ( $model as $key => $item ) {
  93. $line .= '<td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  94. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="" /></td></tr>';
  95. }
  96. echo "$line\n";
  97. ?>
  98. </table>
  99. <br />
  100. <input type="submit" class="coolbutton" value="Commit Changes" />
  101. </form>
  102. <hr />
  103. <p class="title">
  104. Theme cloner:
  105. </p>
  106. <hr />
  107. <p>
  108. Want to write your own theme?
  109. Clone a theme here then see the <a href="https://tcms.troglodyne.net/index.php?nav=5&post=fileshare/manual/Chapter 03-Customization.post" title="GET UR MIND RITE">styling guide</a>
  110. for information on how tCMS' templates, image sets and CSS work in the theming system.
  111. </p>
  112. INSERT FORM HERE