/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * * @return object Wizard * @access public * @since 4/28/05 */ function createWizard() { $harmoni = Harmoni::instance(); //$courseManager = Services::getService("CourseManagement"); //$canonicalCourseIterator =$courseManager->getCanonicalCourses(); // Instantiate the wizard, then add our steps. $wizard = SimpleStepWizard::withDefaultLayout(); // :: Name and Description :: $step = $wizard->addStep("namedescstep", new WizardStep()); $step->setDisplayName(_("Please choose the name and type for this type:")); // Create the type chooser. $select = new WSelectList(); //$select->addOption('',"Canonical Course Type"); $select->addOption('can', "Canonical Course Type"); $select->addOption('can_stat', "Canonical Course Status Type"); $select->addOption('offer', "Course Offering Type"); $select->addOption('offer_stat', "Course Offering Status Type"); $select->addOption('section', "Course Section Type"); $select->addOption('section_stat', "Course Section Status Type"); $select->addOption('enroll_stat', "Enrollment Status Type"); $select->addOption('grade', "Course Grading Type"); $select->addOption('term', "Term Type"); //$select->setValue(''); $typeProp = $step->addComponent("typetype", $select); //$typeProp->setErrorText("<nobr>"._("A value for this field is required.")."</nobr>"); //$typeProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); // Create the title $titleProp = $step->addComponent("keyword", new WTextField()); $titleProp->setErrorText("<nobr>" . _("A value for this field is required.") . "</nobr>"); $titleProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); // Create the description $descriptionProp = $step->addComponent("description", WTextArea::withRowsAndColumns(10, 30)); // Create the step text ob_start(); print "\n<font size=+2><h2>" . _("Type creator") . "</h2></font>"; print "\n<h2>" . _("Type") . "</h2>"; print "\n" . _("Please choose a type of <em>type</em> to create: "); print "\n<br />[[typetype]]"; print "\n<h2>" . _("Keyword") . "</h2>"; print "\n" . _("The keyword of the <em>type</em>: "); print "\n<br />[[keyword]]"; print "\n<h2>" . _("Description") . "</h2>"; print "\n" . _("The optional description of the <em>type</em>: "); print "\n<br />[[description]]"; print "\n<div style='width: 400px'> </div>"; $step->setContent(ob_get_contents()); ob_end_clean(); return $wizard; }
/** * Creates the component. * * styles can be an array indexed just as options is with styles as strings, can be set to a string to describe * the appropriate style property to automatically generate styles, or set to false to just leave them off. */ function WGUISelectList($callBack, $collectionSelector, $styleProperty, $componentClass, $options, $styles = false) { $input = new WSelectList(); foreach ($options as $opt => $name) { if ($styles) { if (is_array($styles)) { $input->addOption($opt, $name, $styles[$opt]); } else { $input->addOption($opt, $name, $styles . ": " . $opt . ";"); } } else { $input->addOption($opt, $name); } } $this->_wizardComponent = $input; $this->init($callBack, $collectionSelector, $styleProperty, $componentClass); }
/** * Answer true if the value passed is a valid option * * @param string $value * @return boolean * @access public * @since 4/28/06 */ function isOption($value) { if (is_object($value)) { ArgumentValidator::validate($value, HasMethodsValidatorRule::getRule("asString")); return parent::isOption($value->asString()); } else { return parent::isOption($value); } }
/** * Rebuild our position selects * * @return void * @access public * @since 5/16/06 */ function rebuildPositionSelects() { // Populate our position list; $positionList = new WSelectList(); $js = ' var choiceName = this.name + \'Choice\'; for (var i = 0; i < this.form.elements.length; i++) { if (this.form.elements[i].name == choiceName) { this.form.elements[i].value = \'true\'; break; } } submitWizard(this.form); '; $positionList->addOnChange(preg_replace("/\\s{2,}/", " ", preg_replace("/[\n\r\t]/", " ", $js))); $i = 0; $this->_orderedSet->reset(); while ($this->_orderedSet->hasNext()) { $this->_orderedSet->next(); $positionList->addOption($i, $i + 1); $i++; } // Enabled State $positionList->setEnabled($this->_enabled, $this->_enabledSticky); // Rebuild the position lists. $this->_orderedSet->reset(); while ($this->_orderedSet->hasNext()) { $collectionId = $this->_orderedSet->next(); $key = $collectionId->getIdString(); $this->_collections[$key]["_moveToPosition"] = $positionList->deepCopy(); $this->_collections[$key]["_moveToPosition"]->setParent($this); $this->_collections[$key]["_moveToPosition"]->setValue(strval($this->_orderedSet->getPosition($collectionId))); $this->_collections[$key]["_moveToPositionChoice"] = WHiddenField::withValue('false'); $this->_collections[$key]["_moveToPositionChoice"]->setParent($this); } }
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; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * * @return object Wizard * @access public * @since 4/28/05 */ function createWizard() { $harmoni = Harmoni::instance(); //$courseManager = Services::getService("CourseManagement"); //$canonicalCourseIterator =$courseManager->getCanonicalCourses(); // Instantiate the wizard, then add our steps. $wizard = SimpleStepWizard::withDefaultLayout(); // :: Name and Description :: $step = $wizard->addStep("namedescstep", new WizardStep()); $step->setDisplayName(_("Select options for the new term:")); //displayname $titleProp = $step->addComponent("displayname", new WTextField()); $titleProp->setErrorText("<nobr>" . _("A value for this field is required.") . "</nobr>"); $titleProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); // Create the type chooser. $select = new WSelectList(); $typename = "term"; $dbHandler = Services::getService("DBHandler"); $query = new SelectQuery(); $query->addTable('cm_' . $typename . "_type"); $query->addColumn('id'); $query->addColumn('keyword'); $res = $dbHandler->query($query); while ($res->hasMoreRows()) { $row = $res->getCurrentRow(); $res->advanceRow(); $select->addOption($row['id'], $row['keyword']); } $typeProp = $step->addComponent("termtype", $select); //$courseManager = Services::getService("CourseManagement"); //$select->addOption('',"Canonical Course Type"); /*$select->addOption('can',"Canonical Course Type"); $select->addOption('can_stat',"Canonical Course Status Type"); $select->addOption('offer',"Course Offering Type"); $select->addOption('offer_stat',"Course Offering Status Type"); $select->addOption('section',"Course Section Type"); $select->addOption('section_stat',"Course Section Status Type"); $select->addOption('enroll_stat',"Enrollment Status Type"); $select->addOption('grade',"Course Grading Type"); $select->addOption('term',"Term Type");*/ //$select->setValue(''); //$typeProp->setErrorText("<nobr>"._("A value for this field is required.")."</nobr>"); //$typeProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); // Create the display name // Create the step text ob_start(); print "\n<font size=+2><h2>" . _("Term creator") . "</h2></font>"; print "\n<h2>" . _("Keyword") . "</h2>"; print "\n" . _("The name of the <em>term</em>: "); print "\n<br />[[displayname]]"; print "\n<h2>" . _("Type") . "</h2>"; print "\n" . _("Please choose a type of <em>term</em>: "); print "\n<br />[[termtype]]"; print "\n<div style='width: 400px'> </div>"; $step->setContent(ob_get_contents()); ob_end_clean(); return $wizard; }
/** * 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'); }
/** * 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'); }