public function BuildChunks() { $enabled = $this->features['HotConversationToggle']->IsActive(); if ($enabled == false) { return false; } // How many posts should we show? TODO add a behaviour hook for this $config_limit = OnePanelConfig::GetNumberOfHotConversationPosts(); if (is_int($config_limit)) { $limit = $config_limit; } else { $limit = 4; } global $wpdb; $sql = 'SELECT pm.meta_value AS file, p.post_title, p.ID FROM ' . DB_NAME . '.' . $wpdb->prefix . 'posts p LEFT JOIN ' . DB_NAME . '.' . $wpdb->prefix . 'postmeta pm on p.ID = pm.post_id WHERE pm.meta_key = "Thumbnail" ORDER BY p.comment_count DESC LIMIT ' . $limit; $result = mysql_query($sql); if (!$result) { return false; } $thumbs = array(); while ($row = mysql_fetch_assoc($result)) { $thumbs[] = $row; } if (count($thumbs) < 2) { return false; } elseif (count($thumbs) < 2 && count($thumbs) > 4) { while (count($thumbs) % 2 != 0) { array_pop($thumbs); } } $this->chunks['Header'] = '<div class="title">' . OnePanelLanguage::GetText('hot_conversation') . '</div>' . "\n"; $this->chunks['Thumbnails'] = '<ul>' . "\n"; foreach ($thumbs as $key => $thumb) { $this->chunks['Thumbnails'] .= '<li><a title="' . $thumb['post_title'] . '" href="' . get_permalink($thumb['ID']) . '"><img alt="' . $thumb['post_title'] . '" src=" ' . $thumb['file'] . '" /></a></li>'; } $this->chunks['Thumbnails'] .= '</ul>' . "\n"; }
public static function PrintPostInfo($gravatar_size = 40) { $enabled = self::FeatureIsActive('PostHeader', 'PostInfoFeature'); if ($enabled == false) { return false; } ?> <div id="post-info"> <?php OnePanelTheme::PrintAuthorGravatar($gravatar_size); ?> <span class="written-by"><?php echo OnePanelLanguage::GetText('written_by'); ?> </span> <span class="author-post-link"><?php the_author_posts_link(); ?> </span> <span class="comments-link"> <?php if (!is_single()) { comments_popup_link('' . OnePanelLanguage::GetText('no_comments') . '', '' . OnePanelLanguage::GetText('1_comments') . '', '% Comments'); } else { ?> <a href="#comments"><?php comments_number('' . OnePanelLanguage::GetText('no_comments') . '', '' . OnePanelLanguage::GetText('1_comments') . '', '% Comments'); ?> </a> <?php } ?> </span> <span class="edit-link"><?php edit_post_link(OnePanelLanguage::GetText('edit_this')); ?> </span> <br /> <span class="last-updated"><?php echo OnePanelLanguage::GetText('last_updated'); ?> </span> <span class="last-updated"><?php the_time(OnePanelLanguage::GetText('date_format')); ?> </span> </div> <?php }
public function BuildChunks() { $feature =& $this->features['FeedBurnerToggle']; // The Subscribe Box if ($feature->IsActive()) { $url = $feature->GetFeedBurnerURL(); $id = $feature->GetFeedBurnerID(); $this->chunks['Header'] = '<div class="title">' . OnePanelLanguage::GetText('subscribe') . '</div>' . "\n"; if (empty($id) && !empty($url)) { // Probably a Google Feedburner account $chunk = '<form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open(\'http://feedburner.google.com/fb/a/mailverify?uri=' . $url . '\', \'popupwindow\', \'scrollbars=yes,width=550,height=520\');return true">'; $chunk .= OnePanelLanguage::GetText('subscribe_detail') . "\n"; $chunk .= '<input type="text" style="width:140px" name="email" value="' . OnePanelLanguage::GetText('subscribe_email') . '" onfocus="if(this.value==\'' . OnePanelLanguage::GetText('subscribe_email') . '\'){this.value=\'\'}" onblur="if(this.value==\'\'){this.value=\'' . OnePanelLanguage::GetText('subscribe_email') . '\'}" />'; $chunk .= '<input type="hidden" value="' . $url . '" name="uri"/><input type="hidden" name="loc" value="en_US"/>'; $chunk .= '<input type="submit" value="' . OnePanelLanguage::GetText('subscribe') . '" />'; $chunk .= '</form>'; } elseif (!empty($id)) { // Probably an old Feedburner account $chunk = '<form action="http://www.feedburner.com/fb/a/emailverify" method="post" target="popupwindow" onsubmit="window.open(\'http://www.feedburner.com/fb/a/emailverifySubmit?feedId=' . $id . '\', \'popupwindow\', \'scrollbars=yes,width=550,height=520\');return true" >' . "\n"; $chunk .= OnePanelLanguage::GetText('subscribe_detail') . "\n"; $chunk .= '<input type="text" id="subbox" name="email" value="' . OnePanelLanguage::GetText('subscribe_email') . '" onfocus="if(this.value==\'' . OnePanelLanguage::GetText('subscribe_email') . '\'){this.value=\'\'}" onblur="if(this.value==\'\'){this.value=\'' . OnePanelLanguage::GetText('subscribe_email') . '\'}" /><input type="submit" value="' . OnePanelLanguage::GetText('subscribe') . '" />' . "\n"; $chunk .= '<input type="hidden" value="http://feeds.feedburner.com/~e?ffid=' . $id . '" name="uri"/>' . "\n"; $chunk .= '<input type="hidden" value="' . get_option('blogname') . '" name="title" />' . "\n"; $chunk .= '</form>' . "\n"; } $this->chunks['Form'] =& $chunk; } }
public function BuildChunks() { if ($this->features['FeaturedVideoFeature']->IsActive()) { $this->chunks['Header'] = '<div class="title">' . OnePanelLanguage::GetText('featured_video') . '</div>' . "\n"; } $this->chunks['Video'] = $this->features['FeaturedVideoFeature']->GetChunk(); }
public function BuildChunks() { // Author Profile Link $enabled = $this->features['AuthorProfileLinkFeature']->IsActive(); if ($enabled) { $this->chunks['AuthorProfileLink'] = '<div id="author-profile-link">' . OnePanelLanguage::GetText('author_view') . '</div>'; } // RSS Link $enabled = $this->features['RSSLinkFeature']->IsActive(); if ($enabled) { $this->chunks['RSSLink'] = '<div id="rss-link">' . OnePanelLanguage::GetText('subscribe_via') . '</div>'; } // Related Articles $enabled = $this->features['RelatedArticlesFeature']->IsActive(); if ($enabled) { $this->chunks['RelatedArticles'] = $this->features['RelatedArticlesFeature']->GetChunk(); } // Social Bookmarks $enabled = $this->features['SocialBookmarksFeature']->IsActive(); if ($enabled) { $chunk = '<div id="social-bookmarks">'; $chunk .= '<a class="digg" href="http://digg.com/submit?phase=2&url=' . get_permalink() . '&title=' . get_the_title() . '">Digg it</a>'; $chunk .= '<a class="stumble" href="http://www.stumbleupon.com/submit?url=' . get_permalink() . '&title=' . get_the_title() . '">Stumble</a>'; $chunk .= '<a class="delicious" href="http://del.icio.us/post?url=' . get_permalink() . '&title=' . get_the_title() . '"> del.icio.us</a>'; $chunk .= '<a class="reddit" href="http://reddit.com/submit?url=' . get_permalink() . '&title=' . get_the_title() . '">reddit</a>'; $chunk .= '<a class="yahoo" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=' . get_the_title() . '&u=' . get_permalink() . '">Yahoo</a>'; $chunk .= '<a class="google" href="http://www.google.com/bookmarks/mark?op=edit&bkmk=' . get_permalink() . '&title=' . get_the_title() . '">Google</a>'; $chunk .= '</div>'; $this->chunks['SocialBookmarks'] =& $chunk; } // Tags $enabled = $this->features['TagsFeature']->IsActive(); if ($enabled) { global $post; $tags = get_the_term_list($post->ID, 'post_tag', '<div class="tag">', '', '</div>'); if (!empty($tags)) { $this->chunks['Tags'] = '<div id="tags"><div class="title">' . OnePanelLanguage::GetText('tags') . '</div>' . $tags . '</div>' . "\n"; } else { $this->chunks['Tags'] = '<div id="no-tags">' . OnePanelLanguage::GetText('no_tags') . '</div>' . "\n"; } } }
private function GetChunkFromCategory() { if (is_null($this->source_id)) { $this->source_id = 1; } // Check for ShowNumberOfPosts behaviour if the requirements are met $default_query = 'cat=' . $this->source_id . '&showposts=1'; $behavioural_params = OnePanelConfig::GetBehaviorAlteration($this->config_module, 'ShowNumberOfPosts'); if (!$behavioural_params) { $query = $default_query; } else { $query = 'cat=' . $this->source_id . '&showposts=' . $behavioural_params[1]; } $recent = new WP_Query($query); global $post; $i = 1; while ($recent->have_posts()) { $recent->the_post(); // Declare Variables if (!isset($this->detail_chunks['Title'])) { $this->detail_chunks['Title']; } if (!isset($this->detail_chunks['Image' . ($i > 1 ? $i : '')])) { $this->detail_chunks['Image' . ($i > 1 ? $i : '')] = ''; } if (!isset($this->detail_chunks['SubTitle' . ($i > 1 ? $i : '')])) { $this->detail_chunks['SubTitle' . ($i > 1 ? $i : '')] = ''; } if (!isset($this->detail_chunks['Content' . ($i > 1 ? $i : '')])) { $this->detail_chunks['Content' . ($i > 1 ? $i : '')] = ''; } if (!isset($this->detail_chunks['NumberOfComments' . ($i > 1 ? $i : '')])) { $this->detail_chunks['NumberOfComments' . ($i > 1 ? $i : '')] = ''; } // Set up pointers $title_chunk =& $this->detail_chunks['Title']; $image_chunk =& $this->detail_chunks['Image' . ($i > 1 ? $i : '')]; $subtitle_chunk =& $this->detail_chunks['SubTitle' . ($i > 1 ? $i : '')]; $content_chunk =& $this->detail_chunks['Content' . ($i > 1 ? $i : '')]; $comments_chunk =& $this->detail_chunks['NumberOfComments' . ($i > 1 ? $i : '')]; // Do the title (Category Name) if ($i == 1) { $title_chunk = '<div class="' . $this->title . '-title">'; $title_chunk .= '<a href="' . get_category_link($this->source_id) . '" title="' . get_cat_name($this->source_id) . '">'; $title_chunk .= !is_null($this->title_limit) && strlen(get_cat_name($this->source_id) > $this->title_limit) ? substr(get_cat_name($this->source_id), 0, $this->title_limit) . '...' : get_cat_name($this->source_id); $title_chunk .= '</a>'; $title_chunk .= '</div>'; } // Comments, ripped off a load of wordpress code for this global $id; $comments_number = get_comments_number($id); if ($comments_number > 1) { $comments_output = str_replace('%', $comments_number, __('% Comments')); } elseif ($comments_number == 0) { $comments_output = OnePanelLanguage::GetText('no_comments'); } else { $comments_output = OnePanelLanguage::GetText('1_comments'); } $comments_chunk = '<div class="' . $this->title . '-comments-number">' . apply_filters('comments_number', $comments_output, $comments_number) . '</div>' . "\n"; // Check to see if we are supposed to use an alternate thumb $default_thumb = get_post_meta($post->ID, 'Thumbnail', true); $behavioural_params = OnePanelConfig::GetBehaviorAlteration($this->config_module, 'UseAlternateThumbnail'); if (!$behavioural_params) { $thumbnail = $default_thumb; } else { $alternate_thumb_object =& $behavioural_params[1]; $custom_field = $alternate_thumb_object->GetCustomField(); $thumbnail = get_post_meta($post->ID, $custom_field, true); if (empty($thumbnail)) { $thumbnail = get_post_meta($post->ID, 'Thumbnail', true); } } $image_chunk = '<div class="' . $this->title . '-image">'; $image_chunk .= '<a href="' . apply_filters('the_permalink', get_permalink()) . '">'; $image_chunk .= '<img alt="' . get_the_title() . '" src="' . $thumbnail . '" />'; // TODO check for behaviour modification $image_chunk .= '</a>'; $image_chunk .= '</div>'; $subtitle_chunk = '<div class="' . $this->title . '-subtitle">'; $subtitle_chunk .= '<a href="' . apply_filters('the_permalink', get_permalink()) . '">'; $subtitle_chunk .= !is_null($this->title_limit) && strlen(get_the_title()) > $this->title_limit ? substr(get_the_title(), 0, $this->title_limit) . '...' : get_the_title(); $subtitle_chunk .= '</a>'; $subtitle_chunk .= '</div>'; $content = get_the_content(OnePanelLanguage::GetText('read_more')); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); // Check to see if the content limit is behaviourally modified $behavioural_params = OnePanelConfig::GetBehaviorAlteration($this->config_module, 'LimitContent'); if ($behavioural_params) { if (is_int($behavioural_params[1])) { $content_limit = $behavioural_params[1]; } } else { $content_limit = $this->content_limit; } if (!is_null($content_limit)) { $content = strip_tags($content); $content = substr($content, 0, $content_limit); $content .= ' <div class="read-more"><a href="' . apply_filters('the_permalink', get_permalink()) . '">' . OnePanelLanguage::GetText('read_more') . ' </a></div>'; } $content_chunk = $content; $i++; } $response = $this->detail_chunks['Title'] . $this->detail_chunks['Image'] . $this->detail_chunks['SubTitle'] . $this->detail_chunks['Content']; if ($i < 1) { for ($j = 2; $j <= $i; $j++) { $response .= $this->detail_chunks['Image' . $j] . $this->detail_chunks['SubTitle' . $j] . $this->detail_chunks['Content' . $j]; } } return $response; }