Example #1
0
 public static function get_instance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #2
0
 public function handle_request_internel()
 {
     $self_uri = $this->get_uri();
     $self_url = $this->build_page_url($self_uri);
     $apf = APF::get_instance();
     $params = $this->request->get_parameters();
     $app_send_os = $apf->get_config('app_send_os');
     $app_send_prefer = $apf->get_config('app_send_prefer');
     $request_uri = explode("/", $this->request->get_request_uri());
     $curr_page = $request_uri[3] ? intval($request_uri[3]) : 1;
     $plan_bll = BLL_AppPlan::get_instance();
     $plan_count = $plan_bll->countPlans();
     $offset = ($curr_page - 1) * $this->pagesize;
     $data = $plan_bll->getPlanlist('', '', $offset, $this->pagesize);
     $page_count = ceil(intval($plan_count) / intval($this->pagesize));
     $merge_rows = $this->mergeRows($data);
     $this->request->set_attribute("data", $data);
     $this->request->set_attribute("merge_rows", $merge_rows);
     $this->request->set_attribute("listcount", $plan_count);
     $this->request->set_attribute("app_send_os", $app_send_os);
     $this->request->set_attribute("app_send_prefer", $app_send_prefer);
     $this->request->set_attribute('pageTotalNum', $page_count);
     $this->request->set_attribute('page', $curr_page);
     $this->request->set_attribute('nowurl', $self_uri);
     $this->request->set_attribute('self_url', $self_url);
     $this->request->set_attribute('prev_url', $curr_page > 1 ? $self_url . ($curr_page - 1) : '#');
     $this->request->set_attribute('next_url', $curr_page >= $page_count ? '#' : $self_url . ($curr_page + 1));
     $userId = $this->get_user_id();
     //最近使用菜单
     $menus_total_info = Bll_Menus::get_user_last_menus_info($userId);
     $this->setAttribute("menus_total_info", $menus_total_info);
     return 'App_Index';
 }
Example #3
0
 public function handle_request_internel()
 {
     $apf = APF::get_instance();
     $request = $apf->get_request();
     $params = $request->get_parameters();
     $this->plan_bll = BLL_AppPlan::get_instance();
     $request_uri = explode("/", $this->request->get_request_uri());
     $act = trim($request_uri[3]);
     $aid = intval($request_uri[4]);
     if ($act == 'delete' && is_numeric($aid)) {
         if ($this->deletePlan($aid)) {
             exit("1");
         } else {
             exit("-1");
         }
     }
     if ($act == 'apply' && is_numeric($aid)) {
         if ($this->applyPlan($aid, 1)) {
             exit("1");
         } else {
             exit("-1");
         }
     }
     if ($act == 'cancel' && is_numeric($aid)) {
         if ($this->applyPlan($aid, 0)) {
             exit("1");
         } else {
             exit("-1");
         }
     }
     if ($act == 'edit' && is_numeric($aid)) {
         $edit_data = $this->plan_bll->getPlanInfo($aid);
         if ($edit_data['sendtime'] && strtotime($edit_data['sendtime']) < time()) {
             $this->request->set_attribute("disable_edit", 1);
         }
         $this->request->set_attribute("edit_data", $edit_data);
     }
     if ($params) {
         $isapply = isset($params['isapply']) ? intval($params['isapply']) : 0;
         $send_time = $params['send_time'] ? strtotime($params['send_time']) : '';
         $send_time = $send_time ? date("Y-m-d H:00:00", $send_time) : '';
         if (is_array($params['send_title'])) {
             foreach ($params['send_title'] as $k => $send_title) {
                 $prefer = $params['app_prefer'][$k] ? $params['app_prefer'][$k] : 0;
                 $os = $params['app_os'][$k] ? $params['app_os'][$k] : 0;
                 $image = $params['app_image'][$k] ? $params['app_image'][$k] : '';
                 $title = $params['content_title'][$k] ? $params['content_title'][$k] : '';
                 $desc = $params['content_desc'][$k] ? $params['content_desc'][$k] : '';
                 if ($k == 0 && $params['edit_id'] && is_numeric($params['edit_id'])) {
                     $data = $this->plan_bll->getPlanInfo($params['edit_id']);
                     if ($data) {
                         $this->plan_bll->updateTemplate($data['msgid'], $image, $send_title, $desc, $title);
                         $result = $this->plan_bll->updatePlan($params['edit_id'], $data['msgid'], $prefer, $send_time, $os, $isapply);
                     }
                 } else {
                     $plan_id = $this->plan_bll->addPlan($image, $title, $desc, $prefer, $os, $send_time, $send_title, $isapply);
                 }
             }
         }
     }
     if ($params['edit_id'] && is_numeric($params['edit_id'])) {
         $apf->get_response()->redirect($this->build_page_url('/user/app/edit/' . $params['edit_id']));
     }
     $app_send_os = $apf->get_config('app_send_os');
     $app_send_prefer = $apf->get_config('app_send_prefer');
     $this->request->set_attribute("app_send_os", $app_send_os);
     $this->request->set_attribute("app_send_prefer", $app_send_prefer);
     $userId = $this->get_user_id();
     //最近使用菜单
     $menus_total_info = Bll_Menus::get_user_last_menus_info($userId);
     $this->setAttribute("menus_total_info", $menus_total_info);
     return 'App_Edit';
 }