clip_options_list.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2023
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. James Rose <[email protected]>
  21. */
  22. //includes files
  23. require_once dirname(__DIR__, 2) . "/resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('clip_edit')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //include
  37. require_once "header.php";
  38. //show the content
  39. echo "<script type=\"text/javascript\" language=\"javascript\">\n";
  40. echo " function makeRequest(url, strpost) {\n";
  41. echo " var http_request = false;\n";
  42. echo "\n";
  43. echo " if (window.XMLHttpRequest) { // Mozilla, Safari, ...\n";
  44. echo " http_request = new XMLHttpRequest();\n";
  45. echo " if (http_request.overrideMimeType) {\n";
  46. echo " http_request.overrideMimeType('text/xml');\n";
  47. echo " // See note below about this line\n";
  48. echo " }\n";
  49. echo " } else if (window.ActiveXObject) { // IE\n";
  50. echo " try {\n";
  51. echo " http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");\n";
  52. echo " } catch (e) {\n";
  53. echo " try {\n";
  54. echo " http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
  55. echo " } catch (e) {}\n";
  56. echo " }\n";
  57. echo " }\n";
  58. echo "\n";
  59. echo " if (!http_request) {\n";
  60. echo " alert('".$text['message-give-up']."');\n";
  61. echo " return false;\n";
  62. echo " }\n";
  63. echo " http_request.onreadystatechange = function() { returnContent(http_request); };\n";
  64. echo " http_request.overrideMimeType('text/html');\n";
  65. echo " http_request.open('POST', url, true);\n";
  66. echo "\n";
  67. echo " if (strpost.length == 0) {\n";
  68. echo " //http_request.send(null);\n";
  69. echo " http_request.send('name=value&foo=bar');\n";
  70. echo " }\n";
  71. echo " else {\n";
  72. echo " http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');\n";
  73. echo " http_request.send(strpost);\n";
  74. echo " }\n";
  75. echo " }\n";
  76. echo "\n";
  77. echo " function returnContent(http_request) {\n";
  78. echo "\n";
  79. echo " if (http_request.readyState == 4) {\n";
  80. echo " if (http_request.status == 200) {\n";
  81. echo " parent.editAreaLoader.setValue('edit1', http_request.responseText); \n";
  82. echo " }\n";
  83. echo " else {\n";
  84. echo " alert('".$text['message-problem']."');\n";
  85. echo " }\n";
  86. echo " }\n";
  87. echo " }\n";
  88. echo "</script>";
  89. echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
  90. //echo "// ---------------------------------------------\n";
  91. //echo "// --- http://www.codeproject.com/jscript/dhtml_treeview.asp\n";
  92. //echo "// --- Name: Easy DHTML Treeview --\n";
  93. //echo "// --- Author: D.D. de Kerf --\n";
  94. //echo "// --- Version: 0.2 Date: 13-6-2001 --\n";
  95. //echo "// ---------------------------------------------\n";
  96. echo "function Toggle(node) {\n";
  97. echo " // Unfold the branch if it isn't visible\n";
  98. echo " if (node.nextSibling.style.display == 'none') {\n";
  99. echo " node.nextSibling.style.display = 'block';\n";
  100. echo " }\n";
  101. echo " // Collapse the branch if it IS visible\n";
  102. echo " else {\n";
  103. echo " node.nextSibling.style.display = 'none';\n";
  104. echo " }\n";
  105. echo "\n";
  106. echo "}\n";
  107. echo "</SCRIPT>";
  108. echo "</head>\n";
  109. echo "<body style='margin: 0; padding: 5px;' onfocus='blur();'>\n";
  110. echo "<div style='text-align: left;'>\n";
  111. $sql = "select * from v_clips order by clip_folder asc, clip_name asc";
  112. $database = new database;
  113. $result = $database->select($sql, null, 'all');
  114. unset($sql);
  115. if (is_array($result) && @sizeof($result) != 0) {
  116. $master_array = array();
  117. foreach ($result as $row) {
  118. $clip_folder = rtrim($row['clip_folder'], '/');
  119. $clip_folder .= '/'.$row['clip_name'];
  120. $parts = explode('/', $clip_folder);
  121. $folders = array();
  122. while ($bottom = array_pop($parts)) {
  123. if (sizeof($folders) > 0) {
  124. $folders = array($bottom => $folders);
  125. }
  126. else {
  127. $clip['uuid'] = $row['clip_uuid'];
  128. $clip['name'] = $row['clip_name'];
  129. $clip['before'] = $row['clip_text_start'];
  130. $clip['after'] = $row['clip_text_end'];
  131. $folders = array($bottom => $clip);
  132. }
  133. }
  134. $master_array = array_merge_recursive($master_array, $folders);
  135. }
  136. function parse_array($array) {
  137. if (is_array($array)) {
  138. foreach ($array as $folder_name => $clips) {
  139. //folder
  140. echo "<a onclick='Toggle(this);' style='display: block; cursor: pointer; text-decoration: none;'><img src='resources/images/icon_folder.png' border='none' align='absmiddle' style='margin: 1px 2px 3px 0px;'>".$folder_name."</a>";
  141. echo "<div style='display: none; padding-left: 16px;'>\n";
  142. //clips
  143. foreach($clips as $row) {
  144. //clip
  145. echo "<div style='white-space: nowrap;'>\n";
  146. echo "<a href='javascript:void(0);' onclick=\"parent.document.getElementById('clip_uuid').value='".$row['uuid']."'; parent.document.getElementById('clip_name').value='".$row['name']."';\">";
  147. echo "<img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>";
  148. echo escape($row['name']);
  149. echo "</a>\n";
  150. echo "<textarea style='display: none' id='before_".$row['uuid']."'>".$row['before']."</textarea>\n";
  151. echo "<textarea style='display: none' id='after_".$row['uuid']."'>".$row['after']."</textarea>\n";
  152. echo "</div>\n";
  153. }
  154. echo "</div>\n";
  155. }
  156. }
  157. }
  158. parse_array($master_array);
  159. }
  160. unset($result, $row);
  161. echo "</div>\n";
  162. //include the footer
  163. require_once "footer.php";