Beispiel #1
0
 /**
  * Processes the POST data from the previous state.
  * @param AdminState $st The next state to be populated with the POST data
  * from the previous state.
  */
 private function processPost($st)
 {
     $state = $st;
     if (isset($_POST['Uninstall'])) {
         $this->uninstall();
         $state->render();
     } else {
         if (isset($_POST["Next"])) {
             if ($_POST["Next"] == "Delete") {
                 LongTailFramework::setConfig($_POST[LONGTAIL_KEY . "config"]);
                 LongTailFramework::deleteConfig();
                 $configs = LongTailFramework::getConfigs();
                 if ($configs && count($configs) >= 2 && $_POST[LONGTAIL_KEY . "config"] == get_option($_POST[LONGTAIL_KEY . "default"])) {
                     update_option(LONGTAIL_KEY . "default", $configs[1]);
                 } else {
                     if (!$configs || count($configs) == 1) {
                         update_option(LONGTAIL_KEY . "default", "Out-of-the-Box");
                     }
                 }
                 $state = new PlayerState($_POST[LONGTAIL_KEY . "config"]);
                 $del_player = $_POST[LONGTAIL_KEY . "config"];
                 $this->feedback_message("The '{$del_player}' Player was successfully deleted.");
                 $state->render();
             } else {
                 if ($_POST["Next"] == "Create Custom Player") {
                     $_POST[LONGTAIL_KEY . "new_player"] = "Custom Player";
                 }
                 $state->getNextState()->render();
             }
         } else {
             if (isset($_POST["Previous"])) {
                 $state->getPreviousState()->render();
             } else {
                 if (isset($_POST["Cancel"])) {
                     $state->getCancelState()->render();
                 } else {
                     if (isset($_POST["Save"])) {
                         $config = $_POST[LONGTAIL_KEY . "config"];
                         LongTailFramework::setConfig($config);
                         $save_values = $this->processSubmit();
                         $success = LongTailFramework::saveConfig($this->convertToXML($save_values), esc_html($_POST[LONGTAIL_KEY . "new_player"]));
                         $configs = LongTailFramework::getConfigs();
                         if ($configs && count($configs) == 2) {
                             update_option(LONGTAIL_KEY . "default", $_POST[LONGTAIL_KEY . "config"] ? $_POST[LONGTAIL_KEY . "config"] : $_POST[LONGTAIL_KEY . "new_player"]);
                             update_option(LONGTAIL_KEY . "ootb", false);
                         }
                         $save_player = $_POST[LONGTAIL_KEY . "new_player"] ? $_POST[LONGTAIL_KEY . "new_player"] : $config;
                         if ($success) {
                             $this->feedback_message("The '{$save_player}' Player was successfully saved.");
                         } else {
                             $this->error_message("The '{$save_player}' failed to save.  Please make sure the " . LongTailFramework::getConfigPath() . " exists and is writable.  " . JW_FILE_PERMISSIONS);
                         }
                         $state->getSaveState()->render();
                     } else {
                         if (isset($_POST[LONGTAIL_KEY . "default"])) {
                             update_option(LONGTAIL_KEY . "default", $_POST[LONGTAIL_KEY . "default"]);
                         }
                         if (isset($_POST[LONGTAIL_KEY . "show_archive"])) {
                             update_option(LONGTAIL_KEY . "show_archive", true);
                         } else {
                             if (!empty($_POST)) {
                                 update_option(LONGTAIL_KEY . "show_archive", false);
                             }
                         }
                         LongTailFramework::setConfig($_POST[LONGTAIL_KEY . "config"]);
                         $state->render();
                     }
                 }
             }
         }
     }
 }
/**
 * Generates the combobox of available players.
 * @param int $id The attachment id.
 * @return string The HTML to render the player selector.
 */
