本文整理汇总了PHP中MassiveAction::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP MassiveAction::getItems方法的具体用法?PHP MassiveAction::getItems怎么用?PHP MassiveAction::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MassiveAction
的用法示例。
在下文中一共展示了MassiveAction::getItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $UNINSTALL_TYPES;
foreach ($ma->getItems() as $itemtype => $data) {
if (!in_array($itemtype, $UNINSTALL_TYPES)) {
return "";
}
}
switch ($ma->getAction()) {
case 'uninstall':
$uninst = new PluginUninstallUninstall();
$uninst->dropdownUninstallModels("model_id", $_SESSION["glpiID"], $_SESSION["glpiactive_entity"]);
echo " " . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
return true;
}
return "";
}
示例2: getRelationMassiveActionsPeerForSubForm
/**
* get the type of the item with the name of the action or the types of the input
*
* @since version 0.85
*
* @param $ma current massive action
*
* @return number of the peer
**/
static function getRelationMassiveActionsPeerForSubForm(MassiveAction $ma)
{
$items = $ma->getItems();
// If direct itemtype, then, its easy to find !
if (isset($items[static::$itemtype_1])) {
return 2;
}
if (isset($items[static::$itemtype_2])) {
return 1;
}
// Else, check if one of both peer is 'itemtype*'
if (preg_match('/^itemtype/', static::$itemtype_1)) {
return 2;
}
if (preg_match('/^itemtype/', static::$itemtype_2)) {
return 1;
}
// Else we cannot define !
return 0;
}
示例3: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
$action = $ma->getAction();
$items = $ma->getItems();
$itemtypes_affect = array();
$itemtypes_unaffect = array();
foreach (array_keys($items) as $itemtype) {
if (!Toolbox::is_a($itemtype, __CLASS__)) {
continue;
}
$specificities = $itemtype::getConnexityMassiveActionsSpecificities();
if (in_array($action, $specificities['normalized']['affect'])) {
$itemtypes_affect[$itemtype] = $specificities;
continue;
}
if (in_array($action, $specificities['normalized']['unaffect'])) {
$itemtypes_unaffect[$itemtype] = $specificities;
continue;
}
}
if (count($itemtypes_affect) > count($itemtypes_unaffect)) {
$normalized_action = 'affect';
$itemtypes = $itemtypes_affect;
} else {
if (count($itemtypes_affect) < count($itemtypes_unaffect)) {
$normalized_action = 'unaffect';
$itemtypes = $itemtypes_unaffect;
} else {
return parent::showMassiveActionsSubForm($ma);
}
}
switch ($normalized_action) {
case 'unaffect':
foreach ($itemtypes as $itemtype => $specificities) {
if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
$peer_field = "peer[{$itemtype}]";
if (!$itemtype::$mustBeAttached_1 && !$itemtype::$mustBeAttached_2) {
// Should never occur ... But we must care !
$values = array();
if (empty($itemtype::$itemtype_1) || preg_match('/^itemtype/', $itemtype::$itemtype_1)) {
$values[0] = __('First Item');
} else {
$itemtype_1 = $itemtype::$itemtype_1;
$values[0] = $itemtype_1::getTypeName(Session::getPluralNumber());
}
if (empty($itemtype::$itemtype_2) || preg_match('/^itemtype/', $itemtype::$itemtype_2)) {
$values[1] = __('Second Item');
} else {
$itemtype_2 = $itemtype::$itemtype_2;
$values[1] = $itemtype_2::getTypeName(Session::getPluralNumber());
}
echo sprintf(__('Select a peer for %s:'), $itemtype::getTypeName());
Dropdown::showFromArray($peer_field, $values);
echo "<br>\n";
} else {
if (!$itemtype::$mustBeAttached_1) {
echo "<input type='hidden' name='{$peer_field}' value='0'>";
} else {
if (!$itemtype::$mustBeAttached_2) {
echo "<input type='hidden' name='{$peer_field}' value='1'>";
}
}
}
}
}
echo "<br><br>" . Html::submit(_x('button', 'Dissociate'), array('name' => 'massiveaction'));
return true;
case 'affect':
$peertypes = array();
foreach ($itemtypes as $itemtype => $specificities) {
if (!$specificities['reaffect']) {
continue;
}
if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
if ($specificities['reaffect'] == 1) {
$peertype = $itemtype::$itemtype_1;
} else {
$peertype = $itemtype::$itemtype_2;
}
} else {
$peertype = $itemtype::$itemtype;
}
if (preg_match('/^itemtype/', $peertype)) {
$peertypes = array_merge($peertypes, $specificities['itemtypes']);
} else {
$peertypes[] = $peertype;
}
}
$peertypes = array_unique($peertypes);
if (count($peertypes) == 0) {
echo __('Unable to reaffect given elements !');
exit;
}
$options = array();
if (count($peertypes) == 1) {
//.........这里部分代码省略.........