From 99271059d2324e5bb171535acbd82fd65d2b99bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABl=20G?= <ggosset@insite.coop>
Date: Tue, 28 Jun 2011 18:12:30 +0200
Subject: [PATCH] Issue #756638: Themeable version

---
 bookmark_page.gif  |  Bin 253 -> 0 bytes
 bookmark_site.gif  |  Bin 1094 -> 0 bytes
 bookmark_us.info   |    9 ++++-
 bookmark_us.js     |   61 ------------------------------
 bookmark_us.module |  106 ++++++++++++++++++++++++++++-----------------------
 5 files changed, 66 insertions(+), 110 deletions(-)
 delete mode 100644 bookmark_page.gif
 delete mode 100644 bookmark_site.gif
 delete mode 100644 bookmark_us.js

diff --git a/bookmark_page.gif b/bookmark_page.gif
deleted file mode 100644
index 1c390409ad3d4fd3a0b2c75a7d1b57ecee1ea87d..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 253
zcmZ?wbhEHb6lV})IKsg2|NsB*-+zAi`1S3(Pfwq{efap*?Yqxz-hO)h=Hsi^A6>kB
z|LplYC(qnEe(J{IW7iHIxw3oTg&lj&ZQg!*?Z#uvS07rqY+v`p^*}=yZ~(=hEUY37
z;tV<<d61n9tW^(G`%*IJWvp7a^65T<>PUxN=FoGO%IAhp6J7tEdsW-sh66X4T;^SP
z-q7j9#MH>R(7{%5>a9ZyvlqE8<|^uJ<CPZTYMYh9n9two`q)rDk|jN`R!J;6zmQKr
nK&aU`sj|9TNTgScgNvJwPf$o$#KFm6k)F}gWy_Z<GFSru+ahl2

diff --git a/bookmark_site.gif b/bookmark_site.gif
deleted file mode 100644
index 99a8fa9d61df51bb1920c49c8afe3a319f4573bc..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1094
zcmeHGTWi!n6wcOG(^_h@c3o=GMn#MWZd9aEu}ex<jXu;-M1l`W6f6-`Mg$q~*0J7#
zHv$%kuwKR+1p5*w!XQN%>V<g2d6J=ukiG>$SOv9a|AUVnKE89#_waGffwN&#xy#ry
zN6Jf8Nt&FTOsmzjnk3b9B1>sCO;V9kp0Ze^QR>BlM@c{v$V5m|oAD$PBoe-ts(#`G
zi9tB=6Fm?pWSp>s#9j~+lqe{XQ6hyb#6pLO<OwCB0t=Z?0fmNyjJV;kz^5E>6>%k?
z#HSJBvddM-6_*$MNWfS_v5cAN#(EHP98nlch$5E($TUPv97ZrqJi<{J;egvA1fk;u
zu|uFk9GhU*7p~6%L7>(eR>py2`LXQ>pau+l7kClyLf{eL`3}x%1TY0SvT$T#4sc+3
zwuzaAiRnQLdlrf<L@kslK*ik1HbF6f)I`vP%z&{Dxt`4jv$?6^W<{X8vEdTUWu}uU
zSaq4<Fx_FA>lNHcbC~MHYK^0U!wL@7?F^x2Q_Us?o2nTDD*cateF61neZ%a`bXm=~
z_7jpkDdpsjjl-4E0l9VQt_Q=Vx^^&8{{;3n)D2GAQEXh$`|`&6vr_*HrBgjMr)SMk
z+&XQ>t)64M<kE=QTd#nwiIeaisq`LP)La}Imj|cLUEMdHyWii@jiujRyZfFE&25|4
zH*)1}|F(7AAG?ZU&o5qXX<h6+_|kSM=)TatuQ+o5)%h7qtRt28yk&cNRWr|hm{M-c
z>%-sM_Kt0B8QA=F%QyATru^gn@z*oA@1NN?u=r19>*<9}*Owm}+j+Q-ctb_y+>_A{
zgH6{Klpp;leID(ZKEKq|araho`R3{aV?z(sx`yV0mhW6vs=wN~?)a~_hgUpfm)e_W
sw=Yz#m9O6J8EE=;Y?e9t`iz1rd!8?Om!CdOto-!m>C+RZaye=3U%K34ng9R*

diff --git a/bookmark_us.info b/bookmark_us.info
index d38b743..27cdbf7 100644
--- a/bookmark_us.info
+++ b/bookmark_us.info
@@ -1,3 +1,10 @@
+; $Id: bookmark_us.info,v 1.1.2.1.2.1 2008/03/22 05:42:12 Gurpartap Exp $
 name = "Bookmark Us"
 description = "The Bookmark Us Module allows visitors to quickly and easily bookmark your site, and the current page."
-core = 6.x
\ No newline at end of file
+core = 6.x
+; Information added by drupal.org packaging script on 2008-08-13
+version = "6.x-1.1"
+core = "6.x"
+project = "bookmark_us"
+datestamp = "1218621007"
+
diff --git a/bookmark_us.js b/bookmark_us.js
deleted file mode 100644
index 2952312..0000000
--- a/bookmark_us.js
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/**
-* Bookmark Us - Drupal "Add to Bookmarks" Module.
-* @ Released under GNU/GPL License - http://www.gnu.org/copyleft/gpl.html
-* @ copyright (C) 2005 by Michael Carico - All rights reserved
-**/
-
-function displayLink(p_type, p_url, p_title, p_link_text) {
-
-  var agt = navigator.userAgent.toLowerCase();
-  var p_here = top.location.href
-  // Escape single-quotes.
-  p_title = p_title.replace(/\'/g, '\\\'');
-
-  if (p_type == 3)
-  {
-    if ((agt.indexOf("opera") != -1)) // || (agt.indexOf("firefox") != -1))
-    {
-      document.write("<a href=\""+p_here+"\" title=\"" + p_title + "\" rel=\"sidebar\">" + p_link_text + "</a>");
-    } else
-    {
-      document.write("<a href=\"javascript:addBookmark('"+p_title+"', top.location.href);\" title=\"" + p_title + "\" >" + p_link_text + "</a>");
-    }
-  } else
-  {
-    if (agt.indexOf("opera") != -1) 
-    {
-      document.write("<a href=\"" + p_url + "\" title=\"" + p_title + "\" rel=\"sidebar\">" + p_link_text + "</a>");
-    } else
-    {
-      document.write("<a href=\"javascript:addBookmark('"+p_title+"', '"+p_url+"');\" title=\"" + p_title + "\" >" + p_link_text + "</a>");
-    }
-  }
-}
-
-
-function addBookmark(title,url) {
-
-  var msg_netscape = "NetScape message";
-  var msg_opera    = "This function does not work with this version of Opera.  Please bookmark us manually.";
-  var msg_other    = "Your browser does not support automatic bookmarks.  Please bookmark us manually.";
-  var agt          = navigator.userAgent.toLowerCase();
-
-
-  if (agt.indexOf("opera") != -1) 
-  {
-    if (window.opera && window.print)
-    {
-      return true;
-    } else 
-    {
-      alert(msg_other);
-    }
-  }    
-  else if (agt.indexOf("firefox") != -1) window.sidebar.addPanel(title,url,"");
-  else if ((agt.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >=4)) window.external.AddFavorite(url,title); 
-  else if (agt.indexOf("netscape") != -1) window.sidebar.addPanel(title,url,"")         
-  else if (window.sidebar && window.sidebar.addPanel) window.sidebar.addPanel(title,url,""); 
-  else alert(msg_other);
-  
-}
diff --git a/bookmark_us.module b/bookmark_us.module
index 759f7e5..85124e8 100644
--- a/bookmark_us.module
+++ b/bookmark_us.module
@@ -1,4 +1,5 @@
 <?php
+// $Id: bookmark_us.module,v 1.5.2.4.2.2 2008/08/13 09:44:04 Gurpartap Exp $
 
 /*
  * Implementation of hook_menu().
@@ -22,23 +23,31 @@ function bookmark_us_menu() {
  * Implementation of hook_block().
  */
 function bookmark_us_block($op = 'list', $delta = 0, $edit = array()) {
-  if ($op == 'list') {
-    $blocks[0] = array(
-      'info' => t('Bookmark Us'),
-      'weight' => 0,
-      'enabled' => 1,
-      'region' => 'left',
-    );
-    return $blocks;
-  }
-  else if ($op == 'view') {
-    switch($delta) {
-      case 0:
-        $block['subject'] = t('Bookmark Us');
-        $block['content'] = bookmark_us_block_code();
-        break;
-    }
-    return $block;
+  switch ($op) {
+    case "list":
+      $blocks[0] = array(
+        'info' => t('Bookmark Us'),
+        'weight' => 0,
+        'enabled' => 1,
+        'region' => 'left',
+        'cache' =>    BLOCK_NO_CACHE, // As it injects JS.
+      );
+      return $blocks;
+      break;
+    case 'configure':
+      return $form;
+      break;
+    case 'save':
+      break;
+    case 'view':
+    default:
+      switch ($delta) {
+        case 0:
+          $block['subject'] = t('Bookmark Us');
+          $block['content'] = bookmark_us_block_code();
+          break;
+        }
+      return $block;
   }
 }
 
@@ -75,39 +84,40 @@ function bookmark_us_settings() {
   return system_settings_form($form);
 }
 
-/*
- * Bookmark Us Block Code
+/**
+ * Implementation of hook_theme().
  */
-function bookmark_us_block_code() {
-  $output = '';
-  global $base_url;
-  $basepath = base_path();
-  $path = drupal_get_path('module', 'bookmark_us');
-
-  $bmarkus_stitle = variable_get('bookmark_us_site', t('Bookmark Website'));
-  $bmarkus_ptitle = variable_get('bookmark_us_page', t('Bookmark Page'));
-  $bmarkus_icons = variable_get('bookmark_us_icons', 1);
-
-  $sitename = variable_get('site_name', t('Drupal'));
-  $pagetitle = strip_tags(drupal_get_title());
-  $head_title = $pagetitle ? $pagetitle .' | '. $sitename : $sitename;
-
-  drupal_add_js($path .'/bookmark_us.js');
-
-  if ($bmarkus_icons) {
-    $output .= '<img src="'. $basepath . $path .'/bookmark_site.gif" alt="'. $bmarkus_stitle .'" style="vertical-align: middle;"/>';
-    $output .= '&nbsp;';
-  }
+function bookmark_us_theme() {
+  $page_url = substr(request_uri(), strlen(base_path()));
+  return array(
+  'bookmark_us_block' => array(
+    'template'    => 'bookmark-us-block',
+    'arguments'   => array(
+      'bookmark_us_site'       => variable_get('bookmark_us_site', t('Bookmark Website')),
+      'bookmark_us_page'       => variable_get('bookmark_us_page', t('Bookmark Page')),
+      'bookmark_us_icons'      => variable_get('bookmark_us_icons', 1),
+      'bookmark_us_icons_path' => base_path() . drupal_get_path('module', 'bookmark_us') . '/images',
+      'site_name'              => variable_get('site_name', t('Drupal')),
+      'page_name'              => strip_tags(drupal_get_title()),
+      'url'                    => url('', array('absolute' => TRUE)),
+      'page_url'               => url($page_url, array('absolute' => TRUE)),
+      ),
+    ),
+  );
+}// function bookmark_us_theme()
 
-  $output .= '<script type="text/javascript"> displayLink("1", "'. $base_url .'", "'. $sitename .'", "'. $bmarkus_stitle .'");</script>';
-  $output .= '<br />';
-  
-  if ($bmarkus_icons) {
-    $output .= '<img src="'. $basepath . $path .'/bookmark_page.gif" alt="'. $bmarkus_ptitle .'" style="vertical-align: middle;"/>';
-    $output .= '&nbsp;';
-  }
+/**
+ * Preprocesses the template variables for the bookmark block
+ */
+function template_preprocess_bookmark_us_block(&$variables) {
 
-  $output .= '<script type="text/javascript"> displayLink("3", "", "'. $head_title .'", "'. $bmarkus_ptitle .'"); </script>';
+}// template_preprocess_bookmark_us_block()
 
-  return $output;
+/*
+ * Bookmark Us Block Code
+ */
+function bookmark_us_block_code() {
+  drupal_add_js(drupal_get_path('module', 'bookmark_us') .'/js/bookmark_us.js');
+  drupal_add_css(drupal_get_path('module', 'bookmark_us') . '/css/bookmark_us.css');
+  return theme('bookmark_us_block');
 }
-- 
1.7.4.1

