Example #1
0
 /**
  * 初始化FAQ数据
  */
 public function init()
 {
     $data = array();
     $data['title'] = 'faq title';
     $data['content'] = 'I am a faq ';
     Myfaq::instance()->add($data);
 }
Example #2
0
 /**
  * init site data
  * 
  * @param int $site_id
  * @param int $theme_id
  * @return boolean
  */
 public static function init($site_id, $theme_id = 1)
 {
     $type = 0;
     //doc default info
     //Mydoc::instance()->init($site_id);
     site::doc_init($site_id);
     //faq default info
     Myfaq::instance()->init($site_id);
     //seo default info
     Myseo::instance()->init($site_id);
     //route default info
     Myroute::instance()->init($site_id);
     //menu default info
     Mysite_menu::instance()->init($site_id);
     //theme default info
     Mytheme::instance($theme_id)->init($site_id);
     //mail default info
     Mymail::instance()->init($site_id);
     //product default info
     //Mydata_import::instance()->import($site_id);
 }
Example #3
0
 /**
  * 批量删除faq
  */
 public function batch_delete()
 {
     //初始化返回数据
     $return_data = array();
     //请求结构体
     $request_data = array();
     try {
         $faq_ids = $this->input->post('faq_ids');
         if (is_array($faq_ids) && count($faq_ids) > 0) {
             /* 删除失败的 */
             $failed_faq_names = '';
             /* 执行操作 */
             foreach ($faq_ids as $key => $faq_id) {
                 if (!Myfaq::instance($faq_id)->delete()) {
                     $failed_faq_names .= ' | ' . $faq_id;
                 }
             }
             if (empty($failed_faq_names)) {
                 throw new MyRuntimeException(Kohana::lang('o_site.delete_faq_success'), 403);
             } else {
                 /* 中转提示页面的停留时间 */
                 $return_struct['action']['time'] = 10;
                 $failed_faq_names = trim($failed_faq_names, ' | ');
                 throw new MyRuntimeException(Kohana::lang('o_site.delete_faq_error', $failed_faq_names), 403);
             }
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.data_load_error'), 403);
         }
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template = new View('layout/empty_html');
             $this->template->content = $return_struct['msg'];
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             /* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             /* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }