Пример #1
0
 /**
  * Sets the display name of this menu item.
  * @access public
  * @param string text The new display name.
  **/
 function setDisplayName($text)
 {
     // ** parameter validation
     ArgumentValidator::validate($text, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_text = $text;
 }
 /**
  * Create a new PrimitiveIO object that allows for selection from an authority
  * list
  * 
  * @param <##>
  * @return <##>
  * @access public
  * @since 5/1/06
  */
 static function createComponentForPartStructure($partStruct)
 {
     ArgumentValidator::validate($partStruct, ExtendsValidatorRule::getRule("PartStructure"));
     $partStructType = $partStruct->getType();
     // get the datamanager data type
     $dataType = $partStructType->getKeyword();
     // 		printpre($dataType);
     $authoritativeValues = $partStruct->getAuthoritativeValues();
     if ($authoritativeValues->hasNext()) {
         $authZManager = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $partStruct->getRepositoryId())) {
             $component = new PrimitiveIO_AuthoritativeContainer();
             $component->setSelectComponent(PrimitiveIOManager::createAuthoritativeComponent($dataType));
             $component->setNewComponent(PrimitiveIOManager::createComponent($dataType));
         } else {
             $component = PrimitiveIOManager::createAuthoritativeComponent($dataType);
         }
         while ($authoritativeValues->hasNext()) {
             $component->addOptionFromSObject($authoritativeValues->next());
         }
     } else {
         // get the simple component for this data type
         $component = PrimitiveIOManager::createComponent($dataType);
     }
     return $component;
 }
Пример #3
0
 /**
  * Constructor
  * 
  * @param object XmlSiteDirector $director
  * @param object DOMElement $element
  * @return object XmlSiteNavBlockSiteComponent
  * @access public
  * @since 4/3/06
  */
 function __construct(AssetSiteDirector $director, Asset $asset, $element)
 {
     ArgumentValidator::validate($element, OptionalRule::getRule(ExtendsValidatorRule::getRule('DOMElement')));
     $this->_director = $director;
     $this->_asset = $asset;
     $this->_element = $element;
 }
 /**
  * Constructor
  * 
  * @param string $name
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniReadableLog($name, $dbIndex)
 {
     ArgumentValidator::validate($name, StringValidatorRule::getRule());
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule());
     $this->_name = $name;
     $this->_dbIndex = $dbIndex;
 }
Пример #5
0
 /**
  * Constructor.
  * 
  * @param string $baseName A name for the file.
  * @param optional DateAndTime $timestamp The Modification date/time
  * @return null
  * @access public
  * @since 5/6/08
  */
 public function __construct($baseName, DateAndTime $timestamp = null)
 {
     ArgumentValidator::validate($baseName, NonzeroLengthStringValidatorRule::getRule());
     $this->baseName = $baseName;
     $this->contents = '';
     $this->timestamp = $timestamp;
 }
Пример #6
0
 /**
  * Sets the display name of this menu item.
  * @access public
  * @param string displayName The new display name.
  **/
 function setDisplayName($displayName)
 {
     // ** parameter validation
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_displayName = $displayName;
 }
