4
0

html.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. trait HTMLHomepageItem
  3. {
  4. public function customHtmlNumber()
  5. {
  6. return 8;
  7. }
  8. public function customHtmlSettingsArray($infoOnly = false)
  9. {
  10. $homepageInformation = [
  11. 'name' => 'CustomHTML',
  12. 'enabled' => strpos('personal,business', $this->config['license']) !== false,
  13. 'image' => 'plugins/images/tabs/HTML5.png',
  14. 'category' => 'Custom',
  15. 'settingsArray' => __FUNCTION__
  16. ];
  17. if ($infoOnly) {
  18. return $homepageInformation;
  19. }
  20. $homepageSettings = [
  21. 'debug' => true,
  22. 'settings' => []
  23. ];
  24. for ($i = 1; $i <= $this->customHtmlNumber(); $i++) {
  25. $i = sprintf('%02d', $i);
  26. $homepageSettings['settings']['Custom HTML ' . $i] = array(
  27. $this->settingsOption('enable', 'homepageCustomHTML' . $i . 'Enabled'),
  28. $this->settingsOption('auth', 'homepageCustomHTML' . $i . 'Auth'),
  29. //$this->settingsOption('pre-code-editor', 'customHTML' . $i), // possibly can remove this as we consolidated the type into one
  30. $this->settingsOption('code-editor', 'customHTML' . $i, ['label' => 'Custom HTML Code', 'mode' => 'html']),
  31. );
  32. }
  33. return array_merge($homepageInformation, $homepageSettings);
  34. }
  35. public function htmlHomepagePermissions($key = null)
  36. {
  37. for ($i = 1; $i <= $this->customHtmlNumber(); $i++) {
  38. $i = sprintf('%02d', $i);
  39. $permissions[$i] = [
  40. 'enabled' => [
  41. 'homepageCustomHTML' . $i . 'Enabled'
  42. ],
  43. 'auth' => [
  44. 'homepageCustomHTML' . $i . 'Auth'
  45. ],
  46. 'not_empty' => [
  47. 'customHTML' . $i
  48. ]
  49. ];
  50. }
  51. return $this->homepageCheckKeyPermissions($key, $permissions);
  52. }
  53. public function homepageOrdercustomhtml($key = '01')
  54. {
  55. if ($this->homepageItemPermissions($this->htmlHomepagePermissions($key))) {
  56. return '
  57. <div id="' . __FUNCTION__ . '">
  58. ' . $this->config['customHTML' . $key] . '
  59. </div>
  60. ';
  61. }
  62. }
  63. }