Esempio n. 1
0
 public function handle_request()
 {
     $id = $this->get_topic_id_from_url();
     Bll_Topic::del_topic($id);
     $url = 'http://' . $_SERVER['HTTP_HOST'] . '/user/topic/';
     $this->response->redirect($url);
 }
Esempio n. 2
0
 public function handle_request_internel()
 {
     $p = $this->request->get_parameters();
     $page = 1;
     if (isset($p['page'])) {
         $page = (int) $p['page'];
     }
     //分页的链接
     $prev = $page === 1 ? 1 : $page - 1;
     $next = $page + 1;
     $prev_uri = '/user/topic/?page=' . $prev;
     $next_uri = '/user/topic/?page=' . $next;
     if ($p['key']) {
         $prev_uri .= '&key=' . $p['key'];
         $next_uri .= '&key=' . $p['key'];
     }
     $prev_url = PageHelper::gen_url($prev_uri);
     $next_url = PageHelper::gen_url($next_uri);
     $topic_list = Bll_Topic::get_list($p, $page);
     foreach ($topic_list as $k => $v) {
         $topic_list[$k]['topic_update'] = date('Y-m-d H:i:s', $v['topic_update']);
         $topic_list[$k]['topic_url'] = 'http://topic.anjuke.com/cms/' . $v['topic_id'] . '.html';
         $topic_list[$k]['edit_url'] = PageHelper::gen_url('/user/topic/edit/' . $v['topic_id']);
         $topic_list[$k]['del_url'] = PageHelper::gen_url('/user/topic/del/' . $v['topic_id']);
     }
     $this->request->set_attribute('topic_list', $topic_list);
     $this->request->set_attribute('prev_url', $prev_url);
     $this->request->set_attribute('next_url', $next_url);
     return 'Topic_List';
 }
Esempio n. 3
0
 public function handle_request()
 {
     $p = $this->request->get_parameters();
     $topic_id = $p['topic_id'];
     $r = Bll_Topic::get_topic_info_api($topic_id);
     header('Content-Type: application/json; charset=utf-8');
     echo json_encode($r);
 }
Esempio n. 4
0
 private function update_topic_info($p, $id)
 {
     $info_index = Bll_Topic::get_index_info($id);
     $basic = array('topic_title' => $p['title'], 'topic_update' => time(), 'topic_create' => $info_index['topic_create'], 'topic_is_deleted' => 0);
     $in1 = $this->upload_prop_image($p);
     $in2 = $this->upload_tp2_right_img($in1);
     $in3 = $this->upload_tp3_right_img($in2);
     $in4 = $this->upload_nav_img($in3);
     Bll_Topic::update_topic($id, $basic, $in4);
     $url = 'http://' . $_SERVER['HTTP_HOST'] . '/user/topic/';
     $this->response->redirect($url);
 }
Esempio n. 5
0
 private function handle_form($p)
 {
     $preview = $p['preview'];
     //基本信息
     $basic = array('topic_title' => $p['title'], 'topic_update' => time(), 'topic_create' => time(), 'topic_is_deleted' => $preview);
     //补充上传文件
     $upload_files = array();
     $upload_files_ids = array();
     foreach ($_FILES as $k => $v) {
         if (is_array($v['tmp_name'])) {
             $upload_files[$k] = array_values($v['tmp_name']);
         } else {
             $upload_files[$k] = $v['tmp_name'];
         }
     }
     foreach ($upload_files as $input_name => $tmp_name) {
         if (is_array($tmp_name)) {
             foreach ($tmp_name as $k => $v) {
                 if (file_exists($v)) {
                     $upload_files_ids[$input_name][$k] = $this->upload($v);
                 } else {
                     $upload_files_ids[$input_name][$k] = '';
                 }
             }
         } else {
             if (file_exists($tmp_name)) {
                 $upload_files_ids[$input_name] = $this->upload($tmp_name);
             }
         }
     }
     //详细信息
     unset($p['preview']);
     $info = array_merge($p, $upload_files_ids);
     $topic_id = Bll_Topic::add_topic($basic, $info);
     if ($preview === '0') {
         //保存
         $url = 'http://' . $_SERVER['HTTP_HOST'] . '/user/topic/';
     } else {
         //预览
         $preview_host = APF::get_instance()->get_config('preview_host');
         $url = $preview_host . $topic_id . '.html?act=preview';
     }
     $this->response->redirect($url);
 }