public function process($pParams) { extract($pParams); if (!isset($name)) { throw new CopixTemplateTagException('[AutoComplete] Required parameter name'); } if (!isset($field)) { $field = $name; } if (!isset($id)) { $id = $name; } if (!isset($value)) { $value = ""; } if (!isset($onSelect)) { $onSelect = ""; } if (!isset($onRequest)) { $onRequest = ''; } if (!isset($extra)) { $extra = ''; } if (!isset($pParams['datasource'])) { $pParams['datasource'] = 'dao'; } $toMaj = ''; $onSelectTemp = ''; if (isset($maj)) { $onSelectTemp .= "eleme.selected.id = 'selector_autocomplete';"; foreach ($maj as $key => $field) { $onSelectTemp .= "\n \$\$('#selector_autocomplete .{$key}').each (function (el) {\n \$('{$field}').value = el.innerHTML;\n });\n "; $toMaj .= $key . ';'; } } $onSelect = $onSelectTemp . $onSelect; $url = 'generictools|ajax|getAutoComplete'; if (isset($pParams['url'])) { $url = $pParams['url']; } $length = isset($length) ? $length : 1; $pParams['view'] = isset($pParams['view']) ? $pParams['view'] : $field; $tab = array(); foreach ($pParams as $key => $param) { $tab[$key] = $param; } $tab['nb'] = 10; $tab['tomaj'] = $toMaj; $js = new CopixJSWidget(); $js->tag_autocomplete($id, $name, $length, $tab, _url($url), $js->function_(null, 'el', $onRequest), $js->function_(null, 'el,eleme,element', $onSelect)); CopixHTMLHeader::addJSDOMReadyCode($js); CopixHTMLHeader::addJSLink(_resource('js/taglib/tag_autocomplete.js')); _eTag("mootools", array('plugin' => "observer;autocompleter")); $toReturn = '<input type="text" id="' . $name . '" name="' . $name . '" value="' . $value . '" ' . $extra . ' /><span id="autocompleteload_' . $name . '"><img src="' . CopixUrl::getResource('img/tools/load.gif') . '" /></span>'; return $toReturn; }
public function testfunction_4() { $js = new CopixJSWidget(); $f = $js->function_(null, array('a', 'b', 'c'), 'return 5;'); $this->assertEquals('', _toString($js)); $this->assertEquals('function(a,b,c){return 5;}', _toString($f)); }
public function process($pParams, $pContent = null) { $tabGroupId = $this->getParam('id', uniqid('tab')); $tabs = $this->requireParam('tabs', null, array()); $groupClass = $this->getParam('groupClass', ''); $tabClass = $this->getParam('tabClass', ''); $selectedClass = $this->getParam('selectedClass', 'tabSelected'); $onSelect = $this->getParam('onSelect', null, 'string'); $onUnselect = $this->getParam('onUnselect', null, 'string'); $default = $this->getParam('default'); $this->validateParams(); if ($default && !isset($tabs[$default])) { _log('[tag tabgroup] invalid default for tabgroup ' . $tabGroupId . ': ' . $default, 'errors'); $default = null; } $toReturn = array(); $toReturn[] = sprintf('<div class="tabGroup %s" id="%s">', $groupClass, $tabGroupId); $tabIds = array(); $tabKeys = array(); $i = 0; $tabIndexes = array(); foreach ($tabs as $key => $caption) { $tabId = $tabGroupId . '_tab' . $i; //preg_replace('/[^\w]/', '_', $key); //$tabIds[$tabId] = $key; $elementIds[$key] = $tabId; $tabIndexes[$key] = $i++; $toReturn[] = sprintf('<span class="tabCaption %s %s" id="%s">%s</span>', $tabClass, $key == $default ? $selectedClass : '', $tabId, _copix_utf8_htmlentities($caption)); } $toReturn[] = '</div>'; CopixHTMLHeader::addJSLink(_resource('js/taglib/tabgroup.js'), array('id' => 'taglib_tabgroup_js')); $params = array('id' => $tabGroupId, 'selectedClass' => $selectedClass, 'tabs' => array_keys($tabs)); if ($default) { $params['defaultTab'] = $tabIndexes[$default]; } $js = new CopixJSWidget(); if ($onSelect) { $params['onSelect'] = $js->function_(null, 'tabId', $onSelect); } if ($onUnselect) { $params['onUnselect'] = $js->function_(null, 'tabId', $onUnselect); } $js->Copix->registerTabGroup($params); CopixHTMLHeader::addJSDOMReadyCode($js); return implode("\n", $toReturn); }
public function process($pParams, $pContent = null) { // Récupère les paramètres $zone = $this->requireParam('process'); $required = $this->getParam('required'); $ajax = $this->getParam('ajax', false); $id = $this->getParam('id'); $idClick = $this->getParam('idClick'); $text = $this->getParam('text', ''); $extra = $this->getParam('extra', ''); $handlers = array_filter($this->getParam(array('onDisplay', 'onHide', 'onComplete'), null, 'string')); $auto = $this->getParam('auto', false); $zoneParams = array_merge($this->getParam('zoneParams', array()), $this->getExtraParams()); // Valide les paramètres $this->validateParams(); // Supprime le préfixe "zoneParams_" des paramètres de la zone // Cela peut servir à passer des paramètres supplémentaires au niveau du tag // qui rentrent en conflit avec les noms des paramètres standard. foreach ($zoneParams as $key => $value) { if (preg_match('/^zoneParams_(.+)$/i', $key, $parts)) { unset($zoneParams[$key]); $zoneParams[$parts[1]] = $value; } } // Vérifie l'existence du module $fileInfo = new CopixModuleFileSelector($zone); if (!CopixModule::isEnabled($fileInfo->module) && $required === false) { return ""; } // Génère un identifiant si nécessaire $idProvided = $id !== null; if (!$idProvided) { $id = uniqid('copixzone'); } $toReturn = array(); // On a spécifié un texte : on l'ajoute comme trigger if ($text) { if ($idClick === null) { $idClick = $id . '_trigger'; } $toReturn[] = '<span id="' . $idClick . '">' . $text . '</span>'; } // Zone javascript si on a un clicker, de l'AJAX ou des gestionnaires d'événéments if ($idProvided || $ajax || count($handlers) || $idClick) { // Initialise le Javascript CopixHTMLHeader::addJSFramework(); CopixHTMLHeader::addJSLink(_resource('js/taglib/copixzone.js'), array('id' => 'taglib_copixzone_js')); $js = new CopixJSWidget(); // Options de la zone $options = array('zoneId' => $id); // Met en session AJAX les paramètres de la zone if ($ajax) { $options['instanceId'] = $instanceId = uniqid(); CopixAJAX::getSession()->set($instanceId, array($zone, $zoneParams)); } if ($auto) { $options['auto'] = true; } // Ajoute les handlers foreach ($handlers as $name => $code) { $options[$name] = $js->function_(null, "div,trigger", $code); } // Identifiant du trigger if ($idClick) { $options['triggerId'] = $idClick; } // Initialise la zone $js->Copix->registerZone($options); // Ajoute le code CopixHTMLHeader::addJSDOMReadyCode($js, "tag_copixzone_" . $id); } // Contenu de la zone if ($ajax) { $zoneContent = ''; $style = 'style="display:none;" '; } else { $zoneContent = CopixZone::process($zone, $zoneParams); $style = ''; } if ($idProvided || $style || $extra || $ajax || count($handlers) || $idClick) { $toReturn[] = '<div id="' . $id . '" ' . trim($style . $extra) . '>' . $zoneContent . '</div>'; } else { $toReturn[] = $zoneContent; } return join('', $toReturn); }
public function process($pParams, $pContent = null) { $id = $this->getParam('id', uniqid('modalbox')); $customContent = $this->getParam('customContent'); if (!$customContent) { $title = $this->getParam('title', ''); $icon = $this->getParam('icon'); } $openTriggers = $this->getParam('openTriggers'); $closeTriggers = $this->getParam('closeTriggers'); $onOpen = $this->getParam('onOpen'); $onClose = $this->getParam('onClose'); $this->validateParams(); CopixHTMLHeader::addJSFramework(); $options = array('id' => $id); if ($customContent) { $options['contentId'] = $customContent; } if ($openTriggers) { if (!is_array($openTriggers)) { $openTriggers = split(',', $openTriggers); } $options['openTriggers'] = $openTriggers; } if ($closeTriggers) { if (!is_array($closeTriggers)) { $closeTriggers = split(',', $closeTriggers); } $options['closeTriggers'] = $closeTriggers; } if ($customContent) { $boxContent = $pContent; } else { $boxContent = '<td width="100%">' . $pContent . '</td>'; if ($icon) { $titleColspan = 2; $boxContent = '<td style="text-align: center"><img src="' . _resource($icon) . '"/></td>' . $boxContent; } else { $titleColspan = 1; } $boxContent = '<tbody><tr>' . $boxContent . '</tr></tbody>'; if ($title) { $boxContent = '<thead><tr><th width="100%" colspan="' . $titleColspan . '">' . htmlEntities($title) . '</th></tr></thead>' . $boxContent; } $boxContent = '<table id="' . $id . '_content" class="CopixModalBox_Content CopixTable">' . $boxContent . '</table>'; } CopixHTMLHeader::addCSSLink(_resource('styles/taglib/js_modalbox.css'), array('id' => 'taglib_js_modalbox_css')); CopixHTMLHeader::addJSLink(_resource('js/taglib/js_modalbox.js'), array('id' => 'taglib_js_modalbox_js')); $js = new CopixJSWidget(); $js->Copix->ModalBox->register($options); $events = array(); if ($onOpen) { $events['open'] = $js->function_(null, null, $onOpen); } if ($onClose) { $events['close'] = $js->function_(null, null, $onClose); } if (count($events)) { $js->_($id)->addEvents($events); } CopixHTMLHeader::addJSDOMReadyCode($js); return '<div id="' . $id . '" style="display:none">' . $boxContent . '</div>'; }