Dotclear

Changeset 2726


Ignore:
Timestamp:
11/03/10 15:22:06 (3 years ago)
Author:
nikrou
Message:

add rel="external" attribute to external links
users can choose whether a link is external or not from the toolbar
extension can be desactivated by blog

Location:
plugins/externalLinks
Files:
16 added
4 edited
5 copied

Legend:

Unmodified
Added
Removed
  • plugins/externalLinks/_admin.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $core->addBehavior('adminBlogPreferencesForm',array('extLinkBehaviors','adminBlogPreferencesForm')); 
    24 $core->addBehavior('adminBeforeBlogSettingsUpdate',array('extLinkBehaviors','adminBeforeBlogSettingsUpdate')); 
     24if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    2525 
    26 class extLinkBehaviors 
     26$_menu['Plugins']->addItem(__('External links'),  
     27                  'plugin.php?p=externalLinks', 
     28                  'index.php?pf=externalLinks/img/external.png', 
     29                  preg_match('/plugin.php\?p=externalLinks(&.*)?$/', $_SERVER['REQUEST_URI']), 
     30                  $core->auth->check('usage,contentadmin', $core->blog->id) 
     31                  ); 
     32 
     33if ($core->blog->settings->externallinks->active) { 
     34  $core->addBehavior('adminPostHeaders', array('externalLinksBehaviors', 'jsLoad')); 
     35  $core->addBehavior('adminPageHeaders', array('externalLinksBehaviors', 'jsLoad')); 
     36  $core->addBehavior('adminRelatedHeaders', array('externalLinksBehaviors', 'jsLoad')); 
     37  $core->addBehavior('adminDashboardHeaders',array('externalLinksBehaviors','jsLoad')); 
     38} 
     39 
     40class externalLinksBehaviors 
    2741{ 
    28      public static function adminBlogPreferencesForm($core,$settings) 
    29      { 
    30           echo 
    31           '<fieldset><legend>'.__('External links').'</legend>'. 
    32           '<p><label class="classic">'. 
    33           form::checkbox('extlink_enabled','1',$settings->extlink->extlink_enabled). 
    34           __('Open external links in a new window').'</label></p>'. 
    35           '</fieldset>'; 
    36      } 
    37       
    38      public static function adminBeforeBlogSettingsUpdate($settings) 
    39      { 
    40           $settings->addNameSpace('extlink'); 
    41           $settings->extlink->put('extlink_enabled',!empty($_POST['extlink_enabled'])); 
    42      } 
     42  public static function jsLoad() { 
     43    global $core; 
     44     
     45    $res = sprintf('<script type="text/javascript" src="%s"></script>', 
     46             html::stripHostURL($core->blog->getQmarkURL().'pf=externalLinks/js/post.min.js') 
     47             ); 
     48    return $res; 
     49  } 
    4350} 
    4451?> 
  • plugins/externalLinks/_define.php

    r2418 r2726  
    2525     /* Description*/         "Opens external links in a new window", 
    2626     /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
     27     /* Version */            '3.2', 
    2828     /* Permissions */        'admin' 
    2929); 
  • plugins/externalLinks/_install.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $this->registerModule( 
    24      /* Name */               "externalLinks", 
    25      /* Description*/         "Opens external links in a new window", 
    26      /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
    28      /* Permissions */        'admin' 
    29 ); 
     24$version = $core->plugins->moduleInfo('externalLinks', 'version'); 
     25if (version_compare($core->getVersion('externalLinks'), $version,'>=')) { 
     26  return; 
     27} 
     28 
     29$settings = $core->blog->settings; 
     30$settings->addNamespace('externallinks'); 
     31 
     32$settings->externallinks->put('active', false, 'boolean', 'external Links plugin activation', false); 
     33 
     34$core->setVersion('externalLinks', $version); 
     35return true; 
    3036?> 
  • plugins/externalLinks/_prepend.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $this->registerModule( 
    24      /* Name */               "externalLinks", 
    25      /* Description*/         "Opens external links in a new window", 
    26      /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
    28      /* Permissions */        'admin' 
    29 ); 
     24if (!defined('DC_RC_PATH')) { return; } 
     25 
     26$GLOBALS['__autoload']['tplExternalLinks'] = dirname(__FILE__).'/inc/class.tpl.external.links.php'; 
    3027?> 
  • plugins/externalLinks/_public.php

    r2418 r2726  
    2121# ***** END LICENSE BLOCK ***** 
    2222 
    23 $core->addBehavior('publicHeadContent',array('extLinkPublic','publicHeadContent')); 
     23if (!defined('DC_RC_PATH')) { return; } 
    2424 
    25 class extLinkPublic 
    26 { 
    27      public static function publicHeadContent($core) 
    28      { 
    29           if (!$core->blog->settings->extlink_enabled) { 
    30                return; 
    31           } 
    32  
    33           $url = $core->blog->getQmarkURL().'pf='.basename(dirname(__FILE__)); 
    34           echo 
    35           '<script type="text/javascript">'."\n". 
    36           "//<![CDATA[\n". 
    37           '$(document).ready(function(){'."\n". 
    38           '$("a[href^=\"http\"]").each(function(i){$(this).not("[href*=\""+document.domain+"\"]").not(":has(img)").after(" <a href=\""+$(this).attr("href")+"\" onclick=\"window.open(this.href); return false;\" style=\"border: none;\"><img src=\"'.$url.'/img/external.gif\" alt=\"\" title=\"'.__('Open this link in a new window').'\" /></a>");});});'."\n". 
    39           "\n//]]>\n". 
    40           "</script>\n"; 
    41      } 
    42 } 
     25$core->addBehavior('publicFooterContent', array('tplExternalLinks', 'publicFooterContent')); 
    4326?> 
  • plugins/externalLinks/config.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $this->registerModule( 
    24      /* Name */               "externalLinks", 
    25      /* Description*/         "Opens external links in a new window", 
    26      /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
    28      /* Permissions */        'admin' 
    29 ); 
     24if (!defined('DC_CONTEXT_ADMIN')) { exit; } 
     25 
     26$active = $core->blog->settings->externallinks->active; 
     27 
     28$default_tab = 'externallinks_settings'; 
     29 
     30if (!empty($_POST['saveconfig'])) { 
     31  try { 
     32    $active = (empty($_POST['active']))?false:true; 
     33 
     34    $core->blog->settings->externallinks->put('active', $active, 'boolean'); 
     35    $core->blog->triggerBlog(); 
     36 
     37    $message = __('Configuration successfully updated.'); 
     38  } catch(Exception $e) { 
     39    $core->error->add($e->getMessage()); 
     40  } 
     41} 
     42include(dirname(__FILE__).'/tpl/index.tpl'); 
    3043?> 
  • plugins/externalLinks/inc/class.tpl.external.links.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $this->registerModule( 
    24      /* Name */               "externalLinks", 
    25      /* Description*/         "Opens external links in a new window", 
    26      /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
    28      /* Permissions */        'admin' 
    29 ); 
     24class tplExternalLinks 
     25{ 
     26  public static function publicFooterContent($core) { 
     27    if (!$core->blog->settings->externallinks->active) { 
     28      return; 
     29    } 
     30     
     31    $url = html::stripHostURL($core->blog->getQmarkURL().'pf=externalLinks'); 
     32 
     33    echo 
     34      '<script type="text/javascript">'."\n". 
     35      "//<![CDATA[\n". 
     36      'var external_links_image = "'.$url.'/img/external.gif";'. 
     37      'var external_links_title = "'.__('Open this link in a new window').'";'. 
     38      "\n//]]>\n". 
     39      "</script>\n"; 
     40 
     41    echo  
     42      '<script type="text/javascript" src="'.$url.'/js/external.min.js"/></script>'; 
     43  } 
     44} 
    3045?> 
  • plugins/externalLinks/index.php

    r2418 r2726  
    44# Copyright (c) 2008 Olivier Meunier and contributors. All rights 
    55# reserved. 
     6# Copyright(C) 2010 Nicolas Roudaire - http://www.nikrou.net 
    67# 
    78# DotClear is free software; you can redistribute it and/or modify 
     
    1718# You should have received a copy of the GNU General Public License 
    1819# along with DotClear; if not, write to the Free Software 
    19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
    2021# 
    2122# ***** END LICENSE BLOCK ***** 
    2223 
    23 $this->registerModule( 
    24      /* Name */               "externalLinks", 
    25      /* Description*/         "Opens external links in a new window", 
    26      /* Author */             "Bruno Hondelatte", 
    27      /* Version */            '3.1', 
    28      /* Permissions */        'admin' 
    29 ); 
     24if (!defined('DC_CONTEXT_ADMIN')) { exit; } 
     25 
     26if (!empty($_GET['popup'])) { 
     27  include(dirname(__FILE__).'/popup_link.php'); 
     28} else { 
     29  include(dirname(__FILE__).'/config.php'); 
     30} 
    3031?> 
  • plugins/externalLinks/locales/fr/main.po

    r1578 r2726  
     1# Translation of externalLinks dotclear plugin to French 
     2# Copyright(C) 2010 Nicolas Roudaire  http://www.nikrou.net 
     3# This file is distributed under the same license as the Dotclear package. 
     4# Nicolas Roudaire <nikrou77@gmail.com>, 2010 
     5# 
     6 
    17msgid "" 
    2 msgstr "Content-Type: text/plain; charset=UTF-8\n" 
     8msgstr "" 
     9 
     10"Language: fr\n" 
     11"MIME-Version: 1.0\n" 
     12"Content-Type: text/plain; charset=utf-8\n" 
     13"Content-Transfer-Encoding: 8bit\n" 
     14 
     15msgid "About" 
     16msgstr "A propos" 
     17 
     18msgid "Enable External links plugin" 
     19msgstr "Activer le plugin Liens externes" 
     20 
     21msgid "If you want more informations on that plugin or have new ideas to develope it, or want to submit a bug or need help (to install or configure it) or for anything else ..." 
     22msgstr "Si vous voulez des informations sur ce plugin ou si vous avez des idées pour l'améliorer ou si vous pensez avoir trouvé un bug ou si vous avez besoin d'aide (pour l'installer ou le configurer) ou pour tout autre chose..." 
     23 
     24msgid "Go to %sthe dedicated page%s in" 
     25msgstr "Allez sur la %spage dédiée%s du" 
     26 
     27msgid "Made by:" 
     28msgstr "Créé par : " 
     29 
     30msgid "Contributor:" 
     31msgstr "Contributeur : " 
     32 
     33msgid "external link?" 
     34msgstr "lien externe ?" 
    335 
    436msgid "External links" 
    537msgstr "Liens externes" 
    6  
    7 msgid "Open external links in a new window" 
    8 msgstr "Ouvrir les liens externes dans une nouvelle fenêtre" 
    938 
    1039msgid "Open this link in a new window" 
     
    1241 
    1342 
     43 
Note: See TracChangeset for help on using the changeset viewer.

Sites map