A free, self-hostable news aggregator…
Ajoute options pour désactiver partage
Marien Fressinaud1e9ccb1da9f3
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.phpindex 31885d30e..d4a821b66 100755--- a/app/controllers/configureController.php+++ b/app/controllers/configureController.php@@ -269,22 +269,18 @@ class configureController extends ActionController {public function sharingAction () {if (Request::isPost ()) {- $urlShaarli = Request::param ('shaarli', '');- $urlPoche = Request::param ('poche', '');- $urlDiaspora = Request::param ('diaspora', '');-- $this->view->conf->_urlShaarli ($urlShaarli);- $this->view->conf->_urlPoche ($urlPoche);- $this->view->conf->_urlDiaspora ($urlDiaspora);-- $values = array (- 'url_shaarli' => $this->view->conf->urlShaarli (),- 'url_poche' => $this->view->conf->urlPoche (),- 'url_diaspora' => $this->view->conf->urlDiaspora ()- );+ $this->view->conf->_sharing (array (+ 'shaarli' => Request::param ('shaarli', ''),+ 'poche' => Request::param ('poche', ''),+ 'diaspora' => Request::param ('diaspora', ''),+ 'twitter' => Request::param ('twitter', 'no') === 'yes',+ 'g+' => Request::param ('g+', 'no') === 'yes',+ 'facebook' => Request::param ('facebook', 'no') === 'yes',+ 'email' => Request::param ('email', 'no') === 'yes',+ ));$confDAO = new RSSConfigurationDAO ();- $confDAO->update ($values);+ $confDAO->update ($this->view->conf->sharing ());Session::_param ('conf', $this->view->conf);// notifdiff --git a/app/i18n/en.php b/app/i18n/en.phpindex 06c439283..fdfe865f3 100644--- a/app/i18n/en.php+++ b/app/i18n/en.php@@ -180,12 +180,19 @@ return array ('your_diaspora_pod' => 'Your Diaspora* pod','sharing' => 'Sharing','share' => 'Share',- 'by_email' => 'By mail',- 'on_shaarli' => 'On your Shaarli',+ 'by_email' => 'By email','optimize_bdd' => 'Optimize database','optimize_todo_sometimes' => 'To do occasionally to reduce size of database','theme' => 'Theme','more_information' => 'More information',+ 'activate_sharing' => 'Activate sharing',+ 'shaarli' => 'Shaarli',+ 'poche' => 'Poche',+ 'diaspora' => 'Diaspora*',+ 'twitter' => 'Twitter',+ 'g+' => 'Google+',+ 'facebook' => 'Facebook',+ 'email' => 'Email','article' => 'Article','title' => 'Title',diff --git a/app/i18n/fr.php b/app/i18n/fr.phpindex 1cc24a516..c2a9a030f 100644--- a/app/i18n/fr.php+++ b/app/i18n/fr.php@@ -180,12 +180,19 @@ return array ('your_diaspora_pod' => 'Votre pod Diaspora*','sharing' => 'Partage','share' => 'Partager',- 'by_email' => 'Par mail',- 'on_shaarli' => 'Sur votre Shaarli',+ 'by_email' => 'Par courriel','optimize_bdd' => 'Optimiser la base de données','optimize_todo_sometimes' => 'À faire de temps en temps pour réduire la taille de la BDD','theme' => 'Thème','more_information' => 'Plus d’informations',+ 'activate_sharing' => 'Activer le partage',+ 'shaarli' => 'Shaarli',+ 'poche' => 'Poche',+ 'diaspora' => 'Diaspora*',+ 'twitter' => 'Twitter',+ 'g+' => 'Google+',+ 'facebook' => 'Facebook',+ 'email' => 'Courriel','article' => 'Article','title' => 'Titre',diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.phpindex e6adf5c51..458362586 100755--- a/app/models/RSSConfiguration.php+++ b/app/models/RSSConfiguration.php@@ -17,9 +17,7 @@ class RSSConfiguration extends Model {private $shortcuts = array ();private $mail_login = '';private $mark_when = array ();- private $url_shaarli = '';- private $url_poche = '';- private $url_diaspora = '';+ private $sharing = array ();private $theme;private $anon_access;private $token;@@ -49,9 +47,7 @@ class RSSConfiguration extends Model {$this->_shortcuts ($confDAO->shortcuts);$this->_mailLogin ($confDAO->mail_login);$this->_markWhen ($confDAO->mark_when);- $this->_urlShaarli ($confDAO->url_shaarli);- $this->_urlPoche ($confDAO->url_poche);- $this->_urlDiaspora ($confDAO->url_diaspora);+ $this->_sharing ($confDAO->sharing);$this->_theme ($confDAO->theme);RSSThemes::setThemeId ($confDAO->theme);$this->_anonAccess ($confDAO->anon_access);@@ -117,14 +113,13 @@ class RSSConfiguration extends Model {public function markWhenScroll () {return $this->mark_when['scroll'];}- public function urlShaarli () {- return $this->url_shaarli;- }- public function urlPoche () {- return $this->url_poche;- }- public function urlDiaspora () {- return $this->url_diaspora;+ public function sharing ($key = false) {+ if ($key === false) {+ return $this->sharing;+ } elseif (isset ($this->sharing[$key])) {+ return $this->sharing[$key];+ }+ return false;}public function theme () {return $this->theme;@@ -258,31 +253,25 @@ class RSSConfiguration extends Model {$this->mark_when['site'] = $values['site'];$this->mark_when['scroll'] = $values['scroll'];}- public function _urlShaarli ($value) {- if (filter_var ($value, FILTER_VALIDATE_URL)) {- $this->url_shaarli = $value;- } elseif (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && ($value === filter_var($value, FILTER_SANITIZE_URL))) { //PHP bug #51192- $this->url_shaarli = $value;- } else {- $this->url_shaarli = '';- }- }- public function _urlPoche ($value) {- if (filter_var ($value, FILTER_VALIDATE_URL)) {- $this->url_poche = $value;- } elseif (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && ($value === filter_var($value, FILTER_SANITIZE_URL))) { //PHP bug #51192- $this->url_poche = $value;- } else {- $this->url_poche = '';- }- }- public function _urlDiaspora ($value) {- if (filter_var ($value, FILTER_VALIDATE_URL)) {- $this->url_diaspora = $value;- } elseif (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && ($value === filter_var($value, FILTER_SANITIZE_URL))) { //PHP bug #51192- $this->url_diaspora = $value;- } else {- $this->url_diaspora = '';+ public function _sharing ($values) {+ $are_url = array ('shaarli', 'poche', 'diaspora');+ foreach ($values as $key => $value) {+ if (in_array($key, $are_url)) {+ $is_url = (+ filter_var ($value, FILTER_VALIDATE_URL) ||+ (version_compare(PHP_VERSION, '5.3.3', '<') &&+ (strpos($value, '-') > 0) &&+ ($value === filter_var($value, FILTER_SANITIZE_URL)))+ ); //PHP bug #51192++ if (!$is_url) {+ $value = '';+ }+ } elseif(!is_bool ($value)) {+ $value = true;+ }++ $this->sharing[$key] = $value;}}public function _theme ($value) {@@ -361,9 +350,15 @@ class RSSConfigurationDAO extends Model_array {'site' => 'yes','scroll' => 'no');- public $url_shaarli = '';- public $url_poche = '';- public $url_diaspora = '';+ public $sharing = array (+ 'shaarli' => '',+ 'poche' => '',+ 'diaspora' => '',+ 'twitter' => true,+ 'g+' => true,+ 'facebook' => true,+ 'email' => true+ );public $theme = 'default';public $anon_access = 'no';public $token = '';@@ -411,7 +406,9 @@ class RSSConfigurationDAO extends Model_array {$this->old_entries = $this->array['old_entries'];}if (isset ($this->array['shortcuts'])) {- $this->shortcuts = array_merge ($this->shortcuts, $this->array['shortcuts']);+ $this->shortcuts = array_merge (+ $this->shortcuts, $this->array['shortcuts']+ );}if (isset ($this->array['mail_login'])) {$this->mail_login = $this->array['mail_login'];@@ -419,14 +416,10 @@ class RSSConfigurationDAO extends Model_array {if (isset ($this->array['mark_when'])) {$this->mark_when = $this->array['mark_when'];}- if (isset ($this->array['url_shaarli'])) {- $this->url_shaarli = $this->array['url_shaarli'];- }- if (isset ($this->array['url_poche'])) {- $this->url_poche = $this->array['url_poche'];- }- if (isset ($this->array['url_diaspora'])) {- $this->url_diaspora = $this->array['url_diaspora'];+ if (isset ($this->array['sharing'])) {+ $this->sharing = array_merge (+ $this->sharing, $this->array['sharing']+ );}if (isset ($this->array['theme'])) {$this->theme = $this->array['theme'];diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtmlindex 0345b9a8d..38abf9ad4 100644--- a/app/views/configure/sharing.phtml+++ b/app/views/configure/sharing.phtml@@ -10,7 +10,7 @@<?php echo Translate::t ('your_shaarli'); ?></label><div class="group-controls">- <input type="url" id="shaarli" name="shaarli" value="<?php echo $this->conf->urlShaarli (); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" />+ <input type="url" id="shaarli" name="shaarli" value="<?php echo $this->conf->sharing ('shaarli'); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" /><?php echo RSSThemes::icon('help'); ?> <a target="_blank" href="http://sebsauvage.net/wiki/doku.php?id=php:shaarli"><?php echo Translate::t ('more_information'); ?></a></div>@@ -21,7 +21,7 @@<?php echo Translate::t ('your_poche'); ?></label><div class="group-controls">- <input type="url" id="poche" name="poche" value="<?php echo $this->conf->urlPoche (); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" />+ <input type="url" id="poche" name="poche" value="<?php echo $this->conf->sharing ('poche'); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" /><?php echo RSSThemes::icon('help'); ?> <a target="_blank" href="http://www.inthepoche.com/"><?php echo Translate::t ('more_information'); ?></a></div>@@ -32,12 +32,28 @@<?php echo Translate::t ('your_diaspora_pod'); ?></label><div class="group-controls">- <input type="url" id="diaspora" name="diaspora" value="<?php echo $this->conf->urlDiaspora (); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" />+ <input type="url" id="diaspora" name="diaspora" value="<?php echo $this->conf->sharing ('diaspora'); ?>" placeholder="<?php echo Translate::t ('blank_to_disable'); ?>" size="64" /><?php echo RSSThemes::icon('help'); ?> <a target="_blank" href="https://diasporafoundation.org/"><?php echo Translate::t ('more_information'); ?></a></div></div>+ <div class="form-group">+ <label class="group-name" for="mail_login"><?php echo Translate::t ('activate_sharing'); ?></label>+ <div class="group-controls">+ <?php+ $services = array ('twitter', 'g+', 'facebook', 'email');++ foreach ($services as $service) {+ ?>+ <label class="checkbox" for="<?php echo $service; ?>">+ <input type="checkbox" name="<?php echo $service; ?>" id="<?php echo $service; ?>" value="yes"<?php echo $this->conf->sharing ($service) ? ' checked="checked"' : ''; ?> />+ <?php echo Translate::t ($service); ?>+ </label>+ <?php } ?>+ </div>+ </div>+<div class="form-group form-actions"><div class="group-controls"><button type="submit" class="btn btn-important"><?php echo Translate::t ('save'); ?></button>diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtmlindex d4343eb13..41b5d4176 100644--- a/app/views/helpers/view/normal_view.phtml+++ b/app/views/helpers/view/normal_view.phtml@@ -12,7 +12,17 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {$display_today = true;$display_yesterday = true;$display_others = true;++ $logged = !login_is_conf ($this->conf) || is_logged ();+ $shaarli = $logged && $this->conf->sharing ('shaarli');+ $poche = $logged && $this->conf->sharing ('poche');+ $diaspora = $logged && $this->conf->sharing ('diaspora');+ $twitter = $this->conf->sharing ('twitter');+ $google_plus = $this->conf->sharing ('g+');+ $facebook = $this->conf->sharing ('facebook');+ $email = $this->conf->sharing ('email');?>+<?php foreach ($items as $item) { ?><?php if ($display_today && $item->isDay (Days::TODAY)) { ?>@@ -91,68 +101,65 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {} ?><li class="item"><?php- if ($this->conf->bottomlineSharing ()) {+ if ($this->conf->bottomlineSharing () && (+ $shaarli || $poche || $diaspora || $twitter ||+ $google_plus || $facebook || $email+ )) {$link = urlencode ($item->link ());$title = urlencode ($item->title () . ' - ' . $feed->name ());?>- <div class="dropdown">+ <div class="dropdown"><div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div><?php echo RSSThemes::icon('share'); ?> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id ();?>"><?php echo Translate::t ('share'); ?></a><ul class="dropdown-menu"><li class="dropdown-close"><a href="#close">❌</a></li>- <?php- $shaarli = $this->conf->urlShaarli ();- if ((!login_is_conf ($this->conf) || is_logged ()) && $shaarli) {- ?>+ <?php if ($shaarli) { ?><li class="item"><a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&title=' . $title . '&source=FreshRSS'; ?>">- Shaarli+ <?php echo Translate::t ('shaarli'); ?></a></li>- <?php } ?>- <?php- $poche = $this->conf->urlPoche ();- if ((!login_is_conf ($this->conf) || is_logged ()) && $poche) {- ?>+ <?php } if ($poche) { ?><li class="item"><a target="_blank" href="<?php echo $poche . '?action=add&url=' . base64_encode (urldecode($link)); ?>">- Poche+ <?php echo Translate::t ('poche'); ?></a></li>- <?php } ?>- <?php- $diaspora = $this->conf->urlDiaspora ();- if ((!login_is_conf ($this->conf) || is_logged ()) && $diaspora) {- ?>+ <?php } if ($diaspora) { ?><li class="item"><a target="_blank" href="<?php echo $diaspora . '/bookmarklet?url=' . $link . '&title=' . $title; ?>">- Diaspora*+ <?php echo Translate::t ('diaspora'); ?></a></li>- <?php } ?>+ <?php } if ($twitter) { ?><li class="item">- <a href="mailto:?subject=<?php echo urldecode($title); ?>&body=<?php echo $link; ?>">- <?php echo Translate::t ('by_email'); ?>+ <a target="_blank" href="https://twitter.com/share?url=<?php echo $link; ?>&text=<?php echo $title; ?>">+ <?php echo Translate::t ('twitter'); ?></a></li>+ <?php } if ($google_plus) { ?><li class="item">- <a target="_blank" href="https://twitter.com/share?url=<?php echo $link; ?>&text=<?php echo $title; ?>">+ <a target="_blank" href="https://plus.google.com/share?url=<?php echo $link; ?>">+ <?php echo Translate::t ('g+'); ?></a></li>+ <?php } if ($facebook) { ?><li class="item"><a target="_blank" href="https://www.facebook.com/sharer.php?u=<?php echo $link; ?>&t=<?php echo $title; ?>">+ <?php echo Translate::t ('facebook'); ?></a></li>+ <?php } if ($email) { ?><li class="item">- <a target="_blank" href="https://plus.google.com/share?url=<?php echo $link; ?>">- Google++ <a href="mailto:?subject=<?php echo urldecode($title); ?>&body=<?php echo $link; ?>">+ <?php echo Translate::t ('by_email'); ?></a></li>+ <?php } ?></ul>- </div><?php } ?>+ </div>+ <?php } ?></li><?php$tags = $this->conf->bottomlineTags () ? $item->tags() : null;