/** * Register option-specific fields * @param SLB_Fields $fields Reference to global fields object * @return void */ function register_fields($fields) { // Layouts $o = $this->get_field_elements(); $l =& $o->layout; $form = implode('', array($l->opt_pre, $l->label_ref, $l->field_pre, $l->form, $l->field_post, $l->opt_post)); // Text input $otxt = new SLB_Field_Type('option_text', 'text'); $otxt->set_property('class', '{inherit} code'); $otxt->set_property('size', null); $otxt->set_property('value', '{data context="form"}'); $otxt->set_layout('label', $l->label); $otxt->set_layout('form', $form); $fields->add($otxt); // Checkbox $ocb = new SLB_Field_Type('option_checkbox', 'checkbox'); $ocb->set_layout('label', $l->label); $ocb->set_layout('form', $form); $fields->add($ocb); // Select $othm = new SLB_Field_Type('option_select', 'select'); $othm->set_layout('label', $l->label); $othm->set_layout('form_start', $l->field_pre . '{inherit}'); $othm->set_layout('form_end', '{inherit}' . $l->field_post); $othm->set_layout('form', $l->opt_pre . '{inherit}' . $l->opt_post); $fields->add($othm); }
/** * Initialize fields */ function register_types() { /* Field Types */ //Base $base = new SLB_Field_Type('base'); $base->set_description(__('Default Element', 'simple-lightbox')); $base->set_property('tag', 'span'); $base->set_property('class', '', 'attr'); $base->set_layout('form_attr', '{tag} name="{field_name}" id="{field_id}" {properties ref_base="root" group="attr"}'); $base->set_layout('form', '<{form_attr ref_base="layout"} />'); $base->set_layout('label', '<label for="{field_id}">{label}</label>'); $base->set_layout('display', '{data context="display"}'); $this->add($base); //Base closed $base_closed = new SLB_Field_Type('base_closed'); $base_closed->set_parent('base'); $base_closed->set_description(__('Default Element (Closed Tag)', 'simple-lightbox')); $base_closed->set_layout('form_start', '<{tag} id="{field_id}" name="{field_name}" {properties ref_base="root" group="attr"}>'); $base_closed->set_layout('form_end', '</{tag}>'); $base_closed->set_layout('form', '{form_start ref_base="layout"}{data}{form_end ref_base="layout"}'); $this->add($base_closed); //Input $input = new SLB_Field_Type('input', 'base'); $input->set_description(__('Default Input Element', 'simple-lightbox')); $input->set_property('tag', 'input'); $input->set_property('type', 'text', 'attr'); $input->set_property('value', '{data}', 'attr'); $this->add($input); //Text input $text = new SLB_Field_Type('text', 'input'); $text->set_description(__('Text Box', 'simple-lightbox')); $text->set_property('size', 15, 'attr'); $text->set_property('label'); $text->set_layout('form', '{label ref_base="layout"} {inherit}'); $this->add($text); //Checkbox $cb = new SLB_Field_Type('checkbox', 'input'); $cb->set_property('type', 'checkbox'); $cb->set_property('value', null); $cb->set_layout('form_attr', '{inherit} {checked}'); $cb->set_layout('form', '{label ref_base="layout"} <{form_attr ref_base="layout"} />'); $this->add($cb); //Textarea $ta = new SLB_Field_Type('textarea', 'base_closed'); $ta->set_property('tag', 'textarea'); $ta->set_property('cols', 40, 'attr'); $ta->set_property('rows', 3, 'attr'); $this->add($ta); //Rich Text $rt = new SLB_Field_Type('richtext', 'textarea'); $rt->set_property('class', 'theEditor {inherit}'); $rt->set_layout('form', '<div class="rt_container">{inherit}</div>'); $rt->add_action('admin_print_footer_scripts', 'wp_tiny_mce', 25); $this->add($rt); //Hidden $hidden = new SLB_Field_Type('hidden'); $hidden->set_parent('input'); $hidden->set_description(__('Hidden Field', 'simple-lightbox')); $hidden->set_property('type', 'hidden'); $this->add($hidden); //Select $select = new SLB_Field_Type('select', 'base_closed'); $select->set_description(__('Select tag', 'simple-lightbox')); $select->set_property('tag', 'select'); $select->set_property('tag_option', 'option'); $select->set_property('options', array()); $select->set_layout('form', '{label ref_base="layout"} {form_start ref_base="layout"}{option_loop ref_base="layout"}{form_end ref_base="layout"}'); $select->set_layout('option_loop', '{loop data="properties.options" layout="option" layout_data="option_data"}'); $select->set_layout('option', '<{tag_option} value="{data_ext id="option_value"}">{data_ext id="option_text"}</{tag_option}>'); $select->set_layout('option_data', '<{tag_option} value="{data_ext id="option_value"}" selected="selected">{data_ext id="option_text"}</{tag_option}>'); $this->add($select); //Span $span = new SLB_Field_Type('span', 'base_closed'); $span->set_description(__('Inline wrapper', 'simple-lightbox')); $span->set_property('tag', 'span'); $span->set_property('value', 'Hello there!'); $this->add($span); //Enable plugins to modify (add, remove, etc.) field types $this->util->do_action_ref_array('register_fields', array($this), false); //Signal completion of field registration $this->util->do_action_ref_array('fields_registered', array($this), false); }