Пример #1
0
 public function indexAction()
 {
     $model_arr = CollectModelModel::inst()->getModelsByCache();
     $source_arr = CollectSourceModel::inst()->getSourcesByCache();
     $collect_source_id = isset($_GET['collect_source_id']) ? intval($_GET['collect_source_id']) : null;
     $collect_model_id = isset($_GET['collect_model_id']) ? intval($_GET['collect_model_id']) : null;
     $searchKey = isset($_GET['searchKey']) ? trim($_GET['searchKey']) : null;
     $this->getView()->assign(array('templates' => CollectTemplateModel::inst()->Pages(array('allow_cache' => false, 'collect_model_id' => $collect_model_id, 'collect_source_id' => $collect_source_id, 'searchKey' => $searchKey)), 'model_arr' => $model_arr, 'source_arr' => $source_arr));
 }
Пример #2
0
 public function updateAction($id)
 {
     $task = CollectTaskModel::inst()->getTaskById($id);
     if (empty($task)) {
         $this->redirect[] = array('text' => '', 'href' => '/collect/task/index');
         $this->message('采集规则不存在或已被删除', self::MSG_ERROR, true);
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['Task']) || !is_array($_POST['Task'])) {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存采集任务信息错误', self::MSG_ERROR, true);
         }
         if ($_POST['Task']['collect_task_name'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('采集任务名称不能为空', self::MSG_ERROR, true);
         }
         if ($_POST['Task']['collect_template_id'] == '') {
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('请选择一个采集模板', self::MSG_ERROR, true);
         }
         $flag = $this->db->update('{{collect_task}}', array('collect_task_name' => $_POST['Task']['collect_task_name'], 'collect_template_id' => $_POST['Task']['collect_template_id'], 'collect_task_urls' => $_POST['Task']['collect_task_urls'], 'collect_task_list_rules' => json_encode($_POST['Task']['List']), 'collect_task_addons_rules' => json_encode($_POST['Task']['Addons']), 'collect_task_rank' => isset($_POST['Task']['collect_task_rank']) ? $_POST['Task']['collect_task_rank'] : 255, 'collect_task_lasttime' => $_SERVER['REQUEST_TIME']), 'collect_task_id=:collect_task_id', array(':collect_task_id' => $id));
         if ($flag) {
             //记录操作日志
             $message = '{user_name}修改了采集任务{collect_task_name}';
             $data = array('collect_task_name' => $_POST['Task']['collect_task_name'], 'data' => array('ori' => $task, 'new' => $_POST['Task']));
             UserLogsModel::inst()->add('Collect/Task', $id, 'Modify', 'success', $message, $data);
             if (!isset($_GET['ajax'])) {
                 $this->redirect[] = array('text' => '', 'href' => '/collect/task/index');
                 $this->message('保存采集任务成功', self::MSG_SUCCESS, true);
             }
         } else {
             //记录操作日志
             $message = '{user_name}修改采集任务({collect_task_name})信息失败';
             $data = array('collect_task_name' => $_POST['Task']['collect_task_name'], 'data' => $_POST['Task']);
             UserLogsModel::inst()->add('Collect/Task', $id, 'Modify', 'failure', $message, $data);
             $this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
             $this->message('保存采集任务失败', self::MSG_ERROR, true);
         }
     }
     $models = CollectModelModel::inst()->getModelsByCache();
     $sources = CollectSourceModel::inst()->getSourcesByCache();
     $templates = CollectTemplateModel::inst()->getTemplatesByCache();
     $charsets = CollectTaskModel::getCharsets();
     //
     $task['template'] = CollectTemplateModel::inst()->getTemplateById($task['collect_template_id']);
     $this->getView()->assign(array('task' => $task, 'models' => $models, 'sources' => $sources, 'templates' => $templates, 'charsets' => $charsets));
 }
Пример #3
0
 public function deleteAction($id)
 {
     $collect_source_name = CollectSourceModel::inst()->getSourceNameById($id);
     $this->db->update('{{collect_source}}', array('collect_source_status' => CollectSourceModel::STAT_STATUS_DELETED), 'collect_source_id=:collect_source_id', array(':collect_source_id' => $id));
     CollectSourceModel::inst()->updateCache();
     //记录操作日志
     $message = '{user_name}删除了采集来源{collect_source_name}';
     $data = array('collect_source_name' => $collect_source_name, 'addons_data' => array('collect_source_id' => $id));
     UserLogsModel::inst()->add('Collect/Source', $id, 'Delete', 'success', $message, $data);
     if (!isset($_GET['ajax'])) {
         $this->redirect('/collect/source/index');
     }
 }