protected function generateAjaxLink($id, $text, $tbodyNode) { $form = $this->options['form']; $tbodyNode->appendChild($trNode = $this->template->createElement('tr', array('colspan' => 2))); $trNode->appendChild($tdNode = $this->template->createElement('td', array('colspan' => 2))); if ($this->options['do_ajax'] && $this->options['link']) { $url = 'index.php/' . $this->options['link'] . $form . '|' . $id; $attrs = array('href' => $url); $content_id = 'content-' . $form . '-' . $id; if ($this->options['link_filter']) { $js = 'ajaxLoadDiv(this,"' . $content_id . '","' . $url . '","' . $this->options['link_filter'] . '");'; } else { $js = 'ajaxLoadDiv(this,"' . $content_id . '","' . $url . '");'; } $this->template->addHeaderLink('mootools-core.js'); $this->template->addHeaderLink('mootools-more.js'); $this->template->addHeaderLink('view.js'); $tdNode->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($this->template->createElement('a', $attrs, $text)); $panelNode->appendChild($panelCNode = $this->template->createElement('div', array('class' => 'panel-heading', 'id' => $content_id, 'style' => 'display:none'))); //$tdNode->appendChild($this->template->createElement('a',$attrs,$text)); } else { if (($childObj = I2CE_FormFactory::instance()->createContainer(array($form, $id))) instanceof I2CE_Form && $tdNode->appendChild($appendNode = $this->template->createElement('span', array('name' => "child:{$form}|{$id}"))) instanceof DOMNode) { $childObj->populate(); $options = $this->options; $options['auto_add_new_child_link'] = false; $options['template'] = $this->options['template_child']; if (array_key_exists('auto_add_new', $options['action_links'])) { unset($options['action_links']['auto_add_new']); } $gizmo = new I2CE_Gizmo_FormView($this->page, $childObj, $options); $appendNode->setAttribute("name", $childObj->getNameID()); I2CE::raiseError("A0"); $gizmo->generate($appendNode); I2CE::raiseError("A1"); } else { $tdNode->appendChild($this->template->createElement('span', array('name' => "child:{$form}|{$id}"), $text)); } } }
protected function loadHTMLTemplates() { $templateConfig = array(); if ($this->module == 'I2CE') { $url = $this->page; } else { $url = $this->module . '/' . $this->page; } if (!array_key_exists('auto_template', $this->args) || !is_array($this->args['auto_template'])) { $this->args['auto_template'] = array(); } $request_remainder = $this->request_remainder; //shift off the action (edit, view) array_shift($request_remainder); $form = $this->getPrimaryFormName(); $templateConfig = $this->args['auto_template']; $error = false; $nav_links = array(); $p_forms = array(); while (count($request_remainder) > 0) { $p_forms[] = $form; $form = $request_remainder[0]; if (!array_key_exists('child_forms', $templateConfig) || !is_array($templateConfig['child_forms']) || !array_key_exists($form, $templateConfig['child_forms']) || !is_array($templateConfig['child_forms'][$form])) { $error = true; break; } $templateConfig = $templateConfig['child_forms'][$form]; if (($p_formObj = $this->factory->createContainer(end($p_forms))) instanceof I2CE_Form) { $view_parent_text = 'View %s'; I2CE::getConfig()->setIfIsSet($view_parent_text, "/modules/form-gizmos/messages/view_parent"); $nav_links['view_parent_' . end($p_forms)] = array('text' => @sprintf($view_parent_text, $p_formObj->getDisplayName()), 'formfield' => end($p_forms) . ':id', 'href' => $url . '/view/' . implode('/', array_slice($p_forms, 1)) . '?id='); } array_shift($request_remainder); } $templateConfig['form'] = $form; if (!array_key_exists('navigation_links', $templateConfig) || !is_array($templateConfig['navigation_links'])) { $templateConfig['navigation_links'] = array(); } foreach ($nav_links as $link => $data) { if (array_key_exists($link, $templateConfig['navigation_links']) && is_array($templateConfig['navigation_links'][$link])) { continue; } $templateConfig['navigation_links'][$link] = $data; } if ($error) { I2CE::raiseError("Could not find details for: " . $form); return false; } //die("MM"); $templateConfig['base_url'] = $url; $request_remainder = $this->request_remainder; array_shift($request_remainder); $templateConfig['append_url'] = implode('/', $request_remainder); if (!($node = $this->template->getElementById('siteContent')) instanceof DOMNode) { return false; } $action = $this->getAction(); $templateConfig['is_edit'] = $action == 'edit'; if (substr($action, 0, strlen('view_container_')) == 'view_container_') { $templateConfig['is_container'] = substr($action, strlen('view_container_')); } $gizmo = new I2CE_Gizmo_FormView($this, $this->getPrimary(), $templateConfig); $gizmo->generate($node); //now make sure all the parent objects are set on the $p_forms = array_reverse($p_forms); $obj = $this->getPrimary(); foreach ($p_forms as $p_form) { if ($p_form != $obj->getParentForm() || !($p_obj = $this->factory->createContainer(array($obj->getParentForm(), $obj->getParentID()))) instanceof I2CE_Form) { break; } $p_obj->populate(); $this->template->setForm($p_obj, $node); $obj = $p_obj; } $this->template->addHeaderLink('I2CE_DropdownMenu.js'); $this->template->addHeaderLink('ihris_menu.js'); $js = 'window.addEvent("domready", function() { $$(".clickslider").each(function(e) {new ClickSlider(e); }); $$(".ajaxlink").each(function(e) { new AjaxLink(e);}); $$(".dropdown").each(function(e) { new I2CE_DropdownMenu(e); }); var error = document.id("error_message"); if (error && error.get("html").replace(/^\\s+|\\s+$/, "").length == 0) { error.dispose();} }); '; $this->template->addHeaderText($js, 'script', 'dropdown-js'); return true; }