theme.html.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php if (!defined('HTMLY')) die('HTMLy'); ?>
  2. <?php
  3. global $config_file;
  4. $this_config = parse_ini_file($config_file, true);
  5. ?>
  6. <div class="row">
  7. <?php foreach (glob('themes/*/layout.html.php') as $folder) : ?>
  8. <?php $exp = explode('/',pathinfo($folder)['dirname']); $theme = $exp['1']; $theme_path = pathinfo($folder)['dirname'];?>
  9. <?php $image = ($m = glob($theme_path . '/screenshot.*')) ? site_url() . $m[0] : site_url() . 'system/resources/images/default-screenshot.jpg';?>
  10. <div class="col-lg-4 col-md-6">
  11. <div class="card <?php echo $this_config['views.root'] === $theme_path ? 'card-primary': '';?>">
  12. <div class="card-header"><img class="card-img-top" height="200px" style="object-fit: cover;" src="<?php echo $image;?>"/></div>
  13. <div class="card-body">
  14. <h3><?php echo $theme;?></h3>
  15. <?php if ($this_config['views.root'] === $theme_path ):?>
  16. <button class="btn btn-secondary disabled"><?php echo i18n('enable');?></button>
  17. <?php else:?>
  18. <button class="btn btn-primary enable-button" data-value="<?php echo $theme_path;?>"><?php echo i18n('enable');?></button>
  19. <?php endif;?>
  20. <?php if ($this_config['views.root'] === $theme_path && file_exists($theme_path . '/theme.json')) :?>
  21. <a class="btn btn-primary" href="<?php echo site_url() . 'admin/themes/' . $theme;?>"><?php echo i18n('settings');?></a>
  22. <?php endif;?>
  23. </div>
  24. </div>
  25. </div>
  26. <?php endforeach; ?>
  27. </div>
  28. <script>
  29. $('.enable-button').on("click", function(e) {
  30. var data = $(e.target).attr('data-value');
  31. $.ajax({
  32. type: 'POST',
  33. url: '<?php echo site_url();?>admin/themes',
  34. dataType: 'json',
  35. data: {'json': data},
  36. success: function (response) {
  37. alert(response.message);
  38. location.reload();
  39. },
  40. });
  41. });
  42. </script>