Commit 6b15d5f4 authored by Marius Burkard's avatar Marius Burkard
Browse files

- added {DOCROOT_CLIENT} to directive placeholders (non-symlink docroot)

- made placeholders visible for apache, too
- added event raise at formdef loading (on_before_formdef and on_after_formdef)
- added possibility to put plugin files into module/lib/plugin.d/ directory
parent d240f6d2
......@@ -43,35 +43,50 @@ class plugin {
if(isset($_SESSION['s']['plugin_cache'])) unset($_SESSION['s']['plugin_cache']);
$plugins_dir = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
$plugin_dirs = array();
$plugin_dirs[] = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
if(is_dir(ISPC_WEB_PATH)) {
if($dh = opendir(ISPC_WEB_PATH)) {
while(($file = readdir($dh)) !== false) {
if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d';
}
closedir($dh);
}
}
$_SESSION['s']['plugin_cache'] = array();
$tmp_plugins = array();
if (is_dir($plugins_dir)) {
if ($dh = opendir($plugins_dir)) {
//** Go trough all files in the plugin dir
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') {
$plugin_name = substr($file, 0, -8);
$tmp_plugins[$plugin_name] = $file;
for($d = 0; $d < count($plugin_dirs); $d++) {
$plugins_dir = $plugin_dirs[$d];
if (is_dir($plugins_dir)) {
if ($dh = opendir($plugins_dir)) {
//** Go trough all files in the plugin dir
while (($file = readdir($dh)) !== false) {
if($file !== '.' && $file !== '..' && substr($file, -8, 8) == '.inc.php') {
$plugin_name = substr($file, 0, -8);
$tmp_plugins[$plugin_name] = $file;
}
}
}
//** sort the plugins by name
ksort($tmp_plugins);
//** load the plugins
foreach($tmp_plugins as $plugin_name => $file) {
include_once $plugins_dir.$file;
if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
$app->loaded_plugins[$plugin_name] = new $plugin_name;
$app->loaded_plugins[$plugin_name]->onLoad();
closedir($dh);
//** sort the plugins by name
ksort($tmp_plugins);
//** load the plugins
foreach($tmp_plugins as $plugin_name => $file) {
include_once $plugins_dir.$file;
if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
$app->loaded_plugins[$plugin_name] = new $plugin_name;
$app->loaded_plugins[$plugin_name]->onLoad();
}
} else {
$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
}
} else {
$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
}
} else {
$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
}
}
......
......@@ -594,7 +594,7 @@ class tform_actions {
$app->load($plugin_class);
$this->plugins[$plugin_name] = new $plugin_class;
$this->plugins[$plugin_name]->setOptions($plugin_name, $plugin_settings['options']);
// Make the data of the form easily accessible for the plugib
// Make the data of the form easily accessible for the plugin
$this->plugins[$plugin_name]->form = $this;
$this->plugins[$plugin_name]->onLoad();
}
......
......@@ -126,6 +126,7 @@ class tform_base {
function loadFormDef($file, $module = '') {
global $app, $conf;
$app->plugin->raiseEvent('on_before_formdef', $module);
include $file;
$this->formDef = $form;
......@@ -150,6 +151,8 @@ class tform_base {
$wb = $app->functions->array_merge($wb_global, $wb);
}
if(isset($wb_global)) unset($wb_global);
$app->plugin->raiseEvent('on_after_formdef', $module);
$this->wordbook = $wb;
......
......@@ -16,7 +16,7 @@
</div>
<div class="form-group">
<label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
</div>
<div class="form-group php">
<label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>
......
......@@ -1091,7 +1091,10 @@ class apache2_plugin {
// Make sure we only have Unix linebreaks
$vhost_data['apache_directives'] = str_replace("\r\n", "\n", $vhost_data['apache_directives']);
$vhost_data['apache_directives'] = str_replace("\r", "\n", $vhost_data['apache_directives']);
$trans = array('{DOCROOT}' => $vhost_data['web_document_root_www']);
$trans = array(
'{DOCROOT}' => $vhost_data['web_document_root_www'],
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root']
);
$vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans);
// Check if a SSL cert exists
......
......@@ -1133,7 +1133,11 @@ class nginx_plugin {
$nginx_directives = str_replace("\r", "\n", $nginx_directives);
$nginx_directive_lines = explode("\n", $nginx_directives);
if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){
$trans = array('{DOCROOT}' => $vhost_data['web_document_root_www'], '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';');
$trans = array(
'{DOCROOT}' => $vhost_data['web_document_root_www'],
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root'],
'{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';'
);
foreach($nginx_directive_lines as $nginx_directive_line){
$final_nginx_directives[] = array('nginx_directive' => strtr($nginx_directive_line, $trans));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment