Merge pull request #18159 from Hystepik/develop#1
New : Language support for knowledge record
This commit is contained in:
commit
ddf425f73e
@ -57,7 +57,9 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!GETPOSTISSET($key)) {
|
if (!GETPOSTISSET($key)) {
|
||||||
continue; // The field was not submited to be edited
|
if ($key != 'lang' || !GETPOSTISSET($key.'object')) {
|
||||||
|
continue; // The field was not submited to be edited
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignore special fields
|
// Ignore special fields
|
||||||
@ -87,7 +89,11 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
$tmparraykey = array_keys($object->param_list);
|
$tmparraykey = array_keys($object->param_list);
|
||||||
$value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
|
$value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOST($key, 'alphanohtml');
|
if ($key == 'lang') {
|
||||||
|
$value = GETPOST($key.'object', 'aZ09');
|
||||||
|
} else {
|
||||||
|
$value = GETPOST($key, 'alphanohtml');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
|
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
|
||||||
$value = ''; // This is an implicit foreign key field
|
$value = ''; // This is an implicit foreign key field
|
||||||
@ -161,7 +167,9 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!GETPOSTISSET($key)) {
|
if (!GETPOSTISSET($key)) {
|
||||||
continue; // The field was not submited to be edited
|
if ($key != 'lang' || !GETPOSTISSET($key.'object')) {
|
||||||
|
continue; // The field was not submited to be edited
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignore special fields
|
// Ignore special fields
|
||||||
@ -199,7 +207,11 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
|||||||
} elseif ($object->fields[$key]['type'] == 'reference') {
|
} elseif ($object->fields[$key]['type'] == 'reference') {
|
||||||
$value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
|
$value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOST($key, 'alpha');
|
if ($key == 'lang') {
|
||||||
|
$value = GETPOST($key.'object', 'aZ09');
|
||||||
|
} else {
|
||||||
|
$value = GETPOST($key, 'alphanohtml');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
|
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
|
||||||
$value = ''; // This is an implicit foreign key field
|
$value = ''; // This is an implicit foreign key field
|
||||||
|
|||||||
@ -79,13 +79,20 @@ foreach ($object->fields as $key => $val) {
|
|||||||
$value = (GETPOST($key) == 'on' ? 1 : 0);
|
$value = (GETPOST($key) == 'on' ? 1 : 0);
|
||||||
} elseif ($val['type'] == 'price') {
|
} elseif ($val['type'] == 'price') {
|
||||||
$value = price2num(GETPOST($key));
|
$value = price2num(GETPOST($key));
|
||||||
|
} elseif ($key == 'lang') {
|
||||||
|
$value = GETPOST($key.'object', 'aZ09');
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOST($key, 'alphanohtml');
|
$value = GETPOST($key, 'alphanohtml');
|
||||||
}
|
}
|
||||||
if (!empty($val['noteditable'])) {
|
if (!empty($val['noteditable'])) {
|
||||||
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
||||||
} else {
|
} else {
|
||||||
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
if ($key == 'lang') {
|
||||||
|
print img_picto('', 'language', 'class="pictofixedwidth"');
|
||||||
|
print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||||
|
} else {
|
||||||
|
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -79,6 +79,8 @@ foreach ($object->fields as $key => $val) {
|
|||||||
$value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
|
$value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
|
||||||
} elseif ($val['type'] == 'price') {
|
} elseif ($val['type'] == 'price') {
|
||||||
$value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
|
$value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
|
||||||
|
} elseif ($key == 'lang') {
|
||||||
|
$value = GETPOSTISSET($key.'object', 'aZ09')?GETPOST($key.'object', 'aZ09'):$object->lang;
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
|
$value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
|
||||||
}
|
}
|
||||||
@ -86,7 +88,12 @@ foreach ($object->fields as $key => $val) {
|
|||||||
if ($val['noteditable']) {
|
if ($val['noteditable']) {
|
||||||
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
||||||
} else {
|
} else {
|
||||||
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
if ($key == 'lang') {
|
||||||
|
print img_picto('', 'language', 'class="pictofixedwidth"');
|
||||||
|
print $formadmin->select_language($value, $key.'object', 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||||
|
} else {
|
||||||
|
print $object->showInputField($val, $key, $value, '', '', '', 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -81,7 +81,14 @@ foreach ($object->fields as $key => $val) {
|
|||||||
if (in_array($val['type'], array('text', 'html'))) {
|
if (in_array($val['type'], array('text', 'html'))) {
|
||||||
print '<div class="longmessagecut">';
|
print '<div class="longmessagecut">';
|
||||||
}
|
}
|
||||||
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
if ($key == 'lang') {
|
||||||
|
$langs->load("languages");
|
||||||
|
$labellang = ($value ? $langs->trans('Language_'.$value) : '');
|
||||||
|
print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
|
||||||
|
print $labellang;
|
||||||
|
} else {
|
||||||
|
print $object->showOutputField($val, $key, $value, '', '', '', 0);
|
||||||
|
}
|
||||||
//print dol_escape_htmltag($object->$key, 1, 1);
|
//print dol_escape_htmltag($object->$key, 1, 1);
|
||||||
if (in_array($val['type'], array('text', 'html'))) {
|
if (in_array($val['type'], array('text', 'html'))) {
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -21,6 +21,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord(
|
|||||||
date_creation datetime NOT NULL,
|
date_creation datetime NOT NULL,
|
||||||
tms timestamp,
|
tms timestamp,
|
||||||
last_main_doc varchar(255),
|
last_main_doc varchar(255),
|
||||||
|
lang varchar(6),
|
||||||
fk_user_creat integer NOT NULL,
|
fk_user_creat integer NOT NULL,
|
||||||
fk_user_modif integer,
|
fk_user_modif integer,
|
||||||
fk_user_valid integer,
|
fk_user_valid integer,
|
||||||
|
|||||||
@ -114,7 +114,8 @@ class KnowledgeRecord extends CommonObject
|
|||||||
'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflow300'),
|
'answer' => array('type'=>'html', 'label'=>'Solution', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>3, 'csslist'=>'tdoverflow300'),
|
||||||
//'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'),
|
//'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'),
|
||||||
'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'),
|
'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php', 'label'=>'GroupOfTicket', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory'),
|
||||||
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated'),),
|
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Valid'),),
|
||||||
|
'lang' => array('type'=>'varchar(6)', 'label'=>'Language', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>1),
|
||||||
);
|
);
|
||||||
public $rowid;
|
public $rowid;
|
||||||
public $ref;
|
public $ref;
|
||||||
@ -130,6 +131,7 @@ class KnowledgeRecord extends CommonObject
|
|||||||
public $answer;
|
public $answer;
|
||||||
public $url;
|
public $url;
|
||||||
public $status;
|
public $status;
|
||||||
|
public $lang;
|
||||||
// END MODULEBUILDER PROPERTIES
|
// END MODULEBUILDER PROPERTIES
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
|
||||||
|
|
||||||
@ -117,6 +118,11 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
$triggermodname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record
|
$triggermodname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||||
|
|
||||||
|
// Upadate / add for lang
|
||||||
|
if (($action == 'update' || $action == 'add') && !empty($permissiontoadd)) {
|
||||||
|
$object->lang = GETPOSTISSET('langkm', 'aZ09')?GETPOST('langkm', 'aZ09'):$object->lang;
|
||||||
|
}
|
||||||
|
|
||||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||||
|
|
||||||
@ -156,6 +162,7 @@ if ($action == 'confirm_validate') {
|
|||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
$formproject = new FormProjets($db);
|
$formproject = new FormProjets($db);
|
||||||
|
$formadmin = new FormAdmin($db);
|
||||||
|
|
||||||
$title = $langs->trans("KnowledgeRecord");
|
$title = $langs->trans("KnowledgeRecord");
|
||||||
$help_url = '';
|
$help_url = '';
|
||||||
@ -185,6 +192,7 @@ if ($action == 'create') {
|
|||||||
// Common attributes
|
// Common attributes
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
|
||||||
|
|
||||||
@ -225,6 +233,7 @@ if (($id || $ref) && $action == 'edit') {
|
|||||||
// Common attributes
|
// Common attributes
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
|
|
||||||
@ -88,7 +89,11 @@ $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alph
|
|||||||
$search = array();
|
$search = array();
|
||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (GETPOST('search_'.$key, 'alpha') !== '') {
|
if (GETPOST('search_'.$key, 'alpha') !== '') {
|
||||||
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
if ($key == "lang") {
|
||||||
|
$search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : '';
|
||||||
|
} else {
|
||||||
|
$search[$key] = GETPOST('search_'.$key, 'alpha');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||||
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
|
||||||
@ -197,6 +202,7 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$user_temp = new User($db);
|
$user_temp = new User($db);
|
||||||
|
$formadmin = new FormAdmin($db);
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
@ -455,7 +461,11 @@ foreach ($object->fields as $key => $val) {
|
|||||||
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) {
|
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) {
|
||||||
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
|
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
|
||||||
} elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
} elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||||
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
if ($key == 'lang') {
|
||||||
|
print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||||
|
} else {
|
||||||
|
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
||||||
|
}
|
||||||
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
||||||
print '<div class="nowrap">';
|
print '<div class="nowrap">';
|
||||||
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
||||||
@ -592,6 +602,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
|||||||
}
|
}
|
||||||
print $user_temp->getNomUrl(-1);
|
print $user_temp->getNomUrl(-1);
|
||||||
}
|
}
|
||||||
|
} elseif ($key == 'lang') {
|
||||||
|
$labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : '');
|
||||||
|
print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"');
|
||||||
|
print $labellang;
|
||||||
} else {
|
} else {
|
||||||
print $object->showOutputField($val, $key, $object->$key, '');
|
print $object->showOutputField($val, $key, $object->$key, '');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user