function WStyleComponent($callBack, $component, $property, $collection) { $this->_getThemeCallBack = $callBack; $this->_collection = $collection; $this->_property = $property; $this->_component = $component; $styleComponent = $this->getStyleComponent(); $rule = $styleComponent->getRule(); $regex = $rule->getRegularExpression(); //$this->setErrorText($styleComponent->getErrorDescription()); //$this->setErrorRule($styleComponent->getRule()); //$this->_showError=false; if (is_null($styleComponent)) { throwError(new Error("The Component this references is based on cannot be null", "WStyleComponent", true)); } if (get_class($styleComponent) == 'colorsc') { $input = new WSelectOrNew(); $input->addOption('', "(not set)"); $digits = array("0", "4", "8", "C", "F"); for ($r = 0; $r < count($digits); $r++) { for ($g = 0; $g < count($digits); $g++) { for ($b = 0; $b < count($digits); $b++) { $val = '#' . $digits[$r] . $digits[$g] . $digits[$b]; $arr = $styleComponent->getRGBArray($val); //num measures the "brightness" of the color. //I think green is "brighter" than red and red "brighter" than blue. $num = $arr[0] * 3 + $arr[1] * 2 + $arr[2]; //Our threshold is 750. if ($num > 750) { $col = "000"; } else { $col = "#FFF"; } $input->addOption($val, $val, "color: " . $col . "; background-color:" . $val . ";"); } } } // make sure the current color is a possibility. if (!is_null($styleComponent->getValue())) { //$input->addOption($styleComponent->getValue(), $styleComponent->getValue(), "color: ".$col."; background-color:".$styleComponent->getValue().";"); $input->setValue($styleComponent->getValue()); } // if ([[colorwheel colors]]) // generate options for colors } else { if ($styleComponent->isLimitedToOptions()) { $input = new WSelectList(); $input->addOption('', "(not set)"); $options = $styleComponent->getOptions(); foreach ($options as $opt) { $input->addOption($opt, $opt, strtolower(preg_replace("/[^a-zA-Z0-9:_-]/", "-", $styleComponent->getDisplayName())) . ": {$opt};"); } $input->setValue($styleComponent->getValue()); } else { if ($styleComponent->hasOptions()) { $input = new WSelectOrNew(); $input->addOption('', "(not set)"); $options = $styleComponent->getOptions(); foreach ($options as $opt) { $input->addOption($opt, $opt, strtolower(preg_replace("/[^a-zA-Z0-9:_-]/", "-", $styleComponent->getDisplayName())) . ": {$opt};"); } $input->setValue($styleComponent->getValue()); } else { $input = new WTextField(); $input->setValue($styleComponent->getValue()); } } } if (!$styleComponent->isLimitedToOptions()) { $input->setErrorRule(new WECRegex($regex)); $input->setErrorText($styleComponent->getErrorDescription()); } $this->_wizardComponent = $input; }
/** * Sets the value of this Component to the {@link SObject} passed. * @param ref object $value The {@link SObject} value to use. * * @return void **/ function setValue($value) { ArgumentValidator::validate($value, HasMethodsValidatorRule::getRule("asString")); parent::setValue($value->asString()); }
/** * Sets the value of this Component to the {@link SObject} passed. * @param ref object $value The {@link SObject} value to use. * * @return void **/ function setValue($value) { parent::setValue($value->asString()); }