Example #1
0
    echo 'none';
}
?>
">
	  <?php 
echo Form::urlrule('content', 'show', 0, $setting['category_ruleid'], 'name="show_php_ruleid"');
?>
	</div>
							<div id="show_html_ruleid" style="display:<?php 
if (!$setting['content_ishtml']) {
    echo 'none';
}
?>
">
	  <?php 
echo Form::urlrule('content', 'show', 1, $setting['category_ruleid'], 'name="show_html_ruleid"');
?>
	</div></td>
					</tr>
					<tr>
						<th><?php 
echo L('create_to_rootdir');
?>
:</th>
						<td><input type='radio' name='setting[create_to_html_root]'
							value='1'
							<?php 
if ($setting['create_to_html_root']) {
    echo 'checked';
}
?>
 public function edit()
 {
     if (IS_POST) {
         $catid = I("post.catid", "", "intval");
         if (empty($catid)) {
             $this->error('请选择需要修改的栏目!');
         }
         $Category = D("Content/Category");
         $status = $Category->editCategory($_POST);
         if ($status) {
             //应用权限设置到子栏目
             if ($_POST['priv_child']) {
                 //子栏目
                 $arrchildid = $Category->where(array('catid' => $catid))->getField('arrchildid');
                 $arrchildid_arr = explode(',', $arrchildid);
                 foreach ($arrchildid_arr as $arr_v) {
                     D("Content/Category_priv")->update_priv($arr_v, $_POST['priv_roleid'], 1);
                 }
             } else {
                 //更新角色栏目权限
                 D("Content/Category_priv")->update_priv($catid, $_POST['priv_roleid'], 1);
                 if (isModuleInstall('Member')) {
                     //更新会员组权限
                     D("Content/Category_priv")->update_priv($catid, $_POST['priv_groupid'], 0);
                 }
             }
             $this->success("更新成功!", U("Category/index"));
         } else {
             $error = $Category->getError();
             $this->error($error ? $error : '栏目修改失败!');
         }
     } else {
         $catid = I('get.catid', 0, 'intval');
         $array = cache("Category");
         foreach ($array as $k => $v) {
             $array[$k] = getCategory($v['catid']);
             if ($v['child'] == "0") {
                 $array[$k]['disabled'] = "disabled";
             } else {
                 $array[$k]['disabled'] = "";
             }
         }
         $data = getCategory($catid);
         $setting = $data['setting'];
         //输出可用模型
         $modelsdata = cache("Model");
         $models = array();
         foreach ($modelsdata as $v) {
             if ($v['disabled'] == 0 && $v['type'] == 0) {
                 $models[] = $v;
             }
         }
         if (!empty($array) && is_array($array)) {
             $this->Tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
             $this->Tree->nbsp = '&nbsp;&nbsp;&nbsp;';
             $this->Tree->init($array);
             $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
             $categorydata = $this->Tree->get_tree(0, $str, $data['parentid']);
         } else {
             $categorydata = '';
         }
         $this->assign("category_php_ruleid", \Form::urlrule('content', 'category', 0, $setting['category_ruleid'], 'name="category_php_ruleid"'));
         $this->assign("category_html_ruleid", \Form::urlrule('content', 'category', 1, $setting['category_ruleid'], 'name="category_html_ruleid"'));
         $this->assign("show_php_ruleid", \Form::urlrule('content', 'show', 0, $setting['show_ruleid'], 'name="show_php_ruleid"'));
         $this->assign("show_html_ruleid", \Form::urlrule('content', 'show', 1, $setting['show_ruleid'], 'name="show_html_ruleid"'));
         $this->assign("tp_category", $this->tp_category);
         $this->assign("tp_list", $this->tp_list);
         $this->assign("tp_show", $this->tp_show);
         $this->assign("tp_comment", $this->tp_comment);
         $this->assign("tp_page", $this->tp_page);
         $this->assign("category", $categorydata);
         $this->assign("models", $models);
         $this->assign("data", $data);
         $this->assign("setting", $setting);
         //栏目扩展字段
         $this->assign('extendList', D("Content/Category")->getExtendField($catid));
         //角色组
         $this->assign("Role_group", M("Role")->order(array("id" => "ASC"))->select());
         $this->assign("big_menu", array(U("Category/index"), "栏目管理"));
         //权限数据
         $this->assign("privs", M("CategoryPriv")->where(array('catid' => $catid))->select());
         if (isModuleInstall('Member')) {
             //会员组
             $this->assign("Member_group", cache("Member_group"));
         }
         if ($data['type'] == 1) {
             //单页栏目
             $this->display("singlepage_edit");
         } else {
             if ($data['type'] == 2) {
                 //外部栏目
                 $this->display("wedit");
             } else {
                 $this->display();
             }
         }
     }
 }
