Skip to content

Commit

Permalink
jLayout for timer element
Browse files Browse the repository at this point in the history
  • Loading branch information
pollen8 committed Mar 23, 2015
1 parent 148cbd2 commit b1a369b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 34 deletions.
26 changes: 26 additions & 0 deletions plugins/fabrik_element/time/layouts/fabrik-element-time-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

defined('JPATH_BASE') or die;

$d = $displayData;
$attribs = 'class="input-small fabrikinput inputbox ' . $d['advancedClass'] . ' ' . $d['errorCSS'] . '"';
?>

<div class="fabrikSubElementContainer" id="<?php echo $d['id']; ?>">
<?php
// $d['name'] already suffixed with [] as element hasSubElements = true
if ($data['format'] != 'i:s')
{
$str[] = JHTML::_('select.genericlist', $d['hours'], preg_replace('#(\[\])$#', '[0]', $d['name']), $attribs, 'value', 'text', $d['hourValue']) . ' '
. $data['sep'];
}

$str[] = JHTML::_('select.genericlist', $d['mins'], preg_replace('#(\[\])$#', '[1]', $d['name']), $attribs, 'value', 'text', $d['minValue']);

if ($data['format'] != 'H:i')
{
echo $data['sep'] . ' '
. JHTML::_('select.genericlist', $d['secs'], preg_replace('#(\[\])$#', '[2]', $d['name']), $attribs, 'value', 'text', $d['secValue']);
}
?>
</div>
37 changes: 37 additions & 0 deletions plugins/fabrik_element/timer/layouts/fabrik-element-timer-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

defined('JPATH_BASE') or die;

$d = $displayData;
$readOnly = $d['timerReadOnly'] ? 'readonly=\"readonly\"' : '';
$kls = $d['timerReadOnly'] ? 'readonly' : '';

if ($d['elementError'] != '') :
$kls .= ' elementErrorHighlight';
endif;
?>

<?php
if (!$d['timerReadOnly']) :
?>
<div class="input-append">
<?php
endif;
?>
<input type="<?php echo $d['type'];?>"
class="fabrikinput input-small inputbox text <?php echo $kls;?>"
name="<?php echo $d['name']; ?>"
<?php echo $readOnly;?>
id="<?php echo $d['id']; ?>" size="<?php echo $d['size']; ?>"
value="<?php echo $d['value']; ?>" />

<?php
if (!$d['timerReadOnly']) :
?>
<button class="btn" id="<?php echo $d['id']; ?>_button">
<i class="<?php echo $d['icon']; ?>"></i> <span><?php echo FText::_('PLG_ELEMENT_TIMER_START'); ?></span>
</button>
</div>
<?php
endif;
?>
Empty file.
46 changes: 12 additions & 34 deletions plugins/fabrik_element/timer/timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,48 +76,26 @@ public function render($data, $repeatCounter = 0)
}
else
{
$value = explode(" ", $value);
$value = explode(' ', $value);
$value = array_pop($value);
}

$type = "text";

if ($this->elementError != '')
{
$type .= " elementErrorHighlight";
}

if ($element->hidden == '1')
{
$type = "hidden";
}

$sizeInfo = " size=\"$size\" ";

if ($params->get('timer_readonly'))
{
$sizeInfo .= " readonly=\"readonly\" ";
$type .= " readonly";
}

if (!$this->isEditable())
{
return ($element->hidden == '1') ? "<!-- " . $value . " -->" : $value;
}

$class = 'class="fabrikinput input-small inputbox ' . $type . '"';
$str[] = '<input type="text" ' . $class . ' name="' . $name . '" id="' . $id . '" ' . $sizeInfo . 'value="' . $value . '" />';

if (!$params->get('timer_readonly'))
{
array_unshift($str, '<div class="input-append">');
$icon = $params->get('icon', 'icon-clock');
$img = '<i class="' . $icon . '"></i> <span>' . FText::_('PLG_ELEMENT_TIMER_START') . '</span>';
$str[] = '<button class="btn" id="' . $id . '_button">' . $img . '</button>';
$str[] = '</div>';
}

return implode("\n", $str);
$layout = $this->getLayout('form');
$data['id'] = $id;
$data['type'] = $element->hidden ? 'hidden' : 'text';
$data['name'] = $name;
$data['value'] = $value;
$data['size'] = $size;
$data['elementError'] = $this->elementError;
$data['icon'] = $params->get('icon', 'icon-clock');
$data['timerReadOnly'] = $params->get('timer_readonly');

return $layout->render($data);
}

/**
Expand Down
1 change: 1 addition & 0 deletions plugins/fabrik_element/timer/timer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
<filename>index.html</filename>
<folder>forms</folder>
<folder>language</folder>
<folder>layouts</folder>
</files>
</extension>

0 comments on commit b1a369b

Please sign in to comment.