html.php 4.4 KB

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