/** * @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); }
/** * Generates the list of flashvars supported by this version of the player along with * their defaults. * @return A structured array of the flashvars. */ private static function loadPlayerFlashVars() { $f_vars = array(); //Load the player xml file. $xml = simplexml_load_file(LongTailFramework::$dir . "/player.xml"); $config_file = LongTailFramework::$current_config_values; $config_values = LongTailFramework::getConfigValues(); //Process the flashvars in the player xml file. foreach ($xml->flashvars as $flash_vars) { $f_var = array(); $f_var_section = (string) $flash_vars["section"]; $f_var_advanced = (string) $flash_vars["type"]; //Ignore the flashvars categorized as "None." if ($f_var_advanced != "None") { 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. if ($config_file && $config_file->{$flash_var->name}) { unset($config_values[(string) $flash_var->name]); $default = (string) $config_file->{$flash_var->name}; $default = str_replace(LongTailFramework::getSkinURL(), "", $default); $default = preg_replace("/(\\.swf|\\.zip)/", "", $default); } $values = (array) $flash_var->select; $val = $values["option"]; $type = (string) $flash_var["type"]; //Load the possible values for the skin flashvar. if ($flash_var->name == "skin") { $type = "select"; $val = array_keys(LongTailFramework::getSkins()); } $temp_var = new FlashVar((string) $flash_var->name, $default, (string) $flash_var->description, $val, $type); $f_var[(string) $flash_var->name] = $temp_var; } $f_vars[$f_var_advanced][$f_var_section] = $f_var; } } unset($config_values["plugins"]); unset($config_values["ltas.cc"]); LongTailFramework::getPlugins($config_values); if ($config_values) { LongTailFramework::$loaded_additional_flash_vars = LongTailFramework::flattenAdditionalFlashVars($config_values); } LongTailFramework::$loaded_flash_vars = $f_vars; }
/** * @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 }