update('RsyncMultiHostPublisher', 'targets', $targets); } /** * Specify folders to exclude from the rsync * For example, you could exclude assets. * * @deprecated 3.2 Use the "RsyncMultiHostPublisher.excluded_folders" config setting instead */ public static function set_excluded_folders($folders) { Deprecation::notice('3.2', 'Use the "RsyncMultiHostPublisher.excluded_folders" config setting instead'); Config::inst()->update('RsyncMultiHostPublisher', 'excluded_folders', $folders); } public function publishPages($urls) { parent::publishPages($urls); $base = Director::baseFolder(); $framework = FRAMEWORK_DIR; // Get variable that can turn off the rsync component of publication if (isset($_GET['norsync']) && $_GET['norsync']) { return; } $extraArg = ""; $excludedFolders = Config::inst()->get('RsyncMultiHostPublisher', 'excluded_folders'); if ($excludedFolders) { foreach ($excludedFolders as $folder) { $extraArg .= " --exclude " . escapeshellarg($folder); } } $targets = Config::inst()->get('RsyncMultiHostPublisher', 'targets'); foreach ((array)$targets as $target) { // Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc $rsyncOutput = `cd $base; rsync -av -e ssh --exclude /.htaccess --exclude /web.config --exclude '*.php' --exclude '*.svn' --exclude '*.git' --exclude '*~' $extraArg --delete . $target`; // Then transfer "safe" PHP from the cache/ directory $rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' $extraArg --delete cache $target`; // Transfer framework/static-main.php to the target $rsyncOutput .= `cd $base; rsync -av -e ssh --delete $framework/static-main.php $target/$framework`; if (Config::inst()->get('StaticPublisher', 'echo_progress')) { echo $rsyncOutput; } } } }