Esempio n. 1
0
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @category  HTML
 * @package   HTML_TagCloud
 * @author    Bastian Onken <*****@*****.**>
 * @copyright 2010 Bastian Onken
 * @license   http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version   SVN: $Id: TagCloud_example1.php 295251 2010-02-19 11:32:43Z bastianonken $
 * @link      http://pear.php.net/package/HTML_TagCloud
 * @since     File available since Release 0.1.0
 */
require_once 'HTML/TagCloud.php';
// To get the date function working properly we have to set the time zone
date_default_timezone_set('UTC');
// Create an instance of HTML_TagCloud with default behaviour
$tags = new HTML_TagCloud();
// Add some elements
$tags->addElement('PHP', 'http://www.php.net', 39, strtotime('-1 day'));
$tags->addElement('XML', 'http://www.xml.org', 21, strtotime('-2 week'));
$tags->addElement('Perl', 'http://www.perl.org', 15, strtotime('-1 month'));
$tags->addElement('PEAR', 'http://pear.php.net', 32, time());
$tags->addElement('MySQL', 'http://www.mysql.com', 10, strtotime('-2 day'));
$tags->addElement('PostgreSQL', 'http://pgsql.com', 6, strtotime('-3 week'));
// Print out HTML and CSS
print $tags->buildALL();
// Show source, you don't need this line in your code, it's just for showing off
?>
<br/>
Take a look at the source:<br/>
<?php 
show_source(__FILE__);
Esempio n. 2
0
 * @link      http://pear.php.net/package/HTML_TagCloud
 * @since     File available since Release 0.2.4
 */
require_once 'HTML/TagCloud.php';
// To get the date function working properly we have to set the time zone
date_default_timezone_set('UTC');
// Set up font sizes, colors and a non-default tag separator
$baseFontSize = 150;
$fontSizeRange = 75;
$sizeSuffix = '%';
$latestColor = 'FF0000';
$earliestColor = 'FFFB00';
$thresholds = 6;
$tagSeparator = '<span style="color:#DDDDDD;"> / </span>';
// Create an instance of HTML_TagCloud with settings we defined above
$tagCloud = new HTML_TagCloud($baseFontSize, $fontSizeRange, $latestColor, $earliestColor, $thresholds, $sizeSuffix, $tagSeparator);
// Set up some tags
$tagFixtures = array('blogs', 'folksonomy', 'wikis', 'rss', 'widgets', 'ajax', 'podcasting', 'semantic', 'xhtml', 'design', 'mobility');
// Set up some time occurrences
$timeFixtures = array('-1 year', '-6 month', '-3 month', '-1 month', '-1 week', '-1 day');
// Build and add randomized tags to the TagCloud
foreach ($tagFixtures as $tag) {
    // Set up how many occurrences this tag has
    $numberOfOccurrences = rand(1, 50);
    // Randomize through the time fixtures and set up the age of this tag
    $time = $timeFixtures[rand(0, count($timeFixtures) - 1)];
    // Finally add it to the cloud, to see how the time and count values are
    //  interpreted we add them to the tagname to see their current value
    $tagCloud->addElement($tag, $dummyURL, $numberOfOccurrences, strtotime($time));
}
// Now return a HTML page that contains additional TagCloud style definitions
Esempio n. 3
0
 /**
  *
  * add a Tag Element to build Tag Cloud
  *
  * @return  void
  * @param   string  $tag
  * @param   string  $url
  * @param   int     $count
  * @param   int     $timestamp unixtimestamp 
  * @param   string  $title HTML <a> title
  * @access  public
  */
 public function addElement($name = '', $url = '', $count = 0, $timestamp = null, $title = '')
 {
     parent::addElement($name, $url, $count, $timestamp);
     $this->_titles[$name] = $title;
 }
Esempio n. 4
0
 * @package   HTML_TagCloud
 * @author    Bastian Onken <*****@*****.**>
 * @copyright 2010 Bastian Onken
 * @license   http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version   SVN: $Id: TagCloud_example2.php 295251 2010-02-19 11:32:43Z bastianonken $
 * @link      http://pear.php.net/package/HTML_TagCloud
 * @since     File available since Release 0.1.0
 */
require_once 'HTML/TagCloud.php';
// To get the date function working properly we have to set the time zone
date_default_timezone_set('UTC');
// Set up new font sizes
$baseFontSize = 36;
$fontSizeRange = 24;
// Create an instance of HTML_TagCloud with non-default font sizes
$tags = new HTML_TagCloud($baseFontSize, $fontSizeRange);
// Prepare some items, without specifying the timestamp (this way they will get
//  the actual timestamp)
$name = 'a';
foreach (range(0, 15) as $i) {
    $arr[$i]['name'] = $name;
    $arr[$i]['url'] = '#';
    $arr[$i]['count'] = $i;
    $name++;
}
// Submit the prepared items to the TagCloud
$tags->addElements($arr);
$tags->addElement('H', '#', 16);
$tags->addElement('P', '#', 18);
// Get the CSS part only
$css = $tags->buildCSS();