auth->isSuperAdmin()) { return null; } # only if activated $core->blog->settings->addNamespace('tweakStores'); if (!$core->blog->settings->tweakStores->active) { return null; } # admin behaviors if ($core->blog->settings->tweakStores->packman) { $core->addBehavior('packmanBeforeCreatePackage', ['tweakStoresBehaviors', 'packmanBeforeCreatePackage']); } $core->addBehavior('pluginsToolsTabs', ['tweakStoresBehaviors', 'pluginsToolsTabs']); $core->addBehavior('themesToolsTabs', ['tweakStoresBehaviors', 'themesToolsTabs']); class tweakStoresBehaviors { # create dcstore.xml file on the fly when pack a module public static function packmanBeforeCreatePackage(dcCore $core, $module) { tweakStores::writeXML($module['id'], $module, $core->blog->settings->tweakStores->file_pattern); } # admin plugins page tab public static function pluginsToolsTabs(dcCore $core) { self::modulesToolsTabs($core, $core->plugins->getModules(), explode(',', DC_DISTRIB_PLUGINS), $core->adminurl->get('admin.plugins').'#tweakStores'); } # admin themes page tab public static function themesToolsTabs(dcCore $core) { self::modulesToolsTabs($core, $core->themes->getModules(), explode(',', DC_DISTRIB_THEMES), $core->adminurl->get('admin.blog.theme').'#tweakStores'); } # generic page tab protected static function modulesToolsTabs(dcCore $core, $modules, $excludes, $page_url) { $file_pattern = $core->blog->settings->tweakStores->file_pattern; $modules = new ArrayObject($modules); $combo = self::comboModules($modules, $excludes); # generate xml code if (!empty($_POST['buildxml_id']) && $modules->offsetExists($_POST['buildxml_id'])) { $xml_content = tweakStores::generateXML($_POST['buildxml_id'], $modules[$_POST['buildxml_id']], $file_pattern); } # write dcstore.xml file 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 '
' . '

' . __('Tweak third-party repositories') . '

'; if (count($combo) < 2) { echo '
' . __('There are no module to tweak') . '
' . '
'; return; } /* echo '
' . '

' . __('Update an existing module') . '

' . '

' . __('Put URL to a dcstore.xml file for selected module to update it.') . '

' . '

' . form::combo('xml_id', $combo) . '

' . '

' . form::field('xml_url', 40, 255, [ 'extra_html' => 'required placeholder="' . __('URL') . '"' ]) . '

' . '

' . form::password(['your_pwd', 'your_pwd1'], 20, 255, [ 'extra_html' => 'required placeholder="' . __('Password') . '"', 'autocomplete' => 'current-password' ] ) . '

' . '

' . $core->formNonce() . '

' . '
'; //*/ echo '
' . '

' . __('Generate xml code') . '

' . '

' . __('This help to generate content of dcstore.xml for seleted module.') . '

' . '

' . form::combo('buildxml_id', $combo, empty($_POST['buildxml_id']) ? '-' : html::escapeHTML($_POST['buildxml_id'])) . '

' . '

' . $core->formNonce() . '

' . '
'; if (!empty($_POST['buildxml_id'])) { echo '
' . '

' . sprintf(__('Generated code for module : %s'), html::escapeHTML($_POST['buildxml_id'])) . '

'; if (!empty(tweakStores::$failed)) { echo sprintf('
' . __('Failed to parse XML code : %s') . '
', implode(', ', tweakStores::$failed)); } if (!empty(tweakStores::$notice)) { echo sprintf('
' . __('Code is not fully filled : %s') . '
', implode(', ', tweakStores::$notice)); } if (!empty($xml_content)) { if (empty(tweakStores::$failed) && empty(tweakStores::$notice)) { echo '
' . __('Code is complete') . '
'; } echo '
' . form::textArea('gen_xml', 165, 14, html::escapeHTML($xml_content), 'maximal') . '
'; if (!empty($file_pattern) && $modules[$_POST['buildxml_id']]['root_writable'] && $core->auth->isSuperAdmin()) { if ($core->error->flag()) { echo '
' . implode(' ', $core->error->getErrors()) . '
'; } elseif (!empty($_POST['write_xml'])) { echo '
' . __('File successfully write') . '
'; } echo '

' . form::password(['your_pwd', 'your_pwd2'], 20, 255, [ 'extra_html' => 'required placeholder="' . __('Password') . '"', 'autocomplete' => 'current-password' ] ) . '

' . '

' . form::hidden('buildxml_id', $_POST['buildxml_id']); } } echo '

' . $core->formNonce() . '

' . '
'; } echo '

' . (empty($file_pattern) ? __('You must configure zip file pattern to complete xml code automaticaly.') : __('You can edit zip file pattern from configuration page.') ). '

' . ''; } # create list of module for combo and remove official modules protected static function comboModules(arrayObject $modules, $excludes) { $combo = [ __('Select a module') => '0']; foreach ($modules as $id => $module) { if (is_array($excludes) && in_array($id, $excludes)) { $modules->offsetUnset($id); continue; } $combo[$module['name'] . ' '. $module['version']] = $id; } return $combo; } }