meta = DOKU_PLUGIN.'subconfhelper/conf/subconfhelper_metadata.php'; $this->default = DOKU_PLUGIN.'subconfhelper/conf/subconfhelper_default.php'; $this->config_path = DOKU_CONF; $this->config_prefix = 'subconfhelper_'; if (!isset($_REQUEST['vhost']['admin'])) { $admin = null; } else { $admin = (is_array($_REQUEST['vhost']['admin'])) ? key( $_REQUEST['vhost']['admin'] ) : $_REQUEST['vhost']['admin']; } if( isset( $_REQUEST['vhost']['vhost']) && preg_match( '/[a-z0-9_\-]/', $_REQUEST['vhost']['vhost'] )) { $vhost = $_REQUEST['vhost']['vhost']; if( $vhost == '__new__' ) { if( isset( $_REQUEST['ns']['ns']) && preg_match( '/[a-z0-9_\-]/', $_REQUEST['ns']['ns'] )) { $vhost = $_REQUEST['ns']['ns']; } } $file = $this->config_path.$this->config_prefix.$vhost.'.php'; $_input = $_REQUEST['config']; } // handle actions switch($admin) { case 'vhost_new': if( is_file( $file ) || is_dir( $file ) || !touch( $file )) { msg($this->getLang('msg_vhost_error'), -1); } else { msg($this->getLang('msg_vhost_delete'), 1); } break; case 'vhost_delete': if( !is_file( $file ) || is_dir( $file ) || !unlink( $file )) { msg($this->getLang('msg_vhost_error'), -1); } else { msg($this->getLang('msg_vhost_save'), 1); } break; case 'vhost_save': if( !$vhost || !is_file( $file )) break; $_changed = false; $_error = false; $_config = &plugin_load( 'helper', 'subconfhelper_config' ); $_config->configuration( $this->meta, array( $file )); while (list($key) = each($_config->setting)) { $input = isset($_input[$key]) ? $_input[$key] : NULL; if ($_config->setting[$key]->update($input)) { $_changed = true; } if ($_config->setting[$key]->error()) $_error = true; } if( $_changed && !$_error && $_config->save_settings( $vhost )) { msg($this->getLang('msg_vhost_save'), 1); } else { msg($this->getLang('msg_vhost_error'), -1); } break; default: // do nothing - show dashboard break; } }/*}}}*/ function html() {/*{{{*/ ptln('
'); $this->xhtml_vhost_list(); ptln('
'); }/*}}}*/ function xhtml_vhost_list( ) {/*{{{*/ global $lang; global $ID; ptln( '
' ); ptln( '

' . $this->getLang( 'vhost_text' ).'

' ); ptln( ''); ptln('
'); }/*}}}*/ function xhtml_vhost_item( $vhost, $file ) {/*{{{*/ global $lang; global $ID; $meta = $this->meta; $default = $this->default; $_config = &plugin_load( 'helper', 'subconfhelper_config'); #$_config->configuration( $meta, array( $file ), array( $default )); // TODO defaults $_config->configuration( $meta, array( $file )); if ($_config->locked) ptln('
'.$this->getLang('locked').'
'); elseif ($this->_error) ptln('
'.$this->getLang('error').'
'); elseif ($this->_changed) ptln('
'.$this->getLang('updated').'
'); ptln( "
" ); ptln( "" ); ptln( "" ); ptln( ''); ptln( "
" ); }/*}}}*/ }