PageRenderTime 25ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/admincp/modules/themes/blocks.php

http://creative-portal.googlecode.com/
PHP | 203 lines | 188 code | 8 blank | 7 comment | 16 complexity | 76cd4e7ace608131a8a1696357af9cfb 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 . "&" . NV_OP_VARIABLE . "=blocks&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></td>\n";
  30. $contents .= "<td>" . $lang_module['block_select_module'] . ":</td>\n";
  31. $contents .= "<td colspan='5'>";
  32. $contents .= "<select name='module'>";
  33. $contents .= "<option value=''>" . $lang_module['block_select_module'] . "</option>";
  34. $sql = "SELECT title, custom_title FROM `" . NV_MODULES_TABLE . "` ORDER BY `weight` ASC";
  35. $result = $db->sql_query( $sql );
  36. while ( list( $m_title, $m_custom_title ) = $db->sql_fetchrow( $result ) )
  37. {
  38. $contents .= "<option value='" . $m_title . "'>" . $m_custom_title . "</option>";
  39. }
  40. $contents .= "</select>\n";
  41. $contents .= "</td>\n";
  42. $contents .= "</tr>\n";
  43. $contents .= "<tr>\n";
  44. $contents .= "<td></td>\n";
  45. $contents .= "<td>" . $lang_module['block_pos'] . "</td>\n";
  46. $contents .= "<td>" . $lang_module['block_title'] . "</td>\n";
  47. $contents .= "<td>" . $lang_module['block_file'] . "</td>\n";
  48. $contents .= "<td>" . $lang_module['block_active'] . "</td>\n";
  49. $contents .= "<td>" . $lang_module['block_func_list'] . "</td>\n";
  50. $contents .= "<td></td>\n";
  51. $contents .= "</tr>\n";
  52. $contents .= "</thead>\n";
  53. $a = 0;
  54. $query = "SELECT * FROM `" . NV_BANNERS_PLANS_GLOBALTABLE . "` WHERE (`blang`='" . NV_LANG_DATA . "' OR `blang`='') ORDER BY `title` ASC";
  55. $result = $db->sql_query( $query );
  56. $banners_pl_list = array();
  57. while ( $row_bpn = $db->sql_fetchrow( $result ) )
  58. {
  59. $banners_pl_list[$row_bpn['id']] = $row_bpn;
  60. }
  61. #load position file
  62. $xml = simplexml_load_file( NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini' );
  63. $content = $xml->xpath( 'positions' ); //array
  64. $positions = $content[0]->position; //object
  65. $result = $db->sql_query( "SELECT bid, groupbl, title, type, file_path, position, all_func, func_id, weight, exp_time, active FROM `" . NV_BLOCKS_TABLE . "` WHERE theme='" . $selectthemes . "' GROUP BY `groupbl` ORDER BY `position` ASC" );
  66. while ( $row = $db->sql_fetchrow( $result ) )
  67. {
  68. $class = ( $a % 2 ) ? " class=\"second\"" : "";
  69. $contents .= "<tbody" . $class . ">\n";
  70. $contents .= "<tr>\n";
  71. $contents .= "<td><input type='checkbox' name='idlist' value='" . $row['groupbl'] . "'/></td>\n";
  72. $contents .= "<td>";
  73. $contents .= "<select name=\"listpos\" id='" . $row['groupbl'] . "'>\n";
  74. for ( $i = 0; $i < count( $positions ); $i ++ )
  75. {
  76. $sel = ( $row['position'] == $positions[$i]->tag ) ? ' selected' : '';
  77. $contents .= "<option value=\"" . $positions[$i]->tag . "\" " . $sel . "> " . $positions[$i]->name . '</option>';
  78. }
  79. $contents .= "</select>";
  80. $contents .= "</td>\n";
  81. $contents .= "<td>" . $row['title'] . "</td>\n";
  82. $contents .= "<td>";
  83. if ( $row['type'] == 'html' )
  84. {
  85. $contents .= $lang_module['block_typehtml'];
  86. }
  87. elseif ( $row['type'] == 'banner' )
  88. {
  89. $idbn = intval( $row['file_path'] );
  90. $contents .= "<strong>banner:</strong> " . $banners_pl_list[$idbn]['title'];
  91. }
  92. elseif ( $row['type'] == 'rss' )
  93. {
  94. $array_rrs = explode( "#@#", $row['file_path'] );
  95. $contents .= "<strong>Rss:</strong> " . $array_rrs[0];
  96. }
  97. else
  98. {
  99. $contents .= $row['file_path'];
  100. }
  101. $contents .= "</td>\n";
  102. $contents .= "<td>" . ( $row['active'] ? $lang_global['yes'] : $lang_global['no'] ) . "</td>\n";
  103. $contents .= "<td>";
  104. if ( $row['all_func'] == 1 )
  105. {
  106. $contents .= $lang_module['add_block_all_module'];
  107. }
  108. else
  109. {
  110. $result_func = $db->sql_query( "SELECT a.func_id,b.in_module, b.func_custom_name FROM `" . NV_BLOCKS_TABLE . "` a INNER JOIN `" . NV_MODFUNCS_TABLE . "` b ON a.func_id=b.func_id WHERE groupbl=" . $row['groupbl'] . "" );
  111. while ( list( $funcid_inlist, $func_inmodule, $funcname_inlist ) = $db->sql_fetchrow( $result_func ) )
  112. {
  113. $contents .= '<a href="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_list&func=' . $funcid_inlist . '&module=' . $func_inmodule . '"><span style="font-weight:bold">' . $func_inmodule . '</span>: ' . $funcname_inlist . '</a><br />';
  114. }
  115. }
  116. $contents .= "</td>\n";
  117. $contents .= "<td align=\"center\" width='50px'><span class=\"edit_icon\"><a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=add&amp;bid=" . $row['bid'] . "#edit\">" . $lang_global['edit'] . "</a></span>\n";
  118. $contents .= "&nbsp;-&nbsp;<span class=\"delete_icon\"><a class='delete' rel='" . $row['groupbl'] . "' href=\"javascript:void(0);\">" . $lang_global['delete'] . "</a></span></td>\n";
  119. $contents .= "</tr>\n";
  120. $contents .= "</tbody>\n";
  121. $a ++;
  122. }
  123. $contents .= "<tfoot><tr><td colspan='9'>
  124. <span>
  125. <a name=\"checkall\" id=\"checkall\" href=\"javascript:void(0);\">" . $lang_module['block_checkall'] . "</a>
  126. &nbsp;&nbsp;<a name=\"uncheckall\" id=\"uncheckall\" href=\"javascript:void(0);\">" . $lang_module['block_uncheckall'] . "</a>&nbsp;&nbsp;
  127. </span><span style='width:100px;display:inline-block'>&nbsp;</span>
  128. <span class=\"delete_icon\"><a class='delete' href=\"javascript:void(0);\">" . $lang_global['delete'] . "</a></span>
  129. <span class=\"add_icon\"><a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=add\">" . $lang_global['add'] . "</a></span>
  130. </td></tr></tfoot>";
  131. $contents .= "</table>\n";
  132. $contents .= '
  133. <script type="text/javascript">
  134. $(function(){
  135. $("select[name=module]").change(function(){
  136. var module = $(this).val();
  137. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_list&module="+module;
  138. });
  139. $("a.delete").click(function(){
  140. var rel = $(this).attr("rel");
  141. if (rel!=0){
  142. list = rel;
  143. } else {
  144. var list = [];
  145. $("input[name=idlist]:checked").each(function(){
  146. list.push($(this).val());
  147. });
  148. if (list.length<1){
  149. alert(" ' . $lang_module['block_error_noblock'] . '");
  150. return false;
  151. }
  152. }
  153. if (confirm(" ' . $lang_module['block_delete_confirm'] . '")){
  154. $.ajax({
  155. type: "POST",
  156. url: "index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_del_group",
  157. data:"list="+list,
  158. success: function(data){
  159. alert(data);
  160. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  161. }
  162. });
  163. }
  164. return false;
  165. });
  166. $("#checkall").click(function(){
  167. $("input[name=idlist]:checkbox").each(function(){
  168. $(this).attr("checked","checked");
  169. });
  170. });
  171. $("#uncheckall").click(function(){
  172. $("input[name=idlist]:checkbox").each(function(){
  173. $(this).removeAttr("checked");
  174. });
  175. });
  176. $("select[name=listpos]").change(function(){
  177. var pos = $(this).val();
  178. var id = $(this).attr("id");
  179. $.ajax({
  180. type: "POST",
  181. url: "index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks_change_pos",
  182. data:"pos="+pos+"&groupbl="+id,
  183. success: function(data){
  184. window.location="index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=blocks";
  185. }
  186. });
  187. });
  188. });
  189. </script>
  190. ';
  191. include ( NV_ROOTDIR . "/includes/header.php" );
  192. echo nv_admin_theme( $contents );
  193. include ( NV_ROOTDIR . "/includes/footer.php" );
  194. ?>