示例#1
0
 /**
  * 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;
 }
 /**
  * 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;
 }