MenuAction.class.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. *
  4. * Menu(菜单管理)
  5. *
  6. */
  7. if(!defined("Ainaphp")) exit("Access Denied");
  8. class MenuAction extends AdminbaseAction
  9. {
  10. public $dao;
  11. function _initialize()
  12. {
  13. parent::_initialize();
  14. $this->dao = D('Admin/menu');
  15. $this->assign('actionname',$this->getActionName());
  16. }
  17. /**
  18. * 列表
  19. *
  20. */
  21. public function index()
  22. {
  23. $result = $this->menudata;
  24. foreach($result as $r) {
  25. if($r['type']!=1) continue;
  26. $r['str_manage'] = '<a href="'.U('Menu/add',array( 'parentid' => $r['id'])).'">'.L('menu_add_submenu').'</a> | <a href="'.U('Menu/edit',array( 'id' => $r['id'])).'">'.L('edit').'</a> | <a href="javascript:confirm_delete(\''.U('Menu/delete',array( 'id' => $r['id'])).'\')">'.L('delete').'</a> ';
  27. $r['status'] ? $r['status']='<font color="green">'.L('enable').'</font>' : $r['status']='<font color="red">'.L(' disable').'</font>' ;
  28. $array[] = $r;
  29. }
  30. $str = "<tr>
  31. <td width='40' align='center'><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input-text-c'></td>
  32. <td align='center'>\$id</td>
  33. <td >\$spacer\$name</td>
  34. <td align='center'>\$status</td>
  35. <td align='center'>\$str_manage</td>
  36. </tr>";
  37. import ( '@.ORG.Tree' );
  38. $tree = new Tree ($array);
  39. $tree->icon = array('&nbsp;&nbsp;&nbsp;<span>'.L('tree_1').'</span>','&nbsp;&nbsp;&nbsp;<span>'.L('tree_2').'</span>','&nbsp;&nbsp;&nbsp;<span>'.L('tree_3').'</span>');
  40. $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
  41. $select_categorys = $tree->get_tree(0, $str);
  42. $this->assign('select_categorys', $select_categorys);
  43. $this->display();
  44. }
  45. /**
  46. * 提交
  47. *
  48. */
  49. public function _before_add()
  50. {
  51. $parentid = intval($_GET['parentid']);
  52. import ( '@.ORG.Tree' );
  53. $result = $this->menudata;
  54. foreach($result as $r) {
  55. if($r['type']!=1) continue;
  56. $r['selected'] = $r['id'] == $parentid ? 'selected' : '';
  57. $array[] = $r;
  58. }
  59. $str = "<option value='\$id' \$selected>\$spacer \$name</option>";
  60. $tree = new Tree ($array);
  61. $tree->icon = array(L('tree_1'),L('tree_2'),L('tree_3'));
  62. $select_categorys = $tree->get_tree(0, $str,$parentid);
  63. $this->assign('select_categorys', $select_categorys);
  64. }
  65. function edit() {
  66. $id = intval($_GET['id']);;
  67. $vo = $this->menudata[$id];
  68. $parentid = intval($vo['parentid']);
  69. import ( '@.ORG.Tree' );
  70. $result = $this->menudata;
  71. foreach($result as $r) {
  72. if($r['type']!=1) continue;
  73. $r['selected'] = $r['id'] == $parentid ? 'selected' : '';
  74. $array[] = $r;
  75. }
  76. $str = "<option value='\$id' \$selected>\$spacer \$name</option>";
  77. $tree = new Tree ($array);
  78. $tree->icon = array(L('tree_1'),L('tree_2'),L('tree_3'));
  79. $select_categorys = $tree->get_tree(0, $str,$parentid);
  80. $this->assign('select_categorys', $select_categorys);
  81. $this->assign ( 'vo', $vo );
  82. $this->display ();
  83. }
  84. }
  85. ?>