• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getParents函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getParents函数的典型用法代码示例。如果您正苦于以下问题:PHP getParents函数的具体用法?PHP getParents怎么用?PHP getParents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getParents函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getParents

function getParents($pid)
{
    $rs = $GLOBALS['db']->query("select *from tree where id='{$pid}'");
    while ($row = $rs->fetch_array()) {
        array_push($GLOBALS['parents'], $row);
        getParents($row['pid']);
    }
}
开发者ID:shashankkulal,项目名称:iisc-network-monitor,代码行数:8,代码来源:functions.php


示例2: getParents

function getParents($list, $id)
{
    static $ids = [];
    foreach ($list as $key => $value) {
        if ($value['id'] == $id) {
            $ids[] = $value['parent_id'];
            getParents($list, $value['parent_id']);
        }
    }
    return $ids;
}
开发者ID:Jokeramc,项目名称:amc,代码行数:11,代码来源:helpers.php


示例3: getParents

    	<?php 
if (ishttp($pd)) {
    ?>
<div class="item item_1" style="background-image:url(<?php 
    echo $pd;
    ?>
);data:#2b74ba;"></div>
    	<?php 
} else {
    ?>
    		<div class="item item_1" style="background-image:url(/tpl/hualibootx/Public/images/page-general.png);data:#2b74ba;"></div><?php 
}
?>
    </div>
    <?php 
$breadnav = getParents($navList, $nid);
$breadnav = array_slice($breadnav, 0, -1);
?>
<div class="sitecon" style="position: absolute; top: 274px;">
    <div class="container">
        <div class="about_site">
            您的位置:
            <a href="/">首页</a> &gt;
            <?php 
