Fix translation for skill short codes - refs BT#13589

pull/3063/head
Angel Fernando Quiroz Campos 8 years ago
parent 28aa1505fe
commit def458f75f
  1. 1
      main/inc/ajax/skill.ajax.php
  2. 35
      main/inc/lib/skill.lib.php
  3. 4
      main/social/my_skills_report.php
  4. 2
      src/Chamilo/CoreBundle/Entity/Skill.php

@ -138,6 +138,7 @@ switch ($action) {
echo $html;
break;
case 'get_skills_tree_json':
header('Content-Type: application/json');
$userId = isset($_REQUEST['load_user']) && $_REQUEST['load_user'] == 1 ? api_get_user_id() : 0;
$skill_id = isset($_REQUEST['skill_id']) ? intval($_REQUEST['skill_id']) : 0;
$depth = isset($_REQUEST['main_depth']) ? intval($_REQUEST['main_depth']) : 2;

@ -619,8 +619,8 @@ class Skill extends Model
{
$result = parent::get($id);
$result['web_icon_path'] = api_get_path(WEB_UPLOAD_PATH).'badges/'.$result['icon'];
$result['name'] = self::translate($result['name']);
$result['short_code'] = self::translate($result['short_code']);
$result['name'] = self::translateName($result['name']);
$result['short_code'] = self::translateCode($result['short_code']);
return $result;
}
@ -664,8 +664,8 @@ class Skill extends Model
"badges/%s-small.png",
sha1($skill['name'])
);
$skill['name'] = self::translate($skill['name']);
$skill['short_code'] = self::translate($skill['short_code']);
$skill['name'] = self::translateName($skill['name']);
$skill['short_code'] = self::translateCode($skill['short_code']);
}
return $skills;
@ -718,8 +718,8 @@ class Skill extends Model
$webPath = api_get_path(WEB_UPLOAD_PATH);
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$row['name'] = self::translate($row['name']);
$row['short_code'] = self::translate($row['short_code']);
$row['name'] = self::translateName($row['name']);
$row['short_code'] = self::translateCode($row['short_code']);
$skill_rel_skill = new SkillRelSkill();
$parents = $skill_rel_skill->get_skill_parents($row['id']);
$row['level'] = count($parents) - 1;
@ -1015,7 +1015,7 @@ class Skill extends Model
sha1($skill['name'])
);
}
$skill['name'] = self::translate($skill['name']);
$skill['name'] = self::translateName($skill['name']);
$clean_skill[$skill['id']] = array_merge(
$skill,
array(
@ -1506,7 +1506,7 @@ class Skill extends Model
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
$row['skill_name'] = self::translate($row['skill_name']);
$row['skill_name'] = self::translateName($row['skill_name']);
$list[] = $row;
}
@ -1551,7 +1551,7 @@ class Skill extends Model
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
$row['skill_name'] = self::translate($row['skill_name']);
$row['skill_name'] = self::translateName($row['skill_name']);
$list[] = $row;
}
@ -1740,7 +1740,7 @@ class Skill extends Model
foreach ($result as $item) {
$skills[] = [
'name' => self::translate($item['name']),
'name' => self::translateName($item['name']),
'acquired_skill_at' => $item['acquired_skill_at']
];
}
@ -1752,7 +1752,7 @@ class Skill extends Model
* @param string $name
* @return string
*/
public static function translate($name)
public static function translateName($name)
{
$camelCase = 'Skill'.api_underscore_to_camel_case(
str_replace(' ', '_', $name)
@ -1760,4 +1760,17 @@ class Skill extends Model
return isset($GLOBALS[$camelCase]) ? $GLOBALS[$camelCase] : $name;
}
public static function translateCode($code)
{
if (empty($code)) {
return '';
}
$camelCase = 'SkillCode'.api_underscore_to_camel_case(
str_replace(' ', '_', $code)
);
return isset($GLOBALS[$camelCase]) ? $GLOBALS[$camelCase] : '';
}
}

@ -50,7 +50,7 @@ if ($isStudent) {
$result = Database::query($sql);
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = array(
'skillName' => Skill::translate($resultData['name']),
'skillName' => Skill::translateName($resultData['name']),
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon(
'course.png',
@ -104,7 +104,7 @@ if ($isStudent) {
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = array(
'completeName' => $followedStudents[$selectedStudent]['completeName'],
'skillName' => Skill::translate($resultData['name']),
'skillName' => Skill::translateName($resultData['name']),
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon(
'course.png',

@ -155,7 +155,7 @@ class Skill
*/
public function getShortCode($translated = true)
{
if ($translated) {
if ($translated && !empty($this->shortCode)) {
$camelCase = 'SkillCode'.api_underscore_to_camel_case(
str_replace(' ', '_', $this->shortCode)
);

Loading…
Cancel
Save