[geeklog-cvs] geeklog: By popular deman: Added an option to allow opening exte...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Nov 23 04:57:40 EST 2008


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/209629e9999f
changeset: 6479:209629e9999f
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Nov 23 10:47:30 2008 +0100
description:
By popular deman: Added an option to allow opening external links in a new window (feature request #0000693)

diffstat:

12 files changed, 71 insertions(+), 30 deletions(-)
plugins/links/install_defaults.php             |    8 +++
plugins/links/language/english.php             |    1 
plugins/links/language/english_utf-8.php       |    1 
plugins/links/language/german.php              |    3 -
plugins/links/language/german_formal.php       |    3 -
plugins/links/language/german_formal_utf-8.php |    3 -
plugins/links/language/german_utf-8.php        |    3 -
public_html/docs/history                       |    3 +
public_html/docs/links.html                    |    7 ++
public_html/links/index.php                    |   61 +++++++++++++-----------
sql/updates/mssql_1.5.1_to_1.5.2.php           |    4 +
sql/updates/mysql_1.5.1_to_1.5.2.php           |    4 +

diffs (271 lines):

diff -r 9bca73bddd43 -r 209629e9999f plugins/links/install_defaults.php
--- a/plugins/links/install_defaults.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/install_defaults.php	Sun Nov 23 10:47:30 2008 +0100
@@ -134,6 +134,12 @@
 $_LI_DEFAULT['show_category_descriptions'] = true;
 
 /**
+ * open links in new window
+ * Whether to open external links in a new window or not.
+ */
+$_LI_DEFAULT['new_window'] = false;
+
+/**
  * Links root category id
  */
 $_LI_DEFAULT['root'] = 'site';
@@ -182,6 +188,8 @@
         $c->add('show_top10', $_LI_DEFAULT['show_top10'], 'select',
                 0, 0, 1, 40, true, 'links');
         $c->add('show_category_descriptions', $_LI_DEFAULT['show_category_descriptions'], 'select', 0, 0, 1, 50, true, 'links');
+        $c->add('new_window', $_LI_DEFAULT['new_window'], 'select',
+                0, 0, 1, 55, true, 'links');
 
         $c->add('fs_admin', NULL, 'fieldset', 0, 1, NULL, 0, true, 'links');
         $c->add('hidenewlinks', $_LI_DEFAULT['hidenewlinks'], 'select',
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/english.php
--- a/plugins/links/language/english.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/english.php	Sun Nov 23 10:47:30 2008 +0100
@@ -274,6 +274,7 @@
     'delete_links' => 'Delete Links with Owner?',
     'aftersave' => 'After Saving Link',
     'show_category_descriptions' => 'Show Category Description?',
+    'new_window' => 'Open external links in new window?',
     'root' => 'ID of Root Category',
     'default_permissions' => 'Link Default Permissions'
 );
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/english_utf-8.php
--- a/plugins/links/language/english_utf-8.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/english_utf-8.php	Sun Nov 23 10:47:30 2008 +0100
@@ -274,6 +274,7 @@
     'delete_links' => 'Delete Links with Owner?',
     'aftersave' => 'After Saving Link',
     'show_category_descriptions' => 'Show Category Description?',
+    'new_window' => 'Open external links in new window?',
     'root' => 'ID of Root Category',
     'default_permissions' => 'Link Default Permissions'
 );
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/german.php
--- a/plugins/links/language/german.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/german.php	Sun Nov 23 10:47:30 2008 +0100
@@ -234,6 +234,7 @@
     'delete_links' => 'Links löschen mit User?',
     'aftersave' => 'Nach Abspeichern des Links',
     'show_category_descriptions' => 'Kategoriebeschreibung anzeigen?',
+    'new_window' => 'Externe Links in neuem Fenster öffnen?',
     'root' => 'ID der Oberkategorie',
     'default_permissions' => 'Grundeinstellung Rechte'
 );
@@ -256,4 +257,4 @@
     12 => array('Kein Zugang' => 0, 'Nur lesen' => 2, 'Lesen-Schreiben' => 3)
 );
 
-?>
\ No newline at end of file
+?>
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/german_formal.php
--- a/plugins/links/language/german_formal.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/german_formal.php	Sun Nov 23 10:47:30 2008 +0100
@@ -234,6 +234,7 @@
     'delete_links' => 'Links löschen mit User?',
     'aftersave' => 'Nach Abspeichern des Links',
     'show_category_descriptions' => 'Kategoriebeschreibung anzeigen?',