Пример #7
0
 /**
  * Constructor. Sign up for reCAPTCHA keys at http://recaptcha.net/
  * 
  * @param string $publicKey
  * @param string $privateKey
  * @return void
  * @access public
  * @since 6/4/08
  */
 public function __construct($publicKey, $privateKey)
 {
     ArgumentValidator::validate($publicKey, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($privateKey, NonzeroLengthStringValidatorRule::getRule());
     $this->_publicKey = $publicKey;
     $this->_privateKey = $privateKey;
 }
 /**
  * Constructor.
  * @param object Id $setId The Id of this set.
  * @param integer $dbIndex The index of the database connection which has
  * 		tables in which to store the set.
  */
 function PersistentOrderedSet($setId, $dbIndex)
 {
     parent::OrderedSet($setId);
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // Create our internal array
     $this->_dbIndex = $dbIndex;
     // populate our array with any previously stored items.
     $query = new SelectQuery();
     $query->addColumn("item_order", "item_order");
     $query->addColumn("item_id", "item_id");
     $query->addTable("sets");
     $query->addWhere("id = '" . addslashes($this->_setId->getIdString()) . "'");
     $query->addOrderBy("item_order");
     $dbHandler = Services::getService("DatabaseManager");
     $result = $dbHandler->query($query, $this->_dbIndex);
     $i = 0;
     $oldItems = array();
     while ($result->hasMoreRows()) {
         // Add the items to our array
         $this->_items[$i] = $result->field("item_id");
         // Store an array of the order-key/value relationships to reference
         // when updating any inconsistancies in order numbering.
         $oldItems[$result->field("item_order")] = $result->field("item_id");
         $i++;
         $result->advanceRow();
     }
     $result->free();
     // Make sure that we have our set is filled from 0 to count()
     reset($oldItems);
     $this->_updateOrders($oldItems);
 }
 /**
  * Constructor
  * 
  * @param object NodeIterator $nodes
  * @param object Repository $repository
  * @return object
  * @access public
  * @since 5/4/06
  */
 function FromNodesAssetIterator($nodes, $repository)
 {
     // 		ArgumentValidator::validate($nodes, ExtendsValidatorRule::getRule("Iterator"));
     ArgumentValidator::validate($repository, ExtendsValidatorRule::getRule("Repository"));
     $this->_nodes = $nodes;
     $this->_repository = $repository;
 }
 /**
  * The constructor.
  * @param string displayName The display name of this menu item.
  * @param string url The url of this menu item.
  * @param boolean selected The selected state of this menu item.
  * @param integer index The index of this component. The index has no semantic meaning: 
  * you can think of the index as 'level' of the component. Alternatively, 
  * the index could serve as means of distinguishing between components with 
  * the same type. Most often one would use the index in conjunction with
  * the <code>getStylesForComponentType()</code> and 
  * <code>addStyleForComponentType()</code> methods.
  * @param string target The target window of this menu item.
  * @param string accessKey The access key (shortcut) of this menu item.
  * @param string toolTip The toolTip of this menu item.
  * @access public
  **/
 function MenuItemLinkWithAdditionalHtml($displayName, $url, $selected, $index, $target = null, $accessKey = null, $toolTip = null, $additionalHtml = '')
 {
     ArgumentValidator::validate($additionalHtml, StringValidatorRule::getRule());
     // ** end of parameter validation
     $this->_additionalHtml = $additionalHtml;
     $this->MenuItemLink($displayName, $url, $selected, $index, $target, $accessKey, $toolTip);
 }
 function updateDisplayName($newDisplayName)
 {
     //make sure its a string
     ArgumentValidator::validate($newDisplayName, new StringValidatorRule(), true);
     //set the display name in the object
     $this->getNode()->updateDisplayName($newDisplayName);
 }
Пример #12
0
 /**
  * Constructor
  * 
  * @param mixed $entryItem
  * @param object Type $formatType
  * @param object Type $priorityType
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniEntry($timestamp, $category, $description, $backtrace, $agents, $nodes, $formatType, $priorityType)
 {
     ArgumentValidator::validate($timestamp, ExtendsValidatorRule::getRule("DateAndTime"));
     ArgumentValidator::validate($category, StringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     ArgumentValidator::validate($backtrace, StringValidatorRule::getRule());
     ArgumentValidator::validate($agents, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($nodes, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($formatType, ExtendsValidatorRule::getRule("Type"));
     ArgumentValidator::validate($priorityType, ExtendsValidatorRule::getRule("type"));
     $this->_timestamp = $timestamp;
     $this->_formatType = $formatType;
     $this->_priorityType = $priorityType;
     $this->_entryItem = new AgentNodeEntryItem($category, $description);
     $this->_entryItem->setBacktrace($backtrace);
     $idManager = Services::getService("Id");
     foreach ($agents as $idString) {
         if ($idString) {
             $this->_entryItem->addAgentId($idManager->getId($idString));
         }
     }
     foreach ($nodes as $idString) {
         if ($idString) {
             $this->_entryItem->addNodeId($idManager->getId($idString));
         }
     }
 }
Пример #13
0
 /**
  * Constructor.
  * 
  * @param string $path
  * @return null
  * @access public
  * @since 5/6/08
  */
 public function __construct($path)
 {
     ArgumentValidator::validate($path, NonzeroLengthStringValidatorRule::getRule());
     if (!file_exists($path) || is_dir($path)) {
         throw new InvalidArgumentException("'" . $path . "' is not a valid file.", 78345);
     }
     $this->path = $path;
 }
Пример #14
0
 /**
  * Adds one SQL string to this query.
  * @access public
  * @param string sql One SQL string,
  * @return void 
  */
 function addSQLQuery($sql)
 {
     // ** parameter validation
     $stringRule = StringValidatorRule::getRule();
     ArgumentValidator::validate($sql, $stringRule, true);
     // ** end of parameter validation
     $this->_sql[] = $sql;
 }
Пример #15
0
 /**
  * Adds a specific data type (identified by a string such as "integer") to our registry. Each data type has two classes associated with it: a {@link Primitive} and a {@link StorablePrimitive}. The former is used when setting/getting values, the latter used when talking with the database.
  * @param string $typeName The name (such as "integer" or "boolean") of this new data type.
  * @param string $primitiveClass The name of the {@link Primitive} class.
  * @param string $storablePrimitiveClass The name of the {@link StorablePrimitive} class.
  * @param string $conversionMethod
  * @access public
  * @return void
  */
 function addDataType($typeName, $primitiveClass, $storablePrimitiveClass, $conversionMethod)
 {
     ArgumentValidator::validate($conversionMethod, StringValidatorRule::getRule());
     $this->_registeredTypes[$typeName] = array("primitive" => $primitiveClass, "storable" => $storablePrimitiveClass, "ConversionMethod" => $conversionMethod);
     if (!in_array(strtolower($storablePrimitiveClass), $this->_primitiveClassMapping)) {
         $this->_primitiveClassMapping[] = strtolower($storablePrimitiveClass);
     }
 }
 /**
  * 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;
 }
 /**
  * Adds a new {@link WizardStep} to this container.
  * @param string $name A reference/ID name for this wizard.
  * @param ref object $step
  * @access public
  * @return ref object The new step object.
  */
 function addStep($name, $step)
 {
     ArgumentValidator::validate($step, ExtendsValidatorRule::getRule("WizardStep"), true);
     $name = preg_replace("/[^a-zA-Z0-9:_\\-]/", "_", $name);
     $this->_steps[] = $step;
     $this->_stepNames[] = $name;
     $step->setParent($this);
     return $step;
 }
 /**
  * The constructor.
  * @access public
  * @param integer $resourceId The resource id for this query.
  */
 function PostgreSQLUpdateQueryResult($resourceId)
 {
     // ** parameter validation
     $resourceRule = ResourceValidatorRule::getRule();
     ArgumentValidator::validate($resourceId, $resourceRule, true);
     // ** end of parameter validation
     $this->_resourceId = $resourceId;
     $this->_numberOfRows = pg_affected_rows($this->_resourceId);
 }
Пример #19
0
 /**
  * Sets the value of this hidden field.
  * @param string $value
  * @access public
  * @return void
  */
 function addValue($id, $name)
 {
     ArgumentValidator::validate($id, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($name, NonzeroLengthStringValidatorRule::getRule());
     if (strlen($this->_value)) {
         $this->_value .= '&';
     }
     $this->_value .= rawurlencode($id) . '=' . rawurlencode($name);
 }
 /**
  * Creates a new MySQLDeleteQueryResult object.
  * Creates a new MySQLDeleteQueryResult object.
  * @access public
  * @param integer $linkId The link identifier for the database connection.
  * @return object MySQLDeleteQueryResult A new MySQLDeleteQueryResult object.
  */
 function MySQLDeleteQueryResult($linkId)
 {
     // ** parameter validation
     $resourceRule = ResourceValidatorRule::getRule();
     ArgumentValidator::validate($linkId, $resourceRule, true);
     // ** end of parameter validation
     $this->_linkId = $linkId;
     $this->_numberOfRows = mysql_affected_rows($this->_linkId);
 }
Пример #21
0
 /**
  * Mark a slot as being accessed. 
  * This method should be called every time a page for a site is visited.
  * 
  * @param string $slotname
  * @return void
  * @access public
  * @since 9/22/08
  */
 public function touch($slotname)
 {
     ArgumentValidator::validate($slotname, NonzeroLengthStringValidatorRule::getRule());
     if ($this->_storePersistently()) {
         $this->_recordVisit($slotname);
     } else {
         $_SESSION['segue_access_log'][$slotname] = DateAndTime::now()->asString();
     }
 }
 /**
  * Initialize this object for a set of authentication tokens. Set the 
  * password to the encrypted version.
  * 
  * @param mixed $tokens
  * @return void
  * @access public
  * @since 3/1/05
  */
 function initializeForTokens($tokens)
 {
     ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
     ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
     $this->_tokens = $tokens;
     $this->_identifier = $tokens['username'];
     $this->_tokens['password'] = crypt($tokens['password'], $this->_configuration->getProperty('crypt_salt'));
 }
Пример #23
0
 /**
  * Constructor
  * 
  * @param object Id $agentId
  * @param object AuthNTokens $authNTokens
  * @param object Type $authenticationType
  * @return object AgentTokenMapping
  * @access public
  * @since 3/1/05
  */
 function AgentTokenMapping($authenticationType, $agentId, $authNTokens)
 {
     ArgumentValidator::validate($authNTokens, ExtendsValidatorRule::getRule("AuthNTokens"));
     ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($authenticationType, ExtendsValidatorRule::getRule("Type"));
     $this->_tokens = $authNTokens;
     $this->_id = $agentId;
     $this->_type = $authenticationType;
 }
Пример #24
0
 /**
  * Adds an {@link EventListener} to be triggered whenever an event is thrown.
  * @param string $eventType The string event type for which this {@link EventListener} is listening (example: "edu.middlebury.harmoni.action_executed")
  * @param ref object $eventListener the {@link EventListener} object.
  * @access public
  * @return ref object
  */
 function addEventListener($eventListener)
 {
     ArgumentValidator::validate($eventListener, HasMethodsValidatorRule::getRule("handleEvent"), true);
     //		if (!isset($this->_eventListeners[$eventType]) || !is_array($this->_eventListeners[$eventType])) {
     //			$this->_eventListeners[$eventType] = array();
     //		}
     //		$this->_eventListeners[$eventType][] =$eventListener;
     $this->_eventListeners[] = $eventListener;
 }
 /**
  * The constructor.
  * @access public
  * @param integer $resourceId The resource id for this query.
  */
 function OracleDeleteQueryResult($resourceId)
 {
     // ** parameter validation
     $resourceRule = ResourceValidatorRule::getRule();
     ArgumentValidator::validate($resourceId, $resourceRule, true);
     // ** end of parameter validation
     $this->_resourceId = $resourceId;
     $this->_numberOfRows = ocirowcount($this->_resourceId);
 }
 /**
  * Assigns the configuration of databases etc.
  * 
  * @param object $configuration
  * 
  * @access public
  *
  * @return void
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbIndex = $dbIndex;
 }
Пример #27
0
 /**
  * Constructor. Creates a HarmoniId with id = $id or a new unique id if $id is NULL.
  * @param string $id The desired id. If NULL, a new unique id is used.
  *
  */
 function __construct($id)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true);
     // ** end of parameter validation
     // 		if (preg_match('/^#.+$/', $id))
     $this->_id = strval($id);
     // 		else
     // 			$this->_id = '#'.md5($id);
 }
