/** * Adds a {@link WizardComponent} to this component. It will return the newly added component. * @param string $name The short-string name of the component - this is used for creating form input field names and storing data. * @param ref object $component A {@link WizardComponent} to add. * @access public * @return ref object */ function addComponent($name, $component) { ArgumentValidator::validate($name, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($component, ExtendsValidatorRule::getRule('WizardComponent')); $this->_children[preg_replace("/[^a-zA-Z0-9:_-]/", "_", $name)] = $component; $component->setParent($this); return $component; }
/** * Constructor * * @param object SeguePluginsAPI $pluginInstance * @param string $versionId * @param object DateAndTime $timestamp * @param object Id $agentId * @param int $number * @param string $comment * @return void * @access public * @since 1/7/08 */ public function __construct(SeguePluginsAPI $pluginInstance, $versionId, DateAndTime $timestamp, Id $agentId, $number, $comment) { ArgumentValidator::validate($versionId, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($number, IntegerValidatorRule::getRule()); ArgumentValidator::validate($comment, StringValidatorRule::getRule()); $this->pluginInstance = $pluginInstance; $this->versionId = $versionId; $this->timestamp = $timestamp; $this->agentId = $agentId; $this->number = $number; $this->comment = $comment; }
/** * This is the primary method that clients will use * * @param string $title * @param object SiteComponent $startingComponent * @return string The string Id. * @access public * @since 12/3/07 */ public function getNodeId($title, SiteComponent $startingComponent) { ArgumentValidator::validate($title, NonZeroLengthStringValidatorRule::getRule()); $this->visited = array(); $this->title = html_entity_decode($title); $this->title = mb_convert_encoding($this->title, 'UTF-8', mb_detect_encoding($this->title, "ASCII,UTF-8,ISO-8859-1,JIS,EUC-JP,SJIS")); $this->title = mb_strtolower($this->title, 'UTF-8'); $this->title = trim($this->title); $result = $this->searchDown($startingComponent); if (is_null($result)) { $result = $this->searchUp($startingComponent); } if (is_null($result)) { throw new UnknownTitleException("Title '{$title}' was now found."); } return $result; }
/** * Answer an iterator of agents that match the value of the property specified * with data from the agent element. * * @param string $propertyKey * @param object DOMElement $element * @return object Iterator * @access protected * @since 1/29/08 */ protected function getAgentsMatchingProperty($propertyKey, DOMElement $element) { ArgumentValidator::validate($propertyKey, NonZeroLengthStringValidatorRule::getRule()); $valueElements = $this->xpath->evaluate('./property[key = \'' . $propertyKey . '\']/string', $element); if ($valueElements->length) { $value = $this->getStringValue($valueElements->item(0)); if (strlen($value)) { $agentManager = Services::getService("Agent"); $searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "TokenSearch"); $string = "*" . $value . "*"; $agents = new MultiIteratorIterator(); $agents->addIterator($agentManager->getAgentsBySearch($string, $searchType)); $agents->addIterator($agentManager->getGroupsBySearch($string, $searchType)); $searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "AgentPropertiesSearch"); $string = "*" . $value . "*"; $agents->addIterator($agentManager->getAgentsBySearch($string, $searchType)); $agents->addIterator($agentManager->getGroupsBySearch($string, $searchType)); return $agents; } } return new HarmoniIterator(array()); }
/** * Answer a new MediaFile Id with any ids found in the id map passed converted * to their new equivalents * * @param array $idMap An associative array of old id-strings to new id-strings. * @param string $idString * @return string The resulting id string * @access public * @since 1/24/08 * @static */ public static function getMappedIdString(array $idMap, $idString) { ArgumentValidator::validate($idString, NonZeroLengthStringValidatorRule::getRule()); if (!preg_match('/^(?:(?:repositoryId=(.+)&(?:amp;)?)|(?:&(?:amp;)?))?assetId=(.+)&(?:amp;)?recordId=(.+)$/', $idString, $matches)) { throw new InvalidArgumentException("Invalid Id format, '{$idString}'"); } // printpre($matches); if (isset($matches[1]) && $matches[1]) { if (isset($idMap[$matches[1]])) { $id = "repositoryId=" . $idMap[$matches[1]] . "&"; } else { $id = "repositoryId=" . $matches[1] . "&"; } } else { $id = ""; } if (isset($idMap[$matches[2]])) { $id .= "assetId=" . $idMap[$matches[2]]; } else { $id .= "assetId=" . $matches[2]; } if (isset($idMap[$matches[3]])) { $id .= "&recordId=" . $idMap[$matches[3]]; } else { $id .= "&recordId=" . $matches[3]; } return $id; }
/** * Answer an 'add new component' link * * @param string $title * @param string $display * @param object SiteComponent $startingSiteComponent * @return string * @access public * @since 12/3/07 */ public function getAddLink($title, $display, SiteComponent $startingComponent) { ArgumentValidator::validate($title, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($display, NonZeroLengthStringValidatorRule::getRule()); $harmoni = Harmoni::instance(); ob_start(); print "<a href='"; $harmoni->request->startNamespace(null); try { print SiteDispatcher::quickURL($this->addModule, $this->addAction, array('title' => $title, 'refNode' => $startingComponent->getId())); } catch (NullArgumentException $e) { print $harmoni->request->quickURL($this->addModule, $this->addAction, array('title' => $title, 'node' => $startingComponent->getId(), 'refNode' => $startingComponent->getId())); } $harmoni->request->endNamespace(); print "'"; print " title=\"" . str_replace('%1', strip_tags($title), _("Add '%1' as a new component.")) . "\""; print ">"; print $display; print " ?</a>"; return ob_get_clean(); }
/** * Add a new field to the matrix. Each field can be set to one of the options. * * The final parameter allows you to set how the value of this field must * relate to the field prior to it. If null, then no relation is enforced. Valid options * for this parameter are: * null * '<' * '<=' * '==' * '>=' * '>' * * When an field is changed, all other fields will attempt to move and respect * the rules set. If the rules cannot be met, then the field change is reverted. * * @param string $parentKey * @param string $key * @param string $displayText * @param optional mixed $initialValue null or an option value. * @param optional mixed $rule One of null, '<', '<=', '==', '>=', '>'. * @return object RadioMatrixField * @access public * @since 11/1/07 */ public function addChildField($parentKey, $key, $displayText, $initialValue = null, $rule = null) { ArgumentValidator::validate($parentKey, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($key, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($displayText, NonZeroLengthStringValidatorRule::getRule()); if (!is_null($initialValue)) { ArgumentValidator::validate($initialValue, NonZeroLengthStringValidatorRule::getRule()); } if (!is_null($rule)) { ArgumentValidator::validate($rule, ChoiceValidatorRule::getRule('<', '<=', '==', '>=', '>')); } parent::addField($key, $displayText, $initialValue, null); $field = $this->fields[count($this->fields) - 1]; $field->rule = $rule; $this->fields[$this->getFieldIndex($parentKey)]->addChild($field); try { $this->validateState(); } catch (RuleValidationFailedException $e) { throw new RuleValidationFailedException("Default state does not validate against the rules supplied. Please change either the default values of the fields or the rules in order to have a valid initial state."); } return $field; }
/** * Answer a MediaFile in this Asset * * @param string $id * @return object MediaFile * @access public * @since 4/27/07 */ function getFileByIdString($id) { ArgumentValidator::validate($id, NonZeroLengthStringValidatorRule::getRule()); $idManager = Services::getService('Id'); return $this->getFileById($idManager->getId($id)); }
/** * Answer a particular version. * * @param string $versionId * @return object SeguePluginVersion * @access public * @since 1/7/08 */ public function getVersion($versionId) { ArgumentValidator::validate($versionId, NonZeroLengthStringValidatorRule::getRule()); if (!isset($this->versions)) { $this->getVersions(); } foreach ($this->versions as $version) { if ($version->getVersionId() == $versionId) { return $version; } } throw new UnknownIdException("No version with id, '{$versionId}', was found for this plugin instance."); }
/** * Constructor * * @param string $eventType * @return void * @access public * @since 11/16/07 */ public function __construct($eventType) { ArgumentValidator::validate($eventType, NonZeroLengthStringValidatorRule::getRule()); $this->eventType = $eventType; }
/** * Answer an Agent Id in the receiving system that corresponds to an id in the * source system. * * @param string $idString * @return object Id * @access protected * @since 1/23/08 */ protected function getAgentId($idString) { ArgumentValidator::validate($idString, NonZeroLengthStringValidatorRule::getRule()); return $this->agentImporter->getAgentId($idString); }
/** * Add an event type for the button * * @param string $event * @return void * @access public * @since 11/16/07 */ public function addEvent($event) { ArgumentValidator::validate($event, NonZeroLengthStringValidatorRule::getRule()); $this->events[] = $event; }
/** * Add a new field to the matrix. Each field can be set to one of the options. * * The final parameter allows you to set how the value of this field must * relate to the field prior to it. If null, then no relation is enforced. Valid options * for this parameter are: * null * '<' * '<=' * '==' * '>=' * '>' * * When an field is changed, all other fields will attempt to move and respect * the rules set. If the rules cannot be met, then the field change is reverted. * * @param string $key * @param string $displayText * @param optional mixed $initialValue null or an option value. * @param optional mixed $rule One of null, '<', '<=', '==', '>=', '>'. * @return object RadioMatrixField * @access public * @since 11/1/07 */ public function addField($key, $displayText, $initialValue = null, $rule = null) { ArgumentValidator::validate($key, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($displayText, NonZeroLengthStringValidatorRule::getRule()); if (!is_null($initialValue)) { ArgumentValidator::validate($initialValue, NonZeroLengthStringValidatorRule::getRule()); } if (!is_null($rule)) { ArgumentValidator::validate($rule, ChoiceValidatorRule::getRule('<', '<=', '==', '>=', '>')); } $field = $this->createField(); $field->key = $key; $field->displayText = $displayText; if (is_null($initialValue)) { $field->value = 0; } else { $field->value = $this->getOptionNumber($initialValue); } $field->rule = $rule; $field->spacerBefore = false; $field->spacerAfter = false; $field->disabledOptions = array(); $field->index = count($this->fields); $this->fields[] = $field; try { $this->validateState(); } catch (RuleValidationFailedException $e) { throw new RuleValidationFailedException("Default state does not validate against the rules supplied. Please change either the default values of the fields or the rules in order to have a valid initial state."); } return $field; }
/** * Set the update module and action. This method should not be used by plugins. * it is to be used only by plugin users to direct plugins to alternate updating * actions. * * @param string $module * @param string $action * @return void * @access public * @since 11/8/07 */ public function setUpdateAction($module, $action) { ArgumentValidator::validate($module, NonZeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($action, NonZeroLengthStringValidatorRule::getRule()); $this->updateModule = $module; $this->updateAction = $action; }