private function _getLabel($optionName)
 {
     if ($this->_reference->getUntranslatedLabel($optionName)) {
         $label = $this->_reference->getUntranslatedLabel($optionName);
         return $this->_translator->trans($label);
     }
     return $optionName;
 }
Ejemplo n.º 2
0
 private function _getLabelMap()
 {
     $toReturn = array();
     $map = $this->_getMetaOptionNamesToAttributeDisplayNames();
     foreach ($map as $metaOptionName => $attributeName) {
         $label = $this->_optionReference->getUntranslatedLabel($metaOptionName);
         $toReturn[$attributeName] = $label;
     }
     return $toReturn;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function get($optionName)
 {
     if (array_key_exists($optionName, $this->_ephemeralOptions)) {
         return $this->_ephemeralOptions[$optionName];
     }
     try {
         return $this->_persistence->fetch($optionName);
     } catch (InvalidArgumentException $e) {
         if ($this->_optionReference->optionExists($optionName) && !$this->_optionReference->isMeantToBePersisted($optionName)) {
             return null;
         }
         throw $e;
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function onSubmit()
 {
     $isBoolean = $this->_optionProvider->isBoolean($this->_optionName);
     $paramName = $this->getId();
     $requestParams = $this->getHttpRequestParameters();
     if ($isBoolean) {
         return $this->sendToStorage($this->_optionName, $requestParams->hasParam($paramName));
     }
     if (!$requestParams->hasParam($paramName)) {
         /* not submitted. */
         return null;
     }
     $value = $requestParams->getParamValue($paramName);
     return $this->sendToStorage($this->_optionName, $this->convertIncomingStringValueToStorageFormat($value));
 }
Ejemplo n.º 5
0
 private function _noChangeBetweenIncomingAndCurrent($optionName, $filteredValue)
 {
     $boolean = $this->_optionsReference->isBoolean($optionName);
     $currentValue = $this->fetch($optionName);
     if ($boolean) {
         return (bool) $filteredValue === (bool) $currentValue;
     }
     return $currentValue == $filteredValue;
 }
 private function _setLegacyVariables(array &$templateVars)
 {
     $metaNames = $this->_getAllMetaOptionNames();
     $shouldShow = array();
     $labels = array();
     foreach ($metaNames as $metaName) {
         if (!$this->_optionReference->optionExists($metaName)) {
             $shouldShow[$metaName] = false;
             $labels[$metaName] = '';
             continue;
         }
         $shouldShow[$metaName] = $this->_context->get($metaName);
         $untranslatedLabel = $this->_optionReference->getUntranslatedLabel($metaName);
         $labels[$metaName] = $this->_translator->trans($untranslatedLabel);
     }
     $templateVars[tubepress_api_const_template_Variable::META_SHOULD_SHOW] = $shouldShow;
     $templateVars[tubepress_api_const_template_Variable::META_LABELS] = $labels;
 }
Ejemplo n.º 7
0
 private function _normalizeIncomingShortcodeOptionMap(array $optionMap)
 {
     if (!isset($this->_optionMapCache)) {
         $this->_optionMapCache = array();
         $allKnownOptionNames = $this->_optionsReference->getAllOptionNames();
         foreach ($allKnownOptionNames as $camelCaseOptionName) {
             $asLowerCase = strtolower($camelCaseOptionName);
             $this->_optionMapCache[$asLowerCase] = $camelCaseOptionName;
         }
     }
     $toReturn = array();
     foreach ($optionMap as $lowerCaseCandidate => $value) {
         if (isset($this->_optionMapCache[$lowerCaseCandidate])) {
             $camelCaseOptionName = $this->_optionMapCache[$lowerCaseCandidate];
             $toReturn[$camelCaseOptionName] = $value;
         }
     }
     return $toReturn;
 }
Ejemplo n.º 8
0
 private function _deepConvertBooleans(array &$candidate)
 {
     foreach ($candidate as $key => $value) {
         if (is_array($value)) {
             $this->_deepConvertBooleans($value);
             $candidate[$key] = $value;
         }
         if (!$this->_optionsReference->optionExists($key)) {
             continue;
         }
         if (!$this->_optionsReference->isBoolean($key)) {
             continue;
         }
         $candidate[$key] = (bool) $value;
     }
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function getUntranslatedLabelForChoice($choice)
 {
     return $this->_optionsReference->getUntranslatedLabel($choice);
 }
 public function __construct(tubepress_api_options_PersistenceInterface $persistence, tubepress_api_http_RequestParametersInterface $requestParams, tubepress_api_template_TemplatingInterface $templating, tubepress_api_options_ReferenceInterface $optionsReference)
 {
     $optionName = tubepress_api_options_Names::OPTIONS_UI_DISABLED_FIELD_PROVIDERS;
     parent::__construct(self::FIELD_ID, $persistence, $requestParams, $templating, $optionsReference->getUntranslatedLabel($optionName), $optionsReference->getUntranslatedDescription($optionName));
 }