Пример #28
0
 /**
  * Constructor
  * 
  * @param string $id
  * @param string $displayName
  * @param string $description
  * @param array $choices
  * @return null
  * @access public
  * @since 5/9/08
  */
 public function __construct($id, $displayName, $description, array $choices)
 {
     ArgumentValidator::validate($id, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($displayName, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     $this->id = $id;
     $this->displayName = $displayName;
     $this->description = $description;
     $this->choices = $choices;
 }
Пример #29
0
 /**
  * Constructor.
  *
  * @param object ID	  $id	The Id of this Node.
  * @param string $displayName The displayName of the Node.
  * @param integer $depth The depth of the Node.
  * @access public
  */
 function __construct(Id $id, $displayName, $depth)
 {
     // Check the arguments
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule());
     ArgumentValidator::validate($depth, IntegerValidatorRule::getRule());
     // set the private variables
     $this->_id = $id;
     $this->_displayName = $displayName;
     $this->_depth = $depth;
 }
 /**
  * Set the value of the child components
  * 
  * @param array $value
  * @access public
  * @return void
  */
 function setValue($value)
 {
     ArgumentValidator::validate($value, ArrayValidatorRule::getRule());
     $children = $this->getChildren();
     foreach (array_keys($children) as $key) {
         if (isset($value[$key])) {
             $children[$key]->setValue($value[$key]);
         }
     }
 }