+    'new_window' => 'Externe Links in neuem Fenster öffnen?',
     'root' => 'ID der Oberkategorie',
     'default_permissions' => 'Grundeinstellung Rechte'
 );
@@ -256,4 +257,4 @@
     12 => array('Kein Zugang' => 0, 'Nur lesen' => 2, 'Lesen-Schreiben' => 3)
 );
 
-?>
\ No newline at end of file
+?>
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/german_formal_utf-8.php
--- a/plugins/links/language/german_formal_utf-8.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/german_formal_utf-8.php	Sun Nov 23 10:47:30 2008 +0100
@@ -234,6 +234,7 @@
     'delete_links' => 'Links löschen mit User?',
     'aftersave' => 'Nach Abspeichern des Links',
     'show_category_descriptions' => 'Kategoriebeschreibung anzeigen?',
+    'new_window' => 'Externe Links in neuem Fenster öffnen?',
     'root' => 'ID der Oberkategorie',
     'default_permissions' => 'Grundeinstellung Rechte'
 );
@@ -256,4 +257,4 @@
     12 => array('Kein Zugang' => 0, 'Nur lesen' => 2, 'Lesen-Schreiben' => 3)
 );
 
-?>
\ No newline at end of file
+?>
diff -r 9bca73bddd43 -r 209629e9999f plugins/links/language/german_utf-8.php
--- a/plugins/links/language/german_utf-8.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/plugins/links/language/german_utf-8.php	Sun Nov 23 10:47:30 2008 +0100
@@ -234,6 +234,7 @@
     'delete_links' => 'Links löschen mit User?',
     'aftersave' => 'Nach Abspeichern des Links',
     'show_category_descriptions' => 'Kategoriebeschreibung anzeigen?',
+    'new_window' => 'Externe Links in neuem Fenster öffnen?',
     'root' => 'ID der Oberkategorie',
     'default_permissions' => 'Grundeinstellung Rechte'
 );
@@ -256,4 +257,4 @@
     12 => array('Kein Zugang' => 0, 'Nur lesen' => 2, 'Lesen-Schreiben' => 3)
 );
 
-?>
\ No newline at end of file
+?>
diff -r 9bca73bddd43 -r 209629e9999f public_html/docs/history
--- a/public_html/docs/history	Sat Nov 22 23:23:34 2008 +0100
+++ b/public_html/docs/history	Sun Nov 23 10:47:30 2008 +0100
@@ -63,6 +63,9 @@
 
 Links plugin
 ------------
