Plugin Directory

Changeset 141675


Ignore:
Timestamp:
08/01/2009 07:24:25 AM (16 years ago)
Author:
ruslany
Message:

More JavaScript cleanup and refactoring.
Added functionality to create a db table for plugin.

Location:
wp-media-player/trunk
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • wp-media-player/trunk/scripts/startplayer.js.dev.js

    r141546 r141675  
    2727                                  null, $get(this._hostname)  );   
    2828
    29     this.post_id = 0;
    30 
    3129    this._playlist = this.getPlaylist();
    3230    this._player.set_mediainfo( this._playlist[0] );
     
    3432   
    3533    _onMediaOpened: function(sender, eventArgs){
    36         this._sendMediaStatus(0);
    37         //window.status = "Media Opened!";
     34        this._logMediaStatus(1);
    3835    },
    3936   
    4037    _onMediaEnded: function(sender, eventArgs) {
    41         this._sendMediaStatus(1);
    42         //window.status = "Media Ended!";
     38        this._logMediaStatus(2);
    4339    },
    4440   
     
    4743    },
    4844   
    49     _sendMediaStatus: function(status){
    50         //jQuery.ajax({type: 'GET', url: 'http://wordpress/wordpress/wp-content/plugins/wp-media-player/wp-media-player.php', data: 'pid=' + this.post_id + '&status=' + status, cache: false});       
     45    _getDocument: function(full_path) {
     46        var end = (full_path.indexOf("?") == -1) ? full_path.length : full_path.indexOf("?");
     47        return full_path.substring(full_path.lastIndexOf("/")+1, end);
     48    },
     49   
     50    _logMediaStatus: function(status){
     51        jQuery.ajax({type: 'GET', url: this.ajaxUrl, data: 'pid=' + this.postId + '&stat=' + status + '&file=' + this._getDocument(this._playlist[0].mediaSource), cache: false});     
    5152    }
    5253}
     
    5556    new StartMediaPlayer(parentId);
    5657}
     58
     59// strings used in scripts
     60
     61Sys.UI.Silverlight.ControlRes={
     62'runtimeErrorWithoutPosition': "Runtime error {2} in control '{0}', method {6}: {3}",
     63'scaleModeRequiresMatrixTransform': "When ScaleMode is set to zoom or stretch, the root Canvas must have not have a RenderTransform applied, or must only have a ScaleTransform.",
     64'mediaError_NotFound': "Media '{3}' in control '{0}' could not be found.",
     65'runtimeErrorWithPosition': "Runtime error {2} in control '{0}', method {6} (line {4}, col {5}): {3}",
     66'silverlightVersionFormat': "Must be in the format 'MajorVersion.MinorVersion'.",
     67'otherError': "{1} error #{2} in control '{0}': {3}",
     68'cannotChangeSource': "You cannot change the XAML source after initialization.",
     69'parserError': "Invalid XAML for control '{0}'. [{7}] (line {4}, col {5}): {3}",
     70'sourceAlreadySet': "You cannot change the XAML source after initialization.",
     71'parentNotFound' : "{1} error #{2} in control '{0}': {3}"
     72};
     73
     74Sys.UI.Silverlight.MediaRes={
     75'volumeRange':  "Volume must be a number greater than or equal to 0 and less than or equal to 1.",
     76'mediaFailed':  "Unable to load media '{0}'. This may be because there is no such file at this location or the video file is encoded incorrectly.",
     77'noMediaElement':  "The XAML document does not contain a media element.",
     78'noThumbElement': "{1} error #{2} in control '{0}': {3}",
     79'invalidChapter':  "Must be greater than or equal to 0 and less than the length of the chapter's array.",
     80'silverlightNotLoaded': "{1} error #{2} in control '{0}': {3}"
     81};
  • wp-media-player/trunk/wp-media-player.php

    r141511 r141675  
    7676        var $post_needs_meta = false;
    7777        var $content_save_pre_count = 0;
     78        var $playerlogs;
    7879
    7980        function wp_media_player()
    8081        {
    81             register_activation_hook(__FILE__, array(&$this, 'store_options'));
     82            global $wpdb;
     83            $this-> playerlogs = $wpdb->prefix.'media_player_logs';
     84            register_activation_hook(__FILE__, array(&$this, 'create_playerlogs_table'));
    8285
    8386            add_action( 'init', array(&$this, 'initialize'), 12 );
     
    117120            load_plugin_textdomain('wp-media-player', '/wp-content/plugins/wp-media-player/languages');
    118121        }
    119 
    120         function store_options()
    121         {
     122        /**
     123         * Creates the database table for storing video views data.
     124         * Also adds plugin options
     125         *
     126         * @return
     127         */
     128        function create_playerlogs_table()
     129        {
     130            global $wpdb;
     131   
     132            if( @is_file(ABSPATH.'/wp-admin/includes/upgrade.php') ) {
     133                include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
     134            }
     135            elseif( @is_file(ABSPATH.'/wp-admin/upgrade-functions.php') ) {
     136                include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
     137            }
     138            else {
     139                die('We have problem finding your \'/wp-admin/upgrade.php\'');
     140            }
     141
     142            $charset_collate = '';
     143            if( $wpdb->supports_collation() ) {
     144                if( !empty($wpdb->charset) ) {
     145                    $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     146                }
     147                if( !empty($wpdb->collate) ) {
     148                    $charset_collate .= " COLLATE $wpdb->collate";
     149                }
     150            }
     151
     152            $create_playerlogs_sql = "CREATE TABLE ".$this->playerlogs." (".
     153            "play_id INT(11) NOT NULL auto_increment,".
     154            "play_postid INT(11) NOT NULL ,".
     155            "play_posttitle TEXT NOT NULL,".
     156            "play_videofile TEXT NOT NULL,".           
     157            "play_opened INT(11) NOT NULL ,".
     158            "play_ended INT(11) NOT NULL ,".
     159            "PRIMARY KEY (play_id)) $charset_collate;";
     160
     161            maybe_create_table($this->playerlogs, $create_playerlogs_sql);
     162           
    122163            add_option('wp_media_player_autoLoad', '0');
    123164            add_option('wp_media_player_autoPlay', '0');
     
    129170            add_option('wp_media_player_show_on_home_page', 0);
    130171        }
    131 
    132172        /**
    133173         * Create a 2D array from a CSV string
     
    418458                    $scriptcode .= "player_".$post_id."_$i.mutedParam=".($tmp == '1'?'true':'false').";\n";
    419459                   
     460                    $scriptcode .= "player_".$post_id."_$i.postId=".$post_id.";\n";
     461                    $scriptcode .= "player_".$post_id."_$i.ajaxUrl='".$this -> pluginurl."wp-media-player.php';\n";
     462                   
    420463                    $scriptcode .= "player_".$post_id."_$i.getPlaylist=getCustomPlaylist_".$post_id."_$i;\n";
    421464                    $scriptcode .= "-->\n";
     
    435478        {
    436479            // This is a workaround for the weird behavior in content_save_pre.
    437             // The filter is called multiple tims and the second time it contains the previos
     480            // The filter is called multiple tims and the second time it contains the previous
    438481            // revision, which screws up the meta logic.
    439482            if ( $this -> content_save_pre_count > 0){
     
    478521        {   
    479522            if ($this -> show_player_check() == true)
    480             {       
     523            {   
     524                global $post;
     525           
    481526                wp_enqueue_script('jquery');
    482527                wp_enqueue_script('microsoftajax', $this -> pluginurl.'scripts/microsoftajax.js');
     
    485530                wp_enqueue_script('silverlightmedia', $this -> pluginurl.'scripts/silverlightmedia.js');
    486531                wp_enqueue_script('expressionplayer', $this -> pluginurl.'scripts/expressionplayer.js');
    487                 wp_enqueue_script('playerstrings', $this -> pluginurl.'scripts/playerstrings.js');
    488532                wp_enqueue_script('player', $this -> pluginurl.'styles/'.strtolower($this -> player_styles[$this -> plugin_parameters['style']]).'/player.js');
    489                 wp_enqueue_script('startmediaplayer', $this -> pluginurl.'scripts/startplayer.js.dev.js', array('jquery'));             
     533                wp_enqueue_script('startmediaplayer', $this -> pluginurl.'scripts/startplayer.js.dev.js', array('jquery'));
    490534            }
    491535        }
     
    631675        }
    632676       
    633         function process_status_ajax()
    634         {
    635             if ( isset($_GET['pid']) && isset($_GET['status']) ){
    636             /*
    637                 $fp = fopen('C:\inetpub\wwwroot\wordpress\wp-content\data.txt', 'a');
    638                 fwrite($fp, 'success for post '.$_GET['pid'].' at '.date('l jS \of F Y h:i:s A'."\n"));
    639                 fclose($fp);
    640             */
    641             }           
     677        function process_ajax_log_request()
     678        {
     679//          if ( isset($_GET['pid']) && isset($_GET['stat']) && isset($_GET['file']) ){
     680//              $post_id = intval($_GET['pid']);
     681//              $status = intval($_GET['stat']);
     682//              // Check Whether Is A Valid Post
     683//              $post = get_post($post_id);
     684//              if ( $post ){
     685//                  $post_title = addslashes($post->post_title);
     686//              }
     687
     688                // REMOVE THIS
     689//              $fp = fopen('C:\inetpub\wwwroot\wordpress\wp-content\data.txt', 'a');
     690//              fwrite($fp, 'video file '.$_GET['file'].': status '.$_GET['stat'].' for post '.$_GET['pid'].' at '.date('l jS \of F Y h:i:s A'."\n"));
     691//              fclose($fp);
     692//          }           
    642693        }
    643694    } // End Class wp_media_player
     
    650701        $mp_plugin = new wp_media_player();
    651702   
    652     $mp_plugin -> process_status_ajax();
     703    $mp_plugin -> process_ajax_log_request();
    653704}
    654705
Note: See TracChangeset for help on using the changeset viewer.