public function processOptions($page)
 {
     if (!$page instanceof I2CE_Page) {
         I2CE::raiseError("Did not receive page when expected");
         return false;
     }
     $template = $page->getTemplate();
     if (!$template instanceof I2CE_Template) {
         return;
     }
     $qry = '//select[@id]';
     $results = $template->query($qry);
     for ($i = 0; $i < $results->length; $i++) {
         $node = $results->item($i);
         $id = $node->getAttribute('id');
         $data_list = $template->getData('OPTION', $id, $node, true, false);
         $template->removeData('OPTION', $id, false, $node);
         if (empty($data_list)) {
             continue;
         }
         I2CE_DisplayData::processDisplayValue($template, $node, $data_list, true);
     }
 }
Пример #2
0
 public function addAjaxLink($link_name, $source_id, $target_id, $node, $action, $transient_options = array())
 {
     if (!$this->template instanceof I2CE_Template) {
         return false;
     }
     $mod_factory = I2CE_ModuleFactory::instance();
     $this->template->setDisplayDataImmediate('description', $this->getDescription(), $node);
     $this->template->setDisplayDataImmediate('displayName', $this->getDisplayName(), $node);
     $this->template->reIdNodes($target_id, $target_id . ':' . $this->path, $node);
     $comps = $this->factory->getPathComponents($this->path);
     if ($link_name === false) {
         $opened = true;
     } else {
         $openName = 'openedLinks:' . implode(':', $comps) . ":/open";
         $opened = $this->factory->getStoredOptions($openName);
     }
     $open = false;
     if ($opened) {
         $targetNode = $this->template->getElementById($target_id . ':' . $this->path, $node);
         if ($targetNode instanceof DOMElement) {
             $open = true;
             $contentNode = $this->template->createElement('span');
             //$node->appendChild($contentNode);
             //we actually display this  swiss;
             $this->displayValues($contentNode, $transient_options, $action);
             $s_contentNode = $this->template->getElementById($source_id, $contentNode);
             if ($s_contentNode instanceof DOMNode) {
                 $s_contentNode->setAttribute('id', $s_contentNode->getAttribute('id') . ':' . $this->path);
                 $targetNode->appendChild($s_contentNode);
             }
         }
     }
     if ($link_name == false) {
         return true;
     }
     $link = $this->getURLRoot($action) . $this->path . $this->getURLQueryString();
     $this->template->setDisplayDataImmediate($link_name, $link, $node);
     $inputNode = $this->template->getElementById($link_name, $node);
     if ($inputNode instanceof DOMElement && $inputNode->tagName == 'a') {
         I2CE_DisplayData::processDisplayValue($this->template, $inputNode, $link);
     }
     if (!$mod_factory->isEnabled('stub') || !$this->template->hasAjax()) {
         return true;
     }
     $this->template->reIdNodes($link_name, $link_name . ':' . $this->path, $node);
     $this->template->addAnchorIdByName($link_name, $link_name . ':' . $this->path, $node);
     $this->template->addAjaxToggle($target_id . ':' . $this->path, $link_name . ':' . $this->path, 'click', $link, $source_id, $this->getAjaxJSNodes(), '', false, $open);
     $js = "formworms['swiss_form'].scanForSubmits('{$target_id}:{$this->path}'); " . "var input = \$\$('input[name=swissFactory:options:{$openName}]'); " . "if (input && input.length > 0) {  input[0].setProperty('value',1);} " . "else {  new Element('input',{type:'hidden',name:'swissFactory:options:{$openName}', value: 1}).inject('swiss_form');}";
     $this->template->addAjaxCompleteFunction($link_name . ':' . $this->path, $js);
     $js = "formworms['swiss_form'].scanForSubmits('{$target_id}:{$this->path}'); " . "var input = \$\$('input[name=swissFactory:options:{$openName}]'); " . "if (input && input.length > 0) {  input[0].setProperty('value',0);} " . "else { new Element('input',{type:'hidden',name:'swissFactory:options:{$openName}', value: 0}).inject('swiss_form');}";
     $this->template->addAjaxToggleOffFunction($link_name . ':' . $this->path, $js);
     if ($inputNode instanceof DOMElement && $inputNode->hasAttribute('toggle_button_show') && $inputNode->hasAttribute('toggle_button_hide')) {
         $js_off = "var button=\$('{$link_name}:{$this->path}');" . " if(button){" . "button.removeClass('" . addslashes($inputNode->getAttribute('toggle_button_show')) . "');" . "button.addClass('" . addslashes($inputNode->getAttribute('toggle_button_hide')) . "');" . '}';
         $js_on = "var button=\$('{$link_name}:{$this->path}');" . "if(button){" . "button.removeClass('" . addslashes($inputNode->getAttribute('toggle_button_hide')) . "');" . "button.addClass('" . addslashes($inputNode->getAttribute('toggle_button_show')) . "');" . '}';
         $inputNode->removeAttribute('toggle_button_show');
         $inputNode->removeAttribute('toggle_button_hide');
         $this->template->addAjaxToggleOffFunction($link_name . ':' . $this->path, $js_off);
         $this->template->addAjaxToggleOnFunction($link_name . ':' . $this->path, $js_on);
     }
     return true;
 }
Пример #3
0
 protected function processDisplayValues()
 {
     $template = self::$page->getTemplate();
     $results = $template->query("//*[@display]");
     for ($i = 0; $i < $results->length; $i++) {
         $node = $results->item($i);
         if ($node->hasAttribute('display')) {
             $display = $node->getAttribute('display');
             $orig_display = $display;
             try {
                 $value = self::callModuleFunction(false, false, $display, false);
                 //not a template function. just
             } catch (Exception $e) {
                 //I2CE::raiseError("Could not display $orig_display:\n" . $e->getMessage());
                 // I2CE_DisplayData::processDisplayValue($template,$node,$value[0],true);
                 continue;
             }
             //we use the output of callModuleFunction to process the display
             //$node->removeAttribute('display');
             if (is_array($value) && count($value) == 1) {
                 I2CE_DisplayData::processDisplayValue($template, $node, $value[0], true);
             }
         }
     }
 }