本文整理匯總了PHP中CommonDropdown::getType方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommonDropdown::getType方法的具體用法?PHP CommonDropdown::getType怎麽用?PHP CommonDropdown::getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CommonDropdown
的用法示例。
在下文中一共展示了CommonDropdown::getType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: showTranslations
/**
* Display all translated field for a dropdown
*
* @param $item a Dropdown item
*
* @return true;
**/
static function showTranslations(CommonDropdown $item)
{
global $DB, $CFG_GLPI;
$rand = mt_rand();
$canedit = $item->can($item->getID(), UPDATE);
if ($canedit) {
echo "<div id='viewtranslation" . $item->getType() . $item->getID() . "{$rand}'></div>\n";
echo "<script type='text/javascript' >\n";
echo "function addTranslation" . $item->getType() . $item->getID() . "{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => -1);
Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
echo "<div class='center'>" . "<a class='vsubmit' href='javascript:addTranslation" . $item->getType() . $item->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>";
}
$query = "SELECT *\n FROM `" . getTableForItemType(__CLASS__) . "`\n WHERE `itemtype` = '" . get_class($item) . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `field` <> 'completename'\n ORDER BY `language` ASC";
$results = $DB->query($query);
if ($DB->numrows($results)) {
if ($canedit) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<div class='center'>";
echo "<table class='tab_cadre_fixehov'><tr class='tab_bg_2'>";
echo "<th colspan='4'>" . __("List of translations") . "</th></tr><tr>";
if ($canedit) {
echo "<th width='10'>";
Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
echo "</th>";
}
echo "<th>" . __("Language") . "</th>";
echo "<th>" . __("Field") . "</th>";
echo "<th>" . __("Value") . "</th></tr>";
while ($data = $DB->fetch_array($results)) {
$onhover = '';
if ($canedit) {
$onhover = "style='cursor:pointer'\n onClick=\"viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}();\"";
}
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td class='center'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td {$onhover}>";
if ($canedit) {
echo "\n<script type='text/javascript' >\n";
echo "function viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => $data["id"]);
Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
}
echo Dropdown::getLanguageName($data['language']);
echo "</td><td {$onhover}>";
$searchOption = $item->getSearchOptionByField('field', $data['field']);
echo $searchOption['name'] . "</td>";
echo "<td {$onhover}>" . $data['value'] . "</td>";
echo "</tr>";
}
echo "</table>";
if ($canedit) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
} else {
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
echo "<th class='b'>" . __("No translation found") . "</th></tr></table>";
}
return true;
}