- Cambios

git-svn-id: https://192.168.0.254/svn/Proyectos.OriginalHouse_Web/trunk@6 54e8636e-a86c-764f-903d-b964358a1ae2
This commit is contained in:
David Arranz 2011-07-04 17:34:14 +00:00
parent af511152ec
commit bb4ee042a7
701 changed files with 263753 additions and 2346 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
información/favico.psd Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
información/mvboli.ttf Normal file

Binary file not shown.

View File

@ -596,7 +596,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
'post_content' => $url,
'post_mime_type' => $type,
'guid' => $url,
'context' => 'custom-header');
'context' => 'custom-header'
);
// Save the data
$id = wp_insert_attachment($object, $file);

View File

@ -454,7 +454,7 @@ class WP_User_Search {
function WP_User_Search ($search_term = '', $page = '', $role = '') {
_deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
$this->search_term = $search_term;
$this->search_term = stripslashes( $search_term );
$this->raw_page = ( '' == $page ) ? false : (int) $page;
$this->page = (int) ( '' == $page ) ? 1 : $page;
$this->role = $role;
@ -485,7 +485,7 @@ class WP_User_Search {
$searches = array();
$search_sql = 'AND (';
foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
$searches[] = $col . " LIKE '%$this->search_term%'";
$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
$search_sql .= implode(' OR ', $searches);
$search_sql .= ')';
}

View File

@ -228,6 +228,10 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
'post_content' => $content,
), $post_data );
// This should never be set as it would then overwrite an existing attachment.
if ( isset( $attachment['ID'] ) )
unset( $attachment['ID'] );
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
@ -281,6 +285,10 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data =
'post_content' => $content,
), $post_data );
// This should never be set as it would then overwrite an existing attachment.
if ( isset( $attachment['ID'] ) )
unset( $attachment['ID'] );
// Save the attachment metadata
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) )
@ -419,6 +427,11 @@ function media_upload_form_handler() {
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
$post = $_post = get_post($attachment_id, ARRAY_A);
$post_type_object = get_post_type_object( $post[ 'post_type' ] );
if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )
continue;
if ( isset($attachment['post_content']) )
$post['post_content'] = $attachment['post_content'];
if ( isset($attachment['post_title']) )

View File

@ -135,6 +135,9 @@ function edit_post( $post_data = null ) {
if ( empty($post_data) )
$post_data = &$_POST;
// Clear out any data in internal vars.
unset( $post_data['filter'] );
$post_ID = (int) $post_data['post_ID'];
$post = get_post( $post_ID );
$post_data['post_type'] = $post->post_type;
@ -341,7 +344,8 @@ function bulk_edit_posts( $post_data = null ) {
continue;
}
$tax_names = get_object_taxonomies( get_post($post_ID) );
$post = get_post( $post_ID );
$tax_names = get_object_taxonomies( $post );
foreach ( $tax_names as $tax_name ) {
$taxonomy_obj = get_taxonomy($tax_name);
if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
@ -363,6 +367,9 @@ function bulk_edit_posts( $post_data = null ) {
unset( $post_data['tax_input']['category'] );
}
$post_data['post_mime_type'] = $post->post_mime_type;
$post_data['guid'] = $post->guid;
$post_data['ID'] = $post_ID;
$updated[] = wp_update_post( $post_data );
@ -534,6 +541,9 @@ function wp_write_post() {
$_POST['post_mime_type'] = '';
// Clear out any data in internal vars.
unset( $_POST['filter'] );
// Check for autosave collisions
// Does this need to be updated? ~ Mark
$temp_id = false;
@ -553,6 +563,15 @@ function wp_write_post() {
}
}
// Edit don't write if we have a post id.
if ( isset( $_POST['ID'] ) ) {
$_POST['post_ID'] = $_POST['ID'];
unset ( $_POST['ID'] );
}
if ( isset( $_POST['post_ID'] ) ) {
return edit_post();
}
$translated = _wp_translate_postdata( false );
if ( is_wp_error($translated) )
return $translated;
@ -997,9 +1016,9 @@ function wp_edit_attachments_query( $q = false ) {
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
$post_type = get_post_type_object( 'attachment' );
$states = array( 'inherit' );
$states = 'inherit';
if ( current_user_can( $post_type->cap->read_private_posts ) )
$states[] = 'private';
$states .= ',private';
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
$media_per_page = (int) get_user_option( 'upload_per_page' );

View File

@ -294,7 +294,7 @@ function update_core($from, $to) {
$mysql_version = $wpdb->db_version();
$required_php_version = '4.3';
$required_mysql_version = '4.1.2';
$wp_version = '3.1.3';
$wp_version = '3.1.4';
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );

View File

@ -29,37 +29,39 @@
}
}
$(document).ready( function() {
$(document).ready(function() {
$('#pass1').val('').keyup( check_pass_strength );
$('#pass2').val('').keyup( check_pass_strength );
$('#pass-strength-result').show();
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
$('#nickname').blur(function(){
var str = $(this).val() || $('#user_login').val();
var select = $('#display_name');
var sel = select.children('option:selected').attr('id');
select.children('#display_nickname').remove();
if ( ! select.children('option[value=' + str + ']').length )
select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>');
$('#'+sel).attr('selected', 'selected');
});
$('#first_name, #last_name').blur(function(){
var select = $('#display_name');
var first = $('#first_name').val(), last = $('#last_name').val();
var sel = select.children('option:selected').attr('id');
$('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
if ( first && ! select.children('option[value=' + first + ']').length )
select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
if ( last && ! select.children('option[value=' + last + ']').length )
select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
if ( first && last ) {
if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
$('.color-palette').click(function(){$(this).siblings('input[name="admin_color"]').prop('checked', true)});
$('#first_name, #last_name, #nickname').blur(function(){
var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [],
inputs = {
display_nickname : $('#nickname').val(),
display_username : $('#user_login').val(),
display_firstname : $('#first_name').val(),
display_lastname : $('#last_name').val()
};
if ( inputs.display_firstname && inputs.display_lastname ) {
inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
}
$('#'+sel).attr('selected', 'selected');
$('option', select).remove();
$.each(inputs, function( id, value ) {
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
if ( inputs[id].length && $.inArray( val, dub ) == -1 ) {
dub.push(val);
$('<option />', {
'id': id,
'text': val,
'selected': (id == current)
}).appendTo( select );
}
});
});
});
});
})(jQuery);

View File

@ -1 +1 @@
(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery);
(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",true)});a("#first_name, #last_name, #nickname").blur(function(){var c=a("#display_name"),e=c.find("option:selected").attr("id"),f=[],d={display_nickname:a("#nickname").val(),display_username:a("#user_login").val(),display_firstname:a("#first_name").val(),display_lastname:a("#last_name").val()};if(d.display_firstname&&d.display_lastname){d.display_firstlast=d.display_firstname+" "+d.display_lastname;d.display_lastfirst=d.display_lastname+" "+d.display_firstname}a("option",c).remove();a.each(d,function(i,g){var h=g.replace(/<\/?[a-z][^>]*>/gi,"");if(d[i].length&&a.inArray(h,f)==-1){f.push(h);a("<option />",{id:i,text:h,selected:(i==e)}).appendTo(c)}})})})})(jQuery);

View File

@ -127,7 +127,7 @@ include('./admin-header.php');
$new_admin_email = get_option( 'new_admin_email' );
if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?>
<div class="updated inline">
<p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_admin_email, esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
<p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), esc_html( $new_admin_email ), esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
</div>
<?php endif; ?>
</td>

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
# This file is distributed under the same license as the Multisite package.
msgid ""
msgstr ""
"PO-Revision-Date: 2011-05-25 19:11:08+0000\n"
"PO-Revision-Date: 2011-06-29 21:47:38+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

View File

@ -1,750 +0,0 @@
<?php
add_action( 'admin_menu', 'akismet_config_page' );
add_action( 'admin_menu', 'akismet_stats_page' );
akismet_admin_warnings();
function akismet_admin_init() {
global $wp_version;
// all admin functions are disabled in old versions
if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) {
function akismet_version_warning() {
echo "
<div id='akismet-warning' class='updated fade'><p><strong>".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ."</strong> ".sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "</p></div>
";
}
add_action('admin_notices', 'akismet_version_warning');
return;
}
if ( function_exists( 'get_plugin_page_hook' ) )
$hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
else
$hook = 'dashboard_page_akismet-stats-display';
add_action('admin_head-'.$hook, 'akismet_stats_script');
add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
wp_enqueue_style('akismet.css');
wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
wp_enqueue_script('akismet.js');
}
add_action('admin_init', 'akismet_admin_init');
function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
$akismet_nonce = 'akismet-update-key';
function akismet_config_page() {
if ( function_exists('add_submenu_page') )
add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
}
function akismet_plugin_action_links( $links, $file ) {
if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
$links[] = '<a href="plugins.php?page=akismet-key-config">'.__('Settings').'</a>';
}
return $links;
}
add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
function akismet_conf() {
global $akismet_nonce, $wpcom_api_key;
if ( isset($_POST['submit']) ) {
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
die(__('Cheatin&#8217; uh?'));
check_admin_referer( $akismet_nonce );
$key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
$home_url = parse_url( get_bloginfo('url') );
if ( empty($key) ) {
$key_status = 'empty';
$ms[] = 'new_key_empty';
delete_option('wordpress_api_key');
} elseif ( empty($home_url['host']) ) {
$key_status = 'empty';
$ms[] = 'bad_home_url';
} else {
$key_status = akismet_verify_key( $key );
}
if ( $key_status == 'valid' ) {
update_option('wordpress_api_key', $key);
$ms[] = 'new_key_valid';
} else if ( $key_status == 'invalid' ) {
$ms[] = 'new_key_invalid';
} else if ( $key_status == 'failed' ) {
$ms[] = 'new_key_failed';
}
if ( isset( $_POST['akismet_discard_month'] ) )
update_option( 'akismet_discard_month', 'true' );
else
update_option( 'akismet_discard_month', 'false' );
if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
update_option( 'akismet_show_user_comments_approved', 'true' );
else
update_option( 'akismet_show_user_comments_approved', 'false' );
} elseif ( isset($_POST['check']) ) {
akismet_get_server_connectivity(0);
}
if ( empty( $key_status) || $key_status != 'valid' ) {
$key = get_option('wordpress_api_key');
if ( empty( $key ) ) {
if ( empty( $key_status ) || $key_status != 'failed' ) {
if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
$ms[] = 'no_connection';
else
$ms[] = 'key_empty';
}
$key_status = 'empty';
} else {
$key_status = akismet_verify_key( $key );
}
if ( $key_status == 'valid' ) {
$ms[] = 'key_valid';
} else if ( $key_status == 'invalid' ) {
delete_option('wordpress_api_key');
$ms[] = 'key_empty';
} else if ( !empty($key) && $key_status == 'failed' ) {
$ms[] = 'key_failed';
}
}
$messages = array(
'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
'new_key_valid' => array('color' => '4AB915', 'text' => __('Your key has been verified. Happy blogging!')),
'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')),
'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')),
'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
);
?>
<?php if ( !empty($_POST['submit'] ) ) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
<?php endif; ?>
<div class="wrap">
<h2><?php _e('Akismet Configuration'); ?></h2>
<?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
<div class="updated below-h2" id="message"><p><?php _e( '<strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.' ); ?></p></div>
<?php } ?>
<div class="narrow">
<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
<?php if ( !$wpcom_api_key ) { ?>
<p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p>
<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
<?php foreach ( $ms as $m ) : ?>
<p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
<?php endforeach; ?>
<p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/">What is this?</a>'); ?>)</p>
<?php if ( isset( $invalid_key) && $invalid_key ) { ?>
<h3><?php _e('Why might my key be invalid?'); ?></h3>
<p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
<?php } ?>
<?php } ?>
<?php akismet_nonce_field($akismet_nonce) ?>
<p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></label></p>
<p><label><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php if ( get_option('akismet_show_user_comments_approved') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></label></p>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Update options &raquo;'); ?>" /></p>
</form>
<form action="" method="post" id="akismet-connectivity" style="margin: auto; width: 400px; ">
<h3><?php _e('Server Connectivity'); ?></h3>
<?php
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) {
?>
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Network functions are disabled.'); ?></p>
<p><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
<?php
} else {
$servers = akismet_get_server_connectivity();
$fail_count = count($servers) - count( array_filter($servers) );
if ( is_array($servers) && count($servers) > 0 ) {
// some connections work, some fail
if ( $fail_count > 0 && $fail_count < count($servers) ) { ?>
<p style="padding: .5em; background-color: #aa0; color: #fff; font-weight:bold;"><?php _e('Unable to reach some Akismet servers.'); ?></p>
<p><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
<?php
// all connections fail
} elseif ( $fail_count > 0 ) { ?>
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to reach any Akismet servers.'); ?></p>
<p><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
<?php
// all connections work
} else { ?>
<p style="padding: .5em; background-color: #4AB915; color: #fff; font-weight:bold;"><?php _e('All Akismet servers are available.'); ?></p>
<p><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
<?php
}
} else {
?>
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to find Akismet servers.'); ?></p>
<p><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
<?php
}
}
if ( !empty($servers) ) {
?>
<table style="width: 100%;">
<thead><th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th></thead>
<tbody>
<?php
asort($servers);
foreach ( $servers as $ip => $status ) {
$color = ( $status ? '#4AB915' : '#888');
?>
<tr>
<td><?php echo htmlspecialchars($ip); ?></td>
<td style="padding: 0 .5em; font-weight:bold; color: #fff; background-color: <?php echo $color; ?>"><?php echo ($status ? __('Accessible') : __('Re-trying') ); ?></td>
<?php
}
}
?>
</tbody>
</table>
<p><?php if ( get_option('akismet_connectivity_time') ) echo sprintf( __('Last checked %s ago.'), human_time_diff( get_option('akismet_connectivity_time') ) ); ?></p>
<p class="submit"><input type="submit" name="check" value="<?php _e('Check network status &raquo;'); ?>" /></p>
<p><?php printf( __('<a href="%s" target="_blank">Click here</a> to confirm that <a href="%s" target="_blank">Akismet.com is up</a>.'), 'http://status.automattic.com/9931/136079/Akismet-API', 'http://status.automattic.com/9931/136079/Akismet-API' ); ?></p>
</form>
</div>
</div>
<?php
}
function akismet_stats_page() {
if ( function_exists('add_submenu_page') )
add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
}
function akismet_stats_script() {
?>
<script type="text/javascript">
function resizeIframe() {
document.getElementById('akismet-stats-frame').style.height = "2500px";
};
function resizeIframeInit() {
document.getElementById('akismet-stats-frame').onload = resizeIframe;
window.onresize = resizeIframe;
}
addLoadEvent(resizeIframeInit);
</script><?php
}
function akismet_stats_display() {
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
$blog = urlencode( get_bloginfo('url') );
$url = 'http://';
if ( is_ssl() )
$url = 'https://';
$url .= 'akismet.com/web/1.0/user-stats.php';
$url .= "?blog={$blog}&api_key=" . akismet_get_key();
?>
<div class="wrap">
<iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
</div>
<?php
}
function akismet_stats() {
if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
return;
if ( !$count = get_option('akismet_spam_count') )
return;
$path = plugin_basename(__FILE__);
echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
global $submenu;
if ( isset( $submenu['edit-comments.php'] ) )
$link = 'edit-comments.php';
else
$link = 'edit.php';
echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
}
add_action('activity_box_end', 'akismet_stats');
function akismet_admin_warnings() {
global $wpcom_api_key;
if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
function akismet_warning() {
echo "
<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
";
}
add_action('admin_notices', 'akismet_warning');
return;
} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
function akismet_warning() {
global $wpdb;
$waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
$next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
if ( $waiting > 0 )
echo "
<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>
";
}
add_action('admin_notices', 'akismet_warning');
return;
}
}
// FIXME placeholder
function akismet_comment_row_action( $a, $comment ) {
// failsafe for old WP versions
if ( !function_exists('add_comment_meta') )
return $a;
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
$comment_status = wp_get_comment_status( $comment->comment_ID );
$desc = null;
if ( !$user_result || $user_result == $akismet_result ) {
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
$desc = __( 'Flagged as spam by Akismet' );
elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
$desc = __( 'Cleared by Akismet' );
} else {
$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
if ( $user_result == 'true' )
$desc = sprintf( __('Flagged as spam by %s'), $who );
else
$desc = sprintf( __('Un-spammed by %s'), $who );
}
// add a History item to the hover links, just after Edit
if ( $akismet_result ) {
$b = array();
foreach ( $a as $k => $item ) {
$b[ $k ] = $item;
if ( $k == 'edit' )
$b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
}
$a = $b;
}
if ( $desc )
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
$comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
$comment_count = intval( $comment_count );
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), number_format_i18n( $comment_count ) ) . '</span></span>';
}
return $a;
}
add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
function akismet_comment_status_meta_box($comment) {
$history = akismet_get_comment_history( $comment->comment_ID );
if ( $history ) {
echo '<div class="akismet-history" style="margin: 13px;">';
foreach ( $history as $row ) {
$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
echo htmlspecialchars( $row['message'] ) . '</div>';
}
echo '</div>';
}
}
// add an extra column header to the comments screen
function akismet_comments_columns( $columns ) {
$columns[ 'akismet' ] = __( 'Akismet' );
return $columns;
}
#add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
// Show stuff in the extra column
function akismet_comment_column_row( $column, $comment_id ) {
if ( $column != 'akismet' )
return;
$history = akismet_get_comment_history( $comment_id );
if ( $history ) {
echo '<dl class="akismet-history">';
foreach ( $history as $row ) {
echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
echo '<dd>' . htmlspecialchars( $row['message'] ) . '</dd>';
}
echo '</dl>';
}
}
#add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
// END FIXME
// call out URLS in comments
function akismet_text_add_link_callback( $m ) {
// bare link?
if ( $m[4] == $m[2] )
return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
else
return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
}
function akismet_text_add_link_class( $comment_text ) {
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', 'akismet_text_add_link_callback', $comment_text );
}
add_filter('comment_text', 'akismet_text_add_link_class');
// WP 2.5+
function akismet_rightnow() {
global $submenu, $wp_db_version;
// clean_url was deprecated in WP 3.0
$esc_url = 'clean_url';
if ( function_exists( 'esc_url' ) )
$esc_url = 'esc_url';
if ( 8645 < $wp_db_version ) // 2.7
$link = 'edit-comments.php?comment_status=spam';
elseif ( isset( $submenu['edit-comments.php'] ) )
$link = 'edit-comments.php?page=akismet-admin';
else
$link = 'edit.php?page=akismet-admin';
if ( $count = get_option('akismet_spam_count') ) {
$intro = sprintf( _n(
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
$count
), 'http://akismet.com/', number_format_i18n( $count ) );
} else {
$intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
}
if ( $queue_count = akismet_spam_count() ) {
$queue_text = sprintf( _n(
'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
$queue_count
), number_format_i18n( $queue_count ), $esc_url($link) );
} else {
$queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
}
$text = $intro . '<br />' . $queue_text;
echo "<p class='akismet-right-now'>$text</p>\n";
}
add_action('rightnow_end', 'akismet_rightnow');
// For WP >= 2.5
function akismet_check_for_spam_button($comment_status) {
if ( 'approved' == $comment_status )
return;
if ( function_exists('plugins_url') )
$link = 'admin.php?action=akismet_recheck_queue';
else
$link = 'edit-comments.php?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true';
echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
}
add_action('manage_comments_nav', 'akismet_check_for_spam_button');
function akismet_submit_nonspam_comment ( $comment_id ) {
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
$comment_id = (int) $comment_id;
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
if ( !$comment ) // it was deleted
return;
// use the original version stored in comment_meta if available
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
$comment = (object) array_merge( (array)$comment, $as_submitted );
}
$comment->blog = get_bloginfo('url');
$comment->blog_lang = get_locale();
$comment->blog_charset = get_option('blog_charset');
$comment->permalink = get_permalink($comment->comment_post_ID);
$comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
if ( is_object($current_user) ) {
$comment->reporter = $current_user->user_login;
}
if ( is_object($current_site) ) {
$comment->site_domain = $current_site->domain;
}
$comment->user_role = '';
if ( isset( $comment->user_ID ) )
$comment->user_role = akismet_get_user_roles($comment->user_ID);
if ( akismet_test_mode() )
$comment->is_test = 'true';
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
if ( $comment->reporter ) {
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam'), $comment->reporter ), 'report-ham' );
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
}
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
}
function akismet_submit_spam_comment ( $comment_id ) {
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
$comment_id = (int) $comment_id;
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
if ( !$comment ) // it was deleted
return;
if ( 'spam' != $comment->comment_approved )
return;
// use the original version stored in comment_meta if available
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
$comment = (object) array_merge( (array)$comment, $as_submitted );
}
$comment->blog = get_bloginfo('url');
$comment->blog_lang = get_locale();
$comment->blog_charset = get_option('blog_charset');
$comment->permalink = get_permalink($comment->comment_post_ID);
$comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
if ( is_object($current_user) ) {
$comment->reporter = $current_user->user_login;
}
if ( is_object($current_site) ) {
$comment->site_domain = $current_site->domain;
}
$comment->user_role = '';
if ( isset( $comment->user_ID ) )
$comment->user_role = akismet_get_user_roles($comment->user_ID);
if ( akismet_test_mode() )
$comment->is_test = 'true';
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
if ( $comment->reporter ) {
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
}
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
}
// For WP 2.7+
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
if ( $new_status == $old_status )
return;
# we don't need to record a history item for deleted comments
if ( $new_status == 'delete' )
return;
if ( !is_admin() )
return;
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
return;
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
return;
global $current_user;
$reporter = '';
if ( is_object( $current_user ) )
$reporter = $current_user->user_login;
// Assumption alert:
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
// determine why the transition_comment_status action was triggered. And there are several different ways by which
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
if ( isset($_POST['action']) || isset($_GET['action']) ) {
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
return akismet_submit_spam_comment( $comment->comment_ID );
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
return akismet_submit_nonspam_comment( $comment->comment_ID );
}
}
if ( !get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
}
add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
// Total spam in queue
// get_option( 'akismet_spam_count' ) is the total caught ever
function akismet_spam_count( $type = false ) {
global $wpdb;
if ( !$type ) { // total
$count = wp_cache_get( 'akismet_spam_count', 'widget' );
if ( false === $count ) {
if ( function_exists('wp_count_comments') ) {
$count = wp_count_comments();
$count = $count->spam;
} else {
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
}
wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
}
return $count;
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
$type = '';
} else { // pingback, trackback, ...
$type = $wpdb->escape( $type );
}
return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
}
function akismet_recheck_queue() {
global $wpdb, $akismet_api_host, $akismet_api_port;
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
return;
$moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
foreach ( (array) $moderation as $c ) {
$c['user_ip'] = $c['comment_author_IP'];
$c['user_agent'] = $c['comment_agent'];
$c['referrer'] = '';
$c['blog'] = get_bloginfo('url');
$c['blog_lang'] = get_locale();
$c['blog_charset'] = get_option('blog_charset');
$c['permalink'] = get_permalink($c['comment_post_ID']);
$c['user_role'] = '';
if ( isset( $c['user_ID'] ) )
$c['user_role'] = akismet_get_user_roles($c['user_ID']);
if ( akismet_test_mode() )
$c['is_test'] = 'true';
$id = (int) $c['comment_ID'];
$query_string = '';
foreach ( $c as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
if ( 'true' == $response[1] ) {
wp_set_comment_status($c['comment_ID'], 'spam');
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
} elseif ( 'false' == $response[1] ) {
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
// abnormal result: error
} else {
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );
}
}
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit;
}
add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
// Check connectivity between the WordPress blog and Akismet's servers.
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
function akismet_check_server_connectivity() {
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
$test_host = 'rest.akismet.com';
// Some web hosts may disable one or both functions
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
return array();
$ips = gethostbynamel($test_host);
if ( !$ips || !is_array($ips) || !count($ips) )
return array();
$servers = array();
foreach ( $ips as $ip ) {
$response = akismet_verify_key( akismet_get_key(), $ip );
// even if the key is invalid, at least we know we have connectivity
if ( $response == 'valid' || $response == 'invalid' )
$servers[$ip] = true;
else
$servers[$ip] = false;
}
return $servers;
}
// Check the server connectivity and store the results in an option.
// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
// Returns the same associative array as akismet_check_server_connectivity()
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
$servers = get_option('akismet_available_servers');
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
return $servers;
// There's a race condition here but the effect is harmless.
$servers = akismet_check_server_connectivity();
update_option('akismet_available_servers', $servers);
update_option('akismet_connectivity_time', time());
return $servers;
}
// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
function akismet_server_connectivity_ok() {
// skip the check on WPMU because the status page is hidden
global $wpcom_api_key;
if ( $wpcom_api_key )
return true;
$servers = akismet_get_server_connectivity();
return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
}

