From b844f05e10d8b0ae9c01641d39c3f894ca12a5d8 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Sat, 10 May 2014 21:06:15 +0200 Subject: [PATCH] Rework startup. Set Encoding and server URI via installer. Activate syncable features, rest API and backbone router by default. --- core/src/.htaccess | 50 +++++++++---------- core/src/core/tests/test.ServerEncoding.php | 8 +-- core/src/plugins/access.fs/manifest.xml | 2 +- .../plugins/authfront.http_basic/manifest.xml | 2 +- .../plugins/authfront.keystore/manifest.xml | 2 +- .../plugins/boot.conf/class.AjxpInstaller.js | 15 +++++- .../boot.conf/class.BootConfLoader.php | 40 ++++++++++++--- core/src/plugins/boot.conf/manifest.xml | 2 + core/src/plugins/gui.ajax/manifest.xml | 2 +- 9 files changed, 83 insertions(+), 40 deletions(-) diff --git a/core/src/.htaccess b/core/src/.htaccess index aee82462bb..7833ac5934 100644 --- a/core/src/.htaccess +++ b/core/src/.htaccess @@ -1,25 +1,25 @@ - -# You must set the correct values here if you want -# to enable webDAV sharing. The values assume that your -# Pydio installation is at http://yourdomain/ -# and that you want the webDAV shares to be accessible via -# http://yourdomain/shares/repository_id/ -RewriteEngine on -RewriteBase / -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^shares ./dav.php [L] -RewriteRule ^api ./rest.php [L] -RewriteRule ^user ./index.php?get_action=user_access_point [L] -RewriteCond %{REQUEST_URI} !^/index -RewriteCond %{REQUEST_URI} !^/plugins -RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/ws- -RewriteRule (.*) index.php [L] - -#Following lines seem to be necessary if PHP is working -#with apache as CGI or FCGI. Just remove the # -#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi - -#RewriteCond %{HTTP:Authorization} ^(.*) -#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1] - + +# You must set the correct values here if you want +# to enable webDAV sharing. The values assume that your +# Pydio installation is at http://yourdomain/ +# and that you want the webDAV shares to be accessible via +# http://yourdomain/shares/repository_id/ +RewriteEngine on +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^shares ./dav.php [L] +RewriteRule ^api ./rest.php [L] +RewriteRule ^user ./index.php?get_action=user_access_point [L] +RewriteCond %{REQUEST_URI} !^/index +RewriteCond %{REQUEST_URI} !^/plugins +RewriteCond %{REQUEST_URI} ^/dashboard|^/settings|^/ws- +RewriteRule (.*) index.php [L] + +#Following lines seem to be necessary if PHP is working +#with apache as CGI or FCGI. Just remove the # +#See http://doc.tiki.org/WebDAV#Note_about_Apache_with_PHP_as_fcgi_or_cgi + +#RewriteCond %{HTTP:Authorization} ^(.*) +#RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1] + diff --git a/core/src/core/tests/test.ServerEncoding.php b/core/src/core/tests/test.ServerEncoding.php index bee2b271a8..d51c084a61 100644 --- a/core/src/core/tests/test.ServerEncoding.php +++ b/core/src/core/tests/test.ServerEncoding.php @@ -28,7 +28,9 @@ */ class ServerEncoding extends AbstractTest { - public function ServerEncoding() { parent::AbstractTest("Server charset encoding", "You must set a correct charset encoding in your locale definition in the form: en_us.UTF-8. Please refer to setlocale man page. If your detected locale is C, please check the F.A.Q.. "); } + public function ServerEncoding() { parent::AbstractTest("Server charset encoding", "You must set a correct charset encoding + in your locale definition in the form: en_us.UTF-8. Please refer to setlocale man page. + If your detected locale is C, simply type echo \$LANG on your server command line to read the correct value."); } public function doTest() { // Get the locale @@ -36,13 +38,13 @@ public function doTest() if ($locale == 'C') { $this->failedLevel = "warning"; $this->failedInfo .= "Detected locale: $locale (using UTF-8)"; - $this->failedInfo .= "

Suggestion : Set the AJXP_LOCALE parameter to the correct value in the conf/bootstrap_conf.php file

"; + $this->failedInfo .= "

