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 
    }
Exemple #3
0
 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;
     }
 }
Exemple #4
0
 private static function SetHooks()
 {
     // go go go
     self::$hooks = array('%RSS_LINK%' => 'OnePanelLanguage::GetRSSLink', '%AUTHOR_PROFILE_LINK%' => 'OnePanelLanguage::GetAuthorProfileLink');
 }
 public function Save()
 {
     $response = '';
     if (!isset($_POST['key']) || !isset($_POST['text'])) {
         $response .= '<div class="popup_no_results"><div class="module_error_stroke">One Panel Error: Invalid Post</div></div>';
     } else {
         $key = $_POST['key'];
         $text = $_POST['text'];
         $editing_language = OnePanelLanguage::GetDefaultLanguage();
         // TODO this needs to change in 2.1
         if (!$editing_language) {
             trigger_error('One Panel Error: No default language.', E_WARNING);
         }
         $language_data =& OnePanel::GetLanguageData($editing_language);
         if (!isset($language_data[$key])) {
             $response .= '<div class="popup_no_results"><div class="module_error_stroke">One Panel Error: Invalid Language Term</div></div>';
         } else {
             $language_data[$key] = $text;
             OnePanel::PackData();
             $response = true;
         }
     }
     return $response;
 }
 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();
 }
Exemple #7
0
 /**
  * PopulateLanguageData
  * 
  * 
  * @todo One Panel should include some default language sets that are
  * external to the theme config files, if data exists in the config it
  * should override the default set. Otherwise the default set should be
  * used.
  * @return boolean
  */
 private function PopulateLanguageData()
 {
     // Debug
     $success = OnePanelDebug::Track('Populating language data.');
     $return_value = false;
     // Check to see if the data is there
     if (!isset(self::$operational_data[2])) {
         $language_data =& self::$operational_data[2];
         // Reference for easier reading
         $config_data = OnePanelLanguage::GetConfigData();
         // Run a check for the config data.
         if (empty($config_data)) {
             OnePanelDebug::Error('No language data found in the theme config.');
             $return_value = false;
         } else {
             // Ensure that the data contains an array
             if (is_array($config_data)) {
                 $language_data = $config_data;
                 // TEST THIS
                 OnePanelLanguage::CleanupData($language_data);
                 $return_value = true;
             } else {
                 OnePanelDebug::Error('Corrupt language data found in the theme config.');
                 $return_value = false;
             }
         }
     } else {
         OnePanelLanguage::CleanupData(self::$operational_data[2]);
         $return_value = true;
     }
     // Check to see if we need to throw an error
     if (defined('ONE_PANEL_RUNNING') && $return_value == false) {
         $success->Fail();
         trigger_error('One Panel Error: No language data found in config file', E_USER_ERROR);
     } elseif ($return_value == true) {
         $success->Affirm();
     }
     return $return_value;
 }
Exemple #8
0
 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";
         }
     }
 }
Exemple #9
0
 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(']]>', ']]&gt;', $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;
 }