public function edit($slug = null) { if (!\App::isGranted('editPost')) { redirect('admin/dashboard'); } try { // get post types and categories from helper $postTypes = getPostTypes(); $categorys = getCategorys(); if (!$slug) { throw new Exception("Error processing request.", 1); } $postManager = $this->container->get('post.post_manager'); $post = $postManager->getPostBySlug($slug); if (!$post) { throw new Exception("Post not found.", 1); } if ($post->isTrashed()) { throw new Exception("Post has been deleted already.", 1); } $oTags = $post->getTags(); $oldTags = ''; foreach ($oTags as $i => $tag) { $oldTags .= $tag->getName(); if ($i != count($oTags)) { $oldTags .= ','; } } $mediaSource = ''; foreach ($post->getMedias() as $i => $media) { $separator = $i == 0 || $i == count($post->getMedias()) ? '' : ','; $mediaSource .= $separator . $media->getSource(); } if ($this->input->post()) { $ruleManager = $this->container->get('post.rule_manager'); $this->form_validation->set_rules($ruleManager->getRules(array('title'))); if ($this->form_validation->run($this)) { $post->setTitle($this->input->post('title')); $post->setContent($this->input->post('content')); $postTypeManager = $this->container->get('post.post_type_manager'); if ($this->input->post('postType')) { $postType = $postTypeManager->getPostTypeById($this->input->post('postType')); } else { $postType = defaultPostType(); } $post->setPostType($postType); $categoryManager = $this->container->get('post.category_manager'); $cats = array(); if ($this->input->post('category')) { foreach ($this->input->post('category') as $id) { $cat = $categoryManager->getCategoryById($id); $cats[] = $cat; } } else { $cats[] = defaultCategory(); } $post->setCategorys($cats); if ($this->input->post('tags')) { $tags = explode(',', $this->input->post('tags')); $dbTags = getAllTags(); $postTags = array(); $tagManager = $this->container->get('post.tag_manager'); foreach ($tags as $tag) { if (!in_array($tag, $dbTags) && $tag) { $newTag = $tagManager->createTag(); $newTag->setName($tag); $tagManager->updateTag($newTag); $tag = $newTag; } else { $tag = $tagManager->getTagByName($tag); } if ($tag) { $postTags[] = $tag; } } $post->setTags($postTags); } else { $post->setTags(array()); } if ($this->input->post('mediaSrc') != $mediaSource) { $sources = explode(',', $this->input->post('mediaSrc')); $dbMedia = getAllMediaSources(); $postMedias = array(); $mediaManager = $this->container->get('media.media_manager'); foreach ($sources as $src) { if (!in_array($src, $dbMedia) && $src) { $newMedia = $mediaManager->createMedia(); $newMedia->setSource($src); $mediaManager->updateMedia($newMedia); $media = $newMedia; } else { $media = $mediaManager->getMediaBySource($src); } if ($src) { $postMedias[] = $media; } } $post->setMedias($postMedias); } if ($this->input->post('btnPublish') && $post->isDraft()) { $post->activate(); } $postManager->updatePost($post); $this->session->setFlashMessage('feedback', "Post ({$post->getTitle()}) has been updated.", 'success'); redirect(site_url('admin/post')); } } $this->breadcrumbs->push('Edit', current_url()); $this->templateData['postTypes'] = $postTypes; $this->templateData['post'] = $post; $this->templateData['mediaSource'] = $mediaSource; $this->templateData['oldTags'] = $oldTags; $this->templateData['categorys'] = $categorys; $this->templateData['pageTitle'] = 'Edit Post'; $this->templateData['content'] = 'post/edit'; $this->load->view('backend/main_layout', $this->templateData); } catch (Exception $e) { $this->session->setFlashMessage('feedback', "Unable to edit post: {$e->getMessage()}", 'error'); redirect(site_url('admin/post')); } }
return "hot_f"; } } for ($i = 0; $i <= 5; $i++) { $pcats[$i] = explode("#", $_MODULE['pcats' . $i]); $ccats[$i] = explode("#", $_MODULE['ccats' . $i]); $ccats_href[$i] = explode("#", $_MODULE['ccats_href' . $i]); $categorys[$i]['parent']['name'] = $pcats[$i][0]; $categorys[$i]['parent']['url'] = $pcats[$i][1]; foreach ($ccats[$i] as $k => $v) { $categorys[$i]['child'][$k]['name'] = $ccats[$i][$k]; $categorys[$i]['child'][$k]['url'] = $ccats_href[$i][$k]; } } if ($_MODULE['load_type'] == 1) { $cat = getCategorys($_MODULE['cate']); } if ($_MODULE['load_type'] == 2) { $cat = $categorys; } ?> <div style="margin-top:5px;"><div class="mod-cates"> <div class="type950"> <div class="<?php echo $_MODULE['show_style']; ?> clear mod f_st" style="">
$handle = fopen(DIR_FS_CATALOG . '' . $name, 'w+'); switch ($_GET['f']) { case 'zc': $filed_format = '"v_products_model","v_products_image","v_products_name_3","v_products_description_3","v_products_url_3","v_specials_price",' . '"v_specials_last_modified","v_specials_expires_date","v_products_price","v_products_weight","v_last_modified","v_date_added","v_products_quantity",' . '"v_manufacturers_name","v_categories_name_1","v_categories_name_2","v_categories_name_3","v_categories_name_4","v_categories_name_5",' . '"v_categories_name_6","v_categories_name_7","v_tax_class_title","v_status","v_metatags_products_name_status","v_metatags_title_status",' . '"v_metatags_model_status","v_metatags_price_status","v_metatags_title_tagline_status","v_metatags_title_3","v_metatags_keywords_3",' . '"v_metatags_description_3","v_property_1"' . "\n"; fwrite($handle, $filed_format); break; case 'wp': $filed_format = 'csv_post_title,csv_post_post,csv_post_categories,csv_post_tags,csv_post_excerpt,csv_post_date,csv_post_author,csv_post_slug' . "\n"; fwrite($handle, $filed_format); break; } $products = $db->Execute("\n\tSELECT *\n\tFROM " . TABLE_PRODUCTS . " p JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (p.products_id=pd.products_id AND pd.language_id={$lang_id})\n\tORDER BY p.products_id ASC\n\t" . $limit); while (!$products->EOF) { //$r = $products->fields; $meta = getMetatags($products->fields['products_id'], $lang_id); $categores = getCategorys($products->fields['master_categories_id'], $lang_id); $image = $products->fields['products_image']; switch ($_GET['f']) { case 'zc': $fields = array($products->fields['products_model'], $image, $products->fields['products_name'], jtrim_desc($products->fields['products_description']), $products->fields['products_url'], zen_get_products_special_price($products->fields['products_id'], true), date('Y-m-d H:i:s'), '2035-12-21 12:35:21', $products->fields['products_price'], $products->fields['products_weight'], $products->fields['products_last_modified'], $products->fields['products_date_added'], $products->fields['products_quantity'], '', jtrim($categores[0]['name']), jtrim($categores[1]['name']), jtrim($categores[2]['name']), jtrim($categores[3]['name']), jtrim($categores[4]['name']), jtrim($categores[5]['name']), jtrim($categores[6]['name']), '--なし--', $products->fields['products_status'], $products->fields['metatags_products_name_status'], $products->fields['metatags_title_status'], $products->fields['metatags_model_status'], $products->fields['metatags_price_status'], $products->fields['metatags_title_tagline_status'], $meta['metatag_title'], $meta['metatag_key'], $meta['metatag_desc']); //v_property_1 $fields[] = getProperty($products->fields['products_id'], $lang_id); break; case 'wp': $description = jtrim_desc($products->fields['products_description']); // $images = array( // getImagePath($products->fields['products_image']) // ); // if (preg_match_all('~src=["\'](.+?)["\']~i', $description, $matchImages)) // { // if ($matchImages[1])
function admin_add() { $this->_check_cms(); $model = createModel($this->app); $php = Swoole::getInstance(); if ($_POST) { $this->proc_upfiles(); if (isset($_POST['cid'])) { $cid = (int) $_POST['cid']; $cate = getCategory($cid); $_POST['cname'] = $cate['name']; $_POST['fid'] = $cate['fid']; $fcate = getCategory($cate['fid']); $_POST['fname'] = $fcate['name']; } elseif (isset($_POST['fid'])) { $fid = (int) $_POST['fid']; $_POST['fid'] = $fid; $fcate = getCategory($fid); $_POST['fname'] = $fcate['name']; } $_POST['uptime'] = time(); //将远程图片本地化 Swoole_content::image_local($_POST['content']); if (!empty($_POST['id'])) { //如果得到id,说明提交的是修改的操作 $id = (int) $_POST['id']; unset($_POST['id']); $model->set($id, $_POST); Swoole_js::js_back('修改成功', -2); if ($php->config->cms['html_static']) { if (!empty($_POST['pagename'])) { $this->updatePage($_POST['pagename']); } else { $this->updateDetail($id); } } } else { //如果没得到id,说明提交的是添加操作 //if(!isset($_POST['cid']) and isset($_GET['fid'])) $_POST['cid'] = $_GET['fid']; $_POST['uid'] = $_SESSION['admin_user_id']; $_POST['uname'] = $_SESSION['admin_user']['realname']; $id = $model->put($_POST); Swoole_js::js_back('添加成功'); if ($php->config->cms['html_static']) { if (!empty($_POST['pagename'])) { $this->updatePage($_POST['pagename']); } else { $this->updateDetail($id); } } } } else { //Error::dbd(); if (empty($_GET['fid']) and empty($_GET['cid'])) { $cates = getCategorys($this->app); $this->swoole->tpl->assign('cates', $cates); } $this->swoole->plugin->load('fckeditor'); if (isset($_GET['id'])) { $id = $_GET['id']; $det = $model->get($id)->get(); $editor = editor("content", $det['content'], 480); $this->swoole->tpl->assign('det', $det); $this->swoole->tpl->assign('cates', false); } else { $editor = editor("content", '', 480); } $this->swoole->tpl->assign('editor', $editor); $this->swoole->tpl->display('admin_' . strtolower($this->app) . '_detail.html'); } }