PageRenderTime 33ms CodeModel.GetById 17ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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