admincp_click.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_click.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. $operation = $operation ? $operation : '';
  12. cpheader();
  13. if(empty($operation)) {
  14. $idtype = in_array($_GET['idtype'], array('blogid', 'picid', 'aid')) ? trim($_GET['idtype']) : 'blogid';
  15. if(!submitcheck('clicksubmit')) {
  16. shownav('style', 'click_edit');
  17. showsubmenu('nav_click', array(
  18. array('click_edit_blogid', 'click&idtype=blogid', $idtype == 'blogid' ? 1 : 0),
  19. array('click_edit_picid', 'click&idtype=picid', $idtype == 'picid' ? 1 : 0),
  20. array('click_edit_aid', 'click&idtype=aid', $idtype == 'aid' ? 1 : 0),
  21. ));
  22. showtips('click_edit_tips');
  23. showformheader('click&idtype='.$idtype);
  24. showtableheader();
  25. showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
  26. '',
  27. cplang('display_order'),
  28. '',
  29. cplang('available'),
  30. cplang('name'),
  31. cplang('click_edit_image'),
  32. cplang('click_edit_type'),
  33. ));
  34. print <<<EOF
  35. <script type="text/JavaScript">
  36. var rowtypedata = [
  37. [
  38. [1,'', 'td25'],
  39. [1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
  40. [1,'', 'td25'],
  41. [1,'<input type="checkbox" name="newavailable[]" value="1">', 'td25'],
  42. [1,'<input type="text" class="txt" name="newname[]" size="10">'],
  43. [1,'<input type="text" class="txt" name="newicon[]" size="20">'],
  44. [1,'', 'td23']
  45. ]
  46. ];
  47. </script>
  48. EOF;
  49. foreach(C::t('home_click')->fetch_all_by_idtype($idtype) as $click) {
  50. $checkavailable = $click['available'] ? 'checked' : '';
  51. $click['idtype'] = cplang('click_edit_'.$click['idtype']);
  52. showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
  53. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$click[clickid]\">",
  54. "<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$click[clickid]]\" value=\"$click[displayorder]\">",
  55. "<img src=\"static/image/click/$click[icon]\">",
  56. "<input class=\"checkbox\" type=\"checkbox\" name=\"available[$click[clickid]]\" value=\"1\" $checkavailable>",
  57. "<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$click[clickid]]\" value=\"$click[name]\">",
  58. "<input type=\"text\" class=\"txt\" size=\"20\" name=\"icon[$click[clickid]]\" value=\"$click[icon]\">",
  59. $click['idtype']
  60. ));
  61. }
  62. echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['click_edit_addnew'].'</a></div></td></tr>';
  63. showsubmit('clicksubmit', 'submit', 'del');
  64. showtablefooter();
  65. showformfooter();
  66. } else {
  67. $ids = array();
  68. if(is_array($_GET['delete'])) {
  69. foreach($_GET['delete'] as $id) {
  70. $ids[] = $id;
  71. }
  72. if($ids) {
  73. C::t('home_click')->delete($ids, true);
  74. }
  75. }
  76. if(is_array($_GET['name'])) {
  77. foreach($_GET['name'] as $id => $val) {
  78. $id = intval($id);
  79. $updatearr = array(
  80. 'name' => dhtmlspecialchars($_GET['name'][$id]),
  81. 'icon' => $_GET['icon'][$id],
  82. 'idtype' => $idtype,
  83. 'available' => intval($_GET['available'][$id]),
  84. 'displayorder' => intval($_GET['displayorder'][$id]),
  85. );
  86. C::t('home_click')->update($id, $updatearr);
  87. }
  88. }
  89. if(is_array($_GET['newname'])) {
  90. foreach($_GET['newname'] as $key => $value) {
  91. if($value != '' && $_GET['newicon'][$key] != '') {
  92. $data = array(
  93. 'name' => dhtmlspecialchars($value),
  94. 'icon' => $_GET['newicon'][$key],
  95. 'idtype' => $idtype,
  96. 'available' => intval($_GET['newavailable'][$key]),
  97. 'displayorder' => intval($_GET['newdisplayorder'][$key])
  98. );
  99. C::t('home_click')->insert($data);
  100. }
  101. }
  102. }
  103. $keys = $ids = $_G['cache']['click'] = array();
  104. foreach(C::t('home_click')->fetch_all_by_available() as $value) {
  105. if(count($_G['cache']['click'][$value['idtype']]) < 8) {
  106. $keys[$value['idtype']] = $keys[$value['idtype']] ? ++$keys[$value['idtype']] : 1;
  107. $_G['cache']['click'][$value['idtype']][$keys[$value['idtype']]] = $value;
  108. } else {
  109. $ids[] = $value['clickid'];
  110. }
  111. }
  112. if($ids) {
  113. C::t('home_click')->update($ids, array('available'=>0), true);
  114. }
  115. updatecache('click');
  116. cpmsg('click_edit_succeed', 'action=click&idtype='.$idtype, 'succeed');
  117. }
  118. }
  119. ?>