/** * 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; }