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 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);
 }
 /**
  * Génère une expression de construction d'un objet.
  *
  * @param mixed ... Arguments du constructeur.
  * @return CopixJSFragment Un fragment de type expression.
  */
 public function new_()
 {
     $args = func_get_args();
     return $this->_widget->addExpression_('new ' . $this->_buildCall($this->toJSON(), $args));
 }
 public function test_A()
 {
     $js = new CopixJSWidget();
     $js->_A('5');
     $this->assertEquals('$A("5");', _toString($js));
 }
 public function process($pParams, $pContent = null)
 {
     if (is_null($pContent) && !isset($pParams['zone'])) {
         return;
     }
     _tag('mootools', array('plugin' => array('overlayfix')));
     $alt = $this->getParam('alt', '');
     $text = $this->getParam('text', '');
     $displayimg = $this->getParam('displayimg', true);
     $img = $this->getParam('img', _resource('img/tools/information.png'));
     $divclass = $this->getParam('divclass', 'popupInformation');
     $handler = $this->getParam('handler', 'onmouseover');
     $namespace = $this->getParam('namespace', 'default');
     $wHandle = $this->getParam('handlerWindow');
     $wHandle = $wHandle != null ? 'handle="' . $wHandle . '" ' : '';
     $title = $this->getParam('title');
     $id = uniqid('popupInformation');
     switch ($handler) {
         case 'window':
             $toReturn = '<a rel="' . $id . '" ' . $wHandle . ' id="div' . $id . '" class="divwindowpopup" href="javascript:void(null);"';
             if (isset($pParams['title'])) {
                 $toReturn .= ' title="' . $pParams['title'] . '"';
             }
             $toReturn .= '>';
             $close = '</a>';
             CopixHTMLHeader::addJsLink(_resource('js/taglib/popupinfo_window.js'));
             $js = new CopixJSWidget();
             CopixHTMLHeader::addJSDOMReadyCode($js->popupinfo_window(), 'popupinfo_window');
             break;
         case 'clickdelay':
             $toReturn = '<a rel="' . $id . '" id="div' . $id . '" class="divclickdelaypopup" href="javascript:void(null);">';
             $close = '</a>';
             CopixHTMLHeader::addJsLink(_resource('js/taglib/popupinfo_clickdelay.js'));
             CopixHTMLHeader::addJSDOMReadyCode('popupinfo_clickdelay ();', 'popupinfo_clickdelay');
             break;
         case 'onclick':
             $toReturn = '<a rel="' . $id . '" id="div' . $id . '" class="divclickpopup" href="javascript:void(null);">';
             $close = '</a>';
             CopixHTMLHeader::addJsLink(_resource('js/taglib/popupinfo_click.js'));
             CopixHTMLHeader::addJSDOMReadyCode('popupinfo_click ();', 'popupinfo_click');
             break;
         default:
             //prend également en charge onmouseover qui est le handler par défaut.
             $toReturn = '<div rel="' . $id . '" id="div' . $id . '" class="divpopup" style="display:inline;">';
             $close = '</div>';
             CopixHTMLHeader::addJsLink(_resource('js/taglib/popupinfo.js'));
             CopixHTMLHeader::addJSDOMReadyCode('popupinfo ();', 'popupinfo');
             break;
     }
     $toReturn .= $displayimg === true ? '<img src="' . $img . '" title="' . $alt . '" alt="' . $alt . '" />' : '';
     $toReturn .= strlen($text) ? $text : '';
     $toReturn .= isset($pParams['imgnext']) ? '<img src="' . $pParams['imgnext'] . '" />' : '';
     $toReturn .= $close;
     $toReturn .= '<div class="' . $divclass . '" id="' . $id . '" style="display:none;" rel=' . $namespace . ' >';
     if ($title !== null) {
         $toReturn .= '<div class="' . $divclass . 'Title">' . $title . '</div>';
     }
     if (isset($pParams['zone'])) {
         $zone = $pParams['zone'];
         unset($pParams['zone']);
         $toReturn .= _tag('copixzone', array_merge($this->getExtraParams(), array('onComplete' => '$(\'div' . $id . '\').fireEvent(\'sync\');', 'process' => $zone, 'ajax' => true, 'id' => 'zone_' . $id)));
     } else {
         $toReturn .= $pContent;
     }
     $toReturn .= '</div>';
     return $toReturn;
 }
 /**
  * Input:    name     = (required  name of the select box
  *           id       = (optional) id of SELECT element.
  *           values   = (optional) values to display the values captions will be
  *                        html_escaped, not the ids
  *           selected = (optional) id of the selected element
  *           assign   = (optional) name of the template variable we'll assign
  *                      the output to instead of displaying it directly
  *           emptyValues = id / value for the empty selection
  *           emptyShow   = [true] / false - wether to show or not the "emptyString"
  *           objectMap   = (optional) if given idProperty;captionProperty
  *           extra = (optional) if given, will be added directly in the select tag
  */
 public function process($pParams, $pContent = null)
 {
     extract($pParams);
     //input check
     if (empty($name)) {
         throw new CopixTemplateTagException("[plugin copixselect] parameter 'name' cannot be empty");
     }
     if (!empty($objectMap)) {
         $tab = explode(';', $objectMap);
         if (count($tab) != 2) {
             throw new CopixTemplateTagException("[plugin copixselect] parameter 'objectMap' must looks like idProp;captionProp");
         }
         $idProp = $tab[0];
         $captionProp = $tab[1];
         $shortCaptionProp = $captionProp;
         if (isset($tab[2])) {
             $shortCaptionProp = $tab[2];
         }
     }
     if (empty($extra)) {
         $extra = '';
     }
     if (empty($id)) {
         $id = $name;
     }
     if (empty($values)) {
         $values = array();
     }
     if (!is_array($values) && !$values instanceof Iterator) {
         $values = (array) $values;
     }
     if (empty($zIndex)) {
         $zIndex = '1000';
     }
     if (empty($heightDiv)) {
         $heightDiv = 'auto';
     } else {
         $heightDiv = intval($heightDiv) . 'px';
     }
     if (empty($widthDiv)) {
         $widthDiv = 'auto';
     } else {
         $widthDiv = intval($widthDiv) . 'px';
     }
     if (empty($width)) {
         $width = 'auto';
     } else {
         $width = intval($width) . 'px';
     }
     if (!isset($img)) {
         $img = 'img/tools/multiple.gif';
     }
     if (!isset($selected)) {
         $selected = '';
     }
     if (!isset($selectedIsIdentical)) {
         $selectedIsIdentical = false;
     }
     if (!isset($class)) {
         $class = 'copixselect';
     }
     $js = new CopixJSWidget();
     $toReturn = "\n        <span id='clicker_{$id}'>\n            <input id='caption{$id}' name='caption{$name}' type='text' readonly='readonly' class='{$class}' style='width:{$width};cursor:default;text-align:left;padding-left:3px;height:13px;' value ='' /><img src=" . CopixUrl::getResource('img/tools/multiple.gif') . " align='absbottom' vspace='1' alt='' />\n            <input id='{$id}' name='{$name}' type='hidden' class='{$class}' value ='{$selected}' />\n        </span>\n        <div class='{$class}' style='position:absolute;z-index:{$zIndex};display:none;width:{$widthDiv};height:{$heightDiv}' id='div{$id}'>\n            <table class='{$class}' style='width:{$widthDiv};'>";
     //each of the values.s
     $arValues = array();
     $toReturnValue = '';
     $event = "onmouseover = \"\$(this).setStyle('cursor','pointer');\$(this).setStyle ('background-color','#AAAAAA');\" onmouseout = \"\$(this).setStyle('background-color','white');\" onclick =\" \$('{$id}').value = \$(this).getProperty('rel');\$('caption{$id}').value = \$(this).innerHTML;\$('caption{$id}').fireEvent ('mouseleavezone');\" ";
     if (empty($objectMap)) {
         $arValues = $values;
         $compteur = 0;
         foreach ($values as $key => $caption) {
             if ($selectedIsIdentical && $selected === $key || !$selectedIsIdentical && $selected == $key) {
                 $js->_("caption" . $id)->value = $caption;
             }
             $toReturn .= "<tr>\n                                <td class='{$id}' rel='{$key}' " . $event . " >{$values}</td>\n                            </tr>";
         }
     } else {
         //if given an object mapping request.
         $compteur = 0;
         foreach ($values as $object) {
             if ($selectedIsIdentical && $selected === $object->{$idProp} || !$selectedIsIdentical && $selected == $object->{$idProp}) {
                 $js->_("caption" . $id)->value = $object->{$shortCaptionProp};
             }
             $arValues[$object->{$idProp}] = $object->{$captionProp};
             $toReturn .= "<tr>\n                                <td class='{$id}' rel='" . $object->{$idProp} . "' " . $event . " >" . $arValues[$object->{$idProp}] . "</td>\n                            </tr>";
         }
     }
     $toReturn .= "</table>\n        </div>";
     _tag('mootools', array('plugin' => array('zone', 'overlayfix')));
     CopixHTMLHeader::addCSSLink(_resource('styles/taglib/copixselect.css'), array('id' => 'taglib_copix_select_css'));
     CopixHTMLHeader::addJSLink(_resource('js/taglib/copixselect.js'));
     $js->selectoverload($id);
     CopixHTMLHeader::addJSDOMReadyCode($js);
     return $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>';
 }