public function showlist() { if ($this->checkFormSubmit()) { $this->update(); } else { global $G, $lang; $pagesize = 20; $condition = array(); $catid = intval($_GET['catid']); $status = intval($_GET['status']); $kw = trim($_GET['kw']); if ($catid) { $condition['catid'] = array('IN', $catid); } if ($status) { $condition['status'] = $status; } if ($kw) { $condition['title'] = array('LIKE', $kw); } $totalnum = $this->t('post_title')->where($condition)->count(); $pagecount = $totalnum < $pagesize ? 1 : ceil($totalnum / $pagesize); $fields = 'id,catid,uid,title,type,alias,commentnum,favtimes,viewnum,pubtime,modified,status'; $articlelist = $this->t('post_title')->field($fields)->where($condition)->page($G['page'], $pagesize)->order('id', 'DESC')->select(); $pages = $this->showPages($G['page'], $pagecount, $totalnum, "kw={$kw}&catid={$catid}&status={$status}"); $categorylist = cache('category_article'); if (is_array($categorylist)) { $category = new \Core\Category(); $categoryoptions = $category->getOptions(0, $catid); } if (!empty($articlelist)) { $newarticlelist = array(); foreach ($articlelist as $article) { $article['pubtime'] = date('Y-m-d H:i:s', $article['pubtime']); $article['type'] = $article['type'] ? $article['type'] : 'article'; $article['typename'] = $lang['posttypes'][$article['type']]; $article['status'] = $lang['poststatus'][$article['status']]; $article['cname'] = $categorylist[$article['catid']]['cname']; $newarticlelist[] = $article; } $articlelist = $newarticlelist; unset($newarticlelist); } include template('post'); } }
public function edit() { $tid = intval($_GET['tid']); if ($this->checkFormSubmit()) { $tasknew = $_GET['tasknew']; if ($tasknew['title'] && $tasknew['contact'] && $tasknew['catid']) { $location = getLocation($tasknew['city'], $tasknew['address']); $tasknew['longitude'] = $location['longitude']; $tasknew['latitude'] = $location['latitude']; $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->update($tasknew); $pics = $_GET['pic']; if ($pics && is_array($pics)) { $this->t('task')->where(array('tid' => $tid))->update(array('pic' => $pics[0])); $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->delete(); foreach ($pics as $pic) { $this->t('image')->insert(array('dataid' => $tid, 'datatype' => 'task', 'image' => $pic)); } } $this->showSuccess('save_succeed'); } else { $this->showError('undefined_action'); } } else { global $G, $lang; $task = $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->selectOne(); if (!$task) { $this->showError('page_notfound'); } $pics = $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->select(); if ($pics) { $newlist = array(); foreach ($pics as $plist) { $plist['url'] = image($plist['image']); $newlist[] = $plist; } $pics = $newlist; unset($newlist); } $categorylist = $this->getCategoryList(); $category = new \Core\Category(); $category->dataList = $categorylist; $categoryoptions = $category->getOptions(0, $task['catid']); include template('task_form'); } }
public function edit() { $id = intval($_GET['id']); if ($this->checkFormSubmit()) { $goodsnew = $_GET['goodsnew']; $goodsnew['price'] = floatval($goodsnew['price']); $goodsnew['stock'] = intval($goodsnew['stock']); if ($goodsnew['name']) { $this->t('goods')->where(array('uid' => $this->uid, 'id' => $id))->update($goodsnew); $pics = $_GET['pic']; if ($pics && is_array($pics)) { $this->t('goods')->where(array('id' => $id))->update(array('pic' => $pics[0])); $this->t('image')->where(array('dataid' => $id, 'datatype' => 'goods'))->delete(); foreach ($pics as $image) { $this->t('image')->insert(array('dataid' => $id, 'datatype' => 'goods', 'image' => $image)); } } $description = htmlspecialchars($_GET['description']); $this->t('goods_description')->where(array('goods_id' => $id))->update(array('description' => $description)); $this->showSuccess('save_succeed'); } else { $this->showError('undefined_action'); } } else { global $G, $lang; $goods = $this->t('goods')->where(array('uid' => $this->uid, 'id' => $id))->selectOne(); if ($goods) { $pics = $this->t('image')->where(array('dataid' => $id, 'datatype' => 'goods'))->select(); if ($pics) { $newlist = array(); foreach ($pics as $list) { $list['url'] = image($list['image']); $newlist[] = $list; } $pics = $newlist; unset($newlist); } $description = $this->t('goods_description')->where(array('goods_id' => $id))->selectOne(); $goods['description'] = $description['description']; $categorylist = $this->getCategoryList(); $category = new \Core\Category(); $category->dataList = $categorylist; $categoryoptions = $category->getOptions(0, $goods['catid']); include template('goods_form'); } else { $this->notFound(); } } }