View File

@ -1,7 +0,0 @@
#submitted-on { position: relative; }
#the-comment-list .author .akismet-user-comment-count { display: inline; }
#dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
.akismet-status { float: right; }
.akismet-status a { color: #AAA; font-style: italic; }
span.comment-link a { text-decoration: underline; }
span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,10 +0,0 @@
jQuery(document).ready(function () {
jQuery('.akismet-status').each(function () {
var thisId = jQuery(this).attr('commentid');
jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
});
jQuery('.akismet-user-comment-count').each(function () {
var thisId = jQuery(this).attr('commentid');
jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
});
});

View File

@ -1,512 +0,0 @@
<?php
/**
* @package Akismet
*/
/*
Plugin Name: Akismet
Plugin URI: http://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
Version: 2.5.3
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
define('AKISMET_VERSION', '2.5.3');
define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
/** If you hardcode a WP.com API key here, all key config screens will be hidden */
if ( defined('WPCOM_API_KEY') )
$wpcom_api_key = constant('WPCOM_API_KEY');
else
$wpcom_api_key = '';
// Make sure we don't expose any info if called directly
if ( !function_exists( 'add_action' ) ) {
echo "Hi there! I'm just a plugin, not much I can do when called directly.";
exit;
}
if ( isset($wp_db_version) && $wp_db_version <= 9872 )
include_once dirname( __FILE__ ) . '/legacy.php';
include_once dirname( __FILE__ ) . '/widget.php';
if ( is_admin() )
require_once dirname( __FILE__ ) . '/admin.php';
function akismet_init() {
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
if ( $wpcom_api_key )
$akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
else
$akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
$akismet_api_port = 80;
}
add_action('init', 'akismet_init');
function akismet_get_key() {
global $wpcom_api_key;
if ( !empty($wpcom_api_key) )
return $wpcom_api_key;
return get_option('wordpress_api_key');
}
function akismet_verify_key( $key, $ip = null ) {
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
$blog = urlencode( get_option('home') );
if ( $wpcom_api_key )
$key = $wpcom_api_key;
$response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
return 'failed';
return $response[1];
}
// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
function akismet_test_mode() {
if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
return true;
return false;
}
// return a comma-separated list of role names for the given user
function akismet_get_user_roles($user_id ) {
$roles = false;
if ( !class_exists('WP_User') )
return false;
if ( $user_id > 0 ) {
$comment_user = new WP_User($user_id);
if ( isset($comment_user->roles) )
$roles = join(',', $comment_user->roles);
}
if ( is_multisite() && is_super_admin( $user_id ) ) {
if ( empty( $roles ) ) {
$roles = 'super_admin';
} else {
$comment_user->roles[] = 'super_admin';
$roles = join( ',', $comment_user->roles );
}
}
return $roles;
}
// Returns array with headers in $response[0] and body in $response[1]
function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
global $wp_version;
$akismet_ua = "WordPress/{$wp_version} | ";
$akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
$content_length = strlen( $request );
$http_host = $host;
// use a specific IP if provided
// needed by akismet_check_server_connectivity()
if ( $ip && long2ip( ip2long( $ip ) ) ) {
$http_host = $ip;
} else {
$http_host = $host;
}
// use the WP HTTP class if it is available
if ( function_exists( 'wp_remote_post' ) ) {
$http_args = array(
'body' => $request,
'headers' => array(
'Content-Type' => 'application/x-www-form-urlencoded; ' .
'charset=' . get_option( 'blog_charset' ),
'Host' => $host,
'User-Agent' => $akismet_ua
),
'httpversion' => '1.0',
'timeout' => 15
);
$akismet_url = "http://{$http_host}{$path}";
$response = wp_remote_post( $akismet_url, $http_args );
if ( is_wp_error( $response ) )
return '';
return array( $response['headers'], $response['body'] );
} else {
$http_request = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
$http_request .= "Content-Length: {$content_length}\r\n";
$http_request .= "User-Agent: {$akismet_ua}\r\n";
$http_request .= "\r\n";
$http_request .= $request;
$response = '';
if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
fwrite( $fs, $http_request );
while ( !feof( $fs ) )
$response .= fgets( $fs, 1160 ); // One TCP-IP packet
fclose( $fs );
$response = explode( "\r\n\r\n", $response, 2 );
}
return $response;
}
}
// filter handler used to return a spam result to pre_comment_approved
function akismet_result_spam( $approved ) {
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
// this is a one-shot deal
remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
return 'spam';
}
function akismet_result_hold( $approved ) {
// once only
remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
return '0';
}
// how many approved comments does this author have?
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
global $wpdb;
if ( !empty($user_id) )
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
if ( !empty($comment_author_email) )
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
return 0;
}
function akismet_microtime() {
$mtime = explode( ' ', microtime() );
return $mtime[1] + $mtime[0];
}
// log an event for a given comment, storing it in comment_meta
function akismet_update_comment_history( $comment_id, $message, $event=null ) {
global $current_user;
// failsafe for old WP versions
if ( !function_exists('add_comment_meta') )
return false;
$user = '';
if ( is_object($current_user) && isset($current_user->user_login) )
$user = $current_user->user_login;
$event = array(
'time' => akismet_microtime(),
'message' => $message,
'event' => $event,
'user' => $user,
);
// $unique = false so as to allow multiple values per comment
$r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
}
// get the full comment history for a given comment, as an array in reverse chronological order
function akismet_get_comment_history( $comment_id ) {
// failsafe for old WP versions
if ( !function_exists('add_comment_meta') )
return false;
$history = get_comment_meta( $comment_id, 'akismet_history', false );
usort( $history, 'akismet_cmp_time' );
return $history;
}
function akismet_cmp_time( $a, $b ) {
return $a['time'] > $b['time'] ? -1 : 1;
}
// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
// because we don't know the comment ID at that point.
function akismet_auto_check_update_meta( $id, $comment ) {
global $akismet_last_comment;
// failsafe for old WP versions
if ( !function_exists('add_comment_meta') )
return false;
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
// as was checked by akismet_auto_check_comment
if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
&& $akismet_last_comment['comment_author'] == $comment->comment_author
&& $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
// normal result: true or false
if ( $akismet_last_comment['akismet_result'] == 'true' ) {
update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
if ( $comment->comment_approved != 'spam' )
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
} elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
if ( $comment->comment_approved == 'spam' ) {
if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
else
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
}
// abnormal result: error
} else {
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
}
// record the complete original data as submitted for checking
if ( isset($akismet_last_comment['comment_as_submitted']) )
update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
}
}
}
add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
function akismet_auto_check_comment( $commentdata ) {
global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
$comment = $commentdata;
$comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
$comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$comment['referrer'] = $_SERVER['HTTP_REFERER'];
$comment['blog'] = get_option('home');
$comment['blog_lang'] = get_locale();
$comment['blog_charset'] = get_option('blog_charset');
$comment['permalink'] = get_permalink($comment['comment_post_ID']);
$comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
$comment['akismet_comment_nonce'] = 'inactive';
if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
$comment['akismet_comment_nonce'] = 'failed';
if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
$comment['akismet_comment_nonce'] = 'passed';
// comment reply in wp-admin
if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
$comment['akismet_comment_nonce'] = 'passed';
}
if ( akismet_test_mode() )
$comment['is_test'] = 'true';
foreach ($_POST as $key => $value ) {
if ( is_string($value) )
$comment["POST_{$key}"] = $value;
}
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
foreach ( $_SERVER as $key => $value ) {
if ( !in_array( $key, $ignore ) && is_string($value) )
$comment["$key"] = $value;
else
$comment["$key"] = '';
}
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
$commentdata['comment_as_submitted'] = $comment;
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
$commentdata['akismet_result'] = $response[1];
if ( 'true' == $response[1] ) {
// akismet_spam_count will be incremented later by akismet_result_spam()
add_filter('pre_comment_approved', 'akismet_result_spam');
do_action( 'akismet_spam_caught' );
$post = get_post( $comment['comment_post_ID'] );
$last_updated = strtotime( $post->post_modified_gmt );
$diff = time() - $last_updated;
$diff = $diff / 86400;
if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
// akismet_result_spam() won't be called so bump the counter here
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
wp_redirect( $_SERVER['HTTP_REFERER'] );
die();
}
}
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
if ( 'true' != $response[1] && 'false' != $response[1] ) {
add_filter('pre_comment_approved', 'akismet_result_hold');
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
}
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
// WP 2.1+: delete old comments daily
if ( !wp_next_scheduled('akismet_scheduled_delete') )
wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
} elseif ( (mt_rand(1, 10) == 3) ) {
// WP 2.0: run this one time in ten
akismet_delete_old();
}
$akismet_last_comment = $commentdata;
return $commentdata;
}
add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
function akismet_delete_old() {
global $wpdb;
$now_gmt = current_time('mysql', 1);
$comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
if ( empty( $comment_ids ) )
return;
$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
do_action( 'delete_comment', $comment_ids );
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
$wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
clean_comment_cache( $comment_ids );
$n = mt_rand(1, 5000);
if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
$wpdb->query("OPTIMIZE TABLE $wpdb->comments");
}
add_action('akismet_scheduled_delete', 'akismet_delete_old');
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
global $wpdb, $akismet_api_host, $akismet_api_port;
$id = (int) $id;
$c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
if ( !$c )
return;
$c['user_ip'] = $c['comment_author_IP'];
$c['user_agent'] = $c['comment_agent'];
$c['referrer'] = '';
$c['blog'] = get_option('home');
$c['blog_lang'] = get_locale();
$c['blog_charset'] = get_option('blog_charset');
$c['permalink'] = get_permalink($c['comment_post_ID']);
$id = $c['comment_ID'];
if ( akismet_test_mode() )
$c['is_test'] = 'true';
$c['recheck_reason'] = $recheck_reason;
$query_string = '';
foreach ( $c as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
return $response[1];
}
function akismet_cron_recheck() {
global $wpdb;
delete_option('akismet_available_servers');
$comment_errors = $wpdb->get_col( "
SELECT comment_id
FROM {$wpdb->prefix}commentmeta
WHERE meta_key = 'akismet_error'
LIMIT 100
" );
foreach ( (array) $comment_errors as $comment_id ) {
// if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
if ( !get_comment( $comment_id ) ) {
delete_comment_meta( $comment_id, 'akismet_error' );
continue;
}
add_comment_meta( $comment_id, 'akismet_rechecking', true );
$status = akismet_check_db_comment( $comment_id, 'retry' );
$msg = '';
if ( $status == 'true' ) {
$msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
} elseif ( $status == 'false' ) {
$msg = __( 'Akismet cleared this comment during an automatic retry.' );
}
// If we got back a legit response then update the comment history
// other wise just bail now and try again later. No point in
// re-trying all the comments once we hit one failure.
if ( !empty( $msg ) ) {
delete_comment_meta( $comment_id, 'akismet_error' );
akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
update_comment_meta( $comment_id, 'akismet_result', $status );
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
$comment = get_comment( $comment_id );
if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
if ( $status == 'true' ) {
wp_spam_comment( $comment_id );
} elseif ( $status == 'false' ) {
// comment is good, but it's still in the pending queue. depending on the moderation settings
// we may need to change it to approved.
if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
wp_set_comment_status( $comment_id, 1 );
}
}
} else {
delete_comment_meta( $comment_id, 'akismet_rechecking' );
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
return;
}
}
$remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
}
}
add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
function akismet_add_comment_nonce( $post_id ) {
echo '<p style="display: none;">';
wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
echo '</p>';
}
$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
add_action( 'comment_form', 'akismet_add_comment_nonce' );
if ( '3.0.5' == $wp_version ) {
remove_filter( 'comment_text', 'wp_kses_data' );
if ( is_admin() )
add_filter( 'comment_text', 'wp_kses_post' );
}

View File

