Skip to content

Commit

Permalink
addon upload: assets can be replaced with those from the root assets …
Browse files Browse the repository at this point in the history
…folder
  • Loading branch information
gharlan committed Jan 22, 2012
1 parent 5e8e620 commit a505cfc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
6 changes: 5 additions & 1 deletion redaxo/src/addons/install/lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class rex_install_helper
{
static public function copyDirToArchive($dir, $archive, $basename = null)
static public function copyDirToArchive($dir, $archive, $basename = null, $excludeDirs = null)
{
$dir = rtrim($dir, '/\\');
$basename = $basename ?: basename($dir);
Expand All @@ -11,6 +11,10 @@ static public function copyDirToArchive($dir, $archive, $basename = null)
$files = array();
$iterator = rex_dir::recursiveIterator($dir, rex_dir_recursive_iterator::LEAVES_ONLY);
$iterator->excludeVersionControl()->excludeTemporaryFiles();
if($excludeDirs)
{
$iterator->excludeDirs($excludeDirs, false);
}
foreach($iterator as $path => $file)
{
$files[str_replace($dir, $basename, $path)] = $path;
Expand Down
1 change: 1 addition & 0 deletions redaxo/src/addons/install/plugins/packages/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install_packages_file_add = Datei hinzufügen
install_packages_file_edit = Datei aktualisieren
install_packages_send = Senden
install_packages_upload_file = Zip-Datei erstellen und hochladen
install_packages_replace_assets = Assets aus dem Root-Assets-Ordner nehmen

install_packages_info_addon_downloaded = AddOn "{0}" wurde heruntergeladen!
install_packages_warning_not_downloaded = AddOn "{0}" konnte aus folgendem Grund nicht heruntergeladen werden:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public function execute()
if($uploadFile)
{
$archive = rex_path::cache('install/'. md5($addonkey . time()) .'.zip');
rex_install_helper::copyDirToArchive(rex_path::addon($addonkey), $archive);
$replaceAssets = isset($upload['replace_assets']) && $upload['replace_assets'];
$exclude = $replaceAssets ? array('assets') : null;
rex_install_helper::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
if($replaceAssets)
rex_install_helper::copyDirToArchive(rex_path::addonAssets($addonkey), $archive, $addonkey .'/assets');
$file['checksum'] = md5_file($archive);
}
rex_install_webservice::post(rex_install_packages::getPath('?package='.$addonkey.'&file_id='.rex_request('file', 'int', 0)), array('file' => $file), $archive);
Expand Down
55 changes: 35 additions & 20 deletions redaxo/src/addons/install/plugins/packages/pages/upload.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,60 @@
<div class="rex-form">
<form action="'. sprintf($path, 'upload') .'" method="post">
<fieldset>';


$formElements = array();

$n = array();
$n['label'] = '<label for="install-packages-upload-version">'. $this->i18n('version') .'</label>';
$n['field'] = '<span id="install-packages-upload-version" class="rex-form-read">'. ($new ? $newVersion : $file['version']) .'</span>
<input type="hidden" name="upload[oldversion]" value="'. $file['version'] .'" />';
$formElements[] = $n;

$n = array();
$n['label'] = '<label for="install-packages-upload-redaxo">REDAXO</label>';
$n['field'] = $redaxo_select->get();
$formElements[] = $n;

$n = array();
$n['label'] = '<label for="install-packages-upload-description">'. $this->i18n('description') .'</label>';
$n['field'] = '<textarea id="install-packages-upload-description" name="upload[description]" cols="50" rows="15">'. $file['description'] .'</textarea>';
$formElements[] = $n;

$n = array();
$n['reverse'] = true;
$n['label'] = '<label for="install-packages-upload-status">'. $this->i18n('online') .'</label>';
$n['field'] = '<input id="install-packages-upload-status" type="checkbox" name="upload[status]" value="1" '. (!$new && $file['status'] ? 'checked="checked" ' : '') .'/>';
$formElements[] = $n;

$n = array();
$n['reverse'] = true;
$n['label'] = '<label for="install-packages-upload-upload-file">'. $this->i18n('upload_file') .'</label>'. $hiddenField .'';
$n['field'] = '<input id="install-packages-upload-upload-file" type="checkbox" name="upload[upload_file]" value="1" '. ($new ? 'checked="checked" ' : '') . $uploadCheckboxDisabled .'/>';
$formElements[] = $n;


if(rex_addon::get($addonkey)->isInstalled() && is_dir(rex_path::addonAssets($addonkey)))
{
$n = array();
$n['reverse'] = true;
$n['label'] = '<label for="install-packages-upload-replace-assets">'. $this->i18n('replace_assets') .'</label>'. $hiddenField .'';
$n['field'] = '<input id="install-packages-upload-replace-assets" type="checkbox" name="upload[replace_assets]" value="1" '. ($new ? '' : 'disabled="disabled" ') .'/>';
$formElements[] = $n;
}

$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('form');

$formElements = array();
$n = array();
$n['field'] = '<input id="install-packages-upload-send" type="submit" name="upload[send]" value="'. $this->i18n('send') .'" />';
$formElements[] = $n;

$n = array();
$n['field'] = '<input id="install-packages-delete" type="button" value="'. $this->i18n('delete') .'" onclick="if(confirm(\''. $this->i18n('delete') .' ?\')) location.href=\''. sprintf($path, 'delete') .'\';" />';
$formElements[] = $n;

$fragment = new rex_fragment();
$fragment->setVar('columns', 2, false);
$fragment->setVar('elements', $formElements, false);
Expand All @@ -112,18 +121,24 @@
</form>
</div>';

if(!$new && $newVersion != $file['version'])
if(!$new)
{
echo '
<script type="text/javascript"><!--
jQuery(function($) {
$("#install-packages-upload-upload-file").change(function(){
if($(this).is(":checked"))
$("#install-packages-upload-version").html("<span class=\'rex-strike\'>'. $file['version'] .'</span> <strong>'. $newVersion .'</strong>");
else
$("#install-packages-upload-version").html("'. $file['version'] .'");
});
$("#install-packages-upload-upload-file").change(function(){
if($(this).is(":checked"))
{
'. ($newVersion != $file['version'] ? '$("#install-packages-upload-version").html("<span class=\'rex-strike\'>'. $file['version'] .'</span> <strong>'. $newVersion .'</strong>");' : '') .'
$("#install-packages-upload-replace-assets").removeAttr("disabled");
}
else
{
$("#install-packages-upload-version").html("'. $file['version'] .'");
$("#install-packages-upload-replace-assets").attr("disabled", "disabled").removeAttr("checked");
}
});
});
//--></script>';
Expand All @@ -138,7 +153,7 @@

$content .= '
<h2>'. $addonkey .'</h2>
<h3>'. $this->i18n('information') .'</h3>
<table class="rex-table">
<tbody>
Expand All @@ -160,7 +175,7 @@
</tr>
</tbody>
</table>
<h3>'. $this->i18n('files') .'</h3>
<table class="rex-table">
<thead>
Expand Down

0 comments on commit a505cfc

Please sign in to comment.