Suggestion : Set the AJXP_LOCALE parameter to the correct value in the conf/bootstrap_conf.php file. You can also set this value using the installer form (next step).

"; return FALSE; } if (strpos($locale, '.') === FALSE) { $this->failedLevel = "warning"; $this->failedInfo .= "Locale doesn't contain encoding: $locale (so using UTF-8)"; - $this->failedInfo .= "

Suggestion : Set the AJXP_LOCALE parameter to the correct value in the conf/bootstrap_conf.php file

"; + $this->failedInfo .= "

Suggestion : Set the AJXP_LOCALE parameter to the correct value in the conf/bootstrap_conf.php file. You can also set this value using the installer form (next step).

"; return FALSE; } // Check if we have iconv diff --git a/core/src/plugins/access.fs/manifest.xml b/core/src/plugins/access.fs/manifest.xml index 9d6df67722..8e2c13667a 100644 --- a/core/src/plugins/access.fs/manifest.xml +++ b/core/src/plugins/access.fs/manifest.xml @@ -17,7 +17,7 @@ - + diff --git a/core/src/plugins/authfront.http_basic/manifest.xml b/core/src/plugins/authfront.http_basic/manifest.xml index b724d8c070..654dfe21e2 100644 --- a/core/src/plugins/authfront.http_basic/manifest.xml +++ b/core/src/plugins/authfront.http_basic/manifest.xml @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/core/src/plugins/authfront.keystore/manifest.xml b/core/src/plugins/authfront.keystore/manifest.xml index f16519ae44..94f2543109 100644 --- a/core/src/plugins/authfront.keystore/manifest.xml +++ b/core/src/plugins/authfront.keystore/manifest.xml @@ -9,7 +9,7 @@ + description="Order this plugin with other auth frontends" default="2"/> diff --git a/core/src/plugins/boot.conf/class.AjxpInstaller.js b/core/src/plugins/boot.conf/class.AjxpInstaller.js index 28e60ef1f0..4dde36e76d 100644 --- a/core/src/plugins/boot.conf/class.AjxpInstaller.js +++ b/core/src/plugins/boot.conf/class.AjxpInstaller.js @@ -137,15 +137,26 @@ Class.create("AjxpInstaller", AjxpPane, { progress.show(); modal.refreshDialogPosition(); conn.onComplete = function(transport){ + new Effect.Fade(progress.down('span.icon-spinner'), {afterFinish : function(){ + progress.down('span.icon-spinner').remove(); + modal.refreshDialogPosition(); + }}); if(transport.responseText == "OK"){ window.setTimeout(function(){ progress.insert('...done!
The page will now reload automatically. You can log in with the admin user "'+params.get('ADMIN_USER_LOGIN')+'" you have just defined.