@ -1,396 +0,0 @@
<?php
function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
global $wpdb;
$page = (int) $page;
if ( $page < 2 )
$page = 1;
$per_page = (int) $per_page;
if ( $per_page < 1 )
$per_page = 50;
$start = ( $page - 1 ) * $per_page;
$end = $start + $per_page;
if ( $type ) {
if ( 'comments' == $type || 'comment' == $type )
$type = '';
else
$type = $wpdb->escape( $type );
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
}
// All
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
}
// Totals for each comment type
// returns array( type => count, ... )
function akismet_spam_totals() {
global $wpdb;
$totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
$return = array();
foreach ( $totals as $total )
$return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
return $return;
}
function akismet_manage_page() {
global $wpdb, $submenu, $wp_db_version;
// WP 2.7 has its own spam management page
if ( 8645 <= $wp_db_version )
return;
$count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
if ( isset( $submenu['edit-comments.php'] ) )
add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
elseif ( function_exists('add_management_page') )
add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
}
function akismet_caught() {
global $wpdb, $comment, $akismet_caught, $akismet_nonce;
akismet_recheck_queue();
if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
check_admin_referer( $akismet_nonce );
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
die(__('You do not have sufficient permission to moderate comments.'));
$i = 0;
foreach ($_POST['not_spam'] as $comment):
$comment = (int) $comment;
if ( function_exists('wp_set_comment_status') )
wp_set_comment_status($comment, 'approve');
else
$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
akismet_submit_nonspam_comment($comment);
++$i;
endforeach;
$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
wp_redirect( $to );
exit;
}
if ('delete' == $_POST['action']) {
check_admin_referer( $akismet_nonce );
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
die(__('You do not have sufficient permission to moderate comments.'));
$delete_time = $wpdb->escape( $_POST['display_time'] );
$comment_ids = $wpdb->get_col( "SELECT comment_id FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
if ( !empty( $comment_ids ) ) {
do_action( 'delete_comment', $comment_ids );
$wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
wp_cache_delete( 'akismet_spam_count', 'widget' );
}
$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
wp_redirect( $to );
exit;
}
if ( isset( $_GET['recovered'] ) ) {
$i = (int) $_GET['recovered'];
echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
}
if (isset( $_GET['deleted'] ) )
echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
$link = 'edit-comments.php';
else
$link = 'edit.php';
?>
<style type="text/css">
.akismet-tabs {
list-style: none;
margin: 0;
padding: 0;
clear: both;
border-bottom: 1px solid #ccc;
height: 31px;
margin-bottom: 20px;
background: #ddd;
border-top: 1px solid #bdbdbd;
}
.akismet-tabs li {
float: left;
margin: 5px 0 0 20px;
}
.akismet-tabs a {
display: block;
padding: 4px .5em 3px;
border-bottom: none;
color: #036;
}
.akismet-tabs .active a {
background: #fff;
border: 1px solid #ccc;
border-bottom: none;
color: #000;
font-weight: bold;
padding-bottom: 4px;
}
#akismetsearch {
float: right;
margin-top: -.5em;
}
#akismetsearch p {
margin: 0;
padding: 0;
}
</style>
<div class="wrap">
<h2><?php _e('Caught Spam') ?></h2>
<?php
$count = get_option( 'akismet_spam_count' );
if ( $count ) {
?>
<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
<?php
}
$spam_count = akismet_spam_count();
if ( 0 == $spam_count ) {
echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
echo '</div>';
} else {
echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don&#8217;t sweat it.').'</p>';
?>
<?php if ( !isset( $_POST['s'] ) ) { ?>
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
<?php akismet_nonce_field($akismet_nonce) ?>
<input type="hidden" name="action" value="delete" />
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
</form>
<?php } ?>
</div>
<div class="wrap">
<?php if ( isset( $_POST['s'] ) ) { ?>
<h2><?php _e('Search'); ?></h2>
<?php } else { ?>
<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
<?php } ?>
<?php
if ( isset( $_POST['s'] ) ) {
$s = $wpdb->escape($_POST['s']);
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
(comment_author LIKE '%$s%' OR
comment_author_email LIKE '%$s%' OR
comment_author_url LIKE ('%$s%') OR
comment_author_IP LIKE ('%$s%') OR
comment_content LIKE ('%$s%') ) AND
comment_approved = 'spam'
ORDER BY comment_date DESC");
} else {
if ( isset( $_GET['apage'] ) )
$page = (int) $_GET['apage'];
else
$page = 1;
if ( $page < 2 )
$page = 1;
$current_type = false;
if ( isset( $_GET['ctype'] ) )
$current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
$comments = akismet_spam_comments( $current_type, $page );
$total = akismet_spam_count( $current_type );
$totals = akismet_spam_totals();
?>
<ul class="akismet-tabs">
<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
<?php
foreach ( $totals as $type => $type_count ) {
if ( 'comment' == $type ) {
$type = 'comments';
$show = __('Comments');
} else {
$show = ucwords( $type );
}
$type_count = number_format_i18n( $type_count );
$extra = $current_type === $type ? ' class="active"' : '';
echo "<li $extra><a href='edit-comments.php?page=akismet-admin&amp;ctype=$type'>$show ($type_count)</a></li>";
}
do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
?>
</ul>
<?php
}
if ($comments) {
?>
<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
<input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam &raquo;')) ?>" /> </p>
</form>
<?php if ( $total > 50 ) {
$total_pages = ceil( $total / 50 );
$r = '';
if ( 1 < $page ) {
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
}
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
if ( $page == $page_num ) :
$r .= "<strong>$page_num</strong>\n";
else :
$p = false;
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
$in = true;
elseif ( $in == true ) :
$r .= "...\n";
$in = false;
endif;
endif;
endfor;
}
if ( ( $page ) * 50 < $total || -1 == $total ) {
$args['apage'] = $page + 1;
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
}
echo "<p>$r</p>";
?>
<?php } ?>
<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
<?php akismet_nonce_field($akismet_nonce) ?>
<input type="hidden" name="action" value="recover" />
<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
<?php
$i = 0;
foreach($comments as $comment) {
$i++;
$comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
$post = get_post($comment->comment_post_ID);
$post_title = $post->post_title;
if ($i % 2) $class = 'class="alternate"';
else $class = '';
echo "\n\t<li id='comment-$comment->comment_ID' $class>";
?>
<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
<?php comment_text() ?>
<p><label for="spam-<?php echo $comment->comment_ID; ?>">
<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
<?php _e('Not Spam') ?></label> &#8212; <?php comment_date('M j, g:i A'); ?> &#8212; [
<?php
$post = get_post($comment->comment_post_ID);
$post_title = wp_specialchars( $post->post_title, 'double' );
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
?>
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
<?php
}
?>
</ul>
<?php if ( $total > 50 ) {
$total_pages = ceil( $total / 50 );
$r = '';
if ( 1 < $page ) {
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";
}
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
if ( $page == $page_num ) :
$r .= "<strong>$page_num</strong>\n";
else :
$p = false;
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
$in = true;
elseif ( $in == true ) :
$r .= "...\n";
$in = false;
endif;
endif;
endfor;
}
if ( ( $page ) * 50 < $total || -1 == $total ) {
$args['apage'] = $page + 1;
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";
}
echo "<p>$r</p>";
}
?>
<p class="submit">
<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments &raquo;')); ?>" />
</p>
<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
</form>
<?php
} else {
?>
<p><?php _e('No results found.'); ?></p>
<?php } ?>
<?php if ( !isset( $_POST['s'] ) ) { ?>
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
<?php akismet_nonce_field($akismet_nonce) ?>
<p><input type="hidden" name="action" value="delete" />
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
</form>
<?php } ?>
</div>
<?php
}
}
add_action('admin_menu', 'akismet_manage_page');
function redirect_old_akismet_urls( ) {
global $wp_db_version;
$script_name = array_pop( split( '/', $_SERVER['PHP_SELF'] ) );
$page = '';
if ( !empty( $_GET['page'] ) )
$page = $_GET['page'];
// 2.7 redirect for people who might have bookmarked the old page
if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
$new_url = esc_url( 'edit-comments.php?comment_status=spam' );
wp_redirect( $new_url, 301 );
exit;
}
}
add_action( 'admin_init', 'redirect_old_akismet_urls' );
// For WP <= 2.3.x
global $pagenow;
if ( 'moderation.php' == $pagenow ) {
function akismet_recheck_button( $page ) {
global $submenu;
if ( isset( $submenu['edit-comments.php'] ) )
$link = 'edit-comments.php';
else
$link = 'edit.php';
$button = "<a href='$link?page=akismet-admin&amp;recheckqueue=true&amp;noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
$page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
return $page;
}
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
ob_start( 'akismet_recheck_button' );
}
// This option causes tons of FPs, was removed in 2.1
function akismet_kill_proxy_check( $option ) { return 0; }
add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');

View File

@ -1,130 +0,0 @@
=== Akismet ===
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
Tags: akismet, comments, spam
Requires at least: 3.0
Tested up to: 3.1
Stable tag: 2.5.3
License: GPLv2 or later
Akismet checks your comments against the Akismet web service to see if they look like spam or not.
== Description ==
Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you
review the spam it catches under your blog's "Comments" admin screen.
Major new features in Akismet 2.5 include:
* A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator
* Links are highlighted in the comment body, to reveal hidden or misleading links
* If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up
* Moderators can see the number of approved comments for each user
* Spam and Unspam reports now include more information, to help improve accuracy
PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
== Installation ==
Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.com API key](http://akismet.com/get/).
1, 2, 3: You're done!
== Changelog ==
= 2.5.3 =
* Specify the license is GPL v2 or later
* Fix a bug that could result in orphaned commentmeta entries
* Include hotfix for WordPress 3.0.5 filter issue
= 2.5.2 =
* Properly format the comment count for author counts
* Look for super admins on multisite installs when looking up user roles
* Increase the HTTP request timeout
* Removed padding for author approved count
* Fix typo in function name
* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
= 2.5.1 =
* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
* Fixed padding bug in "author" column of posts screen
* Added margin-top to "cleared by ..." badges on dashboard
* Fix possible error when calling akismet_cron_recheck()
* Fix more PHP warnings
* Clean up XHTML warnings for comment nonce
* Fix for possible condition where scheduled comment re-checks could get stuck
* Clean up the comment meta details after deleting a comment
* Only show the status badge if the comment status has been changed by someone/something other than Akismet
* Show a 'History' link in the row-actions
* Translation fixes
* Reduced font-size on author name
* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
* Hid "flagged by..." notification while on dashboard
= 2.5.0 =
* Track comment actions under 'Akismet Status' on the edit comment screen
* Fix a few remaining deprecated function calls ( props Mike Glendinning )
* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
* Use the WordPress HTTP class if available
* Move the admin UI code to a separate file, only loaded when needed
* Add cron retry feature, to replace the old connectivity check
* Display Akismet status badge beside each comment
* Record history for each comment, and display it on the edit page
* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
* Highlight links in comment content
* New option, "Show the number of comments you've approved beside each comment author."
* New option, "Use a nonce on the comment form."
= 2.4.0 =
* Spell out that the license is GPLv2
* Fix PHP warnings
* Fix WordPress deprecated function calls
* Fire the delete_comment action when deleting comments
* Move code specific for older WP versions to legacy.php
* General code clean up
= 2.3.0 =
* Fix "Are you sure" nonce message on config screen in WPMU
* Fix XHTML compliance issue in sidebar widget
* Change author link; remove some old references to WordPress.com accounts
* Localize the widget title (core ticket #13879)
= 2.2.9 =
* Eliminate a potential conflict with some plugins that may cause spurious reports
= 2.2.8 =
* Fix bug in initial comment check for ipv6 addresses
* Report comments as ham when they are moved from spam to moderation
* Report comments as ham when clicking undo after spam
* Use transition_comment_status action when available instead of older actions for spam/ham submissions
* Better diagnostic messages when PHP network functions are unavailable
* Better handling of comments by logged-in users
= 2.2.7 =
* Add a new AKISMET_VERSION constant
* Reduce the possibility of over-counting spam when another spam filter plugin is in use
* Disable the connectivity check when the API key is hard-coded for WPMU
= 2.2.6 =
* Fix a global warning introduced in 2.2.5
* Add changelog and additional readme.txt tags
* Fix an array conversion warning in some versions of PHP
* Support a new WPCOM_API_KEY constant for easier use with WordPress MU
= 2.2.5 =
* Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
= 2.2.4 =
* Fixed a key problem affecting the stats feature in WordPress MU
* Provide additional blog information in Akismet API calls

View File

@ -1,90 +0,0 @@
<?php
/**
* @package Akismet
*/
// Widget stuff
function widget_akismet_register() {
if ( function_exists('register_sidebar_widget') ) :
function widget_akismet($args) {
extract($args);
$options = get_option('widget_akismet');
$count = get_option('akismet_spam_count');
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $options['title'] . $after_title; ?>
<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( _n( '%1$s%2$s%3$s %4$sspam comment%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', '%1$s%2$s%3$s %4$sspam comments%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', $count ), '<span id="akismet1"><span id="akismetcount">', number_format_i18n( $count ), '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
<?php echo $after_widget; ?>
<?php
}
function widget_akismet_style() {
$plugin_dir = '/wp-content/plugins';
if ( defined( 'PLUGINDIR' ) )
$plugin_dir = '/' . PLUGINDIR;
?>
<style type="text/css">
#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
#aka:hover{border:none;text-decoration:none}
#aka:hover #akismet1{display:none}
#aka:hover #akismet2,#akismet1{display:block}
#akismet2{display:none;padding-top:2px}
#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
</style>
<?php
}
function widget_akismet_control() {
$options = $newoptions = get_option('widget_akismet');
if ( isset( $_POST['akismet-submit'] ) && $_POST["akismet-submit"] ) {
$newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
if ( empty($newoptions['title']) ) $newoptions['title'] = __('Spam Blocked');
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_akismet', $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
?>
<p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
<input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
<?php
}
if ( function_exists( 'wp_register_sidebar_widget' ) ) {
wp_register_sidebar_widget( 'akismet', 'Akismet', 'widget_akismet', null, 'akismet');
wp_register_widget_control( 'akismet', 'Akismet', 'widget_akismet_control', null, 75, 'akismet');
} else {
register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
register_widget_control('Akismet', 'widget_akismet_control', null, 75, 'akismet');
}
if ( is_active_widget('widget_akismet') )
add_action('wp_head', 'widget_akismet_style');
endif;
}
add_action('init', 'widget_akismet_register');
// Counter for non-widget users
function akismet_counter() {
$plugin_dir = '/wp-content/plugins';
if ( defined( 'PLUGINDIR' ) )
$plugin_dir = '/' . PLUGINDIR;
?>
<style type="text/css">
#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
#aka:hover{border:none;text-decoration:none}
#aka:hover #akismet1{display:none}
#aka:hover #akismet2,#akismet1{display:block}
#akismet2{display:none;padding-top:2px}
#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
</style>
<?php
$count = get_option('akismet_spam_count');
printf( _n( '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comment</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comments</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', $count ), number_format_i18n( $count ) );
}

View File

@ -1,82 +0,0 @@
<?php
/**
* @package Hello_Dolly
* @version 1.6
*/
/*
Plugin Name: Hello Dolly
Plugin URI: http://wordpress.org/extend/plugins/hello-dolly/
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
Author: Matt Mullenweg
Version: 1.6
Author URI: http://ma.tt/
*/
function hello_dolly_get_lyric() {
/** These are the lyrics to Hello Dolly */
$lyrics = "Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
We feel the room swayin'
While the band's playin'
One of your old favourite songs from way back when
So, take her wrap, fellas
Find her an empty lap, fellas
Dolly'll never go away again
Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
We feel the room swayin'
While the band's playin'
One of your old favourite songs from way back when
Golly, gee, fellas
Find her a vacant knee, fellas
Dolly'll never go away
Dolly'll never go away
Dolly'll never go away again";
// Here we split it into lines
$lyrics = explode( "\n", $lyrics );
// And then randomly choose a line
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}
// This just echoes the chosen line, we'll position it later
function hello_dolly() {
$chosen = hello_dolly_get_lyric();
echo "<p id='dolly'>$chosen</p>";
}
// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'hello_dolly' );
// We need some CSS to position the paragraph
function dolly_css() {
// This makes sure that the positioning is also good for right-to-left languages
$x = is_rtl() ? 'left' : 'right';
echo "
<style type='text/css'>
#dolly {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
";
}
add_action( 'admin_head', 'dolly_css' );
?>

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1 @@
This directory holds your custom TubePress themes!

View File

@ -0,0 +1,3 @@
<?php
//This file is here to stop cluttering search engine results for your site with TubePress's internals. Move along, nothing to see here!
?>

View File

@ -0,0 +1,384 @@
=== TubePress ===
Contributors: k2eric
Donate link: http://tubepress.org
Tags: video, youtube, gallery, videos, vimeo
Requires at least: 2.2
Stable tag: trunk
Displays gorgeous YouTube and Vimeo galleries in your posts, pages, and/or sidebar. Please visit http://tubepress.org for more info!
== Installation ==
1. Unzip into your plugins directory at `(wp-content/plugins)`
1. Activate TubePress from Site Admin > Plugins
1. Configure from Site Admin > Settings > TubePress
1. Type `[tubepress]` in a post or a page where you'd like to insert your first gallery
== Changelog ==
= 2.2.0 =
* Interactive searching! (closes issue 138 )
* YouTube iframe embedded player (closes issue 265 and issue 259 )
* Improved inclusion of JS/CSS resources in WordPress environments (closes issue 191 )
* Ability to restrict search-based galleries to videos from a specific YouTube/Vimeo user
* New HTTP subsystem provides faster and more robust feed retrieval
* Added advanced caching options
* Improved visual feedback during Ajax operations (closes issue 142 )
* Better upgrade notice for TubePress Pro users in a WordPress environment (closes issue 252 )
* Graceful handling of single video embedding when video isn't found (closes issue 267 )
* Broken gallery when trying to display Vimeo videos with JW FLV Media Player (closes issue 242 )
* Incorrect detection of multi-gallery mode in some circumstances (closes issue 238 )
* Duplicate videos no longer appear in galleries (closes issue 248 )
* Private Vimeo videos no longer appear in galleries
* Non-functional message service when using TubePress Pro in a PHP environment without built-in gettext support
* Fixed bug that could affect TubePress Pro users in a WordPress environment hosted on Windows-based PHP installations
* Removed option for "mobile" YouTube videos feed as it appears to be completely abandoned
* YouTube now uses the iframe embedded player by default
* Removed "enhanced genie menu" and "border" options from YouTube embedded player
* Version bump for php-gettext to 1.0.11
* Version bump for jQuery to 1.5.1
= 2.1.2 =
* Fixed JavaScript error in Internet Explorer when determining height/width of embedded video player
* Fixed ajax pagination appearance when non-default thumbnail sizes are in use
* Fixed non-functional WordPress widget control
* Updated Italian translation thanks to Gianni Diurno
= 2.1.1 =
* Fixed major JavaScript bug in determining embedded player height/width on jQuery 1.4.2
* Fixed bug with ajax pagination on some PHP installations
= 2.1.0 =
* Ability to create galleries from multiple sources (TubePress Pro only) (closes issue 135)
* Lightweight theming support
* Support for "fluid" thumbnails
* Vimeo universal player (closes issue 215)
* Improved video search capability (closes issue 81)
* Improved mobile user experience
* Single video mode now works in WordPress widget
* Fixed aliased text with Ajax pagination in Internet Explorer 7
* Search engines no longer index TubePress's internal directories (closes issue 221)
* Static player now works with Vimeo (closes issue 217)
* Fixed color support for JW FLV Player
* YouTube "most linked" gallery replaced with YouTube "top favorites" gallery due to change in API
* Version bump for Shadowbox.js to 3.0.3
* Version bump for JW FLV Media Player to 5.2
* Version bump for jQuery to 1.4.2
* Version bump for php-gettext to 1.0.10
* Added Arabic translation thanks to Abdullah Hamed
* Updated Italian translation thanks to Gianni Diurno
* Updated Spanish translation thanks to Luis Fok
= 2.0.0 =
* Vimeo support! Choose from 8 different types of Vimeo galleries. (closes issue 108)
* Brought back ability to play each video from a gallery in a new window by itself (closes issue 94)
* Now detects and parses HTML links found in video descriptions
* Updated Italian translation thanks to Gianni Diurno
* Added Spanish translation thanks to Luis Fok
* Added Hebrew translation thanks to Yaron Ofer
* Ability to blacklist individual videos (closes issue 162)
* Option to use high-quality thumbnails (closes issue 96) (TubePress Pro only)
* HTML popups are now centered on screen (closes issue 160)
* Fixed regression bug for description limit (closes issue 153)
* Incorrect video could load into embedded player after thumbnail click in certain configurations (closes issue 175)
* resultCountCap now works on a single gallery page
* Fixes single video mode in TubePress Pro
* Static player now works with Ajax pagination (closes issue 177)
* Version bump for FancyBox (to 1.3.1)
* FancyBox now operates correctly in all browsers (closes issue 172)
= 1.9.0 =
* Fixed a bug that breaks the WordPress widget administration page in some PHP installations
* Added Portugese translation thanks to Miriam de Pauala
= 1.8.9 =
* Now includes ability to embed individual videos along with all of their meta info (title, author, description, etc)!
* Request cache is now disabled by default
* Updated sorting functionality. Fixes possible "bad request" response from YouTube. Fixes sorting of playlist galleries.
* Fixed blank item on video sort order dropdown of WordPress options page (closes issue 155)
* descLimit shortcode can now be set to zero (closes issue 153)
* Improved compatibility with older versions of PHP (closes issue 163)
* Added Russian translation (thanks to an anonymous supporter)
* ShadowBox version bump to 3.0rc1
* Improved documentation
* (TubePress Pro) Improved i18n support
* (TubePress Pro) FancyBox version bump to 1.2.6
* (TubePress Pro) Fixed bug that prevented FancyBox from operating correctly in IE (closes issue 165)
= 1.8.8 =
* JavaScript initialization is much more robust. Reduces chances of un-clickable video thumbnails.
* Fixed potentially fatal error in cache mechanism
* Improved sidebar's CSS
* Fixed bug in video sort order (closes issue 146)
* Fixed bug that could cause fatal error in templates
* Version bump for JW FLV Media Player (to 5.0)
* Updated Italian translation thanks to Gianni Diurno
= 1.8.7 =
* Improved compatibility with PEAR (closes issue 140)
* Fixed bug that affected determining video ID in some YouTube feeds
* New static player option. Produces page refresh on each thumbnail click.
* Gallery HTML is now semantically correct and more structured (closes issue 125 and issue 117)
* TubePress Pro: New player: TinyBox (closes issue 110)
* TubePress Pro: New player: FancyBox (closes issue 118)
* TubePress Pro: Greatly improved WordPress integration
* TubePress Pro: Fixed bug that produced open_basedir warning message in some installations
* Fixed bug that prevented use of custom templates
* Overhaul and simplification of templating system
* Improved performance of logging system
* Improved iPhone/iPod playback (keeps user on site instead of redirecting to YouTube player) (closes issue 143)
= 1.8.6 =
* WordPress options page now uses jQuery tabs
* Fixed bug that could prevent request cache from working in some PHP installations
* (TubePress Pro only) Ajax pagination (closes issue 45 and issue 111)
* (TubePress Pro only) Version bump for jQuery (1.2.6 -> 1.3.2)
* (TubePress Pro only) Removed potential "Invalid locale category name" warning that shows up on some PHP installations
* Version bump for JW FLV Media Player (to 4.6)
* Fixed bug that prevented display of videos with "limited syndication" restriction
* Shortcode and input validation is much more comprehensive (closes issue 129)
* Fixed bug that prevented videos from playing in high definition upon request (closes issue 137)
* Additional gallery pages are no longer indexed by search engines (closes issue 133)
* Minor refactoring of tubepress.js functions
* Updated WordPress plugins page blurb
* Updated Italian translation thanks to Gianni Diurno
* Various trivial improvements to HTML templates
= 1.8.5 =
* Videos now play correctly on iPhone and iPod Touch (closes issue 101)
* Flexible shortcodes! No need to include commas between attribute/value pairs. Can use single, double, or no quotes around attribute values.
* Greatly improved debugging mode
* Fixed bug that prevents all videos in gallery from playing if first video in gallery is unavailable (closes issue 115)
* Fixed bug that could prevent video playback, and JavaScript error, on Firefox with AdBlock Plus enabled (closes issue 124)
* Added ability to cap the total number of videos in a gallery (closes issue 65)
* Updated Italian translation thanks to Gianni Diurno
* Shadowbox CSS no longer tries to load non-existent images. (closes issue 112)
* WordPress galleries are no longer wrapped with HTML paragraph tags (closes issue 79)
* WordPress.org compliant readme.txt changelog (closes issue 123)
= 1.8.0 =
* Includes all the changes listed in 1.8.0.RC1
* Fixed typo on options page regarding embedded player width/height
* Unavailable videos will now not appear in galleries at all
= 1.8.0 =
* New embedded player option: JW Flv Media Player
* New player location: jqModal
* All classes use dependency injection via Crafty
* jQuery 1.2.6 or higher is now required (built-in for WordPress users)
* Multiple galleries on a single page now behave correctly with "normal" player
* Dynamically load JavaScript libraries as needed (Prototype, Shadowbox, etc) (closes issue 56)
* All JavaScript is now unobtrusive
* Can now use modal players (e.g. Shadowbox) in a TubePress shortcode
* Removed extra HTML comments and whitespace. Galleries now use about 16% less bandwidth.
* CSS will stay valid for multiple galleries on a single page
* CSS classes now have sensible names (renamed some classes)
* Updated Italian translation thanks to Gianni Diurno (closes issue 83)
* Fixed bug that affected some PHP installations with PEAR installed (closes issue 84)
* Fixed bug that blocked WordPress plugin's "database nuke" functionality
* Removed GreyBox as a player location due to its inability to display inline content
* Version bump for ShadowBox (closes issue 77)
* popup.php has been removed and replaced with JavaScript functionality (closes issue 76)
* Better control over pagination visibility for multi-page galleries (closes issue 93)
* Removed GreyBox and LightWindow as players
* Graceful failure for videos that are unavailable
= 1.7.2 =
* Fullscreen playback now available in embedded player (closes issue 64)
* Created "YouTube Feed" options category. Moved some of the advanced options into this category.
* Added ability to exclude non-embeddable videos (closes issue 69)
* Added jscolor HTML color picker for embedded player colors
* Fixed bug where debugging mode threw a fatal error (closes issue 80)
* Fixed bug where random video sort order would throw a fatal error
* Added ability to toggle display of title/rating before video starts playing
* Now using version 2.0 of YouTube gdata API (closes issue 68)
= 1.7.1 =
* Drastically improved class loading mechanism (uses several thousand less system calls)
* Added Italian translation thanks to Gianni Diurno (closes issue 75)
* Minified Shadowbox JS source using YUI Compressor
* Fixed critical bug that broke embedded YouTube player on IE7 (closes issue 73)
* Fixed minor bug in normal player where embedded player would shift by a few pixels after user clicked a thumbnail
= 1.7.0 =
* Option to initialize TubePress options in WordPress (closes issue 52)
* Now works with PHP <= 5.1.0 again (closes issue 59 and issue 67)
* Links to popup.php are drastically shorter, which avoids a 404 on some webservers (closes issue 55)
* Added German translation thanks to Pascal Berger (closes issue 58)
* Option to play videos in HD (closes issue 33)
* Option to show custom video in embedded player on page load while using "normal" player (closes issue 26)
= 1.6.9 =
* TubePress Pro is now available! Use TubePress anywhere that runs PHP
* Default thumbmail URL now uses "default.jpg" (closes issue 47)
* Fixed bug that resulted in inability to paginate past the first page of a multi-page gallery.
* Version bump for Net_URL to Net_URL2
* Version bump for HTTP_Request to HTTP_Request2
* Version bump for Cache_Lite
* Huge amounts of unit/integration tests
* Major refactoring of classes (now using dependency injection)
= 1.6.8 =
* Fixed overly large gap between thumbnail rows
= 1.6.7 =
* Added YouTube connection test to debug output
* Added YouTube API client ID and developer key to aide in debugging
* Fixed bug where TubePress would remove all post/page content if no videos were found for your request
* Toggle request cache on/off (closes issue 43)
* Ampersands in query strings are now properly escaped (closes issue 38)
* Galleries can now sort videos randomly (closes issue 23)
* Toggle "nofollow" attributes to YouTube links (closes issue 35)
= 1.6.6 =
* Widget-enabled! Put TubePress in your sidebar. (closes issue 12)
* Removed pass-by-reference warnings (closes issue 34)
* Ability to limit length of video descriptions
* Option to toggle relative dates/times for video upload timestamps
* Swedish translation. Thanks to Mikael Jorhult
* Improved error handling for PHP installations with suppressed error output
* Removed several small bugs that affected users of PHP < 5.2.1
= 1.6.5 =
* Full internationalization capability (closes issue 21)
* Upgrades, from this version on, will no longer destroy your old TubePress default settings (closes issue 28)
* Multiple galleries on a single post/page now possible (closes issue 20)
* Fixes broken YouTube link (closes issue 30)
* Video playback now functions correctly in IE7
* Cross site scripting vulnerability fixed (thanks Numline1 for reporting)
* Fixed debug output
* Options page now looks good in WordPress 2.5.1
* Various pass-by-reference warnings eliminated
= 1.6.0 =
* PHP5 only. This includes an overall rewrite of the code base to take advantage of PHP5-only stuff
* Responses from YouTube are now cached
* New galleries: Top favorites, Most recently added, Most discussed, Most linked, Most responded, Responses to a video
* New way to watch: Shadowbox.js
* Removed "New Window" player
* Customize textual formatting of dates
* Much more control over embedded player: Toggle "related videos" feature after a video finishes, Choose from several colors, Toggle auto-play, Toggle "enhanced genie menu" when mouse enters video area (instead of user clicking the "menu" button), Toggle video loop
* Interface improvements: Removed border and scroll bars from gallery, Removed time of day from date uploaded, Changed upload label from "Uploaded date" to "Uploaded", Pagination now supports HTTP/HTTPS and non-standard ports, Simplified templating (easier to customize the look of your galleries)
* Issues/enhancements closed: #20, #25, #7
* Upgrade source to GPLv3
= 1.5.7 =
* Fixed yet another title problem due to YouTube changing their feed
* Fixes issue #16
= 1.5.6 =
* Fixes a major problem displaying video titles due to change in YouTube feed format
= 1.5.5 RC3 =
* Fixes issue #13
= 1.5.5 RC2 =
* Fixes issue #5
* Changes default thumb width from 33% to 32% (helps with IE)
= 1.5.5 RC1 =
* "Favorites" mode now displays up to 500 videos
* "Search" mode now can return up to 1,000 videos
* New mode: most-viewed videos from today, this week, this month, or all time
* Customize the order of galleries by view-count, rating, relevance, or date-updated
* Randomize thumbnails (most videos come with 4 thumbnails, this option will mix it up for each pageload)
* Filter "racy" videos from galleries
* Option to show a videos category in its metadata
* All access to TubePressVideo member variables is now done through getters
* All HTML is generated via PEAR's HTML_Template_IT package
= 1.5.2 =
* Fixes a fatal error upon plugin activation in some PHP installations
= 1.5.1 =
* Fixes a minor bug with "search" mode due to YouTube changing the format of the XML results
= 1.5.0 =
* "All tags" and "Any tags" modes now merged into "YouTube search" mode
* Play videos with GreyBox (this replaces ThickBox)
* Play videos with lightWindow
* Pagination now uses modified Digg Style pagination
* Max player size is now 424px x 336px (removes thin white border from player)
* Input validation on options page
* All error messages are extremely detailed
* Debug mode is more comprehensive
* Option to disable debugging mode completely
* Embedded video is XHTML compliant
* "Playlist" mode pages correctly (thanks, YouTube!)
* "Normal" mode displays title and runtime correctly after user click
* Much better code documentation
* Code style is PEAR compliant
* XML parsing uses PEAR's XML_Unserializer instead of XMLIster
* Almost all functions moved to classes (helps namespace management)
* WordPress-specific code is cleanly isolated
* Improved message-resources handling
* Revamped directory structure
* Improved naming conventions all around
* Quasi-private methods (PHP4 OOP isn't too sophisticated)
* Most HTML printing methods use sprintf (or variant) - improves readability
= 1.2.0 =
* Fixed a bug that caused an incorrect count of YouTube video results
* Added debugging mode! See the documentation for how to use it.
= 1.1.5 =
* Fixed major XML bugs that caused a fatal error when parsing YouTube's XML
* CSS bug fixes with the pagination links
* Fixed a bug in the options page related to the "popular" mode drop down menu
= 1.1 =
* CSS bug fixes. Thanks to Scott for reporting it
= 1.05 =
* Fixed huge IE display bug (thanks to Keane and Jojo for reporting it)
* Disabled Thickbox by default due to incompatibilities with themes and other jquery-enabled features
= 1.0 =
* Now with seven modes of operation: videos by playlists (with paging), featured (the latest 25 featured videos from YouTube's homepage), popular (the most-viewed videos from the past day, week, or month), related (videos that match any tag that you specify), tag (videos that match all the tags you specify), favorite videos of any user, videos uploaded by any user
* You no longer need to supply your own developer ID and YouTube username! This means that anyone can use TubePress, even if you don't have a YouTube account!
* Pagination. You control how many videos per page show up (supported modes only)
* Leaner and meaner. The speedups in this version are ridiculous. Makes literally dozens less of the expensive database calls per page that existed in previous versions. Reduces database space in your wordpress options table from about 40 rows to only one.
* Options page is more concise and XHTML compliant
* Improved documentation
* Bug fixes. Too many to list!
= 0.9 =
* Now with five options on where to play the main video: Normally (at the top of your gallery), In a popup window, In a new window all by itself, In its original YouTube page, Using Thickbox (experimental, but very cool!)
* Bug fix regarding HTML special characters in video titles
= 0.8 =
* Major bug fix with PHP4. Thanks to Fabien and Paige for reporting it.
= 0.7 =
* Override global settings on a per-page basis! This will allow you to have one page with your videos (that you've uploaded), another page with your YouTube favorites, etc.
* Choose which meta information (author, rating, description, etc) you want to display
* Lots of optimizations and bug fixes
= 0.6 =
* Now works with PHP4
* CSS revisions
* Uses snoopy class instead of cURL libraries
* Added configurable timeout parameter for contacting YouTube
= 0.5 =
* Fixed small bug in time display
= 0.4 =
* Takes full advantage of the YouTube API: List videos from "your favorites", List your videos (that you've uploaded), List videos that match some tag, List videos of another user
* XHTML compliant
= 0.3 =
* OK, now the bug is really fixed. Sorry about that!
= 0.2 =
* Fixed major bug with CSS file path
= 0.1 =
* Initial release
== Screenshots ==
1. Sample TubePress gallery

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -0,0 +1,34 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Performs TubePress-wide preflight checks and initialization.
*/
interface org_tubepress_api_bootstrap_Bootstrapper
{
/**
* Performs TubePress-wide initialization.
*
* @return null
*/
function boot();
}

View File

@ -0,0 +1,45 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* String cache for TubePress
*/
interface org_tubepress_api_cache_Cache
{
/**
* Get a value from the cache
*
* @param string $key The key of the data to retrieve
*
* @return string The data at the given key, or false if not there
*/
function get($key);
/**
* Save the given data with the given key
*
* @param string $key The key at which to save the data
* @param string $data The data to save at the key
*
* @return void
*/
function save($key, $data);
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Filter execution point names.
*/
class org_tubepress_api_const_filters_ExecutionPoint
{
/* immediately after videos are returned by the provider */
const VIDEOS_DELIVERY = 'videosDelivery';
/* immediately after thumbnail gallery template generation */
const GALLERY_TEMPLATE = 'galleryTemplate';
/* immediately after thumbnail gallery template is converted to HTML */
const GALLERY_HTML = 'galleryHtml';
/* immediately after single video template generation */
const SINGLE_VIDEO_TEMPLATE = 'singleVideoTemplate';
/* immediately after single video template is converted to HTML */
const SINGLE_VIDEO_HTML = 'singleVideoHtml';
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* The valid options categories and their names
*
*/
class org_tubepress_api_const_options_CategoryName
{
const ADVANCED = 'advanced';
const DISPLAY = 'display';
const EMBEDDED = 'embedded';
const FEED = 'feed';
const META = 'meta';
const WIDGET = 'widget';
const OUTPUT = 'output';
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* The types of options TubePress can handle
*
*/
class org_tubepress_api_const_options_Type
{
const BOOL = 'boolean'; // Yes/No options
const COLOR = 'color'; // An HTML color (6 hex digits)
const INTEGRAL = 'integral'; // A number
const MODE = 'mode'; // A gallery mode
const ORDER = 'order'; // Video sort order
const OUTPUT = 'output'; // Output mode
const PLAYER = 'player'; // Shadowbox, popup, etc
const PLAYER_IMPL = 'playerImplementation'; // YouTube, Longtail, etc
const PLAYLIST = 'playlist'; // A YouTube playlist ID
const SAFE_SEARCH = 'safeSearch'; // a SafeSearch level
const TEXT = 'text'; // Free form text
const THEME = 'theme'; // TubePress theme to use
const TIME_FRAME = 'timeFrame'; // Today, last week, etc
const YT_USER = 'youtubeUser'; // A YouTube username
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Advanced option names for the plugin.
*/
class org_tubepress_api_const_options_names_Advanced
{
const CACHE_CLEAN_FACTOR = 'cacheCleaningFactor';
const CACHE_DIR = 'cacheDirectory';
const CACHE_LIFETIME_SECONDS = 'cacheLifetimeSeconds';
const DATEFORMAT = 'dateFormat';
const DEBUG_ON = 'debugging_enabled';
const DISABLE_HTTP_CURL = 'disableHttpTransportCurl';
const DISABLE_HTTP_EXTHTTP = 'disableHttpTransportExtHttp';
const DISABLE_HTTP_FOPEN = 'disableHttpTransportFopen';
const DISABLE_HTTP_FSOCKOPEN = 'disableHttpTransportFsockOpen';
const DISABLE_HTTP_STREAMS = 'disableHttpTransportStreams';
const KEYWORD = 'keyword';
const VIDEO_BLACKLIST = 'videoBlacklist';
}

View File

@ -0,0 +1,43 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Display option names for the plugin
*
*/
class org_tubepress_api_const_options_names_Display
{
//The order in which these constants are declared dictates the
//order in which they'll be presented on the options page
const THEME = 'theme';
const AJAX_PAGINATION = 'ajaxPagination';
const CURRENT_PLAYER_NAME = 'playerLocation';
const RESULTS_PER_PAGE = 'resultsPerPage';
const HQ_THUMBS = 'hqThumbs';
const THUMB_HEIGHT = 'thumbHeight';
const THUMB_WIDTH = 'thumbWidth';
const ORDER_BY = 'orderBy';
const PAGINATE_ABOVE = 'paginationAbove';
const PAGINATE_BELOW = 'paginationBelow';
const RANDOM_THUMBS = 'randomize_thumbnails';
const RELATIVE_DATES = 'relativeDates';
const DESC_LIMIT = 'descriptionLimit';
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Option names for the embedded player
*
*/
class org_tubepress_api_const_options_names_Embedded
{
//The order in which these constants are declared dictates the
//order in which they'll be presented on the options page */
const PLAYER_IMPL = "playerImplementation";
const EMBEDDED_HEIGHT = "embeddedHeight";
const EMBEDDED_WIDTH = "embeddedWidth";
const AUTOPLAY = "autoplay";
const FULLSCREEN = "fullscreen";
const HIGH_QUALITY = "hd";
const LOOP = "loop";
const PLAYER_COLOR = "playerColor";
const PLAYER_HIGHLIGHT = "playerHighlight";
const SHOW_INFO = "showInfo";
const SHOW_RELATED = "showRelated";
}

View File

@ -0,0 +1,37 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* YouTube feed options
*/
class org_tubepress_api_const_options_names_Feed
{
/* The order in which these constants are declared dictates the
order in which they'll be presented on the options page */
const CACHE_ENABLED = 'cacheEnabled';
const EMBEDDABLE_ONLY = 'embeddableOnly';
const FILTER = 'filter_racy';
const DEV_KEY = 'developerKey';
const RESULT_COUNT_CAP = 'resultCountCap';
const SEARCH_ONLY_USER = 'searchResultsRestrictedToUser';
const VIMEO_KEY = 'vimeoKey';
const VIMEO_SECRET = 'vimeoSecret';
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Option names that control which meta info is displayed below video
* thumbnails
*/
class org_tubepress_api_const_options_names_Meta
{
const AUTHOR = "author";
const CATEGORY = "category";
const DESCRIPTION = "description";
const ID = "id";
const LENGTH = "length";
const LIKES = 'likes';
const RATING = "rating";
const RATINGS = "ratings";
const TAGS = "tags";
const TITLE = "title";
const UPLOADED = "uploaded";
const URL = "url";
const VIEWS = "views";
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Option names defining what output to display
*/
class org_tubepress_api_const_options_names_Output
{
const MODE = 'mode';
const VIDEO = 'video';
const OUTPUT = 'output';
const SEARCH_RESULTS_URL = 'searchResultsUrl';
const SEARCH_RESULTS_ONLY = 'searchResultsOnly';
const SEARCH_PROVIDER = 'searchProvider';
const SEARCH_RESULTS_DOM_ID = 'searchResultsDomId';
const FAVORITES_VALUE = 'favoritesValue';
const MOST_VIEWED_VALUE = 'most_viewedValue';
const PLAYLIST_VALUE = 'playlistValue';
const TAG_VALUE = 'tagValue';
const TOP_FAVORITES_VALUE = 'youtubeTopFavoritesValue';
const TOP_RATED_VALUE = 'top_ratedValue';
const USER_VALUE = 'userValue';
const VIMEO_UPLOADEDBY_VALUE = 'vimeoUploadedByValue';
const VIMEO_LIKES_VALUE = 'vimeoLikesValue';
const VIMEO_APPEARS_IN_VALUE = 'vimeoAppearsInValue';
const VIMEO_SEARCH_VALUE = 'vimeoSearchValue';
const VIMEO_CREDITED_VALUE = 'vimeoCreditedToValue';
const VIMEO_CHANNEL_VALUE = 'vimeoChannelValue';
const VIMEO_ALBUM_VALUE = 'vimeoAlbumValue';
const VIMEO_GROUP_VALUE = 'vimeoGroupValue';
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Widget option names for the plugin
*/
class org_tubepress_api_const_options_names_Widget
{
const TAGSTRING = "widget-tagstring";
const TITLE = "widget-title";
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_ModeValue
{
const FAVORITES = 'favorites';
const FEATURED = 'recently_featured';
const MOST_DISCUSSED = 'most_discussed';
const MOST_RECENT = 'most_recent';
const MOST_RESPONDED = 'most_responded';
const PLAYLIST = 'playlist';
const POPULAR = 'most_viewed';
const TAG = 'tag';
const TOP_FAVORITES = 'youtubeTopFavorites';
const TOP_RATED = 'top_rated';
const USER = 'user';
const VIMEO_UPLOADEDBY = 'vimeoUploadedBy';
const VIMEO_LIKES = 'vimeoLikes';
const VIMEO_APPEARS_IN = 'vimeoAppearsIn';
const VIMEO_SEARCH = 'vimeoSearch';
const VIMEO_CREDITED = 'vimeoCreditedTo';
const VIMEO_CHANNEL = 'vimeoChannel';
const VIMEO_ALBUM = 'vimeoAlbum';
const VIMEO_GROUP = 'vimeoGroup';
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_OrderValue
{
const COMMENT_COUNT = 'commentCount';
const DATE_PUBLISHED = 'published';
const DURATION = 'duration';
const NEWEST = 'newest';
const OLDEST = 'oldest';
const POSITION = 'position';
const RANDOM = 'random';
const RATING = 'rating';
const RELEVANCE = 'relevance';
const TITLE = 'title';
const VIEW_COUNT = 'viewCount';
}

View File

@ -0,0 +1,30 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Output options.
*/
class org_tubepress_api_const_options_values_OutputValue
{
const AJAX_SEARCH_INPUT = 'ajaxSearchInput';
const SEARCH_INPUT = 'searchInput';
const SEARCH_RESULTS = 'searchResults';
}

View File

@ -0,0 +1,29 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_PlayerImplementationValue
{
const LONGTAIL = 'longtail';
const PROVIDER_BASED = 'provider_based';
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_PlayerValue
{
const NORMAL = 'normal';
const POPUP = 'popup';
const SHADOWBOX = 'shadowbox';
const JQMODAL = 'jqmodal';
const VIMEO = 'vimeo';
const YOUTUBE = 'youtube';
const STATICC = 'static';
const SOLO = 'solo';
const FANCYBOX = 'fancybox';
const TINYBOX = 'tinybox';
}

View File

@ -0,0 +1,30 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_SafeSearchValue
{
const NONE = 'none';
const MODERATE = 'moderate';
const STRICT = 'strict';
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery content modes.
*/
class org_tubepress_api_const_options_values_TimeFrameValue
{
const TODAY = 'today';
const THIS_WEEK = 'this_week';
const THIS_MONTH = 'this_month';
const ALL_TIME = 'all_time';
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Query string parameter names.
*/
class org_tubepress_api_const_querystring_QueryParamName
{
const DEBUG = 'tubepress_debug';
const GALLERY_ID = 'tubepress_galleryId';
const PAGE = 'tubepress_page';
const SEARCH_TERMS = 'tubepress_search';
const SHORTCODE = 'tubepress_shortcode';
const VIDEO = 'tubepress_video';
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress template variables
*/
class org_tubepress_api_const_template_Variable
{
const AUTHOR_URL_PREFIX = 'authorUrlPrefix';
const EMBEDDED_AUTOSTART = 'autostart';
const EMBEDDED_COLOR_HIGHLIGHT = 'embeddedColorHightlight';
const EMBEDDED_COLOR_PRIMARY = 'embeddedColorPrimary';
const EMBEDDED_DATA_URL = 'homeURL';
const EMBEDDED_FULLSCREEN = 'embeddedFullscreen';
const EMBEDDED_HEIGHT = 'embeddedHeight';
const EMBEDDED_IMPL_NAME = 'embeddedImplementationName';
const EMBEDDED_SOURCE = 'embeddedSource';
const EMBEDDED_WIDTH = 'embeddedWidth';
const GALLERY_ID = 'galleryId';
const META_LABELS = 'metaLabels';
const META_SHOULD_SHOW = 'shouldShow';
const OPTIONS_PAGE_CATEGORIES = 'optionsPageCategories';
const OPTIONS_PAGE_CATEGORY_OPTIONS = 'optionsPageCategoryOptions';
const OPTIONS_PAGE_CATEGORY_TITLE = 'optionsPageCategoryTitle';
const OPTIONS_PAGE_INTRO = 'optionsPageIntro';
const OPTIONS_PAGE_OPTIONS_DESC = 'optionsPageOptionsDesc';
const OPTIONS_PAGE_OPTIONS_FILTER = 'optionsPageOptionsFilter';
const OPTIONS_PAGE_OPTIONS_PRO_ONLY = 'optionsPageProOnly';
const OPTIONS_PAGE_OPTIONS_TITLE = 'optionsPageOptionTitle';
const OPTIONS_PAGE_OPTIONS_WIDGET = 'optionsPageOptionsWidget';
const OPTIONS_PAGE_SAVE = 'optionsPageSave';
const OPTIONS_PAGE_TITLE = 'optionsPageTitle';
const OPTIONS_PAGE_VIMEO_OPTION = 'optionsPageVimeoOption';
const OPTIONS_PAGE_YOUTUBE_OPTION = 'optionsPageYouTubeOption';
const PAGINATION_BOTTOM = 'bottomPagination';
const PAGINATION_TOP = 'topPagination';
const PLAYER_HTML = 'preGallery';
const PLAYER_NAME = 'playerName';
const PRE_GALLERY = self::PLAYER_HTML;
const SEARCH_HANDLER_URL = 'searchHandlerUrl';
const SEARCH_HIDDEN_INPUTS = 'searchHiddenInputs';
const SEARCH_BUTTON = 'searchButton';
const SEARCH_TARGET_DOM_ID = 'searchTargetDomId';
const SEARCH_TERMS = 'searchTerms';
const SHORTCODE = 'shortcode';
const THEME_CSS = 'themeCssUrl';
const THUMBNAIL_HEIGHT = 'thumbHeight';
const THUMBNAIL_WIDTH = 'thumbWidth';
const TUBEPRESS_BASE_URL = 'tubepressBaseUrl';
const VIDEO_ARRAY = 'videoArray';
const VIDEO_SEARCH_PREFIX = 'videoSearchPrefix';
const VIDEO = 'video';
const WIDGET_CONTROL_SHORTCODE = 'widgetControlShortcode';
const WIDGET_CONTROL_TITLE = 'widgetControlTitle';
const WIDGET_SHORTCODE = 'widgetShortcode';
const WIDGET_TITLE = 'widgetTitle';
}
class org_tubepress_template_Template extends org_tubepress_api_const_template_Variable {
//the only purpose of this class is for backwards compatibility with user HTML templates :(
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Represents an HTML-embeddable Flash video player
*
*/
interface org_tubepress_api_embedded_EmbeddedPlayer
{
/**
* Spits back the text for this embedded player
*
* @param string $videoId The video ID to display
*
* @throws Exception If something goes wrong.
*
* @return string The text for this embedded player
*/
function toString($videoId);
}

View File

@ -0,0 +1,40 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Detects TubePress's environment
*/
interface org_tubepress_api_environment_Detector
{
/**
* Detects if the user is running TubePress Pro.
*
* @return boolean True is the user is running TubePress Pro. False otherwise (or if there is a problem detecting the environment).
*/
function isPro();
/**
* Detects if the user is running within WordPress
*
* @return boolean True is the user is running within WordPress (or if there is a problem detecting the environment). False otherwise.
*/
function isWordPress();
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Converts raw video feeds to TubePress videos
*/
interface org_tubepress_api_factory_VideoFactory
{
/**
* Converts raw video feeds to TubePress videos
*
* @param unknown $feed The raw feed result from the video provider
*
* @return array an array of TubePress videos generated from the feed (may be empty).
*/
function feedToVideoArray($feed);
}

View File

@ -0,0 +1,37 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress's feed retrieval mechanism
*
*/
interface org_tubepress_api_feed_FeedFetcher
{
/**
* Fetches the feed from the remote provider
*
* @param string $url The URL to fetch.
* @param boolean $useCache Whether or not to use the network cache.
*
* @return unknown The raw feed from the provider
*/
function fetch($url, $useCache);
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Examines the feed results.
*/
interface org_tubepress_api_feed_FeedInspector
{
/**
* Count the total videos in this feed result.
*
* @param unknown $rawFeed The raw video feed (varies depending on provider)
*
* @return int The total result count of this query, or 0 if there was a problem.
*/
function getTotalResultCount($rawFeed);
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Simple class to abstract the response from a video provider
*/
class org_tubepress_api_feed_FeedResult
{
private $_effectiveDisplayCount;
private $_effectiveTotalResultCount;
private $_videoArray;
/**
* Set the video array
*
* @param array $videos The video array.
*
* @return void
*/
public function setVideoArray($videos)
{
$this->_videoArray = $videos;
}
/**
* Set the effective total result count
*
* @param integer $count The effective total result count.
*
* @return void
*/
public function setEffectiveTotalResultCount($count)
{
$this->_effectiveTotalResultCount = $count;
}
/**
* Get the video array
*
* @return array The video array.
*/
public function getVideoArray()
{
return $this->_videoArray;
}
/**
* Get the effective total result count
*
* @return integer The effective total result count.
*/
public function getEffectiveTotalResultCount()
{
return $this->_effectiveTotalResultCount;
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Filesystem utilities.
*/
interface org_tubepress_api_filesystem_Explorer
{
/**
* Finds the absolute path of the TubePress installation on the filesystem.
*
* @return string The absolute filesystem path of this TubePress installation.
*/
function getTubePressBaseInstallationPath();
/**
* Find the directories contained in the given directory (non-recursive).
*
* @param string $dir The absolute filesystem path of the directory to examine.
* @param string $prefix The logging prefix.
*
* @return array The names of the directories in the given directory (non-recursive).
*/
function getDirectoriesInDirectory($dir, $prefix);
/**
* Find the files contained in the given directory (non-recursive).
*
* @param string $dir The absolute filesystem path of the directory to examine.
* @param string $prefix The logging prefix.
*
* @return array The names of the files in the given directory (non-recursive).
*/
function getFilenamesInDirectory($dir, $prefix);
function getSystemTempDirectory();
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Handles HTML.
*/
interface org_tubepress_api_html_HtmlGenerator
{
function getHeadJqueryIncludeString();
function getHeadInlineJavaScriptString();
function getHeadTubePressJsIncludeString();
function getHeadTubePressCssIncludeString();
function getHeadMetaString();
/**
* Generates the HTML for TubePress. Could be a gallery or single video.
*
* @param string $shortCodeContent The shortcode content. May be empty or null.
*
* @return The HTML for the given shortcode, or the error message if there was a problem.
*/
function getHtmlForShortcode($shortCodeContent);
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Handles HTTP client functionality.
*/
interface org_tubepress_api_http_HttpClient
{
const HTTP_METHOD_GET = 'GET';
const HTTP_METHOD_POST = 'POST';
const HTTP_METHOD_PUT = 'PUT';
const HTTP_HEADER_ACCEPT_ENCODING = 'Accept-Encoding';
const HTTP_HEADER_CONTENT_LENGTH = 'Content-Length';
const HTTP_HEADER_CONTENT_TYPE = 'Content-Type';
const HTTP_HEADER_USER_AGENT = 'User-Agent';
/**
* Get.
*
* @param string $url URI resource.
*
* @throws Exception If something goes wrong.
*
* @return string Resulting body as a string (could be null)
*/
function get($url);
/**
* Post.
*
* @param string $url URI resource.
* @param unknown $body The HTTP body.
*
* @return string Resulting body as a string (could be null)
*/
function post($url, $body);
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Dependency injector for TubePress
*/
interface org_tubepress_api_ioc_IocService
{
/**
* Get an object from the container by name.
*
* @param string $className The name of the object to retrieve.
*
* @return object The object with the given name.
*/
function get($className);
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* General purpose message abstraction for TubePress
*/
interface org_tubepress_api_message_MessageService
{
/**
* Get the message corresponding to the given key.
*
* @param string $messageKey The message key.
*
* @return string The corresponding message.
*/
function _($messageKey);
}

View File

@ -0,0 +1,37 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Performs validation on option values
*/
interface org_tubepress_api_options_OptionValidator
{
/**
* Validates an option value. Will throw an Exception if validation
* fails.
*
* @param string $optionName The option name
* @param unknown_type $candidate The candidate option value
*
* @return void
*/
function validate($optionName, $candidate);
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Holds the current options for TubePress. This is the default options,
* usually in persistent storage somewhere, and custom options parsed
* from a shortcode
*/
interface org_tubepress_api_options_OptionsManager
{
/**
* Gets the value of an option
*
* @param string $optionName The name of the option
*
* @return unknown The option value
*/
function get($optionName);
/**
* Sets the value of an option
*
* @param string $optionName The name of the option
* @param unknown $optionValue The option value
*
* @return void
*/
function set($optionName, $optionValue);
/**
* Sets the options that differ from the default options.
*
* @param array $customOpts The custom options.
*
* @return void
*/
function setCustomOptions($customOpts);
/**
* Gets the options that differ from the default options.
*
* @return array The options that differ from the default options.
*/
function getCustomOptions();
/**
* Set the current shortcode.
*
* @param string $newTagString The current shortcode
*
* @return void
*/
function setShortcode($newTagString);
/**
* Get the current shortcode
*
* @return string The current shortcode
*/
function getShortcode();
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Handles persistent storage of TubePress options
*
*/
interface org_tubepress_api_options_StorageManager
{
/**
* Determines if an option exists
*
* @param string $optionName The name of the option in question
*
* @return boolean True if the option exists, false otherwise
*/
function exists($optionName);
/**
* Initializes the storage
*
* @return void
*/
function init();
/**
* Retrieve the current value of an option
*
* @param string $optionName The name of the option
*
* @return unknown_type The option's value
*/
function get($optionName);
/**
* Sets an option value
*
* @param string $optionName The option name
* @param unknown_type $optionValue The option value
*
* @return void
*/
function set($optionName, $optionValue);
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress gallery pagination service.
*/
interface org_tubepress_api_pagination_Pagination
{
/**
* Get the HTML for pagination.
*
* @param int $totalResults The total number of results in this gallery
*
* @return string The HTML for the pagination.
*/
function getHtml($totalResults);
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Manages the registration and execution of filters.
*/
interface org_tubepress_api_patterns_FilterManager
{
/**
* Run all filters for the specified execution point, giving each filter a chance
* to modify the given value.
*
* @param string $name The execution point name.
* @param unknown_type $value The value to send to the filters.
*
* @return unknown_type The modified value.
*/
function runFilters($name, $value);
/**
* Registers a filter for the specified execution point.
*
* @param string $name The execution point name.
* @param callback $callback The filter callback.
*
* @return void
*/
function registerFilter($name, $callback);
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* A generic strategy.
*/
interface org_tubepress_api_patterns_Strategy
{
/**
* Returns true if this strategy is able to handle
* the request.
*
* @return boolean True if the strategy can handle the request, false otherwise.
*/
function canHandle();
/**
* Execute the strategy.
*
* @return unknown The result of this strategy execution.
*/
function execute();
/**
* Called *before* canHandle() and execute() to allow the strategy
* to initialize itself.
*
* @return void
*/
function start();
/**
* Called *after* canHandle() and execute() to allow the strategy
* to tear itself down.
*
* @return void
*/
function stop();
}

View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Finds the first strategy to execute and executes it.
*/
interface org_tubepress_api_patterns_StrategyManager
{
/**
* Executes the given strategies.
*
* @param array $strategyInstances An array of org_tubepress_api_patterns_Strategy class names to execute.
*
* @return unknown The result of the strategy execution.
*/
function executeStrategy($strategyInstances);
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_video_Video'));
/**
* A TubePress "player", such as lightWindow, GreyBox, popup window, etc
*/
interface org_tubepress_api_player_Player
{
const NORMAL = 'normal';
const POPUP = 'popup';
const SHADOWBOX = 'shadowbox';
const JQMODAL = 'jqmodal';
const YOUTUBE = 'youtube';
const TINYBOX = 'tinybox';
const FANCYBOX = 'fancybox';
const STATICC = 'static';
const SOLO = 'solo';
const VIMEO = 'vimeo';
/**
* Get's the HTML for the TubePress "player"
*
* @param org_tubepress_api_video_Video $vid The video to display in the player.
* @param unknown $galleryId The current gallery ID.
*
* @throws Exception If something goes wrong.
*
* @return string The HTML for this player with the given video.
*/
function getHtml(org_tubepress_api_video_Video $vid, $galleryId);
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_options_OptionsManager'));
/**
* Interface to a remove video provider
*/
interface org_tubepress_api_provider_Provider
{
const DIRECTORY = 'directory';
const YOUTUBE = 'youtube';
const VIMEO = 'vimeo';
/**
* Get the video feed result.
*
* @return org_tubepress_api_feed_FeedResult The feed result, never null.
*/
function getMultipleVideos();
/**
* Fetch a single video.
*
* @param string $customVideoId The video ID to fetch.
*
* @return org_tubepress_api_video_Video The video, or null if there's a problem.
*/
function getSingleVideo($customVideoId);
}

View File

@ -0,0 +1,43 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Calculates video provider in use.
*/
interface org_tubepress_api_provider_ProviderCalculator
{
/**
* Determine the current video provider.
*
* @return string 'youtube', 'vimeo', or 'directory'
*/
function calculateCurrentVideoProvider();
/**
* Determine the provider of the given video ID.
*
* @param string $videoId The ID of the video to examine.
*
* @return string 'youtube', 'vimeo', or 'directory'
*/
function calculateProviderOfVideoId($videoId);
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Handles some tasks related to the query string
*/
interface org_tubepress_api_querystring_QueryStringService
{
/**
* Try to get the custom video ID from the query string
*
* @param array $getVars The PHP $_GET array
*
* @return string The custom video ID, or '' if not set or if there was a problem.
*/
function getCustomVideo($getVars);
/**
* Try to get the gallery ID from the query string
*
* @param array $getVars The PHP $_GET array
*
* @return string The gallery ID, or '' if not set or if there was a problem.
*/
function getGalleryId($getVars);
/**
* Returns what's in the address bar
*
* @param array $serverVars The PHP $_SERVER array
*
* @return string What's in the address bar
*/
function getFullUrl($serverVars);
/**
* Try to figure out what page we're on by looking at the query string
* Defaults to '1' if there's any doubt
*
* @param array $getVars The PHP $_GET array
*
* @return int The page number, or 1 if there was a problem.
*/
function getPageNum($getVars);
/**
* Try to get the shortcode from the query string
*
* @param array $getVars The PHP $_GET array
*
* @return string The shortcode, or '' if not set or if there was a problem.
*/
function getShortcode($getVars);
function getSearchTerms($getVars);
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Parses shortcodes.
*/
interface org_tubepress_api_shortcode_ShortcodeParser
{
/**
* This function is used to parse a shortcode into options that TubePress can use.
*
* @param string $content The haystack in which to search
*
* @return array The associative array of parsed options.
*/
function parse($content);
/**
* Determines if the given content contains a shortcode.
*
* @param string $content The content to search through
* @param string $trigger The shortcode trigger word
*
* @return boolean True if there's a shortcode in the content, false otherwise.
*/
function somethingToParse($content, $trigger = "tubepress");
}

View File

@ -0,0 +1,36 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Handles requests for a single video (for embedding)
*/
interface org_tubepress_api_single_SingleVideo
{
/**
* Get the HTML for a single video display.
*
* @param string $videoId The ID of the video to display.
*
* @return string The HTML for the single video display.
*/
function getSingleVideoHtml($videoId);
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress template
*/
interface org_tubepress_api_template_Template
{
/**
* Converts this template to a string
*
*@throws Exception If there was a problem.
*
* @return string The string representation of this template.
*/
function toString();
/**
* Sets the path of this template.
*
* @param string $path The absolute path on the filesystem of this template.
*
* @throws Exception If there was a problem.
*
* @return void
*/
function setPath($path);
/**
* Set a template variable.
*
* @param string $name The name of the template variable to set.
* @param unknown $value The value of the template variable.
*
* @return void
*/
function setVariable($name, $value);
/**
* Resets this template for use. Clears out any set variables.
*
* @return void
*/
function reset();
}

View File

@ -0,0 +1,54 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* TubePress theme handler.
*/
interface org_tubepress_api_theme_ThemeHandler
{
/**
* Gets an instance of a template appropriate for the current theme.
*
* @param string $pathToTemplate The relative path (from the root of the theme directory) to the template.
*
* @throws Exception If there was a problem.
*
* @return org_tubepress_api_template_Template The template instance.
*/
function getTemplateInstance($pathToTemplate);
/**
* Returns the URL of the CSS stylesheet for the given theme.
*
* @param string $currentTheme The name of the theme.
* @param boolean $relative Whether or not to include the full URL or just the portion relative to $tubepress_base_url
*
* @return string The URl of the CSS stylesheet.
*/
function getCssPath($currentTheme, $relative = false);
/**
* Returns the name of the current TubePress theme in use.
*
* @return string The current theme name, or 'default' if the default theme is in use or if there was a problem.
*/
function calculateCurrentThemeName();
}

View File

@ -0,0 +1,294 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* URL class. Lifted mostly from PEAR's Net_URL2 class.
*/
class org_tubepress_api_url_Url
{
/**
* @var string|bool
*/
private $_scheme = false;
/**
* @var string|bool
*/
private $_userinfo = false;
/**
* @var string|bool
*/
private $_host = false;
/**
* @var string|bool
*/
private $_port = false;
/**
* @var string
*/
private $_path = '';
/**
* @var string|bool
*/
private $_query = false;
/**
* @var string|bool
*/
private $_fragment = false;
/**
* Constructor.
*
* @param string $url an absolute or relative URL
*/
public function __construct($url)
{
// The regular expression is copied verbatim from RFC 3986, appendix B.
// The expression does not validate the URL but matches any string.
preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!', $url, $matches);
// "path" is always present (possibly as an empty string); the rest
// are optional.
$this->_scheme = !empty($matches[1]) ? $matches[2] : false;
$this->setAuthority(!empty($matches[3]) ? $matches[4] : false);
$this->_path = $matches[5];
$this->_query = !empty($matches[6]) ? $matches[7] : false;
$this->_fragment = !empty($matches[8]) ? $matches[9] : false;
}
/**
* Sets the query string to the specified variable in the query string.
*
* @param array $array (name => value) array
*
* @return void
*/
public function setQueryVariables(array $array)
{
if (!$array) {
$this->_query = false;
} else {
foreach ($array as $name => $value) {
$name = self::urlencode($name);
if (is_array($value)) {
foreach ($value as $k => $v) {
$parts[] = sprintf('%s[%s]=%s', $name, $k, $v);
}
} elseif (!is_null($value)) {
$parts[] = $name . '=' . self::urlencode($value);
} else {
$parts[] = $name;
}
}
$this->_query = implode('&', $parts);
}
}
/**
* Sets the specified variable in the query string.
*
* @param string $name variable name
* @param mixed $value variable value
*
* @return array
*/
public function setQueryVariable($name, $value)
{
$array = $this->getQueryVariables();
$array[$name] = $value;
$this->setQueryVariables($array);
}
/**
* Removes the specifed variable from the query string.
*
* @param string $name a query string variable, e.g. "foo" in "?foo=1"
*
* @return void
*/
public function unsetQueryVariable($name)
{
$array = $this->getQueryVariables();
unset($array[$name]);
$this->setQueryVariables($array);
}
/**
* Returns a string representation of this URL.
*
* @return string
*/
public function toString($encodeAmpersands = false)
{
// See RFC 3986, section 5.3
$url = "";
if ($this->_scheme !== false) {
$url .= $this->_scheme . ':';
}
$authority = $this->getAuthority();
if ($authority !== false) {
$url .= '//' . $authority;
}
$url .= $this->_path;
if ($this->_query !== false) {
$url .= '?' . $this->_query;
}
if ($this->_fragment !== false) {
$url .= '#' . $this->_fragment;
}
if ($encodeAmpersands) {
return str_replace("&", "&amp;", $url);
}
return $url;
}
/**
* Percent-encodes all non-alphanumeric characters except these: _ . - ~
* Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP
* 5.2.x and earlier.
*
* @param $raw the string to encode
* @return string
*/
public static function urlencode($string)
{
$encoded = rawurlencode($string);
// This is only necessary in PHP < 5.3.
$encoded = str_replace('%7E', '~', $encoded);
return $encoded;
}
/**
* Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify
* false if there is no authority.
*
* @param string|false $authority a hostname or an IP addresse, possibly
* with userinfo prefixed and port number
* appended, e.g. "foo:bar@example.org:81".
*
* @return void
*/
public function setAuthority($authority)
{
$this->_userinfo = false;
$this->_host = false;
$this->_port = false;
if (preg_match('@^(([^\@]*)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) {
if ($reg[1]) {
$this->_userinfo = $reg[2];
}
$this->_host = $reg[3];
if (isset($reg[5])) {
$this->_port = $reg[5];
}
}
}
/**
* Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or
* false if there is no authority.
*
* @return string|bool
*/
public function getAuthority()
{
if (!$this->_host) {
return false;
}
$authority = '';
if ($this->_userinfo !== false) {
$authority .= $this->_userinfo . '@';
}
$authority .= $this->_host;
if ($this->_port !== false) {
$authority .= ':' . $this->_port;
}
return $authority;
}
/**
* Returns the query string like an array as the variables would appear in
* $_GET in a PHP script. If the URL does not contain a "?", an empty array
* is returned.
*
* @return array
*/
public function getQueryVariables()
{
$pattern = '/[' . preg_quote('&', '/') . ']/';
$parts = preg_split($pattern, $this->_query, -1, PREG_SPLIT_NO_EMPTY);
$return = array();
foreach ($parts as $part) {
if (strpos($part, '=') !== false) {
list($key, $value) = explode('=', $part, 2);
} else {
$key = $part;
$value = null;
}
$key = rawurldecode($key);
$value = rawurldecode($value);
if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
$key = $matches[1];
$idx = $matches[2];
// Ensure is an array
if (empty($return[$key]) || !is_array($return[$key])) {
$return[$key] = array();
}
// Add data
if ($idx === '') {
$return[$key][] = $value;
} else {
$return[$key][$idx] = $value;
}
} else {
$return[$key] = $value;
}
}
return $return;
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Builds URLs to send out to a remote provider
*
*/
interface org_tubepress_api_url_UrlBuilder
{
/**
* Builds a URL for a list of videos
*
* @param int $currentPage The current page number of the gallery.
*
* @throws Exception If there was a problem.
*
* @return string The request URL for this gallery
*/
function buildGalleryUrl($currentPage);
/**
* Builds a request url for a single video
*
* @param string $id The video ID to search for
*
* @throws Exception If there was a problem.
*
* @return string The URL for the single video given.
*/
function buildSingleVideoUrl($id);
}

View File

@ -0,0 +1,100 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* A video object that TubePress processes
*/
class org_tubepress_api_video_Video
{
private $_authorDisplayName;
private $_authorUid;
private $_category;
private $_commentCount;
private $_description;
private $_duration;
private $_homeUrl;
private $_id;
private $_keywords;
private $_likesCount;
private $_ratingAverage;
private $_ratingCount;
private $_thumbnailUrl;
private $_timeLastUpdated;
private $_timePublished;
private $_title;
private $_viewCount;
public function __construct()
{
$this->_keywords = array();
}
public function getAuthorDisplayName() { return $this->_authorDisplayName; }
public function setAuthorDisplayName($author) { $this->_authorDisplayName = $author; }
public function getAuthorUid() { return $this->_authorUid; }
public function setAuthorUid($author) { $this->_authorUid = $author; }
public function getCategory() { return $this->_category; }
public function setCategory($category) { $this->_category = $category; }
public function getCommentCount() { return $this->_commentCount; }
public function setCommentCount($count) { $this->_commentCount = $count; }
public function getDescription() { return $this->_description; }
public function setDescription($description) { $this->_description = $description; }
public function getDuration() { return $this->_duration; }
public function setDuration($duration) { $this->_duration = $duration; }
public function getHomeUrl() { return $this->_homeUrl; }
public function setHomeUrl($url) { $this->_homeUrl = $url; }
public function getId() { return $this->_id; }
public function setId($id) { $this->_id = $id; }
public function getKeywords() { return $this->_keywords; }
public function setKeywords($keywords) { $this->_keywords = $keywords; }
public function getLikesCount() { return $this->_likesCount; }
public function setLikesCount($c) { $this->_likesCount = $c; }
public function getRatingAverage() { return $this->_ratingAverage; }
public function setRatingAverage($average) { $this->_ratingAverage = $average; }
public function getRatingCount() { return $this->_ratingCount; }
public function setRatingCount($count) { $this->_ratingCount = $count; }
public function getThumbnailUrl() { return $this->_thumbnailUrl; }
public function setThumbnailUrl($url) { $this->_thumbnailUrl = $url; }
public function getTimeLastUpdated() { return $this->_timeLastUpdated; }
public function setTimeLastUpdated($time) { $this->_timeLastUpdated = $time; }
public function getTimePublished() { return $this->_timePublished; }
public function setTimePublished($time) { $this->_timePublished = $time; }
public function getTitle() { return $this->_title; }
public function setTitle($title) { $this->_title = $title; }
public function getViewCount() { return $this->_viewCount; }
public function setViewCount($count) { $this->_viewCount = $count; }
}

View File

@ -0,0 +1,125 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_bootstrap_Bootstrapper',
'org_tubepress_impl_log_Log',
'org_tubepress_api_const_filters_ExecutionPoint'));
/**
* Performs TubePress-wide initialization.
*/
abstract class org_tubepress_impl_bootstrap_AbstractBootstrapper implements org_tubepress_api_bootstrap_Bootstrapper
{
private static $_alreadyBooted = false;
/**
* Performs TubePress-wide initialization.
*
* @return null
*/
public function boot()
{
try {
$this->_wrappedBoot();
} catch (Exception $e) {
org_tubepress_impl_log_Log::log($this->_getName(), 'Caught exception while booting: '. $e->getMessage());
}
}
private function _wrappedBoot()
{
/* don't boot twice! */
if (self::$_alreadyBooted) {
return;
}
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
$envDetector = $ioc->get('org_tubepress_api_environment_Detector');
/* WordPress likes to keep control of the output */
if ($envDetector->isWordPress()) {
ob_start();
}
/* Turn on logging if we need to */
org_tubepress_impl_log_Log::setEnabled($tpom->get(org_tubepress_api_const_options_names_Advanced::DEBUG_ON), $_GET);
org_tubepress_impl_log_Log::log($this->_getName(), 'Booting!');
/* register default filters */
$fs = $ioc->get('org_tubepress_api_filesystem_Explorer');
$baseDir = $fs->getTubePressBaseInstallationPath() . '/sys/classes/org/tubepress/impl/filters/';
$this->_loadFilters($baseDir . 'html', $fs, $ioc);
$this->_loadFilters($baseDir . 'template', $fs, $ioc);
$this->_loadFilters($baseDir . 'feedresult', $fs, $ioc);
/* continue booting process */
$this->_doBoot();
/* remember that we booted. */
self::$_alreadyBooted = true;
}
/**
* Get the name of this bootstrapper.
*
* @return void
*/
protected abstract function _getName();
/**
* Perform boot procedure.
*
* @return void
*/
protected abstract function _doBoot();
private function _loadFilters($directory, $fs, $ioc)
{
org_tubepress_impl_log_Log::log($this->_getName(), 'Loading TubePress filters from <tt>%s</tt>', $directory);
/* get a list of the files in the directory */
$pluginPaths = $fs->getFilenamesInDirectory($directory, $this->_getName());
/* we want to provide the filter manager to the filters */
$tubepressFilterManager = $ioc->get('org_tubepress_api_patterns_FilterManager');
/* include the PHP files that we can read */
foreach ($pluginPaths as $pluginPath) {
if ('.php' == substr($pluginPath, -4) && is_readable($pluginPath)) {
org_tubepress_impl_log_Log::log($this->_getName(), 'Loading TubePress filter at <tt>%s</tt>', $pluginPath);
include_once $pluginPath;
} else {
org_tubepress_impl_log_Log::log($this->_getName(), 'Ignoring non-filter file at <tt>%s</tt>', $pluginPath);
}
}
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_bootstrap_AbstractBootstrapper',
'org_tubepress_impl_env_wordpress_Main',
'org_tubepress_impl_env_wordpress_Admin',
'org_tubepress_impl_env_wordpress_Widget'));
/**
* Performs WordPress initialization.
*/
class org_tubepress_impl_bootstrap_FreeWordPressPluginBootstrapper extends org_tubepress_impl_bootstrap_AbstractBootstrapper
{
/**
* Perform boot procedure.
*
* @return void
*/
protected function _doBoot()
{
global $tubepress_base_url;
$baseName = $this->getBaseName();
/* set the tubepress_base_url global */
$tubepress_base_url = get_option('siteurl') . "/wp-content/plugins/$baseName";
/* register the plugin's message bundles */
load_plugin_textdomain('tubepress', false, "$baseName/i18n");
add_filter('the_content', array('org_tubepress_impl_env_wordpress_Main', 'contentFilter'));
add_action('wp_head', array('org_tubepress_impl_env_wordpress_Main', 'headAction'));
add_action('init', array('org_tubepress_impl_env_wordpress_Main', 'initAction'));
add_action('admin_menu', array('org_tubepress_impl_env_wordpress_Admin', 'menuAction'));
add_action('admin_init', array('org_tubepress_impl_env_wordpress_Admin', 'initAction'));
add_action('widgets_init', array('org_tubepress_impl_env_wordpress_Widget', 'initAction'));
}
/**
* Get the name of this bootstrapper.
*
* @return void
*/
protected function _getName()
{
return 'WordPress Bootstrapper';
}
protected function getBaseName()
{
/* have to consider that sometimes people may name the "tubepress" directory differently */
$dirName = realpath(dirname(__FILE__) . '/../../../../../../');
return basename($dirName);
}
}

View File

@ -0,0 +1,359 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*
* Fast, light and safe Cache Class lifted almost entirely from PEAR's Cache_Lite class.
*
* Cache_Lite is a fast, light and safe cache system. It's optimized
* for file containers. It is fast and safe (because it uses file
* locking and/or anti-corruption tests).
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_cache_Cache',
'org_tubepress_impl_log_Log',
'org_tubepress_impl_filesystem_FsExplorer'));
class org_tubepress_impl_cache_PearCacheLiteCacheService implements org_tubepress_api_cache_Cache
{
const HASH_DIR_LEVEL = 1;
const HASH_DIR_UMASK = 0700;
const LOG_PREFIX = 'Cache_Lite Cache';
/**
* Test if a cache is available and (if yes) return it
*
* @param string $id cache id
*
* @return string data of the cache (else : false)
*/
public function get($id)
{
try {
return $this->_wrappedGet($id);
} catch (Exception $e) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Caught exception when running "get": ' . $e->getMessage());
return false;
}
}
private function _wrappedGet($id)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
$life = $tpom->get(org_tubepress_api_const_options_names_Advanced::CACHE_LIFETIME_SECONDS);
$data = false;
$refreshTime = $this->_getRefreshTime($life);
$file = $this->_getFileWithPath($id, $ioc);
clearstatcache();
if (is_null($refreshTime)) {
if (file_exists($file)) {
$data = $this->_read($file, $life);
}
} else {
if ((file_exists($file)) && (@filemtime($file) > $refreshTime)) {
$data = $this->_read($file, $life);
}
}
return $data;
}
/**
* Save some data in a cache file
*
* @param string $id cache id
* @param string $data data to put in cache
*
* @return boolean true if no problem (else : false)
*/
public function save($id, $data)
{
try {
return $this->_wrappedSave($id, $data);
} catch (Exception $e) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Caught exception when saving: ' . $e->getMessage());
return false;
}
}
private function _wrappedSave($id, $data)
{
if (!is_string($data)) {
throw new Exception("Cache can only save string data");
}
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
$life = $tpom->get(org_tubepress_api_const_options_names_Advanced::CACHE_LIFETIME_SECONDS);
$cleaningFactor = $tpom->get(org_tubepress_api_const_options_names_Advanced::CACHE_CLEAN_FACTOR);
$file = $this->_getFileWithPath($id, $ioc);
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Saving data to key at %s and file %s. Cleaning factor is %d', $id, $file, $cleaningFactor);
if ($cleaningFactor > 0) {
$rand = rand(1, $cleaningFactor);
if ($rand == 1) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cleaning out old cache entries');
$this->_cleanDir($this->_getCacheDir($ioc));
}
}
$res = $this->_writeAndControl($id, $data, $life, $file, $ioc);
if (is_bool($res)) {
if ($res) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Saved data to key at %s', $id);
return true;
}
// if $res if false, we need to invalidate the cache
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Invalidating cache under key at %s', $id);
@touch($file, time() - 2 * abs($life));
return false;
}
return $res;
}
/**
* Should only be called during testing!
*
* @return void
*/
public function clean()
{
$this->_cleanDir($this->_getCacheDir(org_tubepress_impl_ioc_IocContainer::getInstance()));
}
/**
* Compute & set the refresh time
*
* @param int $life The current cache lifetime.
*
* @return int The Unix time when a cache item must be refreshed.
*/
private function _getRefreshTime($life)
{
if ($life === 0) {
return null;
} else {
return time() - $life;
}
}
/**
* Remove a file
*
* @param string $file complete file path and name
*
* @return boolean true if no problem
*/
private function _unlink($file)
{
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removing file at %s', $file);
if (!@unlink($file)) {
throw new Exception('Cache_Lite : Unable to remove cache file at ' . $file);
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removed file at %s', $file);
return true;
}
/**
* Recursive function for cleaning cache file in the given directory
*
* @param string $dir directory complete path (with a trailing slash)
*
* @return boolean true if no problem
*/
private function _cleanDir($dir)
{
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Removing cache files under directory at %s', $dir);
$motif = 'cache_';
if (!($dh = @opendir($dir))) {
return;
}
$result = true;
while ($file = readdir($dh)) {
if (($file != '.') && ($file != '..')) {
if (substr($file, 0, 6) == 'cache_') {
$fileTwo = $dir . $file;
if (is_file($fileTwo)) {
if (strpos($fileTwo, $motif) !== false) {
$result = ($result and ($this->_unlink($fileTwo)));
}
}
if ((is_dir($fileTwo)) and (self::HASH_DIR_LEVEL > 0)) {
$result = ($result and ($this->_cleanDir($fileTwo . '/')));
}
}
}
}
return $result;
}
private function _getFileWithoutPath($id)
{
return 'cache_' . md5($id);
}
private function _getFileWithPath($id, $ioc)
{
$suffix = $this->_getFileWithoutPath($id);
$root = $this->_getCacheDir($ioc);
if (self::HASH_DIR_LEVEL > 0) {
$hash = md5($suffix);
for ($i=0 ; $i < self::HASH_DIR_LEVEL ; $i++) {
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
}
}
return $root . $suffix;
}
private function _read($file, $life)
{
$fp = @fopen($file, "rb");
@flock($fp, LOCK_SH);
if (!$fp) {
throw new Exception('Unable to read cache file at ' . $file);
}
clearstatcache();
$length = @filesize($file);
$hashControl = @fread($fp, 32);
$length = $length - 32;
if ($length) {
$data = @fread($fp, $length);
} else {
$data = '';
}
@flock($fp, LOCK_UN);
@fclose($fp);
$hashData = $this->_hash($data);
if ($hashData != $hashControl) {
if (!(is_null($life))) {
@touch($file, time() - 2*abs($life));
} else {
@unlink($file);
}
return false;
}
return $data;
}
private function _write($id, $data, $ioc)
{
$file = $this->_getFileWithPath($id, $ioc);
$cacheDir = $this->_getCacheDir($ioc);
if (self::HASH_DIR_LEVEL > 0) {
$hash = md5($file);
$root = $cacheDir;
for ($i=0 ; $i < self::HASH_DIR_LEVEL ; $i++) {
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
if (!(@is_dir($root))) {
@mkdir($root, self::HASH_DIR_UMASK, true);
}
}
}
$dir = dirname($file);
if (!@is_dir($dir)) {
@mkdir($dir, self::HASH_DIR_UMASK, true);
}
$fp = @fopen($file, "wb");
if (!$fp) {
throw new Exception('Unable to write cache file : ' . $file);
}
@flock($fp, LOCK_EX);
@fwrite($fp, $this->_hash($data), 32);
@fwrite($fp, $data);
@flock($fp, LOCK_UN);
@fclose($fp);
return true;
}
private function _writeAndControl($id, $data, $life, $file, $ioc)
{
$result = $this->_write($id, $data, $ioc);
$dataRead = $this->_read($file, $life);
if ((is_bool($dataRead)) && (!$dataRead)) {
return false;
}
return $dataRead == $data;
}
private function _hash($data)
{
return sprintf('% 32d', crc32($data));
}
private function _getCacheDir($ioc)
{
$tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
$cacheDir = $tpom->get(org_tubepress_api_const_options_names_Advanced::CACHE_DIR);
if ($cacheDir != '') {
return $cacheDir;
}
$fs = $ioc->get('org_tubepress_api_filesystem_Explorer');
$tempDir = $fs->getSystemTempDirectory();
if (!is_dir($tempDir)) {
throw new Exception('Could not determine location of system temp directory');
}
return $tempDir . '/tubepress_cache/';
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_patterns_StrategyManager',
'org_tubepress_api_embedded_EmbeddedPlayer',
'org_tubepress_impl_ioc_IocContainer',
'org_tubepress_api_provider_ProviderCalculator'));
/**
* An HTML-embeddable video player.
*/
class org_tubepress_impl_embedded_DelegatingEmbeddedPlayer implements org_tubepress_api_embedded_EmbeddedPlayer
{
/**
* Spits back the HTML for this embedded player
*
* @param string $videoId The video ID to display
*
* @return string The HTML for this embedded player
*/
public function toString($videoId)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$pc = $ioc->get('org_tubepress_api_provider_ProviderCalculator');
$sm = $ioc->get('org_tubepress_api_patterns_StrategyManager');
//TODO: what if this bails?
$providerName = $pc->calculateProviderOfVideoId($videoId);
/* let the strategies do the heavy lifting */
//TODO: what if this bails?
return $sm->executeStrategy(array(
'org_tubepress_impl_embedded_strategies_JwFlvEmbeddedStrategy',
'org_tubepress_impl_embedded_strategies_YouTubeIframeEmbeddedStrategy',
'org_tubepress_impl_embedded_strategies_VimeoEmbeddedStrategy'
), $providerName, $videoId);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
/**
* Embedded player utilities
*
*/
class org_tubepress_impl_embedded_EmbeddedPlayerUtils
{
/**
* Returns a valid HTML color.
*
* @param string $candidate The first-choice HTML color. May be invalid.
* @param string $default The fallback HTML color. Must be be invalid.
*
* @return string $candidate if it's a valid HTML color. $default otherwise.
*/
public static function getSafeColorValue($candidate, $default)
{
$pattern = '/^[0-9a-fA-F]{6}$/';
if (preg_match($pattern, $candidate) === 1) {
return $candidate;
}
return $default;
}
/**
* Converts a boolean value to a string 1 or 0.
*
* @param boolean $bool The boolean value to convert.
*
* @return string '1' or '0'
*/
public static function booleanToOneOrZero($bool)
{
if ($bool === '1' || $bool === '0') {
return $bool;
}
return $bool ? '1' : '0';
}
/**
* Converts a boolean value to string.
*
* @param boolean $bool The boolean value to convert.
*
* @return string 'true' or 'false'
*/
public static function booleanToString($bool)
{
return $bool ? 'true' : 'false';
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_patterns_Strategy',
'org_tubepress_impl_ioc_IocContainer',
'org_tubepress_api_const_options_names_Embedded',
'org_tubepress_impl_embedded_EmbeddedPlayerUtils',
'org_tubepress_api_options_OptionsManager'));
/**
* Base class for embedded strategies.
*/
abstract class org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy implements org_tubepress_api_patterns_Strategy
{
private $_ioc;
private $_tpom;
/**
* Called *before* canHandle() and execute() to allow the strategy
* to initialize itself.
*/
public function start()
{
$this->_ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$this->_tpom = $this->_ioc->get('org_tubepress_api_options_OptionsManager');
}
/**
* Called *after* canHandle() and execute() to allow the strategy
* to tear itself down.
*/
public function stop()
{
unset($this->_ioc);
unset($this->_tpom);
}
/**
* Returns true if this strategy is able to handle
* the request.
*/
public function canHandle()
{
/* grab the arguments */
$args = func_get_args();
self::_checkArgs($args);
$providerName = $args[0];
$videoId = $args[1];
return $this->_canHandle($providerName, $videoId, $this->_ioc, $this->_tpom);
}
/**
* Execute the strategy.
*/
public function execute()
{
global $tubepress_base_url;
$args = func_get_args();
self::_checkArgs($args);
$providerName = $args[0];
$videoId = $args[1];
$theme = $this->_ioc->get('org_tubepress_api_theme_ThemeHandler');
$template = $theme->getTemplateInstance($this->_getTemplatePath($providerName, $videoId, $this->_ioc, $this->_tpom));
$fullscreen = $this->_tpom->get(org_tubepress_api_const_options_names_Embedded::FULLSCREEN);
$playerColor = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($this->_tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR), '999999');
$playerHighlight = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($this->_tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_HIGHLIGHT), 'FFFFFF');
$autoPlay = $this->_tpom->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY);
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_DATA_URL, $this->_getEmbeddedDataUrl($providerName, $videoId, $this->_ioc, $this->_tpom));
$template->setVariable(org_tubepress_api_const_template_Variable::TUBEPRESS_BASE_URL, $tubepress_base_url);
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_AUTOSTART, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToString($autoPlay));
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_WIDTH, $this->_tpom->get(org_tubepress_api_const_options_names_Embedded::EMBEDDED_WIDTH));
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_HEIGHT, $this->_tpom->get(org_tubepress_api_const_options_names_Embedded::EMBEDDED_HEIGHT));
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_COLOR_PRIMARY, $playerColor);
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_COLOR_HIGHLIGHT, $playerHighlight);
$template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_FULLSCREEN, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToString($fullscreen));
return $template->toString();
}
protected abstract function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom);
protected abstract function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom);
protected abstract function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom);
private static function _checkArgs($args)
{
/* a little sanity checking */
if (count($args) !== 2) {
throw new Exception(sprintf("Wrong argument count sent to canHandle(). Expects 2, you sent %d", count($args)));
}
}
}
?>

View File

@ -0,0 +1,67 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy',
'org_tubepress_api_ioc_IocService',
'org_tubepress_impl_embedded_EmbeddedPlayerUtils',
'org_tubepress_api_const_options_names_Embedded',
'org_tubepress_api_options_OptionsManager',
'org_tubepress_api_url_Url'));
/**
* Embedded player strategy for YouTube embeds
*/
abstract class org_tubepress_impl_embedded_strategies_AbstractYouTubeEmbeddedStrategy extends org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy
{
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
$link = new org_tubepress_api_url_Url($this->_getUrlBaseWithoutTrailingSlash() . '/' . $videoId);
$showRelated = $tpom->get(org_tubepress_api_const_options_names_Embedded::SHOW_RELATED);
$autoPlay = $tpom->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY);
$loop = $tpom->get(org_tubepress_api_const_options_names_Embedded::LOOP);
$fullscreen = $tpom->get(org_tubepress_api_const_options_names_Embedded::FULLSCREEN);
$playerColor = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR), '999999');
$playerHighlight = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_HIGHLIGHT), 'FFFFFF');
$showInfo = $tpom->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO);
if (!($playerColor == '999999' && $playerHighlight == 'FFFFFF')) {
$link->setQueryVariable('color2', '0x' . $playerColor);
$link->setQueryVariable('color1', '0x' . $playerHighlight);
}
$link->setQueryVariable('rel', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showRelated));
$link->setQueryVariable('autoplay', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay));
$link->setQueryVariable('loop', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop));
$link->setQueryVariable('fs', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($fullscreen));
$link->setQueryVariable('showinfo', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
if ($tpom->get(org_tubepress_api_const_options_names_Embedded::HIGH_QUALITY)) {
$link->setQueryVariable('hd', '1');
}
return $link->toString(true);
}
protected abstract function _getUrlBaseWithoutTrailingSlash();
}

View File

@ -0,0 +1,54 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy',
'org_tubepress_api_ioc_IocService',
'org_tubepress_api_url_Url',
'org_tubepress_api_const_options_names_Embedded',
'org_tubepress_api_options_OptionsManager'));
/**
* Embedded player strategy for the JW FLV player
*/
class org_tubepress_impl_embedded_strategies_JwFlvEmbeddedStrategy extends org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy
{
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return $providerName === org_tubepress_api_provider_Provider::YOUTUBE
&& $tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_IMPL) === org_tubepress_api_const_options_values_PlayerImplementationValue::LONGTAIL;
}
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return 'embedded_flash/longtail.tpl.php';
}
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
$link = new org_tubepress_api_url_Url(sprintf('http://www.youtube.com/watch?v=%s', $videoId));
return $link->toString(true);
}
}
?>

View File

@ -0,0 +1,73 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy',
'org_tubepress_api_ioc_IocService',
'org_tubepress_api_options_OptionsManager',
'org_tubepress_impl_embedded_EmbeddedPlayerUtils',
'org_tubepress_api_const_options_names_Embedded',
'org_tubepress_api_provider_Provider',
'org_tubepress_api_url_Url'));
/**
* Embedded player strategy for native Vimeo
*/
class org_tubepress_impl_embedded_strategies_VimeoEmbeddedStrategy extends org_tubepress_impl_embedded_strategies_AbstractEmbeddedStrategy
{
const VIMEO_EMBEDDED_PLAYER_URL = 'http://player.vimeo.com/';
const VIMEO_QUERYPARAM_AUTOPLAY = 'autoplay';
const VIMEO_QUERYPARAM_TITLE = 'title';
const VIMEO_QUERYPARAM_BYLINE = 'byline';
const VIMEO_QUERYPARAM_COLOR = 'color';
const VIMEO_QUERYPARAM_LOOP = 'loop';
const VIMEO_QUERYPARAM_PORTRAIT = 'portrait';
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return $providerName === org_tubepress_api_provider_Provider::VIMEO;
}
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return 'embedded_flash/vimeo.tpl.php';
}
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
$autoPlay = $tpom->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY);
$color = $tpom->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR);
$showInfo = $tpom->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO);
$loop = $tpom->get(org_tubepress_api_const_options_names_Embedded::LOOP);
/* build the data URL based on these options */
$link = new org_tubepress_api_url_Url(self::VIMEO_EMBEDDED_PLAYER_URL . "video/$videoId");
$link->setQueryVariable(self::VIMEO_QUERYPARAM_AUTOPLAY, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay));
$link->setQueryVariable(self::VIMEO_QUERYPARAM_COLOR, $color);
$link->setQueryVariable(self::VIMEO_QUERYPARAM_LOOP, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop));
$link->setQueryVariable(self::VIMEO_QUERYPARAM_TITLE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
$link->setQueryVariable(self::VIMEO_QUERYPARAM_BYLINE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
$link->setQueryVariable(self::VIMEO_QUERYPARAM_PORTRAIT, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo));
return $link->toString(true);
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_embedded_strategies_AbstractYouTubeEmbeddedStrategy',
'org_tubepress_api_ioc_IocService',
'org_tubepress_api_options_OptionsManager',
'org_tubepress_api_const_options_names_Embedded',
'org_tubepress_api_provider_Provider',
'org_tubepress_api_embedded_EmbeddedPlayer'));
/**
* Embedded player strategy for YouTube iframe embeds
*/
class org_tubepress_impl_embedded_strategies_YouTubeIframeEmbeddedStrategy extends org_tubepress_impl_embedded_strategies_AbstractYouTubeEmbeddedStrategy
{
protected function _canHandle($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return $providerName === org_tubepress_api_provider_Provider::YOUTUBE;
}
protected function _getTemplatePath($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_options_OptionsManager $tpom)
{
return "embedded_flash/youtube.tpl.php";
}
protected function _getUrlBaseWithoutTrailingSlash()
{
return 'http://www.youtube.com/embed';
}
}

View File

@ -0,0 +1,95 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_ioc_FreeWordPressPluginIocService',
'org_tubepress_ioc_ProInWordPressIocService',
'org_tubepress_api_ioc_IocService',
'org_tubepress_impl_options_FormHandler',
'org_tubepress_api_filesystem_Explorer'));
class org_tubepress_impl_env_wordpress_Admin
{
/**
* Hook for WordPress init.
*
* @return void
*/
public static function initAction()
{
if (!is_admin()) {
return;
}
global $tubepress_base_url;
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
$fs = $iocContainer->get('org_tubepress_api_filesystem_Explorer');
$dirName = basename($fs->getTubePressBaseInstallationPath());
wp_register_style('jquery-ui-flick', "$tubepress_base_url/sys/ui/static/css/jquery-ui-flick/jquery-ui-1.7.2.custom.css");
wp_register_script('jscolor-tubepress', "$tubepress_base_url/sys/ui/static/js/jscolor/jscolor.js");
wp_enqueue_style('jquery-ui-flick');
wp_enqueue_script('jquery-ui-tabs');
wp_enqueue_script('jscolor-tubepress');
}
/**
* Hook for WordPress admin menu.
*
* @return void
*/
public static function menuAction()
{
add_options_page('TubePress Options', 'TubePress', 'manage_options', __FILE__, array('org_tubepress_impl_env_wordpress_Admin', 'conditionalExecuteOptionsPage'));
}
/**
* Registers the TubePress options page
*
* @return void
*/
public static function conditionalExecuteOptionsPage()
{
/* grab the storage manager */
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
$wpsm = $iocContainer->get('org_tubepress_api_options_StorageManager');
/* initialize our options in case we need to */
$wpsm->init();
/* get the form handler */
$optionsForm = $iocContainer->get('org_tubepress_impl_options_FormHandler');
/* are we updating? */
if (isset($_POST['tubepress_save'])) {
try {
$optionsForm->collect($_POST);
echo '<div id="message" class="updated fade"><p><strong>Options updated</strong></p></div>';
} catch (Exception $error) {
echo '<div id="message" class="error fade"><p><strong>' . $error->getMessage() . '</strong></p></div>';
}
}
print $optionsForm->getHtml();
}
}

