BlockAction.class.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. *
  4. * Posid (推荐位管理)
  5. *
  6. */
  7. if(!defined("Ainaphp")) exit("Access Denied");
  8. class BlockAction extends AdminbaseAction {
  9. protected $dao,$Type;
  10. function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->dao = M(MODULE_NAME);
  14. $this->Type=F('Type');
  15. }
  16. public function index() {
  17. if(APP_LANG)$map['lang']=array('eq',LANG_ID);
  18. $this->_list(MODULE_NAME, $map);
  19. $this->display();
  20. }
  21. public function _before_insert()
  22. {
  23. if(APP_LANG)$_POST['lang']=LANG_ID;
  24. }
  25. public function edit() {
  26. $pos=strip_tags($_REQUEST['pos']);
  27. $name = MODULE_NAME;
  28. $model = M ( $name );
  29. $pk=ucfirst($model->getPk ());
  30. $id = $_REQUEST [$model->getPk ()];
  31. if(empty($id)) $this->error(L('do_empty'));
  32. if($pos){
  33. $map['pos']=array('eq',$pos);
  34. if(APP_LANG)$map['lang']=array('eq',LANG_ID);
  35. $vo = $model->where($map)->find();
  36. }else{
  37. $do='getBy'.$pk;
  38. $vo = $model->$do ( $id );
  39. }
  40. if($vo['setup']) $vo['setup']=string2array($vo['setup']);
  41. $this->assign ( 'vo', $vo );
  42. $this->display ();
  43. }
  44. function delete(){
  45. $name = MODULE_NAME;
  46. $model = M ( $name );
  47. $pk = $model->getPk ();
  48. $id = $_REQUEST [$pk];
  49. if (isset ( $id )) {
  50. if(false!==$model->delete($id)){
  51. delattach(array('moduleid'=>'231','id'=>$id));
  52. $this->success(L('delete_ok'));
  53. }else{
  54. $this->error(L('delete_error').': '.$model->getDbError());
  55. }
  56. }else{
  57. $this->error (L('do_empty'));
  58. }
  59. }
  60. }
  61. ?>