if (is_array($breadnav)) {
    foreach ($breadnav as $key => $bn) {
        ?>
<a href="<?php 
        echo $bn['href'];
        ?>
">
开发者ID:elinxer,项目名称:hualilibrary,代码行数:31,代码来源:a10e3ce8e32e7a44809beb5a1f6989dc.php


示例4: generate_permalink

/**
 * generate permalink url from tokenized permalink structure
 * uses a very basic str_replace based token replacer, not a parser
 * TOKENS (%tokenid%)
 *  %path% - path heirarchy to slug
 *  %slug% - slug
 *  %parent% - direct parent of slug
 *
 * supports prettyurl or any other permalink structure
 * eg. ?id=%slug%&parent=%parent%&path=%path%
 * 
 * @param  (str) $slug      slug to resolve permalink for	
 * @param  (str) $permalink (optional) permalink structure
 * @return (str)            	
 */
function generate_permalink($slug, $permalink = null)
{
    global $PERMALINK;
    $slug = (string) $slug;
    if (!isset($permalink)) {
        $plink = $PERMALINK;
        if (empty($PERMALINK)) {
            $plink = getDef('GSDEFAULTPERMALINK');
        }
    } else {
        $plink = $permalink;
    }
    // replace PATH token
    if (containsToken('path', $plink)) {
        // remove PARENT tokens if path, since it would be pointless and probably accidental
        // leaving in for now lets not make assumptions
        // $plink = replaceToken('parent','',$plink);
        $pagepath = getParents($slug);
        if ($pagepath) {
            $pagepath = implode('/', array_reverse($pagepath));
            $plink = replaceToken('path', $pagepath, $plink);
        } else {
            // page has no parents, remove token
            $plink = replaceToken('path', '', $plink);
        }
    }
    // replace PARENT token
    if (containsToken('parent', $plink)) {
        $parent = getParent($slug);
        $plink = replaceToken('parent', $parent, $plink);
    }
    // replace SLUG token
    $plink = replaceToken('slug', $slug, $plink);
    $plink = str_replace('//', '/', $plink);
    // clean up any double slashes
    // debugLog($url);
    // debugLog($plink);
    return no_lsl($plink);
}
开发者ID:kix23,项目名称:GetSimpleCMS,代码行数:54,代码来源:basic.php


示例5: updateObjectAllocation

function updateObjectAllocation()
{
    global $remote_username, $sic;
    if (!isset($_REQUEST['got_atoms'])) {
        unset($_GET['page']);
        unset($_GET['tab']);
        unset($_GET['op']);
        unset($_POST['page']);
        unset($_POST['tab']);
        unset($_POST['op']);
        return buildRedirectURL(NULL, NULL, $_REQUEST);
    }
    $object_id = getBypassValue();
    $object = spotEntity('object', $object_id);
    $changecnt = 0;
    // Get a list of rack ids which are parents of the object
    $parentRacks = reduceSubarraysToColumn(getParents($object, 'rack'), 'id');
    $workingRacksData = array();
    foreach ($_REQUEST['rackmulti'] as $cand_id) {
        if (!isset($workingRacksData[$cand_id])) {
            $rackData = spotEntity('rack', $cand_id);
            amplifyCell($rackData);
            $workingRacksData[$cand_id] = $rackData;
        } else {
            $rackData = $workingRacksData[$cand_id];
        }
        $is_ro = !rackModificationPermitted($rackData, 'updateObjectAllocation', FALSE);
        // It's zero-U mounted to this rack on the form, but not in the DB.  Mount it.
        if (isset($_REQUEST["zerou_{$cand_id}"]) && !in_array($cand_id, $parentRacks)) {
            if ($is_ro) {
                continue;
            }
            $changecnt++;
            commitLinkEntities('rack', $cand_id, 'object', $object_id);
        }
        // It's not zero-U mounted to this rack on the form, but it is in the DB.  Unmount it.
        if (!isset($_REQUEST["zerou_{$cand_id}"]) && in_array($cand_id, $parentRacks)) {
            if ($is_ro) {
                continue;
            }
            $changecnt++;
            commitUnlinkEntities('rack', $cand_id, 'object', $object_id);
        }
    }
    foreach ($workingRacksData as &$rd) {
        applyObjectMountMask($rd, $object_id);
    }
    $oldMolecule = getMoleculeForObject($object_id);
    foreach ($workingRacksData as $rack_id => $rackData) {
        $is_ro = !rackModificationPermitted($rackData, 'updateObjectAllocation', FALSE);
        if ($is_ro || !processGridForm($rackData, 'F', 'T', $object_id)) {
            continue;
        }
        $changecnt++;
        // Reload our working copy after form processing.
        $rackData = spotEntity('rack', $cand_id);
        amplifyCell($rackData);
        applyObjectMountMask($rackData, $object_id);
        $workingRacksData[$rack_id] = $rackData;
    }
    if ($changecnt) {
        // Log a record.
        $newMolecule = getMoleculeForObject($object_id);
        usePreparedInsertBlade('MountOperation', array('object_id' => $object_id, 'old_molecule_id' => count($oldMolecule) ? createMolecule($oldMolecule) : NULL, 'new_molecule_id' => count($newMolecule) ? createMolecule($newMolecule) : NULL, 'user_name' => $remote_username, 'comment' => empty($sic['comment']) ? NULL : $sic['comment']));
    }
    ###############################################################################################
    # set hostgroup for zabbix host
    $allracks = getMoleculeForObject($object_id);
    $rackids = array();
    $racknames = array();
    foreach ($allracks as $rack) {
        if (in_array($rack['rack_id'], $rackids)) {
            continue;
        }
        array_push($rackids, $rack['rack_id']);
        $rackdata = spotEntity('rack', $rack['rack_id']);
        array_push($racknames, $rackdata['name']);
    }
    $result = updateHostGroup($object['name'], $racknames);
    if (isset($result['error'])) {
        showError('Setting hostgroup for zabbix host is failed. Error message:' . $result['error']);
    }
    # END
    ###############################################################################################
    showFuncMessage(__FUNCTION__, 'OK', array($changecnt));
}
开发者ID:micromachine,项目名称:RackTables-ZABBIX-bridge,代码行数:86,代码来源:ophandlers.php


示例6: initRackTablesObject

function initRackTablesObject($rackDatas)
{
    // zabbix host data
    $params = array('output' => 'extend');
    $result = doPost('host.get', $params);
    $hosts = isset($result['result']) ? $result['result'] : array();
    $objectDatas = array();
    foreach ($hosts as $host) {
        $object_type_id = 4;
        $object_name = isset($host['host']) ? $host['host'] : "";
        $object_label = "";
        $object_asset_no = "";
        $taglist = array();
        $has_problems = $host['status'] == 0 ? 'no' : 'yes';
        $object_id = commitAddObject($object_name, $object_label, $object_type_id, $object_asset_no, $taglist);
        usePreparedUpdateBlade('Object', array('has_problems' => $has_problems), array('id' => $object_id));
        $objectDatas[$host['hostid']] = $object_id;
        // set hostgroup
        $params = array('output' => array('name'), 'hostids' => array($host['hostid']));
        $result = doPost('hostgroup.get', $params);
        $hostgroups = isset($result['result']) ? $result['result'] : array();
        $rack_ids = array();
        $_REQUEST = array();
        foreach ($hostgroups as $hostgroup) {
            if (isset($rackDatas[$hostgroup['name']])) {
                $rack = $rackDatas[$hostgroup['name']];
                amplifyCell($rack);
                array_push($rack_ids, $rack['id']);
                $height = $rack['height'];
                for ($i = 0; $i < 3; $i++) {
                    for ($j = $height; $j > 0; $j--) {
                        if ($rack[$j][$i]['state'] == 'F') {
                            # state == "T" : mounted
                            $_REQUEST['atom_' . $rack['id'] . "_{$j}" . "_{$i}"] = 'on';
                            break 2;
                        }
                    }
                }
            }
        }
        $_REQUEST['object_id'] = $object_id;
        $_REQUEST['rackmulti'] = $rack_ids;
        $object = spotEntity('object', $object_id);
        $changecnt = 0;
        // Get a list of rack ids which are parents of the object
        $parentRacks = reduceSubarraysToColumn(getParents($object, 'rack'), 'id');
        $workingRacksData = array();
        foreach ($_REQUEST['rackmulti'] as $cand_id) {
            if (!isset($workingRacksData[$cand_id])) {
                $rackData = spotEntity('rack', $cand_id);
                amplifyCell($rackData);
                $workingRacksData[$cand_id] = $rackData;
            } else {
                $rackData = $workingRacksData[$cand_id];
            }
            $is_ro = !rackModificationPermitted($rackData, 'updateObjectAllocation', FALSE);
            // It's zero-U mounted to this rack on the form, but not in the DB.  Mount it.
            if (isset($_REQUEST["zerou_{$cand_id}"]) && !in_array($cand_id, $parentRacks)) {
                if ($is_ro) {
                    continue;
                }
                $changecnt++;
                commitLinkEntities('rack', $cand_id, 'object', $object_id);
            }
            // It's not zero-U mounted to this rack on the form, but it is in the DB.  Unmount it.
            if (!isset($_REQUEST["zerou_{$cand_id}"]) && in_array($cand_id, $parentRacks)) {
                if ($is_ro) {
                    continue;
                }
                $changecnt++;
                commitUnlinkEntities('rack', $cand_id, 'object', $object_id);
            }
        }
        foreach ($workingRacksData as &$rd) {
            applyObjectMountMask($rd, $object_id);
        }
        $oldMolecule = getMoleculeForObject($object_id);
        foreach ($workingRacksData as $rack_id => $rackData) {
            $is_ro = !rackModificationPermitted($rackData, 'updateObjectAllocation', FALSE);
            if ($is_ro || !processGridForm($rackData, 'F', 'T', $object_id)) {
                continue;
            }
            $changecnt++;
            // Reload our working copy after form processing.
            $rackData = spotEntity('rack', $cand_id);
            amplifyCell($rackData);
            applyObjectMountMask($rackData, $object_id);
            $workingRacksData[$rack_id] = $rackData;
        }
        if ($changecnt) {
            // Log a record.
            $newMolecule = getMoleculeForObject($object_id);
            global $remote_username, $sic;
            usePreparedInsertBlade('MountOperation', array('object_id' => $object_id, 'old_molecule_id' => count($oldMolecule) ? createMolecule($oldMolecule) : NULL, 'new_molecule_id' => count($newMolecule) ? createMolecule($newMolecule) : NULL, 'user_name' => $remote_username, 'comment' => empty($sic['comment']) ? NULL : $sic['comment']));
        }
        // set IP
        $params = array('output' => 'extend', 'hostids' => $host['hostid']);
        $result = doPost('hostinterface.get', $params);
        $hostinterfaces = isset($result['result']) ? $result['result'] : array();
        foreach ($hostinterfaces as $interface) {
//.........这里部分代码省略.........
开发者ID:micromachine,项目名称:RackTables-ZABBIX-bridge,代码行数:101,代码来源:init_racktables.php


示例7: getParents

            
            <!-- PAGE CONTENT -->
            <div class="page-content">
                
                <!-- START X-NAVIGATION VERTICAL -->
                <?php 
include "config/topbar.php";
?>
                <!-- END X-NAVIGATION VERTICAL -->                     
                
                <!-- START BREADCRUMB -->
                <ol class="breadcrumb" id="navPath">
                    <li><a href="home.php">Home</a></li>
                    <li><a href="link_status.php">Link Status</a></li>
                   <?php 
getParents($current_IP['pid']);
$parents = array_reverse($parents);
foreach ($parents as $v) {
    ?>
                   <li><a href="link_status.php?ip=<?php 
    echo $v['ip'];
    ?>
"><?php 
    echo $v['sname'];
    ?>
</a></li>
                   <?php 
}
?>
                   <li class="active"><?php 
echo $current_IP['sname'];
开发者ID:shashankkulal,项目名称:iisc-network-monitor,代码行数:30,代码来源:link_status.php


示例8: getParentsToString

/**
 * @param string $categoryCode
 * @return null|string
 */
function getParentsToString($categoryCode)
{
    $parents = getParents($categoryCode);
    if (!empty($parents)) {
        $parents = array_reverse($parents);
        $categories = array();
        foreach ($parents as $category) {
            $categories[] = $category['code'];
        }
        $categoriesInString = implode(' > ', $categories) . ' > ';
        return $categoriesInString;
    }
    return null;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:18,代码来源:course_category.lib.php


示例9: renderRackSpaceForObject

function renderRackSpaceForObject($object_id)
{
    // Always process occupied racks plus racks chosen by user. First get racks with
    // already allocated rackspace...
    $workingRacksData = getResidentRacksData($object_id);
    // ...and then add those chosen by user (if any).
    if (isset($_REQUEST['rackmulti'])) {
        foreach ($_REQUEST['rackmulti'] as $cand_id) {
            if (!isset($workingRacksData[$cand_id])) {
                $rackData = spotEntity('rack', $cand_id);
                amplifyCell($rackData);
                $workingRacksData[$cand_id] = $rackData;
            }
        }
    }
    // Get a list of rack ids that are parents of this object.
    $object = spotEntity('object', $object_id);
    $parentRacks = reduceSubarraysToColumn(getParents($object, 'rack'), 'id');
    // Main layout starts.
    echo "<table border=0 class=objectview cellspacing=0 cellpadding=0><tr>";
    // Left portlet with rack list.
    echo "<td class=pcleft height='1%'>";
    startPortlet('Racks');
    $allRacksData = listCells('rack');
    // filter rack list to match only racks having common tags with the object (reducing $allRacksData)
    if (!isset($_REQUEST['show_all_racks']) and getConfigVar('FILTER_RACKLIST_BY_TAGS') == 'yes') {
        $matching_racks = array();
        $object = spotEntity('object', $object_id);
        $matched_tags = array();
        foreach ($allRacksData as $rack) {
            $tag_chain = array_merge($rack['etags'], $rack['itags']);
            foreach ($object['etags'] as $tag) {
                if (tagOnChain($tag, $tag_chain)) {
                    $matching_racks[$rack['id']] = $rack;
                    $matched_tags[$tag['id']] = $tag;
                    break;
                }
            }
        }
        // add current object's racks even if they dont match filter
        foreach ($workingRacksData as $rack_id => $rack) {
            if (!isset($matching_racks[$rack_id])) {
                $matching_racks[$rack_id] = $rack;
            }
        }
        // if matching racks found, and rack list is reduced, show 'show all' link
        if (count($matching_racks) and count($matching_racks) != count($allRacksData)) {
            $filter_text = '';
            foreach ($matched_tags as $tag) {
                $filter_text .= (empty($filter_text) ? '' : ' or ') . '{' . $tag['tag'] . '}';
            }
            $href_show_all = trim($_SERVER['REQUEST_URI'], '&');
            $href_show_all .= htmlspecialchars('&show_all_racks=1');
            echo "(filtered by <span class='filter-text'>{$filter_text}</span>, <a href='{$href_show_all}'>show all</a>)<p>";
            $allRacksData = $matching_racks;
        }
    }
    if (count($allRacksData) <= getConfigVar('RACK_PRESELECT_THRESHOLD')) {
        foreach ($allRacksData as $rack) {
            if (!array_key_exists($rack['id'], $workingRacksData)) {
                amplifyCell($rack);
                $workingRacksData[$rack['id']] = $rack;
            }
        }
    }
    foreach (array_keys($workingRacksData) as $rackId) {
        applyObjectMountMask($workingRacksData[$rackId], $object_id);
    }
    printOpFormIntro('updateObjectAllocation');
    renderRackMultiSelect('rackmulti[]', $allRacksData, array_keys($workingRacksData));
    echo "<br><br>";
    finishPortlet();
    echo "</td>";
    // Middle portlet with comment and submit.
    echo "<td class=pcleft>";
    startPortlet('Comment (for Rackspace History)');
    echo "<textarea name=comment rows=10 cols=40></textarea><br>\n";
    echo "<input type=submit value='Save' name=got_atoms>\n";
    echo "<br><br>";
    finishPortlet();
    echo "</td>";
    // Right portlet with rendered racks. If this form submit is not final, we have to
    // reflect the former state of the grid in current form.
    echo "<td class=pcright rowspan=2 height='1%'>";
    startPortlet('Working copy');
    includeJQueryUI(false);
    addJS('js/racktables.js');
    addJS('js/bulkselector.js');
    echo '<table border=0 cellspacing=10 align=center><tr>';
    foreach ($workingRacksData as $rack_id => $rackData) {
        $is_ro = !rackModificationPermitted($rackData, 'updateObjectAllocation');
        // Order is important here: only original allocation is highlighted.
        highlightObject($rackData, $object_id);
        markupAtomGrid($rackData, 'T');
        // If we have a form processed, discard user input and show new database
        // contents.
        if (!$is_ro && isset($_REQUEST['rackmulti'][0])) {
            // is an update
            mergeGridFormToRack($rackData);
        }
//.........这里部分代码省略.........
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:101,代码来源:interface.php


示例10: getParents

function getParents($cate, $id, $pid_name = 'pid', $id_name = 'id')
{
    $arr = array();
    foreach ($cate as $v) {
        if ($v[$id_name] == $id) {
            $arr[] = $v;
            $arr = array_merge(getParents($cate, $v[$pid_name], $pid_name, $id_name), $arr);
        }
    }
    return $arr;
}
开发者ID:noikiy,项目名称:baomihua,代码行数:11,代码来源:function.php


示例11: getPagePath

/**
 * get PAGE path
 * @param  str $pageId slug of PAGE to get path to
 * @return str         path/to/pageId
 */
function getPagePath($pageId)
{
    $parents = getParents($pageId);
    if ($parents) {
        return implode('/', array_reverse($parents)) . '/' . $pageId;
    }
    return $pageId;
}
开发者ID:HelgeSverre,项目名称:GetSimpleCMS,代码行数:13,代码来源:filter_functions.php


示例12: getParents

 /**
  * get list of sub-locations, recursive
  *
  * @param array $locs cache
  * @param int   $id   locations parent
  *
  * @return list of sub-locations
  */
 function getParents($locs, $id)
 {
     if (!$id) {
         return '';
     }
     foreach ($locs as $loc) {
         if ($loc['id'] == $id) {
             return getParents($locs, $loc['parent_id']) . ' / ' . $loc['name'];
         }
     }
     return '';
 }
开发者ID:raylouis,项目名称:kvwebme,代码行数:20,代码来源:api-funcs.php



注:本文中的getParents函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getParenttab函数代码示例发布时间:2022-05-15
下一篇:
PHP getParentTab函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap