Completed
Push — develop ( 0122be...15a92d )
by
unknown
18:25 queued 09:50
created

FormDatePicker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
B render() 0 31 2
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/**  */
11
namespace Core\Form\View\Helper;
12
13
use Zend\Form\ElementInterface;
14
use Zend\Form\View\Helper\FormText;
15
16
/**
17
 * View Helper for generating the markup used by bootstrap-datepicker4 elements
18
 *
19
 * @see http://bootstrap-datepicker.readthedocs.org/en/latest/
20
 * @author Bleek Carsten <[email protected]>
21
 */
22
class FormDatePicker extends FormText
23
{
24
    /**
25
     * Language of the datepicker
26
     *
27
     * @var string
28
     */
29
    protected $language="de";
30
31
    public function __invoke(\Zend\Form\ElementInterface $element)
32
    {
33
        return $this->render($element);
34
    }
35
36
    public function render(ElementInterface $element)
37
    {
38
        /* @var \Zend\View\Renderer\PhpRenderer $view */
39
        $view = $this->getView();
40
        /* @var \Zend\View\Helper\HeadScript $headScript */
41
        $headScript = $view->plugin('headscript');
42
        /* @var \Zend\View\Helper\BasePath $basePath */
43
44
        $basePath = $view->plugin('basePath');
45
46
        if (in_array($this->language, ['de'])) {
47
            $headScript->appendFile($basePath('/js/bootstrap-datepicker/locales/bootstrap-datepicker.de.min.js'));
48
        }
49
        $headScript->appendFile($basePath('/js/bootstrap-datepicker/js/bootstrap-datepicker.min.js'));
50
51
52
        $input = parent::render($element);
53
54
        /*
55
         *
56
         */
57
        $markup = '<div class="input-group date"  data-date-format="yyyy-mm-dd" data-provide="datepicker">%s<div class="input-group-addon">' .
58
            '<i class="fa fa-calendar"></i></div></div><div class="checkbox"></div>';
59
        
60
        $markup = sprintf(
61
            $markup,
62
            $input
63
        );
64
        
65
        return $markup;
66
    }
67
}
68