/** * 显示左边菜单,进行权限控制 * @author huajie <*****@*****.**> */ protected function getMenu() { $cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select(); $cate = list_to_tree($cate); //生成分类树 //获取分类id $cate_id = I('param.cate_id'); $this->cate_id = $cate_id; //是否展开分类 $hide_cate = false; if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') { $hide_cate = true; } //生成每个分类的url foreach ($cate as $key => &$value) { $value['url'] = 'Article/index?cate_id=' . $value['id']; if ($cate_id == $value['id'] && $hide_cate) { $value['current'] = true; } else { $value['current'] = false; } if (!empty($value['_child'])) { $is_child = false; foreach ($value['_child'] as $ka => &$va) { $va['url'] = 'Article/index?cate_id=' . $va['id']; if (!empty($va['_child'])) { foreach ($va['_child'] as $k => &$v) { $v['url'] = 'Article/index?cate_id=' . $v['id']; $v['pid'] = $va['id']; $is_child = $v['id'] == $cate_id ? true : false; } } //展开子分类的父分类 if ($va['id'] == $cate_id || $is_child) { $is_child = false; if ($hide_cate) { $value['current'] = true; $va['current'] = true; } else { $value['current'] = false; $va['current'] = false; } } else { $va['current'] = false; } } } } //dump($cate); $this->assign('nodes', $cate); $this->assign('cate_id', $this->cate_id); //获取面包屑信息 $nav = get_parent_category($cate_id); $this->assign('rightNav', $nav); }
/** * 显示左边菜单,进行权限控制 * @author huajie <*****@*****.**> */ protected function getMenu() { //获取动态分类 $cate_auth = AuthGroupModel::getAuthCategories(UID); //获取当前用户所有的内容权限节点 $cate_auth = $cate_auth == null ? array() : $cate_auth; $cate = D('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select(); //没有权限的分类则不显示 if (!IS_ROOT) { foreach ($cate as $key => $value) { if (!in_array($value['id'], $cate_auth)) { unset($cate[$key]); } } } $cate = list_to_tree($cate); //生成分类树 //获取分类id $cate_id = I('param.cate_id'); $this->cate_id = $cate_id; //是否展开分类 $hide_cate = false; if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') { $hide_cate = true; } //生成每个分类的url foreach ($cate as $key => &$value) { $value['url'] = 'Article/index?cate_id=' . $value['id']; if ($cate_id == $value['id'] && $hide_cate) { $value['current'] = true; } else { $value['current'] = false; } if (!empty($value['_child'])) { $is_child = false; foreach ($value['_child'] as $ka => &$va) { $va['url'] = 'Article/index?cate_id=' . $va['id']; if (!empty($va['_child'])) { foreach ($va['_child'] as $k => &$v) { $v['url'] = 'Article/index?cate_id=' . $v['id']; $v['pid'] = $va['id']; $is_child = $v['id'] == $cate_id ? true : false; } } //展开子分类的父分类 if ($va['id'] == $cate_id || $is_child) { $is_child = false; if ($hide_cate) { $value['current'] = true; $va['current'] = true; } else { $value['current'] = false; $va['current'] = false; } } else { $va['current'] = false; } } } } $this->assign('nodes', $cate); $this->assign('cate_id', $this->cate_id); //获取面包屑信息 $nav = get_parent_category($cate_id); $this->assign('rightNav', $nav); //获取回收站权限 $this->assign('show_recycle', IS_ROOT || $this->checkRule('Admin/article/recycle')); //获取草稿箱权限 $this->assign('show_draftbox', C('OPEN_DRAFTBOX')); //获取审核列表权限 $this->assign('show_examine', IS_ROOT || $this->checkRule('Admin/article/examine')); }
/** * 分类文档列表页 * @param integer $cate_id 分类id * @param integer $model_id 模型id * @param integer $position 推荐标志 * @param integer $group_id 分组id */ public function index() { $cate_id = I('cate_id'); $model_id = I('model_id', null); $position = I('position', null); $group_id = I('group_id', null); //获取面包屑信息 $nav = get_parent_category($cate_id); $this->assign('rightNav', $nav); if ($cate_id === null) { $cate_id = $this->cate_id; } if (!empty($cate_id)) { $pid = I('pid', 0); // 获取列表绑定的模型 if ($pid == 0) { $models = get_category($cate_id, 'model'); // 获取分组定义 $groups = get_category($cate_id, 'groups'); if ($groups) { $groups = parse_field_attr($groups); } } else { // 子文档列表 $models = get_category($cate_id, 'model_sub'); } if (is_null($model_id) && !is_numeric($models)) { // 绑定多个模型 取基础模型的列表定义 $model = M('Model')->getByName('document'); } else { $model_id = $model_id ?: $models; //获取模型信息 $model = M('Model')->getById($model_id); if (empty($model['list_grid'])) { $model['list_grid'] = M('Model')->getFieldByName('document', 'list_grid'); } } $this->assign('model', explode(',', $models)); } else { $site_id = $this->site_id; $cates = M("Category")->where("site_id = {$site_id}")->getField('id', true); // 获取基础模型信息 $model = M('Model')->getByName('document'); $model_id = null; if (empty($cates)) { $cate_id = array('in', array(null)); } else { $cate_id = array('in', $cates); } $this->assign('model', null); } if ($model['name'] == 'single') { $document_id = M('Document')->where("category_id={$cate_id}")->getField('id'); $data = array(); if ($document_id) { // 获取详细数据 $Document = D('Document'); $data = $Document->detail($document_id); } else { $data['pid'] = 0; $data['category_id'] = $cate_id; $data['model_id'] = $model_id; } $this->assign('data', $data); $this->assign('model_id', $data['model_id']); $this->assign('model', $model); //获取表单字段排序 $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); //获取当前分类的文档类型 $this->assign('type_list', get_type_bycate($data['category_id'])); $this->meta_title = '编辑内容'; $this->display('Profile/Article/edit'); } else { //解析列表规则 $fields = array(); $grids = preg_split('/[;\\r\\n]+/s', trim($model['list_grid'])); foreach ($grids as &$value) { // 字段:标题:链接 $val = explode(':', $value); // 支持多个字段显示 $field = explode(',', $val[0]); $value = array('field' => $field, 'title' => $val[1]); if (isset($val[2])) { // 链接信息 $value['href'] = $val[2]; // 搜索链接信息中的字段信息 preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use(&$fields) { $fields[] = $match[1]; }, $value['href']); } if (strpos($val[1], '|')) { // 显示格式定义 list($value['title'], $value['format']) = explode('|', $val[1]); } foreach ($field as $val) { $array = explode('|', $val); $fields[] = $array[0]; } } // 文档模型列表始终要获取的数据字段 用于其他用途 $fields[] = 'category_id'; $fields[] = 'model_id'; $fields[] = 'pid'; // 过滤重复字段信息 $fields = array_unique($fields); // 列表查询 $list = $this->getDocumentList($cate_id, $model_id, $position, $fields, $group_id); // 列表显示处理 $list = $this->parseDocumentList($list, $model_id); $this->assign('model_id', $model_id); $this->assign('cate_id', $cate_id); $this->assign('group_id', $group_id); $this->assign('position', $position); $this->assign('groups', $groups); $this->assign('list', $list); $this->assign('list_grids', $grids); $this->assign('model_list', $model); // 记录当前列表页的cookie Cookie('__forward__', $_SERVER['REQUEST_URI']); $this->display('Profile/Article/index'); } }
/** * 检查标识是否已存在(只需在同一根节点下不重复) * @param string $name * @return true无重复,false已存在 * @author huajie <*****@*****.**> */ protected function checkName() { $name = I('post.name'); $category_id = I('post.category_id', 0); $id = I('post.id', 0); $map = array('name' => $name, 'id' => array('neq', $id), 'status' => array('neq', -1)); $category = get_category($category_id); if ($category['pid'] == 0) { $map['category_id'] = $category_id; } else { $parent = get_parent_category($category['id']); $root = array_shift($parent); $map['category_id'] = array('in', D("Category")->getChildrenId($root['id'])); } $res = $this->where($map)->getField('id'); if ($res) { return false; } return true; }
/** * 显示左边菜单,进行权限控制 * @author huajie <*****@*****.**> */ protected function getMenu() { //获取动态分类 $cate_auth = AuthGroupModel::getAuthCategories(UID); //获取当前用户所有的内容权限节点 $cate_auth = $cate_auth == null ? array() : $cate_auth; $cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select(); //没有权限的分类则不显示 if (!IS_ROOT) { foreach ($cate as $key => $value) { if (!in_array($value['id'], $cate_auth)) { unset($cate[$key]); } } } $cate = list_to_tree($cate); //生成分类树 //获取分类id $cate_id = I('param.cate_id'); $this->cate_id = $cate_id; //是否展开分类 $hide_cate = false; if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') { $hide_cate = true; } //生成每个分类的url foreach ($cate as $key => &$value) { $value['url'] = 'Article/index?cate_id=' . $value['id']; if ($cate_id == $value['id'] && $hide_cate) { $value['current'] = true; } else { $value['current'] = false; } if (!empty($value['_child'])) { $is_child = false; foreach ($value['_child'] as $ka => &$va) { $va['url'] = 'Article/index?cate_id=' . $va['id']; if (!empty($va['_child'])) { foreach ($va['_child'] as $k => &$v) { $v['url'] = 'Article/index?cate_id=' . $v['id']; $v['pid'] = $va['id']; $is_child = $v['id'] == $cate_id ? true : false; } } //展开子分类的父分类 if ($va['id'] == $cate_id || $is_child) { $is_child = false; if ($hide_cate) { $value['current'] = true; $va['current'] = true; } else { $value['current'] = false; $va['current'] = false; } } else { $va['current'] = false; } } } } $this->assign('nodes', $cate); $this->assign('cate_id', $this->cate_id); //获取面包屑信息 $nav = get_parent_category($cate_id); $this->assign('rightNav', $nav); //获取回收站权限 $this->assign('show_recycle', IS_ROOT || $this->checkRule('Admin/article/recycle')); //获取草稿箱权限 $this->assign('show_draftbox', C('OPEN_DRAFTBOX')); $this->group_id = $_SESSION["onethink_admin"]["user_auth"]["group_id"]; if (is_administrator($uid)) { $this->group_id = 1; } $this->assign('groupId', $this->group_id); $map_sh['status'] = 2; $map_sh['bianji_status'] = 0; $sh_count = M('Document')->where($map_sh)->count(); $_SESSION["menu_nums"]["待编辑审核"] = $sh_count; $map_wd['uid'] = UID; $map_wd['status'] = array("eq", 0); $wd_count = M('Document')->where($map_wd)->count(); $_SESSION["menu_nums"]["我的文档"] = $wd_count; }
function mss_create_xml_product($id) { $product = new WC_Product($id); $weight = get_post_meta($id, '_weight', true); $weight = $weight ? $weight : "0.0"; $buyPrice = get_post_meta($id, '_max_variation_regular_price', true) ? get_post_meta($id, '_max_variation_regular_price', true) : get_post_meta($id, '_regular_price', true); $buyPrice = $buyPrice ? $buyPrice * 100 : "0.0"; $salePrice = get_post_meta($id, '_max_variation_price', true) ? get_post_meta($id, '_max_variation_price', true) : get_post_meta($id, '_price', true); $salePrice = $salePrice ? $salePrice * 100 : "0.0"; $uuid = get_post_meta($id, '_woosklad_good_uuid', true); //echo $uuid."<br />"; $categories = get_the_terms($id, 'product_cat'); put_category_identity($categories); $parent = get_parent_category($categories); $parentUuid = get_option('woosklad_category_' . $parent . '_uuid') ? 'parentUuid="' . get_option('woosklad_category_' . $parent . '_uuid') . '"' : ''; ob_start(); ?> <good isSerialTrackable="false" weight="<?php echo $weight; ?> " salePrice="<?php echo $salePrice; ?> " buyPrice="<?php echo $buyPrice; ?> " name="<?php echo $product->get_title(); ?> " productCode="<?php echo get_post_meta($id, '_sku', true); ?> " <?php echo $parentUuid; ?> > <code><?php echo get_post_meta($id, '_sku', true); ?> </code> <?php if ($uuid) { ?> <uuid><?php echo $uuid; ?> </uuid> <?php } ?> </good> <?php $xml = ob_get_contents(); ob_get_clean(); return $xml; }