--- themesettings.module Sun Aug 02 19:54:48 2009 -0700 +++ themesettings.module Sun Aug 02 20:15:05 2009 -0700 @@ -67,56 +67,59 @@ function themesettings_nodeapi(&$node, $ else { $link = ''; } + // Optionally prepend or append the comments links - $comment_node_type = isset($settings["ts_{$node->type}_comment_singular"]) ? $node->type : 'default'; - if ($op != 'rss item' and $teaser and $settings["ts_{$comment_node_type}_comment_teaser_placement"] != 'links') { - $all = comment_num_all($node->nid); - if ($all) { - $comment_link = _themesettings_link( - $settings["ts_{$comment_node_type}_comment_prefix"], - $settings["ts_{$comment_node_type}_comment_suffix"], - format_plural($all, - $settings["ts_{$comment_node_type}_comment_singular"], - $settings["ts_{$comment_node_type}_comment_plural"] - ), - "node/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_title"]), - NULL, - 'comments' - ); - $new = comment_num_new($node->nid); - if ($new) { - $comment_link .= _themesettings_link( - $settings["ts_{$comment_node_type}_comment_new_prefix"], - $settings["ts_{$comment_node_type}_comment_new_suffix"], - format_plural($new, - $settings["ts_{$comment_node_type}_comment_new_singular"], - $settings["ts_{$comment_node_type}_comment_new_plural"] - ), - "node/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_new_title"]), - NULL, - 'new' - ); + if (module_exists('comment')){ + $comment_node_type = isset($settings["ts_{$node->type}_comment_singular"]) ? $node->type : 'default'; + if ($op != 'rss item' and $teaser and $settings["ts_{$comment_node_type}_comment_teaser_placement"] != 'links') { + $all = comment_num_all($node->nid); + if ($all) { + $comment_link = _themesettings_link( + $settings["ts_{$comment_node_type}_comment_prefix"], + $settings["ts_{$comment_node_type}_comment_suffix"], + format_plural($all, + $settings["ts_{$comment_node_type}_comment_singular"], + $settings["ts_{$comment_node_type}_comment_plural"] + ), + "node/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_title"]), + NULL, + 'comments' + ); + $new = comment_num_new($node->nid); + if ($new) { + $comment_link .= _themesettings_link( + $settings["ts_{$comment_node_type}_comment_new_prefix"], + $settings["ts_{$comment_node_type}_comment_new_suffix"], + format_plural($new, + $settings["ts_{$comment_node_type}_comment_new_singular"], + $settings["ts_{$comment_node_type}_comment_new_plural"] + ), + "node/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_new_title"]), + NULL, + 'new' + ); + } } - } - elseif (!$settings["ts_{$comment_node_type}_comment_add_disable"]) { - $comment_link = _themesettings_link( - $settings["ts_{$comment_node_type}_comment_add_prefix"], - $settings["ts_{$comment_node_type}_comment_add_suffix"], - $settings["ts_{$comment_node_type}_comment_add"], - "comment/reply/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_add_title"]), - NULL, - 'comment-form' - ); - } - if (isset($comment_link)) { - if ($settings["ts_{$comment_node_type}_comment_teaser_placement"] == 'prepend') { - $link = $comment_link . $link; + elseif (!$settings["ts_{$comment_node_type}_comment_add_disable"]) { + $comment_link = _themesettings_link( + $settings["ts_{$comment_node_type}_comment_add_prefix"], + $settings["ts_{$comment_node_type}_comment_add_suffix"], + $settings["ts_{$comment_node_type}_comment_add"], + "comment/reply/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_add_title"]), + NULL, + 'comment-form' + ); } - else { - $link .= $comment_link; + if (isset($comment_link)) { + if ($settings["ts_{$comment_node_type}_comment_teaser_placement"] == 'prepend') { + $link = $comment_link . $link; + } + else { + $link .= $comment_link; + } } } } @@ -155,7 +158,7 @@ function themesettings_nodeapi(&$node, $ * @return * void */ -function themesettings_link_alter(&$node, &$links) { +function themesettings_link_alter(&$links, $node) { // Get current settings global $theme_key; @@ -197,71 +200,73 @@ function themesettings_link_alter(&$node } // Comments link - if (isset($links['comment_comments'])) { - $all = comment_num_all($node->nid); - $links['comment_comments'] = array( - 'title' => _themesettings_link( - $settings["ts_{$comment_node_type}_comment_prefix"], - $settings["ts_{$comment_node_type}_comment_suffix"], - format_plural($all, - $settings["ts_{$comment_node_type}_comment_singular"], - $settings["ts_{$comment_node_type}_comment_plural"] - ), - "node/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_title"]), - NULL, - 'comments' - ), - 'html' => TRUE, - ); - } - if (isset($links['comment_new_comments'])) { - $new = comment_num_new($node->nid); - $links['comment_new_comments'] = array( - 'title' => _themesettings_link( - $settings["ts_{$comment_node_type}_comment_new_prefix"], - $settings["ts_{$comment_node_type}_comment_new_suffix"], - format_plural($new, - $settings["ts_{$comment_node_type}_comment_new_singular"], - $settings["ts_{$comment_node_type}_comment_new_plural"] - ), - "node/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_new_title"]), - NULL, - 'new' - ), - 'html' => TRUE, - ); - } - if (isset($links['comment_add'])) { - if ($node->display_teaser) { - $links['comment_add'] = array( + if (module_exists('comment')) { + if (isset($links['comment_comments'])) { + $all = comment_num_all($node->nid); + $links['comment_comments'] = array( 'title' => _themesettings_link( - $settings["ts_{$comment_node_type}_comment_add_prefix"], - $settings["ts_{$comment_node_type}_comment_add_suffix"], - $settings["ts_{$comment_node_type}_comment_add"], - "comment/reply/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_add_title"]), + $settings["ts_{$comment_node_type}_comment_prefix"], + $settings["ts_{$comment_node_type}_comment_suffix"], + format_plural($all, + $settings["ts_{$comment_node_type}_comment_singular"], + $settings["ts_{$comment_node_type}_comment_plural"] + ), + "node/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_title"]), NULL, - 'comment-form' + 'comments' ), 'html' => TRUE, ); } - else { - $links['comment_add'] = array( + if (isset($links['comment_new_comments'])) { + $new = comment_num_new($node->nid); + $links['comment_new_comments'] = array( 'title' => _themesettings_link( - $settings["ts_{$comment_node_type}_comment_node_prefix"], - $settings["ts_{$comment_node_type}_comment_node_suffix"], - $settings["ts_{$comment_node_type}_comment_node"], - "comment/reply/$node->nid", - array('title' => $settings["ts_{$comment_node_type}_comment_node_title"]), + $settings["ts_{$comment_node_type}_comment_new_prefix"], + $settings["ts_{$comment_node_type}_comment_new_suffix"], + format_plural($new, + $settings["ts_{$comment_node_type}_comment_new_singular"], + $settings["ts_{$comment_node_type}_comment_new_plural"] + ), + "node/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_new_title"]), NULL, - 'comment-form' + 'new' ), 'html' => TRUE, ); } + if (isset($links['comment_add'])) { + if ($node->display_teaser) { + $links['comment_add'] = array( + 'title' => _themesettings_link( + $settings["ts_{$comment_node_type}_comment_add_prefix"], + $settings["ts_{$comment_node_type}_comment_add_suffix"], + $settings["ts_{$comment_node_type}_comment_add"], + "comment/reply/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_add_title"]), + NULL, + 'comment-form' + ), + 'html' => TRUE, + ); + } + else { + $links['comment_add'] = array( + 'title' => _themesettings_link( + $settings["ts_{$comment_node_type}_comment_node_prefix"], + $settings["ts_{$comment_node_type}_comment_node_suffix"], + $settings["ts_{$comment_node_type}_comment_node"], + "comment/reply/$node->nid", + array('title' => $settings["ts_{$comment_node_type}_comment_node_title"]), + NULL, + 'comment-form' + ), + 'html' => TRUE, + ); + } + } } } @@ -277,7 +282,7 @@ function themesettings_link_alter(&$node * @return * void */ -function themesettings_form_alter($form_id, &$form) { +function themesettings_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'system_theme_settings': @@ -287,6 +292,8 @@ function themesettings_form_alter($form_ $var = $form['var']['#value']; $settings = _themesettings_get_settings($var); + $form['buttons']['#weight'] = 1; + // Read more link settings $form['readmore'] = array( '#type' => 'fieldset', @@ -764,11 +771,13 @@ function _themesettings_link($prefix, $s . ($text ? l($text, $path, - $attributes, - $query, - $fragment, - $absolute, - TRUE // Allow HTML. + array( + 'attributes' => $attributes, + 'query' => $query, + 'fragment' => $fragment, + 'absolute' => $absolute, + 'html' => TRUE, + ) ) : '' )