PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/modules/themes/blocks.php

http://viet-group.googlecode.com/
PHP | 251 lines | 230 code | 14 blank | 7 comment | 15 complexity | b7322361b7c8316b332c742d86c7d41d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-2-2010 12:55
  7. */
  8. if ( ! defined( 'NV_IS_FILE_THEMES' ) ) die( 'Stop!!!' );
  9. $select_options = array();
  10. $theme_array = nv_scandir( NV_ROOTDIR . "/themes", $global_config['check_theme'] );
  11. foreach ( $theme_array as $themes_i )
  12. {
  13. $select_options[NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=blocks&amp;selectthemes=" . $themes_i] = $themes_i;
  14. }
  15. $selectthemes_old = $nv_Request->get_string( 'selectthemes', 'cookie', $global_config['site_theme'] );
  16. $selectthemes = $nv_Request->get_string( 'selectthemes', 'get', $selectthemes_old );
  17. if ( ! in_array( $selectthemes, $theme_array ) )
  18. {
  19. $selectthemes = $global_config['site_theme'];
  20. }
  21. if ( $selectthemes_old != $selectthemes )
  22. {
  23. $nv_Request->set_Cookie( 'selectthemes', $selectthemes, NV_LIVE_COOKIE_TIME );
  24. }
  25. $page_title = $lang_module['blocks'] . ':' . $selectthemes;
  26. $contents .= "<table class=\"tab1\">\n";
  27. $contents .= "<thead>\n";
  28. $contents .= "<tr>\n";
  29. $contents .= "<td colspan='8'>";
  30. $contents .= $lang_module['block_select_module'] . " <select name='module'>";
  31. $contents .= "<option value=''>" . $lang_module['block_select_module'] . "</option>";
  32. $sql = "SELECT title, custom_title FROM `" . NV_MODULES_TABLE . "` ORDER BY `weight` ASC";
  33. $result = $db->sql_query( $sql );
  34. while ( list( $m_title, $m_custom_title ) = $db->sql_fetchrow( $result ) )
  35. {
  36. $contents .= "<option value='" . $m_title . "'>" . $m_custom_title . "</option>";
  37. }
  38. $contents .= "</select>\n";
  39. $contents .= "</td>\n";
  40. $contents .= "</tr>\n";
  41. $contents .= "<tr>\n";
  42. $contents .= "<td>" . $lang_module['block_sort'] . "</td>\n";
  43. $contents .= "<td>" . $lang_module['block_pos'] . "</td>\n";
  44. $contents .= "<td>" . $lang_module['block_title'] . "</td>\n";
  45. $contents .= "<td>" . $lang_module['block_file'] . "</td>\n";
  46. $contents .= "<td>" . $lang_module['block_active'] . "</td>\n";
  47. $contents .= "<td>" . $lang_module['block_func_list'] . "</td>\n";
  48. $contents .= "<td>" . $lang_module['functions'] . "</td>\n";
  49. $contents .= "<td></td>\n";
  50. $contents .= "</tr>\n";
  51. $contents .= "</thead>\n";
  52. $a = 0;
  53. #load position file
  54. $xml = simplexml_load_file( NV_ROOTDIR . '/themes/' . $selectthemes . '/config.ini' );
  55. $content = $xml->xpath( 'positions' ); //array
  56. $positions = $content[0]->position; //object
  57. $blocks_positions = array();
  58. $result = $db->sql_query( "SELECT `position`, count(*) FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE theme='" . $selectthemes . "' GROUP BY `position`" );
  59. while ( list( $position, $numposition ) = $db->sql_fetchrow( $result ) )
  60. {
  61. $blocks_positions[$position] = $numposition;
  62. }
  63. $result = $db->sql_query( "SELECT * FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE theme='" . $selectthemes . "' ORDER BY `position` ASC, `weight` ASC" );
  64. while ( $row = $db->sql_fetchrow( $result ) )
  65. {
  66. $class = ( $a % 2 ) ? " class=\"second\"" : "";
  67. $contents .= "<tbody" . $class . ">\n";
  68. $contents .= "<tr>\n";
  69. $contents .= "<td>";
  70. $contents .= '<select class="order" title="' . $row['bid'] . '">';
  71. $numposition = $blocks_positions[$row['position']];
  72. for ( $i = 1; $i <= $numposition; $i ++ )
  73. {
  74. $sel = ( $row['weight'] == $i ) ? ' selected="selected"' : '';
  75. $contents .= '<option value="' . $i . '" ' . $sel . '>' . $i . '</option>';
  76. }
  77. $contents .= '</select>';
  78. $contents .= "</td>\n";
  79. $contents .= "<td>";
  80. $contents .= "<select name=\"listpos\" title='" . $row['bid'] . "'>\n";
  81. for ( $i = 0; $i < count( $positions ); $i ++ )
  82. {
  83. $sel = ( $row['position'] == $positions[$i]->tag ) ? ' selected="selected"' : '';
  84. $contents .= "<option value=\"" . $positions[$i]->tag . "\" " . $sel . "> " . $positions[$i]->name . '</option>';
  85. }
  86. $contents .= "</select>";
  87. $contents .= "</td>\n";
  88. $contents .= "<td>" . $row['title'] . "</td>\n";
  89. $contents .= "<td>" . $row['module'] . " " . $row['file_name'] . "</td>\n";
  90. $contents .= "<td>" . ( $row['active'] ? $lang_global['yes'] : $lang_global['no'] ) . "</td>\n";
  91. $contents .= "<td>";
  92. if ( $row['all_func'] == 1 )
  93. {
  94. $contents .= $lang_module['add_block_all_module'];
  95. }
  96. else
  97. {
  98. $result_func = $db->sql_query( "SELECT a.func_id, a.in_module, a.func_custom_name FROM `" . NV_MODFUNCS_TABLE . "` AS a INNER JOIN `" . NV_BLOCKS_TABLE . "_weight` AS b ON a.func_id=b.func_id WHERE b.bid=" . $row['bid'] . "" );
  99. while ( list( $funcid_inlist, $func_inmodule, $funcname_inlist ) = $db->sql_fetchrow( $result_func ) )
  100. {
  101. $contents .= '<a href="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=blocks_func&amp;func=' . $funcid_inlist . '&amp;module=' . $func_inmodule . '"><span style="font-weight:bold">' . $func_inmodule . '</span>: ' . $funcname_inlist . '</a><br />';
  102. }
  103. }
  104. $contents .= "</td>\n";
  105. $contents .= "<td align=\"center\"><span class=\"edit_icon\"><a class=\"block_content\" title=\"" . $row['bid'] . "\" href=\"javascript:void(0);\">" . $lang_global['edit'] . "</a></span>\n";
  106. $contents .= "&nbsp;-&nbsp;<span class=\"delete_icon\"><a class=\"delete\" title=\"" . $row['bid'] . "\" href=\"javascript:void(0);\">" . $lang_global['delete'] . "</a></span></td>\n";
  107. $contents .= "<td><input type='checkbox' name='idlist' value='" . $row['bid'] . "'/></td>\n";
  108. $contents .= "</tr>\n";
  109. $contents .= "</tbody>\n";
  110. $a ++;
  111. }
  112. $contents .= "<tbody>\n";
  113. $contents .= "<tr align=\"right\" class=\"tfoot_box\"><td colspan='8'>
  114. <span class=\"edit_icon\"><a class=\"block_weight\" href=\"javascript:void(0);\">" . $lang_module['block_weight'] . "</a></span>&nbsp;&nbsp;&nbsp;&nbsp;
  115. <span class=\"add_icon\"><a class=\"block_content\" href=\"javascript:void(0);\">" . $lang_module['block_add'] . "</a></span>&nbsp;&nbsp;&nbsp;&nbsp;
  116. <span class=\"delete_icon\"><a class=\"delete_group\" href=\"javascript:void(0);\">" . $lang_global['delete'] . "</a></span>
  117. <span style='width:100px;display:inline-block'>&nbsp;</span>
  118. <span>
  119. <a name=\"checkall\" id=\"checkall\" href=\"javascript:void(0);\">" . $lang_module['block_checkall'] . "</a>&nbsp;&nbsp;
  120. <a name=\"uncheckall\" id=\"uncheckall\" href=\"javascript:void(0);\">" . $lang_module['block_uncheckall'] . "</a>
  121. </span>
  122. </td></tr>";
  123. $contents .= "</tbody>\n";
  124. $contents .= "</table>\n";
  125. $contents .= '<script type="text/javascript">
  126. //<![CDATA[
  127. $(function(){
  128. $("a.block_content").click(function(){
  129. var bid = parseInt($(this).attr("title"));
  130. Shadowbox.open(
  131. {
  132. content : "<iframe src=\"' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=block_content&bid="+bid+"&blockredirect=' . nv_base64_encode( $client_info['selfurl'] ) . '\" border=\"1\" frameborder=\"0\" style=\"width:780px;height:450px\"></iframe>",
  133. player : "html",
  134. height : 450,
  135. width : 780
  136. }
  137. );
  138. });
  139. $("select.order").change(function(){
  140. $("select.order").attr({"disabled":""});
  141. var order = $(this).val();
  142. var bid = $(this).attr("title");
  143. $.ajax({
  144. type: "POST",
  145. url: "index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_change_order_group",
  146. data: "order="+order+"&bid="+bid,
  147. success: function(data){
  148. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  149. }
  150. });
  151. });
  152. $("select[name=module]").change(function(){
  153. var module = $(this).val();
  154. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_func&module="+module;
  155. });
  156. $("a.delete").click(function(){
  157. var bid = parseInt($(this).attr("title"));
  158. if (bid > 0 && confirm(" ' . $lang_module['block_delete_per_confirm'] . '")){
  159. $.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=blocks_del", "bid="+bid, function(theResponse){
  160. alert(theResponse);
  161. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  162. });
  163. }
  164. });
  165. $("a.block_weight").click(function(){
  166. if (confirm(" ' . $lang_module['block_weight_confirm'] . '")){
  167. $.post("' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=themes&' . NV_OP_VARIABLE . '=blocks_reset_order", "checkss=' . md5( $selectthemes . $global_config['sitekey'] . session_id() ) . '", function(theResponse){
  168. alert(theResponse);
  169. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  170. });
  171. }
  172. });
  173. $("a.delete_group").click(function(){
  174. var list = [];
  175. $("input[name=idlist]:checked").each(function(){
  176. list.push($(this).val());
  177. });
  178. if (list.length<1){
  179. alert(" ' . $lang_module['block_error_noblock'] . '");
  180. return false;
  181. }
  182. if (confirm(" ' . $lang_module['block_delete_confirm'] . '")){
  183. $.ajax({
  184. type: "POST",
  185. url: "index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_del_group",
  186. data:"list="+list,
  187. success: function(data){
  188. alert(data);
  189. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  190. }
  191. });
  192. }
  193. return false;
  194. });
  195. $("#checkall").click(function(){
  196. $("input[name=idlist]:checkbox").each(function(){
  197. $(this).attr("checked","checked");
  198. });
  199. });
  200. $("#uncheckall").click(function(){
  201. $("input[name=idlist]:checkbox").each(function(){
  202. $(this).removeAttr("checked");
  203. });
  204. });
  205. $("select[name=listpos]").change(function(){
  206. var pos = $(this).val();
  207. var bid = $(this).attr("title");
  208. $.ajax({
  209. type: "POST",
  210. url: "index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_change_pos",
  211. data:"bid="+bid+"&pos="+pos,
  212. success: function(data){
  213. alert(data);
  214. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  215. }
  216. });
  217. });
  218. });
  219. //]]>
  220. </script>';
  221. if ( ! defined( 'SHADOWBOX' ) )
  222. {
  223. $my_head = "<link type=\"text/css\" rel=\"Stylesheet\" href=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.css\" />\n";
  224. $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.js\"></script>\n";
  225. $my_head .= "<script type=\"text/javascript\">Shadowbox.init();</script>";
  226. define( 'SHADOWBOX', true );
  227. }
  228. include ( NV_ROOTDIR . "/includes/header.php" );
  229. echo nv_admin_theme( $contents );
  230. include ( NV_ROOTDIR . "/includes/footer.php" );
  231. ?>