本文整理汇总了PHP中Device::GetDeviceChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::GetDeviceChildren方法的具体用法?PHP Device::GetDeviceChildren怎么用?PHP Device::GetDeviceChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::GetDeviceChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CopyDevice
function CopyDevice($clonedparent = null, $newPosition = null)
{
/*
* Need to make a copy of a device for the purpose of assigning a reservation during a move
*
* The second parameter is optional for a copy. If it is set and the device is a chassis
* this should be set to the ID of the new parent device.
*
* Also do not copy any power or network connections!
*/
// Get the device being copied
$this->GetDevice();
// If this is a chassis device then check for children to cloned BEFORE we change the deviceid
if ($this->DeviceType == "Chassis") {
// Examine the name to try to make a smart decision about the naming
if (preg_match("/(.+?[\\[?\\(]?)(\\d+)-(\\d+)([\\)\\]])?/", $this->Label, $tmpName)) {
$numLen = strlen($tmpName[3]);
$this->Label = sprintf("%s%0" . $numLen . "d-%0" . $numLen . "d%s", $tmpName[1], $tmpName[3] + 1, $tmpName[3] + ($tmpName[3] - $tmpName[2] + 1), @$tmpName[4]);
} else {
$this->Label = $this->Label . " (" . __("Copy") . ")";
}
$childList = $this->GetDeviceChildren();
}
if ($this->ParentDevice > 0) {
/*
* Child devices will need to be constrained to the chassis. Check for open slots
* on whichever side of the chassis the blade is currently. If a slot is available
* clone into the next available slot or return false and display an appropriate
* errror message
*/
$tmpdev = new Device();
$tmpdev->DeviceID = $this->ParentDevice;
$tmpdev->GetDevice();
preg_match("/(.+?[\\[?\\(]?)(\\d+)-(\\d+)([\\)\\]])?/", $tmpdev->Label, $tmpName);
$children = $tmpdev->GetDeviceChildren();
if ($tmpdev->ChassisSlots > 0 || $tmpdev->RearChassisSlots > 0) {
// If we're cloning every child then there is no need to attempt to find empty slots
if (is_null($clonedparent)) {
$front = array();
$rear = array();
$pos = $this->Position;
if ($tmpdev->ChassisSlots > 0) {
for ($i = 1; $i <= $tmpdev->ChassisSlots; $i++) {
$front[$i] = false;
}
}
if ($tmpdev->RearChassisSlots > 0) {
for ($i = 1; $i <= $tmpdev->RearChassisSlots; $i++) {
$rear[$i] = false;
}
}
foreach ($children as $child) {
$child->ChassisSlots == 0 ? $front[$child->Position] = "yes" : ($rear[$child->Position] = "yes");
}
if ($this->ChassisSlots == 0) {
//Front slot device
for ($i = $tmpdev->ChassisSlots; $i >= 1; $i--) {
if ($front[$i] != "yes") {
$this->Position = $i;
}
}
} else {
//Rear slot device
for ($i = $tmpdev->RearChassisSlots; $i >= 1; $i--) {
if ($rear[$i] != "yes") {
$this->Position = $i;
}
}
}
}
// Make sure the position updated before creating a new device
if (isset($pos) && $pos != $this->Position || !is_null($clonedparent)) {
!is_null($clonedparent) ? $this->ParentDevice = $clonedparent : '';
$olddev = new Device();
$olddev->DeviceID = $this->DeviceID;
$olddev->GetDevice();
if (preg_match("/(.*)(.\\d)+(\\ *[\\]|\\)])?/", $olddev->Label, $tmpChild)) {
$numLen = strlen($tmpChild[2]);
$this->Label = sprintf("%s%0" . $numLen . "d%s", $tmpChild[1], $tmpChild[2] + sizeof($children), @$tmpChild[3]);
}
$this->CreateDevice();
$olddev->CopyDeviceCustomValues($this);
} else {
return false;
}
}
} else {
// Set the position in the current cabinet above the usable space. This will
// make the user change the position before they can update it.
$cab = new Cabinet();
$cab->CabinetID = $this->Cabinet;
$cab->GetCabinet();
if ($newPosition == null) {
$this->Position = $cab->CabinetHeight + 1;
} else {
$this->Position = $newPosition;
}
$olddev = new Device();
$olddev->DeviceID = $this->DeviceID;
$olddev->GetDevice();
//.........这里部分代码省略.........
示例2: Device
}
if ($lastCab != $Location) {
$pdf->Cell($cellWidths[1], 6, $Location, 'LR', 0, 'L', $fill);
} else {
$pdf->Cell($cellWidths[1], 6, '', 'LR', 0, 'L', $fill);
}
$pdf->Cell($cellWidths[2], 6, $Position, 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[3], 6, $Label, 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[4], 6, $SerialNo, 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[5], 6, $AssetTag, 'LR', 0, 'L', $fill);
$pdf->Ln();
$fill = !$fill;
if ($reportRow["DeviceType"] == "Chassis") {
$chDev = new Device();
$chDev->DeviceID = $reportRow["DeviceID"];
$chList = $chDev->GetDeviceChildren();
foreach ($chList as $chRow) {
$pdf->Cell($cellWidths[0], 6, '', 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[1], 6, '', 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[2], 6, '(blade)', 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[3], 6, $chRow->Label, 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[4], 6, $chRow->SerialNo, 'LR', 0, 'L', $fill);
$pdf->Cell($cellWidths[5], 6, $chRow->AssetTag, 'LR', 0, 'L', $fill);
$pdf->Ln();
$fill = !$fill;
}
}
$lastDC = $DataCenter;
$lastCab = $Location;
}
$pdf->Cell(array_sum($cellWidths), 0, '', 'T');
示例3: implode
if ($row["TemplateID"] > 0) {
$templ->TemplateID = $row["TemplateID"];
$templ->GetTemplateByID();
$Model = "<a href=\"device_templates.php?TemplateID={$templ->TemplateID}\" target=\"template\">{$templ->Model}</a>";
}
if ($row["Owner"] > 0) {
$dept->DeptID = $row["Owner"];
$dept->GetDeptByID();
$Department = $dept->Name;
}
$dev->DeviceID = $row["DeviceID"];
$tags = implode(",", $dev->GetTags());
$body .= "\t\t<tr>\n\t\t\t\t<td><a href=\"dc_stats.php?dc={$row["DataCenterID"]}\" target=\"datacenter\">{$row["DataCenter"]}</a></td>\n\t\t\t\t<td><a href=\"cabnavigator.php?cabinetid={$row["CabinetID"]}\" target=\"cabinet\">{$row["Location"]}</a></td>\n\t\t\t\t<td>{$row["Position"]}</td>\n\t\t\t\t<td>{$row["Height"]}</td>\n\t\t\t\t<td><a href=\"devices.php?DeviceID={$dev->DeviceID}\" target=\"device\">{$row["Label"]}</a></td>\n\t\t\t\t<td>{$row["SerialNo"]}</td>\n\t\t\t\t<td>{$row["AssetTag"]}</td>\n\t\t\t\t<td><a href=\"search.php?key=dev&DeviceType={$row["DeviceType"]}&search\" target=\"search\">{$row["DeviceType"]}</a></td>\n\t\t\t\t<td>{$Model}</td>\n\t\t\t\t<td>{$tags}</td>\n\t\t\t\t<td>{$Department}</td>\n\t\t\t\t<td>{$date}</td>\n\t\t</tr>\n";
if ($row["DeviceType"] == "Chassis") {
// Find all of the children!
$childList = $dev->GetDeviceChildren();
foreach ($childList as $child) {
$cdate = date("d M Y", strtotime($child->InstallDate));
$cModel = "";
$cDepartment = "";
$ctags = implode(",", $child->GetTags());
if ($child->TemplateID > 0) {
$templ->TemplateID = $child->TemplateID;
$templ->GetTemplateByID();
$cModel = "<a href=\"device_templates.php?TemplateID={$templ->TemplateID}\" target=\"template\">{$templ->Model}</a>";
}
if ($child->Owner > 0) {
$dept->DeptID = $child->Owner;
$dept->GetDeptByID();
$cDepartment = $dept->Name;
}
示例4: CopyDevice
function CopyDevice($clonedparent = null)
{
/*
* Need to make a copy of a device for the purpose of assigning a reservation during a move
*
* The second paremeter is optional for a copy. if it is set and the device is a chassis
* this should be set to the ID of the new parent device.
*
* Also do not copy any power or network connections!
*/
// Get the device being copied
$this->GetDevice();
// If this is a chassis device then check for children to cloned BEFORE we change the deviceid
if ($this->DeviceType == "Chassis") {
$childList = $this->GetDeviceChildren();
}
if ($this->ParentDevice > 0) {
/*
* Child devices will need to be constrained to the chassis. Check for open slots
* on whichever side of the chassis the blade is currently. If a slot is available
* clone into the next available slot or return false and display an appropriate
* errror message
*/
$tmpdev = new Device();
$tmpdev->DeviceID = $this->ParentDevice;
$tmpdev->GetDevice();
$children = $tmpdev->GetDeviceChildren();
if ($tmpdev->ChassisSlots > 0 || $tmpdev->RearChassisSlots > 0) {
// If we're cloning every child then there is no need to attempt to find empty slots
if (is_null($clonedparent)) {
$front = array();
$rear = array();
$pos = $this->Position;
if ($tmpdev->ChassisSlots > 0) {
for ($i = 1; $i <= $tmpdev->ChassisSlots; $i++) {
$front[$i] = false;
}
}
if ($tmpdev->RearChassisSlots > 0) {
for ($i = 1; $i <= $tmpdev->RearChassisSlots; $i++) {
$rear[$i] = false;
}
}
foreach ($children as $child) {
$child->ChassisSlots == 0 ? $front[$child->Position] = "yes" : ($rear[$child->Position] = "yes");
}
if ($this->ChassisSlots == 0) {
//Front slot device
for ($i = $tmpdev->ChassisSlots; $i >= 1; $i--) {
if ($front[$i] != "yes") {
$this->Position = $i;
}
}
} else {
//Rear slot device
for ($i = $tmpdev->RearChassisSlots; $i >= 1; $i--) {
if ($rear[$i] != "yes") {
$this->Position = $i;
}
}
}
}
// Make sure the position updated before creating a new device
if (isset($pos) && $pos != $this->Position || !is_null($clonedparent)) {
!is_null($clonedparent) ? $this->ParentDevice = $clonedparent : '';
$olddev = new Device();
$olddev->DeviceID = $this->DeviceID;
$olddev->GetDevice();
$this->CreateDevice();
$olddev->CopyDeviceCustomValues($this);
} else {
return false;
}
}
} else {
// Set the position in the current cabinet above the usable space. This will
// make the user change the position before they can update it.
$cab = new Cabinet();
$cab->CabinetID = $this->Cabinet;
$cab->GetCabinet();
$this->Position = $cab->CabinetHeight + 1;
$olddev = new Device();
$olddev->DeviceID = $this->DeviceID;
$olddev->GetDevice();
// And finally create a new device based on the exact same info
$this->CreateDevice();
$olddev->CopyDeviceCustomValues($this);
}
// If this is a chassis device and children are present clone them
if (isset($childList)) {
foreach ($childList as $child) {
$child->CopyDevice($this->DeviceID);
}
}
return true;
}
示例5: computeDeviceChildren
/**
* Capture the device values for child devices
*
* @param array $sheetColumns
* @param array $invData
* @param Device $parentDev
* parent device of the child
* @param array $DCName
* @param Cabinet $cab
* @param array $devTemplates
* @param array $deptList a list of departments (Department) indexed by the DeptID
* @param array $contactList list of all contacts (Contact) indexed by ContactID
* @param array $dcContainerList list of containers the data center is positioned in
* @return (integer|array)[] sum of wattage of child devices, array of devices
* in the inventory
*/
function computeDeviceChildren($sheetColumns, $invData, $parentDev, $DCName, $cab, $devTemplates, $deptList, $contactList, $dcContainerList)
{
// capture the device values for child devices
$wattageTotal = 0;
$children = $parentDev->GetDeviceChildren();
if (is_array($children)) {
usort($children, 'cmpDevPos');
$chassisNumSlots = $parentDev->ChassisSlots;
$idx = 1;
$zoneName = getZoneName($cab);
$rowName = getRowName($cab);
foreach ($children as $child) {
if ($idx < $child->Position) {
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
$devSpec['Zone'] = $zoneName;
$devSpec['Row'] = $rowName;
$devSpec['DC Name'] = $DCName;
$devSpec['Cabinet'] = $cab->Location;
$devSpec['Position'] = $idx;
$devSpec['Height'] = $child->Position - $idx;
$devSpec['Device'] = '__EMPTYSLOT';
$devSpec['Parent Device'] = $parentDev->Label;
$invData[] = $devSpec;
$idx = $child->Position;
}
$reserved = $child->Reservation ? 'reserved' : null;
list($manufacturer, $model) = getDeviceTemplateName($devTemplates, $child);
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
$devSpec['DevID'] = $child->DeviceID;
$devSpec['Zone'] = $zoneName;
$devSpec['Row'] = $rowName;
$devSpec['DC Name'] = $DCName;
$devSpec['Cabinet'] = $cab->Location;
$devSpec['Position'] = $child->Position;
$devSpec['Height'] = $child->Height;
$devSpec['Device'] = $child->Label;
$devSpec['Parent Device'] = $parentDev->Label;
$devSpec['Manufacturer'] = $manufacturer;
$devSpec['Model'] = $model;
$devSpec['Device Type'] = $child->DeviceType;
$devSpec['Asset Number'] = $child->AssetTag;
$devSpec['Serial No.'] = $child->SerialNo;
$devSpec['Install Date'] = $child->InstallDate;
$devSpec['Warranty End'] = $child->WarrantyExpire;
$devSpec['Owner'] = getOwnerName($child, $deptList);
$devSpec['Power (W)'] = $child->NominalWatts;
$devSpec['Reservation'] = $reserved;
$devSpec['Contact'] = getContactName($contactList, $child->PrimaryContact);
$devSpec['Tags'] = getTagsString($child);
$devSpec['Notes'] = html_entity_decode(strip_tags($child->Notes), ENT_COMPAT, 'UTF-8');
$wattageTotal += $child->NominalWatts;
$invData[] = $devSpec;
$idx += $child->Height;
}
if ($idx <= $chassisNumSlots) {
$freeSlots = $chassisNumSlots - $idx + 1;
$devSpec = makeEmptySpec($sheetColumns, $dcContainerList);
$devSpec['Zone'] = $zoneName;
$devSpec['Row'] = $rowName;
$devSpec['DC Name'] = $DCName;
$devSpec['Cabinet'] = $cab->Location;
$devSpec['Position'] = $idx;
$devSpec['Height'] = $freeSlots;
$devSpec['Device'] = '__EMPTYSLOT';
$devSpec['Parent Device'] = $parentDev->Label;
$invData[] = $devSpec;
}
}
return array($wattageTotal, $invData);
}