PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / ui / element / form.php

form.php in ShiftController Employee Shift Scheduling 4.9.66, at hc3/ui/element/form.php

93 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 interface HC3_Ui_Element_IForm
3 {
4 public function setId( $set );
5 public function getId();
6 public function getAction();
7 public function setAction( $action );
8 public function render();
9 public function willCallCommand( $command );
10 }
11
12 class HC3_Ui_Element_Form extends HC3_Ui_Abstract_Element implements HC3_Ui_Element_IForm
13 {
14 protected $uiType = 'form';
15
16 protected $htmlFactory = NULL;
17 protected $action = NULL;
18 protected $content = NULL;
19 protected $id = NULL;
20
21 protected $willCallCommand = NULL;
22
23 public function __construct( HC3_Ui $htmlFactory, $action, $content = NULL )
24 {
25 $this->htmlFactory = $htmlFactory;
26 $this->content = $content;
27 $this->setAction( $action );
28 $this->id = 'hc3form_' . mt_rand( 100000, 999999 );
29 }
30
31 public function setId( $set )
32 {
33 $this->id = $set;
34 return $this;
35 }
36
37 public function willCallCommand( $command )
38 {
39 $this->willCallCommand = $command;
40 return $this;
41 }
42
43 public function getId()
44 {
45 return $this->id;
46 }
47
48 public function getChildren()
49 {
50 $return = array( $this->content );
51 return $return;
52 }
53
54 public function setChild( $key, $child )
55 {
56 $this->content = $child;
57 return $this;
58 }
59
60 public function getAction()
61 {
62 return $this->action;
63 }
64
65 public function setAction( $action )
66 {
67 $this->action = $action;
68 return $this;
69 }
70
71 public function render()
72 {
73 $content = $this->content;
74
75 // $nonceVal = wp_create_nonce( 'shiftcontroller' );
76 // $nonceView = '<input type="hidden" name="hc_nonce" value="' . $nonceVal . '"/>';
77 // $content = $this->htmlFactory->makeCollection( array($nonceView, $content) );
78
79 $out = $this->htmlFactory->makeElement('form', $content)
80 ->addAttr('action', $this->action)
81 ->addAttr('method', 'post')
82 ->addAttr('accept-charset', 'utf-8')
83 ->addAttr('id', $this->id)
84 ;
85
86 $attr = $this->getAttr();
87 foreach( $attr as $k => $v ){
88 $out->addAttr( $k, $v );
89 }
90
91 return $out;
92 }
93 }