use Dotclear VAR as default repository dir, fix #7
This commit is contained in:
parent
f877746e3b
commit
e176ff703f
4 changed files with 35 additions and 14 deletions
|
@ -57,11 +57,11 @@ class Config
|
|||
$pack_overwrite = !empty($_POST['pack_overwrite']);
|
||||
$pack_filename = (string) $_POST['pack_filename'];
|
||||
$secondpack_filename = (string) $_POST['secondpack_filename'];
|
||||
$pack_repository = (string) path::real($_POST['pack_repository'], false);
|
||||
$pack_repository = (string) $_POST['pack_repository'];
|
||||
$pack_excludefiles = (string) $_POST['pack_excludefiles'];
|
||||
|
||||
$check = Utils::is_configured(
|
||||
$pack_repository,
|
||||
Utils::getRepositoryDir($pack_repository),
|
||||
$pack_filename,
|
||||
$secondpack_filename
|
||||
);
|
||||
|
@ -110,7 +110,7 @@ class Config
|
|||
__('Preconization: %s'),
|
||||
dcCore::app()->blog->public_path ?
|
||||
dcCore::app()->blog->public_path : __("Blog's public directory")
|
||||
) . '</p>
|
||||
) . '<br />' . __('Leave it empty to use Dotclear VAR directory') . '</p>
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
|
|
|
@ -248,7 +248,7 @@ class Core
|
|||
{
|
||||
$c = DC_TPL_CACHE . '/packman';
|
||||
if (!file_exists($c)) {
|
||||
@mkdir($c);
|
||||
@files::makeDir($c);
|
||||
}
|
||||
if (!is_writable($c)) {
|
||||
throw new Exception(__('Failed to get temporary directory'));
|
||||
|
|
|
@ -62,6 +62,7 @@ class Manage
|
|||
|
||||
# Settings
|
||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
||||
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
||||
|
||||
# Modules
|
||||
if (!(dcCore::app()->themes instanceof dcThemes)) {
|
||||
|
@ -73,7 +74,7 @@ class Manage
|
|||
|
||||
# Rights
|
||||
$is_writable = Utils::is_writable(
|
||||
$s->get('pack_repository'),
|
||||
$dir,
|
||||
$s->get('pack_filename')
|
||||
);
|
||||
$is_editable = !empty($type)
|
||||
|
@ -91,8 +92,8 @@ class Manage
|
|||
$modules = Core::getPackages(self::$themes_path);
|
||||
} else {
|
||||
$modules = array_merge(
|
||||
Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('pack_filename'))),
|
||||
Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('secondpack_filename')))
|
||||
Core::getPackages(dirname($dir . '/' . $s->get('pack_filename'))),
|
||||
Core::getPackages(dirname($dir . '/' . $s->get('secondpack_filename')))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -141,7 +142,6 @@ class Manage
|
|||
$module['id'] = $id;
|
||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||
|
||||
$root = (string) $s->get('pack_repository');
|
||||
$files = [
|
||||
(string) $s->get('pack_filename'),
|
||||
(string) $s->get('secondpack_filename'),
|
||||
|
@ -154,7 +154,7 @@ class Manage
|
|||
# --BEHAVIOR-- packmanBeforeCreatePackage
|
||||
dcCore::app()->callBehavior('packmanBeforeCreatePackage', $module);
|
||||
|
||||
Core::pack($module, $root, $files, $overwrite, $exclude, $nocomment, $fixnewline);
|
||||
Core::pack($module, $dir, $files, $overwrite, $exclude, $nocomment, $fixnewline);
|
||||
|
||||
# --BEHAVIOR-- packmanAfterCreatePackage
|
||||
dcCore::app()->callBehavior('packmanAfterCreatePackage', $module);
|
||||
|
@ -224,7 +224,7 @@ class Manage
|
|||
|
||||
# Copy
|
||||
} elseif (strpos($action, 'copy_to_') !== false) {
|
||||
$dest = (string) $s->get('pack_repository');
|
||||
$dest = (string) $dir;
|
||||
if ($action == 'copy_to_plugins') {
|
||||
$dest = self::$plugins_path;
|
||||
} elseif ($action == 'copy_to_themes') {
|
||||
|
@ -250,7 +250,7 @@ class Manage
|
|||
|
||||
# Move
|
||||
} elseif (strpos($action, 'move_to_') !== false) {
|
||||
$dest = (string) $s->get('pack_repository');
|
||||
$dest = (string) $dir;
|
||||
if ($action == 'move_to_plugins') {
|
||||
$dest = self::$plugins_path;
|
||||
} elseif ($action == 'move_to_themes') {
|
||||
|
@ -288,9 +288,10 @@ class Manage
|
|||
|
||||
# Settings
|
||||
$s = dcCore::app()->blog->settings->get(Core::id());
|
||||
$dir = Utils::getRepositoryDir($s->get('pack_repository'));
|
||||
|
||||
$is_configured = Utils::is_configured(
|
||||
$s->get('pack_repository'),
|
||||
$dir,
|
||||
$s->get('pack_filename'),
|
||||
$s->get('secondpack_filename')
|
||||
);
|
||||
|
@ -320,8 +321,8 @@ class Manage
|
|||
'</div>';
|
||||
} else {
|
||||
$repo_path_modules = array_merge(
|
||||
Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('pack_filename'))),
|
||||
Core::getPackages(dirname($s->get('pack_repository') . '/' . $s->get('secondpack_filename')))
|
||||
Core::getPackages(dirname($dir . '/' . $s->get('pack_filename'))),
|
||||
Core::getPackages(dirname($dir . '/' . $s->get('secondpack_filename')))
|
||||
);
|
||||
$plugins_path_modules = Core::getPackages(self::$plugins_path);
|
||||
$themes_path_modules = Core::getPackages(self::$themes_path);
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace Dotclear\Plugin\pacKman;
|
|||
use dcCore;
|
||||
|
||||
/* clearbricks ns */
|
||||
use dt;
|
||||
use files;
|
||||
use form;
|
||||
use html;
|
||||
use path;
|
||||
|
@ -63,6 +65,20 @@ class Utils
|
|||
return !(empty($path) || empty($file) || !is_writable(dirname($path . '/' . $file)));
|
||||
}
|
||||
|
||||
public static function getRepositoryDir($dir)
|
||||
{
|
||||
if (empty($dir)) {
|
||||
try {
|
||||
$dir = DC_VAR . DIRECTORY_SEPARATOR . 'packman';
|
||||
@files::makeDir($dir, true);
|
||||
} catch (Exception $e) {
|
||||
$dir = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
|
||||
public static function getModules(string $type, ?string $id = null): ?array
|
||||
{
|
||||
$type = $type == 'themes' ? 'themes' : 'plugins';
|
||||
|
@ -187,6 +203,7 @@ class Utils
|
|||
'<th class="nowrap">' . __('Version') . '</th>' .
|
||||
'<th class="nowrap">' . __('Name') . '</th>' .
|
||||
'<th class="nowrap">' . __('File') . '</th>' .
|
||||
'<th class="nowrap">' . __('Date') . '</th>' .
|
||||
'</tr>';
|
||||
|
||||
$dup = [];
|
||||
|
@ -218,6 +235,9 @@ class Utils
|
|||
]) . '" title="' . __('Download') . '">' .
|
||||
html::escapeHTML(basename($module['root'])) . '</a>' .
|
||||
'</td>' .
|
||||
'<td class="nowrap">' .
|
||||
html::escapeHTML(dt::str(__('%Y-%m-%d %H:%M'), (int) @filemtime($module['root']))) .
|
||||
'</td>' .
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue