Skip to content

Commit

Permalink
php7 & new form element
Browse files Browse the repository at this point in the history
  • Loading branch information
gvollbach committed Jan 19, 2017
1 parent e1e7d5b commit 0da1d2f
Show file tree
Hide file tree
Showing 21 changed files with 1,961 additions and 426 deletions.
158 changes: 158 additions & 0 deletions classes/Form/class.ilInteractiveVideoTimePicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php
require_once './Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php';
/**
* Class ilInteractiveVideoTimePicker
*/
class ilInteractiveVideoTimePicker extends ilSubEnabledFormPropertyGUI
{
/**
* @var string
*/
protected $value;

/**
* @var string
*/
protected $title;

/**
* @var string
*/
protected $info;

/**
* @var string
*/
protected $id;

/**
* ilInteractiveVideoTimePicker constructor.
* @param string $a_title
* @param string $a_id
*/
public function __construct($a_title = "", $a_id = "")
{
parent::__construct($a_title, $a_id);
$this->setTitle($a_title);
$this->setId($a_id);
$this->setType("interactive_video_time_picker");
}

/**
* @return bool
*/
public function checkInput()
{
if(!is_array($_POST[$this->getPostVar()]))
{
$_POST[$this->getPostVar()] = $this->getSecondsFromString(ilUtil::stripSlashes($_POST[$this->getPostVar()]));
}
return $this->checkSubItemsInput();
}

/**
* @param $a_value
*/
public function setValue($a_value)
{
$this->value = $a_value;
}

/**
* @return string
*/
public function getValue()
{
return $this->value;
}

/**
* @return string
*/
public function getId()
{
return $this->id;
}

/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}

protected function appendJavascriptAndHTML()
{
/**
* @var ilTemplate $tpl
*/
global $tpl;

$tpl->addCss('Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/libs/bootstrap-timepicker/css/bootstrap-timepicker.css');
$tpl->addJavaScript('Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/libs/bootstrap-timepicker/js/bootstrap-timepicker.min.js');
}

/**
* @return string
*/
public function render()
{
$this->appendJavascriptAndHTML();
$my_tpl = new ilTemplate('tpl.time_picker.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/');
$value = $this->getValue();
$my_tpl->setVariable("VALUE", $this->getTimeStringFromSeconds($value));
$my_tpl->setVariable("ID", $this->getId());

return $my_tpl->get();
}

/**
* @param ilTemplate $a_tpl
*/
public function insert($a_tpl)
{
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $this->render());
$a_tpl->parseCurrentBlock();
}

/**
* @param $a_values
*/
public function setValueByArray($a_values)
{
if ($this->getPostVar() && isset($a_values[$this->getPostVar()]))
{
$this->setValue($a_values[$this->getPostVar()]);
}
foreach($this->getSubItems() as $item)
{
$item->setValueByArray($a_values);
}
}

/**
* @param string $comment_time
* @return int
*/
public static function getSecondsFromString($comment_time)
{
$seconds = 0;
$comment_time = preg_split('/:/', $comment_time);
if(sizeof($comment_time) == 3)
{
$seconds = ((int)$comment_time[0] * 3600) + ((int)$comment_time[1] * 60) + (int)$comment_time[2];
}
return $seconds;
}

/**
* @param $seconds
* @return false|string
*/
public static function getTimeStringFromSeconds($seconds)
{
return gmdate('H:i:s', $seconds);
}
}
2 changes: 1 addition & 1 deletion classes/Form/class.ilTextAreaInputCkeditorGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct($a_title = "", $a_postvar = "")
/**
* Insert property html
*/
function insert(&$a_tpl)
public function insert($a_tpl)
{
$this->appendJavascriptFile();
$ttpl = new ilTemplate("tpl.textarea_ckeditor.html", true, true, "Customizing/global/plugins/Services/Repository/RepositoryObject/InteractiveVideo/");
Expand Down
8 changes: 4 additions & 4 deletions classes/class.ilInteractiveVideoLearningProgressGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Michael Jansen <[email protected]>
* @ilCtrl_Calls ilInteractiveVideoLearningProgressGUI: ilLearningProgressGUI, ilInteractiveVideoLPSummaryTableGUI, ilInteractiveVideoLPUsersTableGUI
*/
class ilInteractiveVideoLearningProgressGUI
class ilInteractiveVideoLearningProgressGUI extends ilLearningProgressBaseGUI
{
//TODO: PRECONDITON HANDLING
/**
Expand Down Expand Up @@ -217,7 +217,7 @@ public function showLPUsers()

$this->gui->getPluginInstance()->includeClass('class.ilInteractiveVideoLPUsersTableGUI.php');
$table = new ilInteractiveVideoLPUsersTableGUI($this, 'showLPUsers', $this->object->getId(), $this->object->getRefId(), false);
$this->tpl->setContent(implode('<br />', array($table->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML())));
$this->tpl->setContent(implode('<br />', array($table->getHTML(), $this->__getLegendHTML())));
}

/**
Expand All @@ -237,7 +237,7 @@ public function showLPSummary()

$this->gui->getPluginInstance()->includeClass('class.ilInteractiveVideoLPSummaryTableGUI.php');
$table = new ilInteractiveVideoLPSummaryTableGUI($this, 'showLPSummary', $this->object->getRefId(), $this->gui->getPluginInstance());
$this->tpl->setContent(implode('<br />', array($table->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML())));
$this->tpl->setContent(implode('<br />', array($table->getHTML(), $this->__getLegendHTML())));
}

public function showLPUserDetails()
Expand Down Expand Up @@ -279,7 +279,7 @@ public function showLPUserDetails()
$info->addProperty($this->lng->txt('trac_comment'),$comment);
}

$this->tpl->setContent(implode('<br />', array($info->getHTML(), ilLearningProgressBaseGUI::__getLegendHTML())));
$this->tpl->setContent(implode('<br />', array($info->getHTML(), $this->__getLegendHTML())));
}

/**
Expand Down
Loading

0 comments on commit 0da1d2f

Please sign in to comment.