/** * Display a full form without the use of other plugins. * usage : {formfull $theformobject,'submit_action', $submit_action_params} * * You can add this others parameters :<ul> * <li>string $builderName (default is 'html')</li> * <li>array $options for the builder. Example, for the 'html' builder : <ul> * <li>"errorDecorator"=>"name of your javascript object for error listener"</li> * <li>"method" => "post" or "get". default is "post"</li> * </ul> * </li> * </ul> * @param jTplCompiler $compiler the template compiler * @param array $param 0=>form object * 1=>selector of submit action * 2=>array of parameters for submit action * 3=>name of the builder : default is html * 4=>array of options for the builder * @return string the php code corresponding to the begin or end of the block */ function jtpl_cfunction_html_formfull($compiler, $params = array()) { global $gJConfig; if (count($params) < 2 || count($params) > 5) { $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number', 'formfull', '2-5'); } if (isset($params[3]) && trim($params[3]) != '""' && trim($params[3]) != "''") { $builder = $params[3]; } else { $builder = "'" . $gJConfig->tplplugins['defaultJformsBuilder'] . "'"; } $compiler->addMetaContent('if(isset(' . $params[0] . ')) { ' . $params[0] . '->getBuilder(' . $builder . ')->outputMetaContent($t);}'); if (count($params) == 2) { $params[2] = 'array()'; } if (isset($params[4])) { $options = $params[4]; } else { $options = "array()"; } $content = ' $formfull = ' . $params[0] . '; $formfullBuilder = $formfull->getBuilder(' . $builder . '); $formfullBuilder->setAction(' . $params[1] . ',' . $params[2] . '); $formfullBuilder->outputHeader(' . $options . '); $formfullBuilder->outputAllControls(); $formfullBuilder->outputFooter();'; return $content; }
/** * a block to display an html form, with data from a jforms * * usage : {form $theformobject,'submit_action', $submit_action_params} here form content {/form} * * You can add this others parameters :<ul> * <li>string $builderName (default is 'html')</li> * <li>array $options for the builder. Example, for the 'html' builder : <ul> * <li>"errorDecorator"=>"name of your javascript object for error listener"</li> * <li>"method" => "post" or "get". default is "post"</li> * </ul> * </li> * </ul> * * @param jTplCompiler $compiler the template compiler * @param boolean $begin true if it is the begin of block, else false * @param array $param 0=>form object * 1=>selector of submit action * 2=>array of parameters for submit action * 3=>name of the builder : default is html * 4=>array of options for the builder * @return string the php code corresponding to the begin or end of the block * @see jForms */ function jtpl_block_html_form($compiler, $begin, $param = array()) { global $gJConfig; if (!$begin) { return '$t->_privateVars[\'__formbuilder\']->outputFooter(); unset($t->_privateVars[\'__form\']); unset($t->_privateVars[\'__formbuilder\']); unset($t->_privateVars[\'__displayed_ctrl\']);'; } if (count($param) < 2 || count($param) > 5) { $compiler->doError2('errors.tplplugin.block.bad.argument.number', 'form', '2-5'); return ''; } if (count($param) == 2) { $param[2] = 'array()'; } if (isset($param[3]) && trim($param[3]) != '""' && trim($param[3]) != "''") { $builder = $param[3]; } else { $builder = "'" . $gJConfig->tplplugins['defaultJformsBuilder'] . "'"; } if (isset($param[4])) { $options = $param[4]; } else { $options = "array()"; } $content = ' $t->_privateVars[\'__form\'] = ' . $param[0] . '; $t->_privateVars[\'__formbuilder\'] = $t->_privateVars[\'__form\']->getBuilder(' . $builder . '); $t->_privateVars[\'__formbuilder\']->setAction(' . $param[1] . ',' . $param[2] . '); $t->_privateVars[\'__formbuilder\']->outputHeader(' . $options . '); $t->_privateVars[\'__displayed_ctrl\'] = array(); '; $compiler->addMetaContent('if(isset(' . $param[0] . ')) { ' . $param[0] . '->getBuilder(' . $builder . ')->outputMetaContent($t);}'); return $content; }
/** * cfunction plugin : init a tinymce environnement * * @param jTplCompiler $compiler */ function jtpl_cfunction_html_tinymce($compiler, $params = array()) { // on génère du code php qui sera intégré dans le template compilé $codesource = '$rep = $GLOBALS[\'gJCoord\']->response; if($rep!=null) { $rep->addJSLink(\'js/tinymce/tiny_mce.js\'); $rep->addJSCode(\'tinyMCE.init({ mode : "textareas", theme : "simple"});\'); } '; $compiler->addMetaContent($codesource); }
/** * function plugin : include a template into another template * * <pre>{include 'myModule~foo'}</pre> * @param jTplCompiler $compiler the template compiler * @param array $param 0=>$string the template selector (string) * @return string the php code corresponding to the function content */ function jtpl_cfunction_common_include($compiler, $param = array()) { if (!$compiler->trusted) { $compiler->doError1('errors.tplplugin.untrusted.not.available', 'include'); return ''; } if (count($param) == 1) { $compiler->addMetaContent('$t->meta(' . $param[0] . ');'); return '$t->display(' . $param[0] . ');'; } else { $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number', 'include', '1'); return ''; } }
/** * swfjs plugin : Adds html and JS code to display a swf * * Example : * {swfjs 'promobidon.swf', * array('id'=>'promo', 'width'=>150, 'height'=>90, 'detect'=>true), * array('quality'=>'hight', 'wmode'=>'transparent'), * array('longeur'=>150)} * {image 'toupie.png'} * {/swfjs} * * Render after the execution of javascript file : * * <div id="promo"> * <embed width="150" height="90" wmode="transparent" quality="hight" * type="application/x-shockwave-flash" src="/data/fichiers/promobidon.swf" * pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="longeur=150"/> * </div> * * $params[0] url of the swf * $params[1]['id'] id of <object .../> * $params[1]['class'] class of <object .../> * $params[1]['width'] Width final of SWF * $params[1]['height'] Height final of SWF * $params[1]['version'] (ex: '6.0.65') Detect specific major, minor and revision versions of the Flash plugin. * $params[1]['expressinstall'] (true:Bool) Use Express Install, or show an update message if Flash isn't installed. * OR $params[1]['update'] (false:Bool) Or, degrade silently and gracefully. * $params[2][xx] Parameter of the Flash Player * $params[3][xx] Flashvar for the Flash Player * * @param jTplCompiler $compiler the template compiler * @param boolean $begin true if it is the begin of block, else false * @param array $params parameters for the url */ function jtpl_block_html_swfjs($compiler, $begin, $params) { if ($begin) { $meta = ' $resp = jApp::coord()->response if( $resp && $resp->getType() ==\'html\') { $src = ' . $params[0] . '; $options = ' . $params[1] . '; $params = ' . $params[2] . '; $flashvar = ' . $params[3] . '; $script = \'$(function(){\'."\\n"; $script .= " ".\'$("#\'.$options[\'id\'].\'").flash({\'."\\n"; if( !empty($options[\'width\']) ) $script .= " ".\'width:"\'.$options[\'width\'].\'",\'."\\n"; if( !empty($options[\'height\']) ) $script .= " ".\'height:"\'.$options[\'height\'].\'",\'."\\n"; if( count($params) ) foreach($params as $key => $val) $script .= " ".$key.\':"\'.$val.\'", \'."\\r"; $script .= " ".\'src:"\'.$src.\'"\'."\\n"; $script .= " ".\'}, {\'."\\n"; if( !empty($options[\'version\']) ) $script .= " ".\'version:\'.$options[\'version\']; if( !empty($options[\'version\']) && !empty($options[\'detect\']) ) $script .= \',\'."\\n"; if( !empty($options[\'detect\']) ) $script .= " ".\'expressInstall:\'.$options[\'detect\'].\'\'."\\n"; $script .= " ".\'}, function(htmlOptions) {\'."\\n"; if( count($flashvar) ) foreach($flashvar as $key => $val) $script .= " ".\'htmlOptions.flashvars.\'.$key.\' = "\'.$val.\'";\'."\\n"; $script .= " ".\'$(this).children().remove();\'."\\n"; $script .= " ".\'$(this).prepend($.fn.flash.transform(htmlOptions));\'."\\n"; $script .= " ".\'});\'."\\n"; $script .= " ".\'});\'."\\n"; $p = jApp::config()->urlengine[\'jqueryPath\'] $resp->addJSLink($p.\'jquery.js\'); $resp->addJSLink($p.\'flash/jquery.flash.js\'); $resp->addJSCode($script); } '; $compiler->addMetaContent($meta); $sortie = ' $options = ' . $params[1] . '; $att = \'\'; $atts = array(\'id\'=>\'\', \'class\'=>\'\'); $atts = array_intersect_key($options, $atts); foreach( $atts as $key => $val ) if( !empty($val) ) $att .= \' \'.$key.\'="\'.$val.\'"\'; echo \'<div \'.$att.\'>\'; '; return $sortie; } else { return 'echo \'</div>\''; } }