View File

@ -0,0 +1,146 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_options_WordPressStorageManager',
'org_tubepress_api_const_options_names_Advanced',
'org_tubepress_api_shortcode_ShortcodeParser',
'org_tubepress_ioc_ProInWordPressIocService',
'org_tubepress_impl_ioc_IocContainer',
'org_tubepress_impl_util_StringUtils',
'org_tubepress_api_const_options_values_ModeValue',
'org_tubepress_api_html_HtmlGenerator'));
class org_tubepress_impl_env_wordpress_Main
{
/**
* Filters the WordPress content, looking for TubePress shortcodes and replacing them with galleries/videos.
*
* @param string $content The WordPress content.
*
* @return string The modified content.
*/
public static function contentFilter($content = '')
{
try {
/* Whip up the IOC service */
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
/* do as little work as possible here 'cause we might not even run */
$wpsm = $ioc->get('org_tubepress_api_options_StorageManager');
$trigger = $wpsm->get(org_tubepress_api_const_options_names_Advanced::KEYWORD);
$parser = $ioc->get('org_tubepress_api_shortcode_ShortcodeParser');
/* no shortcode? get out */
if (!$parser->somethingToParse($content, $trigger)) {
return $content;
}
return self::_getHtml($content, $trigger, $parser, $ioc);
} catch (Exception $e) {
return $e->getMessage() . $content;
}
}
/**
* Does the heavy lifting of generating videos/galleries from content.
*
* @param string $content The WordPress content.
* @param string $trigger The shortcode keyword
*
* @return string The modified content.
*/
private static function _getHtml($content, $trigger, $parser, $ioc)
{
/* Get a handle to our options manager */
$tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
/* Grab the gallery that will do the heavy lifting */
$gallery = $ioc->get('org_tubepress_api_html_HtmlGenerator');
/* Parse each shortcode one at a time */
while ($parser->somethingToParse($content, $trigger)) {
/* Get the HTML for this particular shortcode. Could be a single video or a gallery. */
$generatedHtml = $gallery->getHtmlForShortcode($content);
/* remove any leading/trailing <p> tags from the content */
$pattern = '/(<[P|p]>\s*)(' . preg_quote($tpom->getShortcode(), '/') . ')(\s*<\/[P|p]>)/';
$content = preg_replace($pattern, '${2}', $content);
/* replace the shortcode with our new content */
$currentShortcode = $tpom->getShortcode();
$content = org_tubepress_impl_util_StringUtils::replaceFirst($currentShortcode, $generatedHtml, $content);
}
return $content;
}
/**
* WordPress head action hook.
*
* @return void
*/
public static function headAction()
{
/* no need to print anything in the head of the admin section */
if (is_admin()) {
return;
}
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$hh = $ioc->get('org_tubepress_api_html_HtmlGenerator');
/* this inline JS helps initialize TubePress */
$inlineJs = $hh->getHeadInlineJavaScriptString();
/* this meta stuff prevents search engines from indexing gallery pages > 1 */
$meta = $hh->getHeadMetaString();
print <<<EOT
$inlineJs
$meta
EOT;
}
/**
* WordPress init action hook.
*
* @return void
*/
public static function initAction()
{
/* no need to queue any of this stuff up in the admin section or login page */
if (is_admin() || __FILE__ === 'wp-login.php') {
return;
}
global $tubepress_base_url;
wp_register_script('tubepress', "$tubepress_base_url/sys/ui/static/js/tubepress.js");
wp_register_style('tubepress', "$tubepress_base_url/sys/ui/themes/default/style.css");
wp_enqueue_script('jquery');
wp_enqueue_script('tubepress');
wp_enqueue_style('tubepress');
}
}

