From: <bh...@us...> - 2008-04-13 06:34:33
|
Revision: 17581 http://gallery.svn.sourceforge.net/gallery/?rev=17581&view=rev Author: bharat Date: 2008-04-12 23:34:38 -0700 (Sat, 12 Apr 2008) Log Message: ----------- Force the config baseUri to be set to the current URL for both regular and multisite installs at install and upgrade time. When you upgrade, if you have an empty baseUri in your config, it'll get updated here. If you already have something it won't get overwritten. Core upgrade to 1.2.33. Modified Paths: -------------- trunk/gallery2/install/steps/CreateConfigFileStep.class trunk/gallery2/install/steps/FinishedStep.class trunk/gallery2/install/steps/MultisiteStep.class trunk/gallery2/install/templates/Finished.html trunk/gallery2/install/templates/Multisite.html trunk/gallery2/modules/core/CoreModuleExtras.inc trunk/gallery2/modules/core/module.inc Modified: trunk/gallery2/install/steps/CreateConfigFileStep.class =================================================================== --- trunk/gallery2/install/steps/CreateConfigFileStep.class 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/install/steps/CreateConfigFileStep.class 2008-04-13 06:34:38 UTC (rev 17581) @@ -170,6 +170,10 @@ $line = sprintf("\$gallery->setConfig('galleryBaseUrl', '%s');\n", $tmp); } + if (trim($line) == '$gallery->setConfig(\'baseUri\', \'\');') { + $line = sprintf("\$gallery->setConfig('baseUri', '%s');\n", $_SESSION['baseUri']); + } + $contents .= $line; } fclose($in); Modified: trunk/gallery2/install/steps/FinishedStep.class =================================================================== --- trunk/gallery2/install/steps/FinishedStep.class 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/install/steps/FinishedStep.class 2008-04-13 06:34:38 UTC (rev 17581) @@ -30,7 +30,7 @@ function loadTemplateData(&$templateData) { global $galleryStub; - $templateData['isMultisite'] = $galleryStub->getConfig('isMultisite'); + $templateData['baseUri'] = $_SESSION['baseUri']; $templateData['galleryDir'] = basename($_SESSION['configPath']); $templateData['bodyFile'] = 'Finished.html'; $this->setComplete(true); Modified: trunk/gallery2/install/steps/MultisiteStep.class =================================================================== --- trunk/gallery2/install/steps/MultisiteStep.class 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/install/steps/MultisiteStep.class 2008-04-13 06:34:38 UTC (rev 17581) @@ -25,6 +25,7 @@ class MultisiteStep extends InstallStep { var $_isMultisite; var $_configPath; + var $_baseUri; function stepName() { return _('Installation Type'); @@ -45,6 +46,7 @@ $this->_isMultisite = false; $baseDir = dirname(dirname(dirname(__FILE__))); $_SESSION['configPath'] = $baseDir; + $_SESSION['baseUri'] = getGalleryDirUrl() . GALLERY_MAIN_PHP; $this->setComplete(true); $this->readConfigFile(); /* Remember the value also for the storage and database setup steps */ @@ -62,6 +64,12 @@ } else { $this->_configPath = rtrim($this->sanitize($_POST['configPath']), ' ' . DIRECTORY_SEPARATOR); + $this->_baseUri = isset($_POST['baseUri']) ? $_POST['baseUri'] : ''; + + if (substr($this->_baseUri, -4) != '.php' + && substr($this->_baseUri, -1) != '/') { + $this->_baseUri .= '/' . GALLERY_MAIN_PHP; + } } } return true; @@ -73,6 +81,7 @@ if (!isset($this->_isMultisite)) { $this->_isMultisite = false; $this->_configPath = ''; + $this->_baseUri = ''; } $galleryDir = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR; @@ -80,22 +89,31 @@ if (isset($_POST['isMultisite']) && $_POST['isMultisite'] == '1') { $this->_isMultisite = true; if (empty($this->_configPath)) { - $templateData['error']['missing_value'] = 1; + $templateData['error']['dir']['empty'] = 1; } else if (!is_dir($this->_configPath)) { - $templateData['error']['missing_dir'] = 1; + $templateData['error']['dir']['missing'] = 1; } else if ($this->_configPath == $galleryDir || $this->_configPath . DIRECTORY_SEPARATOR == $galleryDir) { - $templateData['error']['codebase_dir'] = 1; + $templateData['error']['dir']['codebase'] = 1; } else if (!is_readable($this->_configPath)) { - $templateData['error']['inaccessible_dir'] = 1; + $templateData['error']['dir']['inaccessible'] = 1; } else if (!MultisiteStep::populateMultisiteDirectory($this->_configPath)) { - $templateData['error']['creation_error'] = 1; - } else { + $templateData['error']['dir']['creation_error'] = 1; + } + + if (empty($this->_baseUri)) { + $templateData['error']['uri']['missing'] = 1; + } + + if (empty($templateData['error'])) { $_SESSION['configPath'] = $this->_configPath; + $_SESSION['baseUri'] = $this->_baseUri; $this->setComplete(true); $this->readConfigFile(); $galleryStub->setConfig('isMultisite', true); } + } else { + $_SESSION['baseUri'] = getGalleryDirUrl() . GALLERY_MAIN_PHP; } /* @@ -111,6 +129,7 @@ $templateData['isMultisite'] = $this->_isMultisite; $templateData['configPath'] = $this->_configPath; + $templateData['baseUri'] = $this->_baseUri; $templateData['galleryDir'] = $galleryDir; $templateData['galleryUrl'] = getGalleryDirUrl(); $templateData['bodyFile'] = $this->isComplete() ? 'MultisiteSuccess.html' Modified: trunk/gallery2/install/templates/Finished.html =================================================================== --- trunk/gallery2/install/templates/Finished.html 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/install/templates/Finished.html 2008-04-13 06:34:38 UTC (rev 17581) @@ -4,12 +4,6 @@ <?php print _("Congratulations! Your Gallery 2 install is complete! See... that wasn't so hard, was it? Now it's time to upload some photos!") ?> </p> - <?php if (!$templateData['isMultisite']): ?> <div class="go"> - <a href="../main.php" class="btn continue"><i></i><span><span></span><i></i><?php print _('Go to my Gallery!') ?></span></a> + <a href="<?php print $templateData['baseUri'] ?>" class="btn continue"><i></i><span><span></span><i></i><?php print _('Go to my Gallery!') ?></span></a> </div> - <?php else: ?> - <p> - <?php printf(_("You may now go to your new Gallery. Enter the URL in your browser for %smain.php%s in your %s directory."), '<tt>', '</tt>', '<tt>' . $templateData['galleryDir'] . '</tt>') ?> - </p> - <?php endif; ?> Modified: trunk/gallery2/install/templates/Multisite.html =================================================================== --- trunk/gallery2/install/templates/Multisite.html 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/install/templates/Multisite.html 2008-04-13 06:34:38 UTC (rev 17581) @@ -33,33 +33,33 @@ <?php printf(_('This is for multiple Gallery installations on a single web server. Each Gallery is totally independent with its own database of photos, albums, and users. For more details, refer to the %s page.'), '<a href="http://codex.gallery2.org/index.php/Gallery2:Multisite" target="_blank">Multisite Documentation</a>') ?> </p> - <?php if (isset($templateData['error'])): ?> + <?php if (isset($templateData['error']['dir'])): ?> <div class="error" style="padding-top: 0.8em; padding-bottom: 0.9em"> - <?php if (isset($templateData['error']['missing_value'])): ?> + <?php if (isset($templateData['error']['dir']['empty'])): ?> <?php print _('You must enter a directory');?> - <?php elseif (isset($templateData['error']['codebase_dir'])): ?> - <?php printf(_('You entered the %s directory. If you want to install a Gallery there, select the standard installation type. If you want to install a multisite, choose a different directory.'), basename($templateData['configPath'])); ?> - <?php elseif (isset($templateData['error']['missing_dir'])): ?> - <?php if (!empty($templateData['openBasedir'])): ?> - <?php print _('The directory you entered either does not exist, or is prohibited by your webserver configuration. Your webserver is configured to only allow access to the following directories. You must choose a directory under one of these, or you must modify the <b>open_basedir</b> setting in your PHP configuration to allow a new directory.'); ?> - <ul> - <?php foreach ($templateData['openBasedir'] as $dir): ?> - <li> <?php print $dir ?> </li> - <?php endforeach; ?> - </ul> - <?php print _('If your multisite installation is in a different virtual host, you should contact your system administrator and request that they configure your <b>open_basedir</b> setting so that your virtual hosts can access each other.'); ?> - <?php else: ?> - <?php print _('The directory you entered does not exist'); ?> + <?php elseif (isset($templateData['error']['dir']['codebase'])): ?> + <?php printf(_('You entered the %s directory. If you want to install a Gallery there, select the standard installation type. If you want to install a multisite, choose a different directory.'), basename($templateData['configPath'])); ?> + <?php elseif (isset($templateData['error']['dir']['missing'])): ?> + <?php if (!empty($templateData['openBasedir'])): ?> + <?php print _('The directory you entered either does not exist, or is prohibited by your webserver configuration. Your webserver is configured to only allow access to the following directories. You must choose a directory under one of these, or you must modify the <b>open_basedir</b> setting in your PHP configuration to allow a new directory.'); ?> + <ul> + <?php foreach ($templateData['openBasedir'] as $dir): ?> + <li> <?php print $dir ?> </li> + <?php endforeach; ?> + </ul> + <?php print _('If your multisite installation is in a different virtual host, you should contact your system administrator and request that they configure your <b>open_basedir</b> setting so that your virtual hosts can access each other.'); ?> + <?php else: ?> + <?php print _('The directory you entered does not exist'); ?> + <?php endif; ?> + <?php elseif (isset($templateData['error']['dir']['inaccessible'])): ?> + <?php print _('The directory you entered is not accessible. Change the permissions so that the webserver can read this directory.'); ?> + <?php elseif (isset($templateData['error']['dir']['creation_error'])): ?> + <?php print _('Unable to create multisite files. Ensure the files listed below are writeable.'); ?> + <br/><br/> + <?php foreach (array('main.php', 'index.php', 'embed.php', 'upgrade/index.php', 'lib/support/index.php (optional)') as $file): ?> + <?php printf('%s%s%s', $templateData['configPath'], DIRECTORY_SEPARATOR, $file) ?> <br/> + <?php endforeach; ?> <?php endif; ?> - <?php elseif (isset($templateData['error']['inaccessible_dir'])): ?> - <?php print _('The directory you entered is not accessible. Change the permissions so that the webserver can read this directory.'); ?> - <?php elseif (isset($templateData['error']['creation_error'])): ?> - <?php print _('Unable to create multisite files. Ensure the files listed below are writeable.'); ?> - <br/><br/> - <?php foreach (array('main.php', 'index.php', 'embed.php', 'upgrade/index.php', 'lib/support/index.php (optional)') as $file): ?> - <?php printf('%s%s%s', $templateData['configPath'], DIRECTORY_SEPARATOR, $file) ?> <br/> - <?php endforeach; ?> - <?php endif; ?> </div> <br/> <?php endif; ?> @@ -69,6 +69,17 @@ <input type="text" id="dir" name="configPath" size="50" value="<?php print $templateData['configPath'] ?>" autocomplete="off" <?php if (!$templateData['isMultisite']) print 'class="disabled" disabled="disabled"' ?>/> + <?php if (isset($templateData['error']['uri']['missing'])): ?> + <div class="error" style="margin-top: 1em; padding-top: 0.8em; padding-bottom: 0.9em"> + <?php print _('You must provide the URL for your new multisite'); ?> + </div> + <?php endif; ?> + <p> + <?php print _('URL for the new Gallery installation (example: http://example.com/gallery2/main.php) ') ?> + </p> + <input type="text" id="url" name="baseUri" size="50" + value="<?php print $templateData['baseUri'] ?>" + <?php if (!$templateData['isMultisite']) print 'class="disabled" disabled="disabled"' ?>/> <script type="text/javascript"> // <![CDATA[ YAHOO.util.Event.addListener( @@ -80,11 +91,13 @@ document.getElementById('linkContinue').style.display = m ? 'none' : 'inline'; document.getElementById('linkSelect').style.display = m ? 'inline' : 'none'; var dirEl = document.getElementById('dir'); + var urlEl = document.getElementById('url'); dirEl.disabled = m ? '' : 'disabled'; + urlEl.disabled = m ? '' : 'disabled'; if (m) { - YAHOO.util.Dom.removeClass(dirEl, 'disabled'); + YAHOO.util.Dom.removeClass(Array(dirEl, urlEl), 'disabled'); } else { - YAHOO.util.Dom.addClass(dirEl, 'disabled'); + YAHOO.util.Dom.addClass(Array(dirEl, urlEl), 'disabled'); } } // ]]> @@ -98,5 +111,5 @@ <?php printf(_('Continue to Step %d»'), $stepNumber + 1) ?></span></a> <a href="javascript:document.forms[0].submit()"<?php if (!$templateData['isMultisite']) print ' style="display:none"' ?> id="linkSelect" class="btn continue"><i></i><span><span></span><i></i> - <?php print _('Select Directory') ?></span></a> + <?php print _('Select Directory and URL') ?></span></a> </div> Modified: trunk/gallery2/modules/core/CoreModuleExtras.inc =================================================================== --- trunk/gallery2/modules/core/CoreModuleExtras.inc 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/modules/core/CoreModuleExtras.inc 2008-04-13 06:34:38 UTC (rev 17581) @@ -2545,6 +2545,8 @@ if ($ret) { return $ret; } + case '1.2.32': + /* Set the default baseUri in config.php */ case 'end of upgrade path': /* @@ -2890,6 +2892,15 @@ case '1.2.29': case '1.2.30': case '1.2.31': + case '1.2.32': + /* Change the baseUri if it's not set. */ + $urlGenerator =& $gallery->getUrlGenerator(); + $urlPath = preg_replace('|^(.*/)upgrade/index.php.*$|s', '$1', + $urlGenerator->getCurrentUrl()) . GALLERY_MAIN_PHP; + $edit = array(); + $edit['regexp'] = '{\$gallery->setConfig\(\'baseUri\', \'\'\);}s'; + $edit['replacement'] = '$gallery->setConfig(\'baseUri\', \'' . $urlPath . '\');'; + $configChanges[] = array('remove' => array(), 'add' => array(), 'edit' => array($edit)); case 'end of upgrade path': /* Modified: trunk/gallery2/modules/core/module.inc =================================================================== --- trunk/gallery2/modules/core/module.inc 2008-04-13 00:38:13 UTC (rev 17580) +++ trunk/gallery2/modules/core/module.inc 2008-04-13 06:34:38 UTC (rev 17581) @@ -34,7 +34,7 @@ $this->setGalleryVersion('2.3-svn'); /* Don't forget to update CoreModuleExtras::upgrade and _prepareConfigUpgrade too! */ - $this->setVersion('1.2.32'); + $this->setVersion('1.2.33'); $this->_templateVersion = 1; $this->setDescription($gallery->i18n('Gallery 2 Core Module')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |