/**
  * 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)
 {
     if (is_object($value)) {
         ArgumentValidator::validate($value, HasMethodsValidatorRule::getRule("asString"));
         parent::setValue($value->asString());
     } else {
         parent::setValue($value);
     }
 }
Ejemplo n.º 2
0
 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;
 }
 /**
  * Add the attribution settings options to the property
  * 
  * @param object WSelectList $property
  * @return void
  * @access public
  * @since 3/20/08
  */
 public function addAttributionSettingsOptions(WSelectList $property)
 {
     $property->addOption('default', _("use default"));
     $property->addOption('none', _("override- No Attribution"));
     $property->addOption('creator', _("override-Original author"));
     $property->addOption('last_editor', _("override-Last editor"));
     $property->addOption('both', _("override-Both author and last editor"));
     $property->addOption('all_editors', _("override-All editors"));
     $property->setValue('default');
 }
Ejemplo n.º 4
0
 /**
  * Add the comments options to the property
  * 
  * @param object WSelectList $property
  * @return void
  * @access public
  * @since 11/30/07
  */
 public function addCommentsOptions(WSelectList $property)
 {
     $property->addOption('true', _("enable"));
     $property->addOption('false', _("disable"));
     $property->setValue('false');
 }