\n";
$this->showFormButtons($options);
return true;
}
/**
* Get a translation for a value
*
* @param Reminder $item item to translate
* @param string $field field to return (default 'name')
*
* @return string the field translated if a translation is available, or the original field if not
**/
static function getTranslatedValue(Reminder $item, $field = "name") {
$obj = new self;
$found = $obj->find([
'reminders_id' => $item->getID(),
'language' => $_SESSION['glpilanguage']
]);
if ((count($found) > 0)
&& in_array($field, ['name', 'text'])) {
$first = array_shift($found);
return $first[$field];
}
return $item->fields[$field];
}
/**
* Is kb item translation functionnality active
*
* @return boolean
**/
static function isReminderTranslationActive() {
global $CFG_GLPI;
return $CFG_GLPI['translate_reminders'];
}
/**
* Check if an item can be translated
* It be translated if translation if globally on and item is an instance of CommonDropdown
* or CommonTreeDropdown and if translation is enabled for this class
*
* @param item the item to check
*
* @return true if item can be translated, false otherwise
**/
static function canBeTranslated(CommonGLPI $item) {
return (self::isReminderTranslationActive()
&& $item instanceof Reminder);
}
/**
* Return the number of translations for an item
*
* @param Reminder $item
*
* @return integer the number of translations for this item
**/
static function getNumberOfTranslationsForItem($item) {
return countElementsInTable(getTableForItemType(__CLASS__),
['reminders_id' => $item->getID()]);
}
/**
* Get already translated languages for item
*
* @param item
*
* @return array of already translated languages
**/
static function getAlreadyTranslatedForItem($item) {
global $DB;
$tab = [];
$iterator = $DB->request([
'FROM' => getTableForItemType(__CLASS__),
'WHERE' => ['reminders_id' => $item->getID()]
]);
while ($data = $iterator->next()) {
$tab[$data['language']] = $data['language'];
}
return $tab;
}
}