ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSkillCertificateAdapter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "./Services/Certificate/classes/class.ilCertificateAdapter.php";
6
15{
16 protected $object;
17 private $skill;
19
26 public function __construct($a_skill, $a_skill_level_id)
27 {
28 $this->skill = $a_skill;
29 $this->skill_level_id = $a_skill_level_id;
30 parent::__construct();
31 $this->lng->loadLanguageModule('skmg');
32 }
33
39 public function getCertificatePath()
40 {
41 return CLIENT_WEB_DIR . "/certificates/skill/" . $this->skill->getId() .
42 "/" . $this->skill_level_id . "/";
43 }
44
52 {
55
56 $vars = $this->getBaseVariablesForPreview();
57 $vars["SKILL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTitleForCertificate());
58 $vars["SKILL_LEVEL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getLevelTitleForCertificate($this->skill_level_id));
59 $vars["SKILL_TRIGGER_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTriggerTitleForCertificate($this->skill_level_id));
60
62
63 $insert_tags = array();
64 foreach ($vars as $id => $caption) {
65 $insert_tags["[" . $id . "]"] = $caption;
66 }
67 return $insert_tags;
68 }
69
79 {
80 $this->lng->loadLanguageModule('certificate');
81
82 $user_data = $params["user_data"];
83
84 $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], null);
85 $vars["SKILL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTitleForCertificate());
86 $vars["SKILL_LEVEL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getLevelTitleForCertificate($this->skill_level_id));
87 $vars["SKILL_TRIGGER_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTriggerTitleForCertificate($this->skill_level_id));
88
89 // custom completion date
90 $achievement_date = ilBasicSkill::lookupLevelAchievementDate($user_data["usr_id"], $this->skill_level_id);
91 if ($achievement_date !== false) {
94
95 $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($achievement_date, IL_CAL_DATETIME));
96 $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($achievement_date, IL_CAL_DATETIME));
97
99 } else {
100 $vars["DATE_COMPLETED"] = "";
101 $vars["DATETIME_COMPLETED"] = "";
102 }
103
104 foreach ($vars as $id => $caption) {
105 $insert_tags["[" . $id . "]"] = $caption;
106 }
107 return $insert_tags;
108 }
109
117 {
118 $this->lng->loadLanguageModule("skmg");
119
120 $vars = $this->getBaseVariablesDescription();
121 $vars["SKILL_TITLE"] = $this->lng->txt("skmg_cert_skill_title");
122 $vars["SKILL_LEVEL_TITLE"] = $this->lng->txt("skmg_cert_skill_level_title");
123 $vars["SKILL_TRIGGER_TITLE"] = $this->lng->txt("skmg_cert_skill_trigger_title");
124
125 $template = new ilTemplate("tpl.certificate_edit.html", true, true, "Services/Skill");
126 $template->setCurrentBlock("items");
127 foreach ($vars as $id => $caption) {
128 $template->setVariable("ID", $id);
129 $template->setVariable("TXT", $caption);
130 $template->parseCurrentBlock();
131 }
132
133 $template->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
134
135 return $template->get();
136 }
137
147 public function addAdditionalFormElements(&$form, $form_fields)
148 {
149 }
150
159 public function addFormFieldsFromPOST(&$form_fields)
160 {
161 }
162
171 public function addFormFieldsFromObject(&$form_fields)
172 {
173 }
174
182 public function saveFormFields(&$form_fields)
183 {
184 }
185
192 public function getAdapterType()
193 {
194 return "skill";
195 }
196
203 public function getCertificateID()
204 {
206 }
207
214 public function getCertificateFilename($params = array())
215 {
216 $basename = parent::getCertificateFilename($params);
217
218 $user_data = $params["user_data"];
219 if (!is_array($user_data)) {
220 $short_title = $this->skill->getShortTitleForCertificate();
221 return strftime("%y%m%d", time()) . "_" . $this->lng->txt("certificate_var_user_lastname") . "_" . $short_title . "_" . $basename;
222 } else {
223 return strftime("%y%m%d", time()) . "_" . $user_data["lastname"] . "_" . $params["short_title"] . "_" . $basename;
224 }
225 }
226
232 public function deleteCertificate()
233 {
234 }
235}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
Adapter class to provide certificate data for the certificate generator.
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
Class for single dates.
addFormFieldsFromObject(&$form_fields)
Allows to add additional form values to the array of form values evaluating the associated adapter cl...
getCertificateVariablesForPresentation($params=array())
Returns an array containing all variables and values which can be exchanged in the certificate The va...
getCertificateVariablesForPreview()
Returns an array containing all variables and values which can be exchanged in the certificate.
addFormFieldsFromPOST(&$form_fields)
Allows to add additional form values to the array of form values evaluating a HTTP POST action.
getCertificateFilename($params=array())
Set the name of the certificate file This method will be called when the certificate will be generate...
getAdapterType()
Returns the adapter type This value will be used to generate file names for the certificates.
getCertificateID()
Returns a certificate ID This value will be used to generate unique file names for the certificates.
getCertificateVariablesDescription()
Returns a description of the available certificate parameters.
getCertificatePath()
Returns the certificate path (with a trailing path separator)
deleteCertificate()
Is called when the certificate is deleted Add some adapter specific code if more work has to be done ...
addAdditionalFormElements(&$form, $form_fields)
Allows to add additional form fields to the certificate editor form This method will be called when t...
__construct($a_skill, $a_skill_level_id)
Contructor.
saveFormFields(&$form_fields)
Allows to save additional adapter form fields This method will be called when the certificate editor ...
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$template
if(!array_key_exists('StateId', $_REQUEST)) $id
if(isset($_POST['submit'])) $form
$old
$params
Definition: disable.php:11