]> gitweb.fluxo.info Git - drupal/muambeiro.git/commitdiff
Link icons
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Nov 2011 21:58:21 +0000 (19:58 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Nov 2011 21:58:21 +0000 (19:58 -0200)
images/icons/messages.png [new file with mode: 0644]
template.php

diff --git a/images/icons/messages.png b/images/icons/messages.png
new file mode 100644 (file)
index 0000000..30bbfb5
Binary files /dev/null and b/images/icons/messages.png differ
index 9da450eedc676dbd0d0309a259fb050690d3eeff..5038ead8d6eac3483376cb5bfed89864ec0e604c 100644 (file)
@@ -286,3 +286,32 @@ function muambeiro_ns() {
   }
   return $output;
 }
+
+/**
+ * Overrides theme_link(). Add icons to links.
+ */
+function muambeiro_link($variables) {
+  $path = drupal_get_path('theme', 'muambeiro');
+  $file = $path .'/images/icons/' . $variables['path'] .'.png';
+
+  if (file_exists($file)) {
+    $icon = theme('image',
+      array(
+        'path'  => $file,
+        'alt'   => $variables['text'],
+        'title' => $variables['text'],
+      )
+    );    
+
+    $link  = '<a href="' . check_plain(url($variables['path'], $variables['options']));
+    $link .= '"' . drupal_attributes($variables['options']['attributes']) . '>';
+    $link .= $icon;
+    $link .= ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text']));
+    $link .= '</a>';
+
+    return $link;
+  }
+  else {
+    return theme_link($variables);
+  }
+}