本文整理匯總了PHP中Data::isChild方法的典型用法代碼示例。如果您正苦於以下問題:PHP Data::isChild方法的具體用法?PHP Data::isChild怎麽用?PHP Data::isChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Data
的用法示例。
在下文中一共展示了Data::isChild方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
public function edit()
{
if (IS_POST) {
if ($this->_db->edit_node()) {
$this->_ajax(1, '修改節點成功');
}
} else {
$nid = Q('nid');
$this->field = $this->_node[$nid];
foreach ($this->_node as $id => $node) {
$this->_node[$id]['disabled'] = Data::isChild($this->_node, $id, $nid, 'nid') ? ' disabled="disabled" ' : '';
}
$this->node = $this->_node;
$this->display();
}
}
示例2: getLevelCategory
/**
* 獲取樹狀欄目
* 指定cid時過濾掉cid及其子欄目
*
* @param int $cid
*
* @return mixed
*/
public function getLevelCategory($cid = 0)
{
$category = Db::table('web_category')->where('siteid', SITEID)->get();
if ($category) {
$category = Data::tree($category, 'title', 'cid', 'pid');
if ($cid) {
//編輯時在欄目選擇中不顯示自身與子級欄目
foreach ($category as $k => $v) {
if ($v['cid'] == $cid || Data::isChild($category, $v['cid'], $cid)) {
unset($category[$k]);
}
}
}
return $category;
}
}
示例3: edit
public function edit()
{
if (IS_POST) {
if ($this->db->editNode()) {
$this->success('修改節點成功');
}
} else {
$nid = Q('nid');
$this->field = $this->node[$nid];
foreach ($this->node as $id => $node) {
$this->node[$id]['disabled'] = Data::isChild($this->node, $id, $nid, 'nid') ? ' disabled="disabled" ' : '';
}
$this->assign('node', $this->node);
$this->display();
}
}
示例4: getEdit
public function getEdit($id, $pid)
{
$data = $this->getAll();
foreach ($data as $key => $value) {
$data[$key]["_disabled"] = $data[$key]['_selected'] = '';
if ($id == $value['id']) {
$data[$key]['_disabled'] = 'disabled=""';
}
if (Data::isChild($data, $value['id'], $id, 'id')) {
$data[$key]['_disabled'] = 'disabled=""';
}
if ($value['id'] == $pid) {
$data[$key]['_selected'] = "selected=''";
}
}
return $data;
}
示例5: getEditData
public function getEditData($id, $pid)
{
$data = $this->getAll();
foreach ($data as $k => $d) {
$data[$k]['_selected'] = $data[$k]['_disabled'] = '';
if ($d['id'] == $id) {
$data[$k]['_disabled'] = ' disabled=""';
}
if (Data::isChild($data, $d['id'], $id, 'id')) {
$data[$k]['_disabled'] = ' disabled=""';
}
if ($pid == $d['id']) {
$data[$k]['_selected'] = " selected=''";
}
}
return $data;
}
示例6: edit
public function edit()
{
//打印用戶自定義常量
//print_const();
if (IS_POST) {
if ($this->_db->edit_category()) {
$this->ajax(array('state' => 1, 'message' => '欄目修改成功'));
} else {
$this->ajax(array('state' => 0, 'message' => $this->_db->error));
}
} else {
//分配編輯欄目舊的數據
$field = $this->_db->find(Q("cid"));
//分配所有欄目
$category = $this->_db->all();
$category = Data::tree($category, 'cname');
foreach ($category as $n => $v) {
//將父級欄目添加selected(選中狀態)
$v['selected'] = '';
if ($field['pid'] == $v['cid']) {
$v['selected'] = ' selected="selected" ';
}
//將子欄目與自身添加disabled(禁止選擇)
$v['disabled'] = '';
if ($field['cid'] == $v['cid'] || Data::isChild($category, $v['cid'], $field['cid'])) {
$v['disabled'] = ' disabled="disabled" class="disabled" ';
}
$category[$n] = $v;
}
//分配當前欄目數據
$this->field = $field;
//分配欄目數據
$this->category = $category;
$this->display();
}
}
示例7: edit
public function edit()
{
if (IS_POST) {
if ($this->db->editCategory()) {
$this->success('修改欄目成功');
} else {
$this->error($this->db->error);
}
} else {
if (!$this->cid || !isset($this->category[$this->cid])) {
$this->error('欄目不存在');
}
$cache = $this->category;
$category = $cache[$this->cid];
foreach ($cache as $n => $cat) {
//父欄目select狀態
$selected = $category['pid'] == $cat['cid'] ? 'selected=""' : '';
//子欄目disabled
$disabled = Data::isChild($this->category, $cat['cid'], $this->cid) || $this->cid == $cat['cid'] ? 'disabled=""' : '';
$cache[$n]['selected'] = $selected;
$cache[$n]['disabled'] = $disabled;
}
/**
* 獲得欄目權限
*/
$categoryAccess = $this->db->getCategoryAccess($this->cid);
/**
* 如果當前欄目有文章時不允許更改模型
*/
$map['cid'] = $this->cid;
$contentTable = $this->model[$this->category[$this->cid]['mid']]['table_name'];
if (M($contentTable)->where($map)->count()) {
$disabledChangeModel = true;
} else {
$disabledChangeModel = false;
}
$this->assign('disabledChangeModel', $disabledChangeModel);
$this->assign('access', $categoryAccess);
$this->assign('field', $category);
$this->assign('model', $this->model);
$this->assign('category', $cache);
$this->display();
}
}
示例8: edit
public function edit()
{
$CategoryModel = K("Category");
$cid = Q('cid', 0, 'intval');
if (IS_POST) {
$post = $_POST;
if (empty($post)) {
$this->error('參數錯誤');
}
if ($CategoryModel->editCategory($post)) {
$this->success('修改欄目成功');
} else {
$this->error($CategoryModel->error);
}
} else {
$categoryCache = cache('category');
$categoryData = $categoryCache[$cid];
foreach ($categoryCache as $n => $cat) {
$selected = $disabled = "";
//父欄目select狀態
$selected = $categoryData['pid'] == $cat['cid'] ? 'selected=""' : '';
//子欄目disabled
$disabled = Data::isChild($categoryCache, $cat['cid'], $cid) ? 'disabled=""' : '';
//當前欄目不可選
if ($cid == $cat['cid']) {
$disabled = 'disabled="disabled"';
}
$categoryCache[$n]['selected'] = $selected;
$categoryCache[$n]['disabled'] = $disabled;
}
$categoryAccess = $CategoryModel->getCategoryAccess($cid);
//分配角色權限
$this->assign('access', $categoryAccess);
$this->assign('field', $categoryData);
$this->assign('category', $categoryCache);
$this->display();
}
}
示例9: edit
public function edit()
{
if (IS_POST) {
if ($this->db->editCategory()) {
$this->success('修改欄目成功');
} else {
$this->error($this->db->error);
}
} else {
if (!$this->cid || !isset($this->category[$this->cid])) {
$this->error('cid不存在');
}
$cache = $this->category;
$category = $cache[$this->cid];
foreach ($cache as $n => $cat) {
$selected = $disabled = "";
//父欄目select狀態
$selected = $category['pid'] == $cat['cid'] ? 'selected=""' : '';
//子欄目disabled
$disabled = Data::isChild($this->category, $cat['cid'], $this->cid) || $this->cid == $cat['cid'] ? 'disabled=""' : '';
$cache[$n]['selected'] = $selected;
$cache[$n]['disabled'] = $disabled;
}
$categoryAccess = $this->db->getCategoryAccess($this->cid);
//分配角色權限
$this->assign('access', $categoryAccess);
$this->assign('field', $category);
$this->assign('model', $this->model);
$this->assign('category', $cache);
$this->display();
}
}