Пример #1
0
 public function detail()
 {
     $id = intval($this->input['id']);
     if (!$id) {
         $this->output();
     }
     if (!class_exists('programTemplate')) {
         include CUR_CONF_PATH . 'lib/program_template.class.php';
     }
     $objProTemplate = new programTemplate();
     $ret = $objProTemplate->getOneById($id);
     if (!empty($ret['data'])) {
         $date = date('Y-m-d');
         $noon = strtotime($date . ' 12:00');
         $program = array();
         if (is_array($ret['data']) && count($ret['data']) > 0) {
             foreach ($ret['data'] as $k => $v) {
                 $v['start_time'] = strtotime($data . ' ' . $v['start']);
                 if ($v['start_time'] < $noon) {
                     $v['pos'] = hg_get_pos($v['start_time'] - strtotime($date));
                     $v['slider'] = hg_get_slider($v['start_time'] - strtotime($date));
                     $key = 'am';
                 } else {
                     $v['pos'] = hg_get_pos($v['start_time'] - strtotime($date . " 12:00"));
                     $v['slider'] = hg_get_slider($v['start_time'] - strtotime($date . " 12:00"));
                     $key = 'pm';
                 }
                 $v['id'] = $v['key'] = hg_rand_num(4);
                 $program[$key][] = $v;
             }
             $ret['data'] = $program;
         }
     }
     if ($ret) {
         $this->addItem($ret);
     }
     $this->output();
 }
Пример #2
0
 private function getTemplate($channel_id, $dates)
 {
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'program_template_relation WHERE channel_id=' . $channel_id . ' AND date = \'' . $dates . '\'';
     $proTemRelation = $this->db->query_first($sql);
     if (empty($proTemRelation) || !$proTemRelation['template_id']) {
         return array();
     }
     if (!class_exists('programTemplate')) {
         include CUR_CONF_PATH . 'lib/program_template.class.php';
     }
     $objProgramTemplate = new programTemplate();
     $arTemplate = $objProgramTemplate->getOneById($proTemRelation['template_id']);
     $programTemplate = array();
     if (is_array($arTemplate['data']) && count($arTemplate['data']) > 0) {
         foreach ($arTemplate['data'] as $k => $v) {
             $v['start_time'] = strtotime($dates . ' ' . $v['start']);
             $program = array('channel_id' => $channel_id, 'start_time' => $v['start_time'], 'toff' => $v['toff'], 'theme' => $v['theme'], 'subtopic' => '', 'type_id' => 1, 'dates' => $dates, 'weeks' => date('W', $v['start_time']), 'describes' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1, 'color' => '#537ABF,#E5EEFF', 'start' => $v['start'], 'end' => date("H:i", strtotime($v['start_time'] + $v['toff'])), 'week_set' => date('W', strtotime($v['start_time'])), 'item' => $v['item'], 'new' => 0, 'outdate' => $v['start_time'] <= TIMENOW ? 1 : 0, 'is_plan' => 1, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'appid' => $v['appid'], 'appname' => $v['appname']);
             $programTemplate[] = $program;
         }
     }
     return $programTemplate;
 }
Пример #3
0
 public function programTemplateSet()
 {
     $intTemplateId = intval($this->input['templateId']);
     $intChannelId = intval($this->input['channelId']);
     $arDates = !is_array($this->input['date']) ? explode(',', $this->input['date']) : $this->input['date'];
     if (!empty($arDates)) {
         foreach ($arDates as $k => $v) {
             $arDates[$k] = date('Y-m-d', strtotime($v));
         }
     }
     $strDates = implode(',', $arDates);
     if (!$strDates || !$intChannelId) {
         $this->errorOutput('NO DATES OR TEMPALTEID');
     }
     $sql = 'DELETE FROM ' . DB_PREFIX . 'program_template_relation WHERE 1 AND date IN(\'' . implode('\',\'', $arDates) . '\') AND channel_id = ' . $intChannelId;
     $this->db->query($sql);
     if ($intTemplateId) {
         if (!class_exists('programTemplate')) {
             include CUR_CONF_PATH . 'lib/program_template.class.php';
         }
         $objProTemplate = new programTemplate();
         $arTemplateInfo = $objProTemplate->getOneById($intTemplateId);
         if (empty($arTemplateInfo)) {
             $this->errorOutput('NO TEMPLATE');
         }
         foreach ($arDates as $k => $v) {
             $arTmp = array('date' => $v, 'template_id' => $intTemplateId, 'template_title' => $arTemplateInfo['title'], 'channel_id' => $intChannelId, 'intdate' => date('Ymd', strtotime($v)));
             $this->db->insert_data($arTmp, 'program_template_relation');
         }
     }
     $this->addItem('success');
     $this->output();
 }