public function generate($node) { parent::generate($node); if (!$node instanceof DOMNode || !$this->options['parent_obj'] instanceof I2CE_Form) { return; } if ($this->options['parent_display']['printf']) { ksort($this->options['parent_display']['printf_args']); $vals = array(); foreach ($this->options['parent_display']['printf_args'] as $field) { $fieldObj = $this->options['parent_obj']->getField($field); if ($fieldObj instanceof I2CE_FormField) { $vals[] = $fieldObj->getDisplayValue(); } else { $vals[] = ''; } } $disp = @vsprintf($this->options['parent_display']['printf'], $vals); $this->setDisplayDataImmediate('parent_disp', $disp, $node); } }
public function generate($node) { parent::generate($node); if (!$node instanceof DOMNode || !$this->primaryObject instanceof I2CE_Form || $this->options['is_edit']) { return; } if (count($this->options['mapped']) > 0 && ($mapped_node = $this->template->getElementById('mapped_forms', $node)) instanceof DOMNode) { $this->template->addHeaderLink('view.js'); foreach ($this->options['mapped'] as $list => $form_data) { $mapped_node->appendChild($divNode = $this->template->createElement('div')); $link_data['form'] = $form; $gizmo = new I2CE_Gizmo_MappedLists($this->page, $this->primaryObject, $form_data); $gizmo->generate($divNode); } } if (count($this->options['linked']) > 0 && ($linked_node = $this->template->getElementById('linked_forms', $node)) instanceof DOMNode) { foreach ($this->options['linked'] as $link_data) { $linked_node->appendChild($divNode = $this->template->createElement('div')); $gizmo = new I2CE_Gizmo_LinkedLists($this->page, $this->primaryObject, $link_data); $gizmo->generate($divNode); } } return true; }
/** * Load the HTML template files for editing. */ protected function loadHTMLTemplates() { if (array_key_exists('auto_template', $this->args) && is_array($this->args['auto_template']) && !(array_key_exists('disabled', $this->args['auto_template']) && $this->args['auto_template']['disabled'])) { $append_node = 'siteContent'; if (array_key_exists('append_node', $this->args['auto_template']) && is_scalar($this->args['auto_template']['append_node']) && $this->args['auto_template']['append_node']) { $append_node = $this->args['auto_template']['append_node']; } if (!($node = $this->template->appendFileById($this->getBaseTemplate(), 'div', $append_node)) instanceof DOMNode) { I2CE::raiseError("Could not load template:" . $this->getBaseTemplate()); return false; } $options = $this->args['auto_template']; $options['is_edit'] = true; $gizmo = new I2CE_Gizmo_Form($this, $this->primaryObject, $options); $gizmo->generate($node); return true; } else { return parent::loadHTMLTemplates(); } }
protected function loadHTMLTemplates() { $append_node = 'siteContent'; if (array_key_exists('auto_template', $this->args) && is_array($this->args['auto_template'])) { if (array_key_exists('append_node', $this->args['auto_template']) && is_scalar($this->args['auto_template']['append_node']) && $this->args['auto_template']['append_node']) { $append_node = $this->args['auto_template']['append_node']; } $options = $this->args['auto_template']; } else { $options = array(); } if (!array_key_exists('field_data', $options) || !is_array($opions['field_data'])) { $options['field_data'] = array(); } if (!($node = $this->template->appendFileById($this->getBaseTemplate(), 'div', $append_node)) instanceof DOMNode || !($searchNode = $this->template->getElementByID('search', $node)) instanceof DOMNode || !($resultsNode = $this->template->getElementByID('results', $node)) instanceof DOMNode) { I2CE::raiseError("Could not load template:" . $this->getBaseTemplate()); return false; } $s_options = $options; $s_options['is_edit'] = true; $s_options['template'] = 'csd_search_form_search.html'; $s_options['field_data']['matches'] = array('enabled' => false); $s_options['field_data']['result'] = array('enabled' => false); $searchGizmo = new I2CE_Gizmo_Form($this, $this->primaryObject, $s_options); $searchGizmo->generate($searchNode); if (($this->isPost() || $this->hasData()) && !$this->bad_result) { $r_soptions = $options; $r_options['is_edit'] = false; $r_options['template'] = 'csd_search_form_results.html'; foreach ($this->primaryObject->getFieldNames() as $field) { if ($field != 'matches' && $field != 'result') { $r_options['field_data'][$field] = array('enabled' => false); } } $r_options['display_order'] = 'matches,result'; $resultsGizmo = new I2CE_Gizmo_Form($this, $this->primaryObject, $r_options); $resultsGizmo->generate($resultsNode); } else { $this->template->removeNode($resultsNode); } return true; }
public function generate($node) { parent::generate($node); if (!$node instanceof DOMNode || !$this->primaryObject instanceof I2CE_Form || !($linked_node = $this->template->getElementById('child_forms', $node)) instanceof DOMNode || $this->options['is_edit'] && $this->options['edit_child']) { return; } if (is_array($this->options['child_forms'])) { $t_child_forms = array(); foreach ($this->options['child_forms'] as $k => $v) { $t_child_forms[] = $k; } } else { I2CE::raiseError('No array'); } $child_forms = array(); if (array_key_exists('child_form_order', $this->options) && is_array($order = $this->options['child_form_order'])) { foreach ($order as $child_form) { if (!in_array($child_form, $t_child_forms)) { continue; } $child_forms[] = $child_form; } } $child_forms = array_unique(array_merge($child_forms, $t_child_forms)); $id = $this->primaryObject->getNameId(); foreach ($child_forms as $child_form) { if (!array_key_exists($child_form, $this->options['child_forms']) || !is_array($c_data = $this->options['child_forms'][$child_form])) { continue; } if (!array_key_exists('base_url', $c_data)) { $c_data['base_url'] = $this->options['base_url']; $c_data['append_url'] = $this->options['append_url'] . '/' . $child_form; } $container_id = 'container-' . $child_form . '-' . $id; $attrs = array('name' => 'child_' . $child_form, 'id' => $container_id, 'class' => 'container_content'); $linked_node->appendChild($divNode = $this->template->createElement('div', $attrs)); switch ($c_data['ajax_load_child']) { case 'on_container': $url = 'index.php/' . $c_data['container_link'] . $id; $attrs = array('href' => $url); if ($c_data['container_link_filter']) { $js = 'ajaxLoadDiv(this,"' . $container_id . '","' . $url . '","' . $c_data['container_link_filter'] . '");'; } else { $js = 'ajaxLoadDiv(this,"' . $container_id . '","' . $url . '");'; } $this->template->addHeaderLink('mootools-core.js'); $this->template->addHeaderLink('mootools-more.js'); $this->template->addHeaderLink('view.js'); //this will be replaced by container on ajax load $divNode->appendChild($panelNode = $this->template->createElement('div', array('class' => 'panel panel-default'))); $panelNode->appendChild($panelHNode = $this->template->createElement('div', array('class' => 'panel-heading'))); $panelHNode->appendChild($this->template->createElement('a', array('onClick' => $js, 'class' => 'clicker_hide'))); $panelHNode->appendChild($titleNode = $this->template->createElement('h3', array('style' => 'display:inline-block;margin-bottom:1em'))); $titleNode->appendChild($this->template->createElement('a', $attrs, $c_data['title'])); $panelNode->appendChild($panelCNode = $this->template->createElement('div', array('class' => 'panel-heading', 'id' => $container_id, 'style' => 'display:none'))); break; case 'static': if (!array_key_exists('do_ajax', $c_data)) { $c_data['do_ajax'] = false; } $gizmo = new I2CE_Gizmo_FormAjaxChildView($this->page, $this->primaryObject, $c_data); $gizmo->generate($divNode); break; case 'on_child_links': default: if (!array_key_exists('do_ajax', $c_data)) { $c_data['do_ajax'] = true; } $gizmo = new I2CE_Gizmo_FormAjaxChildView($this->page, $this->primaryObject, $c_data); $gizmo->generate($divNode); break; } } return true; }