本文整理汇总了PHP中API::TemplateScreenItem方法的典型用法代码示例。如果您正苦于以下问题:PHP API::TemplateScreenItem方法的具体用法?PHP API::TemplateScreenItem怎么用?PHP API::TemplateScreenItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API::TemplateScreenItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getScreen
/**
* Get particular screen object.
*
* @static
*
* @param array $options
* @param int $options['resourcetype']
* @param int $options['screenitemid']
* @param int $options['hostid']
*
* @return CScreenBase
*/
public static function getScreen(array $options = array())
{
// get resourcetype from screenitem
if (empty($options['screenitem']) && !empty($options['screenitemid'])) {
if (!empty($options['hostid'])) {
$options['screenitem'] = API::TemplateScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'hostids' => $options['hostid'], 'output' => API_OUTPUT_EXTEND));
} else {
$options['screenitem'] = API::ScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'output' => API_OUTPUT_EXTEND));
}
$options['screenitem'] = reset($options['screenitem']);
}
if (zbx_empty($options['resourcetype']) && !zbx_empty($options['screenitem']['resourcetype'])) {
$options['resourcetype'] = $options['screenitem']['resourcetype'];
}
if (zbx_empty($options['resourcetype'])) {
return null;
}
// get screen
switch ($options['resourcetype']) {
case SCREEN_RESOURCE_GRAPH:
return new CScreenGraph($options);
case SCREEN_RESOURCE_SIMPLE_GRAPH:
return new CScreenSimpleGraph($options);
case SCREEN_RESOURCE_MAP:
return new CScreenMap($options);
case SCREEN_RESOURCE_PLAIN_TEXT:
return new CScreenPlainText($options);
case SCREEN_RESOURCE_HOSTS_INFO:
return new CScreenHostsInfo($options);
case SCREEN_RESOURCE_TRIGGERS_INFO:
return new CScreenTriggersInfo($options);
case SCREEN_RESOURCE_SERVER_INFO:
return new CScreenServerInfo($options);
case SCREEN_RESOURCE_CLOCK:
return new CScreenClock($options);
case SCREEN_RESOURCE_SCREEN:
return new CScreenScreen($options);
case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
return new CScreenTriggersOverview($options);
case SCREEN_RESOURCE_DATA_OVERVIEW:
return new CScreenDataOverview($options);
case SCREEN_RESOURCE_URL:
return new CScreenUrl($options);
case SCREEN_RESOURCE_ACTIONS:
return new CScreenActions($options);
case SCREEN_RESOURCE_EVENTS:
return new CScreenEvents($options);
case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
return new CScreenHostgroupTriggers($options);
case SCREEN_RESOURCE_SYSTEM_STATUS:
return new CScreenSystemStatus($options);
case SCREEN_RESOURCE_HOST_TRIGGERS:
return new CScreenHostTriggers($options);
case SCREEN_RESOURCE_HISTORY:
return new CScreenHistory($options);
case SCREEN_RESOURCE_CHART:
return new CScreenChart($options);
default:
return null;
}
}
示例2: __construct
/**
* Init screen data.
*
* @param array $options
* @param boolean $options['isFlickerfree']
* @param string $options['pageFile']
* @param int $options['mode']
* @param int $options['timestamp']
* @param int $options['resourcetype']
* @param int $options['screenid']
* @param array $options['screenitem']
* @param string $options['action']
* @param int $options['groupid']
* @param int $options['hostid']
* @param int $options['period']
* @param int $options['stime']
* @param string $options['profileIdx']
* @param int $options['profileIdx2']
* @param boolean $options['updateProfile']
* @param array $options['timeline']
* @param string $options['dataId']
*/
public function __construct(array $options = array())
{
$this->isFlickerfree = isset($options['isFlickerfree']) ? $options['isFlickerfree'] : true;
$this->mode = isset($options['mode']) ? $options['mode'] : SCREEN_MODE_SLIDESHOW;
$this->timestamp = !empty($options['timestamp']) ? $options['timestamp'] : time();
$this->resourcetype = isset($options['resourcetype']) ? $options['resourcetype'] : null;
$this->screenid = !empty($options['screenid']) ? $options['screenid'] : null;
$this->action = !empty($options['action']) ? $options['action'] : null;
$this->groupid = !empty($options['groupid']) ? $options['groupid'] : null;
$this->hostid = !empty($options['hostid']) ? $options['hostid'] : null;
$this->dataId = !empty($options['dataId']) ? $options['dataId'] : null;
// get page file
if (!empty($options['pageFile'])) {
$this->pageFile = $options['pageFile'];
} else {
global $page;
$this->pageFile = $page['file'];
}
// calculate timeline
$this->profileIdx = !empty($options['profileIdx']) ? $options['profileIdx'] : '';
$this->profileIdx2 = !empty($options['profileIdx2']) ? $options['profileIdx2'] : null;
$this->updateProfile = isset($options['updateProfile']) ? $options['updateProfile'] : true;
$this->timeline = !empty($options['timeline']) ? $options['timeline'] : null;
if (empty($this->timeline)) {
$this->timeline = $this->calculateTime(array('profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'period' => !empty($options['period']) ? $options['period'] : null, 'stime' => !empty($options['stime']) ? $options['stime'] : null));
}
// get screenitem
if (!empty($options['screenitem'])) {
$this->screenitem = $options['screenitem'];
} elseif (!empty($options['screenitemid'])) {
if (!empty($this->hostid)) {
$this->screenitem = API::TemplateScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'hostids' => $this->hostid, 'output' => API_OUTPUT_EXTEND));
} else {
$this->screenitem = API::ScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'output' => API_OUTPUT_EXTEND));
}
$this->screenitem = reset($this->screenitem);
}
// get screenid
if (empty($this->screenid) && !empty($this->screenitem)) {
$this->screenid = $this->screenitem['screenid'];
}
// get resourcetype
if (is_null($this->resourcetype) && !empty($this->screenitem['resourcetype'])) {
$this->resourcetype = $this->screenitem['resourcetype'];
}
// create action url
if (empty($this->action)) {
$this->action = 'screenedit.php?form=update&screenid=' . $this->screenid . '&screenitemid=' . $this->screenitem['screenitemid'];
}
}
示例3: getScreen
/**
* Get particular screen object.
*
* @static
*
* @param array $options
* @param int $options['resourcetype']
* @param int $options['screenitemid']
* @param int $options['hostid']
* @param array $options['screen']
* @param int $options['screenid']
*
* @return CScreenBase
*/
public static function getScreen(array $options = array())
{
// get resourcetype from screenitem
if (empty($options['screenitem']) && !empty($options['screenitemid'])) {
if (!empty($options['hostid'])) {
$options['screenitem'] = API::TemplateScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'hostids' => $options['hostid'], 'output' => API_OUTPUT_EXTEND));
} else {
$options['screenitem'] = API::ScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'output' => API_OUTPUT_EXTEND));
}
$options['screenitem'] = reset($options['screenitem']);
}
if (zbx_empty($options['resourcetype']) && !zbx_empty($options['screenitem']['resourcetype'])) {
$options['resourcetype'] = $options['screenitem']['resourcetype'];
}
if (zbx_empty($options['resourcetype'])) {
return null;
}
// get screen
switch ($options['resourcetype']) {
case SCREEN_RESOURCE_GRAPH:
return new CScreenGraph($options);
case SCREEN_RESOURCE_SIMPLE_GRAPH:
return new CScreenSimpleGraph($options);
case SCREEN_RESOURCE_MAP:
return new CScreenMap($options);
case SCREEN_RESOURCE_PLAIN_TEXT:
return new CScreenPlainText($options);
case SCREEN_RESOURCE_HOSTS_INFO:
return new CScreenHostsInfo($options);
case SCREEN_RESOURCE_TRIGGERS_INFO:
return new CScreenTriggersInfo($options);
case SCREEN_RESOURCE_SERVER_INFO:
return new CScreenServerInfo($options);
case SCREEN_RESOURCE_CLOCK:
return new CScreenClock($options);
case SCREEN_RESOURCE_SCREEN:
return new CScreenScreen($options);
case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
return new CScreenTriggersOverview($options);
case SCREEN_RESOURCE_DATA_OVERVIEW:
return new CScreenDataOverview($options);
case SCREEN_RESOURCE_URL:
$options = self::appendTemplatedScreenOption($options);
return new CScreenUrl($options);
case SCREEN_RESOURCE_ACTIONS:
return new CScreenActions($options);
case SCREEN_RESOURCE_EVENTS:
return new CScreenEvents($options);
case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
return new CScreenHostgroupTriggers($options);
case SCREEN_RESOURCE_SYSTEM_STATUS:
return new CScreenSystemStatus($options);
case SCREEN_RESOURCE_HOST_TRIGGERS:
return new CScreenHostTriggers($options);
case SCREEN_RESOURCE_HISTORY:
// TODO: pass the items from the outside instead of retrieving them by ids
if (isset($options['itemids'])) {
$items = API::Item()->get(array('itemids' => $options['itemids'], 'webitems' => true, 'selectHosts' => array('name'), 'output' => array('itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'), 'preservekeys' => true));
$items = CMacrosResolverHelper::resolveItemNames($items);
$options['items'] = $items;
unset($options['itemids']);
}
return new CScreenHistory($options);
case SCREEN_RESOURCE_CHART:
return new CScreenChart($options);
case SCREEN_RESOURCE_LLD_GRAPH:
$options = self::appendTemplatedScreenOption($options);
return new CScreenLldGraph($options);
case SCREEN_RESOURCE_LLD_SIMPLE_GRAPH:
$options = self::appendTemplatedScreenOption($options);
return new CScreenLldSimpleGraph($options);
default:
return null;
}
}
示例4: getScreen
/**
* Get particular screen object.
*
* @static
*
* @param array $options
* @param int $options['resourcetype']
* @param int $options['screenitemid']
* @param int $options['hostid']
* @param array $options['screen']
* @param int $options['screenid']
*
* @return CScreenBase
*/
public static function getScreen(array $options = [])
{
if (!array_key_exists('resourcetype', $options)) {
$options['resourcetype'] = null;
// get resourcetype from screenitem
if (!array_key_exists('screenitem', $options) && array_key_exists('screenitemid', $options)) {
if (array_key_exists('hostid', $options) && $options['hostid'] > 0) {
$options['screenitem'] = API::TemplateScreenItem()->get(['screenitemids' => $options['screenitemid'], 'hostids' => $options['hostid'], 'output' => API_OUTPUT_EXTEND]);
} else {
$options['screenitem'] = API::ScreenItem()->get(['screenitemids' => $options['screenitemid'], 'output' => API_OUTPUT_EXTEND]);
}
$options['screenitem'] = reset($options['screenitem']);
}
if (array_key_exists('screenitem', $options) && array_key_exists('resourcetype', $options['screenitem'])) {
$options['resourcetype'] = $options['screenitem']['resourcetype'];
}
}
if ($options['resourcetype'] === null) {
return null;
}
// get screen
switch ($options['resourcetype']) {
case SCREEN_RESOURCE_GRAPH:
return new CScreenGraph($options);
case SCREEN_RESOURCE_SIMPLE_GRAPH:
return new CScreenSimpleGraph($options);
case SCREEN_RESOURCE_MAP:
return new CScreenMap($options);
case SCREEN_RESOURCE_PLAIN_TEXT:
return new CScreenPlainText($options);
case SCREEN_RESOURCE_HOSTS_INFO:
return new CScreenHostsInfo($options);
case SCREEN_RESOURCE_TRIGGERS_INFO:
return new CScreenTriggersInfo($options);
case SCREEN_RESOURCE_SERVER_INFO:
return new CScreenServerInfo($options);
case SCREEN_RESOURCE_CLOCK:
return new CScreenClock($options);
case SCREEN_RESOURCE_SCREEN:
return new CScreenScreen($options);
case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
return new CScreenTriggersOverview($options);
case SCREEN_RESOURCE_DATA_OVERVIEW:
return new CScreenDataOverview($options);
case SCREEN_RESOURCE_URL:
$options = self::appendTemplatedScreenOption($options);
return new CScreenUrl($options);
case SCREEN_RESOURCE_ACTIONS:
return new CScreenActions($options);
case SCREEN_RESOURCE_EVENTS:
return new CScreenEvents($options);
case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
return new CScreenHostgroupTriggers($options);
case SCREEN_RESOURCE_SYSTEM_STATUS:
return new CScreenSystemStatus($options);
case SCREEN_RESOURCE_HOST_TRIGGERS:
return new CScreenHostTriggers($options);
case SCREEN_RESOURCE_HISTORY:
return new CScreenHistory($options);
case SCREEN_RESOURCE_CHART:
return new CScreenChart($options);
case SCREEN_RESOURCE_LLD_GRAPH:
$options = self::appendTemplatedScreenOption($options);
return new CScreenLldGraph($options);
case SCREEN_RESOURCE_LLD_SIMPLE_GRAPH:
$options = self::appendTemplatedScreenOption($options);
return new CScreenLldSimpleGraph($options);
case SCREEN_RESOURCE_HTTPTEST_DETAILS:
return new CScreenHttpTestDetails($options);
case SCREEN_RESOURCE_DISCOVERY:
return new CScreenDiscovery($options);
case SCREEN_RESOURCE_HTTPTEST:
return new CScreenHttpTest($options);
default:
return null;
}
}
示例5: __construct
/**
* Init screen data.
*
* @param array $options
* @param boolean $options['isFlickerfree']
* @param string $options['pageFile']
* @param int $options['mode']
* @param int $options['timestamp']
* @param int $options['resourcetype']
* @param bool $options['isTemplatedScreen']
* @param int $options['screenid']
* @param array $options['screenitem']
* @param string $options['action']
* @param int $options['groupid']
* @param int $options['hostid']
* @param int $options['period']
* @param int $options['stime']
* @param string $options['profileIdx']
* @param int $options['profileIdx2']
* @param boolean $options['updateProfile']
* @param array $options['timeline']
* @param string $options['dataId']
*/
public function __construct(array $options = [])
{
$this->parameters = ['isFlickerfree' => true, 'mode' => SCREEN_MODE_SLIDESHOW, 'timestamp' => time(), 'resourcetype' => null, 'isTemplatedScreen' => false, 'screenid' => null, 'action' => null, 'groupid' => null, 'hostid' => 0, 'pageFile' => null, 'profileIdx' => '', 'profileIdx2' => null, 'updateProfile' => true, 'timeline' => null, 'dataId' => null, 'page' => 1];
$this->resourcetype = array_key_exists('resourcetype', $options) ? $options['resourcetype'] : null;
$this->required_parameters = ['isFlickerfree' => true, 'mode' => true, 'timestamp' => true, 'resourcetype' => true, 'dataId' => true];
switch ($this->resourcetype) {
case SCREEN_RESOURCE_HTTPTEST_DETAILS:
$this->required_parameters += ['isTemplatedScreen' => false, 'screenid' => false, 'action' => false, 'groupid' => false, 'hostid' => false, 'pageFile' => false, 'profileIdx' => false, 'profileIdx2' => true, 'updateProfile' => false, 'timeline' => false, 'page' => false];
break;
case SCREEN_RESOURCE_DISCOVERY:
$this->required_parameters += ['isTemplatedScreen' => false, 'screenid' => false, 'action' => false, 'groupid' => false, 'hostid' => false, 'pageFile' => false, 'profileIdx' => false, 'profileIdx2' => false, 'updateProfile' => false, 'timeline' => false, 'page' => false];
break;
case SCREEN_RESOURCE_HTTPTEST:
$this->required_parameters += ['isTemplatedScreen' => false, 'screenid' => false, 'action' => false, 'groupid' => true, 'hostid' => true, 'pageFile' => false, 'profileIdx' => false, 'profileIdx2' => false, 'updateProfile' => false, 'timeline' => false, 'page' => true];
break;
default:
$this->required_parameters += ['isTemplatedScreen' => true, 'screenid' => true, 'action' => true, 'groupid' => true, 'hostid' => true, 'pageFile' => true, 'profileIdx' => true, 'profileIdx2' => true, 'updateProfile' => true, 'timeline' => true, 'page' => false];
}
// Get screenitem if its required or resource type is null.
$this->screenitem = [];
if (array_key_exists('screenitem', $options) && is_array($options['screenitem'])) {
$this->screenitem = $options['screenitem'];
} elseif (array_key_exists('screenitemid', $options) && $options['screenitemid'] > 0) {
$screenitem_output = ['screenitemid', 'screenid', 'resourcetype', 'resourceid', 'width', 'height', 'elements', 'halign', 'valign', 'style', 'url', 'dynamic', 'sort_triggers', 'application', 'max_columns'];
if ($this->hostid != 0) {
$this->screenitem = API::TemplateScreenItem()->get(['output' => $screenitem_output, 'screenitemids' => $options['screenitemid'], 'hostids' => $this->hostid]);
} else {
$this->screenitem = API::ScreenItem()->get(['output' => $screenitem_output, 'screenitemids' => $options['screenitemid']]);
}
if ($this->screenitem) {
$this->screenitem = reset($this->screenitem);
}
}
// Get resourcetype.
if ($this->resourcetype === null && array_key_exists('resourcetype', $this->screenitem)) {
$this->resourcetype = $this->screenitem['resourcetype'];
}
foreach ($this->parameters as $pname => $default_value) {
if ($this->required_parameters[$pname]) {
$this->{$pname} = array_key_exists($pname, $options) ? $options[$pname] : $default_value;
}
}
// Get page file.
if ($this->required_parameters['pageFile'] && $this->pageFile === null) {
global $page;
$this->pageFile = $page['file'];
}
// Calculate timeline.
if ($this->required_parameters['timeline'] && $this->timeline === null) {
$this->timeline = $this->calculateTime(['profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'period' => array_key_exists('period', $options) ? $options['period'] : null, 'stime' => array_key_exists('stime', $options) ? $options['stime'] : null]);
}
// Get screenid.
if ($this->required_parameters['screenid'] && $this->screenid === null && $this->screenitem) {
$this->screenid = $this->screenitem['screenid'];
}
// Create action URL.
if ($this->required_parameters['action'] && $this->action === null && $this->screenitem) {
$this->action = 'screenedit.php?form=update&screenid=' . $this->screenid . '&screenitemid=' . $this->screenitem['screenitemid'];
}
}