View File

@ -0,0 +1,135 @@
<?php
/**
Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
This file is part of TubePress (http://tubepress.org)
TubePress is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TubePress is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_message_WordPressMessageService',
'org_tubepress_impl_ioc_FreeWordPressPluginIocService',
'org_tubepress_api_ioc_IocService',
'org_tubepress_api_const_options_names_Widget',
'org_tubepress_impl_template_SimpleTemplate',
'org_tubepress_api_const_template_Variable',
'org_tubepress_ioc_ProInWordPressIocService',
'org_tubepress_api_const_options_names_Advanced',
'org_tubepress_api_const_options_names_Display',
'org_tubepress_api_const_options_names_Meta',
'org_tubepress_api_player_Player'));
class org_tubepress_impl_env_wordpress_Widget
{
/**
* Registers the TubePress widget with WordPress.
*
* @return void
*/
public static function initAction()
{
$msg = new org_tubepress_impl_message_WordPressMessageService();
$widgetOps = array('classname' => 'widget_tubepress', 'description' => $msg->_('widget-description'));
wp_register_sidebar_widget('tubepress', 'TubePress', array('org_tubepress_impl_env_wordpress_Widget', 'printWidget'), $widgetOps);
wp_register_widget_control('tubepress', 'TubePress', array('org_tubepress_impl_env_wordpress_Widget', 'printControlPanel'));
}
/**
* Prints the output of the TubePress widget.
*
* @param array $opts The array of widget options.
*
* @return void
*/
public static function printWidget($opts)
{
extract($opts);
$iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
$tpom = $iocContainer->get('org_tubepress_api_options_OptionsManager');
$parser = $iocContainer->get('org_tubepress_api_shortcode_ShortcodeParser');
$gallery = $iocContainer->get('org_tubepress_api_html_HtmlGenerator');
/* Turn on logging if we need to */
org_tubepress_impl_log_Log::setEnabled($tpom->get(org_tubepress_api_const_options_names_Advanced::DEBUG_ON), $_GET);
/* default widget options */
$defaultWidgetOptions = array(
org_tubepress_api_const_options_names_Display::RESULTS_PER_PAGE => 3,
org_tubepress_api_const_options_names_Meta::VIEWS => false,
org_tubepress_api_const_options_names_Meta::DESCRIPTION => true,
org_tubepress_api_const_options_names_Display::DESC_LIMIT => 50,
org_tubepress_api_const_options_names_Display::CURRENT_PLAYER_NAME => org_tubepress_api_player_Player::POPUP,
org_tubepress_api_const_options_names_Display::THUMB_HEIGHT => 105,
org_tubepress_api_const_options_names_Display::THUMB_WIDTH => 135,
org_tubepress_api_const_options_names_Display::PAGINATE_ABOVE => false,
org_tubepress_api_const_options_names_Display::PAGINATE_BELOW => false,
org_tubepress_api_const_options_names_Display::THEME => 'sidebar'
);
/* now apply the user's options */
$wpsm = $iocContainer->get('org_tubepress_api_options_OptionsManager');
$parser->parse($wpsm->get(org_tubepress_api_const_options_names_Widget::TAGSTRING));
/* calculate the final options */
$finalOptions = array_merge($defaultWidgetOptions, $tpom->getCustomOptions());
$tpom->setCustomOptions($finalOptions);
if ($tpom->get(org_tubepress_api_const_options_names_Display::THEME) === '') {
$tpom->set(org_tubepress_api_const_options_names_Display::THEME, 'sidebar');
}
$out = $gallery->getHtmlForShortcode('');
/* do the standard WordPress widget dance */
echo $before_widget . $before_title .
$wpsm->get(org_tubepress_api_const_options_names_Widget::TITLE) .
$after_title . $out . $after_widget;
}
/**
* Prints the TubePress widget control panel.
*
* @return void
*/
public static function printControlPanel()
{
$iocContainer = new org_tubepress_impl_ioc_FreeWordPressPluginIocService();
$wpsm = $iocContainer->get('org_tubepress_api_options_StorageManager');
$msg = $iocContainer->get('org_tubepress_api_message_MessageService');
/* are we saving? */
if (isset($_POST['tubepress-widget-submit'])) {
$wpsm->set(org_tubepress_api_const_options_names_Widget::TAGSTRING, strip_tags(stripslashes($_POST['tubepress-widget-tagstring'])));
$wpsm->set(org_tubepress_api_const_options_names_Widget::TITLE, strip_tags(stripslashes($_POST['tubepress-widget-title'])));
}
/* load up the gallery template */
$tpl = new org_tubepress_impl_template_SimpleTemplate();
$tpl->setPath(dirname(__FILE__) . '/../../../../../../../sys/ui/templates/wordpress/widget_controls.tpl.php');
/* set up the template */
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_CONTROL_TITLE, $msg->_('options-meta-title-title'));
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_TITLE, $wpsm->get(org_tubepress_api_const_options_names_Widget::TITLE));
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_CONTROL_SHORTCODE, $msg->_('widget-tagstring-description'));
$tpl->setVariable(org_tubepress_api_const_template_Variable::WIDGET_SHORTCODE, $wpsm->get(org_tubepress_api_const_options_names_Widget::TAGSTRING));
/* get the template's output */
echo $tpl->toString();
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_environment_Detector'));
/**
* Detects TubePress's environment
*/
class org_tubepress_impl_environment_SimpleEnvironmentDetector implements org_tubepress_api_environment_Detector
{
/**
* Detects if the user is running TubePress Pro.
*
* @return boolean True is the user is running TubePress Pro. False otherwise.
*/
public function isPro()
{
return is_readable(dirname(__FILE__) . '/../ioc/ProIocService.class.php');
}
/**
* Detects if the user is running within WordPress
*
* @return boolean True is the user is running within WordPress. False otherwise.
*/
public function isWordPress()
{
return strpos(realpath(__FILE__), 'wp-content' . DIRECTORY_SEPARATOR . 'plugins') !== false
|| function_exists('wp_cron');
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require(dirname(__FILE__) . '/../../../../tubepress_classloader.php');
tubepress_load_classes(array('org_tubepress_api_factory_VideoFactory',
'org_tubepress_impl_ioc_IocContainer',
'org_tubepress_api_patterns_StrategyManager'));
/**
* Video factory that sends the feed to the right video factory based on the provider
*/
class org_tubepress_impl_factory_DelegatingVideoFactory implements org_tubepress_api_factory_VideoFactory
{
/**
* Converts raw video feeds to TubePress videos
*
* @param unknown $feed The raw feed result from the video provider
*
* @return array an array of TubePress videos generated from the feed
*/
public function feedToVideoArray($feed)
{
try {
return $this->_wrappedFeedToVideoArray($feed);
} catch (Exception $e) {
org_tubepress_impl_log_Log::log('Delegating video factory', 'Caught exception building videos: ' . $e->getMessage());
return array();
}
}
protected function getArrayOfStrategyNames()
{
return array(
'org_tubepress_impl_factory_strategies_YouTubeFactoryStrategy',
'org_tubepress_impl_factory_strategies_VimeoFactoryStrategy'
);
}
private function _wrappedFeedToVideoArray($feed)
{
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$sm = $ioc->get('org_tubepress_api_patterns_StrategyManager');
/* let the strategies do the heavy lifting */
return $sm->executeStrategy($this->getArrayOfStrategyNames(), $feed);
}
}

View File

@ -0,0 +1,242 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_patterns_Strategy',
'org_tubepress_api_video_Video',
'org_tubepress_impl_log_Log',
'org_tubepress_impl_util_TimeUtils'));
/**
* Base class for factory strategies.
*/
abstract class org_tubepress_impl_factory_strategies_AbstractFactoryStrategy implements org_tubepress_api_patterns_Strategy
{
const LOG_PREFIX = 'Abstract Factory Strategy';
private $_tpom;
/**
* Called *before* canHandle() and execute() to allow the strategy
* to initialize itself.
*
* @return void
*/
function start()
{
return;
}
/**
* Called *after* canHandle() and execute() to allow the strategy
* to tear itself down.
*
* @return void
*/
function stop()
{
return;
}
/**
* Execute the strategy.
*
* @return unknown The result of this strategy execution.
*/
function execute()
{
/* grab the arguments */
$args = func_get_args();
self::_checkArgs($args);
$feed = $args[0];
/* give the strategy a chance to do some initial processing */
$this->_preExecute($feed);
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$this->_tpom = $ioc->get('org_tubepress_api_options_OptionsManager');
$results = array();
$index = 0;
$total = $this->_countVideosInFeed($feed);
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Now building %d video(s) from raw feed', $total);
for ($index = 0; $index < $total; $index++) {
if (!$this->_canHandleVideo($index)) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Skipping video at index %d', $index);
continue;
}
$results[] = $this->_buildVideo($index);
}
/* give the strategy a chance to do some post processing */
$this->_postExecute($feed);
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Built %d video(s) from raw feed', sizeof($results));
return $results;
}
/**
* Safely attempts to unserialize serialized PHP.
*
* @param unknown_type $raw The item to attempt to unserialize.
* @throws Exception If the item cannot be unserialized.
*
* @return unknown_type The unserialized PHP.
*/
protected static function _unserializePhpFeed($raw)
{
$result = false;
if (is_string($raw) && trim($raw) != '' && preg_match("/^(i|s|a|o|d):(.*);/si",$raw) > 0) {
$result = unserialize($raw);
}
if ($result === false) {
throw new Exception(sprintf('Unable to unserialize PHP from feed'));
}
return $result;
}
protected abstract function _preExecute($feed);
protected abstract function _postExecute($feed);
protected abstract function _countVideosInFeed($feed);
protected abstract function _canHandleVideo($index);
protected abstract function _getAuthorDisplayName($index);
protected abstract function _getAuthorUid($index);
protected abstract function _getCategory($index);
protected abstract function _getRawCommentCount($index);
protected abstract function _getDescription($index);
protected abstract function _getDurationInSeconds($index);
protected abstract function _getHomeUrl($index);
protected abstract function _getId($index);
protected abstract function _getKeywordsArray($index);
protected abstract function _getRawLikeCount($index);
protected abstract function _getRatingAverage($index);
protected abstract function _getRawRatingCount($index);
protected abstract function _getThumbnailUrlsArray($index);
protected abstract function _getTimeLastUpdatedInUnixTime($index);
protected abstract function _getTimePublishedInUnixTime($index);
protected abstract function _getTitle($index);
protected abstract function _getRawViewCount($index);
protected static function _checkArgs($args)
{
if (sizeof($args) !== 1) {
throw new Exception("Expected one arg. You sent %d", sizeof($args));
}
}
protected function _pickThumbnailUrl($urls)
{
if (!is_array($urls) || sizeof($urls) == 0) {
return '';
}
$random = $this->_tpom->get(org_tubepress_api_const_options_names_Display::RANDOM_THUMBS);
if ($random) {
return $urls[array_rand($urls)];
} else {
return $urls[1];
}
}
private function _buildVideo($index)
{
/* collect the pieces of the video */
$authorDisplayName = $this->_getAuthorDisplayName($index);
$authorUid = $this->_getAuthorUid($index);
$category = $this->_getCategory($index);
$commentCount = self::_fancyNumber($this->_getRawCommentCount($index));
$description = $this->_trimDescription($this->_getDescription($index));
$duration = org_tubepress_impl_util_TimeUtils::secondsToHumanTime($this->_getDurationInSeconds($index));
$homeUrl = $this->_getHomeUrl($index);
$id = $this->_getId($index);
$keywordsArray = $this->_getKeywordsArray($index);
$likesCount = self::_fancyNumber($this->_getRawLikeCount($index));
$ratingAverage = $this->_getRatingAverage($index);
$ratingCount = self::_fancyNumber($this->_getRawRatingCount($index));
$thumbUrl = $this->_pickThumbnailUrl($this->_getThumbnailUrlsArray($index));
$timeLastUpdated = $this->_fancyTime($this->_getTimeLastUpdatedInUnixTime($index));
$timePublished = $this->_fancyTime($this->_getTimePublishedInUnixTime($index));
$title = $this->_getTitle($index);
$viewCount = self::_fancyNumber($this->_getRawViewCount($index));
/* now build a video out of them */
$vid = new org_tubepress_api_video_Video();
$vid->setAuthorDisplayName($authorDisplayName);
$vid->setAuthorUid($authorUid);
$vid->setCategory($category);
$vid->setCommentCount($commentCount);
$vid->setDescription($description);
$vid->setDuration($duration);
$vid->setHomeUrl($homeUrl);
$vid->setId($id);
$vid->setKeywords($keywordsArray);
$vid->setLikesCount($likesCount);
$vid->setRatingAverage($ratingAverage);
$vid->setRatingCount($ratingCount);
$vid->setThumbnailUrl($thumbUrl);
$vid->setTimeLastUpdated($timeLastUpdated);
$vid->setTimePublished($timePublished);
$vid->setTitle($title);
$vid->setViewCount($viewCount);
return $vid;
}
private static function _fancyNumber($num)
{
if (!is_numeric($num)) {
return 'N/A';
}
return number_format($num);
}
private function _fancyTime($unixTime)
{
if ($unixTime == '') {
return '';
}
if ($this->_tpom->get(org_tubepress_api_const_options_names_Display::RELATIVE_DATES)) {
return org_tubepress_impl_util_TimeUtils::getRelativeTime($unixTime);
}
return date($this->_tpom->get(org_tubepress_api_const_options_names_Advanced::DATEFORMAT), $unixTime);
}
private function _trimDescription($description)
{
$limit = $this->_tpom->get(org_tubepress_api_const_options_names_Display::DESC_LIMIT);
if ($limit > 0 && strlen($description) > $limit) {
$description = substr($description, 0, $limit) . '...';
}
return $description;
}
}