">
	<?php 
    echo Form::urlrule('content', 'category', 0, $cat['setting']['category_ruleid'], 'name="category_php_ruleid[' . $catid . ']" style="width:250px;"');
    ?>
	</div>
							<div id="category_html_ruleid<?php 
    echo $catid;
    ?>
" style="display:<?php 
    if (!$cat['setting']['ishtml']) {
        echo 'none';
    }
    ?>
">
	<?php 
    echo Form::urlrule('content', 'category', 1, $cat['setting']['category_ruleid'], 'name="category_html_ruleid[' . $catid . ']" style="width:250px;"');
    ?>
	</div></td>
	<?php 
}
?>
	 </tr>

					<tr>
	 <?php 
foreach ($batch_array as $catid => $cat) {
    ?>
		<td><b><?php 
    echo L('meta_title');
    ?>
:</b><br> <input
Example #4
0
">
	  <?php 
    echo Form::urlrule('content', 'show', 0, $cat['setting']['show_ruleid'], 'name="show_php_ruleid[' . $catid . ']" style="width:250px;"');
    ?>
	</div>
							<div id="show_html_ruleid<?php 
    echo $catid;
    ?>
" style="display:<?php 
    if (!$cat['setting']['content_ishtml']) {
        echo 'none';
    }
    ?>
">
	  <?php 
    echo Form::urlrule('content', 'show', 1, $cat['setting']['show_ruleid'], 'name="show_html_ruleid[' . $catid . ']" style="width:250px;"');
    ?>
	</div></td>
	<?php 
}
?>
	 </tr>
					<tr>
	 <?php 
