Index: weblink.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/weblink/weblink.module,v
retrieving revision 1.63
diff -u -r1.63 weblink.module
--- weblink.module	19 Jun 2004 10:53:37 -0000	1.63
+++ weblink.module	29 Aug 2004 17:46:35 -0000
@@ -16,20 +16,12 @@
  <li>The module exports both a page and a block that displays the registered sites ordered by their last modification date.</li>
 </ul>");
 
-    case "admin/system/modules#description":
+    case "admin/modules#description":
       return t("A weblinks module with integrated monitoring");
       
     case 'node/add#weblink':
       return t("Weblinks allow you to link to other websites and pages.");
       
-    case "filter#short-tip":
-      if (variable_get("weblink_filter_enabled", 0)) {
-        return t("You may link to webpages <a href=\"%long-tip\">through the weblinks registry</a>", array("%long-tip" => url("filter/tips", NULL, 'weblink')));
-      }
-    case "filter#long-tip":
-      if (variable_get("weblink_filter_enabled", 0)) {
-        return t("<p>You may create links to items stored in our weblink registry using a special syntax. The weblink codes will be replaced by a links to visit the real websites. Syntax: <code>[weblink:link_id]</code> or <code>[weblink:http://a.weblink.example.com/]</code>.</p>");
-      }
       break;
       
     case "weblink/monitor":
@@ -37,17 +29,37 @@
   }
 }
 
+/**
+ * Implementation of hook_menu().
+ */
+function weblink_menu() {
+  global $user;
+
+  $items = array();
+
+  $items[] = array('path' => 'weblink', 'title' => t('links'),
+    'callback' => 'weblink_page',
+    'access' => user_access('access content'),
+    'type' => MENU_CALLBACK);
+  $items[] = array('path' => 'node/add/weblink', 'title' => t('weblink'),
+    'access' => user_access('create weblinks'));
+  $items[] = array('path' => 'weblink/blogmark/js', 'title' => t('blogmark'),
+    'callback' => 'weblink_blogmark_js',
+    'access' => TRUE,
+    'type' => MENU_CALLBACK);
+  $items[] = array('path' => 'weblink/blogmark', 'title' => t('blogmark'),
+    'callback' => 'weblink_blogmark',
+    'access' => TRUE,
+    'type' => MENU_CALLBACK);
+
+  return $items;
+}
+
 function weblink_link($type, $node = 0) {
   $links = array();
   
-  // System menu items
-  if ($type == "system") {
-    if (user_access("create weblinks")) {
-      menu("node/add/weblink", t("weblink"), "node_page");
-    }
-    menu("weblink/blogmark/js", t("blogmark"), "weblink_blogmark_js", 0, MENU_HIDE);
-    menu("weblink/blogmark", t("blogmark"), "weblink_blogmark", 0, MENU_HIDE);
-    menu("weblink", t("weblink"), "weblink_page", 0, MENU_HIDE);
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('weblinks'), 'weblink');
   }
 
   // Node links for a weblink
@@ -216,7 +228,7 @@
     // Save node and note in the watchdog log
     $nid = node_save($node);
     if ($nid) {
-      watchdog("special", "{$node->type}: added '{$node->title}' blogmark", l(t("view post"), "node/view/$nid"));
+      watchdog("special", "{$node->type}: added '{$node->title}' blogmark", l(t("view post"), "node/$nid"));
       print theme("page", t("Thanks for your contribution to our blogmark collection. Now feel free to browse on or close this window."), t("Blogmark added"));
       return;
     }
@@ -301,13 +313,15 @@
  * Filter handling code
  ********************************************************************/
 
-function weblink_filter($op, $text = "") {
+function weblink_filter($op, $delta = 0, $format = -1, $text = "") {
   switch ($op) {
-    case "name":
-      return t("Weblink filter");
-    case "process":
+    case 'list':
+      return array(0 => t("Weblink filter"));
+    case 'description':
+      return t("Insert description of weblink filter here.");
+    case 'process':
       return _weblink_filter_process($text);
-    case "settings":
+    case 'settings':
       return _weblink_filter_settings();
     default:
       return $text;
@@ -360,7 +374,7 @@
   }
 }
 
-function weblink_form(&$node, $error, &$param) {
+function weblink_form(&$node, &$param) {
 
   $output .= form_textfield(t("Link"), "weblink", $node->weblink, 60, 128, t("Links should be submitted in a form similar to http://www.example.com/") . ($error['weblink'] ? $error["weblink"] : ''));
     
@@ -387,7 +401,7 @@
 
   $output .= implode("", taxonomy_node_form("weblink", $node));
 
-  $output .= form_textarea(t("Body"), "body", $node->body, 60, 20, t("Textual description of the weblink") . ($error['body'] ? $error['body'] : '') . filter_tips_short());
+  $output .= form_textarea(t("Body"), "body", $node->body, 60, 20, t("Textual description of the weblink") . ($error['body'] ? $error['body'] : ''));
  
   return $output;
 }
@@ -412,7 +426,7 @@
   if (db_num_rows($result) > 0) {
     $weblink = db_fetch_object($result);
     $othernode = node_load(array("nid" => $weblink->nid));
-    return array("weblink" => theme("error", t("A weblink %link-to-existing with that link already exists", array("%link-to-existing" => l($othernode->title, "admin/node/edit/$othernode->nid")))));
+    form_set_error('weblink', t('A weblink %link-to-existing using that link already exists', array("%link-to-existing" => l($othernode->title, 'node/' . $othernode->nid . '/edit'))));
   }
 }
 
@@ -420,6 +434,14 @@
   return db_fetch_object(db_query("SELECT * FROM {weblink} WHERE nid = '%d'", $node->nid));
 }
 
+function weblink_filter_tips($delta, $format, $long = false) {
+  if ($long) {
+    return t("<p>You may create links to items stored in our weblink registry using a special syntax. The weblink codes will be replaced by a links to visit the real websites. Syntax: <code>[weblink:link_id]</code> or <code>[weblink:http://a.weblink.example.com/]</code>.</p>");
+  }
+  else {
+    return t("You may link to webpages <a href=\"%long-tip\">through the weblinks registry</a>", array("%long-tip" => url("filter/tips", NULL, 'weblink')));
+  }
+}
 /********************************************************************
  * Block display functions
  ********************************************************************/
@@ -491,7 +513,7 @@
   while($node = db_fetch_object($result)) {
     $node->body = htmlspecialchars($node->body);
     $comments = (int) module_invoke('comment', 'num_all', $node->nid);
-    $links[] = l($node->title, "weblink/goto/$node->nid", _weblink_attributes($node, 'body')) . " " . l("($comments)", "node/view/$node->nid", array('title' => format_plural($comments, '1 comment', '%count comments'), 'class' => "comment-count"));
+    $links[] = l($node->title, "weblink/goto/$node->nid", _weblink_attributes($node, 'body')) . " " . l("($comments)", "node/$node->nid", array('title' => format_plural($comments, '1 comment', '%count comments'), 'class' => "comment-count"));
   }
   
   $navlinks = array(l(t('read more'), "weblink/view/$tid"));
@@ -532,13 +554,13 @@
 
   $url = "";
   if (!ereg("^http://|https://|ftp://", $node->weblink)) {
-    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL for '%node'", array("%node" => $node->title)), l(t("edit site"), "admin/node/edit/". $node->nid));
+    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL for '%node'", array("%node" => $node->title)), l(t('edit site'), 'node/' . $node->nid . '/edit'));
   } else {
     $url = $node->weblink;
   }
 
   if (!ereg("^http://|https://|ftp://", $node->feed) && !$url) {
-    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL to monitor for '%node'", array("%node" => $node->title)), l(t("edit site"), "admin/node/edit/". $node->nid));
+    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL to monitor for '%node'", array("%node" => $node->title)), l(t('edit site'), 'node/' . $node->nid . '/edit'));
   } else {
     // Overwrite previously set link
     $url = $node->weblink;
@@ -764,9 +786,9 @@
   $output .= " - ". $node->weblink ."</dt>";
   $output .= "<dd>" . $node->teaser;
   $output .= "<div class=\"links\">(". format_plural($node->click, "1 hit", "%count hits") . " - ";
-  $output .= l(t("detail"), "node/view/$node->nid", array("title" => t("Read details, read and add comments.")));
+  $output .= l(t("detail"), "node/$node->nid", array("title" => t("Read details, read and add comments.")));
   if (user_access("administer nodes")) {
-    $output .=  " - " . l(t("administer"), "admin/node/edit/$node->nid", array("title" => t("Administer this node.")));  
+    $output .=  " - " . l(t("administer"), 'node/' . $node->nid . '/edit', array("title" => t("Administer this node.")));  
   }
   $output .= ")</div>";
   $output .= "</dd>";
@@ -828,7 +850,7 @@
 }
 
 function _weblink_get_links($tid) {
-  $SQL = "SELECT n.nid, n.title, n.teaser, n.status, n.moderate, w.weblink, w.click FROM {node} n, {term_node} t, {weblink} w WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 ORDER BY n.created DESC";
+  $SQL = "SELECT n.nid, n.title, n.teaser, n.status, n.moderate, w.weblink, w.click FROM {node} n, {term_node} t, {weblink} w WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 ORDER BY n.title";
   if ($weblink_pager_term = variable_get("weblink_pager_term", 0)) {
     $result = pager_query(sprintf($SQL, $tid), $weblink_pager_term);
   }
@@ -849,7 +871,8 @@
     db_query("UPDATE {weblink} SET click = click + 1 where nid = '%d'", $id);
     $result = db_query("SELECT %s FROM {weblink} WHERE nid = '%d'", $type, $id);
     $wl = db_fetch_object($result);
-    header("HTTP/1.0 301 Moved Permanently");
+    // Didn't this use to work?
+    //header("HTTP/1.0 301 Moved Permanently");
     header("Location: " . $wl->$type);
   }
 }
