示例#1
0
文件: Task.php 项目: nbaiwan/yav
 public function actionLoadTemplateRules($id)
 {
     $template = CollectTemplateModel::inst()->getTemplateById($id);
     if ($template) {
         $rules = array('ok' => true, 'list' => $template['collect_template_list_rules'], 'addons' => $template['collect_template_addons_rules']);
     } else {
         $rules = array('ok' => false);
     }
     echo json_encode($rules);
     exit;
 }
示例#2
0
文件: Template.php 项目: nbaiwan/yav
 public function ruleAction($id)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $template_fields = array();
         if ($_POST['Rule']) {
             $this->db->update('{{collect_template}}', array('collect_template_list_rules' => json_encode($_POST['Rule']['List']), 'collect_template_addons_rules' => json_encode($_POST['Rule']['Addons'])), 'collect_template_id=:collect_template_id', array(':collect_template_id' => intval($id)));
         }
         if (!isset($_GET['ajax'])) {
             $this->redirect[] = array('text' => '', 'href' => '/collect/template/index');
             $this->message('修改模板规则完成', self::MSG_SUCCESS, true);
         }
     }
     $template = CollectTemplateModel::inst()->getTemplateById($id);
     $fields = CollectModelFieldModel::inst()->getFieldsByModelId($template['collect_model_id']);
     foreach ($fields as $_k => $_v) {
         if (isset($template['collect_template_addons_rules'][$_v['collect_fields_identify']])) {
             $template['collect_template_addons_rules'][$_v['collect_fields_identify']] += $_v;
         } else {
             $rules['collect_template_addons_rules'][$_v['collect_fields_identify']] = $_v;
         }
     }
     unset($fields);
     $this->getView()->assign(array('template' => $template));
 }