Ejemplo n.º 1
0
        $temp_split = split("<title>", $twitter_raw_rss);
        for ($k = 1; $k <= 7; $k += 1) {
            $final_string_array = split("\\<", $temp_split[$k]);
            $tweets[$i][] = $final_string_array[0];
        }
        for ($h = 1; $h <= 6; $h += 1) {
            echo "<li>" . $tweets[$i][$h] . "<br>";
            //split_words($tweets[$h]);
            //$array_search_words = split_words($tweets[$h]);
            //foreach ($array_search_words as $value) {
            //$stripped_tweet = ereg_replace($value, "", $stripped_tweet);
            //}
            $stripped_tweet = $tweets[$i][$h];
            $stripped_tweet = ereg_replace(" in |(S|s)aw |I |i |you |and |a |with |to |is | of | for |movie | it |it | not| as| it|it |Just | just|just| was| my ", " ", $stripped_tweet);
            $stripped_tweet = preg_replace('/[^a-zA-Z0-9-\\s]/', ' ', $stripped_tweet);
            $stripped_tweet = ereg_replace(" {2,}", ' ', $stripped_tweet);
            $stripped_tweet = ereg_replace(" . ", ' ', $stripped_tweet);
            $stripped_tweet = ereg_replace("the ", ' ', $stripped_tweet);
            $stripped_tweet = ereg_replace("saw ", ' ', $stripped_tweet);
            $stripped_tweet = ereg_replace("Saw ", ' ', $stripped_tweet);
            //echo  $stripped_tweet;
            $string_for_cloud = $string_for_cloud . " " . $stripped_tweet;
        }
        echo "<p><hr>";
    }
}
$cloud = new wordCloud();
//echo $string_for_cloud;
$cloud->addString($string_for_cloud);
echo $cloud->showCloud();
echo "</body></html>";
Ejemplo n.º 2
0
    function ModulePage()
    {
        global $PIO, $PTE;
        if (isset($_GET['action'])) {
            // 標籤雲
            require './module/wordcloud.class.php';
            $pte_vals = array('{$TITLE}' => TITLE, '{$RESTO}' => '');
            $dat = $PTE->ParseBlock('HEADER', $pte_vals);
            $dat .= '<style type="text/css">
.word { padding: 4px 4px 4px 4px; letter-spacing: 3px; text-decoration: none; font-weight: normal; }
.size9 { color: #000 !important; font-size: 200%; }
.size8 { color: #111 !important; font-size: 170%; }
.size7 { color: #222 !important; font-size: 150%; }
.size6 { color: #333 !important; font-size: 120%; }
.size5 { color: #444 !important; font-size: 110%; }
.size4 { color: #555 !important; font-size: 100%; }
.size3 { color: #666 !important; font-size: 90%; }
.size2 { color: #777 !important; font-size: 80%; }
.size1 { color: #888 !important; font-size: 70%; }
.size0 { color: #999 !important; font-size: 60%; }
</style>
</head>
<body id="main">';
            $p = $PIO->fetchPosts($PIO->fetchPostList());
            $cloud = new wordCloud();
            foreach ($p as $pp) {
                if ($pp['category']) {
                    $pp['category'] = substr(str_replace(array(',', '&#44;'), ' ', $pp['category']), 1, -1);
                    $cloud->addString($pp['category']);
                }
            }
            $myCloud = $cloud->showCloud('array');
            if (is_array($myCloud)) {
                foreach ($myCloud as $key => $value) {
                    $dat .= '<a href="./pixmicat.php?mode=category&c=' . urlencode($value['word']) . '" class="word size' . $value['range'] . '">' . $value['word'] . '</a>' . "\n";
                }
            }
            echo $dat . "</body></html>";
            return;
        }
        if (!isset($_GET['no'])) {
            die('[Error] not enough parameter.');
        }
        if (!isset($_POST['tag'])) {
            $post = $PIO->fetchPosts($_GET['no']);
            if (!count($post)) {
                die('[Error] Post does not exist.');
            }
            $pte_vals = array('{$TITLE}' => TITLE, '{$RESTO}' => '');
            $dat = $PTE->ParseBlock('HEADER', $pte_vals);
            $dat .= '</head><body id="main">';
            $dat .= '<form action="' . $this->mypage . '&amp;no=' . $_GET['no'] . '" method="POST">Tag: <input type="text" name="tag" value="' . htmlentities(substr(str_replace('&#44;', ',', $post[0]['category']), 1, -1), ENT_QUOTES, 'UTF-8') . '" size="28" /><input type="submit" name="submit" value="Tag!" /></form>';
            echo $dat . "</body></html>";
        } else {
            $Tag = CleanStr($_POST['tag']);
            if ($_SERVER['REQUEST_METHOD'] != 'POST') {
                error(_T('regist_notpost'));
            }
            // 非正規POST方式
            $post = $PIO->fetchPosts($_GET['no']);
            $parentNo = $post[0]['resto'] ? $post[0]['resto'] : $post[0]['no'];
            $threads = array_flip($PIO->fetchThreadList());
            $threadPage = floor($threads[$parentNo] / PAGE_DEF);
            if (!count($post)) {
                die('[Error] Post does not exist.');
            }
            if (USE_CATEGORY && $Tag) {
                // 修整標籤樣式
                $ss = method_exists($PIO, '_replaceComma') ? '&#44;' : ',';
                // Dirty implement
                $category = explode(',', $Tag);
                // 把標籤拆成陣列
                $category = $ss . implode($ss, array_map('trim', $category)) . $ss;
                // 去空白再合併為單一字串 (左右含,便可以直接以,XX,形式搜尋)
            } else {
                $category = '';
            }
            $PIO->updatePost($_GET['no'], array('category' => $category));
            $PIO->dbCommit();
            if (STATIC_HTML_UNTIL == -1 || $threadPage <= STATIC_HTML_UNTIL) {
                updatelog(0, $threadPage, true);
            }
            // 僅更新討論串出現那頁
            deleteCache(array($parentNo));
            // 刪除討論串舊快取
            if (isset($_POST['ajaxmode'])) {
                echo $Tag;
            } else {
                header('HTTP/1.1 302 Moved Temporarily');
                header('Location: ' . fullURL() . PHP_SELF2 . '?' . time());
            }
        }
    }
Ejemplo n.º 3
0
$cloud-&gt;addWord('php'); // Basic Method of Adding Keyword
$cloud-&gt;addWord(array('word' =&gt; 'google', 'size' =&gt; 2, 'url' =&gt; 'http://www.google.com')); // Advanced user method
$cloud-&gt;addWord(array('word' =&gt; 'digg', 'url' =&gt; 'http://digg.com'));
$cloud-&gt;addWord(array('word' =&gt; 'lotsofcode', 'size' =&gt; 4, 'url' =&gt; 'http://www.lotsofcode.com'));
echo $cloud-&gt;showCloud();
?&gt;</textarea>
      <!-- e: basic example -->
      
      <br /><br />
      <!-- b: basic string example -->
      <h3>Basic String Example</h3>
      <p>This is a basic example of how you can impliment a tag-cloud into your website by using a single string</p>
      <div class="word-cloud">
      <?php 
$cloud = new wordCloud();
$cloud->addString('lotsofcode lotsofcode lotsofcode have developed a tag cloud that contains keywords found ');
echo $cloud->showCloud();
?>
      <br /><br />
      </div>
      <h4>Code Example</h4>
      <textarea>&lt;?php
$cloud = new wordCloud();
$cloud-&gt;addString('lotsofcode lotsofcode lotsofcode have developed a tag cloud that contains keywords found ');
echo $cloud-&gt;showCloud();
?&gt;</textarea>
      <!-- e: basic string example -->
      
      <br /><br />
      <!-- b: basic example w/ links -->
      <h3>Example w/ Links</h3>