1 <?php
2 3 4 5 6 7 8
9
10 defined('JPATH_PLATFORM') or die;
11
12 13 14 15 16
17 class JFormFieldContenthistory extends JFormField
18 {
19 20 21 22 23 24
25 public $type = 'ContentHistory';
26
27 28 29 30 31
32 protected $layout = 'joomla.form.field.contenthistory';
33
34 35 36 37 38
39 public function getLayoutData()
40 {
41
42 $data = parent::getLayoutData();
43
44 $typeId = JTable::getInstance('Contenttype')->getTypeId($this->element['data-typeAlias']);
45 $itemId = $this->form->getValue('id');
46 $label = JText::_('JTOOLBAR_VERSIONS');
47
48 $link = 'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&field='
49 . $this->id . '&item_id=' . $itemId . '&type_id=' . $typeId . '&type_alias='
50 . $this->element['data-typeAlias'] . '&' . JSession::getFormToken() . '=1';
51
52 $extraData = array(
53 'type' => $typeId,
54 'item' => $itemId,
55 'label' => $label,
56 'link' => $link,
57 );
58
59 return array_merge($data, $extraData);
60 }
61
62 63 64 65 66 67 68
69 protected function getInput()
70 {
71 if (empty($this->layout))
72 {
73 throw new UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
74 }
75
76 return $this->getRenderer($this->layout)->render($this->getLayoutData());
77 }
78 }
79