public function process($pParams, $pContent = null) { if (is_array($pParams)) { return _copix_utf8_htmlentities(isset($pParams['value']) ? $pParams['value'] : ''); } return _copix_utf8_htmlentities($pParams); }
/** * Construction du code HTML * On utilise également les modifications d'en tête HTML */ public function process($pParams, $pContent = null) { $toReturn = ''; extract($pParams); //input check if (empty($name)) { throw new CopixTemplateTagException("[plugin checkbox] parameter 'name' cannot be empty"); } if (empty($values)) { $values = array(); } if (!is_array($values) && !$values instanceof Iterator) { $values = (array) $values; } if (empty($id)) { $id = $name; } if (empty($selected)) { $selected = null; } if (empty($encoding)) { $encoding = null; } if (!empty($objectMap)) { $tab = explode(';', $objectMap); if (count($tab) != 2) { throw new CopixTemplateTagException("[plugin checkbox] parameter 'objectMap' must looks like idProp;captionProp"); } $idProp = $tab[0]; $captionProp = $tab[1]; } if (empty($extra)) { $extra = ''; } if (empty($separator)) { $separator = ''; } //each of the values. if (empty($objectMap)) { foreach ($values as $key => $caption) { $selectedString = array_key_exists('selected', $pParams) && in_array($key, is_array($selected) ? $selected : array($selected)) ? ' checked="checked" ' : ''; $classString = !empty($class) ? ' class="' . $class . '"' : ''; $checkid = $id . '_' . $key; $toReturn .= '<input' . $classString . ' id="' . $checkid . '" type="checkbox" name="' . $name . '[]" ' . $extra . ' value="' . $key . '"' . $selectedString . ' /><label id="' . $checkid . '_label" for="' . $checkid . '" >' . _copix_utf8_htmlentities($caption, $encoding) . '</label>' . $separator; } } else { //if given an object mapping request. foreach ($values as $key => $object) { $selectedString = array_key_exists('selected', $pParams) && $object->{$idProp} == $selected ? ' checked="checked" ' : ''; $checkid = $id . '_' . $object->{$idProp}; $toReturn .= '<input' . $classString . ' id="' . $checkid . '" type="checkbox" name="' . $name . '[]" ' . $extra . ' value="' . $object->{$idProp} . '"' . $selectedString . ' /><label id="' . $checkid . '_label" for="' . $checkid . '" >' . _copix_utf8_htmlentities($object->{$captionProp}, $encoding) . '</label>' . $separator; } } 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); }
/** * Construction du message * @param mixed $pParams tableau de paramètre ou clef * @param mixed $pContent null (i18n n'est pas censé recevoir de contenu) * @return string message traduit */ public function process($pParams, $pContent = null) { if (!is_array($pParams)) { $pParams = array('key' => $pParams); } if (!isset($pParams['key'])) { throw new CopixTagException("[CopixTagCustomI18N] Missing key parameter"); return; } if (isset($pParams['lang'])) { $lang = $pParams['lang']; unset($pParams['lang']); } else { $lang = null; } $key = $pParams['key']; unset($pParams['key']); if (isset($pParams['pNb'])) { switch ($pParams['pNb']) { case 0: $key .= '_0'; break; case 1: $key .= '_1'; break; default: $key .= '_N'; break; } } if (isset($pParams['noEscape'])) { $noEscape = $pParams['noEscape']; unset($pParams['noEscape']); } if (count($pParams) == 0) { $pParams = null; } $message = CopixCustomI18N::get($key, $pParams, $lang); if (!isset($noEscape)) { return _copix_utf8_htmlentities($message); } return $message; }
/** * 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 select] parameter 'name' cannot be empty"); } if (!empty($objectMap)) { $tab = explode(';', $objectMap); if (count($tab) != 2) { throw new CopixTemplateTagException("[plugin select] parameter 'objectMap' must looks like idProp;captionProp"); } $idProp = $tab[0]; $captionProp = $tab[1]; } if (empty($emptyValues)) { $emptyValues = array('' => '-----'); } elseif (!is_array($emptyValues)) { $emptyValues = array('' => $emptyValues); } if (empty($extra)) { $extra = ''; } if (empty($id)) { $id = $name; } if (empty($encoding)) { $encoding = null; } if (empty($values)) { $values = array(); } if (!is_array($values) && !$values instanceof Iterator) { $values = (array) $values; } elseif ($values instanceof Iterator) { $values = iterator_to_array($values); } //proceed $toReturn = '<select name="' . $name . '" id="' . $id . '" ' . $extra . '>'; if (!isset($emptyShow) || $emptyShow == true) { //the "empty" element. If no key is the selected value, then its the one. $selectedString = isset($selected) && in_array($selected, array_keys($values)) ? '' : ' selected="selected" '; list($keyEmpty, $valueEmpty) = each($emptyValues); $toReturn .= '<option value="' . $keyEmpty . '"' . $selectedString . '>' . $valueEmpty . '</option>'; } //each of the values. if (empty($objectMap)) { foreach ($values as $key => $caption) { $selectedString = !empty($selected) && $key == $selected ? ' selected="selected" ' : ''; $toReturn .= '<option value="' . $key . '"' . $selectedString . '>' . _copix_utf8_htmlentities($caption, $encoding) . '</option>'; } } else { //if given an object mapping request. foreach ($values as $object) { $selectedString = !empty($selected) && $object->{$idProp} == $selected ? ' selected="selected" ' : ''; $toReturn .= '<option value="' . $object->{$idProp} . '"' . $selectedString . '>' . _copix_utf8_htmlentities($object->{$captionProp}, $encoding) . '</option>'; } } $toReturn .= '</select>'; return $toReturn; }
public function processGetMultipleSelectContent() { $currentId = null; $classString = CopixSession::get(CopixRequest::get('class')); $arClass = explode('::', $classString); $class = _ioClass($arClass[0]); $values = $class->{$arClass}[1](); $objectMap = CopixRequest::get('objectMap'); if (!empty($objectMap)) { $tab = explode(';', $objectMap); if (count($tab) != 2) { throw new CopixTemplateTagException("[plugin select] parameter 'objectMap' must looks like idProp;captionProp"); } $idProp = $tab[0]; $captionProp = $tab[1]; } $id = CopixRequest::get('idselect'); $name = CopixRequest::get('nameselect'); $toReturn = ''; $compteur = 0; if (empty($objectMap)) { foreach ((array) $values as $key => $caption) { $currentId = uniqid(); $compteur++; $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $toReturn .= '<div style="width:100%;background-color:' . $color . '"><input type="checkbox" class="check_' . $id . '" id="' . $currentId . '" value="' . $key . '" /><label id="label_' . $currentId . '" for="' . $currentId . '">' . _copix_utf8_htmlentities($caption) . '</label></div>'; } } else { //if given an object mapping request. foreach ((array) $values as $object) { $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $toReturn .= '<div style="width:100%;background-color:' . $color . '"><input type="checkbox" id="' . $currentId . '" class="check_' . $id . '" value="' . $object->{$idProp} . '" /><label id="label_' . $currentId . '" for="' . $currentId . '">' . _copix_utf8_htmlentities($object->{$captionProp}) . '</label></div>'; } } //CopixSession::set(CopixRequest::get('class'),null); CopixHTMLHeader::addJsCode("\n window.addEvent('domready', function () {\n var input = \$('{$id}');\n \$\$('.check_{$id}').each (function (el) {\n el.addEvent ('change', function () {\n var value = '';\n \$('hidden_{$id}').setHTML('');\n \$\$('.check_{$id}').each ( function (el) {\n if (el.checked) {\n if (value!='') {\n value += ',';\n }\n value += \$('label_'+el.getProperty('id')).innerHTML;\n \$('hidden_{$id}').setHTML (\$('hidden_{$id}').innerHTML+'<input type=\"hidden\" name=\"" . $name . "[]\" value=\"'+el.value+'\" />');\n }\n });\n input.value = value;\n });\n });\n });\n "); return _arDirectPPO(new CopixPPO(array('MAIN' => $toReturn)), 'generictools|blank.tpl'); }
/** * Construction du code HTML * On utilise également les modifications d'en tête HTML */ public function process($pParams, $pContent = null) { extract($pParams); if (empty($name)) { throw new CopixTemplateTagException('[calendar] missing name parameter'); } if (empty($image)) { $image = '"' . _resource("img/tools/calendar.png") . '"'; } else { $image = '"' . $image . '"'; } if (empty($extra)) { $extra = ''; } if (empty($size)) { $size = 8; } if (!isset($mask)) { $mask = true; } _tag('mootools', array('plugin' => array('datepicker'))); if ($mask) { _tag('mootools', array('plugin' => array('imask'))); CopixHTMLHeader::addJsCode("\n window.addEvent('domready', function () {\n new iMask({\n onFocus: function(obj) {\n },\n\n onBlur: function(obj) {\n },\n\n onValid: function(event, obj) {\n },\n\n onInvalid: function(event, obj) {\n if(!event.shift) {\n }\n }\n });\n });\n ", 'calendarmask'); } if (empty($lang)) { $lang = CopixI18N::getLang(); } if (empty($format)) { $format = str_replace(array('d', 'm', 'Y'), array('dd', 'mm', 'yyyy'), CopixI18N::getDateFormat('/')); } else { $format = strtolower($format); } $maskFormat = str_replace(array('d', 'm', 'y'), array('9', '9', '9'), $format); if (!empty($yyyymmdd)) { $value = date(str_replace(array('dd', 'mm', 'yyyy'), array('d', 'm', 'Y'), $format), CopixDateTime::yyyymmddToTimestamp($yyyymmdd)); } if (!empty($timestamp)) { $value = date(str_replace(array('dd', 'mm', 'yyyy'), array('d', 'm', 'Y'), $format), $timestamp); } if (empty($sizeday)) { $sizeday = 3; } if (!isset($beforeyear)) { $beforeyear = 10; } if (!isset($afteryear)) { $afteryear = 10; } if (!isset($duration)) { $duration = 500; } if (!isset($closebuttonsrc)) { $closebuttonsrc = null; } else { $closebuttonsrc = _resource($closebuttonsrc); } if (!isset($draggable)) { $draggable = true; } $draggable = $draggable ? 'true' : 'false'; if (!isset($title)) { $title = null; } if (empty($value)) { if ($mask) { $value = str_replace('9', '_', $maskFormat); } else { $value = null; } } $strMask = ''; if ($mask) { $strMask = 'style="text-align:center" class="iMask" alt="{ type:\'fixed\', mask:\'' . $maskFormat . '\', stripMask: false }"'; } $out = '<input type="text" id="' . $name . '" name="' . $name . '" value="' . _copix_utf8_htmlentities($value) . '" ' . $extra . ' size="' . $size . '" '; //name of the input. if (!empty($tabindex)) { $out .= ' tabindex="' . $tabindex . '" '; } $out .= $strMask . ' />' . "\n\r"; $out .= '<script type="text/javascript">' . "\n\r"; $out .= "\$('" . $name . "').makeDatePicker({draggable:{$draggable}, title: '" . str_replace("'", "\\'", $title) . "', closebuttonsrc: '" . $closebuttonsrc . "', value: '" . $value . "', format: '" . $format . "', language: '" . $lang . "', sizeday:" . $sizeday . ", beforeyear:" . $beforeyear . ", afteryear:" . $afteryear . ", duration:" . $duration . ", imageCalendar:" . $image; //class du calendrier. if (!empty($classe)) { $out .= ', classe:"' . $classe . '"'; } $out .= "});" . "\n\r"; return $out .= '</script>'; }
/** * 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 multipleselect] parameter 'name' cannot be empty"); } if (!empty($objectMap)) { $tab = explode(';', $objectMap); if (count($tab) != 2) { throw new CopixTemplateTagException("[plugin multipleselect] parameter 'objectMap' must looks like idProp;captionProp"); } $idProp = $tab[0]; $captionProp = $tab[1]; } 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($height)) { $height = 'auto'; } else { $height = intval($height) . 'px'; } if (empty($width)) { $width = 'auto'; } else { $width = intval($width) . 'px'; } if (!isset($img)) { $img = 'img/tools/multiple.gif'; } //each of the values. $idDiv = 'divdata_' . $id; $arValues = array(); $toReturnValue = ''; if (empty($objectMap)) { $arValues = $values; $compteur = 0; foreach ($values as $key => $caption) { $selectedString = isset($selected) && in_array($key, is_array($selected) ? $selected : array($selected), true) ? ' checked="checked" ' : ''; $currentId = uniqid('ch'); $compteur++; $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $toReturnValue .= '<div class="multipleselect_checker_' . $id . '" rel="' . $id . '" style="width:auto;background-color:' . $color . ';color:black"><input type="checkbox" class="multipleselect_check_' . $id . '" rel="' . $id . '" id="' . $currentId . '" value="' . $key . '"' . $selectedString . ' /><label id="label_' . $currentId . '" for="' . $currentId . '" style="color:black">' . _copix_utf8_htmlentities($caption) . '</label><br /></div>'; } } else { //if given an object mapping request. $compteur = 0; foreach ($values as $object) { $arValues[$object->{$idProp}] = $object->{$captionProp}; $currentId = uniqid('check'); $compteur++; $color = $compteur % 2 == 0 ? '#cccccc' : '#ffffff'; $selectedString = array_key_exists('selected', $pParams) && in_array($object->{$idProp}, is_array($selected) ? $selected : array($selected)) ? ' checked="checked" ' : ''; $toReturnValue .= '<div class="multipleselect_checker_' . $id . '" rel="' . $id . '" style="width:auto;background-color:' . $color . ';color:black"><input type="checkbox" class="multipleselect_check_' . $id . '" rel="' . $id . '" id="' . $currentId . '" value="' . $object->{$idProp} . '"' . $selectedString . ' /><label id="label_' . $currentId . '" for="' . $currentId . '" style="color:black">' . _copix_utf8_htmlentities($object->{$captionProp}) . '</label><br /></div>'; } } _tag('mootools', array('plugin' => array('zone', 'overlayfix'))); CopixHTMLHeader::addJSLink(_resource('js/taglib/multipleselect.js')); CopixHTMLHeader::addJsDomReadyCode('multipleselect ();', 'multipleselect'); //proceed $value = ''; $hidden = ''; if (isset($selected) && is_array($selected)) { foreach ($selected as $select) { if ($value != null) { $value .= ','; } $value .= isset($arValues[$select]) ? $arValues[$select] : ''; $hidden .= '<input type="hidden" name="' . $name . '[]" value="' . $select . '" />'; } } elseif (isset($selected)) { $value .= isset($arValues[$select]) ? $arValues[$selected] : ''; } //Div caché pour avoir des paramètres disponible dans le DOM $toReturn = '<div style="display:none;" class="multipleselect_id" rel="' . $id . '"></div><div style="display:none;" id="name_' . $id . '" rel="' . $name . '"></div><div style="display:none;" id="height_' . $id . '" rel="' . $height . '"></div>'; //Commence par un car bug d'alignement dans certains nav $noreset = false; if (isset($pParams['noreset']) && $pParams['noreset']) { $noreset = true; } $toReturn .= '<span id="div_' . $id . '" style="width:' . $width . ';vertical-align:center;" ><input type="text" id="input_' . $id . '" name="input_' . $name . '" value="' . $value . '" ' . $extra . ' style="width:' . $width . '" readonly="readonly" noreset="' . $noreset . '"/><img src="' . CopixUrl::getResource($img) . '" align="absbottom" vspace="1" alt="" /></span>'; //Div contenant la liste $toReturn .= '<div id="' . $idDiv . '" style="margin:auto;visibility:hidden;top:1px;left:1px;position:absolute;z-index:9999;background-color:white;border:1px solid #bbbbbb">' . $toReturnValue . '</div>'; //Div contenant les champs hidden permettant de passer les valeurs sélectionner $toReturn .= '<div id="hidden_' . $id . '" style="visibility:hidden;position:absolute">' . $hidden . '</div>'; return $toReturn; }
/** * @param PHPUnit_Framework_TestFailure $defect * @access protected */ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) { $this->write('<tr><td>*</td><td>'); $e = $defect->thrownException(); if ($e instanceof PHPUnit_Framework_SelfDescribing) { $this->write(_copix_utf8_htmlentities($e->toString())); if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { $comparisonFailure = $e->getComparisonFailure(); if ($comparisonFailure !== NULL && $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) { $this->write(_copix_utf8_htmlentities($comparisonFailure->toString())); } } } elseif ($e instanceof PHPUnit_Framework_Error) { $this->write(_copix_utf8_htmlentities($e->getMessage())); } else { $this->write(_copix_utf8_htmlentities(get_class($e) . ': ' . $e->getMessage())); } $this->write(PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE)); $this->write('</td></tr>'); }