function plugin_tag_giveItem($type, $field, $data, $num, $linkfield = "")
{
    if ($data['raw']["ITEM_{$num}"] == '') {
        return "";
    }
    switch ($field) {
        case "10500":
            $tags = explode("\$\$\$\$", $data['raw']["ITEM_{$num}"]);
            $out = '<div class="select2-container select2-container-multi chosen-select-no-results" id="s2id_tag_select" style="width: 100%;">
                  <ul class="select2-choices">';
            foreach ($tags as $tag) {
                $tmp = explode("\$\$", $tag);
                $style = "padding-left:5px;";
                //because we don't have 'x' before the tag
                if (isset($tmp[1])) {
                    $plugintagtag = new PluginTagTag();
                    $plugintagtag->getFromDB($tmp[1]);
                    $color = $plugintagtag->fields["color"];
                    if (!empty($color)) {
                        $style .= "border-width:2px;border-color:{$color};";
                    }
                }
                $out .= '<li class="select2-search-choice" style="' . $style . '">' . $tmp[0] . '</li>';
            }
            $out .= '</ul>
               </div>';
            return $out;
            break;
    }
    return "";
}
示例#2
0
文件: hook.php 项目: korial29/tag
function plugin_tag_giveItem($type, $field, $data, $num, $linkfield = "")
{
    switch ($field) {
        case PluginTagTag::TAG_SEARCH_NUM:
            //Note : can declare a const for "10500"
            $out = '<div id="s2id_tag_select" class="select2-container select2-container-multi chosen-select-no-results" style="width: 100%;">
                 <ul class="select2-choices">';
            $separator = '';
            $plugintagtag = new PluginTagTag();
            foreach ($data[$num] as $tag) {
                if (isset($tag['id']) && isset($tag['name'])) {
                    $id = $tag['id'];
                    $name = $tag['name'];
                    $plugintagtag->getFromDB($id);
                    $color = $plugintagtag->fields["color"];
                    $style = "";
                    if (!empty($color)) {
                        $style .= "border-width:2px; border-color:{$color};";
                    }
                    $out .= '<li class="select2-search-choice" style="padding-left:5px;' . $style . '">' . $separator . $name . '</li>';
                    $separator = '<span style="display:none">, </span>';
                    //For export (CSV, PDF) of GLPI core
                }
            }
            $out .= '</ul></div>';
            return $out;
            break;
    }
    if ($type == 'PluginTagTag' && $field == 6) {
        $key = $data[$num][0]['name'];
        $menu = Html::getMenuInfos();
        return $menu[$key]['title'];
    }
    return "";
}