foreach ($batch_array as $catid => $cat) {
    ?>
		<td><b><?php 
    echo L('create_to_rootdir');
    ?>
:</b><br> <input
							boxid="create_to_html_root"
 /**
  * 编辑栏目 
  */
 public function edit()
 {
     if (IS_POST) {
         $_POST['info'][C("TOKEN_NAME")] = $_POST[C("TOKEN_NAME")];
         $catid = $this->_post("catid");
         $setting = $_POST['setting'];
         //栏目生成静态配置,外部栏目无需
         if ($_POST['type'] != 2) {
             if ($setting['ishtml']) {
                 $setting['category_ruleid'] = $_POST['category_html_ruleid'];
             } else {
                 $setting['category_ruleid'] = $_POST['category_php_ruleid'];
                 $_POST['info']['url'] = '';
             }
         }
         //栏目生成静态配置
         if ($setting['ishtml']) {
             $setting['category_ruleid'] = $_POST['category_html_ruleid'];
         } else {
             $setting['category_ruleid'] = $_POST['category_php_ruleid'];
         }
         //内容生成静态配置
         if ($setting['content_ishtml']) {
             $setting['show_ruleid'] = $_POST['show_html_ruleid'];
         } else {
             $setting['show_ruleid'] = $_POST['show_php_ruleid'];
         }
         $_POST['info']['sethtml'] = $setting['ishtml'] ? 1 : 0;
         if ((int) $_POST['type'] != 2) {
             //绑定域名
             $_POST['info']['domain'] = $_POST['info']['url'];
         }
         $_POST['info']['setting'] = serialize($setting);
         //设置模块
         $_POST['info']['module'] = 'content';
         // //栏目拼音
         $catname = iconv('utf-8', 'gbk', $_POST['info']['catname']);
         $letters = gbk_to_pinyin($catname);
         $_POST['info']['letter'] = strtolower(implode('', $letters));
         $Category = D("Category");
         //去除child属性,防止意外发生,如需改变栏目属性,使用属性转换功能
         unset($_POST['info']['child']);
         //判断URL规则是否有设置
         if ((!$setting['category_ruleid'] || !$setting['category_ruleid']) && (int) $_POST['type'] != 2) {
             $this->error("URL规则不能为空!");
         }
         $data = $Category->create($_POST['info']);
         if ($data) {
             if ($Category->where(array("catid" => $catid))->save($data) !== false) {
                 $this->assign("jumpUrl", U("Category/index"));
                 //更新附件状态
                 if ($_POST['info']['image']) {
                     //更新附件状态,把相关附件和文章进行管理
                     service("Attachment")->api_update('', 'catid-' . $catid, 1);
                 }
                 //子栏目
                 $arrchildid = $Category->where(array('catid' => $catid))->getField('arrchildid');
                 //当前栏目目录路径
                 $catdir = $this->get_parentdir($catid) . $data['catdir'] . "/";
                 //绑定域名应用到子栏目
                 if (isset($_POST['domain_childid'])) {
                     $domain = $data['domain'];
                     $childid_arr = explode(',', $arrchildid);
                     //去除自身
                     unset($childid_arr[0]);
                     if ($domain) {
                         foreach ($childid_arr as $chil_catid) {
                             //取得目录
                             $chil_catdir = $Category->where(array('catid' => $chil_catid))->getField('catdir');
                             //取得父栏目路径
                             $chil_parent_pat = $this->get_parentdir($chil_catid);
                             //完整栏目路径
                             $chil_pat = $chil_parent_pat . $chil_catdir . "/";
                             $Category->where(array('catid' => $chil_catid, "sethtml" => 1))->save(array("domain" => str_replace(array($catdir), array($domain), $chil_pat)));
                         }
                     } else {
                         foreach ($childid_arr as $chil_catid) {
                             $Category->where(array('catid' => $chil_catid, "sethtml" => 1))->save(array("domain" => ""));
                         }
                     }
                 }
                 //应用权限设置到子栏目
                 if ($_POST['priv_child']) {
                     $arrchildid_arr = explode(',', $arrchildid);
                     foreach ($arrchildid_arr as $arr_v) {
                         $this->update_priv($arr_v, $_POST['priv_roleid']);
                         $this->update_priv($arr_v, $_POST['priv_groupid'], 0);
                     }
                 } else {
                     //更新角色栏目权限
                     $this->update_priv($catid, $_POST['priv_roleid']);
                     //更新会有组权限
                     $this->update_priv($catid, $_POST['priv_groupid'], 0);
                 }
                 //更新缓存
                 $this->cache();
                 $this->success("更新成功!");
             } else {
                 $this->assign("jumpUrl", U("Category/edit", array("catid" => $catid)));
                 $this->error("更新失败!");
             }
         } else {
             $this->error($Category->getError());
         }
     } else {
         $catid = (int) $this->_get("catid");
         import('Tree');
         $tree = new Tree();
         $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
         $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
         $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
         $array = F("Category");
         foreach ($array as $k => $v) {
             if ($v['child'] == "0") {
                 $array[$k]['disabled'] = "disabled";
             } else {
                 $array[$k]['disabled'] = "";
             }
         }
         $data = $array[$catid];
         $setting = $data['setting'] = unserialize($data['setting']);
         $models = F("Model");
         $tree->init($array);
         $categorydata = $tree->get_tree(0, $str, $data['parentid']);
         import('Form');
         $this->assign("category_php_ruleid", Form::urlrule('content', 'category', 0, $setting['category_ruleid'], 'name="category_php_ruleid"'));
         $this->assign("category_html_ruleid", Form::urlrule('content', 'category', 1, $setting['category_ruleid'], 'name="category_html_ruleid"'));
         $this->assign("show_php_ruleid", Form::urlrule('content', 'show', 0, $setting['show_ruleid'], 'name="show_php_ruleid"'));
         $this->assign("show_html_ruleid", Form::urlrule('content', 'show', 1, $setting['show_ruleid'], 'name="show_html_ruleid"'));
         $this->assign("tp_category", $this->tp_category);
         $this->assign("tp_list", $this->tp_list);
         $this->assign("tp_show", $this->tp_show);
         $this->assign("tp_comment", $this->tp_comment);
         $this->assign("category", $categorydata);
         $this->assign("models", $models);
         $this->assign("data", $data);
         $this->assign("setting", $setting);
         //会员组
         $this->assign("Member_group", F("Member_group"));
         //角色组
         $this->assign("Role_group", M("Role")->order(array("id" => "ASC"))->select());
         $this->assign("big_menu", array(U("Category/index"), "栏目管理"));
         //权限数据
         $this->assign("privs", M("CategoryPriv")->where(array('catid' => $catid))->select());
         if ($data['type'] == 2) {
             $this->display("wedit");
         } else {
             $this->display();
         }
     }
 }
 /**
  * 初始模板和URL规则信息
  * @param type $info
  */
 private function templateAndRule($info = array('urlruleid' => ''))
 {
     $filepath = TEMPLATE_PATH . (empty(self::$Cache["Config"]['theme']) ? "Default" : self::$Cache["Config"]['theme']) . "/Content/";
     $tp_list = str_replace("{$filepath}List/", '', glob($filepath . 'List/list*'));
     $this->assign('list_html_ruleid', \Form::urlrule('content', 'category', 1, $info['urlruleid'], 'name="urlruleid"'));
     $this->assign('tp_list', $tp_list);
 }