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