. * */ function_exists('tubepress_load_classes') || require(dirname(__FILE__) . '/../../../../tubepress_classloader.php'); tubepress_load_classes(array('org_tubepress_options_manager_OptionsManager', 'org_tubepress_options_storage_StorageManager', 'org_tubepress_options_reference_OptionsReference', 'org_tubepress_options_validation_InputValidationService')); /** * Holds the current options for TubePress. This is the default options, * usually in persistent storage somewhere, and custom options parsed * from a shortcode */ class org_tubepress_options_manager_SimpleOptionsManager implements org_tubepress_options_manager_OptionsManager { /** * Enter description here... * * @var array */ private $_customOptions = array(); /** * Enter description here... * * @var org_tubepress_options_storage_StorageManager */ private $_tpsm; private $_optionsReference; private $_validationService; /** * The shortcode currently in use * * @var string */ private $_shortcode; /** * Gets the value of an option * * @param string $optionName The name of the option * * @return unknown The option value */ public function get($optionName) { /* get the value, either from the shortcode or the db */ $value = array_key_exists($optionName, $this->_customOptions) ? $this->_customOptions[$optionName] : $this->_tpsm->get($optionName); /* get a valid value for this option */ try { $this->_validationService->validate($optionName, $value); } catch (Exception $e) { $value = $this->_optionsReference->getDefaultValue($optionName); } return $value; } /** * Enter description here... * * @param array $customOpts Custom options * * @return void */ public function setCustomOptions($customOpts) { $this->_customOptions = $customOpts; } public function mergeCustomOptions($customOpts) { $this->_customOptions = array_merge($this->_customOptions, $customOpts); } /** * Enter description here... * * @param string $newTagString The new shortcode * * @return void */ public function setShortcode($newTagString) { $this->_shortcode = $newTagString; } /** * Enter description here... * * @return string The full shortcode */ public function getShortcode() { return $this->_shortcode; } public function setStorageManager(org_tubepress_options_storage_StorageManager $tpsm) { $this->_tpsm = $tpsm; } public function setOptionsReference(org_tubepress_options_reference_OptionsReference $ref) { $this->_optionsReference = $ref; } public function setValidationService(org_tubepress_options_validation_InputValidationService $valService) { $this->_validationService = $valService; } }