Initial commit
This commit is contained in:
79
playarea/plugins/bive-admin-panel/template/parents_list.php
Normal file
79
playarea/plugins/bive-admin-panel/template/parents_list.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
$all_parents_items = $variables["all_parents_items"];
|
||||
$parents = $variables["parents"];
|
||||
$item = $variables["item"];
|
||||
|
||||
function render_parent_list($all_parents_items, $parents, $item)
|
||||
{
|
||||
$ul_dom = new DOM("ul");
|
||||
$ul_dom->setAttribute("class", "item-parents__list");
|
||||
|
||||
foreach ($all_parents_items as $key => $parent_item) {
|
||||
$li_dom = render_parent_item($parent_item, $parents, $item);
|
||||
$ul_dom->append($li_dom);
|
||||
}
|
||||
|
||||
$ul_dom->view();
|
||||
}
|
||||
|
||||
function render_parent_item($parent_item, $parents, $item){
|
||||
$li_dom = new DOM("li");
|
||||
$li_dom->setAttribute("class", "item-parent");
|
||||
|
||||
$line_dom = new DOM("div");
|
||||
$line_dom->setAttribute("class", "item-parent__line");
|
||||
|
||||
$label_text_dom = new DOM("label");
|
||||
$label_text_dom->setAttribute("class", "item-parent__checkbox");
|
||||
|
||||
$input_text_dom = new DOM("input", false);
|
||||
$input_text_dom->setAttribute("value", $parent_item->item_id);
|
||||
$input_text_dom->setAttribute("type", "checkbox");
|
||||
$input_text_dom->setAttribute("name", "item_parents[]");
|
||||
$input_text_dom->setAttribute("class", "item-parent__main-checkbox");
|
||||
|
||||
if(check_parent($parents, $parent_item, $item))
|
||||
$input_text_dom->setAttribute("checked", "checked");
|
||||
|
||||
$label_text_dom->append($input_text_dom);
|
||||
$label_text_dom->append("<span>" . $parent_item->get_field("item_name") . "</span>");
|
||||
$line_dom->append($label_text_dom);
|
||||
|
||||
$label_main_dom = new DOM("label");
|
||||
$label_main_dom->setAttribute("class", "item-parent__main");
|
||||
|
||||
$input_main_dom = new DOM("input", false);
|
||||
$input_main_dom->setAttribute("value", $parent_item->item_id);
|
||||
$input_main_dom->setAttribute("type", "radio");
|
||||
$input_main_dom->setAttribute("name", "item_parent");
|
||||
$input_main_dom->setAttribute("class", "item-parent__main-input");
|
||||
|
||||
if($parent_item->item_id == $item->parent_id)
|
||||
$input_main_dom->setAttribute("checked", "checked");
|
||||
|
||||
$p_main_dom = new DOM("p");
|
||||
$p_main_dom->setAttribute("class", "item-parent__main-label");
|
||||
$p_main_dom->append("Основная");
|
||||
|
||||
$label_main_dom->append($input_main_dom);
|
||||
$label_main_dom->append($p_main_dom);
|
||||
$line_dom->append($label_main_dom);
|
||||
|
||||
$li_dom->append($line_dom);
|
||||
|
||||
$childs_main_dom = new DOM("ul");
|
||||
$childs_main_dom->setAttribute("class", "item-parent__childs");
|
||||
|
||||
$childs = $parent_item->get_main_child_items($parent_item->get_class_name());
|
||||
foreach ($childs as $key => $child) {
|
||||
$new_li = render_parent_item($child, $parents, $item);
|
||||
$childs_main_dom->append($new_li);
|
||||
}
|
||||
|
||||
$li_dom->append($childs_main_dom);
|
||||
return $li_dom;
|
||||
}
|
||||
|
||||
render_parent_list($all_parents_items, $parents, $item);
|
||||
|
||||
Reference in New Issue
Block a user