function generatePlayerSelectorHTML($id)
{
    $player_select = "<select name='attachments[{$id}][" . LONGTAIL_KEY . "player_select]' id='" . LONGTAIL_KEY . "player_select_" . $id . "'>\n";
    $player_select .= "<option value='Default'>Default</option>\n";
    $configs = LongTailFramework::getConfigs();
    if ($configs) {
        foreach ($configs as $config) {
            if ($config != "New Player") {
                $player_select .= "<option value='" . $config . "'>" . $config . "</option>\n";
            }
        }
    }
    $player_select .= "</select>\n";
    return $player_select;
}
function jwplayermodule_js()
{
    ?>

function updateHandler(button) {
  button.form.submit();
}

function selectionHandler(button) {
  var field = document.getElementById("<?php 
    echo LONGTAIL_KEY . "player";
    ?>
");
  field.setAttribute("value", button.id.replace("<?php 
    echo LONGTAIL_KEY . "player_";
    ?>
", ""));
  var field = document.getElementById("<?php 
    echo LONGTAIL_KEY . "new_player";
    ?>
");
  field.setAttribute("value", button.id.replace("<?php 
    echo LONGTAIL_KEY . "player_";
    ?>
", ""));
}

function copyHandler(button) {
  var field = document.getElementById("<?php 
    echo LONGTAIL_KEY . "player";
    ?>
");
  field.setAttribute("value", button.id.replace("<?php 
    echo LONGTAIL_KEY . "player_";
    ?>
", ""));
  var field = document.getElementById("<?php 
    echo LONGTAIL_KEY . "new_player";
    ?>
");
  field.setAttribute("value", button.id.replace("<?php 
    echo LONGTAIL_KEY . "player_";
    ?>
", "") + "_copy");
}

function deleteHandler(button) {
  var result = confirm("Are you sure wish to delete the Player?");
  if (result) {
    selectionHandler(button);
    return true;
  }
  return false;
}

function saveHandler(button) {
  var configs = eval('(' + '<?php 
    echo json_encode(LongTailFramework::getConfigs());
    ?>
' + ')');
  var newVal = document.getElementById("<?php 
    echo LONGTAIL_KEY . "new_player";
    ?>
");
  var configVal = document.getElementById("<?php 
    echo LONGTAIL_KEY . "config";
    ?>
");
  if (configVal != null && newVal != null && configVal.value == newVal.value) {
    return true;
  }
  for (var config in configs) {
    if (newVal.value == configs[config]) {
      return confirm("A player with this name already exists and will be overwritten.  Would you like to continue?");
    }
  }
  return true;
}

<?php 
}
/**
 * This file contains the necessary methods for rendering the Playlist Manager
 * tab in the WordPress media popup.  The code is largely borrowed from the
 * WordPress Gallery with necessary modifications for managing playlists and
 * showing all uploaded media.
 * @global string $redir_tab Global reference to the tab to redirect to on
 * submit.
 * @global string $type Global reference to the type of content being managed.
 * @param undefined $errors List of any errors encountered.
 */
function media_jwplayer_insert_form($errors)
{
    global $redir_tab, $type, $jw_query, $p_items;
    $args = array('post_parent' => null, 'posts_per_page' => 10, 'paged' => $_GET['paged'] ? $_GET['paged'] : 1, 'post_status' => 'inherit', 'post_type' => 'attachment', 'orderby' => 'title ASC, ID', 'order' => 'DESC');
    $jw_query = new WP_Query($args);
    $redir_tab = 'jwplayer';
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=jwplayer&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    $playlists = jwplayer_get_playlists();
    if (isset($_POST[LONGTAIL_KEY . "playlist_create"]) || isset($_POST["save"])) {
        $post_title = $_POST[LONGTAIL_KEY . "playlist_name"];
        $new_playlist = array();
        $new_playlist["post_title"] = $post_title;
        $new_playlist["post_type"] = "jw_playlist";
        $new_playlist["post_status"] = null;
        $new_playlist["post_parent"] = null;
        $new_playlist_id = -1;
        if (isset($_POST["save"])) {
            $new_playlist_id = isset($_POST[LONGTAIL_KEY . "playlist_select"]) ? $_POST[LONGTAIL_KEY . "playlist_select"] : $playlists[0]->ID;
        } else {
            $new_playlist_id = wp_insert_post($new_playlist);
            $playlists = jwplayer_get_playlists();
        }
        $current_playlist = $new_playlist_id;
    } else {
        if (isset($_POST["delete"])) {
            wp_delete_post($_POST[LONGTAIL_KEY . "playlist_select"]);
            $playlists = jwplayer_get_playlists();
            $current_playlist = $playlists[0]->ID;
        }
    }
    if (!isset($current_playlist)) {
        if (isset($_POST[LONGTAIL_KEY . "playlist_select"])) {
            $current_playlist = $_POST[LONGTAIL_KEY . "playlist_select"];
        } else {
            if (isset($_GET["playlist"])) {
                $current_playlist = $_GET["playlist"];
            } else {
                $current_playlist = $playlists[0]->ID;
            }
        }
    }
    if (isset($_GET["p_items"])) {
        $p_items = json_decode(str_replace("\\", "", $_GET["p_items"]));
    } else {
        if (isset($_POST["playlist_items"]) && $_POST["old_playlist"] == $current_playlist) {
            $p_items = json_decode(str_replace("\\", "", $_POST["playlist_items"]));
        } else {
            $p_items = explode(",", get_post_meta($current_playlist, LONGTAIL_KEY . "playlist_items", true));
        }
    }
    update_post_meta($new_playlist_id, LONGTAIL_KEY . "playlist_items", implode(",", $p_items));
    echo '<link rel="stylesheet" href="' . WP_PLUGIN_URL . '/' . plugin_basename(dirname(dirname(__FILE__))) . '/' . 'css/playlist.css" type="text/css" media="print, projection, screen" />' . "\n";
    echo '<script type=text/javascript src="' . WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)) . '/' . 'js/playlist.js"></script>' . "\n";
    ?>

<script type="text/javascript">

  jQuery(function($){
    var desc = false;
    var preloaded = $(".media-item.preloaded");
    if ( preloaded.length > 0 ) {
      preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
      updateMediaForm();
    }
    var playlistPreloaded = $(".playlist-item.preloaded");
    if ( playlistPreloaded.length > 0 ) {
      playlistPreloaded.each(function(){preparePlaylistItem({id:this.id.replace(/[^0-9]/g, '')},'');});
      updatePlaylistForm();
    }
    $('#playlist-items').sortable( {
			items: 'div.playlist-item',
			placeholder: 'sorthelper',
			axis: 'y',
			distance: 2,
			handle: 'div.filename',
			stop: function(e, ui) {
				// When an update has occurred, adjust the order for each item
        var item_list = document.getElementById("playlist_items");
        var p_items = new Array();
        var old_p_items =  eval('(' + item_list.value + ')');
        if (old_p_items[0] == "") {old_p_items = new Array();}
				var all = $('#playlist-items').sortable('toArray'), len = all.length;
				$.each(all, function(i, id) {
					var order = desc ? (len - i) : (1 + i);
					$('#' + id + ' .menu_order input').val(order);
          p_items.push(id.replace("playlist-item-", ""));
				});
        update_page_numbers(p_items, old_p_items);
        document.getElementById("playlist_items").value = dump(p_items);
			}
		} );
  });

  function insertPlaylist() {
    var s;
    var playlist_dropdown = document.getElementById("<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
");
    var player_dropdown = document.getElementById("<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
");
    s = "[jwplayer ";
    if (player_dropdown.value != "Default") {
      s += "config=\"" + player_dropdown.value + "\" ";
    }
    s += "playlistid=\"" + playlist_dropdown.value + "\"]";
    getJWWin().send_to_editor(s);
    return;
  }

  function getJWWin() {
    return window.dialogArguments || opener || parent || top;
  }

  function deletePlaylistHandler() {
    return confirm("Are you sure wish to delete the Playlist?");
  }

  function createPlaylistHandler() {
    var playlistName = document.forms[0]["<?php 
    echo LONGTAIL_KEY . "playlist_name";
    ?>
"];
    if (playlistName.value == "") {
      alert("Your playlist must have a valid name.");
      return false;
    }
    return true;
  }

  function updatePlaylist(object) {
    var item_list = document.getElementById("playlist_items");
    var p_items = eval('(' + item_list.value + ')');
    if (p_items[0] == "") {p_items = new Array();}
    var old_p_items =  eval('(' + item_list.value + ')');
    if (old_p_items[0] == "") {old_p_items = new Array();}
    var playlist_check = object.id.indexOf("playlist_") > -1;
    var attachment_id = "";
    attachment_id = playlist_check ? object.id.replace("playlist_", "") : object.id;
    attachment_id = attachment_id.replace("attachments[", "").replace("][enabled]", "");
    if (object != null && object.checked === true) {
      p_items.push(attachment_id);
      update_checks(attachment_id, playlist_check, true);
    } else {
      var i = 0;
      for (i=0; i < p_items.length; i++) {
        if (p_items[i] == attachment_id) {
          break;
        }
      }
      update_checks(attachment_id, playlist_check, false);
      p_items.splice(i, 1);
    }
    update_page_numbers(p_items, old_p_items);
    item_list.value = dump(p_items);
  }

  function update_page_numbers(p_items, old_p_items) {
    var pages = jQuery(".page-numbers");
    var j = 0;
    for (j = 0; j < pages.length; j++) {
      var page = pages[j];
      if (page.href) {
        page.href = page.href.replace(encodeURI("&p_items=" + dump(old_p_items)), "");
        page.href = page.href + encodeURI("&p_items=" + dump(p_items));
      }
    }
  }

  function update_checks(attachment_id, playlist_check, new_state) {
    if (playlist_check) {
      var targetBox = document.getElementById("attachments[" + attachment_id + "][enabled]");
      if (targetBox != null) {
        targetBox.checked = new_state;
      }
    }
    if (new_state) {
      var itemToAdd = jQuery("#media-item-" + attachment_id).clone();
      itemToAdd[0].id = itemToAdd[0].id.replace("media", "playlist");
      itemToAdd[0].className = itemToAdd[0].className.replace("media", "playlist");
      var input = itemToAdd.children(".menu_order").children(".menu_order_input")[0];
      input.id = "playlist_" + input.id
      input.name = "playlist_" + input.name;
      if (input != null) input.checked = true;
      itemToAdd.appendTo("#playlist-items");
    } else {
      jQuery("#playlist-item-" + attachment_id).empty().remove();
    }
  }

</script>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form validate" id="playlist-form" style="width: 626px;">
  <?php 
    wp_nonce_field('media-form');
    ?>
  <?php 
    //media_upload_form( $errors );
    ?>
  <div class="tablenav" style="width: 626px;">
    <?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($jw_query->found_posts / 10), 'current' => $_GET['paged'] ? $_GET['paged'] : 1, 'add_args' => array('playlist' => $current_playlist)));
    if ($page_links) {
        ?>
        <div class='tablenav-pages'>
          <span style="font-size: 13px;"><?php 
        _e("Available Media:");
        ?>
</span>
          <?php 
        echo $page_links;
        ?>
        </div>
      <?php 
    }
    ?>
    <div class="alignleft actions">
      <div class="hide-if-no-js">
        <?php 
    _e("Playlist:");
    ?>
        <select onchange="this.form.submit()" id="<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
" name="<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
">
          <?php 
    foreach ($playlists as $playlist) {
        ?>
            <option value="<?php 
        echo $playlist->ID;
        ?>
" <?php 
        selected($playlist->ID, $current_playlist);
        ?>
>
              <?php 
        echo $playlist->post_title;
        ?>
            </option>
          <?php 
    }
    ?>
        </select>
        <input type="submit" class="button savebutton" name="save" id="save-all" value="<?php 
    esc_attr_e('Save');
    ?>
" />
        <input type="submit" class="button savebutton" name="delete" id="delete-all" value="<?php 
    esc_attr_e('Delete');
    ?>
" onclick="return deletePlaylistHandler()" />
        <input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
        <input type="hidden" name="type" value="<?php 
    echo esc_attr($GLOBALS['type']);
    ?>
" />
        <input type="hidden" name="tab" value="<?php 
    echo esc_attr($GLOBALS['tab']);
    ?>
" />
        <input type="hidden" id="playlist_items" name="playlist_items" value='<?php 
    echo json_encode($p_items);
    ?>
' />
        <input type="hidden" id="old_playlist" name="old_playlist" value="<?php 
    echo $current_playlist;
    ?>
" />
      </div>
    </div>
  </div>

  <div id="playlist-items" style="width: 300px; float: left;" class="ui-sortable">
    <?php 
    echo get_jw_playlist_items($post_id, $errors, $current_playlist);
    ?>
  </div>

  <div id="media-items" style="width: 300px; float: right;">
    <?php 
    add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    ?>
    <?php 
    echo get_playlist_items($post_id, $errors, $current_playlist);
    ?>
  </div>

  <div class="clear"></div>

  <p class="ml-submit">
    <?php 
    _e("New Playlist:");
    ?>
    <input type="text" value="" name="<?php 
    echo LONGTAIL_KEY . "playlist_name";
    ?>
" />
    <input type="submit" class="button savebutton" style="" name="<?php 
    echo LONGTAIL_KEY . "playlist_create";
    ?>
" id="<?php 
    echo LONGTAIL_KEY . "playlist_create";
    ?>
" value="<?php 
    esc_attr_e("Create Playlist");
    ?>
" onclick="return createPlaylistHandler()" />
  </p>
  <p class="ml-submit" style="padding: 0em 0;">
    <?php 
    _e("Select Player:");
    ?>
    <select name="<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
" id="<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
">
      <option value="Default">Default</option>
      <?php 
    $configs = LongTailFramework::getConfigs();
    ?>
      <?php 
    if ($configs) {
        ?>
        <?php 
        foreach ($configs as $config) {
            ?>
          <?php 
            if ($config != "New Player") {
                ?>
            <option value="<?php 
                echo $config;
                ?>
"><?php 
                echo $config;
                ?>
</option>
          <?php 
            }
            ?>
        <?php 
        }
        ?>
      <?php 
    }
    ?>
    </select>
    <input type="button" class="button-primary" onmousedown="insertPlaylist();" name="insert-gallery" id="insert-gallery" value="<?php 
    esc_attr_e('Insert Playlist');
    ?>
" />
  </p>
</form>
<?php 
}
 /**
  * Checks if there are any custom Player configs available.
  * @return boolean If there are any configs or not. 
  */
 public static function configsAvailable()
 {
     $configs = LongTailFramework::getConfigs();
     if ($configs && count($configs) > 1) {
         return true;
     }
     return false;
 }
/**
 * This file contains the necessary methods for rendering the Playlist Manager
 * tab in the WordPress media popup.  The code is largely borrowed from the
 * WordPress Gallery with necessary modifications for managing playlists and
 * showing all uploaded media.
 * @global string $redir_tab Global reference to the tab to redirect to on
 * submit.
 * @global string $type Global reference to the type of content being managed.
 * @param mixed $errors List of any errors encountered.
 */
function media_jwplayer_insert_form($errors)
{
    global $redir_tab, $type;
    $redir_tab = 'jwplayer';
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=jwplayer&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    $playlists = jwplayer_get_playlists();
    $current_playlist = $playlists[0]->ID;
    ?>

<script type="text/javascript">

  function insertPlaylist() {
    var s;
    var playlist_dropdown = document.getElementById("<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
");
    var player_dropdown = document.getElementById("<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
");
    s = "[jwplayer ";
    if (player_dropdown.value != "Default") {
      s += "config=\"" + player_dropdown.value + "\" ";
    }
    s += "playlistid=\"" + playlist_dropdown.value + "\"]";
    getJWWin().send_to_editor(s);
  }

  function getJWWin() {
    return window.dialogArguments || opener || parent || top;
  }

</script>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form validate" id="playlist-form" style="width: 626px;">
  <?php 
    wp_nonce_field('media-form');
    ?>

  <h3 class="media-title"><?php 
    _e("Insert a playlist", 'jw-player-plugin-for-wordpress');
    ?>
</h3>
  <p><?php 
    _e("This tab allows you to insert one of your playlists into your post.  To construct a playlist please visit the Playlist Media page.", 'jw-player-plugin-for-wordpress');
    ?>
</p>
  <div id="media-items">
    <div class="media-item">
      <div class="alignleft actions" style="margin: 1em;">
        <div class="hide-if-no-js">
          <label for="<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
"><strong><?php 
    _e("Select Playlist:", 'jw-player-plugin-for-wordpress');
    ?>
</strong></label>
          <select id="<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
" name="<?php 
    echo LONGTAIL_KEY . "playlist_select";
    ?>
">
            <?php 
    foreach ($playlists as $playlist_list) {
        ?>
            <option value="<?php 
        echo $playlist_list->ID;
        ?>
" <?php 
        selected($playlist_list->ID, $current_playlist);
        ?>
>
              <?php 
        echo $playlist_list->post_title;
        ?>
            </option>
            <?php 
    }
    ?>
          </select>
          <input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
          <input type="hidden" name="type" value="<?php 
    echo esc_attr($GLOBALS['type']);
    ?>
" />
          <input type="hidden" name="tab" value="<?php 
    echo esc_attr($GLOBALS['tab']);
    ?>
" />
        </div>
      </div>

      <div class="clear"></div>

      <p class="ml-submit" style="padding: 0 0; margin: 1em;">
        <label for="<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
"><strong><?php 
    _e("Select Player:", 'jw-player-plugin-for-wordpress');
    ?>
</strong></label>
        <select name="<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
" id="<?php 
    echo LONGTAIL_KEY . "player_select";
    ?>
">
          <option value="Default">Default</option>
          <?php 
    $configs = LongTailFramework::getConfigs();
    ?>
          <?php 
    if ($configs) {
        ?>
          <?php 
        foreach ($configs as $config) {
            ?>
            <?php 
            if ($config != "New Player") {
                ?>
              <option value="<?php 
                echo $config;
                ?>
"><?php 
                echo $config;
                ?>
</option>
              <?php 
            }
            ?>
            <?php 
        }
        ?>
          <?php 
    }
    ?>
        </select>
        <input type="button" class="button-primary" onmousedown="insertPlaylist();" name="insert-gallery" id="insert-gallery" value="<?php 
    esc_attr_e('Insert Playlist', 'jw-player-plugin-for-wordpress');
    ?>
" />
      </p>
    </div>
  </div>
</form>
<?php 
}
    /**
     * Displays the buttons at the bottom of a Wizard page.  Available buttons
     * can be controlled through parameter options.
     * @param string $id The id of the current state.
     * @param boolean $show_previous Show the previous button.
     * @param boolean $show_next Show the next button.
     * @param boolean $show_save Show the save button.
     * @param boolean $show_cancel Show the cancel button.
     */
    protected function buttonBar($id, $show_previous = true, $show_next = true, $show_save = true, $show_cancel = true)
    {
        ?>
    <p align="right" class="submit">
      <?php 
        foreach ($_POST as $key => $val) {
            ?>
        <?php 
            if (strstr($key, LONGTAIL_KEY) && !strstr($key, "state") && !strstr($key, "config") && !strstr($key, "new_player")) {
                ?>
          <input type="hidden" name="<?php 
                echo $key;
                ?>
" value="<?php 
                echo $val;
                ?>
" />
        <?php 
            }
            ?>
      <?php 
        }
        ?>
      <input type="hidden" name="<?php 
        echo LONGTAIL_KEY . "state";
        ?>
" value="<?php 
        echo $id;
        ?>
" />
      <input type="hidden" id="<?php 
        echo LONGTAIL_KEY . "config";
        ?>
" name="<?php 
        echo LONGTAIL_KEY . "config";
        ?>
" value="<?php 
        echo $this->current_player;
        ?>
" />
      <?php 
        if ($show_save) {
            ?>
        <script type="text/javascript">
          function saveHandler(button) {
            var configs = eval('(' + '<?php 
            echo json_encode(LongTailFramework::getConfigs());
            ?>
' + ')');
            var newVal = document.getElementById("<?php 
            echo LONGTAIL_KEY . "new_player";
            ?>
");
            var configVal = document.getElementById("<?php 
            echo LONGTAIL_KEY . "config";
            ?>
");
            if (configVal != null && newVal != null && configVal.value == newVal.value) {
              return true;
            }
            for (var config in configs) {
              if (newVal.value == configs[config]) {
                return confirm("A player with this name already exists and will be overwritten.  Would you like to continue?");
              }
            }
            return true;
          }
        </script>
        <input align="left" class="button-primary" type="submit" name="Save" value="Save" onclick="return saveHandler(this);"/>
      <?php 
        }
        ?>
      <?php 
        if ($show_previous) {
            ?>
<input type="submit" name="Previous" value="Previous" /><?php 
        }
        ?>
      <?php 
        if ($show_cancel) {
            ?>
<input align="right" type="submit" name="Cancel" value="Cancel" /><?php 
        }
        ?>
      <?php 
        if ($show_next) {
            ?>
<input align="right" type="submit" name="Next" value="Next" /><?php 
        }
        ?>
    </p><?php 
    }
    /**
     * @see AdminState::render()
     */
    public function render()
    {
        $players = LongTailFramework::getConfigs();
        if (!$players) {
            $this->infoMessage("If you wish to create custom players please make sure the " . JWPLAYER_FILES_DIR . "/configs/" . " directory exists and is writable.  This directory is necessary for creating custom players.  " . JW_FILE_PERMISSIONS);
        }
        ?>
    <div class="wrap">

      <script type="text/javascript">

        function updateHandler(button) {
          button.form.submit();
        }

        function selectionHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
        }

        function copyHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", "") + "_copy");
        }

        function deleteHandler(button) {
          var result = confirm("Are you sure wish to delete the Player?");
          if (result) {
            selectionHandler(button);
            return true;
          }
          return false;
        }

      </script>

      <h2>JW Player Setup</h2>
      <p><span><?php 
        echo JW_SETUP_DESC;
        ?>
</span><p>
      <?php 
        if (file_exists(LongTailFramework::getPrimaryPlayerPath())) {
            ?>
        <form name="<?php 
            echo LONGTAIL_KEY . "upgrade_form";
            ?>
" method="post" action="admin.php?page=jwplayer-update">
          <?php 
            $version = get_option(LONGTAIL_KEY . "version");
            ?>
          <?php 
            $alternate = get_option(LONGTAIL_KEY . "player_location_enable");
            ?>
          <?php 
            $location = get_option(LONGTAIL_KEY . "player_location");
            ?>
            <div id="poststuff">
              <div id="post-body">
                <div id="post-body-content">
                  <div class="stuffbox">
                    <h3 class="hndle"><span>JW Player Version</span></h3>
                    <div class="inside" style="margin: 15px;">
                      <table>
                        <tr valign="top">
                          <td>
                            <div>
                            <?php 
            if (isset($version) && !empty($version) && !$alternate) {
                ?>
                              <p><span><?php 
                echo "<strong>Current Player:</strong> JW Player " . $version;
                ?>
</span></p>
                              <?php 
                if (!strstr($version, "Licensed")) {
                    ?>
                                <p><span><?php 
                    echo JW_LICENSED;
                    ?>
</span></p>
                                <p><input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Upgrade" /></p>
                              <?php 
                }
                ?>
                            <?php 
            } else {
                if ($alternate) {
                    ?>
                              <p><span><?php 
                    echo "<strong>Current Player:</strong> Version Unknown";
                    ?>
</span></p>
                              <p><span>The player is being loaded from an alternate location (<strong><?php 
                    echo $location;
                    ?>
</strong>) and is not being managed by the plugin.</span></p>
                            <?php 
                } else {
                    ?>
                              <p><span><?php 
                    echo "<strong>Current Player:</strong> Version Unknown";
                    ?>
</span></p>
                              <p><input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Reinstall" /></p>
                            <?php 
                }
            }
            ?>
                          </div>
                        </td>
                      </tr>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </form>
      <?php 
        } else {
            if (file_exists(LongTailFramework::getSecondaryPlayerPath())) {
                ?>
        <form name="<?php 
                echo LONGTAIL_KEY . "upgrade_form";
                ?>
" method="post" action="admin.php?page=jwplayer-update">
          <span><?php 
                echo "<strong>Current Player:</strong> Version Unknown ";
                ?>
</span>
          <input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Reinstall" />
        </form>
      <?php 
            }
        }
        ?>
      <form name="<?php 
        echo LONGTAIL_KEY . "form";
        ?>
" method="post" action="">
      <div id="poststuff">
        <div id="post-body">
          <div id="post-body-content">
            <div class="stuffbox">
              <h3 class="hndle"><span>Manage Players</span></h3>
              <div class="inside" style="margin: 15px;">
                <table style="width: 100%;">
                  <tr valign="top">
                    <td>
                      <div>
                        <p><span><?php 
        echo JW_SETUP_EDIT_PLAYERS;
        ?>
</span></p>
                          <table class="widefat" cellspacing="0">
                            <thead>
                              <tr>
                                <th class="manage-column column-name" style="text-shadow: none;">Default</th>
                                <th class="manage-column column-name">Players</th>
                                <th class="manage-column column-name">Control Bar</th>
                                <th class="manage-column column-name">Skin</th>
                                <th class="manage-column column-name">Dock</th>
                                <th class="manage-column column-name">Autostart</th>
                                <th class="manage-column column-name">Height</th>
                                <th class="manage-column column-name">Width</th>
                                <th class="manage-column column-name" style="text-shadow: none;">Actions</th>
                              </tr>
                            </thead>
                            <tbody>
                              <tr>
                                <td style="vertical-align: middle">
                                  <input onchange="updateHandler(this);" type="radio" id="<?php 
        echo LONGTAIL_KEY . "default_Out-of-the-Box";
        ?>
" name="<?php 
        echo LONGTAIL_KEY . "default";
        ?>
" value="Out-of-the-Box" <?php 
        checked("Out-of-the-Box", get_option(LONGTAIL_KEY . "default"));
        ?>
/>
                                </td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "Out-of-the-Box";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "bottom";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "default";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "300";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "400";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><input class="button-secondary action" id="<?php 
        echo LONGTAIL_KEY . "player_Out-of-the-Box";
        ?>
" type="submit" name="Next" value="Copy" onclick="copyHandler(this)"/></td>
                              </tr>
                              <?php 
        $alternate = false;
        ?>
                              <?php 
        if ($players) {
            ?>
                                <?php 
            foreach ($players as $player) {
                ?>
                                  <?php 
                if ($player != "New Player") {
                    ?>
                                    <?php 
                    $alternate = !$alternate;
                    ?>
                                    <?php 
                    LongTailFramework::setConfig($player);
                    ?>
                                    <?php 
                    $details = LongTailFramework::getPlayerFlashVars(LongTailFramework::BASIC);
                    ?>
                                    <tr <?php 
                    if ($alternate) {
                        echo "class=\"alternate\"";
                    }
                    ?>
 >
                                      <td style="vertical-align: middle;">
                                        <input onchange="updateHandler(this);" type="radio" id="<?php 
                    echo LONGTAIL_KEY . "default_" . $player;
                    ?>
" name="<?php 
                    echo LONGTAIL_KEY . "default";
                    ?>
" value="<?php 
                    echo $player;
                    ?>
" <?php 
                    checked($player, get_option(LONGTAIL_KEY . "default"));
                    ?>
/>
                                      </td>
                                      <td style="vertical-align: middle;"><span><?php 
                    echo $player;
                    ?>
</span></td>
                                      <?php 
                    foreach (array_keys($details) as $detail) {
                        ?>
                                        <?php 
                        foreach ($details[$detail] as $fvar) {
                            ?>
                                          <td style="vertical-align: middle;"><span><?php 
                            echo $fvar->getDefaultValue() ? $fvar->getDefaultValue() : "default";
                            ?>
</span></td>
                                        <?php 
                        }
                        ?>
                                      <?php 
                    }
                    ?>
                                      <td>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Copy" onclick="copyHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Edit" onclick="selectionHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Delete" onclick="return deleteHandler(this)"/>
                                      </td>
                                    </tr>
                                  <?php 
                }
                ?>
                                <?php 
            }
            ?>
                              <?php 
        }
        ?>
                            </tbody>
                          </table>
                          <br/>
                          <input class="button-secondary action" type="submit" name="Next" value="Create Custom Player"/>
                          <input id="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" value=""/>
                          <input id="<?php 
        echo LONGTAIL_KEY . "player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "config";
        ?>
" value=""/>
                          <input type="hidden" name="<?php 
        echo LONGTAIL_KEY . "state";
        ?>
" value=<?php 
        echo PlayerState::getID();
        ?>
 />
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </form>
    </div>
    <?php 
    }
Beispiel #9
0
 /**
  * Processes the POST data from the previous state.
  * @param AdminState $st The next state to be populated with the POST data
  * from the previous state.
  * @param $form
  * @param $form_state
  *
  */
 private function processPost($st, &$form, &$form_state)
 {
     $state = $st;
     if (isset($_POST["Next"])) {
         if ($_POST["Next"] == "Delete") {
             LongTailFramework::setConfig($form_state["storage"][LONGTAIL_KEY . "config"]);
             LongTailFramework::deleteConfig();
             $configs = LongTailFramework::getConfigs();
             if ($configs && count($configs) >= 2 && $_POST[LONGTAIL_KEY . "config"] == variable_get($form_state["storage"][LONGTAIL_KEY . "default"], "")) {
                 variable_set(LONGTAIL_KEY . "default", $configs[1]);
             } else {
                 if (!$configs || count($configs) == 1) {
                     variable_set(LONGTAIL_KEY . "default", "Out-of-the-Box");
                 }
             }
             $state = new PlayerState($form_state["storage"][LONGTAIL_KEY . "config"]);
             $del_player = $form_state["storage"][LONGTAIL_KEY . "config"];
             drupal_set_message("The '{$del_player}' Player was successfully deleted.");
             $state->render($form, $form_state);
         } else {
             if ($_POST["Next"] == "Create Custom Player") {
                 $form_state["storage"][LONGTAIL_KEY . "new_player"] = "Custom Player";
             }
             $state->getNextState()->render($form, $form_state);
         }
     } else {
         if (isset($_POST["Previous"])) {
             $state->getPreviousState()->render($form, $form_state);
         } else {
             if (isset($_POST["Cancel"])) {
                 unset($form_state["storage"]);
                 $state->getCancelState()->render($form, $form_state);
             } else {
                 if (isset($_POST["Save"]) && isset($form_state["storage"])) {
                     $config = $form_state["storage"][LONGTAIL_KEY . "config"];
                     $save_player = $form_state["storage"][LONGTAIL_KEY . "new_player"] ? $form_state["storage"][LONGTAIL_KEY . "new_player"] : $config;
                     LongTailFramework::setConfig($config);
                     $save_values = $this->processSubmit($form_state);
                     $success = LongTailFramework::saveConfig($this->convertToXML($save_values), check_plain($save_player));
                     $configs = LongTailFramework::getConfigs();
                     if ($configs && count($configs) == 2) {
                         variable_set(LONGTAIL_KEY . "ootb", false);
                     }
                     if ($success) {
                         drupal_set_message(t("The '{$save_player}' Player was successfully saved."));
                     } else {
                         drupal_set_message(t("The '{$save_player}' failed to save.  Please make sure the " . JWPLAYER_FILES_DIR . "/configs/ directory exists and is writable."), "error");
                     }
                     unset($form_state["storage"]);
                     $state->getSaveState()->render($form, $form_state);
                 } else {
                     if (isset($form_state["storage"][LONGTAIL_KEY . "default"])) {
                         variable_set(LONGTAIL_KEY . "default", $form_state["storage"][LONGTAIL_KEY . "default"]);
                     }
                     LongTailFramework::setConfig($form_state["storage"][LONGTAIL_KEY . "config"]);
                     $state->render($form, $form_state);
                 }
             }
         }
     }
 }
Beispiel #10
0
    /**
     * @see AdminState::render()
     */
    public function render()
    {
        $players = LongTailFramework::getConfigs();
        if (!$players) {
            $this->infoMessage(sprintf(__("If you wish to create custom players please make sure the %s/configs/" . " directory exists and is writable.  This directory is necessary for creating custom players.  ", 'jw-player-plugin-for-wordpress') . JW_FILE_PERMISSIONS, JWPLAYER_FILES_DIR));
        }
        ?>
    <div class="wrap">

      <script type="text/javascript">

        function updateHandler(button) {
          button.form.submit();
        }

        function selectionHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
        }

        function copyHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", "") + "_copy");
        }

        function deleteHandler(button) {
          var result = confirm(__("Are you sure wish to delete the Player?", 'jw-player-plugin-for-wordpress'));
          if (result) {
            selectionHandler(button);
            return true;
          }
          return false;
        }

      </script>

      <h2>JW Player Setup</h2>
      <p><span><?php 
        echo JW_SETUP_EDIT_PLAYERS;
        ?>
</span><p>
      <?php 
        /* Please upgrade to JWP6! if (file_exists(LongTailFramework::getPrimaryPlayerPath())) { ?>
             <form name="<?php echo LONGTAIL_KEY . "upgrade_form" ?>" method="post" action="admin.php?page=jwplayer-update">
               <?php $version = get_option(LONGTAIL_KEY . "version"); ?>
               <?php $alternate = get_option(LONGTAIL_KEY . "player_location_enable"); ?>
               <?php $location = get_option(LONGTAIL_KEY . "player_location"); ?>
               <?php $jwPlayer = file_exists(LongTailFramework::getPlayerPath()); ?>
               <?php $jwEmbedder = file_exists(LongTailFramework::getEmbedderPath()); ?>
                 <div id="poststuff">
                   <div id="post-body">
                     <div id="post-body-content">
                       <div class="stuffbox">
                         <h3 class="hndle"><span><?php _e("JW Player Status", 'jw-player-plugin-for-wordpress'); ?></span></h3>
                         <div class="inside" style="margin: 15px;">
                           <table>
                             <tr valign="top">
                               <td>
                                 <div>
                                 <?php if (!$alternate) { ?>
                                   <p>
                                     <span><strong>JW Player:</strong> <?php echo $jwPlayer ? __("Installed", 'jw-player-plugin-for-wordpress') : __("Not detected", 'jw-player-plugin-for-wordpress'); echo $version && $jwPlayer ? " (JW Player $version)" : ""; ?></span>
                                   </p>
                                   <p><span><strong>JW Embedder:</strong></span> <?php echo $jwEmbedder ? __("Installed", 'jw-player-plugin-for-wordpress') : __("Not detected (SWFObject will be used instead)", 'jw-player-plugin-for-wordpress'); ?></p>
                                   <?php if (!strstr($version, "Licensed")) { ?>
                                     <p><span><strong><?php _e("Please Note:", 'jw-player-plugin-for-wordpress');?></strong> <?php _e("The JW Player Plugin for WordPress does not yet support JW Player 6.  We are working quickly to update the plugin over the next few weeks. By early 2013, you will be able to use WordPress with JW Player 6.  For now, we recommend sticking with JW Player 5. Please stay tuned!", 'jw-player-plugin-for-wordpress'); ?></span></p>
                                     <p><strong><?php _e("Supported Versions:", 'jw-player-plugin-for-wordpress'); ?></strong></p>
                                     <table style="border: 1px solid gray;">
                                       <tr>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.0</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.1</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.2</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.3</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.4</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.5</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.6</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.7</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.8</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.9</td>
                                         <td style="border: 1px solid gray; width: 30px; text-align: center">5.10</td>
                                       </tr>
                                     </table>
                                     <p><em><?php _e("If you have already purchased a commercial upgrade for JW6, we can either process a refund, or you can keep your commercial license until the plugin is updated.  We apologize for the inconvenience.");?></em></p>
                                   <?php } ?>
                                 <?php } else if ($alternate) { ?>
                                   <p><span><?php echo "<strong>" . __("Current Player", 'jw-player-plugin-for-wordpress') . ":</strong> " . __("Version Unknown", 'jw-player-plugin-for-wordpress'); ?></span></p>
                                   <p><span><?php printf(__("The player is being loaded from an alternate location (<strong>%s</strong>) and is not being managed by the plugin.", 'jw-player-plugin-for-wordpress'), $location); ?></span></p>
                                 <?php } else { ?>
                                   <p><span><?php _e("<strong>Current Player:</strong> Version Unknown", 'jw-player-plugin-for-wordpress'); ?></span></p>
                                   <p><input class="button-secondary" type="submit" name="Update_Player" value="<?php _e("Click Here to Reinstall", 'jw-player-plugin-for-wordpress'); ?>" /></p>
                                 <?php } ?>
                               </div>
                             </td>
                           </tr>
                         </table>
                       </div>
                     </div>
                   </div>
                 </div>
               </div>
             </form>
           <?php } else if (file_exists(LongTailFramework::getSecondaryPlayerPath())) { ?>
             <form name="<?php echo LONGTAIL_KEY . "upgrade_form" ?>" method="post" action="admin.php?page=jwplayer-update">
               <span><?php _e("<strong>Current Player:</strong> Version Unknown ", 'jw-player-plugin-for-wordpress'); ?></span>
               <input class="button-secondary" type="submit" name="Update_Player" value="<?php _e("Click Here to Reinstall", 'jw-player-plugin-for-wordpress'); ?>" />
             </form>
           <?php } */
        ?>
      <form name="<?php 
        echo LONGTAIL_KEY . "form";
        ?>
" method="post" action="">
      <div id="poststuff">
        <div id="post-body">
          <div id="post-body-content">
            <div class="stuffbox">
              <h3 class="hndle"><span>Manage Players</span></h3>
              <div class="inside" style="margin: 15px;">
                <table style="width: 100%;">
                  <tr valign="top">
                    <td>
                      <div>
                          <table class="widefat" cellspacing="0">
                            <thead>
                              <tr>
                                <th class="manage-column column-name" style="text-shadow: none;">Default</th>
                                <th class="manage-column column-name">Players</th>
                                <th class="manage-column column-name">Control Bar</th>
                                <th class="manage-column column-name">Skin</th>
                                <th class="manage-column column-name">Dock</th>
                                <th class="manage-column column-name">Autostart</th>
                                <th class="manage-column column-name">Height</th>
                                <th class="manage-column column-name">Width</th>
                                <th class="manage-column column-name" style="text-shadow: none;">Actions</th>
                              </tr>
                            </thead>
                            <tbody>
                              <tr>
                                <td style="vertical-align: middle">
                                  <input onchange="updateHandler(this);" type="radio" id="<?php 
        echo LONGTAIL_KEY . "default_Out-of-the-Box";
        ?>
" name="<?php 
        echo LONGTAIL_KEY . "default";
        ?>
" value="<?php 
        _e("Out-of-the-Box", 'jw-player-plugin-for-wordpress');
        ?>
 <?php 
        checked("Out-of-the-Box", get_option(LONGTAIL_KEY . "default"));
        ?>
"/>
                                </td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "Out-of-the-Box";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "bottom";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "default";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "300";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "400";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><input class="button-secondary action" id="<?php 
        echo LONGTAIL_KEY . "player_Out-of-the-Box";
        ?>
" type="submit" name="Next" value="<?php 
        _e("Copy", 'jw-player-plugin-for-wordpress');
        ?>
" onclick="copyHandler(this)"/></td>
                              </tr>
                              <?php 
        $alternate = false;
        ?>
                              <?php 
        if ($players) {
            ?>
                                <?php 
            foreach ($players as $player) {
                ?>
                                  <?php 
                if ($player != __("New Player", 'jw-player-plugin-for-wordpress')) {
                    ?>
                                    <?php 
                    $alternate = !$alternate;
                    ?>
                                    <?php 
                    LongTailFramework::setConfig($player);
                    ?>
                                    <?php 
                    $details = LongTailFramework::getPlayerFlashVars(LongTailFramework::BASIC);
                    ?>
                                    <tr <?php 
                    if ($alternate) {
                        echo "class=\"alternate\"";
                    }
                    ?>
 >
                                      <td style="vertical-align: middle;">
                                        <input onchange="updateHandler(this);" type="radio" id="<?php 
                    echo LONGTAIL_KEY . "default_" . $player;
                    ?>
" name="<?php 
                    echo LONGTAIL_KEY . "default";
                    ?>
" value="<?php 
                    echo $player;
                    ?>
" <?php 
                    checked($player, get_option(LONGTAIL_KEY . "default"));
                    ?>
/>
                                      </td>
                                      <td style="vertical-align: middle;"><span><?php 
                    echo $player;
                    ?>
</span></td>
                                      <?php 
                    foreach (array_keys($details) as $detail) {
                        ?>
                                        <?php 
                        foreach ($details[$detail] as $fvar) {
                            ?>
                                          <td style="vertical-align: middle;"><span><?php 
                            echo $fvar->getDefaultValue() ? $fvar->getDefaultValue() : "default";
                            ?>
</span></td>
                                        <?php 
                        }
                        ?>
                                      <?php 
                    }
                    ?>
                                      <td>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="<?php 
                    _e("Copy", 'jw-player-plugin-for-wordpress');
                    ?>
" onclick="copyHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="<?php 
                    _e("Edit", 'jw-player-plugin-for-wordpress');
                    ?>
" onclick="selectionHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="<?php 
                    _e("Delete", 'jw-player-plugin-for-wordpress');
                    ?>
" onclick="return deleteHandler(this)"/>
                                      </td>
                                    </tr>
                                  <?php 
                }
                ?>
                                <?php 
            }
            ?>
                              <?php 
        }
        ?>
                            </tbody>
                          </table>
                          <br/>
                          <input class="button-secondary action" type="submit" name="Next" value="<?php 
        _e("Create Custom Player", 'jw-player-plugin-for-wordpress');
        ?>
"/>
                          <input id="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" value=""/>
                          <input id="<?php 
        echo LONGTAIL_KEY . "player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "config";
        ?>
" value=""/>
                          <input type="hidden" name="<?php 
        echo LONGTAIL_KEY . "state";
        ?>
" value=<?php 
        echo PlayerState::getID();
        ?>
 />
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </form>
    </div>
    <?php 
    }
Beispiel #11
0
 private function renderPlayers(&$form)
 {
     $players = LongTailFramework::getConfigs();
     $count = 1;
     foreach ($players as $player) {
         if ($player != "New Player") {
             LongTailFramework::setConfig($player);
             $details = LongTailFramework::getPlayerFlashVars(LongTailFramework::BASIC);
             $form["Manage"]["Players"][$player] = array();
             $form["Manage"]["Players"][$player][LONGTAIL_KEY . "default"] = array("#type" => "radio", "#name" => LONGTAIL_KEY . "default", "#return_value" => $player, "#default_value" => variable_get(LONGTAIL_KEY . "default", "Out-of-the-Box"), "#ahah" => array("path" => "admin/settings/jwplayermodule/default/js", "wrapper" => "version-wrapper", "event" => "change"));
             $form["Manage"]["Players"][$player]["name"] = array("#type" => "item", "#value" => $player);
             foreach (array_keys($details) as $detail) {
                 foreach ($details[$detail] as $fvar) {
                     $form["Manage"]["Players"][$player][$fvar->getName()] = array("#type" => "item", "#value" => $fvar->getDefaultValue() ? $fvar->getDefaultValue() : "default");
                 }
             }
             $form["Manage"]["Players"][$player]["actions"] = array();
             $form["Manage"]["Players"][$player]["actions"]["copy"] = array("#type" => "submit", "#id" => LONGTAIL_KEY . "player_{$player}", "#value" => "Copy", "#name" => "Next", "#attributes" => array("onclick" => "copyHandler(this)"));
             $form["Manage"]["Players"][$player]["actions"]["edit"] = array("#type" => "submit", "#id" => LONGTAIL_KEY . "player_{$player}", "#value" => "Edit", "#name" => "Next", "#attributes" => array("onclick" => "selectionHandler(this)"));
             $form["Manage"]["Players"][$player]["actions"]["delete"] = array("#type" => "submit", "#id" => LONGTAIL_KEY . "player_{$player}", "#value" => "Delete", "#name" => "Next", "#attributes" => array("onclick" => "deleteHandler(this)"));
         }
         $count++;
     }
 }
    /**
     * @see AdminState::render()
     */
    public function render()
    {
        $players = LongTailFramework::getConfigs();
        if (!$players) {
            $this->infoMessage("If you wish to create custom players please make sure the uploads/jw-player-plugin-for-wordpress/configs directory exists and is writable.  This directory is necessary for creating custom players.  " . JW_FILE_PERMISSIONS);
        }
        ?>
    <div class="wrap">

      <script type="text/javascript">

        function updateHandler(button) {
          button.form.submit();
        }

        function selectionHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
        }

        function copyHandler(button) {
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", ""));
          var field = document.getElementById("<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
");
          field.setAttribute("value", button.id.replace("<?php 
        echo LONGTAIL_KEY . "player_";
        ?>
", "") + "_copy");
        }

        function deleteHandler(button) {
          var result = confirm("Are you sure wish to delete the Player?");
          if (result) {
            selectionHandler(button);
            return true;
          }
          return false;
        }

      </script>

      <h2>JW Player Setup</h2>
      <p><span><?php 
        echo JW_SETUP_DESC;
        ?>
</span><p>
      <?php 
        if (file_exists(LongTailFramework::getPrimaryPlayerPath())) {
            ?>
        <form name="<?php 
            echo LONGTAIL_KEY . "upgrade_form";
            ?>
" method="post" action="admin.php?page=jwplayer-update">
          <?php 
            $version = get_option(LONGTAIL_KEY . "version");
            ?>
          <?php 
            if (isset($version) && !empty($version)) {
                ?>
            <div id="poststuff">
              <div id="post-body">
                <div id="post-body-content">
                  <div class="stuffbox">
                    <h3 class="hndle"><span>JW Player Version</span></h3>
                    <div class="inside" style="margin: 15px;">
                      <table>
                        <tr valign="top">
                          <td>
                            <div>
                              <p><span><?php 
                echo "<strong>Current Player:</strong> JW Player " . $version;
                ?>
</span></p>
                              <?php 
                if (!strstr($version, "Licensed")) {
                    ?>
                                <p><span><?php 
                    echo JW_LICENSED;
                    ?>
</span></p>
                                <p><input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Upgrade" /></p>
                              <?php 
                }
                ?>
                            </div>
                          </td>
                        </tr>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          <?php 
            } else {
                ?>
            <span><?php 
                echo "<strong>Current Player:</strong> Version Unknown";
                ?>
</span>
            <input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Reinstall" />
          <?php 
            }
            ?>
        </form>
      <?php 
        } else {
            if (file_exists(LongTailFramework::getSecondaryPlayerPath())) {
                ?>
        <form name="<?php 
                echo LONGTAIL_KEY . "upgrade_form";
                ?>
" method="post" action="admin.php?page=jwplayer-update">
          <span><?php 
                echo "<strong>Current Player:</strong> Version Unknown ";
                ?>
</span>
          <input class="button-secondary" type="submit" name="Update_Player" value="Click Here to Reinstall" />
        </form>
      <?php 
            }
        }
        ?>
      <form name="<?php 
        echo LONGTAIL_KEY . "form";
        ?>
" method="post" action="">
      <div id="poststuff">
        <div id="post-body">
          <div id="post-body-content">
            <div class="stuffbox">
              <h3 class="hndle"><span>Manage Players</span></h3>
              <div class="inside" style="margin: 15px;">
                <table style="width: 100%;">
                  <tr valign="top">
                    <td>
                      <div>
                        <p><span><?php 
        echo JW_SETUP_EDIT_PLAYERS;
        ?>
</span></p>
                          <table class="widefat" cellspacing="0">
                            <thead>
                              <tr>
                                <th class="manage-column column-name">Default</th>
                                <th class="manage-column column-name">Players</th>
                                <th class="manage-column column-name">Control Bar</th>
                                <th class="manage-column column-name">Skin</th>
                                <th class="manage-column column-name">Dock</th>
                                <th class="manage-column column-name">Autostart</th>
                                <th class="manage-column column-name">Height</th>
                                <th class="manage-column column-name">Width</th>
                                <th class="manage-column column-name">Actions</th>
                              </tr>
                            </thead>
                            <tbody>
                              <tr>
                                <td style="vertical-align: middle">
                                  <input onchange="updateHandler(this);" type="radio" id="<?php 
        echo LONGTAIL_KEY . "default_Out-of-the-Box";
        ?>
" name="<?php 
        echo LONGTAIL_KEY . "default";
        ?>
" value="Out-of-the-Box" <?php 
        checked("Out-of-the-Box", get_option(LONGTAIL_KEY . "default"));
        ?>
/>
                                </td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "Out-of-the-Box";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "bottom";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "default";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "false";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "300";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><span><?php 
        echo "400";
        ?>
</span></td>
                                <td style="vertical-align: middle;"><input class="button-secondary action" id="<?php 
        echo LONGTAIL_KEY . "player_Out-of-the-Box";
        ?>
" type="submit" name="Next" value="Copy" onclick="copyHandler(this)"/></td>
                              </tr>
                              <?php 
        $alternate = false;
        ?>
                              <?php 
        if ($players) {
            ?>
                                <?php 
            foreach ($players as $player) {
                ?>
                                  <?php 
                if ($player != "New Player") {
                    ?>
                                    <?php 
                    $alternate = !$alternate;
                    ?>
                                    <?php 
                    LongTailFramework::setConfig($player);
                    ?>
                                    <?php 
                    $details = LongTailFramework::getPlayerFlashVars(LongTailFramework::BASIC);
                    ?>
                                    <tr <?php 
                    if ($alternate) {
                        echo "class=\"alternate\"";
                    }
                    ?>
 >
                                      <td style="vertical-align: middle;">
                                        <input onchange="updateHandler(this);" type="radio" id="<?php 
                    echo LONGTAIL_KEY . "default_" . $player;
                    ?>
" name="<?php 
                    echo LONGTAIL_KEY . "default";
                    ?>
" value="<?php 
                    echo $player;
                    ?>
" <?php 
                    checked($player, get_option(LONGTAIL_KEY . "default"));
                    ?>
/>
                                      </td>
                                      <td style="vertical-align: middle;"><span><?php 
                    echo $player;
                    ?>
</span></td>
                                      <?php 
                    foreach (array_keys($details) as $detail) {
                        ?>
                                        <?php 
                        foreach ($details[$detail] as $fvar) {
                            ?>
                                          <td style="vertical-align: middle;"><span><?php 
                            echo $fvar->getDefaultValue() ? $fvar->getDefaultValue() : "default";
                            ?>
</span></td>
                                        <?php 
                        }
                        ?>
                                      <?php 
                    }
                    ?>
                                      <td>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Copy" onclick="copyHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Edit" onclick="selectionHandler(this)"/>
                                        <input class="button-secondary action" id="<?php 
                    echo LONGTAIL_KEY . "player_" . $player;
                    ?>
" type="submit" name="Next" value="Delete" onclick="return deleteHandler(this)"/>
                                      </td>
                                    </tr>
                                  <?php 
                }
                ?>
                                <?php 
            }
            ?>
                              <?php 
        }
        ?>
                            </tbody>
                          </table>
                          <br/>
                          <input class="button-secondary action" type="submit" name="Next" value="Create Custom Player"/>
                          <div style="display: inline-block; float: right;">
                            <label for="<?php 
        echo LONGTAIL_KEY . "show_archive";
        ?>
">Show players on category and search pages</label>
                            <input id="<?php 
        echo LONGTAIL_KEY . "show_archive";
        ?>
" type="checkbox" name="<?php 
        echo LONGTAIL_KEY . "show_archive";
        ?>
" onclick="form.submit();" <?php 
        checked(true, get_option(LONGTAIL_KEY . "show_archive"));
        ?>
/>
                          </div>
                          <input id="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "new_player";
        ?>
" value=""/>
                          <input id="<?php 
        echo LONGTAIL_KEY . "player";
        ?>
" type="hidden" name="<?php 
        echo LONGTAIL_KEY . "config";
        ?>
" value=""/>
                          <input type="hidden" name="<?php 
        echo LONGTAIL_KEY . "state";
        ?>
" value=<?php 
        echo PlayerState::getID();
        ?>
 />
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div id="poststuff">
          <div id="post-body">
            <div id="post-body-content">
              <div class="stuffbox">
                <h3 class="hndle"><span>JW Player Plugin for WordPress Uninstall</span></h3>
                <div class="inside" style="margin: 15px;">
                  <table>
                    <tr valign="top">
                      <td>
                        <div>
                          <p><?php 
        _e('To fully remove the plugin, click the Uninstall button.  Deactivating without uninstalling will not remove the data created by the plugin.');
        ?>
</p>
                        </div>
                        <p><font color="red"><strong><?php 
        _e('WARNING:');
        ?>
</strong><br />
                        <?php 
        _e('This cannot be undone.  Since this is deleting data from your database, it is recommended that you create a backup.');
        ?>
</font></p>
                        <div align="left">
                          <input type="submit" name="Uninstall" class="button-secondary delete" value="<?php 
        _e('Uninstall plugin');
        ?>
" onclick="return confirm('<?php 
        _e('You are about to Uninstall this plugin from WordPress.\\nThis action is not reversible.\\n\\nChoose [Cancel] to Stop, [OK] to Uninstall.\\n');
        ?>
');"/>
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </form>
    </div>
    <?php 
    }