private function _addData() { $usedDataids = array(); $ds = Wekit::load('design.PwDesignData'); Wind::import('SRV:design.dm.PwDesignDataDm'); $time = Pw::getTime(); list($start, $end, $refresh) = $this->bo->refreshTime($time); $orderid = $ds->getMaxOrder($this->bo->moduleid); foreach ($this->sourData as $k => $v) { if (!isset($v['standard_title']) && $v['from_type'] == 'auto') { continue; } $orderid++; $dm = new PwDesignDataDm(); $dm->setDatatype(PwDesignData::AUTO)->setFromType(PwDesignData::FROM_AUTO)->setFromApp($v['standard_fromapp'])->setFromid($v['standard_fromid'])->setModuleid($this->bo->moduleid)->setStandard($v['standard'])->setVieworder($orderid)->setStarttime($time)->setEndtime($refresh); if ($v['from_type'] == 'push') { $dm->setFromType(PwDesignData::FROM_PUSH)->setVieworder($v['vieworder']); } if (isset($v['bold'])) { $dm->setStyle($v['bold'], $v['underline'], $v['italic'], $v['color']); } $extend = $this->getExtend($v); $dm->setExtend($extend); $resource = $ds->addData($dm); if (isset($extend['__asyn'])) { $imageDs->updateDataId($extend['__asyn'], $resource); } } }
public function doeditAction() { $dataid = (int) $this->getInput('dataid', 'post'); $info = $this->_getDataDs()->getData($dataid); if (!$info) { $this->showError("operate.fail"); } $orderid = $info['vieworder']; $start = $this->getInput('start_time', 'post'); $end = $this->getInput('end_time', 'post'); $data = $this->getInput('data', 'post'); $images = $this->getInput('images', 'post'); $bold = $this->getInput('bold', 'post'); $italic = $this->getInput('italic', 'post'); $underline = $this->getInput('underline', 'post'); $color = $this->getInput('color', 'post'); $standard = $this->_getDesignService()->getStandardSignkey($this->bo->getModel()); if (!$data[$standard['sTitle']]) { $this->showError("operate.fail"); } foreach ($images as $k => $v) { if ($_FILES[$k]['name'] && ($image = $this->_uploadFile($k, $this->bo->moduleid))) { $data[$k] = $image; } else { $data[$k] = $v; } } $time = Pw::getTime(); $startTime = $start ? Pw::str2time($start) : $time; $endTime = $end ? Pw::str2time($end) : $end; if ($end && $endTime < $time) { $this->showError("DESIGN:endtimd.error"); } Wind::import('SRV:design.dm.PwDesignDataDm'); $dm = new PwDesignDataDm($dataid); $dm->setStyle($bold, $underline, $italic, $color)->setExtend($data)->setStarttime($startTime)->setEndtime($endTime); //推送的数据,不打修改标识 if ($info['from_type'] == PwDesignData::FROM_AUTO) { $dm->setEdited(1); } if ($startTime > $time) { $dm->setReservation(1); } $this->_getDataDs()->updateData($dm); if ($info['from_type'] == PwDesignData::FROM_PUSH) { Wind::import('SRV:design.dm.PwDesignPushDm'); $pushDm = new PwDesignPushDm($info['from_id']); $pushDm->setStyle($bold, $underline, $italic, $color)->setExtend($data)->setStartTime($startTime)->setEndTime($endTime)->setModuleId($info['module_id']); $this->_getPushDs()->updatePush($pushDm); } $this->showMessage("operate.success", 'design/data/run?moduleid=' . $this->bo->moduleid, true); }
private function _addData() { $delDataIds = $newOrderIds = array(); $delImages = ''; $delImgIds = array(); $ds = Wekit::load('design.PwDesignData'); $pushDs = Wekit::load('design.PwDesignPush'); $imageDs = Wekit::load('design.PwDesignAsynImage'); Wind::import('SRV:design.dm.PwDesignDataDm'); list($start, $end, $refresh) = $this->bo->refreshTime($this->time); foreach ($this->designData as $k => $v) { $k++; if (!$v) { $newOrderIds[] = $k; continue; } if ($v['from_type'] == PwDesignData::FROM_PUSH) { if (isset($this->_newPushIds[$v['from_id']])) { if ($v['data_type'] == PwDesignData::ISFIXED) { unset($this->_newPushIds[$v['from_id']]); continue; } $data = $this->formatDesginData($v); $data['vieworder'] = $this->_newPushIds[$v['from_id']]['vieworder']; $data['from_type'] = $this->_newPushIds[$v['from_id']]['from_type']; if (!$this->_newPushIds[$v['from_id']]['vieworder'] && !$data['is_edited']) { $data['data_type'] = PwDesignData::AUTO; } $this->_newPushIds[$v['from_id']] = $data; $delDataIds[] = $v['data_id']; // $delImages .= $data['standard_image']; unset($v); } } if ($v['from_type'] == PwDesignData::FROM_AUTO) { if (isset($this->_newAutoIds[$v['from_id']])) { if ($v['data_type'] == PwDesignData::ISFIXED) { $ds->updateEndTime($v['data_id'], $refresh); unset($this->_newAutoIds[$v['from_id']]); continue; } $data = $this->formatDesginData($v); $data['vieworder'] = $this->_newAutoIds[$v['from_id']]['vieworder']; $data['from_type'] = $this->_newAutoIds[$v['from_id']]['from_type']; $this->_newAutoIds[$v['from_id']] = $data; $delDataIds[] = $v['data_id']; $delImages .= $data['standard_image']; isset($data['__asyn']) && ($delImgIds[] = $data['__asyn']); unset($v); } } if ($v) { if ($v['data_type'] == PwDesignData::ISFIXED) { continue; } $delDataIds[] = $v['data_id']; if ($v['from_type'] != PwDesignData::FROM_PUSH) { $extend = unserialize($v['extend_info']); $delImages .= $extend['standard_image']; isset($data['__asyn']) && ($delImgIds[] = $data['__asyn']); } } $newOrderIds[] = $k; } $ds->batchDelete($delDataIds); if ($delImages) { Wekit::load('design.srv.PwDesignImage')->clearFiles($this->bo->moduleid, explode('|||', $delImages)); } if ($delImgIds) { Wekit::load('design.PwDesignAsynImage')->batchDelete($delImgIds); } // 添加新显示数据 $limit = count($delDataIds); $i = 1; foreach ($this->_newPushIds as $key => $newData) { if (!$newData['vieworder']) { continue; } if ($i > $limit) { break; } $_k = array_search($newData['vieworder'], $newOrderIds); if ($_k !== false) { unset($newOrderIds[$_k]); } $dm = new PwDesignDataDm(); $dm->setDatatype(PwDesignData::AUTO)->setFromType(PwDesignData::FROM_AUTO)->setFromApp($newData['standard_fromapp'])->setFromid($newData['standard_fromid'])->setModuleid($this->bo->moduleid)->setStandard($newData['standard'])->setVieworder($newData['vieworder'])->setStarttime($this->time)->setEdited($newData['is_edited'])->setEndtime($refresh); if ($newData['standard_style']) { list($bold, $underline, $italic, $color) = $newData['standard_style']; $dm->setStyle($bold, $underline, $italic, $color); } if ($newData['from_type'] == 'push') { $dm->setFromType(PwDesignData::FROM_PUSH)->setStarttime($newData['start_time'])->setEndtime($newData['end_time']); } if ($newData['data_type']) { $dm->setDatatype($newData['data_type']); } if ($newData['vieworder']) { $dm->setDatatype(PwDesignData::ISFIXED); } $extend = $this->getExtend($newData); $dm->setExtend($extend); $resource = $ds->addData($dm); if (isset($extend['__asyn'])) { $imageDs->updateDataId($extend['__asyn'], $resource); } unset($this->_newPushIds[$key]); $i++; } foreach ($newOrderIds as $order) { $isupdate = false; $newData = array_shift($this->_newPushIds); if (!$newData) { $newData = array_shift($this->_newAutoIds); } if (!$newData) { break; } $newData['vieworder'] && ($order = $newData['vieworder']); $dm = new PwDesignDataDm(); $dm->setDatatype(PwDesignData::AUTO)->setFromType(PwDesignData::FROM_AUTO)->setFromApp($newData['standard_fromapp'])->setFromid($newData['standard_fromid'])->setModuleid($this->bo->moduleid)->setStandard($newData['standard'])->setVieworder($order)->setStarttime($this->time)->setEndtime($refresh)->setEdited($newData['is_edited']); if ($newData['standard_style']) { list($bold, $underline, $italic, $color) = $newData['standard_style']; $dm->setStyle($bold, $underline, $italic, $color); } if ($newData['from_type'] == 'push') { $dm->setFromType(PwDesignData::FROM_PUSH)->setStarttime($newData['start_time'])->setEndtime($newData['end_time']); } if ($newData['data_type']) { $dm->setDatatype($newData['data_type']); } if ($newData['vieworder']) { $dm->setDatatype(PwDesignData::ISFIXED); } $extend = $this->getExtend($newData, $order); $dm->setExtend($extend); $resource = $ds->addData($dm); if (isset($extend['__asyn'])) { $imageDs->updateDataId($extend['__asyn'], $resource); } } // 添加预定数据 foreach ($this->_reservData as $newData) { $dm = new PwDesignDataDm(); $dm->setDatatype(PwDesignData::AUTO)->setFromType(PwDesignData::FROM_PUSH)->setFromApp($newData['standard_fromapp'])->setFromid($newData['standard_fromid'])->setModuleid($this->bo->moduleid)->setStandard($newData['standard'])->setVieworder($newData['vieworder'])->setStarttime($newData['start_time'])->setEndtime($newData['end_time'])->setReservation(1)->setEdited(0); if ($newData['standard_style']) { list($bold, $underline, $italic, $color) = $newData['standard_style']; $dm->setStyle($bold, $underline, $italic, $color); } if ($newData['vieworder']) { $dm->setDatatype(PwDesignData::ISFIXED); } $extend = $this->getExtend($newData); $dm->setExtend($extend); $resource = $ds->addData($dm); if (isset($extend['__asyn'])) { $imageDs->updateDataId($extend['__asyn'], $resource); } } }