+- Added an option to allow opening external links in a new window (feature
+  request #0000693). Use with care, please [Dirk]
+- Only external links are marked with class="ext-link" [Dirk]
 - Added urlencoded versions of {link_actual_url} and {link_name} [Dirk]
 - Prevent overwriting existing links when changing the link ID [Dirk]
 
diff -r 9bca73bddd43 -r 209629e9999f public_html/docs/links.html
--- a/public_html/docs/links.html	Sat Nov 22 23:23:34 2008 +0100
+++ b/public_html/docs/links.html	Sun Nov 23 10:47:30 2008 +0100
@@ -58,6 +58,13 @@
   <td><a name="desc_show_category_descriptions">show_category_descriptions</a></td>
   <td><code>true</code></td>
   <td>Whether to show subcategory descriptions when viewing a category or not.</td>
+</tr>
+<tr class="r2">
+  <td><a name="desc_new_window">new_window</a></td>
+  <td><code>false</code></td>
+  <td>Whether to open external links in a new window or not.<br>
+  <strong>Note:</strong> Use this option with care. <a
+    href="http://diveintoaccessibility.org/day_16_not_opening_new_windows.html">It takes control away</a> from your users and may confuse or annoy them.</td>
 </tr>
 </table>
 
diff -r 9bca73bddd43 -r 209629e9999f public_html/links/index.php
--- a/public_html/links/index.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/public_html/links/index.php	Sun Nov 23 10:47:30 2008 +0100
@@ -340,55 +340,64 @@
 * @param    ref     $template   reference of the links template
 *
 */
-function prepare_link_item ($A, &$template)
+function prepare_link_item($A, &$template)
 {
-    global $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE, $LANG_DIRECTION;
+    global $_CONF, $_USER, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION,
+           $_IMAGE_TYPE;
 
     $url = COM_buildUrl($_CONF['site_url']
                         . '/links/portal.php?what=link&item=' . $A['lid']);
+    $actualUrl = stripslashes($A['url']);
+    $title = stripslashes($A['title']);
+
     $template->set_var('link_url', $url);
-    $template->set_var('link_actual_url', $A['url']);
-    $template->set_var('link_actual_url_encoded', urlencode($A['url']));
-    $template->set_var('link_name', stripslashes($A['title']));
-    $template->set_var('link_name_encoded',
-                       urlencode(stripslashes($A['title'])));
-    $template->set_var('link_hits', COM_numberFormat ($A['hits']));
+    $template->set_var('link_actual_url', $actualUrl);
+    $template->set_var('link_actual_url_encoded', urlencode($actualUrl));
+    $template->set_var('link_name', $title);
+    $template->set_var('link_name_encoded', urlencode($title));
+    $template->set_var('link_hits', COM_numberFormat($A['hits']));
     $template->set_var('link_description',
                        nl2br(stripslashes($A['description'])));
-    $content = stripslashes($A['title']);
-    $class = 'ext-link';
-    if ((!empty($LANG_DIRECTION)) && ($LANG_DIRECTION == 'rtl')) {
-        $class .= '-rtl';
+
+    $attr = array('title' => $actualUrl);
+    if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
+        $class = 'ext-link';
+        if ((!empty($LANG_DIRECTION)) && ($LANG_DIRECTION == 'rtl')) {
+            $class .= '-rtl';
+        }
+        $attr['class'] = $class;
+        if ($_LI_CONF['new_window']) {
+            $attr['target'] = '_blank';
+        }
     }
-    $attr = array(
-        'title' => stripslashes ($A['url']),
-        'class' => $class);
-    $html = COM_createLink($content, $url, $attr);
-    $template->set_var ('link_html', $html);
+    $html = COM_createLink($title, $url, $attr);
+    $template->set_var('link_html', $html);
+
     if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
         $reporturl = $_CONF['site_url']
-                 . '/links/index.php?mode=report&lid=' . $A['lid'];
-        $template->set_var ('link_broken',
+                   . '/links/index.php?mode=report&lid=' . $A['lid'];
+        $template->set_var('link_broken',
                 COM_createLink($LANG_LINKS[117], $reporturl,
                                array('class' => 'pluginSmallText',
                                      'rel'   => 'nofollow'))
         );
     } else {
-        $template->set_var ('link_broken', '');
+        $template->set_var('link_broken', '');
     }
 
-    if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
+    if ((SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'],
             $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
-            SEC_hasRights ('links.edit')) {
+            SEC_hasRights('links.edit')) {
         $editurl = $_CONF['site_admin_url']
                  . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
-        $template->set_var ('link_edit', COM_createLink($LANG_ADMIN['edit'],$editurl));
+        $template->set_var('link_edit',
+                           COM_createLink($LANG_ADMIN['edit'], $editurl));
         $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.$_IMAGE_TYPE\" "
             . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
-        $template->set_var ('edit_icon', COM_createLink($edit_icon, $editurl));
+        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
     } else {
-        $template->set_var ('link_edit', '');
-        $template->set_var ('edit_icon', '');
+        $template->set_var('link_edit', '');
+        $template->set_var('edit_icon', '');
     }
 }
 
diff -r 9bca73bddd43 -r 209629e9999f sql/updates/mssql_1.5.1_to_1.5.2.php
--- a/sql/updates/mssql_1.5.1_to_1.5.2.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/sql/updates/mssql_1.5.1_to_1.5.2.php	Sun Nov 23 10:47:30 2008 +0100
@@ -10,6 +10,10 @@
 
     // new option
     $c->add('jpeg_quality',75,'text',5,23,NULL,1495,FALSE);
+
+    if (INST_pluginExists('links')) {
+        $c->add('new_window',false,'select',0,0,1,55,TRUE,'links');
+    }
 
     return true;
 }
diff -r 9bca73bddd43 -r 209629e9999f sql/updates/mysql_1.5.1_to_1.5.2.php
--- a/sql/updates/mysql_1.5.1_to_1.5.2.php	Sat Nov 22 23:23:34 2008 +0100
+++ b/sql/updates/mysql_1.5.1_to_1.5.2.php	Sun Nov 23 10:47:30 2008 +0100
@@ -10,6 +10,10 @@
 
     // new option
     $c->add('jpeg_quality',75,'text',5,23,NULL,1495,FALSE);
+
+    if (INST_pluginExists('links')) {
+        $c->add('new_window',false,'select',0,0,1,55,TRUE,'links');
+    }
 
     return true;
 }



More information about the geeklog-cvs mailing list