function create_tag_cloud() { $sql = "SELECT DISTINCT `additional_description` AS name FROM `wp_product_list` WHERE `active` = 1 AND `visible` = 1 AND `additional_description` > '' ORDER BY id DESC LIMIT 500"; global $wpdb; $result_array = $wpdb->get_results($sql, ARRAY_A); //$result_array = array_map('trim',$result_array); $result_string = r_implode(",", $result_array); $result_string = str_replace(".", ",", $result_string); $result_string = str_replace(",,", ",", $result_string); $result_string = str_replace(", ", "|", $result_string); $result_string = str_replace(",", "|", $result_string); $tags = explode("|", $result_string); array_walk($tags, 'edit_value'); sort($tags); foreach ($tags as $key => $value) { if (is_null($value)) { unset($tags[$key]); //echo "<br />unset null<br />"; } if ($value == '') { unset($tags[$key]); //echo "<br />unset empty<br />"; } if ($value == ' ') { unset($tags[$key]); //echo "<br />unset space<br />"; } } $cloud = new wordCloud($tags); return $cloud->showCloud(); }
public function createTagCloud($event_id) { $words = $this->CI->tag->getAllReferencedTags($event_id); if (!empty($words)) { $cloud = new wordCloud($words); $cloud_array = $cloud->showCloud('array'); return $this->createTagLink($cloud_array); } }
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(',', ','), ' ', $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 . '&no=' . $_GET['no'] . '" method="POST">Tag: <input type="text" name="tag" value="' . htmlentities(substr(str_replace(',', ',', $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') ? ',' : ','; // 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()); } } }
$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>";
public function videoQueue($uri_array, $event_id) { if ($this->ajax) { $data['ajax'] = true; } $data['event_type'] = 'video'; $this->load->model('Video_model', 'video2'); //event $this->video2->event_id = $event_id; $data['event_name'] = $uri_array['event']; //video if (isset($uri_array['video'])) { if (is_numeric($uri_array['video'])) { // change all is_numeric, is_string groups to if, elseif logic $this->video2->video_id = $uri_array['video']; } elseif (is_string($uri_array['video'])) { $this->video2->video_id = $this->video->get_id_from_url($uri_array['video']); } $data['video_view'] = true; } //user if (isset($uri_array['user']) && is_numeric($uri_array['user'])) { $this->video2->user_id = $uri_array['user']; } if (isset($uri_array['user']) && is_string($uri_array['user'])) { ${$this}->video2->user_id = $this->user->get_id_from_name($uri_array['user']); } //tag if (isset($uri_array['tag']) && is_numeric($uri_array['tag'])) { $this->video2->tag_id = $uri_array['tag']; } if (isset($uri_array['tag']) && is_string($uri_array['tag'])) { $this->video2->tag_id = $this->tag->get_id_from_tag($uri_array['tag']); $data['tag'] = $uri_array['tag']; } //set default sort link $type = ucfirst($data['event_type']); $sort_active = 'upcoming'; $queue_title = 'Upcoming ' . $type . 's'; //create sorting options if (isset($uri_array['sort'])) { //order by date if ($uri_array['sort'] == 'newest') { $this->video2->order_by = 'date'; $sort_active = 'newest'; $queue_title = 'Newest ' . $type . 's'; } //limit to asked videos if ($uri_array['sort'] == 'asked') { $this->video2->video_status = 'asked'; $sort_active = 'asked'; $queue_title = 'Asked ' . $type . 's'; } //limit to current video if ($uri_array['sort'] == 'current') { $this->video2->video_status = 'current'; $sort_active = 'current'; $queue_title = 'Current ' . $type; } } $data['sort'] = $sort_active; $data['event_url'] = $this->uri->assoc_to_uri(array('event' => $uri_array['event'])); //set a sorting array $sort_array = array('<strong>Sort ' . $data['event_type'] . 's by:</strong>'); $sort_active == 'upcoming' ? array_push($sort_array, 'Score') : array_push($sort_array, anchor("conventionnext/queue/{$data['event_url']}", 'Score')); $sort_active == 'newest' ? array_push($sort_array, 'Newest') : array_push($sort_array, anchor("conventionnext/queue/{$data['event_url']}/sort/newest", 'Newest')); $data['sort_array'] = $sort_array; //var_dump($sort_array); if (isset($uri_array['sort'])) { $data['event_url'] = $this->uri->assoc_to_uri(array('event' => $uri_array['event'], 'sort' => $uri_array['sort'])); } $data['queue_title'] = $queue_title; $data['breadcrumb'] = array('Home' => $this->config->site_url(), 'Events' => 'event/', ucwords(str_replace('_', ' ', $uri_array['event'])) => "conventionnext/queue/{$data['event_url']}"); // pagination if (isset($event_id)) { $segment_array = $this->uri->segment_array(); if (is_numeric($segment_array[$this->uri->total_segments()])) { array_pop($segment_array); } $base_url = implode('/', $segment_array); $pagination_per_page = '5'; // $this->video2->limit = $pagination_per_page; // // if(is_numeric($this->uri->segment($this->uri->total_segments()))) // $this->video2->offset = $this->uri->segment($this->uri->total_segments()); $offset = is_numeric($this->uri->segment($this->uri->total_segments())) ? $this->uri->segment($this->uri->total_segments()) : 0; $data['results'] = $this->video2->videoQueue(); $total_rows = count($data['results']); $data['results'] = array_splice($data['results'], $offset, $pagination_per_page); $this->load->library('pagination'); $config['base_url'] = site_url($base_url); $config['total_rows'] = $total_rows; $config['per_page'] = $pagination_per_page; $config['uri_segment'] = $this->uri->total_segments(); //add some style $config['first_link'] = ''; $config['last_link'] = ''; $config['next_link'] = '>'; $config['next_tag_open'] = '<li class="next"><span>'; $config['next_tag_close'] = '</span></li>'; $config['prev_link'] = '<'; $config['prev_tag_open'] = '<li class="prev"><span>'; $config['prev_tag_close'] = '</span></li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="current">'; $config['cur_tag_close'] = '</li>'; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $data['offset'] = $this->uri->segment($this->uri->total_segments()); if (!is_numeric($data['offset'])) { $data['offset'] = 0; } } //set user score foreach ($data['results'] as $key => $row) { if ($this->userauth->isUser()) { $this->vote->type = 'video'; $score = $this->vote->votedScore($row['video_id'], $this->userauth->user_id); if ($score > 0) { $data['results'][$key]['voted'] = 'up'; } else { if ($score < 0) { $data['results'][$key]['voted'] = 'down'; } else { $data['results'][$key]['voted'] = false; } } } else { $data['results'][$key]['voted'] = false; } } // tag cloud - this section might need a little tweaking if (isset($event_id) && !empty($data['results'])) { $this->load->model('tag_model'); $this->load->library('wordcloud'); $this->tag_model->type = 'video'; $words = $this->tag_model->getAllReferencedTags($event_id); if (!empty($words)) { $cloud = new wordCloud($words); $cloud_array = $cloud->showCloud('array'); $this->load->library('tag_lib'); $data['cloud'] = $this->tag_lib->createTagLink($cloud_array); // create tag links for all tags in queue foreach ($data['results'] as $k1 => $question) { foreach ($question['tags'] as $k2 => $tag) { $data['results'][$k1]['tags'][$k2] = $this->tag_lib->createTagLink($tag); } } } } $this->load->view('view_queue', $data); }