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('pluginsToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']); $core->addBehavior('themesToolsHeaders', ['tweakStoresBehaviors', 'modulesToolsHeaders']); $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); } # addd some js public static function modulesToolsHeaders(dcCore $core, $plugin) { return dcPage::jsVars(['dotclear.ts_copied' => __('Copied to clipboard')]) . dcPage::jsLoad(dcPage::getPF('tweakStores/js/admin.js')); } # 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) { $combo = self::comboModules($modules, $excludes); # zip file url pattern $file_pattern = $core->blog->settings->tweakStores->file_pattern; # check dcstore repo $file_content = ''; if (!empty($_POST['checkxml_id']) && in_array($_POST['checkxml_id'], $combo)) { if (empty($modules[$_POST['checkxml_id']]['repository'])) { $file_content = __('This module has no repository set in its _define.php file.'); } else { try { if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $modules[$_POST['checkxml_id']]['repository']); curl_setopt($ch, CURLOPT_REFERER, $modules[$_POST['checkxml_id']]['repository']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $file_content = curl_exec($ch); curl_close($ch); } else { $file_content = file_get_contents($modules[$_POST['checkxml_id']]['repository']); } } catch (Exception $e) { $file_content = __('Failed to read third party repository'); } } } # generate xml code if (!empty($_POST['buildxml_id']) && in_array($_POST['buildxml_id'], $combo)) { $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 '
' . implode(' ', $core->error->getErrors()) . '
'; } else { echo '' . __('File successfully written') . '
'; } } if (count($combo) < 2) { echo '' . form::textArea('file_xml', 165, 14, [ 'default' => html::escapeHTML(str_replace('><', ">\n<", $file_content)), 'class' => 'maximal', 'extra_html' => 'readonly="true"' ]) . '' . '