source: extensions/PWG_Stuffs/modules/Tags/main.inc.php @ 6229

Last change on this file since 6229 was 3609, checked in by patdenice, 15 years ago

Convert all php and tpl files in Unix format for my plugins.

File size: 3.0 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $conf, $template;
6
7function counter_compare($a, $b)
8{
9  if ($a['counter'] == $b['counter'])
10  {
11    return id_compare($a, $b);
12  }
13
14  return ($a['counter'] < $b['counter']) ? +1 : -1;
15}
16
17function id_compare($a, $b)
18{
19  return ($a['id'] < $b['id']) ? -1 : 1;
20}
21
22$pwgCumulus_installed = get_db_plugins('active','pwgCumulus');
23
24$block['TITLE_URL'] = 'tags.php';
25
26$tags = get_available_tags();
27
28if ((!$pwgCumulus_installed and $datas[0] == 'cumulus') or empty($datas[0]))
29{
30  $datas[0] = 'cloud';
31}
32
33if ($datas[0] == 'letters')
34{
35  // we want tags diplayed in alphabetic order
36  usort($tags, 'tag_alpha_compare');
37
38  $current_letter = null;
39  $nb_tags = count($tags);
40  $current_column = 1;
41  $current_tag_idx = 0;
42
43  $letter = array(
44    'tags' => array()
45    );
46
47  foreach ($tags as $tag)
48  {
49    $tag_letter = strtoupper(substr($tag['url_name'], 0, 1));
50
51    if ($current_tag_idx==0) {
52      $current_letter = $tag_letter;
53      $letter['TITLE'] = $tag_letter;
54    }
55
56    //lettre precedente differente de la lettre suivante
57    if ($tag_letter !== $current_letter)
58    {
59      if ($current_column<$conf['tag_letters_column_number']
60          and $current_tag_idx > $current_column*$nb_tags/$conf['tag_letters_column_number'] )
61      {
62        $letter['CHANGE_COLUMN'] = true;
63        $current_column++;
64      }
65
66      $letter['TITLE'] = $current_letter;
67
68      $template->append(
69        'letters',
70        $letter
71        );
72
73      $current_letter = $tag_letter;
74      $letter = array(
75        'tags' => array()
76        );
77    }
78
79    array_push(
80      $letter['tags'],
81      array_merge(
82        $tag,
83        array(
84          'URL' => make_index_url(
85            array(
86              'tags' => array($tag),
87              )
88            ),
89          )
90        )
91      );
92
93    $current_tag_idx++;
94  }
95
96  // flush last letter
97  if (count($letter['tags']) > 0)
98  {
99    unset($letter['CHANGE_COLUMN']);
100    $letter['TITLE'] = $current_letter;
101    $template->append(
102      'letters',
103      $letter
104      );
105  }
106}
107else
108{
109  usort($tags, 'counter_compare');
110  $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
111
112  // depending on its counter and the other tags counter, each tag has a level
113  $tags = add_level_to_tags($tags);
114
115  // we want tags diplayed in alphabetic order
116  usort($tags, 'tag_alpha_compare');
117
118  // display sorted tags
119  foreach ($tags as $tag)
120  {
121    $template->append(
122      'tags',
123      array_merge(
124        $tag,
125        array(
126          'URL' => make_index_url(
127            array(
128              'tags' => array($tag),
129              )
130            ),
131          )
132        )
133      );
134  }
135  if ($datas[0] == 'cumulus')
136  {
137    include_once PWG_CUMULUS_PLUGIN_ROOT . "/include/pwgCumulusContent.class.php";
138    $cumulus = new pwgCumulusContent(get_plugin_data('pwgCumulus'));
139    $cumulus->loc_begin_page_header();
140  }
141}
142
143$template->assign('display_mode', $datas[0]);
144
145if (get_db_plugins('active','typetags'))
146{
147  include(typetags_PATH . 'typetags.php');
148}
149
150?>
Note: See TracBrowser for help on using the repository browser.