diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-03-19 12:10:48 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-03-19 12:10:48 +0100 |
commit | 8d42cd79ea294fc836eca94c7bc469d5bad5e8eb (patch) | |
tree | 7ead6353ce259c3c6db0b7afed0ffe920a5947ce | |
parent | c6571d58ba8f02fc1afaeb54319f4289da993d02 (diff) | |
parent | 7ff009d9323a4431c9463fc8e5bfb3ada17f33e0 (diff) | |
download | rpg-8d42cd79ea294fc836eca94c7bc469d5bad5e8eb.tar.gz rpg-8d42cd79ea294fc836eca94c7bc469d5bad5e8eb.tar.bz2 |
Merge pull request #622 from splitbrain/disablefeed
allow disabling the rss feed
-rw-r--r-- | feed.php | 7 | ||||
-rw-r--r-- | inc/template.php | 22 | ||||
-rw-r--r-- | lib/plugins/config/lang/en/lang.php | 1 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.class.php | 152 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.metadata.php | 2 |
5 files changed, 146 insertions, 38 deletions
@@ -15,6 +15,13 @@ require_once(DOKU_INC.'inc/init.php'); //close session session_write_close(); +//feed disabled? +if(!actionOK('rss')) { + http_status(404); + echo '<error>RSS feed is disabled.</error>'; + exit; +} + // get params $opt = rss_parseOptions(); diff --git a/inc/template.php b/inc/template.php index 8bd3234cc..a3808aa81 100644 --- a/inc/template.php +++ b/inc/template.php @@ -318,15 +318,17 @@ function tpl_metaheaders($alt = true) { } if($alt) { - $head['link'][] = array( - 'rel' => 'alternate', 'type'=> 'application/rss+xml', - 'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php' - ); - $head['link'][] = array( - 'rel' => 'alternate', 'type'=> 'application/rss+xml', - 'title'=> $lang['currentns'], - 'href' => DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace'] - ); + if(actionOK('rss')) { + $head['link'][] = array( + 'rel' => 'alternate', 'type'=> 'application/rss+xml', + 'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php' + ); + $head['link'][] = array( + 'rel' => 'alternate', 'type'=> 'application/rss+xml', + 'title'=> $lang['currentns'], + 'href' => DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace'] + ); + } if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) { $head['link'][] = array( 'rel' => 'edit', @@ -335,7 +337,7 @@ function tpl_metaheaders($alt = true) { ); } - if($ACT == 'search') { + if(actionOK('rss') && $ACT == 'search') { $head['link'][] = array( 'rel' => 'alternate', 'type'=> 'application/rss+xml', 'title'=> $lang['searchresult'], diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php index 66d4dc356..5e5218aff 100644 --- a/lib/plugins/config/lang/en/lang.php +++ b/lib/plugins/config/lang/en/lang.php @@ -101,6 +101,7 @@ $lang['disableactions_subscription'] = 'Subscribe/Unsubscribe'; $lang['disableactions_wikicode'] = 'View source/Export Raw'; $lang['disableactions_profile_delete'] = 'Delete Own Account'; $lang['disableactions_other'] = 'Other actions (comma separated)'; +$lang['disableactions_rss'] = 'XML Syndication (RSS)'; $lang['auth_security_timeout'] = 'Authentication Security Timeout (seconds)'; $lang['securecookie'] = 'Should cookies set via HTTPS only be sent via HTTPS by the browser? Disable this option when only the login of your wiki is secured with SSL but browsing the wiki is done unsecured.'; $lang['remote'] = 'Enable the remote API system. This allows other applications to access the wiki via XML-RPC or other mechanisms.'; diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 05f8470f7..8dae23110 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -18,6 +18,7 @@ if (!class_exists('configuration')) { var $_heading = ''; // heading string written at top of config file - don't include comment indicators var $_loaded = false; // set to true after configuration files are loaded var $_metadata = array(); // holds metadata describing the settings + /** @var setting[] */ var $setting = array(); // array of setting objects var $locked = false; // configuration is considered locked if it can't be updated var $show_disabled_plugins = false; @@ -31,8 +32,10 @@ if (!class_exists('configuration')) { /** * constructor + * + * @param string $datafile path to config metadata file */ - function configuration($datafile) { + public function configuration($datafile) { global $conf, $config_cascade; if (!@file_exists($datafile)) { @@ -55,7 +58,10 @@ if (!class_exists('configuration')) { $this->retrieve_settings(); } - function retrieve_settings() { + /** + * Retrieve and stores settings in setting[] attribute + */ + public function retrieve_settings() { global $conf; $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class'); @@ -100,7 +106,15 @@ if (!class_exists('configuration')) { } } - function save_settings($id, $header='', $backup=true) { + /** + * Stores setting[] array to file + * + * @param string $id Name of plugin, which saves the settings + * @param string $header Text at the top of the rewritten settings file + * @param bool $backup backup current file? (remove any existing backup) + * @return bool succesful? + */ + public function save_settings($id, $header='', $backup=true) { global $conf; if ($this->locked) return false; @@ -138,13 +152,19 @@ if (!class_exists('configuration')) { /** * Update last modified time stamp of the config file */ - function touch_settings(){ + public function touch_settings(){ if ($this->locked) return false; $file = end($this->_local_files); return @touch($file); } - function _read_config_group($files) { + /** + * Read and merge given config files + * + * @param array $files file paths + * @return array config settings + */ + protected function _read_config_group($files) { $config = array(); foreach ($files as $file) { $config = array_merge($config, $this->_read_config($file)); @@ -154,7 +174,10 @@ if (!class_exists('configuration')) { } /** - * return an array of config settings + * Return an array of config settings + * + * @param string $file file path + * @return array config settings */ function _read_config($file) { @@ -206,7 +229,14 @@ if (!class_exists('configuration')) { return $config; } - function _out_header($id, $header) { + /** + * Returns header of rewritten settings file + * + * @param string $id plugin name of which generated this output + * @param string $header additional text for at top of the file + * @return string text of header + */ + protected function _out_header($id, $header) { $out = ''; if ($this->_format == 'php') { $out .= '<'.'?php'."\n". @@ -221,7 +251,12 @@ if (!class_exists('configuration')) { return $out; } - function _out_footer() { + /** + * Returns footer of rewritten settings file + * + * @return string text of footer + */ + protected function _out_footer() { $out = ''; if ($this->_format == 'php') { $out .= "\n// end auto-generated content\n"; @@ -230,9 +265,13 @@ if (!class_exists('configuration')) { return $out; } - // configuration is considered locked if there is no local settings filename - // or the directory its in is not writable or the file exists and is not writable - function _is_locked() { + /** + * Configuration is considered locked if there is no local settings filename + * or the directory its in is not writable or the file exists and is not writable + * + * @return bool true: locked, false: writable + */ + protected function _is_locked() { if (!$this->_local_files) return true; $local = $this->_local_files[0]; @@ -247,7 +286,7 @@ if (!class_exists('configuration')) { * not used ... conf's contents are an array! * reduce any multidimensional settings to one dimension using CM_KEYMARKER */ - function _flatten($conf,$prefix='') { + protected function _flatten($conf,$prefix='') { $out = array(); @@ -264,6 +303,12 @@ if (!class_exists('configuration')) { return $out; } + /** + * Returns array of plugin names + * + * @return array plugin names + * @triggers PLUGIN_CONFIG_PLUGINLIST event + */ function get_plugin_list() { if (is_null($this->_plugin_list)) { $list = plugin_list('',$this->show_disabled_plugins); @@ -281,6 +326,9 @@ if (!class_exists('configuration')) { /** * load metadata for plugin and template settings + * + * @param string $tpl name of active template + * @return array metadata of settings */ function get_plugintpl_metadata($tpl){ $file = '/conf/metadata.php'; @@ -321,7 +369,10 @@ if (!class_exists('configuration')) { } /** - * load default settings for plugins and templates + * Load default settings for plugins and templates + * + * @param string $tpl name of active template + * @return array default settings */ function get_plugintpl_default($tpl){ $file = '/conf/default.php'; @@ -368,7 +419,11 @@ if (!class_exists('setting')) { static protected $_validCautions = array('warning','danger','security'); - function setting($key, $params=null) { + /** + * @param string $key + * @param array|null $params array with metadata of setting + */ + public function setting($key, $params=null) { $this->_key = $key; if (is_array($params)) { @@ -379,9 +434,13 @@ if (!class_exists('setting')) { } /** - * receives current values for the setting $key + * Receives current values for the setting $key + * + * @param mixed $default default setting value + * @param mixed $local local setting value + * @param mixed $protected protected setting value */ - function initialize($default, $local, $protected) { + public function initialize($default, $local, $protected) { if (isset($default)) $this->_default = $default; if (isset($local)) $this->_local = $local; if (isset($protected)) $this->_protected = $protected; @@ -395,7 +454,7 @@ if (!class_exists('setting')) { * @param mixed $input the new value * @return boolean true if changed, false otherwise (incl. on error) */ - function update($input) { + public function update($input) { if (is_null($input)) return false; if ($this->is_protected()) return false; @@ -413,9 +472,13 @@ if (!class_exists('setting')) { } /** - * @return array(string $label_html, string $input_html) + * Build html for label and input of setting + * + * @param DokuWiki_Plugin $plugin object of config plugin + * @param bool $echo true: show inputted value, when error occurred, otherwise the stored setting + * @return array(string $label_html, string $input_html) */ - function html(&$plugin, $echo=false) { + public function html(&$plugin, $echo=false) { $value = ''; $disable = ''; @@ -439,9 +502,9 @@ if (!class_exists('setting')) { } /** - * generate string to save setting value to file according to $fmt + * Generate string to save setting value to file according to $fmt */ - function out($var, $fmt='php') { + public function out($var, $fmt='php') { if ($this->is_protected()) return ''; if (is_null($this->_local) || ($this->_default == $this->_local)) return ''; @@ -457,17 +520,45 @@ if (!class_exists('setting')) { return $out; } - function prompt(&$plugin) { + /** + * Returns the localized prompt + * + * @param DokuWiki_Plugin $plugin object of config plugin + * @return string text + */ + public function prompt(&$plugin) { $prompt = $plugin->getLang($this->_key); if (!$prompt) $prompt = htmlspecialchars(str_replace(array('____','_'),' ',$this->_key)); return $prompt; } - function is_protected() { return !is_null($this->_protected); } - function is_default() { return !$this->is_protected() && is_null($this->_local); } - function error() { return $this->_error; } + /** + * Is setting protected + * + * @return bool + */ + public function is_protected() { return !is_null($this->_protected); } + + /** + * Is setting the default? + * + * @return bool + */ + public function is_default() { return !$this->is_protected() && is_null($this->_local); } + + /** + * Has an error? + * + * @return bool + */ + public function error() { return $this->_error; } - function caution() { + /** + * Returns caution + * + * @return bool|string caution string, otherwise false for invalid caution + */ + public function caution() { if (!empty($this->_caution)) { if (!in_array($this->_caution, setting::$_validCautions)) { trigger_error('Invalid caution string ('.$this->_caution.') in metadata for setting "'.$this->_key.'"', E_USER_WARNING); @@ -486,7 +577,14 @@ if (!class_exists('setting')) { return false; } - function _out_key($pretty=false,$url=false) { + /** + * Returns setting key, eventually with referer to config: namespace at dokuwiki.org + * + * @param bool $pretty create nice key + * @param bool $url provide url to config: namespace + * @return string key + */ + public function _out_key($pretty=false,$url=false) { if($pretty){ $out = str_replace(CM_KEYMARKER,"»",$this->_key); if ($url && !strstr($out,'»')) {//provide no urls for plugins, etc. diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index 69cc0df01..aaa32cd70 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -138,7 +138,7 @@ $meta['manager'] = array('string'); $meta['profileconfirm'] = array('onoff'); $meta['rememberme'] = array('onoff'); $meta['disableactions'] = array('disableactions', - '_choices' => array('backlink','index','recent','revisions','search','subscription','register','resendpwd','profile','profile_delete','edit','wikicode','check'), + '_choices' => array('backlink','index','recent','revisions','search','subscription','register','resendpwd','profile','profile_delete','edit','wikicode','check', 'rss'), '_combine' => array('subscription' => array('subscribe','unsubscribe'), 'wikicode' => array('source','export_raw'))); $meta['auth_security_timeout'] = array('numeric'); $meta['securecookie'] = array('onoff'); |