'); - new Effect.Fade(progress.down('span.icon-spinner'), {afterFinish : function(){progress.down('span.icon-spinner').remove();}}); - modal.refreshDialogPosition(); window.setTimeout(function(){ document.location.reload(true); }, 6000); }, 3000); + }else{ + var json = transport.responseJSON; + progress.insert('Warning: cannot write htaccess file. Please copy the content below and update the ' + + 'file located at the following location: ' + json['file'] + '
Hit Ctrl/Cmd+C ' + + 'to copy the content to your clipboard. Simply reload this page once it\'s done.'); + var textarea = new Element('textarea', {style:'width: 98%;height: 260px; margin-top:10px;'}).update(json['content']); + progress.insert(textarea); + textarea.select(); + modal.refreshDialogPosition(); } }; conn.sendAsync(); diff --git a/core/src/plugins/boot.conf/class.BootConfLoader.php b/core/src/plugins/boot.conf/class.BootConfLoader.php index 9530e7ef1a..51f83d87c2 100644 --- a/core/src/plugins/boot.conf/class.BootConfLoader.php +++ b/core/src/plugins/boot.conf/class.BootConfLoader.php @@ -105,6 +105,18 @@ public function loadInstallerForm($action, $httpVars, $fileVars) $addParams .= AJXP_XMLWriter::replaceAjxpXmlKeywords($typePlug->getManifestRawContent("server_settings/global_param")); } } + $uri = $_REQUEST["REQUEST_URI"]; + if(strpos($uri, '.php') !== false) $uri = dirname($uri); + if(empty($uri)) $uri = "/"; + $loadedValues = array( + "ENCODING" => (defined('AJXP_LOCALE')?AJXP_LOCALE:SystemTextEncoding::getEncoding()), + "SERVER_URI"=> $uri + ); + foreach($loadedValues as $pName => $pValue){ + $vNodes = $xPath->query("server_settings/global_param[@name='$pName']"); + if(!$vNodes->length) continue; + $vNodes->item(0)->setAttribute("default", $pValue); + } $allParams = AJXP_XMLWriter::replaceAjxpXmlKeywords($fullManifest->ownerDocument->saveXML($fullManifest)); $allParams = str_replace('type="plugin_instance:', 'type="group_switch:', $allParams); $allParams = str_replace("", $addParams."", $allParams); @@ -124,7 +136,7 @@ public function applyInstallerForm($action, $httpVars, $fileVars) { $data = array(); AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, ""); - $tot = "toto"; + // Create a custom bootstrap.json file $coreConf = array(); $coreAuth = array(); $this->_loadPluginConfig("core.conf", $coreConf); @@ -133,7 +145,6 @@ public function applyInstallerForm($action, $httpVars, $fileVars) if(!isSet($coreAuth["MASTER_INSTANCE_CONFIG"])) $coreAuth["MASTER_INSTANCE_CONFIG"] = array(); $storageType = $data["STORAGE_TYPE"]["type"]; - $coreConfLIVECONFIG = array(); if ($storageType == "db") { // REWRITE BOOTSTRAP.JSON $coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"]; @@ -155,7 +166,7 @@ public function applyInstallerForm($action, $httpVars, $fileVars) )); // INSTALL ALL SQL TABLES - $sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql"); + $sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql", "meta.syncable"); foreach ($sqlPlugs as $plugId) { $plug = AJXP_PluginsService::findPluginById($plugId); $plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"])); @@ -191,6 +202,18 @@ public function applyInstallerForm($action, $httpVars, $fileVars) $newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); $newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver"); + if($data["ENCODING"] != (defined('AJXP_LOCALE')?AJXP_LOCALE:SystemTextEncoding::getEncoding())){ + file_put_contents($this->getPluginWorkDir()."/encoding.php", "getBaseDir()."/htaccess.tpl"); + $htContent = str_replace('${APPLICATION_ROOT}', $data["SERVER_URI"], $tpl); + if(is_writeable(AJXP_INSTALL_PATH."/.htaccess")){ + file_put_contents(AJXP_INSTALL_PATH."/.htaccess", $htContent); + }else{ + $htAccessToUpdate = AJXP_INSTALL_PATH."/.htaccess"; + } + } if ($storageType == "db") { $sqlPlugs = array( @@ -274,14 +297,19 @@ public function applyInstallerForm($action, $httpVars, $fileVars) } - @unlink(AJXP_PLUGINS_CACHE_FILE); @unlink(AJXP_PLUGINS_REQUIRES_FILE); @unlink(AJXP_PLUGINS_MESSAGES_FILE); AJXP_Utils::setApplicationFirstRunPassed(); - session_destroy(); - echo 'OK'; + if(isSet($htAccessToUpdate)){ + HTMLWriter::charsetHeader("application/json"); + echo json_encode(array('file' => $htAccessToUpdate, 'content' => $htContent)); + }else{ + session_destroy(); + HTMLWriter::charsetHeader("text/plain"); + echo 'OK'; + } } diff --git a/core/src/plugins/boot.conf/manifest.xml b/core/src/plugins/boot.conf/manifest.xml index 10c0d9dd14..36c1fbbfc3 100644 --- a/core/src/plugins/boot.conf/manifest.xml +++ b/core/src/plugins/boot.conf/manifest.xml @@ -14,6 +14,8 @@ + + diff --git a/core/src/plugins/gui.ajax/manifest.xml b/core/src/plugins/gui.ajax/manifest.xml index 32e946aeaf..d45a8a9af0 100644 --- a/core/src/plugins/gui.ajax/manifest.xml +++ b/core/src/plugins/gui.ajax/manifest.xml @@ -7,7 +7,7 @@ - +