Create tpl for skills block - refs BT#9901 #TMI

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent 6b5ef8b70e
commit 640edd74b5
  1. 30
      main/inc/lib/social.lib.php
  2. 83
      main/social/home.php
  3. 71
      main/social/profile.php
  4. 41
      main/template/default/social/skills_block.tpl

@ -1603,4 +1603,34 @@ class SocialManager extends UserManager
return $html;
}
/**
* Get HTML code block for user skills
* @param int $userId The user ID
* @return string
*/
public static function getSkillBlock($userId)
{
if (api_get_setting('allow_skills_tool') !== 'true') {
return null;
}
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true);
$template = new Template(null, false, false, false, false, false);
$template->assign('ranking', $ranking);
$template->assign('skills', $skills);
$template->assign(
'show_skills_report_link',
api_is_student() || api_is_student_boss() || api_is_drh()
);
$skillBlock = $template->get_template('social/skills_block.tpl');
return $template->fetch($skillBlock);
}
}

@ -80,87 +80,6 @@ if (api_get_setting('profile', 'picture') == 'true') {
$social_menu_block = SocialManager::show_social_menu('home');
$social_search_block = Display::panel(UserManager::get_search_form(''), get_lang("SearchUsers"));
//BLock Social Skill
$social_skill_block = '';
if (api_get_setting('allow_skills_tool') == 'true') {
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$skills = $skill->get_user_skills(api_get_user_id(), true);
$extra = '<div class="btn-group pull-right">
<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
<ul class="dropdown-menu">';
if (api_is_student() || api_is_student_boss() || api_is_drh()) {
$extra .= '<li>' . Display::url(
get_lang('SkillsReport'),
api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
) . '</li>';
}
$extra.= '<li>' . Display::url(
get_lang('SkillsWheel'),
api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
) . '</li>';
$extra .= '<li>' . Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
) . '</li>';
$extra .= '</ul></div>';
$social_skill_block = Display::panel(
null,
get_lang('Skills'),
null,
null,
$extra
);
$lis = '';
if (!empty($skills)) {
foreach ($skills as $skill) {
$badgeImage = null;
if (!empty($skill['icon'])) {
$badgeImage = Display::img(
$skill['web_icon_thumb_path'],
$skill['name']
);
} else {
$badgeImage = Display::return_icon(
'badges-default.png',
$skill['name'],
array('title' => $skill['name']), ICON_SIZE_BIG
);
}
$lis .= Display::tag(
'li',
$badgeImage .
'<div class="badges-name">' . $skill['name'] . '</div>'
);
}
$content = Display::tag('ul', $lis, array('class' => 'list-badges'));
$social_skill_block = Display::panel(
$content,
get_lang('Skills'),
null,
null,
$extra
);
} else {
$social_skill_block .= Display::panel(
Display::url(get_lang('SkillsWheel'), api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'),
get_lang('WithoutAchievedSkills')
);
}
}
$results = $userGroup->get_groups_by_age(1, false);
$groups_newest = array();
@ -277,7 +196,7 @@ SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_search_block', $social_search_block);
$tpl->assign('social_skill_block', $social_skill_block);
$tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id));
$tpl->assign('social_group_block', $social_group_block);
$social_layout = $tpl->get_template('social/home.tpl');
$tpl->display($social_layout);

@ -34,7 +34,6 @@ $social_extra_info_block = null;
$social_course_block = null;
$social_group_info_block = null;
$social_rss_block = null;
$social_skill_block = null;
$social_session_block = null;
if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) {
@ -501,74 +500,6 @@ if ($show_full_profile) {
$social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds'));
}
//BLock Social Skill
if (api_get_setting('allow_skills_tool') == 'true') {
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($my_user_id);
$skills = $skill->get_user_skills($my_user_id, true);
$social_skill_block = '<div class="panel panel-default social-skill">';
$social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
$social_skill_block .= '<div class="btn-group pull-right"> <a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
<ul class="dropdown-menu">';
if (api_is_student() || api_is_student_boss() || api_is_drh()) {
$social_skill_block .= '<li>' . Display::url(
get_lang('SkillsReport'),
api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
) . '</li>';
}
$social_skill_block .= '<li>' . Display::url(
get_lang('SkillsWheel'),
api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
) . '</li>';
$social_skill_block .= '<li>' . Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
) . '</li>';
$social_skill_block .= '</ul></div></div>';
$lis = '';
if (!empty($skills)) {
foreach ($skills as $skill) {
$badgeImage = null;
if (!empty($skill['icon'])) {
$badgeImage = Display::img(
api_get_path(WEB_DATA_PATH) . $skill['icon'],
$skill['name']
);
} else {
$badgeImage = Display::return_icon(
'badges-default.png',
$skill['name'],
array('title' => $skill['name']),ICON_SIZE_BIG
);
}
$lis .= Display::tag(
'li',
$badgeImage .
'<div class="badges-name">' . $skill['name'] . '</div>'
);
}
$social_skill_block .= '<div class="panel-body">';
$social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
$social_skill_block .= '</div>';
} else {
$social_skill_block .= '<div class="panel-body">';
$social_skill_block .= '<p>'. get_lang("WithoutAchievedSkills") . '</p>';
$social_skill_block .= '<p>' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'</p>';
$social_skill_block .= '</div>';
}
$social_skill_block.='</div>';
}
// Productions
$production_list = UserManager::build_production_list($user_id);
@ -691,7 +622,7 @@ $tpl->assign('social_extra_info_block', $social_extra_info_block);
$tpl->assign('social_course_block', $social_course_block);
$tpl->assign('social_group_info_block', $social_group_info_block);
$tpl->assign('social_rss_block', $social_rss_block);
$tpl->assign('social_skill_block', $social_skill_block);
$tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id));
$tpl->assign('social_session_block', $social_session_block);
$tpl->assign('social_right_information', $socialRightInformation);
$tpl->assign('social_auto_extend_link', $socialAutoExtendLink);

@ -0,0 +1,41 @@
<div class="panel panel-default social-skill">
<div class="panel-heading">
{{ 'Skills'|get_lang }}
<div class="btn-group pull-right">
<a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% if show_skills_report_link %}
<li>
<a href="{{ _p.web_main ~ 'social/my_skills_report.php' }}"> {{'SkillsReport'|get_lang }}</a>
</li>
{% endif %}
<li>
<a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}"> {{ 'SkillsWheel'|get_lang }}</a>
</li>
<li>
<a href="{{ _p.web_main ~ 'social/skills_ranking.php' }}"> {{ 'YourSkillRankingX'|get_lang|format(ranking) }}</a>
</li>
</ul>
</div>
</div>
<div class="panel-body">
{% if skills %}
<ul class="list-badges">
{% for skill in skills %}
<li>
<img title="{{ skill.name }}" src="{{ skill.icon ? skill.web_icon_thumb_path : 'badges-default.png'|icon(64) }}" alt="{{ skill.name }}">
<div class="badges-name">{{ skill.name }}</div>
</li>
{% endfor %}
</ul>
{% else %}
<p>{{ 'WithoutAchievedSkills'|get_lang }}</p>
<p>
<a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}">{{ 'SkillsWheel'|get_lang }}</a>
</p>
{% endif %}
</div>
</div>
Loading…
Cancel
Save