1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| /****************************************************
* Name: Tagcloud
* Version: 0.2
* Desc: Displays the containing words of documents in a "tag cloud"
* Based on the Tagcloud 1.1. snippet created by Marc Hinse, mh@madeyourweb.com
* Converted to EtomiteCMS by Bogge, bogge.com
*
* Change 0.1 => 0.2 Removed explode $parent and optimized sql query. Thanks to adamzyg.
*
* Usage: [[tagcloud?parent=`1,3,5,6,7,14`&min=`3`&landing=`12`
* Parameters:
* parent: comma separated list of the folders that conatin the documents which are to be counted
* min: Minimum occurrences of a word to be displayed
* landing: the id of your search result page. If you don´t have one, create it like: [!FlexSearchForm?FSF_showResults=`1` &FSF_showForm=`0`!]
* (this is required for linking the tags)
* ***************************************************/
//Start Config
$parent = isset($parent)? $parent : "0";
$min = isset($min)? $min : "2";
$landing = isset($landing)? $landing : "[~[*id*]~]";
$minChars = 4; //Minimum number of chars in word
$exclude = array('',' ',' ',' ','and','a','-','—','–','the','—','to','.',':',',','på',' '); //exclude list
$indication = array(',','.',':'); //array of chars to be deleted
//End Config
If (!$tags) {
$select = $etomite->getIntTableRows($fields="pagetitle,longtitle,description,content", $from="site_content", $where="parent IN ($parent) AND published = 1 AND searchable=1 AND deleted=0", $sort="", $dir="", $limit="", $push=false, $addPrefix=true);
while ($contents = $etomite->fetchRow($select, $mode='both')) {
$content.=$contents['pagetitle'].' '.$contents['longtitle'].' '.$contents['description'].' '.$contents['content'];
}
$content=strtolower(str_replace($indication,' ',strip_tags($content))); //all to lower and without HTML
$array_content=explode(' ',$content); //split them in separate words
$number=array_count_values($array_content); //count the words
$words=array();
foreach($number as $key => $worth) {
if($worth>$min && (!in_array($key,$exclude) && (strlen($key) >= $minChars))) { //look if the word counts the required minimum and is not in the exclude list
$words[$key] = $worth; //put them in a new array
}
}
}
else {
$words=array();
foreach($tags as $tag) {
if($tag['count']>=$min && (!in_array($tag['tag'],$exclude))) {
$words[$tag['tag']] = $tag['count'];
}
}
}
//unset($words['etomite']); //if you want to override the value of words (in this case 'etomite'), uncomment it and put in your word
$max_size=max($words); //word with most hits
//$words['etomite']=8; // put in again your deleted word and value from two lines above
ksort($words); //sort them alphabetically (just comment that out, then they will be unsortet
$multiplier=400/$max_size; //define the multiplier for the size (play with that to fit your site!)
$min_size=80; //minimum size
$output='<div class="tagcloud">';
foreach($words as $key => $worth) {
$font_size=$multiplier*$worth;
//$countvalues='('.$worth.')'; //uncomment this for displaying the hits next to the links
$output.='<span><a style="font-size:'.max($font_size,$min_size).'%;" href="[~'.$landing.'~]&FSF_search='.$key.'">'.$key.'</a>'.$countvalues.'</span> ';
$output.="\r\n";
}
$output.='</div>';
return $output; |