diff --git a/interface/lib/classes/tform_actions.inc.php b/interface/lib/classes/tform_actions.inc.php index 84613866aa48578c2db907fe1d7e2cb6276a1026..7ab09ae794eb47d39ffe2abaa3c4904a560e3fcd 100644 --- a/interface/lib/classes/tform_actions.inc.php +++ b/interface/lib/classes/tform_actions.inc.php @@ -46,7 +46,7 @@ class tform_actions { $app->tpl->newTemplate("tabbed_form.tpl.htm"); // Load table definition from file - $app->tform->loadFormDef($tform_def_file); + $app->tform->loadFormDef($tform_def_file, (isset($_SESSION['s']['module']['name']) ? $_SESSION['s']['module']['name'] : '')); // Importing ID $this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0; diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index 4cc98a4f56e0d4eac7611ad50d1d8b37c3845a31..2e53d2773bc2d0550548f878ba2f8493bd9bd2fe 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -126,8 +126,8 @@ class tform_base { function loadFormDef($file, $module = '') { global $app, $conf; - $app->plugin->raiseEvent('on_before_formdef', $this); include $file; + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$form['name'] . ':on_before_formdef', $this); $this->formDef = $form; $this->module = $module; @@ -152,9 +152,9 @@ class tform_base { } if(isset($wb_global)) unset($wb_global); - $app->plugin->raiseEvent('on_after_formdef', $this); - $this->wordbook = $wb; + + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'] . ':on_after_formdef', $this); $this->dateformat = $app->lng('conf_format_dateshort'); $this->datetimeformat = $app->lng('conf_format_datetime'); diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php index 3210cc0b35f4bf51f7b6e111cbe4ef72840d9863..928c215e203503b381af30e4e0c054a6de121000 100644 --- a/interface/lib/classes/tpl.inc.php +++ b/interface/lib/classes/tpl.inc.php @@ -1073,20 +1073,37 @@ if (!defined('vlibTemplateClassLoaded')) { * @param string $name * @return string hook data */ - private function _parseHook ($type, $name) + private function _parseHook ($name) { global $app; - $module_name = ''; - if(strpos($name, ':') !== false) list($module_name, $name) = explode(':', $name, 2); + if(!$name) return false; - $result = $app->plugin->raiseEvent('on_template_content_hook', array( - 'type' => $type, - 'name' => $name, - 'module' => $module_name - ), true); - if(!$result) $result = ''; - else $result = $this->_getData($result, false, true); + $module = isset($_SESSION['s']['module']['name']) ? $_SESSION['s']['module']['name'] : ''; + $form = isset($app->tform->formDef['name']) ? $app->tform->formDef['name'] : ''; + + $events = array(); + if($module) { + $events[] = $module . ':' . ($form ? $form : '') . ':' . $name; + $events[] = $module . ':' . ($form ? $form : '') . ':on_template_content'; + } else { + $events[] = $name; + $events[] = 'on_template_content'; + } + + $events = array_unique($events); + + for($e = 0; $e < count($events); $e++) { + $tmpresult = $app->plugin->raiseEvent($events[$e], array( + 'name' => $name, + 'module' => $module, + 'form' => $form + ), true); + if(!$tmpresult) $tmpresult = ''; + else $tmpresult = $this->_getData($tmpresult, false, true); + + $result .= $tmpresult; + } return $result; } @@ -1285,7 +1302,7 @@ if (!defined('vlibTemplateClassLoaded')) { } case 'hook': - return $this->_parseHook(@$var, @$value); + return $this->_parseHook(@$var); case 'include': return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; diff --git a/interface/web/sites/templates/web_vhost_domain_edit.htm b/interface/web/sites/templates/web_vhost_domain_edit.htm index d28f0b72603307f14a42ca9ba9eac5f1cf250606..230c8d0dcef4894b6e25f372d12dd7a887bb7cfe 100644 --- a/interface/web/sites/templates/web_vhost_domain_edit.htm +++ b/interface/web/sites/templates/web_vhost_domain_edit.htm @@ -13,7 +13,7 @@ </tmpl_if> - {tmpl_hook name="begin_form" value="web_vhost_domain_edit"} + {tmpl_hook name="begin_form"} <tmpl_if name="vhostdomain_type" value="domain"> <tmpl_if name="is_admin"> <div class="form-group"> @@ -222,32 +222,29 @@ {tmpl_var name='php'} </select></div> </div> - {tmpl_hook name="begin_field" value="web_vhost_domain_edit:fastcgi_php_version"} + {tmpl_hook name="field_fastcgi_php_version"} <div class="form-group fastcgi_php_version"> <label for="fastcgi_php_version" class="col-sm-3 control-label">{tmpl_var name='fastcgi_php_version_txt'}</label> <div class="col-sm-9"><select name="fastcgi_php_version" id="fastcgi_php_version" class="form-control"> {tmpl_var name='fastcgi_php_version'} </select></div> </div> - {tmpl_hook name="end_field" value="web_vhost_domain_edit:fastcgi_php_version"} - {tmpl_var name="directive_snippets_id"} - {tmpl_hook name="begin_field" value="web_vhost_domain_edit:enable_pagespeed"} + {tmpl_var name="directive_snippets_id"} + {tmpl_hook name="field_enable_pagespeed"} <div class="form-group nginx pagespeed"> <label class="col-sm-3 control-label">{tmpl_var name='enable_pagespeed_txt'}</label> <div class="col-sm-9"> {tmpl_var name="enable_pagespeed"} </div> </div> - {tmpl_hook name="end_field" value="web_vhost_domain_edit:enable_pagespeed"} - {tmpl_hook name="begin_field" value="web_vhost_domain_edit:active"} + {tmpl_hook name="field_active"} <div class="form-group"> <label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label> <div class="col-sm-9"> {tmpl_var name='active'} </div> </div> - {tmpl_hook name="end_field" value="web_vhost_domain_edit:active"} - {tmpl_hook name="end_form" value="web_vhost_domain_edit"} + {tmpl_hook name="end_form"} <input type="hidden" name="id" value="{tmpl_var name='id'}"> diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index bdfc761fdac5a093dba5601c33d2c931589c0b56..ab8430d36f1cc052a0b606b85af44fa02c12ce28 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -1,3 +1,4 @@ +<tmpl_hook name='apache2_vhost:header'> <Directory {tmpl_var name='web_basedir'}/{tmpl_var name='domain'}> AllowOverride None @@ -9,8 +10,9 @@ </tmpl_if> </Directory> -<tmpl_loop name="vhosts"> +<tmpl_loop name='vhosts'> <VirtualHost {tmpl_var name='ip_address'}:{tmpl_var name='port'}> +<tmpl_hook name='apache2_vhost:vhost_header'> <tmpl_if name='php' op='==' value='suphp'> DocumentRoot <tmpl_var name='web_document_root'> </tmpl_else> @@ -444,5 +446,8 @@ </IfModule> <tmpl_var name='apache_directives'> +<tmpl_hook name='apache2_vhost:vhost_footer'> </VirtualHost> </tmpl_loop> + +<tmpl_hook name='apache2_vhost:footer'> \ No newline at end of file diff --git a/server/lib/classes/plugins.inc.php b/server/lib/classes/plugins.inc.php index 4771487dce37e3d97b282fc8cfa9235f894ea231..9b9b143776d3e4ffe390cc73406c96fef4ae0b6c 100644 --- a/server/lib/classes/plugins.inc.php +++ b/server/lib/classes/plugins.inc.php @@ -73,7 +73,6 @@ class plugins { } else { $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR); } - } /* @@ -138,13 +137,15 @@ class plugins { } - function raiseAction($action_name, $data) { + function raiseAction($action_name, $data, $return_data = false) { global $app; //* Get the subscriptions for this action $actions = (isset($this->subscribed_actions[$action_name]))?$this->subscribed_actions[$action_name]:''; if($this->debug) $app->log('Raised action: '.$action_name, LOGLEVEL_DEBUG); + $result = ''; + if(is_array($actions)) { foreach($actions as $action) { $plugin_name = $action['plugin']; @@ -154,8 +155,13 @@ class plugins { $app->log("Calling function '$function_name' from plugin '$plugin_name' raised by action '$action_name'.", LOGLEVEL_DEBUG); $state = call_user_func(array($app->loaded_plugins[$plugin_name], $function_name), $action_name, $data); //* ensure that we return the highest warning / error level if a error occured in one of the functions - if($state == 'warning' && $state_out != 'error') $state_out = 'warning'; - if($state == 'error') $state_out = 'error'; + if($return_data) { + if($state) $result .= $state; + } else { + if($state == 'warning' && $state_out != 'error') $state_out = 'warning'; + elseif($state == 'error') $state_out = 'error'; + } + unset($plugin_name); unset($function_name); } @@ -163,7 +169,8 @@ class plugins { unset($action); unset($actions); - return $state_out; + if($return_data == true) return $result; + else return $state_out; } } diff --git a/server/lib/classes/tpl.inc.php b/server/lib/classes/tpl.inc.php index 34df2a9343c467c2dfe39bb017fbcaee0a30c1cd..5e595f69fe01e6715f6d8ba7665147a81390aede 100644 --- a/server/lib/classes/tpl.inc.php +++ b/server/lib/classes/tpl.inc.php @@ -839,28 +839,34 @@ if (!defined('vlibTemplateClassLoaded')) { * @access private * @return mixed data/string or boolean */ - private function _getData ($tmplfile, $do_eval=false) + private function _getData ($tmplfile, $do_eval=false, $tmpl_from_string = false) { //* check the current file depth if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) { return; } else { if ($this->_debug){ - array_push($this->_debugIncludedfiles, $tmplfile); + if($tmpl_from_string) array_push($this->_debugIncludedfiles, 'String: ' . substr($tmplfile, 0, 25) . '...'); + else array_push($this->_debugIncludedfiles, $tmplfile); } if ($do_eval) { - array_push($this->_currentincludedir, dirname($tmplfile)); + if($tmpl_from_string == true) array_push($this->_currentincludedir, end($this->_currentincludedir)); + else array_push($this->_currentincludedir, dirname($tmplfile)); $this->_includedepth++; } } - if($this->_cache && $this->_checkCache($tmplfile)) { //* cache exists so lets use it + if($this->_cache && $this->_checkCache($tmplfile, $tmpl_from_string)) { //* cache exists so lets use it $data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile)); fclose($fp); } else { //* no cache lets parse the file - $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); - fclose($fp); + if($tmpl_from_string == true) { + $data = $tmplfile; + } else { + $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); + fclose($fp); + } $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*'; $regex.= 'tmpl_([\w]+)\s*'; @@ -884,7 +890,7 @@ if (!defined('vlibTemplateClassLoaded')) { } //* now we must parse the $data and check for any <tmpl_include>'s - if ($this->_debug) $this->doDebugWarnings(file($tmplfile), $tmplfile); + if ($this->_debug && $tmpl_from_string == false) $this->doDebugWarnings(file($tmplfile), $tmplfile); if ($do_eval) { $success = @eval('?>'.$data.'<?php return 1;'); @@ -1061,6 +1067,29 @@ if (!defined('vlibTemplateClassLoaded')) { } } + /** + * returns a string containing hook data + * @param string $type + * @param string $name + * @return string hook data + */ + private function _parseHook ($name) + { + global $app; + + $namespace = ''; + if(strpos($name, ':') !== false) list($namespace, $name) = explode(':', $name, 2); + + $result = $app->plugins->raiseAction('on_template_content_hook', array( + 'name' => $name, + 'namespace' => $namespace, + 'vars' => $this->_vars + ), true); + if(!$result) $result = ''; + else $result = $this->_getData($result, false, true); + + return $result; + } /** * returns a string used for parsing in tmpl_loop statements. @@ -1254,7 +1283,10 @@ if (!defined('vlibTemplateClassLoaded')) { if ($this->OPTIONS['ENABLE_PHPINCLUDE']) { return '<?php include(\''.$file.'\'); ?>'; } - + + case 'hook': + return $this->_parseHook(@$var); + case 'include': return '<?php $this->_getData($this->_fileSearch(\''.$file.'\'), 1); ?>'; diff --git a/server/lib/classes/tpl_cache.inc.php b/server/lib/classes/tpl_cache.inc.php index 4bf75faa8c8cda9ccb92a3b8749cf0926fce8f47..ce8a5b16ceccb5d9cdab6a7c4c125a6367a34b0f 100644 --- a/server/lib/classes/tpl_cache.inc.php +++ b/server/lib/classes/tpl_cache.inc.php @@ -101,8 +101,8 @@ class tplc extends tpl { * FUNCTION: _checkCache * checks if there's a cache, if there is then it will read the cache file as the template. */ - function _checkCache ($tmplfile) { - $this->_cachefile = $this->_getFilename($tmplfile); + function _checkCache ($tmplfile, $tmpl_from_string = false) { + $this->_cachefile = $this->_getFilename($tmplfile, $tmpl_from_string); if ($this->_clearcache) { if (file_exists($this->_cachefile)) unlink($this->_cachefile); return false; @@ -133,8 +133,9 @@ class tplc extends tpl { * gets the full pathname for the cached file * */ - function _getFilename($tmplfile) { - return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION']; + function _getFilename($tmplfile, $tmpl_from_string = false) { + if($tmpl_from_string == true) return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaRSTRING'.$tmplfile).'.'.$this->OPTIONS['CACHE_EXTENSION']; + else return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION']; }