--- site_map.module 2008-02-08 07:21:59.000000000 +0000
+++ site_map_n.module 2008-06-23 15:53:38.000000000 +0000
@@ -151,6 +151,12 @@ function site_map_admin_settings() {
'#description' => t('Specify how many subcategories should be included on the categorie page. Enter "all" to include all subcategories,"0" to include no subcategories, or "-1" not to append the depth at all.'),
);
+ $form['site_map_content_options']['site_map_taxonomy_tree_page_increment'] = array(
+ '#type' => 'select',
+ '#title' => t('Select how many taxonomy terms to display per page'),
+ '#default_value' => variable_get('site_map_taxonomy_tree_page_increment', 0),
+ '#options' => array(0 => "ALL", 100 => "100", 200 => "200", 500 => "500")
+ );
$form['site_map_rss_options'] = array(
'#type' => 'fieldset',
'#title' => t('RSS settings'),
@@ -434,101 +440,157 @@ function _site_map_menu_tree($pid = 1, $
* This function can be called from blocks or pages as desired.
*/
function _site_map_taxonomys() {
+
+ $show_pager = false;
+ $page_increment = variable_get("site_map_taxonomy_tree_page_increment", 0);
+
if (module_exists('taxonomy') && $vids = variable_get('site_map_show_vocabularies', array())) {
$result = db_query('SELECT vid, name, description
FROM {vocabulary} WHERE vid IN (%s) ORDER BY weight ASC, name', implode(',', $vids));
+
+ $current_page = 0;
+ $start_from = 0;
+ $total_entries = 0;
+ $tree_items;
+
while ($t = db_fetch_object($result)) {
- $output .= _site_map_taxonomy_tree($t->vid, $t->name, $t->description);
+ _site_map_collate_trees($tree_items, $total_entries, $t->vid, $t->name, $t->description);
}
+
+ $display_limit = $total_entries;
+
+ if($page_increment > 0){
+ $show_pager = true;
+ $current_page = $_GET['page'] ? $_GET['page'] : 0;
+ $start_from = $current_page * $page_increment;
+ $display_limit = intval(($current_page + 1) * $page_increment);
+ $display_limit = ($display_limit >= $total_entries)? $total_entries:$display_limit;
+
+ $GLOBALS['pager_page_array'][] = $current_page;
+ $GLOBALS['pager_total'][] = intval($total_entries / $page_increment) + 1;
+ }
+
+ $output .= _site_map_taxonomy_tree($start_from, $display_limit, $tree_items);
+
+ if($show_pager === true){
+ $output .= theme('pager', NULL, $page_increment);
+ }
}
return $output;
}
-/**
- * Render taxonomy tree
- *
- * @param $tree The results of taxonomy_get_tree() with optional 'count' fields.
- * @param $name An optional name for the tree. (Default: NULL)
- * @param $description An optional description of the tree. (Default: NULL)
- * @return A string representing a rendered tree.
+function _site_map_collate_trees(&$tree_items, &$count, $vid, $name = NULL, $description = NULL){
+ $tree = taxonomy_get_tree($vid);
+ foreach($tree as $term){
+ $tree_items[$count][0] = $vid;
+ $tree_items[$count][1] = $name;
+ $tree_items[$count][2] = $description;
+ $tree_items[$count][3] = $term;
+ $count++;
+ }
+}
+
+/**
+ * Render taxonomy tree
+ *
+ * @param $start_from The start index for the array of terms.
+ * @param $display_count The end index for the array of terms
+ * @param $items The array of all the terms
+ * @return A string representing a rendered tree.
*/
-function _site_map_taxonomy_tree($vid, $name = NULL, $description = NULL) {
- if ($vid == variable_get('forum_nav_vocabulary', '')) {
- $title = l($name, 'forum');
- }
- else {
- $title = $name ? check_plain($name) : '';
- }
- $title .= (module_exists('commentrss') ? ' '. theme('site_map_feed_icon', url("crss/vocab/$vid"), 'comment') : '');
-
- $last_depth = -1;
- $rss_depth = variable_get('site_map_rss_depth', 'all');
- if (!is_numeric($rss_depth) || $rss_depth < 0) {
- $rss_depth = 'all';
- }
- $cat_depth = variable_get('site_map_categories_depth', 'all');
- if (!is_numeric($cat_depth)) {
- $cat_depth = 'all';
- }
-
- $output = $description ? '
'. check_plain($description) .'
' : '';
-
- $output .= '';
- // taxonomy_get_tree() honors access controls
- $tree = taxonomy_get_tree($vid);
- foreach ($tree as $term) {
- // Adjust the depth of the
based on the change
- // in $term->depth since the $last_depth.
- if ($term->depth > $last_depth) {
- for ($i = 0; $i < ($term->depth - $last_depth); $i++) {
- $output .= '';
- }
- }
- else if ($term->depth < $last_depth) {
- for ($i = 0; $i < ($last_depth - $term->depth); $i++) {
- $output .= '
';
- }
- }
- // Display the $term.
- $output .= '- ';
- $term->count = taxonomy_term_count_nodes($term->tid);
- if ($term->count) {
- if ($cat_depth < 0) {
- $output .= l($term->name, taxonomy_term_path($term), array('title' => $term->description));
- }
- else {
- $output .= l($term->name, "taxonomy/term/$term->tid/$cat_depth", array('title' => $term->description));
- }
- }
- else {
- $output .= check_plain($term->name);
- }
- if (variable_get('site_map_show_count', 1)) {
- $output .= " ($term->count)";
- }
- if (variable_get('site_map_show_rss_links', 1)) {
- $output .= ' '. theme('site_map_feed_icon', url("taxonomy/term/$term->tid/$rss_depth/feed"));
- $output .= (module_exists('commentrss') ? ' '. theme('site_map_feed_icon', url("crss/term/$term->tid"), 'comment') : '');
- }
-
-
-
- $output .= "
\n";
- // Reset $last_depth in preparation for the next $term.
- $last_depth = $term->depth;
- }
-
- // Bring the depth back to where it began, -1.
- if ($last_depth > -1) {
- for ($i = 0; $i < ($last_depth + 1); $i++) {
- $output .= '
';
- }
- }
- $output .= "
\n";
- $output = theme('box', $title, $output);
-
- return $output;
+function _site_map_taxonomy_tree($start_from, $display_count, $items) {
+ $last_vid = -1;
+ $output = "";
+ $glob_output = "";
+
+ for($pager_count = $start_from; $pager_count < $display_count; $pager_count++){
+
+ $vid = $items[$pager_count][0];
+ $name = $items[$pager_count][1];
+ $description = $items[$pager_count][2];
+ $term = $items[$pager_count][3];
+
+ if($vid != $last_vid){
+ if($last_vid != -1){
+ // Bring the depth back to where it began, -1.
+ if ($last_depth > -1) {
+ for ($i = 0; $i < ($last_depth + 1); $i++) {
+ $output .= '';
+ }
+ }
+ $output .= "\n";
+ $glob_output .= theme('box', $title, $output);
+ }
+ $last_vid = $vid;
+
+ if ($vid == variable_get('forum_nav_vocabulary', '')) {
+ $title = l($name, 'forum');
+ }
+ else {
+ $title = $name ? check_plain($name) : '';
+ }
+ $title .= (module_exists('commentrss') ? ' '. theme('site_map_feed_icon', url("crss/vocab/$vid"), 'comment') : '');
+
+ $last_depth = -1;
+ $rss_depth = variable_get('site_map_rss_depth', 'all');
+ if (!is_numeric($rss_depth) || $rss_depth < 0) {
+ $rss_depth = 'all';
+ }
+ $cat_depth = variable_get('site_map_categories_depth', 'all');
+ if (!is_numeric($cat_depth)) {
+ $cat_depth = 'all';
+ }
+
+ $output = $description ? ''. check_plain($description) .'
' : '';
+ $output .= '';
+ }
+ // Adjust the depth of the
based on the change
+ // in $term->depth since the $last_depth.
+ if ($term->depth > $last_depth) {
+ for ($i = 0; $i < ($term->depth - $last_depth); $i++) {
+ $output .= '';
+ }
+ }
+ else if ($term->depth < $last_depth) {
+ for ($i = 0; $i < ($last_depth - $term->depth); $i++) {
+ $output .= '
';
+ }
+ }
+ // Display the $term.
+ $output .= '- ';
+ $term->count = taxonomy_term_count_nodes($term->tid);
+ if ($term->count) {
+ if ($cat_depth < 0) {
+ $output .= l($term->name, taxonomy_term_path($term), array('title' => $term->description));
+ }
+ else {
+ $output .= l($term->name, "taxonomy/term/$term->tid/$cat_depth", array('title' => $term->description));
+ }
+ }
+ else {
+ $output .= check_plain($term->name);
+ }
+ if (variable_get('site_map_show_count', 1)) {
+ $output .= " ($term->count)";
+ }
+ if (variable_get('site_map_show_rss_links', 1)) {
+ $output .= ' '. theme('site_map_feed_icon', url("taxonomy/term/$term->tid/$rss_depth/feed"));
+ $output .= (module_exists('commentrss') ? ' '. theme('site_map_feed_icon', url("crss/term/$term->tid"), 'comment') : '');
+ }
+
+ $output .= "
\n";
+ // Reset $last_depth in preparation for the next $term.
+ $last_depth = $term->depth;
+ }
+ if ($last_depth > -1) {
+ for ($i = 0; $i < ($last_depth + 1); $i++) {
+ $output .= '
';
+ }
+ }
+ $output .= "
\n";
+ $glob_output .= theme('box', $title, $output);
+ return $glob_output;
}
/**