html.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. trait HTMLHomepageItem
  3. {
  4. public function htmlOneSettingsArray()
  5. {
  6. return array(
  7. 'name' => 'CustomHTML-1',
  8. 'enabled' => strpos('personal,business', $this->config['license']) !== false,
  9. 'image' => 'plugins/images/tabs/custom1.png',
  10. 'category' => 'Custom',
  11. 'settings' => array(
  12. 'Enable' => array(
  13. array(
  14. 'type' => 'switch',
  15. 'name' => 'homepageCustomHTMLoneEnabled',
  16. 'label' => 'Enable',
  17. 'value' => $this->config['homepageCustomHTMLoneEnabled']
  18. ),
  19. array(
  20. 'type' => 'select',
  21. 'name' => 'homepageCustomHTMLoneAuth',
  22. 'label' => 'Minimum Authentication',
  23. 'value' => $this->config['homepageCustomHTMLoneAuth'],
  24. 'options' => $this->groupOptions
  25. )
  26. ),
  27. 'Code' => array(
  28. array(
  29. 'type' => 'textbox',
  30. 'name' => 'customHTMLone',
  31. 'class' => 'hidden customHTMLoneTextarea',
  32. 'label' => '',
  33. 'value' => $this->config['customHTMLone'],
  34. ),
  35. array(
  36. 'type' => 'html',
  37. 'override' => 12,
  38. 'label' => 'Custom HTML/JavaScript',
  39. 'html' => '<button type="button" class="hidden savecustomHTMLoneTextarea btn btn-info btn-circle pull-right m-r-5 m-l-10"><i class="fa fa-save"></i> </button><div id="customHTMLoneEditor" style="height:300px">' . htmlentities($this->config['customHTMLone']) . '</div>'
  40. ),
  41. )
  42. )
  43. );
  44. }
  45. public function htmlTwoSettingsArray()
  46. {
  47. return array(
  48. 'name' => 'CustomHTML-2',
  49. 'enabled' => strpos('personal,business', $this->config['license']) !== false,
  50. 'image' => 'plugins/images/tabs/custom2.png',
  51. 'category' => 'Custom',
  52. 'settings' => array(
  53. 'Enable' => array(
  54. array(
  55. 'type' => 'switch',
  56. 'name' => 'homepageCustomHTMLtwoEnabled',
  57. 'label' => 'Enable',
  58. 'value' => $this->config['homepageCustomHTMLtwoEnabled']
  59. ),
  60. array(
  61. 'type' => 'select',
  62. 'name' => 'homepageCustomHTMLtwoAuth',
  63. 'label' => 'Minimum Authentication',
  64. 'value' => $this->config['homepageCustomHTMLtwoAuth'],
  65. 'options' => $this->groupOptions
  66. )
  67. ),
  68. 'Code' => array(
  69. array(
  70. 'type' => 'textbox',
  71. 'name' => 'customHTMLtwo',
  72. 'class' => 'hidden customHTMLtwoTextarea',
  73. 'label' => '',
  74. 'value' => $this->config['customHTMLtwo'],
  75. ),
  76. array(
  77. 'type' => 'html',
  78. 'override' => 12,
  79. 'label' => 'Custom HTML/JavaScript',
  80. 'html' => '<button type="button" class="hidden savecustomHTMLtwoTextarea btn btn-info btn-circle pull-right m-r-5 m-l-10"><i class="fa fa-save"></i> </button><div id="customHTMLtwoEditor" style="height:300px">' . htmlentities($this->config['customHTMLtwo']) . '</div>'
  81. ),
  82. )
  83. )
  84. );
  85. }
  86. public function htmlHomepagePermissions($key = null)
  87. {
  88. $permissions = [
  89. 'one' => [
  90. 'enabled' => [
  91. 'homepageCustomHTMLoneEnabled'
  92. ],
  93. 'auth' => [
  94. 'homepageCustomHTMLoneAuth'
  95. ],
  96. 'not_empty' => [
  97. 'customHTMLone'
  98. ]
  99. ],
  100. 'two' => [
  101. 'enabled' => [
  102. 'homepageCustomHTMLtwoEnabled'
  103. ],
  104. 'auth' => [
  105. 'homepageCustomHTMLtwoAuth'
  106. ],
  107. 'not_empty' => [
  108. 'customHTMLtwo'
  109. ]
  110. ]
  111. ];
  112. if (array_key_exists($key, $permissions)) {
  113. return $permissions[$key];
  114. } elseif ($key == 'all') {
  115. return $permissions;
  116. } else {
  117. return [];
  118. }
  119. }
  120. public function homepageOrdercustomhtml()
  121. {
  122. if ($this->homepageItemPermissions($this->htmlHomepagePermissions('one'))) {
  123. return '
  124. <div id="' . __FUNCTION__ . '">
  125. ' . $this->config['customHTMLone'] . '
  126. </div>
  127. ';
  128. }
  129. }
  130. public function homepageOrdercustomhtmlTwo()
  131. {
  132. if ($this->homepageItemPermissions($this->htmlHomepagePermissions('two'))) {
  133. return '
  134. <div id="' . __FUNCTION__ . '">
  135. ' . $this->config['customHTMLtwo'] . '
  136. </div>
  137. ';
  138. }
  139. }
  140. }