html.php 4.3 KB

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