theme-settings.html.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <?php
  3. $theme = $theme;
  4. $configPath = 'themes/' . $theme . '/theme.json';
  5. $theme_path = 'themes/' . $theme;
  6. $image = ($m = glob($theme_path . '/screenshot.*')) ? site_url() . $m[0] : site_url() . 'system/resources/images/default-screenshot.jpg';
  7. $themeConfig = array();
  8. if (file_exists($configPath)) {
  9. $json = file_get_contents($configPath);
  10. $themeConfig = json_decode($json, true);
  11. }
  12. ?>
  13. <?php if (!empty($themeConfig)): ?>
  14. <div class="row">
  15. <div class="col">
  16. <div class="mb-3">
  17. <img class="card-img-top" style="object-fit: cover;" height="400px" src="<?php echo $image;?>"/>
  18. </div>
  19. </div>
  20. <div class="col">
  21. <div class="mb-3">
  22. <strong><?php echo i18n('name');?>:</strong>
  23. <div><?php echo $themeConfig['name'] ?: $theme; ?></div>
  24. </div>
  25. <div class="mb-3">
  26. <strong><?php echo i18n('version');?>:</strong>
  27. <div><?php echo $themeConfig['version'] ?: HTMLY_VERSION; ?></div>
  28. </div>
  29. <div class="mb-3">
  30. <strong><?php echo i18n('author');?>:</strong>
  31. <div><?php echo $themeConfig['author'] ?: 'Contributor'; ?></div>
  32. </div>
  33. <div class="mb-3">
  34. <strong><?php echo i18n('homepage');?>:</strong>
  35. <div><a target="_blank" href="<?php echo $themeConfig['homepage'] ?: site_url(); ?>"><?php echo $themeConfig['homepage'] ?: site_url(); ?></a></div>
  36. </div>
  37. <div class="mb-3">
  38. <strong><?php echo i18n('description');?>:</strong>
  39. <div><?php echo $themeConfig['description'] ?: 'HTMLy ' . $theme; ?></div>
  40. </div>
  41. </div>
  42. </div>
  43. <br><br>
  44. <?php if (!empty($themeConfig['settings'])): ?>
  45. <h2><?php echo i18n('settings');?></h2>
  46. <form method="POST">
  47. <input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
  48. <?php foreach ($themeConfig['settings'] as $setting):?>
  49. <div class="form-group row">
  50. <label class='col-sm-2 col-form-label'><?php echo $setting['label'];?></label>
  51. <div class="col-sm-10">
  52. <?php if ($setting['type'] === 'select'): ?>
  53. <select class='form-control' name='-config-<?php echo $setting['name'];?>'>
  54. <?php foreach ($setting['options'] as $option):?>
  55. <?php $selected = $option === theme_config($setting['name']) ? 'selected' : '';?>
  56. <option value='<?php echo $option;?>' <?php echo $selected;?>><?php echo $option;?></option>
  57. <?php endforeach;?>
  58. </select>
  59. <?php elseif ($setting['type'] === 'checkbox'): ?>
  60. <?php $checked = theme_config($setting['name']) ? 'checked' : '';?>
  61. <input type="hidden" name="-config-<?php echo $setting['name'];?>" value="0" />
  62. <input type='checkbox' name='-config-<?php echo $setting['name'];?>' <?php echo $checked;?> value="1"/>
  63. <br>
  64. <?php else: ?>
  65. <input class="form-control" type="<?php echo $setting['type'];?>" name="-config-<?php echo $setting['name'];?>" value="<?php echo theme_config($setting['name']);?>"/>
  66. <?php endif;?>
  67. <small><?php echo $setting['info'];?></small>
  68. </div>
  69. </div>
  70. <?php endforeach;?>
  71. <div class="form-group row">
  72. <div class="col-sm-10 offset-sm-2">
  73. <button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button>
  74. </div>
  75. </div>
  76. </form>
  77. <?php endif;?>
  78. <?php endif; ?>