public function process($pParams, $content) { extract($pParams); if (!isset($name)) { throw new CopixTemplateTagException("Manque nom"); } $toReturn = "<div id=\"wiki_toolbar\" style=\"clear:both\">\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('**','**','" . _i18n("wiki|wiki.bold") . "');\" title=\"" . _i18n("wiki|wiki.bold") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/bold.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('//','//','" . _i18n("wiki|wiki.italic") . "');\" title=\"" . _i18n("wiki|wiki.italic") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/italic.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('__','__','" . _i18n("wiki|wiki.underline") . "');\" title=\"" . _i18n("wiki|wiki.underline") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/underline.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle(' *','','" . _i18n("wiki|wiki.listitem") . "');\" title=\"" . _i18n("wiki|wiki.listitem") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/list.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('<del>','</del>','" . _i18n("wiki|wiki.strike") . "');\" title=\"" . _i18n("wiki|wiki.strike") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/strike.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('\n----\n','','');\" title=\"" . _i18n("wiki|wiki.hr") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/hr.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('\\'\\'','\\'\\'','" . _i18n("wiki|wiki.code") . "');\" title=\"" . _i18n("wiki|wiki.code") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/code.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(1);\" title=\"" . _i18n("wiki|wiki.header", 1) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h1.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(2);\" title=\"" . _i18n("wiki|wiki.header", 2) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h2.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(3);\" title=\"" . _i18n("wiki|wiki.header", 3) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h3.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(4);\" title=\"" . _i18n("wiki|wiki.header", 4) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h4.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(5);\" title=\"" . _i18n("wiki|wiki.header", 5) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h5.png') . "\" /></a>\n"; $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:sendForPreview();\" title=\"" . _i18n("wiki|wiki.show.preview") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/preview.png') . "\" /></a>\n"; $toReturn .= "</div>"; $toReturn .= "\n<textarea class=\"noresizable\" id=\"wiki_area_content\" name=\"{$name}\"\n cols=\"100\" rows=\"30\">{$content}\n</textarea>\n<div id=\"aj_wiki_prev\" style=\"display: none\">\n</div>\n\n "; $urlofrenderer = _url('generictools|ajax|getwikipreview'); CopixHTMLHeader::addJsCode("\nvar onPreviewMode = false;\nfunction sendForPreview()\n{\n if(!onPreviewMode){\n var borders=\$('wiki_area_content').getStyle('border');\n var width=\$('wiki_area_content').getStyle('width');\n \$('aj_wiki_prev').setStyles({\n 'border': borders,\n 'width' : width\n });\n var aj = new Ajax('" . $urlofrenderer . "',{\n method : 'post',\n update :'aj_wiki_prev',\n data : 'torender='+\$('wiki_area_content').value\n }).request();\n onPreviewMode = true;\n \$('wiki_area_content').setStyle('display','none')\n \$('aj_wiki_prev').setStyle('display','block')\n }else{\n \$('wiki_area_content').setStyle('display','block');\n \$('aj_wiki_prev').setStyle('display','none');\n onPreviewMode = false;\n }\n}\n\nfunction addHeader(n)\n{\n var h=\"\";\n if(n==1) h=\"======\";\n if(n==2) h=\"=====\";\n if(n==3) h=\"====\";\n if(n==4) h=\"===\";\n if(n==5) h=\"==\";\n\n var editor = document.getElementById('wiki_area_content');\n fontStyle(h+\" \",\" \"+h,\"Header\"+n);\n}\n\n/**\n * apply tagOpen/tagClose to selection in textarea, use sampleText instead\n * of selection if there is none copied and adapted from phpBB\n *\n * @author phpBB development team\n * @author MediaWiki development team\n * @author Andreas Gohr <*****@*****.**>\n * @author Jim Raynor <*****@*****.**>\n */\nfunction fontStyle(tagOpen, tagClose, sampleText)\n{\n var txtarea = document.getElementById('wiki_area_content');\n // IE\n if(document.selection && !is_gecko) {\n var theSelection = document.selection.createRange().text;\n var replaced = true;\n if(!theSelection){\n replaced = false;\n theSelection=sampleText;\n }\n txtarea.focus();\n\n // This has change\n text = theSelection;\n if(theSelection.charAt(theSelection.length - 1) == \" \"){// exclude ending space char, if any\n theSelection = theSelection.substring(0, theSelection.length - 1);\n r = document.selection.createRange();\n r.text = tagOpen + theSelection + tagClose + \" \";\n } else {\n r = document.selection.createRange();\n r.text = tagOpen + theSelection + tagClose;\n }\n if(!replaced){\n r.moveStart('character',-text.length-tagClose.length);\n r.moveEnd('character',-tagClose.length);\n }\n r.select();\n // Mozilla\n } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {\n var replaced = false;\n var startPos = txtarea.selectionStart;\n var endPos = txtarea.selectionEnd;\n if(endPos - startPos) replaced = true;\n var scrollTop=txtarea.scrollTop;\n var myText = (txtarea.value).substring(startPos, endPos);\n if(!myText) { myText=sampleText;}\n if(myText.charAt(myText.length - 1) == \" \"){ // exclude ending space char, if any\n subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + \" \";\n } else {\n subst = tagOpen + myText + tagClose;\n }\n txtarea.value = txtarea.value.substring(0, startPos) + subst +\n txtarea.value.substring(endPos, txtarea.value.length);\n txtarea.focus();\n\n //set new selection\n //modified by Patrice Ferlet\n // - selection wasn't good for selected text replaced\n txtarea.selectionStart=startPos+tagOpen.length;\n txtarea.selectionEnd=startPos+tagOpen.length+myText.length;\n\n txtarea.scrollTop=scrollTop;\n // All others\n } else {\n var copy_alertText=alertText;\n var re1=new RegExp(\"\\\$1\",\"g\");\n var re2=new RegExp(\"\\\$2\",\"g\");\n copy_alertText=copy_alertText.replace(re1,sampleText);\n copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);\n var text;\n if (sampleText) {\n text=prompt(copy_alertText);\n } else {\n text=\"\";\n }\n if(!text) { text=sampleText;}\n text=tagOpen+text+tagClose;\n //append to the end\n txtarea.value += text;\n\n // in Safari this causes scrolling\n if(!is_safari) {\n txtarea.focus();\n }\n\n }\n // reposition cursor if possible\n if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();\n}\n "); return $toReturn; }
public function process($pParams, $pContent = null) { $toReturn = ' ' . $pContent . '<br /><br />'; $toReturn .= ' <a href="' . CopixUrl::get($pParams['yes']) . '">' . _i18n('copix:common.buttons.yes') . '</a>'; $toReturn .= ' <a href="' . CopixUrl::get($pParams['no']) . '">' . _i18n('copix:common.buttons.no') . '</a>'; _tag('mootools'); CopixHTMLHeader::addJsCode("\n window.addEvent('domready', function () {\n var elem = new Element('div');\n elem.setStyles({'z-index':99999,'background-color':'white','border':'1px solid black','width':'200px','height':'100px','top': window.getScrollTop().toInt()+window.getHeight ().toInt()/2-100+'px','left':window.getScrollLeft().toInt()+window.getWidth ().toInt()/2-100+'px','position':'absolute','text-align':'center'});\n elem.setHTML ('{$toReturn}');\n elem.injectInside(document.body);\n\n });\n\n "); return null; }
public function process($pParams, $pContent = null) { // paramètre id if (!isset($pParams['id'])) { throw new CopixTemplateTagException(_i18n('copix:taglib.showdiv.missingIdParameter')); } // paramètre show if (!isset($pParams['show'])) { $pParams['show'] = true; } else { $pParams['show'] = $pParams['show'] == 'true' || $pParams['show'] == 1; } // paramètre captioni18n fourni, qui vaut dans le cas up et le cas down if (isset($pParams['captioni18n'])) { $pParams['captionup'] = _i18n($pParams['captioni18n']); $pParams['captiondown'] = $pParams['captionup']; // si on a un paramètre caption qui s'occupe de tout les cas } elseif (isset($pParams['caption'])) { $pParams['captionup'] = $pParams['caption']; $pParams['captiondown'] = $pParams['caption']; // paramètres captionupi18n et captiondowni18n, qui valent chacun pour leur cas } elseif (isset($pParams['captionupi18n']) && isset($pParams['captiondowni18n'])) { $pParams['captionup'] = _i18n($pParams['captionupi18n']); $pParams['captiondown'] = _i18n($pParams['captiondowni18n']); // pas de paramètre captionup ou captiondown } elseif (!isset($pParams['captionup']) || !isset($pParams['captiondown'])) { $pParams['captionup'] = null; $pParams['captiondown'] = null; } // paramètre showicon $pParams['showicon'] = !isset($pParams['showicon']) || isset($pParams['showicon']) && ($pParams['showicon'] == 'true' || $pParams['showicon'] == 1); // paramètre iconup $pParams['iconup'] = isset($pParams['iconup']) ? _resource($pParams['iconup']) : _resource('img/tools/way_up.png'); // paramètre icondown $pParams['icondown'] = isset($pParams['icondown']) ? _resource($pParams['icondown']) : _resource('img/tools/way_down.png'); // code javascript pour afficher / cacher un div CopixHTMLHeader::addJsCode('if (!window.smarty_show_div_infos) { smarty_show_div_infos = new Array (); } function smarty_show_div (id, show) { if (show) { img = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'img_up\']) ? smarty_show_div_infos[id][\'img_up\'] : null; style = \'\'; caption = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'caption_up\']) ? smarty_show_div_infos[id][\'caption_up\'] : null; } else { img = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'img_down\']) ? smarty_show_div_infos[id][\'img_down\'] : null; style = \'none\'; caption = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'caption_down\']) ? smarty_show_div_infos[id][\'caption_down\'] : null; } document.getElementById (id).style.display = style; if (document.getElementById (\'img_\' + id) != undefined) { document.getElementById (\'img_\' + id).src = img; if (caption != null) { document.getElementById (\'caption_\' + id).innerHTML = caption; } } } function smarty_invert_show (id) { smarty_show_div (id, (document.getElementById (id).style.display != \'\')); }', 'smarty_show_div'); // code JS pour créer le tableau des infos de cet ID CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'] = new Array ();', 'smarty_show_div_' . $pParams['id']); // code JS pour les images if ($pParams['showicon'] && !is_null($pParams['iconup']) && !is_null($pParams['icondown'])) { CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'img_up\'] = \'' . $pParams['iconup'] . '\';' . "\n" . 'smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'img_down\'] = \'' . $pParams['icondown'] . '\';', 'smarty_show_div_img_' . $pParams['id']); } // code javascript pour les captions if (!is_null($pParams['captionup']) && !is_null($pParams['captiondown'])) { CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'caption_up\'] = \'' . str_replace("'", "\\'", $pParams['captionup']) . '\';' . "\n" . 'smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'caption_down\'] = \'' . str_replace("'", "\\'", $pParams['captiondown']) . '\';', 'smarty_show_div_captions_' . $pParams['id']); } // création du code HTML if ($pParams['showicon'] || !is_null($pParams['captionup']) && !is_null($pParams['captiondown'])) { if ($pParams['show']) { $imgSrc = $pParams['iconup']; $caption = $pParams['captionup']; } else { $imgSrc = $pParams['icondown']; $caption = $pParams['captiondown']; } $out = '<a href="javascript: smarty_invert_show (\'' . $pParams['id'] . '\');">'; // si on veut afficher un icon if ($pParams['showicon']) { $out .= '<img id="img_' . $pParams['id'] . '" src="' . $imgSrc . '" style="cursor:pointer" alt="showdiv" />'; } // si on veut afficher un caption if (!is_null($caption)) { $out .= ' <span id="caption_' . $pParams['id'] . '">' . $caption . "</span>"; } $out .= '</a>'; } else { $out = null; } return $out; }
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>'; }
public function beforeProcess() { CopixHTMLHeader::addJsCode("\nwindow.addEvent('domready',\n function () {\n var divlog = new Element('div');\n divlog.injectInside(document.body);\n divlog.setStyles({\n 'background-color':'white',\n 'width':'500px',\n 'height':'200px',\n 'overflow':'auto'\n });\n//\t\tdivlog.setOpacity('0.5');\n divlog.makeDraggable();\n\n var ajax = new Ajax('" . CopixUrl::get('generictools|ajax|getZone') . "',\n {\n method: 'post',\n update: divlog,\n evalScripts : true,\n data : {'zone':'admin|showlog','profil':'test'},\n onComplete: function () {\n }\n }).request()\n }\n);\n "); }