/** * Déclare la fonction getHTTPObject () dans l'en tête HTML. * @param mixed $pParams aucun paramètre attendu ici. */ public function process($pParams, $pContent = null) { static $called = false; if (!$called) { CopixHTMLHeader::addJSCode('function getHTTPObject() { var xmlhttp = false; /*@cc_on @if (@_jscript_version >= 5) try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != "undefined"){ try{ xmlhttp = new XMLHttpRequest(); }catch (e){ xmlhttp = false; } } return xmlhttp; }', 'getHTTPObject'); $called = true; } }
public function process($pParams) { // paramètres requis $requestedParameters = array('form', 'submit', 'divErrors', 'urlVerif', 'urlSubmit'); foreach ($requestedParameters as $param) { if (!isset($pParams[$param])) { throw new CopixTemplateTagException(_i18n('copix:copix.smarty.badTagParamValue', array('null', $param, 'ajax_submitform'))); } } // on a besoin de mootools _tag('mootools'); // code javascript $jsCode = ' window.addEvent(\'domready\', function(){ $(\'' . $pParams['submit'] . '\').addEvent(\'click\', function(e) { $(\'' . $pParams['submit'] . '\').disabled = true; $(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlVerif']) . '\'; new Event (e).stop (); $(\'' . $pParams['form'] . '\').send ({ update: $(\'formErrors\'), onComplete: function (response) { if (response == \'true\') { $(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlSubmit']) . '\'; $(\'' . $pParams['form'] . '\').submit (); } else { $(\'' . $pParams['submit'] . '\').disabled = false; } }, }); }); });'; CopixHTMLHeader::addJSCode($jsCode, 'ajax_submitform_' . $pParams['form']); }
function smarty_function_htmlarea($params, &$smarty) { static $_init = false; extract($params); //check the initialisation if (!$_init) { CopixHtmlHeader::addJsCode('_editor_url = "' . CopixUrl::get() . 'js/htmlarea/";'); //path of the library if (empty($path)) { $path = CopixUrl::get() . 'js/htmlarea/'; //default path under CopiX } CopixHTMLHeader::addJSLink($path . 'htmlarea.js'); CopixHTMLHeader::addJSLink($path . 'dialog.js'); if (empty($lang)) { $lang = CopixI18N::getLang(); } CopixHTMLHeader::addJSLink($path . 'lang/' . $lang . '.js'); CopixHTMLHeader::addCSSLink($path . 'htmlarea.css'); CopixHTMLHeader::addJSLink($path . 'popupwin.js'); CopixHTMLHeader::addJSCode(' HTMLArea.loadPlugin("TableOperations"); HTMLArea.loadPlugin("InsertAnchor"); HTMLArea.loadPlugin("TableToggleBorder"); HTMLArea.loadPlugin("AstonTools"); HTMLArea.loadPlugin("ContextMenu"); '); $_init = true; } if (empty($content)) { $content = ''; } //name of the textarea. if (empty($name)) { $smarty->trigger_error('htmlarea: missing name parameter'); } else { // CopixHTMLHeader::addOthers ($script); if (!$width) { $width = 500; } if (!$height) { $height = 500; } $out = '<textarea id="' . $name . '" name="' . $name . '" style="width: ' . $width . 'px; height:' . $height . 'px;" >' . $content . '</textarea>'; $out .= '<script type="text/javascript" defer="1"> var editor' . $name . ' = null; editor' . $name . ' = new HTMLArea("' . $name . '"); editor' . $name . '.registerPlugin("TableOperations"); editor' . $name . '.registerPlugin("TableToggleBorder"); editor' . $name . '.registerPlugin("InsertAnchor"); editor' . $name . '.registerPlugin("AstonTools"); editor' . $name . '.registerPlugin("ContextMenu"); editor' . $name . '.config.pageStyle = "@import url(\\"' . CopixUrl::get() . 'styles/styles_copix.css\\");"; editor' . $name . '.generate (); </script>'; } return $out; }
function smarty_function_calendar($params, &$smarty) { static $_init = false; extract($params); //check the initialisation if (!$_init) { //path of the library CopixHTMLHeader::addCSSLink(CopixUrl::get() . "js/dynCal/dynCalendar.css", array('media' => 'screen')); CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/browserSniffer.js"); CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/dynCalendar.js"); if (empty($lang)) { $lang = CopixI18N::getLang(); } CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/lang/" . $lang . ".js"); $_init = true; } //Calculating the jsCode (kind of silly trick to use a separator as a part of jsCode, but still quick) $jsCode = str_replace(array('d', 'm', 'Y'), array('day', 'month', 'year'), CopixI18N::getDateFormat(" + '/' + ")); CopixHTMLHeader::addJSCode("\n\r" . ' function calendarCallback' . $name . '(day, month, year) { var tmp; if (String(month).length == 1) { month = \'0\' + month; } if (String(day).length == 1) { day = \'0\' + day; } tmp = document.getElementById (\'' . $name . '\'); tmp.value = ' . $jsCode . '; } ' . "\n\r"); //name of the textarea. if (empty($name)) { $smarty->trigger_error('[smarty_calendar] missing name parameter'); } else { $out = '<input type="text" class="calendar" id="' . $name . '" name="' . $name . '" value="' . $value . '">' . "\n\r"; $out .= '<script language="javascript" type="text/javascript">' . "\n\r"; $out .= '<!--' . "\n\r"; $out .= 'calendar_' . $name . ' = new dynCalendar(\'calendar_' . $name . '\', \'calendarCallback' . $name . '\', \'' . CopixUrl::get() . 'js/dynCal/images/\');' . "\n\r"; $out .= '//-->' . "\n\r"; $out .= '</script>' . "\n\r"; } return $out; }
function smarty_function_htmleditor($params, &$smarty) { static $_init = false; extract($params); //check the initialisation if (!$_init) { switch (strtolower(CopixConfig::get('htmleditor|type'))) { case 'htmlarea': CopixHtmlHeader::addJsCode('_editor_url = "' . CopixUrl::get() . 'js/htmlarea/";'); //path of the library if (empty($htmlPath)) { $htmlPath = CopixUrl::get() . 'js/htmlarea/'; //default path under CopiX } CopixHTMLHeader::addJSLink($htmlPath . 'htmlarea.js'); CopixHTMLHeader::addJSLink($htmlPath . 'dialog.js'); if (empty($lang)) { $lang = CopixI18N::getLang(); } CopixHTMLHeader::addJSLink($htmlPath . 'lang/' . $lang . '.js'); CopixHTMLHeader::addCSSLink($htmlPath . 'htmlarea.css'); CopixHTMLHeader::addJSLink($htmlPath . 'popupwin.js'); $jsCode = 'HTMLArea.loadPlugin("TableOperations"); HTMLArea.loadPlugin("InsertAnchor"); HTMLArea.loadPlugin("TableToggleBorder"); HTMLArea.loadPlugin("ContextMenu");'; if (CopixModule::isValid('pictures') && CopixModule::isValid('cms') && CopixModule::isValid('document')) { $jsCode = 'HTMLArea.loadPlugin("AstonTools");'; } CopixHTMLHeader::addJSCode($jsCode); break; case 'fckeditor': default: $path = COPIX_MODULE_PATH . 'htmleditor/' . COPIX_CLASSES_DIR; $htmlPath = CopixUrl::get() . 'js/FCKeditor/'; require_once $path . 'fckeditor.php'; break; } // CopixHTMLHeader::addJSLink ($path.'fckconfig.js'); // CopixHTMLHeader::addJSLink ($path.'fckeditor.js'); $_init = true; } if (empty($content)) { $content = ' '; } //name of the textarea. if (empty($name)) { $smarty->trigger_error('htmleditor: missing name parameter'); } else { if (!$width) { $width = CopixConfig::get('htmleditor|width'); //$width = '100%'; } if (!$height) { $height = CopixConfig::get('htmleditor|height'); //$height = '450px'; } switch (strtolower(CopixConfig::get('htmleditor|type'))) { case 'htmlarea': $out = '<textarea id="' . $name . '" name="' . $name . '" style="width: ' . $width . 'px; height:' . $height . 'px;" >' . $content . '</textarea>'; $out .= '<script type="text/javascript" defer="1"> var editor' . $name . ' = null; editor' . $name . ' = new HTMLArea("' . $name . '"); editor' . $name . '.registerPlugin("TableOperations"); editor' . $name . '.registerPlugin("TableToggleBorder"); editor' . $name . '.registerPlugin("InsertAnchor"); editor' . $name . '.registerPlugin("ContextMenu");'; if (CopixModule::isValid('pictures') && CopixModule::isValid('cms') && CopixModule::isValid('document')) { $out .= 'editor' . $name . '.registerPlugin("AstonTools");'; } $out .= 'editor' . $name . '.config.pageStyle = "@import url(\\"' . CopixUrl::get() . 'styles/styles_copix.css\\");"; editor' . $name . '.generate (); </script>'; break; case 'fckeditor': default: /* * ATTENTION les éléments de config viewPhototèque etc font doublon avec la sélection de la toolbarset, mais sont nécessaire à Copix * Par contre si on ne les load pas, on a une erreur de FCKeditor, il faut donc supprimer ce gestionnaire d'erreur sinon on se prend un alert javascript * le gestionnaire en question se trouve dans "FCKToolbarItems.GetItem" (chercher cette chaîne pour le trouver) et désactiver "alert( FCKLang.UnknownToolbarItem.replace( /%1/g, itemName ) ) ;" */ $oFCKeditor = new FCKeditor($name); $oFCKeditor->BasePath = $htmlPath; $oFCKeditor->Value = $content; $oFCKeditor->ToolbarSet = 'Copix'; $oFCKeditor->Width = $width; $oFCKeditor->Height = $height; $oFCKeditor->Config['viewPhototheque'] = CopixModule::isValid('pictures') ? 'true' : 'false'; $oFCKeditor->Config['viewCmsLink'] = CopixModule::isValid('cms') ? 'true' : 'false'; $oFCKeditor->Config['viewLinkPopup'] = CopixModule::isValid('cms') ? 'true' : 'false'; $oFCKeditor->Config['viewDocument'] = CopixModule::isValid('document') ? 'true' : 'false'; // Configuration de la feuille de style à utiliser. $oFCKeditor->Config['EditorAreaCSS'] = CopixUrl::get() . 'styles/styles_copix.css'; $out = $oFCKeditor->CreateHtml(); break; } } return $out; }
?> " /> <?php if ($ppo->valid) { ?> <input type="submit" id="record" name="btn" value="<?php _etag('i18n', 'install.database.save'); ?> " /> <?php } ?> </form> <a href="<?php echo CopixURL::get("admin||"); ?> "> <input type="button" value="<?php _eTag('i18n', "copix:common.buttons.back"); ?> " /></a> <?php _etag('copixtips', array('warning' => $ppo->importantTips, 'tips' => $ppo->tips, 'titlei18n' => 'install.tips.title')); ?> <?php _eTag('mootools'); $jsCode = "\n\nwindow.addEvent('domready', function () {\n \$\$('.bdd input,.bdd select').each(function (el) {\n el.addEvent('change',function () {\n \$('record').setStyle('display','none');\n });\n });\n});\n\n"; CopixHTMLHeader::addJSCode($jsCode);
public function beforeDisplay(&$display) { $jscode = array(); $logs = array(); foreach (CopixConfig::instance()->copixlog_getRegistered() as $profil) { $name = CopixConfig::instance()->copixlog_getProfile($profil); $name = $name['strategy']; if (strtoupper($name) == "FIREBUG") { $logs[] = CopixLog::getLog($profil); } } //merge last logs to new logs if (CopixSession::get('plugin|firebug|log') !== null) { $logs = array_merge(CopixSession::get('plugin|firebug|log'), $logs); CopixSession::set('plugin|firebug|log', null); } $logs = array_reverse($logs); foreach ($logs as $arlog) { foreach ($arlog as $log) { foreach (array('message', 'file', 'line', 'level', 'classname', 'functionname', 'type') as $var) { if (isset($log->{$var})) { ${$var} = $log->{$var}; unset($log->{$var}); } else { ${$var} = null; } } $log->date = CopixDateTime::yyyymmddhhiissToDateTime($log->date); $log->location = "{$file}:{$line}"; $log->function = ($classname ? "{$classname}::" : "") . $functionname; switch ($level) { case CopixLog::INFORMATION: $type = "info"; break; case CopixLog::WARNING: case CopixLog::NOTICE: $type = "warn"; break; case CopixLog::EXCEPTION: case CopixLog::ERROR: case CopixLog::FATAL_ERROR: $type = "error"; break; default: $type = "log"; } unset($log->level); $jscode[] = sprintf('_l(%s,%s,%s,%s);', CopixJSON::encode($type), CopixJSON::encode($message), CopixJSON::encode($log->location), CopixJSON::encode($log)); } } foreach (CopixConfig::instance()->copixlog_getRegistered() as $profil) { $name = CopixConfig::instance()->copixlog_getProfile($profil); $name = $name['strategy']; if (strtoupper($name) == "FIREBUG") { CopixLog::deleteProfile($profil); } } if (count($jscode) > 0) { $jscode[] = "if(window.console && console.firebug){var _l=function(t,m,l,e){console.group('[COPIX] - '+t+' - '+l);console[t](m);console.dir(e);console.groupEnd();}"; $jscode = array_reverse($jscode); $jscode[] = "}"; CopixHTMLHeader::addJSCode(implode("\n", $jscode)); } }
/** * Gestion de la fin du formulaire * * @return HTML */ public function end() { //Affichage des différents bouton a la fin du formulaire //$toReturn = $this->getButton ('edit').$this->getButton ('delete').$this->getButton ('submit'). $toReturn = '</form>'; //Gestion des messages d'erreurs non affichées dans le formulaire if (count($this->_errors) > 0) { $htmlError = ''; foreach ($this->_errors as $key => $error) { if (is_array($error)) { foreach ($error as $err) { $htmlError .= $key . ' : ' . $err . '<br />'; } } else { $htmlError .= $key . ' : ' . $error . '<br />'; } unset($this->_errors[$key]); } _tag('mootools'); CopixHTMLHeader::addJSCode("\n window.addEvent('domready', function () {\n \$('error_formpost_" . $this->_id . "').setHTML('" . stripslashes($htmlError) . "');\n });\n\n "); } return $toReturn; }
public function process($pParams) { if (!isset($pParams['zone'])) { new CopixTemplateTagException('zone'); } $sessionVar = uniqid(); $sessionZone = uniqid(); CopixSession::set($sessionZone, $pParams['zone']); unset($pParams['zone']); CopixSession::set($sessionVar, $pParams); if (!isset($pParams['alt'])) { $pParams['alt'] = ''; } if (!isset($pParams['imgtitle'])) { $pParams['imgtitle'] = ''; } if (!isset($pParams['text'])) { $pParams['text'] = ''; } if (!isset($pParams['displayimg'])) { $pParams['displayimg'] = true; } if (!isset($pParams['img'])) { $pParams['img'] = _resource('img/tools/information.png'); } if (!isset($pParams['divclass'])) { $pParams['divclass'] = 'popupInformation'; } if (!isset($pParams['handler'])) { $pParams['handler'] = 'onmouseover'; } $id = uniqid('popupInformation'); switch ($pParams['handler']) { case 'click': $toReturn = '<a rel="' . $id . '" id="div' . $id . '" href="javascript:void(null);">'; $close = '</a>'; 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>'; break; } $toReturn .= $pParams['displayimg'] === true ? '<img src="' . $pParams['img'] . '" title="' . $pParams['imgtitle'] . '" alt="' . $pParams['alt'] . '" />' : ''; $toReturn .= strlen($pParams['text']) ? $pParams['text'] : ''; $toReturn .= isset($pParams['imgnext']) ? '<img src="' . $pParams['imgnext'] . '" />' : ''; $toReturn .= $close; $width = 'auto'; if (isset($pParams['width'])) { $width = $pParams['width']; } $toReturn .= '<div class="' . $pParams['divclass'] . '" id="' . $id . '" style="width:' . $width . ';display:none;" >'; //$toReturn .= $pContent; $toReturn .= '</div>'; $jsCode = "\nvar ajax_zone = {\n getZone : function (pZone,pSession,pDiv) {\n new Ajax('" . _url('generictools|ajax|getZone') . "', {\n method: 'post',\n update: pDiv,\n evalScripts : true,\n data: {'zone':pZone,'sessionvar':pSession}\n }).request();\n }\n};\n"; CopixHTMLHeader::addJSCode($jsCode, 'ajaxpopup'); switch ($pParams['handler']) { case 'click': $jsCode = "\n window.addEvent('domready',function () {\n var el = \$('div{$id}');\n var rel = \$(el.getProperty('rel'));\n var save{$id} = {\n click : false,\n flag : false,\n hide : function () {\n if (!save{$id}.flag) {\n rel.fireEvent('hide');\n }\n }\n };\n el.addEvent ('click', function (e) {\n save{$id}.click = true;\n rel.fireEvent('display');\n });\n el.addEvent('mouseleave', function () {\n if (save{$id}.click) {\n save{$id}.hide.delay(1000);\n }\n });\n rel.addEvent ('mouseleave', function () {\n rel.fireEvent('hide');\n });\n rel.addEvent ('mouseenter', function () {\n save{$id}.flag = true;\n });\n rel.addEvent ('display', function (e) {\n if (rel.getStyle('display') == 'none') {\n if (rel.innerHTML=='') {\n rel.setHTML('<img src=\"" . CopixUrl::getResource('img/tools/load.gif') . "\" />');\n ajax_zone.getZone('{$sessionZone}','{$sessionVar}',rel);\n }\n rel.setStyles({'left':(el.getLeft()+el.getSize().size.x)+'px','zIndex':'10'});\n\n rel.setStyle('display','');\n rel.fixdivShow.delay(200,rel);\n } else {\n rel.fixdivHide();\n rel.setStyle('display','none');\n }\n });\n rel.addEvent ('hide', function () {\n save{$id}.flag = false;\n save{$id}.click = false;\n rel.fixdivHide();\n rel.setStyle('display','none');\n });\n });\n "; break; default: $jsCode = "\n window.addEvent('domready',function () {\n el = \$('div{$id}');\n var rel = \$(el.getProperty('rel'));\n /*\n el.addEvent('trash',function () {\n rel.remove();\n });\n */\n\n rel.injectInside(document.body);\n el.addEvent('mouseenter', function (e) {\n if (rel.innerHTML=='') {\n rel.setHTML('<img src=\"" . CopixUrl::getResource('img/tools/load.gif') . "\" />');\n ajax_zone.getZone('{$sessionZone}','{$sessionVar}',rel)\n }\n var e = new Event(e);\n rel.fixdivShow();\n rel.setStyle('visibility','visible');\n });\n\n el.addEvent('mousemove', function (e) {\n var e = new Event(e);\n rel.setStyles({\n 'position':'absolute',\n 'top' : (e.page.y+5)+'px',\n 'left' : (e.page.x+5)+'px'\n });\n });\n\n el.addEvent('mouseleave', function (e) {\n var e = new Event(e);\n rel.fixdivHide();\n rel.setStyle('visibility','hidden');\n });\n\n\n });\n "; } CopixHTMLHeader::addJSCode($jsCode); _tag('mootools', array('plugin' => array('overlayfix'))); return $toReturn; }