/source/gl/module/module.php

http://prosporous.googlecode.com/ · PHP · 195 lines · 167 code · 13 blank · 15 comment · 39 complexity · f588e66bb54b0af1b3a316476ace498a MD5 · raw file

  1. <?php
  2. /* * ??????UTF-8???.
  3. * Created on 2010-6-3
  4. *
  5. * @author EXT <isrn@qq.com>
  6. *
  7. */
  8. include ('../../includes/global.php');
  9. include ('../global.php');
  10. include ("../power.php");
  11. switch ($_REQUEST['op']) {
  12. case 'updata': {
  13. function getparentidsorts($id, $table) {
  14. //???????
  15. global $db, $prefix;
  16. $sorts = mysql_query("SELECT parentid FROM se_" . $table . " WHERE id='" . $id . "'");
  17. while ($sort = mysql_fetch_array($sorts)) {
  18. $id .=",";
  19. $id .=getparentidsorts($sort[parentid], $table);
  20. }
  21. return $id;
  22. }
  23. function backdselect($id, $table) {
  24. //???????
  25. global $db, $prefix;
  26. mysql_query("UPDATE se_" . $table . " SET plist='" . getparentidsorts($id, $table) . "' WHERE id='" . $id . "'");
  27. //echo "UPDATE ".$prefix."_".$table." SET plist='".getparentidsorts($id,$table)."' WHERE id='".$id."'";
  28. }
  29. if ($_POST['id'] != '') {
  30. if (Du('sevenel', 'sort', $_POST, 'id', $_POST['id'], 1)) backdselect($_POST['id'], 'sort');
  31. ja('????');
  32. }else {
  33. if (Di('sevenel', 'sort', $_POST)) ;
  34. backdselect(mysql_insert_id(), 'sort');
  35. ja('????');
  36. }
  37. ?>
  38. <script>
  39. n=parent.tabs.getActiveTab();
  40. parent.tabs.remove(n);
  41. </script><?php
  42. break;
  43. }
  44. case 'add': {
  45. $drop_down_info = '';
  46. function drop_down($id, $i, $selected, $table, $lang, $mid, $minfo) {
  47. global $drop_down_info;
  48. //fal($id,$i,$selected,$table,$mid,$minfo);
  49. $temp = Dgs($table, " parentid='" . $id . "' and lg like '" . $lang . "' and del != '1'");
  50. if ($temp != '') {
  51. foreach ($temp as $p) { if (@in_array($p['id'], $selected) || $p['id'] == $selected) {
  52. $drop_down_info.="<option value=\"" . $p['id'] . "\" selected=\"selected\">" . str_repeat('--', $i) . $p['title'] . "</option>";
  53. } else {
  54. $drop_down_info.="<option value=\"" . $p['id'] . "\">" . str_repeat('?', $i) . $p['title'] . "</option>";
  55. }
  56. $qq = Dgs($table, " parentid='" . $p['id'] . "' and lg like '" . $lang . "' and del != '1'");
  57. if ($qq != '') { $j = $i + 1;
  58. @drop_down($p[id], $j, $selected, $table, $lang);
  59. }
  60. }
  61. if ($mid !== '' && $minfo != '') {
  62. $drop_down_info = "<option value=\"" . $mid . "\">" . $minfo . "</option>" . $drop_down_info;
  63. }
  64. } else {
  65. if ($mid != '' && $minfo != '') {
  66. $drop_down_info = "<option value=\"" . $mid . "\">" . $minfo . "</option>" . $drop_down_info;
  67. }
  68. }
  69. }
  70. if ($_GET['id']) {
  71. $edite = Dgd(array(
  72. 'db' => 'd_sevenel',
  73. 'cd' => " id = '" . $_GET['id'] . "' and del != '1' ",
  74. 'tn' => "sort",
  75. 'limit' => 1
  76. ));
  77. drop_down(-1, 0, $edite['parentid'], 'sort', 'zh', '-1', '???');
  78. Tr($drop_down_info, 'option');
  79. Tr($edite, 'info');
  80. }
  81. if ($_GET['pid']) {
  82. $edite = Dgd(array(
  83. 'db' => 'd_sevenel',
  84. 'cd' => " id = '" . $_GET['pid'] . "' and del != '1' ",
  85. 'tn' => "sort",
  86. 'limit' => 1
  87. ));
  88. drop_down(-1, 0, $_GET['pid'], 'sort', 'zh', '-1', '???');
  89. Tr($drop_down_info, 'option');
  90. //Tr($edite,'info');
  91. }
  92. // print_r($drop_down_info);
  93. Ts('module/add.html');
  94. break; }
  95. case 'list': {
  96. $_GET['rootIndex'] || $_GET['rootIndex'] = 1;
  97. function buildsortnav($id, $table) {
  98. $navbit = " <a href=\"./module.php?op=list&id=-1\">???</a>";
  99. if ($id != -1) {
  100. $temp = Dga($table, "id ='" . $id . "'");
  101. $zistr = explode(",", $temp[plist]);
  102. $j = count($zistr);
  103. if ($j > 2) {
  104. for ($i = 1; $i < $j - 1; $i++) {
  105. $temp1 = Dga($table, "id ='" . $zistr[$i] . "' ");
  106. $subRootIndex = $temp1['rootIndex'] +1;
  107. $navbit .= " / <a href=\"./module.php?op=list&id=" . $temp1[id] . "&rootIndex={$subRootIndex}\">" . $temp1['title'] . "</a>";
  108. }
  109. }
  110. $subRootIndex = $temp['rootIndex'] +1;
  111. $navbit .= " / <a href=\"./module.php?op=list&id=" . $temp[id] . "&rootIndex={$subRootIndex}\">" . $temp['title'] . "</a>";
  112. }
  113. return $navbit;
  114. }
  115. if (empty($_GET[id])) {
  116. $_GET[id] = "-1";
  117. }
  118. $dcfg['name'] = 'sort';
  119. $sortnav = buildsortnav($_GET[id], $dcfg['name']);
  120. $Tp->assign("sortnav", $sortnav);
  121. if (isset($_POST[offset]) and isset($_POST[pageline])) {
  122. $classtest = new tviewpage("se_" . $dcfg['name'], $_POST[pageline], $_POST[offset]);
  123. //echo "Post";
  124. } elseif (isset($_GET[offset]) and isset($_GET[pageline])) {
  125. $classtest = new tviewpage("se_" . $dcfg['name'], $_GET[pageline], $_GET[offset]);
  126. //echo "GET";
  127. } else {
  128. $offset = 0;
  129. $pageline = 5;
  130. $classtest = new tviewpage("se_" . $dcfg['name'], $pageline, $offset);
  131. //echo "none";
  132. }
  133. $classtest->setCondition(" where parentid=" . $_GET[id] . " and ( title like '%" . $_GET['title'] . "%') and del !='1' ORDER BY `id` asc ");
  134. $classtest->setPageQuery('op', 'list');
  135. $classtest->setPageQuery('id', $_GET[id]);
  136. $classtest->setPageQuery('title', $_GET['title']);
  137. $classtest->setPageQuery('rootIndex', $_GET['rootIndex']);
  138. $recordset = $classtest->getRecords();
  139. ob_start();
  140. $classtest->showFullFunc();
  141. $nav = ob_get_contents();
  142. ob_end_clean();
  143. $Tp->assign("nav", "$nav");
  144. $j = count($recordset);
  145. $content = "";
  146. for ($i = 0; $i < $j; $i++) { $temp = Dga($dcfg['name'], "parentid='" . $recordset[$i][id] . "' and del =0");
  147. $aml = '';
  148. if (!empty($temp)) {
  149. if ($_GET['rootIndex']>0){
  150. $subRootIndex = $_GET['rootIndex']+1;
  151. }else{
  152. $subRootIndex = 1;
  153. }
  154. $aml = " <a href=\"module.php?op=list&id=" . $recordset[$i][id] . "&rootIndex={$subRootIndex}\" title='?????'><font color=red ><b>_|_</b></font> </a>";
  155. }
  156. $content.=" <tr>
  157. <td height=\"25\" bgColor=#ffffff>" . $recordset[$i]['id'] . "</td>
  158. <td height=\"25\" bgColor=#ffffff>" . $aml . "" . $recordset[$i]['title'] . "</td>
  159. <td align=\"middle\" height=\"25\" bgColor=#ffffff>" . $recordset[$i][id] . "</td>
  160. <td align=\"middle\" width=\"235\" height=\"25\" bgColor=#ffffff>
  161. ?<a href=\"#\" onclick=\"sortedit('" . $recordset[$i][id] . "')\"><img src='../img/chart_organisation(1).png' title='?????'></a>?|?<a href=\"./module.php?op=del&id=" . $recordset[$i][id] . "\"><img src='../img/chart_organisation_delete.png' title='?????'></a>?|?<a href=\"#\" onclick=\"sortadd('" . $recordset[$i][id] . "')\"><img src='../img/chart_organisation_add.png' title='?????'></a>?</td>
  162. </tr>";
  163. }
  164. $Tp->assign("content", $content);
  165. Ts('module/list.html');
  166. break; }
  167. case 'del': {
  168. $_POST['del'] = 1;
  169. Du('sevenel', 'sort', $_POST, 'id', $_GET['id'], 0);
  170. ?>
  171. <script>
  172. window.history.back(1);
  173. </script>
  174. <?php
  175. break;
  176. }
  177. default: {
  178. Ts('module/index.html');
  179. break;
  180. }
  181. }
  182. ?>