function uninstall() { global $wpdb; $meta_query = "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '" . LONGTAIL_KEY . "%';"; $option_query = "DELETE FROM {$wpdb->options} WHERE option_name LIKE '" . LONGTAIL_KEY . "%';"; $post_query = "DELETE FROM {$wpdb->posts} WHERE post_type = 'jw_playlist';"; $wpdb->query($meta_query); $wpdb->query($option_query); $wpdb->query($post_query); @unlink(LongTailFramework::getPlayerPath()); @unlink(LongTailFramework::getEmbedderPath()); @rmdir(JWPLAYER_FILES_DIR . "/player/"); $handler = @opendir(JWPLAYER_FILES_DIR . "/configs"); if ($handler) { while ($file = readdir($handler)) { if ($file != "." && $file != ".." && strstr($file, ".xml")) { @unlink(JWPLAYER_FILES_DIR . "/configs/{$file}"); } } closedir($handler); } @rmdir(JWPLAYER_FILES_DIR . "/configs/"); @rmdir(JWPLAYER_FILES_DIR); update_option(LONGTAIL_KEY . "uninstalled", true); feedback_message(__('Files and settings deleted. The plugin can now be deactivated.', 'jw-player-plugin-for-wordpress')); }
/** * @see AdminState::render() * @param $form * @param $form_state */ public function render(&$form, $form_state) { $flash_vars = LongTailFramework::getPlayerFlashVars($this->flashVarCat()); parent::getBreadcrumbBar($form, $form_state); $this->selectedPlayer($form, $form_state); $this->getHeader(); foreach (array_keys($flash_vars) as $groups) { $form[$groups] = array("#type" => "fieldset", "#title" => $groups); foreach ($flash_vars[$groups] as $fvar) { $name = LONGTAIL_KEY . "player_" . $fvar->getName(); $value = $form_state["storage"][$name] ? $form_state["storage"][$name] : $fvar->getDefaultValue(); $form[$groups][$name] = array("#title" => $fvar->getName(), "#description" => $fvar->getDescription(), "#default_value" => $value); if ($fvar->getType() == FlashVar::SELECT) { $form[$groups][$name]["#type"] = "select"; $options = array(); foreach ($fvar->getValues() as $val) { $options[$val] = $val; } $form[$groups][$name]["#options"] = $options; } else { $form[$groups][$name]["#type"] = "textfield"; } } } $this->getFooter($form, $form_state); $this->getButtonBar($form, false); }
/** * @see AdminState::render() * @param $form * @param $form_state */ public function render(&$form, $form_state) { $ltas = LongTailFramework::getLTASConfig(); parent::getBreadcrumbBar($form, $form_state); $this->selectedPlayer($form, $form_state); $form["LTAS"] = array("#type" => "fieldset", "#title" => t("LongTail AdSolution Settings")); $value = $form_state["storage"][LONGTAIL_KEY . "plugin_ltas_enable"] ? $form_state["storage"][LONGTAIL_KEY . "plugin_ltas_enable"] : $ltas["enabled"]; $form["LTAS"][LONGTAIL_KEY . "plugin_ltas_enable"] = array("#type" => "checkbox", "#name" => LONGTAIL_KEY . "plugin_ltas_enable", "#title" => t("Enable LongTail AdSolution"), "#default_value" => $value); $form["LTAS"]["description"] = array("#type" => "item", "#description" => JW_PLAYER_LTAS_DESC); $value = $_POST[LONGTAIL_KEY . "plugin_ltas_cc"] ? $_POST[LONGTAIL_KEY . "plugin_ltas_cc"] : $ltas["channel_code"]; $form["LTAS"][LONGTAIL_KEY . "plugin_ltas_cc"] = array("#type" => "textfield", "#name" => LONGTAIL_KEY . "plugin_ltas_cc", "#title" => t("ltas.cc"), "#default_value" => $value, "#description" => "Your LTAS channel code. Obtained from the <a href=https://dashboard.longtailvideo.com/" . JW_PLAYER_GA_VARS . " target=_blank>AdSolution Dashboard.</a>"); $this->buttonBar($form, LTASState::getID()); }
/** * @see AdminState::render() * @param $form * @param $form_state */ public function render(&$form, $form_state) { $plugins = LongTailFramework::getPlugins(); parent::getBreadcrumbBar($form, $form_state); $this->selectedPlayer($form, $form_state); $id = LONGTAIL_KEY . "plugin_selector"; $form["JWPlugins"] = array("#prefix" => "<div>", "#suffix" => "</div>"); $form["JWPlugins"][$id] = array(); $form["JWPlugins"][$id]["tab"] = array("#id" => "{$id}" . "_tab", "#type" => "item", "#value" => "<a href='#{$id}'>Plugin Selector</a>"); foreach ($plugins as $plugin) { $id = LONGTAIL_KEY . "plugin_" . $plugin->getRepository(); $form["JWPlugins"][$id] = array(); $form["JWPlugins"][$id]["tab"] = array("#id" => "{$id}" . "_tab", "#type" => "item", "#value" => "<a href='#{$id}'>" . $plugin->getTitle() . "</a>"); } $id = LONGTAIL_KEY . "plugin_selector"; $form["JWPlugins"][$id]["body"] = array(); foreach ($plugins as $plugin) { $name = LONGTAIL_KEY . "plugin_" . $plugin->getRepository() . "_" . "enable"; $value = $form_state["storage"][$name] ? $form_state["storage"][$name] : $plugin->isEnabled(); $form["JWPlugins"][$id]["body"][$name] = array("#type" => "checkbox", "#title" => "Enable " . $plugin->getTitle(), "#description" => $plugin->getDescription(), "#name" => $name, "#default_value" => $value); } foreach ($plugins as $plugin) { $id = LONGTAIL_KEY . "plugin_" . $plugin->getRepository(); $form["JWPlugins"][$id]["body"] = array(); foreach (array_keys($plugin->getFlashVars()) as $plugin_flash_vars) { $p_vars = $plugin->getFlashVars(); foreach ($p_vars[$plugin_flash_vars] as $plugin_flash_var) { $name = LONGTAIL_KEY . "plugin_" . $plugin->getPluginPrefix() . "_" . $plugin_flash_var->getName(); $value = $form_state["storage"][$name] ? $form_state["storage"][$name] : $plugin_flash_var->getDefaultValue(); $form["JWPlugins"][$id]["body"][$name] = array("#title" => $plugin->getPluginPrefix() . "." . $plugin_flash_var->getName(), "#description" => $plugin_flash_var->getDescription(), "#default_value" => $value); if ($plugin_flash_var->getType() == FlashVar::SELECT) { $form["JWPlugins"][$id]["body"][$name]["#type"] = "select"; $options = array(); foreach ($plugin_flash_var->getValues() as $val) { $options[$val] = $val; } $form["JWPlugins"][$id]["body"][$name]["#options"] = $options; } else { $form["JWPlugins"][$id]["body"][$name]["#type"] = "textfield"; } } } } drupal_add_js($this->generateScript($plugins), "inline"); $this->buttonBar($form, PluginState::getID(), true, false); }
private function init() { //Set the config flashvar to the Player configuration path if ($this->conf != "") { $this->fvars["config"] = $this->conf; } $events = array(); $modeAttrs = array(); //Populate the values used for the embed process. $this->config["jwplayer"]["files"][$this->id] = array("flashplayer" => $this->path, "width" => $this->dim["width"], "height" => $this->dim["height"], "controlbar" => $this->dim["controlbar"], "wmode" => $this->dim["wmode"]); foreach ($this->fvars as $key => $value) { if (isset(self::$events[$key])) { $events[$key] = urldecode(html_entity_decode($value)); } else { if ($key == "html5_file" || $key == "download_file") { $modeAttrs[$key] = $value; } else { $this->config["jwplayer"]["files"][$this->id][$key] = $value; } } } $this->config["jwplayer"]["files"][$this->id]["events"] = $events; if (!empty($modeAttrs)) { $modes = array(); $mode = new stdClass(); $mode->type = "flash"; $mode->src = LongTailFramework::getPlayerURL(); $modes[] = $mode; foreach ($modeAttrs as $key => $value) { $mode = new stdClass(); $mode->config = new stdClass(); $mode->config->file = $value; $mode->config->streamer = ""; $mode->config->provider = ""; if ($key == "html5_file") { $mode->type = "html5"; } else { $mode->type = "download"; } $modes[] = $mode; } $this->config["jwplayer"]["files"][$this->id]["modes"] = $modes; } }
/** * @see AdminState::render() */ public function render() { $ltas = LongTailFramework::getLTASConfig(); ?> <div class="wrap"> <form name="<?php echo LONGTAIL_KEY . "form"; ?> " method="post" action=""> <?php parent::getBreadcrumbBar(); ?> <?php $this->selectedPlayer(); ?> <p/> <div id="poststuff"> <div id="post-body"> <div id="post-body-content"> <div class="stuffbox"> <h3 class="hndle"><span><?php echo "LongTail AdSolution Settings"; ?> </span></h3> <div class="inside" style="margin: 15px;"> <table class="form-table"> <tr> <?php $value = isset($_POST["jwplayermodule_plugin_ltas_enable"]) ? $_POST["jwplayermodule_plugin_ltas_enable"] : isset($ltas["enabled"]) ? $ltas["enabled"] : false; ?> <?php unset($_POST["jwplayermodule_plugin_ltas_enable"]); ?> <td><input name="jwplayermodule_plugin_ltas_enable" type="checkbox" value="1" <?php checked(true, $value); ?> /> <span>Enable LongTail AdSolution</span> </td> </tr> <tr> <td colspan="2"><span class="description"><?php echo JW_PLAYER_LTAS_DESC; ?> </span></td> </tr> <tr> <?php $value = isset($_POST["jwplayermodule_plugin_ltas_cc"]) ? $_POST["jwplayermodule_plugin_ltas_cc"] : $ltas["channel_code"]; ?> <?php unset($_POST["jwplayermodule_plugin_ltas_cc"]); ?> <th>ltas.cc</th> <td> <input type="text" value="<?php echo $value; ?> " name="jwplayermodule_plugin_ltas_cc" /> <span class="description"><?php echo "Your LTAS channel code. Obtained from the <a href=https://dashboard.longtailvideo.com/" . JW_PLAYER_GA_VARS . " target=_blank>AdSolution Dashboard.</a>"; ?> </span> </td> </tr> </table> </div> </div> </div> </div> </div> <?php $this->buttonBar(LTASState::getID()); ?> </form> </div> <?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 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 }
static function purge_jwp5_settings() { global $wpdb; $meta_query = "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '" . LONGTAIL_KEY . "%';"; $option_query = "DELETE FROM {$wpdb->options} WHERE option_name LIKE '" . LONGTAIL_KEY . "%';"; $post_query = "DELETE FROM {$wpdb->posts} WHERE post_type = 'jw_playlist';"; $wpdb->query($meta_query); $wpdb->query($option_query); $wpdb->query($post_query); require_once dirname(__FILE__) . '/../framework/LongTailFramework.php'; // echo "\nUnlinking: " . LongTailFramework::getPlayerPath(); // echo "\nUnlinking: " . LongTailFramework::getEmbedderPath(); @unlink(LongTailFramework::getPlayerPath()); @unlink(LongTailFramework::getEmbedderPath()); @rmdir(JWPLAYER_FILES_DIR . "/player/"); $uploads = wp_upload_dir(); $jwp5_files_dir = $uploads["basedir"] . "/" . plugin_basename(JWP6_PLUGIN_DIR_NAME); $handler = @opendir($jwp5_files_dir . "/configs"); if ($handler) { while ($file = readdir($handler)) { if ($file != "." && $file != ".." && strstr($file, ".xml")) { // echo "\nUnlinking: " . $jwp5_files_dir . "/configs/$file"; @unlink($jwp5_files_dir . "/configs/{$file}"); } } closedir($handler); } // echo "Deleting: directories."; @rmdir($jwp5_files_dir . "/configs/"); @rmdir($jwp5_files_dir); add_option(JWP6 . 'jwp5_purged', true); return True; }
/** * 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 FlashVarState::getNextState() * @return \AdvancedState */ public function getNextState() { LongTailFramework::setConfig($this->current_player); return new AdvancedState($this->current_player, $this->current_post_values); }
/** * @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 }
function skin_unzip($archive) { if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open($archive)) { $zip->extractTo(LongTailFramework::getSkinPath()); $zip->close(); return true; } } else { require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); $zip = new PclZip($archive); $zip->extract(PCLZIP_OPT_PATH, LongTailFramework::getSkinPath()); return true; } return false; }
chmod(JWPLAYER_FILES_DIR . "/player", 0755); if (!@mkdir(JWPLAYER_FILES_DIR . "/configs", 0755)) { add_action('admin_notices', create_function('', 'echo \'<div id="message" class="fade updated"><p><strong>' . __('There was a problem completing activation of the plugin. The wp-content/uploads/jw-player-plugin-for-wordpress/configs directory could not be created. Please ensure the WordPress uploads directory is writable. ' . JW_FILE_PERMISSIONS) . '</strong></p></div>\';')); return; } chmod(JWPLAYER_FILES_DIR . "/configs", 0755); if (@is_dir(JWPLAYER_PLUGIN_DIR . "/configs")) { foreach (get_old_configs() as $config) { @rename(JWPLAYER_PLUGIN_DIR . "/configs/{$config}.xml", JWPLAYER_FILES_DIR . "/configs/{$config}.xml"); } } } } // Add JW Embedder for 5.3 players or higher. Otherwise add swfobject.js from Google CDN. if (version_compare(get_option(LONGTAIL_KEY . "version"), "5.3", ">=")) { wp_enqueue_script("jw-embedder", LongTailFramework::getEmbedderURL()); } wp_deregister_script("swfobject"); wp_register_script("swfobject", 'http' . (is_ssl() ? 's' : '') . '://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js', NULL, NULL); wp_enqueue_script("swfobject"); add_filter("the_content", "jwplayer_tag_callback", 11); add_filter("the_excerpt", "jwplayer_tag_excerpt_callback", 11); add_filter("widget_text", "jwplayer_tag_widget_callback", 11); // Player configuration and Media Management, limited to administrators. if (is_admin()) { add_action('plugins_loaded', create_function('', 'global $adminContext; $adminContext = new AdminContext();')); add_action("admin_menu", "jwplayer_plugin_menu"); wp_register_script('jquery-ui-jw', $pluginURL . '/' . plugin_basename(dirname(__FILE__)) . "/js/jquery.ui.jw.js"); } function jwplayer_install_notices() {
/** * @see AdminState::render() */ public function render() { $flash_vars = LongTailFramework::getPlayerFlashVars($this->flashVarCat()); ?> <div class="wrap"> <form name="<?php echo LONGTAIL_KEY . "form"; ?> " method="post" action=""> <?php parent::getBreadcrumbBar(); ?> <?php $this->selectedPlayer(); ?> <p/> <div id="poststuff"> <div id="post-body"> <div id="post-body-content"> <?php $this->getHeader(); ?> <?php foreach (array_keys($flash_vars) as $groups) { ?> <div class="stuffbox"> <h3 class="hndle"><span><?php echo $groups; ?> </span></h3> <div class="inside" style="margin: 15px;"> <table class="form-table"> <?php foreach ($flash_vars[$groups] as $fvar) { ?> <tr valign="top"> <th><?php echo $fvar->getName(); ?> :</th> <td> <?php $name = LONGTAIL_KEY . "player_" . $fvar->getName(); ?> <?php $value = $_POST[$name] ? $_POST[$name] : $fvar->getDefaultValue(); ?> <?php unset($_POST[$name]); ?> <?php if ($fvar->getType() == FlashVar::SELECT) { ?> <select size="1" name="<?php echo $name; ?> "> <?php foreach ($fvar->getValues() as $val) { ?> <option value="<?php echo $val; ?> " <?php selected($val, $value); ?> > <?php echo htmlentities($val); ?> </option> <?php } ?> </select> <?php } else { ?> <input type="text" value="<?php echo $value; ?> " name="<?php echo $name; ?> " /> <?php } ?> <span class="description"><?php echo $fvar->getDescription(); ?> </span> </td> </tr> <?php } ?> </table> </div> </div> <?php } ?> <?php $this->getFooter(); ?> </div> </div> </div> <?php $this->getButtonBar(false); ?> </form> </div> <?php }
/** * @see FlashVarState::getFooter() * @param $form * @param $form_state */ protected function getFooter(&$form, $form_state) { $form["Additional"] = array("#type" => "fieldset", "#title" => t("Additional Flashvars")); $name = LONGTAIL_KEY . "player_flashvars"; $form["Additional"][$name] = array("#type" => "textarea", "#title" => "flashvars", "#description" => t("Enter a comma delimited list of additional flashvars you would like to be used by this player."), "#name" => $name, "#default_value" => $form_state["storage"][$name] ? $form_state["storage"][$name] : LongTailFramework::getPlayerAdditionalFlashVars(), "#rows" => 2); }
/** * @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 }
function generateModeString(&$atts, $id) { $html5 = $atts["html5_file"]; if (!isset($html5) || $html5 == null || $html5 == "") { $html5 = get_post_meta($id, LONGTAIL_KEY . "html5_file", true); } if (!isset($html5) || $html5 == null || $html5 == "") { $html5_id = get_post_meta($id, LONGTAIL_KEY . "html5_file_selector", true); if (isset($html5_id)) { $html5_attachment = get_post($html5_id); $html5 = $html5_attachment->guid; } } $download = $atts["download_file"]; if (!isset($download) || $download == null || $download == "") { $download = get_post_meta($id, LONGTAIL_KEY . "download_file", true); } if (!isset($download) || $download == null || $download == "") { $download_id = get_post_meta($id, LONGTAIL_KEY . "download_file_selector", true); if (isset($download_id)) { $download_attachment = get_post($download_id); $download = $download_attachment->guid; } } if (isset($html5) || isset($download)) { $mode = "[{type: \"flash\", src: \"" . LongTailFramework::getPlayerURL() . "\"}"; if (isset($html5)) { $mode .= ", {type: \"html5\", config: {\"file\": \"{$html5}\", \"streamer\": \"\", \"provider\": \"\"}}"; } if (isset($download)) { $mode .= ", {type: \"download\", config: {\"file\": \"{$download}\", \"streamer\": \"\", \"provider\": \"\"}}"; } $mode .= "]"; $atts["modes"] = $mode; } }
/** * @see FlashVarState::getFooter() */ protected function getFooter() { ?> <div class="stuffbox"> <h3 class="hndle"><span><?php echo "Additional Flashvars"; ?> </span></h3> <div class="inside" style="margin: 15px;"> <table class="form-table"> <tr valign="top"> <th><?php echo "flashvars:"; ?> </th> <td> <?php $name = LONGTAIL_KEY . "player_flashvars"; ?> <?php $value = $_POST[$name] ? $_POST[$name] : LongTailFramework::getPlayerAdditionalFlashVars(); ?> <?php unset($_POST[$name]); ?> <textarea name="<?php echo $name; ?> " cols="80" rows="2"><?php echo $value; ?> </textarea> <br/> <span class="description"><?php echo "Enter a comma delimited list of additional flashvars you would like to be used by this player."; ?> </span> </td> </tr> </table> </div> </div> <?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' => __('«'), 'next_text' => __('»'), '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 }
/** * Creates a Plugin object which represents a given Player plugin. * @param file $file The xml file which represents the Plugin * @param &$config_values The currently loaded config values. Used to * distinguish between standard flashvars and additional flashvars. * @return A new Plugin object */ private static function processPlugin($file, &$config_values = null) { $plugin_xml = simplexml_load_file(LongTailFramework::getPluginPath() . $file); $title = (string) $plugin_xml->{"title"}; $version = (string) $plugin_xml->{"version"}; $file_name = (string) $plugin_xml->{"filename"}; $repository = (string) $plugin_xml->{"repository"}; $description = (string) $plugin_xml->{"description"}; $href = (string) $plugin_xml->{"page"}; $enabled = false; $config_found = true; $plugin_name = str_replace(".swf", "", $file_name); //Check if the config file exists. if (file_exists(LongTailFramework::getConfigPath())) { $config_file = simplexml_load_file(LongTailFramework::getConfigPath()); } else { $config_found = false; } $enabled = strstr((string) $config_file->plugins, $repository) ? true : false; $f_vars = array(); //Process the flashvars in the plugin xml file. foreach ($plugin_xml->flashvars as $flash_vars) { $f_var = array(); $f_var_section = (string) $flash_vars["section"]; $f_var_section = $f_var_section ? $f_var_section : "FlashVars"; foreach ($flash_vars as $flash_var) { $default = (string) $flash_var->{"default"}; //If the config file was loaded and has an entry for the current flashvar //use the value in the config file and set the plugin as enabled. if ($config_found && $config_file->{$plugin_name . "." . $flash_var->name}) { $p_key = $plugin_name . "." . $flash_var->name; if ($config_values != null) { unset($config_values[(string) $p_key]); } $default = (string) $config_file->{$plugin_name . "." . $flash_var->name}; } $values = (array) $flash_var->select; $temp_var = new FlashVar((string) $flash_var->name, $default, (string) $flash_var->description, (array) $values["option"], (string) $flash_var["type"]); $f_var[(string) $flash_var->name] = $temp_var; } $f_vars[$f_var_section] = $f_var; } $plugin = new Plugin($title, $version, $repository, $file_name, $enabled, $description, $f_vars, $href); return $plugin; }
function create_mode_block($atts) { $modes = array(); $playerMode = get_option(LONGTAIL_KEY . "player_mode", true); $flashMode = new stdClass(); $flashMode->type = "flash"; $flashMode->src = LongTailFramework::getPlayerURL(); $html5Mode = new stdClass(); $html5Mode->type = "html5"; $html5Mode->config = new stdClass(); $html5Mode->config->streamer = ""; $html5Mode->config->provider = ""; if (array_key_exists("html5_file", $atts)) { $html5Mode->config->file = $atts["html5_file"]; } $downloadMode = new stdClass(); $downloadMode->type = "download"; $downloadMode->config = new stdClass(); $downloadMode->config->streamer = ""; $downloadMode->config->provider = ""; if (array_key_exists("download_file", $atts)) { $downloadMode->config->file = $atts["download_file"]; } if ($playerMode == "html5") { $modes[] = $html5Mode; $modes[] = $flashMode; } else { $modes[] = $flashMode; $modes[] = $html5Mode; } $modes[] = $downloadMode; return $modes; }
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 }
/** * @see AdminState::render() */ public function render() { $plugins = LongTailFramework::getPlugins(); $configValues = LongTailFramework::getConfigValues(); $pluginString = explode(",", $configValues["plugins"]); $pluginList = array(); foreach ($pluginString as $pluginStr) { $pluginList[$pluginStr] = $pluginStr; } ?> <div class="wrap"> <script type="text/javascript"> jQuery(function () { jQuery('#tabs').tabs(); removeAllTabs(); jQuery("<?php echo "#" . LONGTAIL_KEY . "plugin_selector_tab"; ?> ").css("display", "block"); <?php foreach ($plugins as $plugin) { ?> <?php if ($plugin->isEnabled()) { ?> jQuery("<?php echo "#" . LONGTAIL_KEY . "plugin_" . $plugin->getRepository() . "_tab"; ?> ").css("display", "block"); <?php } ?> <?php } ?> jQuery("#tabs").css("display", "block"); jQuery(":checkbox").change(function() { var name = "#" + jQuery(this)[0].name.replace("enable", "tab"); var hidden = jQuery(this)[0].name + "_hidden"; if(jQuery(this)[0].checked) { jQuery(name).css("display", "block"); jQuery(name).val(true); } else { jQuery(name).css("display", "none"); jQuery(name).val(false); } }) }); function removeAllTabs() { jQuery("#tabNavigation").children().css("display","none"); } </script> <form name="<?php echo LONGTAIL_KEY . "form"; ?> " method="post" action=""> <?php parent::getBreadcrumbBar(); ?> <?php $this->selectedPlayer(); ?> <p/> <div id="tabs"> <ul id="tabNavigation"> <?php $id = LONGTAIL_KEY . "plugin_selector"; ?> <li id="<?php echo $id . "_tab"; ?> "><a href="<?php echo "#" . $id; ?> ">Plugin Selector</a></li> <?php foreach ($plugins as $plugin) { ?> <?php $id = LONGTAIL_KEY . "plugin_" . $plugin->getRepository(); ?> <li id="<?php echo $id . "_tab"; ?> "><a href="<?php echo "#" . $id; ?> "><?php echo $plugin->getTitle(); ?> </a></li> <?php } ?> </ul> <div id="<?php echo LONGTAIL_KEY . "plugin_selector"; ?> "> <table class="form-table"> <?php foreach ($plugins as $plugin) { ?> <?php $name = LONGTAIL_KEY . "plugin_" . $plugin->getRepository() . "_" . "enable"; ?> <?php $value = isset($_POST[$name]) ? $_POST[$name] : $plugin->isEnabled(); ?> <?php unset($_POST[$name]); ?> <tr valign="top"> <th>Enable <?php echo $plugin->getTitle(); ?> :</th> <td> <input name="<?php echo $name; ?> " type="checkbox" value="1" <?php checked(true, $value); ?> /> <input name="<?php echo $name . "_hidden"; ?> " type="hidden" value="0"/> <span class="description"><?php echo $plugin->getDescription() . " <a href=" . $plugin->getPage() . JW_PLAYER_GA_VARS . " target=_blank>Learn more...</a>"; ?> </span> </td> </tr> <tr> <td colspan="2"></td> </tr> <?php } ?> </table> </div> <?php foreach ($plugins as $plugin) { ?> <?php unset($pluginList[$plugin->getRepository()]); ?> <div id="<?php echo LONGTAIL_KEY . "plugin_" . $plugin->getRepository(); ?> "> <table class="form-table"> <?php foreach (array_keys($plugin->getFlashVars()) as $plugin_flash_vars) { ?> <?php $p_vars = $plugin->getFlashVars(); ?> <?php foreach ($p_vars[$plugin_flash_vars] as $plugin_flash_var) { ?> <tr valign="top"> <?php $name = LONGTAIL_KEY . "plugin_" . $plugin->getPluginPrefix() . "_" . $plugin_flash_var->getName(); ?> <?php $value = isset($_POST[$name]) ? $_POST[$name] : $plugin_flash_var->getDefaultValue(); ?> <?php unset($_POST[$name]); ?> <th><?php echo $plugin->getPluginPrefix() . "." . $plugin_flash_var->getName(); ?> :</th> <td> <?php if ($plugin_flash_var->getType() == FlashVar::SELECT) { ?> <select size="1" name="<?php echo $name; ?> "> <?php foreach ($plugin_flash_var->getValues() as $val) { ?> <option value="<?php echo $val; ?> " <?php selected($val, $value); ?> > <?php echo htmlentities($val); ?> </option> <?php } ?> </select> <?php } else { ?> <input type="text" value="<?php echo $value; ?> " name="<?php echo $name; ?> " /> <?php } ?> <span class="description"><?php echo $plugin_flash_var->getDescription(); ?> </span> </td> </tr> <?php } ?> <?php } ?> </table> </div> <?php } ?> </div> <?php $this->getFooter($pluginList); ?> <?php $this->buttonBar(PluginState::getID(), true, false); ?> </form> </div> <?php }
/** * @see FlashVarState::getFooter() */ protected function getFooter() { ?> <div class="stuffbox"> <h3 class="hndle"><span><?php _e("Additional Flashvars", 'jw-player-plugin-for-wordpress'); ?> </span></h3> <div class="inside" style="margin: 15px;"> <table class="form-table"> <tr valign="top"> <th><?php echo "flashvars:"; ?> </th> <td> <?php $name = LONGTAIL_KEY . "player_flashvars"; ?> <?php $value = isset($_POST[$name]) ? $_POST[$name] : LongTailFramework::getPlayerAdditionalFlashVars(); ?> <?php unset($_POST[$name]); ?> <textarea name="<?php echo $name; ?> " cols="80" rows="2"><?php echo $value; ?> </textarea> <br/> <span class="description"><?php _e("Enter one additional flashvar (name=value) per line that you would like to be used by this player. <strong>Note:</strong> Overriding the standard flashvars could lead to unexpected behavior. ", 'jw-player-plugin-for-wordpress'); ?> </span> </td> </tr> </table> </div> </div> <?php }
function embed_demo_player($download = false) { $atts = array("file" => "http://content.longtailvideo.com/videos/bunny.flv", "image" => "http://content.longtailvideo.com/videos/bunny.jpg", "id" => "jwplayer-1"); $swf = LongTailFramework::generateSWFObject($atts, false); ?> <script type="text/javascript"> var player, t; jQuery(document).ready(function() { t = setTimeout(playerNotReady, 2000); }); function playerNotReady() { var data = { action: "verify_player", version: null, type: <?php echo (int) $download; ?> }; document.getElementById("version").value = null; document.getElementById("type").value = <?php echo (int) $download; ?> ; jQuery.post(ajaxurl, data, function(response) { var download = <?php echo (int) $download; ?> ; if (!download) { document.getElementById("error").style.display = "block"; } }); } function playerReady(object) { player = document.getElementById(object.id); var data = { action: "verify_player", version: player.getConfig().version, type: <?php echo (int) $download; ?> }; clearTimeout(t); document.getElementById("version").value = player.getConfig().version; document.getElementById("type").value = <?php echo (int) $download; ?> ; jQuery.post(ajaxurl, data, function(response) { var download = <?php echo (int) $download; ?> ; if (!download) { document.getElementById("error").style.display = "none"; document.getElementById("info").style.display = "block"; } document.getElementById("player_version").innerHTML = document.getElementById("player_version").innerHTML + player.getConfig().version; }); } </script> <?php echo $swf->generateEmbedScript(); ?> <input id="type" class="hidden" type="text" name="Type" /> <input id="version" class="hidden" type="text" name="Version" /> <?php }
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++; } }
/** * 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; }
/** * 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 }
/** * Processes the final submission of the wizard to be saved as a player * configuration. * @return Array The array of configuration options to be saved. */ private function processSubmit() { $data = LongTailFramework::getConfigValues(); $plugins = array(); foreach ($_POST as $name => $value) { if (strstr($name, LONGTAIL_KEY . "player_")) { $val = esc_html($value); $new_val = $val; $new_name = str_replace(LONGTAIL_KEY . "player_", "", $name); if ($new_name == "skin") { if ($new_val != "[Default]") { $skins = LongTailFramework::getSkins(); $new_val = LongTailFramework::getSkinURL() . $val . "." . $skins[$val]; $data[$new_name] = $new_val; } } else { if ($new_name == "flashvars") { $this->parseFlashvarString($new_val, $data); } else { if (!empty($new_val)) { $data[$new_name] = $new_val; } else { unset($data[$new_name]); } } } } else { if (strstr($name, LONGTAIL_KEY . "plugin_") && strstr($name, "_enable")) { $plugins[str_replace("_enable", "", str_replace(LONGTAIL_KEY . "plugin_", "", $name))] = esc_html($value); //Process the plugin flashvars. } else { if (strstr($name, LONGTAIL_KEY . "plugin_") && !empty($value)) { $plugin_key = preg_replace("/_/", ".", str_replace(LONGTAIL_KEY . "plugin_", "", $name), 1); $found = false; foreach (array_keys($plugins) as $repo) { $key = explode(".", $plugin_key); if (strstr($repo, $key[0]) && $plugins[$repo]) { $data[$plugin_key] = esc_html($value); $found = true; break; } } if (!$found) { unset($data[$plugin_key]); } } } } } $active_plugins = array(); //Build final list of plugins to be used for this Player. foreach ($plugins as $name => $enabled) { if ($enabled) { $active_plugins[] = $name; } } $plugin_string = implode(",", $active_plugins); if (!empty($plugins)) { $data["plugins"] = $plugin_string; } if ($data["plugins"] == "" || empty($data["plugins"])) { unset($data["plugins"]); } return $data; }
function generate_embed_code($config, $atts) { LongTailFramework::setConfig($config); $version = version_compare(get_option(LONGTAIL_KEY . "version"), "5.3", ">="); $embedder = file_exists(LongTailFramework::getEmbedderPath()); if (!$embedder && !$version && preg_match("/iP(od|hone|ad)/i", $_SERVER["HTTP_USER_AGENT"])) { $youtube_pattern = "/youtube.com\\/watch\\?v=([0-9a-zA-Z_-]*)/i"; $loaded_config = LongTailFramework::getConfigValues(); $width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"]; $height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"]; $output = ""; if (preg_match($youtube_pattern, $atts["file"], $match)) { $output = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $match[1] . '&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $match[1] . '&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>'; } else { $output = '<video src="' . $atts["file"] . '" width="' . $width . '" height="' . $height . '" controls="controls"></video>'; } return $output; } else { $swf = LongTailFramework::generateSWFObject($atts, $version && $embedder); return $swf->generateEmbedScript(); } }