add write dcstore.xml from plugins tab
parent
43bd962b45
commit
ff2a17b264
36
_admin.php
36
_admin.php
|
@ -52,14 +52,25 @@ class tweakStoresBehaviors
|
|||
$plugins[$module['name'] . ' '. $module['version']] = $id;
|
||||
}
|
||||
|
||||
if (!empty($_POST['build_xml']) && !empty($_POST['buildxml_id']) && in_array($_POST['buildxml_id'], $plugins)) {
|
||||
if (!empty($_POST['buildxml_id']) && in_array($_POST['buildxml_id'], $plugins)) {
|
||||
$xml_content = tweakStores::generateXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern);
|
||||
}
|
||||
|
||||
if (!empty($_POST['write_xml'])) {
|
||||
if (empty($_POST['your_pwd']) || !$core->auth->checkPassword($_POST['your_pwd'])) {
|
||||
$core->error->add(__('Password verification failed'));
|
||||
} else {
|
||||
$ret = tweakStores::writeXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern);
|
||||
if (!empty(tweakStores::$failed)) {
|
||||
$core->error->add(implode(' ', tweakStores::$failed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo
|
||||
'<div class="multi-part" id="tweakStores" title="' . __('Tweak stores') . '">' .
|
||||
'<h3>' . __('Tweak third-party repositories') . '</h3>' .
|
||||
|
||||
/*
|
||||
'<form method="post" action="' . $core->adminurl->get('admin.plugins') . '#tweakStores" id="fetchxml" class="fieldset">' .
|
||||
'<h4>' . __('Update an existing plugin') . '</h4>' .
|
||||
'<p>' . __('Put URL to a dcstore.xml file for selected plugin to update it.') . '</p>' .
|
||||
|
@ -81,7 +92,7 @@ class tweakStoresBehaviors
|
|||
'<p><input type="submit" name="fetch_xml" value="' . __('Update') . '" />' .
|
||||
$core->formNonce() . '</p>' .
|
||||
'</form>' .
|
||||
|
||||
//*/
|
||||
'<form method="post" action="' . $core->adminurl->get('admin.plugins') . '#tweakStores" id="buildxml" class="fieldset">' .
|
||||
'<h4>' . __('Generate xml code') . '</h4>' .
|
||||
'<p>' . __('This help to generate content of dcstore.xml for seleted plugin.') . '</p>' .
|
||||
|
@ -89,10 +100,13 @@ class tweakStoresBehaviors
|
|||
form::combo('buildxml_id', $plugins, empty($_POST['buildxml_id']) ? '-' : html::escapeHTML($_POST['buildxml_id'])) .
|
||||
'</p>' .
|
||||
'<p><input type="submit" name="build_xml" value="' . __('Generate') . '" />' .
|
||||
$core->formNonce() . '</p>';
|
||||
$core->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
|
||||
if (!empty($_POST['buildxml_id'])) {
|
||||
echo '<h5>' . sprintf(__('Generated code for module : %s'), html::escapeHTML($_POST['buildxml_id'])) . '</h5>';
|
||||
echo
|
||||
'<form method="post" action="' . $core->adminurl->get('admin.plugins') . '#tweakStores" id="writexml" class="fieldset">' .
|
||||
'<h5>' . sprintf(__('Generated code for module : %s'), html::escapeHTML($_POST['buildxml_id'])) . '</h5>';
|
||||
|
||||
if (!empty(tweakStores::$failed)) {
|
||||
echo sprintf('<div class="warn">' . __('Failed to parse XML code : %s') . '</div>', implode(', ', tweakStores::$failed));
|
||||
|
@ -108,6 +122,11 @@ class tweakStoresBehaviors
|
|||
'<pre>' . form::textArea('gen_xml', 165, 14, html::escapeHTML($xml_content), 'maximal') . '</pre>';
|
||||
|
||||
if (!empty($file_pattern) && $modules[$_POST['buildxml_id']]['root_writable'] && $core->auth->isSuperAdmin()) {
|
||||
if ($core->error->flag()) {
|
||||
echo '<div class="error">' . implode(' ', $core->error->getErrors()) . '</div>';
|
||||
} elseif (!empty($_POST['write_xml'])) {
|
||||
echo '<div class="success">' . __('File successfully write') . '</div>';
|
||||
}
|
||||
echo
|
||||
'<p class="field"><label for="your_pwd2" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Your password:') . '</label> ' .
|
||||
form::password(['your_pwd', 'your_pwd2'], 20, 255,
|
||||
|
@ -116,9 +135,13 @@ class tweakStoresBehaviors
|
|||
'autocomplete' => 'current-password'
|
||||
]
|
||||
) . '</p>' .
|
||||
'<p><input type="submit" name="write_xml" value="' . __('Save to plugin directory') . '" />';
|
||||
'<p><input type="submit" name="write_xml" value="' . __('Save to plugin directory') . '" />' .
|
||||
form::hidden('buildxml_id', $_POST['buildxml_id']);
|
||||
}
|
||||
}
|
||||
echo
|
||||
'<p>' . $core->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
if (empty($file_pattern)) {
|
||||
echo '<p><a href="' . $core->adminurl->get('admin.plugins', ['module' => 'tweakStores', 'conf' => 1]) .'">' .
|
||||
|
@ -126,7 +149,6 @@ class tweakStoresBehaviors
|
|||
}
|
||||
|
||||
echo
|
||||
'</form>' .
|
||||
'</div>';
|
||||
}
|
||||
}
|
|
@ -105,38 +105,38 @@ class tweakStores
|
|||
|
||||
# name
|
||||
if (empty($module['name'])) {
|
||||
self::$failed[] = 'no module name';
|
||||
self::$failed[] = 'no module name set in _define.php';
|
||||
}
|
||||
$xml[] = sprintf('<name>%s</name>', html::escapeHTML($module['name']));
|
||||
|
||||
# version
|
||||
if (empty($module['version'])) {
|
||||
self::$failed[] = 'no module version';
|
||||
self::$failed[] = 'no module version set in _define.php';
|
||||
}
|
||||
$xml[] = sprintf('<version>%s</version>', html::escapeHTML($module['version']));
|
||||
|
||||
# author
|
||||
if (empty($module['author'])) {
|
||||
self::$failed[] = 'no module author';
|
||||
self::$failed[] = 'no module author set in _define.php';
|
||||
|
||||
}
|
||||
$xml[] = sprintf('<author>%s</author>', html::escapeHTML($module['author']));
|
||||
|
||||
# desc
|
||||
if (empty($module['desc'])) {
|
||||
self::$failed[] = 'no module description';
|
||||
self::$failed[] = 'no module description set in _define.php';
|
||||
}
|
||||
$xml[] = sprintf('<desc>%s</desc>', html::escapeHTML($module['desc']));
|
||||
|
||||
# repository
|
||||
if (empty($module['repository'])) {
|
||||
self::$failed[] = 'no repository';
|
||||
self::$failed[] = 'no repository set in _define.php';
|
||||
}
|
||||
|
||||
# file
|
||||
$file_pattern = self::parseFilePattern($id, $module, $file_pattern);
|
||||
if (empty($file_pattern)) {
|
||||
self::$failed[] = 'no zip file pattern';
|
||||
self::$failed[] = 'no zip file pattern set in Tweak Store configuration';
|
||||
}
|
||||
$xml[] = sprintf('<file>%s</file>', html::escapeHTML($file_pattern));
|
||||
|
||||
|
@ -169,6 +169,7 @@ class tweakStores
|
|||
|
||||
public static function writeXML($id, $module, $file_pattern)
|
||||
{
|
||||
self::$failed = [];
|
||||
if (!$module['root_writable']) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue