=== renamed file 'janode.install' => 'sitelink.install' --- janode.install +++ sitelink.install @@ -1,18 +1,18 @@ 'sitelink.module' --- janode.module +++ sitelink.module @@ -1,9 +1,9 @@ '; + var $html_link_class = 'sitelink_link'; + var $html_link_wrapperA = '

'; } /* }}} */ -/* {{{ janode_help() */ +/* {{{ sitelink_help() */ /** * Implementation of hook_help(). */ -function janode_help($section) { +function sitelink_help($section) { switch ($section) { case 'admin/modules#description': - return t('The JANode node type definition module.'); - case 'node/add#janode': + return t('The sitelink node type definition module.'); + case 'node/add#sitelink': return t('A node with an HTTP link that is periodically checked for 404') . '

'; } // end switch() } /* }}} */ -/* {{{ janode_info() */ +/* {{{ sitelink_info() */ /** * Implementation of hook_info() */ -function janode_node_info() { - return array('janode' => array('name' => t("Jan's node"), 'base' => 'janode')); -} -/* }}} */ - -/* {{{ janode_perm() */ +function sitelink_node_info() { + return array('sitelink' => array('name' => t("page link"), 'base' => 'sitelink')); +} +/* }}} */ + +/* {{{ sitelink_perm() */ /** * Implementation of hook_perm() */ -function janode_perm() { - return array('create janode', 'edit own janode'); -} -/* }}} */ - -/* {{{ janode_access() */ +function sitelink_perm() { + return array('create sitelink', 'edit own sitelink'); +} +/* }}} */ + +/* {{{ sitelink_access() */ /** * Implementation of hook_access() */ -function janode_access($op, $node) { +function sitelink_access($op, $node) { global $user; switch ($op) { @@ -92,10 +92,10 @@ return TRUE; } case 'create': - return user_access('create janode'); + return user_access('create sitelink'); case 'update': case 'delete': - if (user_access('edit own janode') && $user->uid == $node->uid) { + if (user_access('edit own sitelink') && $user->uid == $node->uid) { return TRUE; } } @@ -104,18 +104,18 @@ } /* }}} */ -/* {{{ janode_menu() */ +/* {{{ sitelink_menu() */ /** * Implementation of hook_menu() */ -function janode_menu($may_cache) { +function sitelink_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( - 'path' => 'node/add/janode', - 'title' => t('janode'), - 'access' => user_access('create janode') + 'path' => 'node/add/sitelink', + 'title' => t('sitelink'), + 'access' => user_access('create sitelink') ); } @@ -123,65 +123,65 @@ } /* }}} */ -/* {{{ janode_settings() */ +/* {{{ sitelink_settings() */ /** * Implementation of hook_settings() */ -function janode_settings() { +function sitelink_settings() { $form = array(); - $form['janode'] = array( + $form['sitelink'] = array( '#type' => 'fieldset', - '#title' => 'janode ' . t('settings'), + '#title' => 'sitelink ' . t('settings'), '#tree' => TRUE ); - $form['janode']['show_link_on_teaser'] = array( + $form['sitelink']['show_link_on_teaser'] = array( '#type' => 'checkbox', '#title' => t('Display the link on teasers'), - '#default_value' => _janode_local_settings('show_link_on_teaser'), + '#default_value' => _sitelink_local_settings('show_link_on_teaser'), '#description' => t('Set this to enable the link display on teasers') ); - $form['janode']['show_link_on_body'] = array( + $form['sitelink']['show_link_on_body'] = array( '#type' => 'checkbox', '#title' => t('Display the link on main node body'), - '#default_value' => _janode_local_settings('show_link_on_body'), + '#default_value' => _sitelink_local_settings('show_link_on_body'), '#description' => t('Set this to enable the link display on node main body') ); - $form['janode']['index_how_many_per_cron'] = array( + $form['sitelink']['index_how_many_per_cron'] = array( '#type' => 'textfield', - '#title' => t('How many janodes to 404 test'), - '#default_value' => _janode_local_settings('index_how_many_per_cron'), + '#title' => t('How many sitelinks to 404 test'), + '#default_value' => _sitelink_local_settings('index_how_many_per_cron'), '#size' => 8, '#maxlength' => 8, - '#description' => t('The maximum janodes to 404 test on each cron run. '. + '#description' => t('The maximum sitelinks to 404 test on each cron run. '. "Don't set this too high or the cron may stall.") ); - $form['janode']['enable_404_check'] = array( + $form['sitelink']['enable_404_check'] = array( '#type' => 'checkbox', '#title' => t('Enable link checking by cron'), - '#default_value' => _janode_local_settings('enable_404_check'), + '#default_value' => _sitelink_local_settings('enable_404_check'), '#description' => t('Uncheck to disable link checking by cron') ); - $form['janode']['markup1'] = array( + $form['sitelink']['markup1'] = array( '#type' => 'markup', '#value' => t('The following allow the admin to "wrap" the link up in custom html') ); - $form['janode']['html_link_class'] = array( + $form['sitelink']['html_link_class'] = array( '#type' => 'textfield', '#title' => t("The class name applied to link's HREF"), - '#default_value' => _janode_local_settings('html_link_class'), + '#default_value' => _sitelink_local_settings('html_link_class'), '#description' => t('The class applied to the HREF link') ); - $form['janode']['html_link_wrapperA'] = array( + $form['sitelink']['html_link_wrapperA'] = array( '#type' => 'textfield', '#title' => t('Link prefix'), - '#default_value' => _janode_local_settings('html_link_wrapperA'), + '#default_value' => _sitelink_local_settings('html_link_wrapperA'), '#description' => t('This prefixs the link') ); - $form['janode']['html_link_wrapperB'] = array( + $form['sitelink']['html_link_wrapperB'] = array( '#type' => 'textfield', '#title' => t('Link suffix'), - '#default_value' => _janode_local_settings('html_link_wrapperB'), + '#default_value' => _sitelink_local_settings('html_link_wrapperB'), '#description' => t('This suffixs the link') ); @@ -189,13 +189,13 @@ } /* }}} */ -/* {{{ janode_form() */ +/* {{{ sitelink_form() */ /** * Implementation of hook_form() */ -function janode_form(&$node) { +function sitelink_form(&$node) { - _janode_debug("janode_form(" . $node->nid . ")"); + _sitelink_debug("sitelink_form(" . $node->nid . ")"); $form['title'] = array( '#type' => 'textfield', @@ -214,7 +214,7 @@ $form['body_filter']['filter'] = filter_form($node->format); // Now we define the form elements specific to our node type. - if (isset($node->janode_status) && (int)$node->janode_status > 299) { + if (isset($node->sitelink_status) && (int)$node->sitelink_status > 299) { $form['http_link_markup1'] = array( '#type' => 'markup', '#value' => '

' . @@ -231,21 +231,21 @@ '#maxsize' => 254 ); - if (isset($node->janode_status) && (int)$node->janode_status > 299) { + if (isset($node->sitelink_status) && (int)$node->sitelink_status > 299) { drupal_set_message(t('Problem exists with URL'), 'error'); } return $form; } /* }}} */ -/* {{{ janode_validate() */ +/* {{{ sitelink_validate() */ /** * Implementation of hook_validate() */ -function janode_validate(&$node) { +function sitelink_validate(&$node) { if ($node->http_link) { - if (!_janode_is_http_link($node->http_link)) { + if (!_sitelink_is_http_link($node->http_link)) { form_set_error('http_link', t('Field must begin with') . ' http://'); } } @@ -255,89 +255,89 @@ } /* }}} */ -/* {{{ janode_insert() */ +/* {{{ sitelink_insert() */ /** * Implementation of hook_insert() */ -function janode_insert($node) { - db_query("INSERT INTO {janode} (vid, nid, http_link) VALUES (%d, %d, '%s')", +function sitelink_insert($node) { + db_query("INSERT INTO {sitelink} (vid, nid, http_link) VALUES (%d, %d, '%s')", $node->vid, $node->nid, $node->http_link); } /* }}} */ -/* {{{ janode_update() */ +/* {{{ sitelink_update() */ /** * Implementation of hook_update */ -function janode_update($node) { +function sitelink_update($node) { if($node->revision) { - janode_insert($node); + sitelink_insert($node); } else { - db_query("UPDATE {janode} SET http_link = '%s' WHERE vid = %d", $node->http_link, $node->vid); - } -} -/* }}} */ - -/* {{{ janode_nodeapi() */ + db_query("UPDATE {sitelink} SET http_link = '%s' WHERE vid = %d", $node->http_link, $node->vid); + } +} +/* }}} */ + +/* {{{ sitelink_nodeapi() */ /** * Implementation of hook_nodeapi() */ -function janode_nodeapi(&$node, $op, $teaser, $page) { +function sitelink_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'delete revision': - db_query("DELETE FROM {janode} WHERE vid = %d", $node->vid); + db_query("DELETE FROM {sitelink} WHERE vid = %d", $node->vid); return; } } /* }}} */ -/* {{{ janode_delete() */ +/* {{{ sitelink_delete() */ /** * Implementation of hook_delete() */ -function janode_delete($node) { - db_query("DELETE FROM {janode} WHERE nid = %d", $node->nid); -} -/* }}} */ - -/* {{{ janode_load() */ +function sitelink_delete($node) { + db_query("DELETE FROM {sitelink} WHERE nid = %d", $node->nid); +} +/* }}} */ + +/* {{{ sitelink_load() */ /** * Implementation of hook_load() */ -function janode_load($node) { - $sql = "SELECT http_link, status AS janode_status FROM {janode} WHERE vid = %d"; +function sitelink_load($node) { + $sql = "SELECT http_link, status AS sitelink_status FROM {sitelink} WHERE vid = %d"; return db_fetch_object(db_query($sql, $node->vid)); } /* }}} */ -/* {{{ janode_view() */ +/* {{{ sitelink_view() */ /** * Implementation of hook_view() */ -function janode_view(&$node, $teaser = FALSE, $page = FALSE) { +function sitelink_view(&$node, $teaser = FALSE, $page = FALSE) { $node = node_prepare($node, $teaser); - $http_link_info = theme('janode_http_link', $node); - if (_janode_local_settings('show_link_on_body')) { + $http_link_info = theme('sitelink_http_link', $node); + if (_sitelink_local_settings('show_link_on_body')) { $node->body .= $http_link_info; } - if (_janode_local_settings('show_link_on_teaser')) { + if (_sitelink_local_settings('show_link_on_teaser')) { $node->teaser .= $http_link_info; } } /* }}} */ -/* {{{ theme_janode_http_link() */ -function theme_janode_http_link($node) { - - $link_class = _janode_local_settings('html_link_class'); +/* {{{ theme_sitelink_http_link() */ +function theme_sitelink_http_link($node) { + + $link_class = _sitelink_local_settings('html_link_class'); $link_class_array = (strlen($link_class)) ? array('class' => $link_class) : array(); - $link_prefix = _janode_local_settings('html_link_wrapperA'); + $link_prefix = _sitelink_local_settings('html_link_wrapperA'); $link_prefix_text = (strlen($link_prefix)) ? (check_markup($link_prefix,FILTER_FORMAT_DEFAULT, FALSE)) : (''); - $link_suffix = _janode_local_settings('html_link_wrapperB'); + $link_suffix = _sitelink_local_settings('html_link_wrapperB'); $link_suffix_text = (strlen($link_suffix)) ? (check_markup($link_suffix,FILTER_FORMAT_DEFAULT, FALSE)) : (''); $link_text = l($node->http_link, $node->http_link, $link_class_array, NULL, NULL, FALSE, FALSE); @@ -345,21 +345,21 @@ } /* }}} */ -/* {{{ janode_cron() */ +/* {{{ sitelink_cron() */ /** * Implementation of hook_cron() */ -function janode_cron() { - - if (!(int)_janode_local_settings('enable_404_check')) { +function sitelink_cron() { + + if (!(int)_sitelink_local_settings('enable_404_check')) { return; } - $max_to_do = (int)_janode_local_settings('index_how_many_per_cron'); + $max_to_do = (int)_sitelink_local_settings('index_how_many_per_cron'); $limit_sql = ($max_to_do > 0) ? ("LIMIT $max_to_do") : (""); - $r = db_query("SELECT * FROM {janode} ORDER BY last_checked ASC $limit_sql"); + $r = db_query("SELECT * FROM {sitelink} ORDER BY last_checked ASC $limit_sql"); while ($row = db_fetch_object($r)) { - _janode_check_404($row); + _sitelink_check_404($row); } } /* }}} */ @@ -368,17 +368,17 @@ /* Helper functions follow */ /*=========================*/ -/* {{{ _janode_check_404() */ -/** - * _janode_check_404() +/* {{{ _sitelink_check_404() */ +/** + * _sitelink_check_404() * * @param - * An object of a janode + * An object of a sitelink * * @return * void, act's directly on the db table */ -function _janode_check_404($janode) { +function _sitelink_check_404($sitelink) { static $message_once = TRUE; // check php var "allow_url_fopen" is true as we need it to fetch the URL @@ -399,10 +399,10 @@ $status = 0; // provide a default value to ensure var exists // use my error handler for this part - set_error_handler("_janode_error_handler"); + set_error_handler("_sitelink_error_handler"); // create a full URL - $url_parts = parse_url($janode->http_link); + $url_parts = parse_url($sitelink->http_link); if (isset($url_parts['port']) && strlen($url_parts['port']) > 0) { $url_parts['host'] .= ':' . $url_parts['port']; } @@ -414,14 +414,14 @@ // currently only support http if ($url_parts['scheme'] != 'http') { - $status = _JANODE_NOT_HTTP; + $status = _SITELINK_NOT_HTTP; } else { if(!function_exists('stream_get_meta_data')) { // needed next - $status = _JANODE_NO_MATA_DATA; + $status = _SITELINK_NO_MATA_DATA; } elseif(!($fp = @fopen($full_url, 'r'))) { - $status = _JANODE_FILE_OPEN_FAILURE; + $status = _SITELINK_FILE_OPEN_FAILURE; unset($_SESSION['messages']['error']); // rough but gets rid of hostname errors, @fopen didn't work } else { @@ -442,19 +442,19 @@ restore_error_handler(); // tell the db what we have discovered... - $sql = "UPDATE {janode} SET last_checked = NOW(), status = '%s' WHERE nid = %d AND vid = %d"; - db_query($sql, (string)$status, $janode->nid, $janode->vid); + $sql = "UPDATE {sitelink} SET last_checked = NOW(), status = '%s' WHERE nid = %d AND vid = %d"; + db_query($sql, (string)$status, $sitelink->nid, $sitelink->vid); // unpublish and force the node into the moderation queue - if ((int)$status > _JANODE_FAILURE_PIVOT) { - db_query("UPDATE {node} SET status = 0, moderate = 1 WHERE nid = %d", $janode->nid); - } -} -/* }}} */ - -/* {{{ _janode_is_http_link() */ -/** - * _janode_is_http_link() + if ((int)$status > _SITELINK_FAILURE_PIVOT) { + db_query("UPDATE {node} SET status = 0, moderate = 1 WHERE nid = %d", $sitelink->nid); + } +} +/* }}} */ + +/* {{{ _sitelink_is_http_link() */ +/** + * _sitelink_is_http_link() * * Used to test the leading portion of the URL for required text * @@ -467,12 +467,12 @@ * @return * TRUE if ok or FALSE otherwise */ -function _janode_is_http_link($s, $check = 'http://') { +function _sitelink_is_http_link($s, $check = 'http://') { return ($check == substr($s, 0, strlen($check))) ? TRUE : FALSE; } /* }}} */ -/* {{{ _janode_error_handler() */ +/* {{{ _sitelink_error_handler() */ /** * PHP callback error handler function * @@ -481,7 +481,7 @@ * the file open operations ending up on the browser. So this * handler exists to ensure these are suppressed. */ -function _janode_error_handler($errno, $errstr, $errfile = NULL, $errline = NULL, $errcont = NULL) { +function _sitelink_error_handler($errno, $errstr, $errfile = NULL, $errline = NULL, $errcont = NULL) { // was @ in operation? if (error_reporting() == 0) { @@ -495,14 +495,14 @@ } /* }}} */ -/* {{{ _janode_local_settings() */ -/** - * _janode_local_settings($name = FALSE) +/* {{{ _sitelink_local_settings() */ +/** + * _sitelink_local_settings($name = FALSE) * * Used to get a modules "settings" value. Note, the "out of box" * settings are defined by the place holder class * - * @see janode_defaults + * @see sitelink_defaults * * @param $name * A string of the variable name to get or FALSE return all variables as array @@ -511,10 +511,10 @@ * array of all variables (if param was false) * string the named variabled value */ -function _janode_local_settings($name = FALSE) { - - $defaults = (array)(new _janode_defaults); - if (!($settings = variable_get('janode', FALSE))) { +function _sitelink_local_settings($name = FALSE) { + + $defaults = (array)(new _sitelink_defaults); + if (!($settings = variable_get('sitelink', FALSE))) { $settings = $defaults; } @@ -535,9 +535,9 @@ } /* }}} */ -/* {{{ _janode_debug() */ -function _janode_debug($s) { - if (defined("_JANODE_DEBUG") && _JANODE_DEBUG) { +/* {{{ _sitelink_debug() */ +function _sitelink_debug($s) { + if (defined("_SITELINK_DEBUG") && _SITELINK_DEBUG) { error_log($s); } } === modified file 'INSTALL.txt' --- INSTALL.txt +++ INSTALL.txt @@ -2,16 +2,16 @@ ================ $Id: INSTALL.txt,v 1.1 2006/05/23 23:50:56 karpuz Exp $ -1. Place the janode folder in your drupal/modules folder +1. Place the sitelink folder in your drupal/modules folder (or if multisite and this module is meant to be available to just one site in drupal/sites/www.YOURSITE.com/modules) -2. Enable the janode module at administer > modules +2. Enable the sitelink module at administer > modules 3. Ensure the correct admin users have permissions to administer the - janode module at administer > access control + sitelink module at administer > access control -4. Set-up the module at administer > settings > janode +4. Set-up the module at administer > settings > sitelink 5. Read the supplied README.txt file === modified file 'README.txt' --- README.txt +++ README.txt @@ -2,12 +2,12 @@ =============== $Id: README.txt,v 1.1.2.2 2006/05/26 11:59:38 karpuz Exp $ -This is a node type that allows you to create a library of http:// +sitelink is a node type that allows you to create a library of http:// links to other resources on the Internet. Each node has a title, the matching url and a description. The node can be allocated to a taxonomy in the normal way. -You can use Janode to create your own webdirectory. Janode also -periodically checks each http:// link for 404 errors. Any Janodes +You can use sitelink to create your own webdirectory. sitelink also +periodically checks each http:// link for 404 errors. Any sitelinks with a 404 error are put into a moderation queue for investigation. To install simply go to "admin >> modules" and enable. @@ -15,12 +15,12 @@ required for this module. Don't forget to go to "admin >> access control" to setup -which roles can create/modify own janodes. +which roles can create/modify own sitelinks. Limitation: currently only "http://" links are permitted. Cron is used to attempt an "HTTP GET" of your link. If an -invalid http header (say 404) is detected, the janode is +invalid http header (say 404) is detected, the sitelink is placed back into the moderation queue and unpublished. The site admin should decide what to do with it. @@ -29,7 +29,7 @@ may block this thus sending all ur links back into the moderation queue. If this is the case and you are unable to chamge any external firewall rule sets but wish to continue -using Janodes then you can disable the automatic link check +using sitelinks then you can disable the automatic link check facility as show below. Settings @@ -41,7 +41,7 @@ Display the link on main node body Does what it says on the tin -How many janodes to 404 test +How many links to 404 test Does what it says on the tin. Don't set this too high. The module batch tests the links.