View File

@ -0,0 +1,187 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_impl_factory_strategies_AbstractFactoryStrategy'));
/**
* Video factory for Vimeo
*/
class org_tubepress_impl_factory_strategies_VimeoFactoryStrategy extends org_tubepress_impl_factory_strategies_AbstractFactoryStrategy
{
const LOG_PREFIX = 'Vimeo Factory Strategy';
protected $_videoArray;
/**
* Returns true if this strategy is able to handle
* the request.
*
* @return boolean True if the strategy can handle the request, false otherwise.
*/
function canHandle()
{
/* grab the arguments */
$args = func_get_args();
self::_checkArgs($args);
$feed = $args[0];
try {
$unserialized = org_tubepress_impl_factory_strategies_AbstractFactoryStrategy::_unserializePhpFeed($feed);
} catch (Exception $e) {
return false;
}
return $unserialized->stat === 'ok';
}
protected function _preExecute($feed)
{
$unserialized = org_tubepress_impl_factory_strategies_AbstractFactoryStrategy::_unserializePhpFeed($feed);
if (isset($unserialized->video)) {
$this->_videoArray = $unserialized->video;
return;
}
if (isset($unserialized->videos) && isset($unserialized->videos->video)) {
$this->_videoArray = $unserialized->videos->video;
return;
}
$this->_videoArray = array();
}
protected function _postExecute($feed)
{
unset($this->_videoArray);
}
protected function _countVideosInFeed($feed)
{
return sizeof($this->_videoArray);
}
protected function _getAuthorDisplayName($index)
{
return $this->_videoArray[$index]->owner->display_name;
}
protected function _getAuthorUid($index)
{
return $this->_videoArray[$index]->owner->username;
}
protected function _getCategory($index)
{
return '';
}
protected function _getRawCommentCount($index)
{
return '';
}
protected function _getDescription($index)
{
return $this->_videoArray[$index]->description;
}
protected function _getDurationInSeconds($index)
{
return $this->_videoArray[$index]->duration;
}
protected function _getHomeUrl($index)
{
return 'http://vimeo.com/' . $this->_videoArray[$index]->id;
}
protected function _getId($index)
{
return $this->_videoArray[$index]->id;
}
protected function _getKeywordsArray($index)
{
return self::_gatherArrayOfContent($this->_videoArray[$index], 'tags', 'tag');
}
protected function _getRawLikeCount($index)
{
return $this->_videoArray[$index]->number_of_likes;
}
protected function _getRatingAverage($index)
{
return '';
}
protected function _getRawRatingCount($index)
{
return '';
}
protected function _getThumbnailUrlsArray($index)
{
$raw = self::_gatherArrayOfContent($this->_videoArray[$index], 'thumbnails', 'thumbnail');
return array($raw[0]);
}
protected function _getTimeLastUpdatedInUnixTime($index)
{
return '';
}
protected function _getTimePublishedInUnixTime($index)
{
return strtotime($this->_videoArray[$index]->upload_date);
}
protected function _getTitle($index)
{
return $this->_videoArray[$index]->title;
}
protected function _getRawViewCount($index)
{
return $this->_videoArray[$index]->number_of_plays;
}
protected function _canHandleVideo($index)
{
//Vimeo never sends us videos we can't display
return true;
}
protected static function _gatherArrayOfContent($node, $firstDimension, $secondDimension)
{
$results = array();
if (isset($node->$firstDimension) && is_array($node->$firstDimension->$secondDimension)) {
foreach ($node->$firstDimension->$secondDimension as $item) {
$results[] = $item->_content;
}
}
return $results;
}
}

View File

@ -0,0 +1,252 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes')
|| require dirname(__FILE__) . '/../../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_patterns_Strategy',
'org_tubepress_api_video_Video',
'org_tubepress_api_url_Url',
'org_tubepress_impl_factory_strategies_AbstractFactoryStrategy'));
/**
* Video factory for YouTube
*/
class org_tubepress_impl_factory_strategies_YouTubeFactoryStrategy extends org_tubepress_impl_factory_strategies_AbstractFactoryStrategy
{
/* shorthands for the namespaces */
const NS_APP = 'http://www.w3.org/2007/app';
const NS_ATOM = 'http://www.w3.org/2005/Atom';
const NS_MEDIA = 'http://search.yahoo.com/mrss/';
const NS_YT = 'http://gdata.youtube.com/schemas/2007';
const NS_GD = 'http://schemas.google.com/g/2005';
const LOG_PREFIX = 'YouTube Video Factory';
private $_xpath;
/**
* Returns true if this strategy is able to handle
* the request.
*
* @return boolean True if the strategy can handle the request, false otherwise.
*/
function canHandle()
{
/* grab the arguments */
$args = func_get_args();
self::_checkArgs($args);
$feed = $args[0];
return is_string($feed) && strpos($feed, "http://gdata.youtube.com/schemas/2007") !== false;
}
protected function getXpath()
{
return $this->_xpath;
}
protected function _preExecute($feed)
{
$this->_xpath = $this->_createXPath($this->_createDomDocument($feed));
}
protected function _postExecute($feed)
{
unset($this->_xpath);
}
protected function _countVideosInFeed($feed)
{
return $this->_xpath->query('//atom:entry')->length;
}
protected function _canHandleVideo($index)
{
$states = $this->_relativeQuery($index, 'app:control/yt:state');
/* no state applied? we're good to go */
if ($states->length == 0) {
return true;
}
/* if state is other than limitedSyndication, it's not available */
return $this->_relativeQuery($index, "app:control/yt:state[@reasonCode='limitedSyndication']")->length !== 0;
}
protected function _getAuthorDisplayName($index)
{
return $this->_getAuthorUid($index);
}
protected function _getAuthorUid($index)
{
return $this->_relativeQuery($index, 'atom:author/atom:name')->item(0)->nodeValue;
}
protected function _getCategory($index)
{
return trim($this->_relativeQuery($index, 'media:group/media:category')->item(0)->getAttribute('label'));
}
protected function _getRawCommentCount($index)
{
return '';
}
protected function _getDescription($index)
{
return $this->_relativeQuery($index, 'media:group/media:description')->item(0)->nodeValue;
}
protected function _getDurationInSeconds($index)
{
return $this->_relativeQuery($index, 'media:group/yt:duration')->item(0)->getAttribute('seconds');
}
protected function _getHomeUrl($index)
{
$rawUrl = $this->_relativeQuery($index, "atom:link[@rel='alternate']")->item(0)->getAttribute('href');
$url = new org_tubepress_api_url_Url($rawUrl);
return $url->toString(true);
}
protected function _getId($index)
{
$link = $this->_relativeQuery($index, "atom:link[@type='text/html']")->item(0);
$matches = array();
preg_match('/.*v=(.{11}).*/', $link->getAttribute('href'), $matches);
return $matches[1];
}
protected function _getKeywordsArray($index)
{
$rawKeywords = $this->_relativeQuery($index, 'media:group/media:keywords')->item(0);
$raw = trim($rawKeywords->nodeValue);
return split(", ", $raw);
}
protected function _getRawLikeCount($index)
{
return '';
}
protected function _getRatingAverage($index)
{
$count = $this->_relativeQuery($index, 'gd:rating')->item(0);
if ($count != null) {
return number_format($count->getAttribute('average'), 2);
}
return '';
}
protected function _getRawRatingCount($index)
{
$count = $this->_relativeQuery($index, 'gd:rating')->item(0);
if ($count != null) {
return $count->getAttribute('numRaters');
}
return '';
}
protected function _getThumbnailUrlsArray($index)
{
$thumbs = $this->_relativeQuery($index, 'media:group/media:thumbnail');
$result = array();
foreach ($thumbs as $thumb) {
//if (strpos($thumb->getAttribute('url'), 'hqdefault') === false) {
$result[] = $thumb->getAttribute('url');
//}
}
return $result;
}
protected function _getTimeLastUpdatedInUnixTime($index)
{
return '';
}
protected function _getTimePublishedInUnixTime($index)
{
$publishedNode = $this->_relativeQuery($index, 'atom:published');
if ($publishedNode->length == 0) {
return '';
}
$rawTime = $publishedNode->item(0)->nodeValue;
return org_tubepress_impl_util_TimeUtils::rfc3339toUnixTime($rawTime);
}
protected function _getTitle($index)
{
return $this->_relativeQuery($index, 'atom:title')->item(0)->nodeValue;
}
protected function _getRawViewCount($index)
{
$stats = $this->_relativeQuery($index, 'yt:statistics')->item(0);
if ($stats != null) {
return $stats->getAttribute('viewCount');
}
return '';
}
protected function _relativeQuery($index, $query)
{
return $this->_xpath->query('//atom:entry[' . ($index + 1) . "]/$query");
}
private function _createXPath(DOMDocument $doc)
{
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Building xpath to parse XML');
if (!class_exists('DOMXPath')) {
throw new Exception('Class DOMXPath not found');
}
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('atom', self::NS_ATOM);
$xpath->registerNamespace('yt', self::NS_YT);
$xpath->registerNamespace('gd', self::NS_GD);
$xpath->registerNamespace('media', self::NS_MEDIA);
$xpath->registerNamespace('app', self::NS_APP);
return $xpath;
}
private function _createDomDocument($feed)
{
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Attempting to load XML from YouTube');
if (!class_exists('DOMDocument')) {
throw new Exception('DOMDocument class not found');
}
$doc = new DOMDocument();
if ($doc->loadXML($feed) === false) {
throw new Exception('Could not parse XML from YouTube');
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Successfully loaded XML from YouTube');
return $doc;
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* Copyright 2006 - 2011 Eric D. Hough (http://ehough.com)
*
* This file is part of TubePress (http://tubepress.org)
*
* TubePress is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TubePress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TubePress. If not, see <http://www.gnu.org/licenses/>.
*
*/
function_exists('tubepress_load_classes') || require dirname(__FILE__) . '/../../../../tubepress_classloader.php';
tubepress_load_classes(array('org_tubepress_api_feed_FeedFetcher',
'org_tubepress_api_cache_Cache',
'org_tubepress_impl_log_Log',
'org_tubepress_impl_ioc_IocContainer',
'org_tubepress_api_http_HttpClient'));
/**
* Base functionality for feed retrieval services.
*/
class org_tubepress_impl_feed_CacheAwareFeedFetcher implements org_tubepress_api_feed_FeedFetcher
{
const LOG_PREFIX = 'Cache Aware Feed Fetcher';
/**
* Fetches the feed from a remote provider
*
* @param string $url The URL to fetch.
* @param boolean $useCache Whether or not to use the network cache.
*
* @return unknown The raw feed from the provider
*/
public function fetch($url, $useCache)
{
global $tubepress_base_url;
$ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
$cache = $ioc->get('org_tubepress_api_cache_Cache');
$result = '';
if ($useCache) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'First asking cache for <a href="%s">%s</a>', $url, $url);
$result = $cache->get($url);
if ($result !== false) {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cache has <a href="%s">%s</a>. Sweet.', $url, $url);
} else {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Cache does not have <a href="%s">%s</a>. We\'ll have to get it from the network.', $url, $url);
$result = $this->_getFromNetwork($url, $ioc);
$cache->save($url, $result);
}
} else {
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Skip cache check for <a href="%s">%s</a>', $url, $url);
$result = $this->_getFromNetwork($url, $ioc);
}
org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Raw result for <a href="%s">%s</a> is in the HTML source for this page. <span style="display:none">%s</span>', $url, $url, htmlspecialchars($result));
return $result;
}
private function _getFromNetwork($url, $ioc)
{
$client = $ioc->get('org_tubepress_api_http_HttpClient');
return $client->get($url);
}
}

Some files were not shown because too many files have changed in this diff Show More