本文整理汇总了PHP中CLink::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP CLink::setId方法的具体用法?PHP CLink::setId怎么用?PHP CLink::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLink
的用法示例。
在下文中一共展示了CLink::setId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$resourceid = !empty($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid'];
$containerid = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$graphDims = getGraphDims();
$graphDims['graphHeight'] = $this->screenitem['height'];
$graphDims['width'] = $this->screenitem['width'];
// get time control
$timeControlData = ['id' => $this->getDataId(), 'containerid' => $containerid, 'objDims' => $graphDims, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD];
// host feature
if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
$newitemid = get_same_item_for_host($resourceid, $this->hostid);
$resourceid = !empty($newitemid) ? $newitemid : '';
}
if ($this->mode == SCREEN_MODE_PREVIEW && !empty($resourceid)) {
$this->action = 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams();
}
if ($resourceid && $this->mode != SCREEN_MODE_EDIT) {
if ($this->mode == SCREEN_MODE_PREVIEW) {
$timeControlData['loadSBox'] = 1;
}
}
$timeControlData['src'] = $resourceid ? 'chart.php?itemids[]=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] : 'chart3.php?';
$timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
$timeControlData['src'] .= $this->getProfileUrlParams();
// output
if ($this->mode == SCREEN_MODE_JS) {
return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')';
} else {
if ($this->mode == SCREEN_MODE_SLIDESHOW) {
insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
} else {
zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
}
if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW || !$resourceid) {
$item = new CDiv();
} elseif ($this->mode == SCREEN_MODE_PREVIEW) {
$item = new CLink(null, 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
}
$item->setId($containerid);
return $this->getOutput($item);
}
}
示例2: get
//.........这里部分代码省略.........
{
$this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$resourceId = isset($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid'];
$containerId = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
$graphDims = getGraphDims($resourceId);
$graphDims['graphHeight'] = $this->screenitem['height'];
$graphDims['width'] = $this->screenitem['width'];
$graph = getGraphByGraphId($resourceId);
$graphId = $graph['graphid'];
$legend = $graph['show_legend'];
$graph3d = $graph['show_3d'];
if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && $this->hostid) {
// get host
$hosts = API::Host()->get(['hostids' => $this->hostid, 'output' => ['hostid', 'name']]);
$host = reset($hosts);
// get graph
$graph = API::Graph()->get(['graphids' => $resourceId, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => ['hostid'], 'selectGraphItems' => API_OUTPUT_EXTEND]);
$graph = reset($graph);
// if items from one host we change them, or set calculated if not exist on that host
if (count($graph['hosts']) == 1) {
if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) {
$newDynamic = getSameGraphItemsForHost([['itemid' => $graph['ymax_itemid']]], $this->hostid, false);
$newDynamic = reset($newDynamic);
if (isset($newDynamic['itemid']) && $newDynamic['itemid'] > 0) {
$graph['ymax_itemid'] = $newDynamic['itemid'];
} else {
$graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
}
}
if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) {
$newDynamic = getSameGraphItemsForHost([['itemid' => $graph['ymin_itemid']]], $this->hostid, false);
$newDynamic = reset($newDynamic);
if (isset($newDynamic['itemid']) && $newDynamic['itemid'] > 0) {
$graph['ymin_itemid'] = $newDynamic['itemid'];
} else {
$graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
}
}
}
// get url
$this->screenitem['url'] = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php';
$this->screenitem['url'] = new CUrl($this->screenitem['url']);
foreach ($graph as $name => $value) {
if ($name == 'width' || $name == 'height') {
continue;
}
$this->screenitem['url']->setArgument($name, $value);
}
$newGraphItems = getSameGraphItemsForHost($graph['gitems'], $this->hostid, false);
foreach ($newGraphItems as $newGraphItem) {
unset($newGraphItem['gitemid'], $newGraphItem['graphid']);
foreach ($newGraphItem as $name => $value) {
$this->screenitem['url']->setArgument('items[' . $newGraphItem['itemid'] . '][' . $name . ']', $value);
}
}
$this->screenitem['url']->setArgument('name', $host['name'] . NAME_DELIMITER . $graph['name']);
$this->screenitem['url'] = $this->screenitem['url']->getUrl();
}
// get time control
$timeControlData = ['id' => $this->getDataId(), 'containerid' => $containerId, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD];
$isDefault = false;
if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
if ($this->screenitem['dynamic'] == SCREEN_SIMPLE_ITEM || $this->screenitem['url'] === '') {
$this->screenitem['url'] = 'chart6.php?graphid=' . $resourceId . '&screenid=' . $this->screenitem['screenid'];
$isDefault = true;
}
$this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_graphid($resourceId));
$timeControlData['src'] = $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&legend=' . $legend . '&graph3d=' . $graph3d . $this->getProfileUrlParams();
$timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
} else {
if ($this->screenitem['dynamic'] == SCREEN_SIMPLE_ITEM || $this->screenitem['url'] === '') {
$this->screenitem['url'] = 'chart2.php?graphid=' . $resourceId . '&screenid=' . $this->screenitem['screenid'];
$isDefault = true;
}
if ($this->mode != SCREEN_MODE_EDIT && $graphId) {
if ($this->mode == SCREEN_MODE_PREVIEW) {
$timeControlData['loadSBox'] = 1;
}
}
$timeControlData['src'] = $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&legend=' . $legend . $this->getProfileUrlParams();
$timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
}
// output
if ($this->mode == SCREEN_MODE_JS) {
return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')';
} else {
if ($this->mode == SCREEN_MODE_SLIDESHOW) {
insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
} else {
zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
}
if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW || !$isDefault) {
$item = new CDiv();
} elseif ($this->mode == SCREEN_MODE_PREVIEW) {
$item = new CLink(null, 'charts.php?graphid=' . $resourceId . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
}
$item->setId($containerId);
return $this->getOutput($item);
}
}
示例3: die
<?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
// @todo convert to template
$object_id = (int) w2PgetParam($_GET, 'link_id', 0);
$task_id = (int) w2PgetParam($_GET, 'task_id', 0);
$project_id = (int) w2PgetParam($_GET, 'project_id', 0);
$object = new CLink();
$object->setId($object_id);
$obj = $object;
$canAddEdit = $obj->canAddEdit();
$canAuthor = $obj->canCreate();
$canEdit = $obj->canEdit();
$canDelete = $object->canDelete();
if (!$canAddEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
$obj = $AppUI->restoreObject();
if ($obj) {
$object = $obj;
$object_id = $object->getId();
} else {
$object->load($object_id);
}
if (!$object && $object_id > 0) {
$AppUI->setMsg('Link');
$AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect('m=' . $m);
}