From 9dacc1610f2dba12e80137ed023d3a5f38d8f899 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sun, 14 Jan 2007 16:21:08 +0000 Subject: [PATCH] Allow spartacus plugin to configure which repositories to connect to --- docs/NEWS | 3 + .../lang_en.inc.php | 3 + .../serendipity_event_spartacus.php | 90 ++++++++++++------- 3 files changed, 63 insertions(+), 33 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 82dc87a..e712fd5 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.2 () ------------------------------------------------------------------------ + * Update Spartacus plugin to allow configuring whether to fetch + Themes or Plugins, or only one/none of them (garvinhicking) + * Remove "View" option for drafted entries in the "Edit entries" section and replace with a "Preview" option. (garvinhicking) diff --git a/plugins/serendipity_event_spartacus/lang_en.inc.php b/plugins/serendipity_event_spartacus/lang_en.inc.php index 1657c22..3d6158b 100644 --- a/plugins/serendipity_event_spartacus/lang_en.inc.php +++ b/plugins/serendipity_event_spartacus/lang_en.inc.php @@ -37,3 +37,6 @@ @define('PLUGIN_EVENT_SPARTACUS_TRYCURL', 'Trying to use cURL library as fallback...'); @define('PLUGIN_EVENT_SPARTACUS_CURLFAIL', 'cURL library returned a failure, too.'); @define('PLUGIN_EVENT_SPARTACUS_HEALTFIREWALLED', 'It was not possible to download the required files from the Spartacus repository, but the health of our repository was retrievable. This means your provider uses a content-based firewall and does not allow to fetch PHP code over the web by using mod_security or other reverse proxies. You either need to ask your provider to turn this off, or you cannot use the Spartacus plugin and need to download files manually.'); + +@define('PLUGIN_EVENT_SPARTACUS_ENABLE_PLUGINS', 'Enable the use of Spartacus for fetching plugins?'); +@define('PLUGIN_EVENT_SPARTACUS_ENABLE_THEMES', 'Enable the use of Spartacus for fetching themes?'); \ No newline at end of file diff --git a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php index ddb950c..1c05c84 100644 --- a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php +++ b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php @@ -39,7 +39,7 @@ class serendipity_event_spartacus extends serendipity_event $propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '2.11'); + $propbag->add('version', '2.12'); $propbag->add('requirements', array( 'serendipity' => '0.9', 'smarty' => '2.6.7', @@ -56,7 +56,7 @@ class serendipity_event_spartacus extends serendipity_event 'backend_pluginlisting_header_upgrade' => true )); $propbag->add('groups', array('BACKEND_FEATURES')); - $propbag->add('configuration', array('mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir')); + $propbag->add('configuration', array('enable_plugins', 'enable_themes', 'mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir')); } function generate_content(&$title) { @@ -130,6 +130,20 @@ class serendipity_event_spartacus extends serendipity_event global $serendipity; switch($name) { + case 'enable_plugins': + $propbag->add('type', 'string'); + $propbag->add('name', PLUGIN_EVENT_SPARTACUS_ENABLE_PLUGINS); + $propbag->add('description', ''); + $propbag->add('default', 'false'); + break; + + case 'enable_themes': + $propbag->add('type', 'string'); + $propbag->add('name', PLUGIN_EVENT_SPARTACUS_ENABLE_THEMES); + $propbag->add('description', ''); + $propbag->add('default', 'true'); + break; + case 'chmod_files': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_SPARTACUS_CHMOD); @@ -839,10 +853,12 @@ class serendipity_event_spartacus extends serendipity_event if (isset($hooks[$event])) { switch($event) { case 'backend_pluginlisting_header': - echo '
'; - echo '' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '   '; - echo '' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . ' '; - echo '
'; + if (serendipity_db_bool($this->get_config('enable_plugins'))) { + echo '
'; + echo '' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '   '; + echo '' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . ' '; + echo '
'; + } return true; break; @@ -854,50 +870,58 @@ class serendipity_event_spartacus extends serendipity_event break; case 'backend_templates_fetchlist': - $eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template'); + if (serendipity_db_bool($this->get_config('enable_themes'))) { + $eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template'); + } return true; break; case 'backend_templates_fetchtemplate': - if (!empty($eventData['GET']['spartacus_fetch'])) { - $this->download( - $this->fetchOnline('template', true), - $eventData['GET']['theme'], - 'templates' - ); + if (serendipity_db_bool($this->get_config('enable_themes'))) { + if (!empty($eventData['GET']['spartacus_fetch'])) { + $this->download( + $this->fetchOnline('template', true), + $eventData['GET']['theme'], + 'templates' + ); + } } return false; break; case 'backend_plugins_fetchlist': - $type = (isset($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar'); - - $eventData = array( - 'pluginstack' => $this->buildList($this->fetchOnline($type), $type), - 'errorstack' => array(), - 'upgradeURI' => '&serendipity[spartacus_upgrade]=true', - 'baseURI' => '&serendipity[spartacus_fetch]=' . $type - ); + if (serendipity_db_bool($this->get_config('enable_plugins'))) { + $type = (isset($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar'); + + $eventData = array( + 'pluginstack' => $this->buildList($this->fetchOnline($type), $type), + 'errorstack' => array(), + 'upgradeURI' => '&serendipity[spartacus_upgrade]=true', + 'baseURI' => '&serendipity[spartacus_fetch]=' . $type + ); + } return true; break; case 'backend_plugins_fetchplugin': - if (!empty($eventData['GET']['spartacus_fetch'])) { - $baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']); - - if ($baseDir === false) { - $eventData['install'] = false; - } elseif (!empty($baseDir)) { - $eventData['GET']['pluginPath'] = $baseDir; - } else { - $eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin']; - } + if (serendipity_db_bool($this->get_config('enable_plugins'))) { + if (!empty($eventData['GET']['spartacus_fetch'])) { + $baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']); + + if ($baseDir === false) { + $eventData['install'] = false; + } elseif (!empty($baseDir)) { + $eventData['GET']['pluginPath'] = $baseDir; + } else { + $eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin']; + } - if ($eventData['GET']['spartacus_upgrade']) { - $eventData['install'] = false; + if ($eventData['GET']['spartacus_upgrade']) { + $eventData['install'] = false; + } } } -- 2.39.5