function generate_tree($id, $mode = '') { # selected item # get childs $child_array = get_childs($id, $mode); # get information of selected item $query = 'SELECT DISTINCT attr_value as name,ItemLinks.fk_id_item AS item_id, (SELECT config_class FROM ConfigItems,ConfigClasses WHERE id_class=fk_id_class AND id_item=item_id) AS type, (SELECT attr_value FROM ConfigValues, ItemLinks, ConfigAttrs, ConfigClasses WHERE ConfigValues.fk_id_item = ItemLinks.fk_item_linked2 AND id_attr = ConfigValues.fk_id_attr AND attr_name = "icon_image" AND id_class = fk_id_class AND config_class = "os" AND ItemLinks.fk_id_item = item_id ) AS os_icon FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses WHERE ItemLinks.fk_id_item=ConfigValues.fk_id_item AND id_attr=ItemLinks.fk_id_attr AND ConfigAttrs.visible="yes" AND fk_id_class=id_class AND (SELECT naming_attr FROM ConfigAttrs WHERE id_attr=ConfigValues.fk_id_attr)="yes" AND ItemLinks.fk_id_item="' . $id . '" ORDER BY config_class DESC,attr_value'; $selected_item_info = db_handler($query, "assoc", "Get informations on selected item"); # get informations about host # prepend inforomation from selected host to the top of the list array_unshift($child_array, get_informations($id)); # set values of selected item AND put all childs (generated bevore) in it. $root_item = array($id => array("id" => $id, "selected" => TRUE, "status" => 'open', "name" => $selected_item_info["name"], "type" => $selected_item_info["type"], "os_icon" => $selected_item_info["os_icon"], "childs" => $child_array)); # get parents $parents_flat = get_parents($id); # make the parents array ordered top2down $parents_flat = array_reverse($parents_flat); # prepare list (if there are parents call the prepare function if (!empty($parents_flat)) { $tree = prepare_dependency($parents_flat, $root_item); } else { $tree = $root_item; } ## Display the top tree item # check for parent loop error if (isset($tree[0]["status"]) and $tree[0]["status"] == "loop_error") { # make a error item at the top $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => TXT_DEPVIEW_ERROR_LOOP, "type" => "warn", "childs" => $tree)); } else { # make a root tree at the top $dependency_tree = array("root" => array("id" => "root", "status" => 'open', "name" => "Top level", "type" => "parent", "childs" => $tree)); } //echo "<pre>"; //var_dump($tree); //echo "</pre>"; echo '<div>'; displayTree_list($dependency_tree); echo '</div>'; }
function get_childs_rdn($baseDN) { $childs = get_childs($baseDN, array("dn")); # print_r($childs); echo "<br><br>"; $childs_rdn = array(); foreach ($childs as $item) { $exp = explode(',', $item['dn']); $rdn = $exp[0]; $childs_rdn[] = $rdn; } # print_r($childs_rdn); return $childs_rdn; }
function get_childs($catid) { $cates = get_category($catid); if ($cates) { $str = ''; foreach ($cates as $key => $val) { $str .= $key . ','; $str .= get_childs($key); } return $str; } else { return ''; } }
<?php /** * Template Name: One Page Template Test * Author: Trang Huynh */ do_action('st_theme_start'); get_header(); $GLOBALS['st_template_file_name'] = 'page'; // get page template // get child pages of Home page $current_front_page_ID = get_option('page_on_front'); $section_list = get_childs($current_front_page_ID); do_action('st_before_layout'); foreach ($section_list as $page) { $slug = $page->post_name; $title = $page->post_title; $st_page_options = $st_page_builder = get_page_builder_options($page->ID); $builder_content = get_page_builder_content($page->ID); $showTitle = true; // echo $st_page_options['page_options']['show_title']; if (empty($st_page_options['page_options']['show_title']) || $st_page_options['page_options']['show_title'] == '') { $showTitle = false; } $showContent = true; if (empty($st_page_options['page_options']['show_content']) || $st_page_options['page_options']['show_content'] == '') { $showContent = false; } // get_template_part('templates/layout/'.st_get_layout()); do_action('st_top_page_template'); ?>
<?php session_start(); include_once '../dao/serviceskills.php'; $parent_skill_id = $_GET['skillid']; $_SESSION['parent_id'] = $_GET['skillid']; ?> <?php $names = array(); $list_record = get_childs($parent_skill_id); if ($list_record > 0) { ?> <div class="scroll-pane skill-selector"> <?php $list_count = count($list_record); $i = 0; while ($list_count > $i) { ?> <a id="level2_<?php echo $i; ?> " name="level2" href="javascript:void(0);" onclick="select_level2_value(this,<?php echo $list_record[$i]['serviceskill_id']; ?> );"><?php echo $list_record[$i]['serviceskillname']; ?> </a> <?php $i++;
function adsList_post() { $this->load->model("webservice_api_model"); $this->load->helper('wall_type'); if (count($this->post()) > 0) { $input = $this->inputCleaner($this->post()); } // clean input variables // get list of ads //$re = $this->webservice_api_model->adsList($input['offset'],$input['limit'],$input); $filter = array(); // keyword filter if (isset($input['keyword'])) { $filter['title'] = $input['keyword']; } // cat filter if (isset($input['cat']) && $input['cat'] != 'false') { $filter['cat'] = $input['cat']; } // cat filter if (isset($input['state']) && $input['state'] != 0) { $filter['state'] = $input['state']; } // get full list of childs of this parent cat // if (isset($filter['cat'])) { $parent = $filter['cat']; $childs = get_childs($parent); //print_r($childs); $filter['cat'] = $childs; } // print_r($filter); if (isset($input['offset']) && isset($input['offset'])) { $re = $this->webservice_api_model->get_list($filter, $input['offset'], $input['limit']); } else { $re = $this->webservice_api_model->get_list($filter, 0); } // foreach for convert to base64 images //foreach($re as $key=>$value) // { // if($value['pic']!="") // { // // conver to base64 and return to $re[$key]['basepic'] // $month = date('ym',strtotime($value['ads_subdate'])); // $day = date('d',strtotime($value['ads_subdate'])); // $re[$key]['basepic'] = $this->imageToBase64(base_url("uploads/adspics/$month/$day/$value[pic]")); // } // else // { // // if ads dont have a adsPic set base64 no pic avatar // $re[$key]['basepic'] = $this->imageToBase64(base_url("uploads/adspics/no-pic.png")); // } // // } // url images foreach ($re as $key => $value) { if ($value['pic'] != "") { // image url return to $re[$key]['basepic'] $month = date('ym', strtotime($value['ads_subdate'])); $day = date('d', strtotime($value['ads_subdate'])); $re[$key]['basepic'] = "{$month}/{$day}/{$value['pic']}"; } else { // if ads dont have a adsPic set no pic avatar $re[$key]['basepic'] = ""; } } if (count($re) > 0) { $re = array("status" => 1000, "data" => $re); $this->response($re, 200); // success : return listed ADSs } else { $re = array("status" => 1001, "data" => "some error happend , check error number in error list."); //1001 not found $this->response($re, 200); // Faild : NotFound Record } }
function get_childs($id, $mode, $levels = 0) { global $all_childs; $all_childs[$id] = TRUE; $childs = array(); $services = array(); $child_id = 0; # get entries linked as child $query = 'SELECT DISTINCT attr_value,ItemLinks.fk_id_item AS item_id, (SELECT config_class FROM ConfigItems,ConfigClasses WHERE id_class=fk_id_class AND id_item=item_id) AS config_class, (SELECT attr_value FROM ConfigValues, ItemLinks, ConfigAttrs, ConfigClasses WHERE ConfigValues.fk_id_item = ItemLinks.fk_item_linked2 AND id_attr = ConfigValues.fk_id_attr AND attr_name = "icon_image" AND id_class = fk_id_class AND config_class = "os" AND ItemLinks.fk_id_item = item_id ) AS os_icon FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses WHERE ItemLinks.fk_id_item=ConfigValues.fk_id_item AND id_attr=ItemLinks.fk_id_attr AND ConfigAttrs.visible="yes" AND fk_id_class=id_class AND (SELECT naming_attr FROM ConfigAttrs WHERE id_attr=ConfigValues.fk_id_attr)="yes" AND ItemLinks.fk_item_linked2="' . $id . '" ORDER BY config_class DESC,attr_value'; $result = db_handler($query, 'result', "get childs from {$id}"); while ($entry = mysql_fetch_assoc($result)) { /* #special for services if($entry["config_class"] == "service"){ $host_query = 'SELECT attr_value AS hostname FROM ConfigValues,ConfigAttrs,ConfigClasses,ItemLinks WHERE fk_item_linked2=ConfigValues.fk_id_item AND id_attr=ConfigValues.fk_id_attr AND naming_attr="yes" AND fk_id_class = id_class AND config_class="host" AND ItemLinks.fk_id_item='.$entry["item_id"]; $hostname = db_handler($host_query, "getOne", "Get linked hostnames"); } */ # set child //var_dump($entry); if ($entry["config_class"] == "service") { if (!isset($childs["services"]["id"])) { $service_tree = array("id" => "service_{$id}", "status" => 'closed', "name" => "Services", "type" => "service"); $childs["services"] = $service_tree; } $childs["services"]["childs"][$child_id]["parent"] = $id; $childs["services"]["childs"][$child_id]["id"] = $entry["item_id"]; $childs["services"]["childs"][$child_id]["name"] = $entry["attr_value"]; $childs["services"]["childs"][$child_id]["type"] = $entry["config_class"]; # Nagiosview link if ($mode == "nagiosview") { $link = generate_nagios_service_link($id, $entry["attr_value"]); $childs["services"]["childs"][$child_id]["link"] = $link; } } elseif ($entry["config_class"] == "advanced-service") { if (!isset($childs["advanced-services"]["id"])) { $service_tree = array("id" => "service_{$id}", "status" => 'closed', "name" => "Advanced-services", "type" => "service"); $childs["advanced-services"] = $service_tree; } $childs["advanced-services"]["childs"][$child_id]["parent"] = $id; $childs["advanced-services"]["childs"][$child_id]["id"] = $entry["item_id"]; $childs["advanced-services"]["childs"][$child_id]["name"] = $entry["attr_value"]; $childs["advanced-services"]["childs"][$child_id]["type"] = "service"; // advanced services display as services # Nagiosview link if ($mode == "nagiosview") { $link = generate_nagios_service_link($id, $entry["attr_value"]); $childs["advanced-services"]["childs"][$child_id]["link"] = $link; } } elseif ($entry["config_class"] == "host") { $childs[$child_id]["parent"] = $id; $childs[$child_id]["id"] = $entry["item_id"]; $childs[$child_id]["name"] = $entry["attr_value"]; $childs[$child_id]["type"] = $entry["config_class"]; $childs[$child_id]["os_icon"] = $entry["os_icon"]; # Nagiosview link if ($mode == "nagiosview") { $link = generate_nagios_pnp_link($id); // $link = generate_nagios_pnp_link($id, $entry["attr_value"]); $childs[$child_id]["link"] = $link; } # check if that child is called a second time (prevent a endless looilds) if (!isset($all_childs[$entry["item_id"]])) { # save the child and parent combinatino, so that a loop can be prevented //$all_childs[ $childs[$child_id]["parent"].":".$childs[$child_id]["id"] ] = TRUE; //$all_childs[ $entry["item_id"] ] = TRUE; # get childs $childs[$child_id]["childs"] = get_childs($entry["item_id"], $mode, $levels + 1); # get informations about host # prepend the Host information to the beginning of the array array_unshift($childs[$child_id]["childs"], get_informations($entry["item_id"])); # remove from loop detection unset($all_childs[$entry["item_id"]]); } else { # re-iteration $childs[$child_id]["childs"] = error_loop($entry["item_id"]); $childs[$child_id]["status"] = "open"; } } # increase child id $child_id++; } # return child information NConf_DEBUG::set($childs, 'DEBUG', "child tree"); return $childs; }
function get_childs($id) { $children = array(); $result = mysql_query('select * from tree_struct where pid=' . $id . ' order by lft'); if ($result) { while ($row = mysql_fetch_assoc($result)) { $children[$row['id']] = $row; if ($row['type'] != 'article') { $children[$row['id']]['children'] = get_childs($row['id']); } } } return $children; }
public function index($filter = false, $offset = 0) { $this->load->helper('wall_type'); $this->load->helper('wall_mapdb'); date_default_timezone_set('Asia/Tehran'); // state filter if (isset($_POST['state']) && $_POST['state'] != 'false') { $filter['state'] = $_POST['state']; $this->session->set_userdata('state', $filter['state']); } elseif (isset($_GET['state']) && $_GET['state'] != 'false') { $filter['state'] = $_GET['state']; $this->session->set_userdata('state', $filter['state']); } elseif ($this->session->userdata('state')) { $filter['state'] = $this->session->userdata('state'); } $data['state_id'] = $filter['state']; // if(isset($filter['state']) && $filter['state'] != '0'){ // $data['state_title'] = get_state_title($filter['state']); // }else{ // $data['state_title'] = "تمام شهرها"; // } // keyword filter if (isset($_POST['keyword']) && $_POST['keyword'] != 'false') { $filter['keyword'] = $_POST['keyword']; } elseif (isset($_GET['keyword']) && $_GET['keyword'] != 'false') { $filter['keyword'] = $_GET['keyword']; } // cat filter if (isset($_POST['cat']) && $_POST['cat'] != 'false') { $filter['cat'] = $_POST['cat']; } elseif (isset($_GET['cat']) && $_GET['cat'] != 'false') { $filter['cat'] = $_GET['cat']; } // offset filter if (isset($_POST['offset']) && $_POST['offset'] != 'false') { $filter['offset'] = $_POST['offset']; } elseif (isset($_GET['offset']) && $_GET['offset'] != 'false') { $filter['offset'] = $_GET['offset']; } else { $filter['offset'] = 0; } // get full list of childs of this parent cat if (isset($filter['cat'])) { $parent = $filter['cat']; $childs = get_childs($parent); $filter['cat'] = $childs; } $this->load->model('ads_model'); $data['adss'] = $this->ads_model->get_list($filter, $offset); if (isset($_POST['from']) && ($_POST['from'] == "ajaxFilter" or $_POST['from'] = "ajaxAutoLoad")) { $last_id = 0; $ctr = 0; foreach ($data['adss'] as $ads) { $ctr++; $detailLink = site_url("ads/detail/{$ads['ads_id']}"); if ($last_id == $ads['ads_id']) { continue; } else { $last_id = $ads['ads_id']; } if ($ads['price'] == '' or $ads['price'] == '0') { $price = 'توافقی'; } else { $price = $ads['price']; } $now = new DateTime(); $subdate = new DateTime($ads['ads_subdate']); $diff = (int) date_diff($now, $subdate)->format("%R%a"); // check date for days switch ($diff) { case 0: $ads_subdate = "امروز"; break; case -1: $ads_subdate = "دیروز"; break; case -2: $ads_subdate = "2 روز قبل"; break; case -3: $ads_subdate = "3 روز قبل"; break; default: $ads_subdate = $this->jdf->g_to_j_dayAndMonthTitle(strtotime($ads['ads_subdate'])); break; } echo "\n\t\t \t<div class=\"userads1\">\n \t\t<div class=\"contuserads1\">\n\t \t\t<a href=\"{$detailLink}\">"; $month = date('ym', strtotime($ads['pic_subdate'])); $day = date('d', strtotime($ads['pic_subdate'])); if ($ads['pic'] != '' && file_exists("./uploads/adspics/{$month}/{$day}/thumbs/{$ads['pic']}")) { $adsPic = base_url("uploads/adspics/{$month}/{$day}/{$ads['pic']}"); echo "\n\t\t\t\t \t\t<img src=\"{$adsPic}\" />"; } elseif ($ads['cat_pic'] != "" && file_exists("./assets/graphicfiles/cats/{$ads['cat_pic']}")) { $catPic = base_url("assets/graphicfiles/cats/{$ads['cat_pic']}"); echo "<img src=\"{$catPic}\" />"; } else { $defaultPic = base_url("assets/graphicfiles/imguser.png"); echo "\n\t\t\t\t \t\t<img src=\"{$defaultPic}\" />"; } echo "</a>\n\t\t\t \t</div>\n\t <div class=\"contuserads1\">\n\t \t<span id=\"spantitle1\">\n \t\t<a href=\"{$detailLink}\">{$ads['title']}</a>\n\t </span>\n\t <span id=\"spantime1\">\n\t \t<i class=\"icon calendar\"></i> {$ads_subdate}\n\t </span>\n\t <span id=\"spanmoney1\">\n\t \t<i class=\"icon money\"></i> {$price}\n\t </span>\n\t </div>\n\t\t\t </div>"; } if ($ctr == 0) { //echo "110"; //echo "<div class=\"noAdsMsg\"><center>آگهی یافت نشد !</center></div>"; } } else { // get parent cats list if (isset($_GET['cat']) && $_GET['cat'] != 0) { $data['routes'] = get_parents($_GET['cat']); $data['cats'] = get_slave_items(1, $_GET['cat']); } else { //$data['routes'] = array(); $data['cats'] = get_slave_items(1, 0); } $data['states'] = get_state(); $this->load->view('ads/show', $data); } }
function get_childs($parent) { if ($GLOBALS['ctr'] == 0) { $GLOBALS['ctr']++; array_push($GLOBALS['childs'], $parent); } $childs = get_slave_items(1, $parent); if (isset($childs[0])) { foreach ($childs as $child) { array_push($GLOBALS['childs'], $child['id']); array_push($GLOBALS['childs'], $child['title']); get_childs($child['id']); } } else { return $GLOBALS['childs']; } return $GLOBALS['childs']; }