/** * 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; }
/** * Add a user agent string and an array of matching codes. If the user agent * matches the string and the code or exception class is in the list, the exception * will not be logged. This can be used to prevent misbehaving bots and web * crawlers from filling the logs with repeated invalid requests. * * @param string $userAgent * @param optional array $codesOrExceptionClasses If empty, no matches to the user agent will be logged. * @return void * @access public * @since 2/26/08 */ public function addUserAgentFilter($userAgent, $codesOrExceptionClasses = array()) { $userAgent = trim($userAgent); ArgumentValidator::validate($userAgent, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($codesOrExceptionClasses, ArrayValidatorRuleWithRule::getRule(OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()))); $this->userAgentFilters[$userAgent] = $codesOrExceptionClasses; }
/** * 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; }
/** * Stores the configuration. Calls the parent configuration first, * then does additional operations. * * @param object Properties $configuration * @return object * @access public * @since 3/24/05 */ function assignConfiguration(Properties $configuration) { // Set the configuration values to our custom values. $configuration->addProperty('authentication_table', 'auth_visitor'); $configuration->addProperty('username_field', 'email'); $configuration->addProperty('password_field', 'password'); $propertiesFields = array('name' => 'display_name', 'email' => 'email'); $configuration->addProperty('properties_fields', $propertiesFields); try { ArgumentValidator::validate($configuration->getProperty('email_from_name'), NonzeroLengthStringValidatorRule::getRule()); } catch (InvalidArgumentException $e) { throw new ConfigurationErrorException("'email_from_name' must be a string. " . $e->getMessage()); } try { ArgumentValidator::validate($configuration->getProperty('email_from_address'), RegexValidatorRule::getRule('/^.+@.+$/')); } catch (InvalidArgumentException $e) { throw new ConfigurationErrorException("'email_from_address' must be an email address. " . $e->getMessage()); } try { ArgumentValidator::validate($configuration->getProperty('domain_blacklist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule()))); ArgumentValidator::validate($configuration->getProperty('domain_whitelist'), OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(NonzeroLengthStringValidatorRule::getRule()))); } catch (InvalidArgumentException $e) { throw new ConfigurationErrorException("'domain_blacklist' and 'domain_whitelist' if specified must be arrays of domain name strings. " . $e->getMessage()); } parent::assignConfiguration($configuration); }
/** * 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; }
/** * 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(); } }
/** * 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); }
/** * 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; }
/** * 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); }
/** * 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 HarmoniStringId($id = NULL) { if ($id !== NULL) { // use this id // SLOW-VALIDATE -- comment validation out to increase program speed. ArgumentValidator::validate($id, NonzeroLengthStringValidatorRule::getRule()); $this->_id = $id; } else { // get a new unique id } }
/** * Constructor * * @param string $query * @return void * @access public * @since 8/11/08 */ public function __construct($query) { ArgumentValidator::validate($query, NonzeroLengthStringValidatorRule::getRule()); if (strip_tags($query) != $query) { throw new InvalidArgumentException("Invalid query '" . htmlspecialchars($query) . "'."); } $this->query = strip_tags($query); $this->queryParts = explode(' ', mb_convert_encoding($this->query, 'UTF-8', mb_detect_encoding($this->query, "ASCII,UTF-8,ISO-8859-1,JIS,EUC-JP,SJIS"))); $this->id = urlencode($this->query); $authN = Services::getService('AuthN'); $this->agentId = $authN->getFirstUserId(); }
/** * Constructor * * @param string $outputFilePath * @param string $relativeOutputFilePath The output file path relative to * encode into the xml output. * @return void * @access public * @since 2/4/08 */ public function __construct($outputFilePath, $relativeOutputFilePath) { if (!is_dir($outputFilePath)) { throw new Exception("'{$outputFilePath}' does not exist for export."); } if (!is_writable($outputFilePath)) { throw new Exception("'{$outputFilePath}' is not writable for export."); } ArgumentValidator::validate($relativeOutputFilePath, NonzeroLengthStringValidatorRule::getRule()); $this->outputFilePath = $outputFilePath; $this->relativeOutputFilePath = $relativeOutputFilePath; }
/** * Constructor * * @param array $configuration * @return null * @access public * @since 5/6/08 */ public function __construct(array $configuration) { if (!isset($configuration['database_index'])) { throw new ConfigurationErrorException("No 'database_index' specified.'"); } if (is_numeric($configuration['database_index'])) { $this->databaseIndex = intval($configuration['database_index']); } else { throw new ConfigurationErrorException("'database_index' must be an integer, '" . $configruation['database_index'] . "' given."); } // If no site Id is specified, we will fetch it from the request context // when we need it. if (isset($configuration['site_id'])) { ArgumentValidator::validate($configuration['site_id'], NonzeroLengthStringValidatorRule::getRule()); $this->siteId = $configuration['site_id']; } }
/** * Set the destination slot name * * @param string $slotname * @return void * @access public * @since 3/20/08 */ public function setDestinationSlotname($slotname) { ArgumentValidator::validate($slotname, NonzeroLengthStringValidatorRule::getRule()); $this->destSlotname = $slotname; }
/** * Constructor * * @param int $databaseIndex * @param int $themeId * @return null * @access public * @since 5/15/08 */ public function __construct($databaseIndex, $themeId, $path) { parent::__construct($databaseIndex, $themeId); ArgumentValidator::validate($path, NonzeroLengthStringValidatorRule::getRule()); $this->path = $path; }
/** * Assign the configuration of this Manager. Valid configuration options are as * follows: * database_index integer * database_name string * * @param object Properties $configuration (original type: java.util.Properties) * * @throws object OsidException An exception with one of the following * messages defined in org.osid.OsidException: {@link * org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED}, * {@link org.osid.OsidException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.OsidException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link * org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT} * * @access public */ function assignConfiguration(Properties $configuration) { $this->_configuration = $configuration; $hierarchyId = $configuration->getProperty('hierarchy_id'); $agentFlavor = $configuration->getProperty('defaultAgentFlavor'); // ** parameter validation ArgumentValidator::validate($hierarchyId, StringValidatorRule::getRule(), true); ArgumentValidator::validate($agentFlavor, StringValidatorRule::getRule(), true); // ** end of parameter validation $idManager = Services::getService("Id"); $this->_hierarchyId = $idManager->getId($hierarchyId); $this->_agentFlavor = $agentFlavor; $hierarchyManager = Services::getService("Hierarchy"); $hierarchy = $hierarchyManager->getHierarchy($this->_hierarchyId); if ($this->_configuration->getProperty('group_ip_ranges')) { ArgumentValidator::validate($this->_configuration->getProperty('group_ip_ranges'), ArrayValidatorRule::getRule()); $stringRule = NonzeroLengthStringValidatorRule::getRule(); $rangeRule = RegexValidatorRule::getRule('/^([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})$/'); foreach ($this->_configuration->getProperty('group_ip_ranges') as $groupIdString => $range) { ArgumentValidator::validate($groupIdString, $stringRule); ArgumentValidator::validate($range, $rangeRule); } } // initialize our Agent Search Types $this->_agentSearches = array(); $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"] = new TokenSearch(); $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"] = new AgentPropertiesSearch($this->_configuration->getProperty('database_index')); // initialize our Group Search Types $this->_groupSearches = array(); $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::AncestorGroups"] = new AncestorGroupSearch($hierarchy); $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::RootGroups"] = new RootGroupSearch($hierarchy); $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"] = $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"]; $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"] = $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"]; $this->_everyoneGroup = new EveryoneGroup($hierarchy, $hierarchy->getNode($this->_everyoneId)); }
/** * Add an external library to our configuration * * @param string $title * @param string $jsClass The javascript class of the library. * @param string $jsSourceUrl The path to the javascript file that defines the $jsClass. * @param array $extraParams An associative array of other parameters to pass to the library. * @return void * @access public * @since 1/13/09 * @static */ public static function addExternalLibrary($title, $jsClass, $jsSourceUrl, array $extraParams = array()) { ArgumentValidator::validate($title, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($jsClass, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($jsSourceUrl, NonzeroLengthStringValidatorRule::getRule()); self::$externalLibraries[] = array('title' => $title, 'jsClass' => $jsClass, 'jsSourceUrl' => $jsSourceUrl, 'extraParams' => $extraParams); }
/** * Add a value, escaping it and surrounding it with quotes. * * @param string $column * @param string $value * @return void * @access public * @since 3/8/07 */ function addValue($column, $value) { ArgumentValidator::validate($column, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($value, StringValidatorRule::getRule()); $this->addRawValue($column, "'" . addslashes($value) . "'"); }
/** * Add a new protocal (i.e. 'feed' for urls like 'feed://www.example.com/') * to those allowed to exist in urls. The following protocals are allowed by * default: * 'ed2k', 'file', 'ftp', 'gopher', 'http', 'https', * 'irc', 'mailto', 'news', 'nntp', 'telnet', 'webcal', * 'xmpp', 'callto', 'feed' * * @param string $protocal name * @return void * @access public * @since 2/14/08 */ public function addSafeProtocal($protocal) { ArgumentValidator::validate($protocal, NonzeroLengthStringValidatorRule::getRule()); $this->safeProtocals[] = $protocal; }
/** * Attempts to delete the specified node in the database. Only leaf nodes can * be deleted. * @access public * @param mixed idValue The string id of the node to delete. * @return void **/ function deleteNode($idValue) { // ** parameter validation ArgumentValidator::validate($idValue, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true); // ** end of parameter validation // get the node $node = $this->getNode($idValue); // if not a leaf, cannot delete if (!$node->isLeaf()) { // "Can not delete non-leaf nodes."; throw new OperationFailedException("Cannont delete non-leaf nodes."); } // clear the cache and update the _tree structure // detach the node from each of its parents and update the join table $parents = $node->getParents(); while ($parents->hasNext()) { $parent = $parents->next(); $node->removeParent($parent->getId()); } // now delete the tree node $treeNode = $this->_tree->getNode($idValue); $this->_tree->deleteNode($treeNode); // ----------------- // remove from cache unset($this->_cache[$idValue]); $node = null; // now remove from database $dbHandler = Services::getService("DatabaseManager"); // 1. Get the id of the type associated with the node $query = new SelectQuery(); $query->addTable("az2_node"); $query->addColumn("fk_type", "type_id", "az2_node"); $query->addWhereEqual("id", $idValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); if (!$queryResult->hasNext()) { $queryResult->free(); throw new OperationFailedException("No type found for node, '{$idValue}'."); } $typeIdValue = $queryResult->field("type_id"); $queryResult->free(); // 2. Now delete the node $query = new DeleteQuery(); $query->setTable("az2_node"); $query->addWhereEqual("id", $idValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); // 3. Now see if any other nodes have the same type $query = new SelectQuery(); $query->addTable("az2_node"); // count the number of nodes using the same type $query->addColumn("COUNT(fk_type)", "num"); $query->addWhereEqual("fk_type", $typeIdValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); $num = $queryResult->field("num"); $queryResult->free(); if ($num == 0) { // if no other nodes use this type, then delete the type $query = new DeleteQuery(); $query->setTable("az2_node_type"); $query->addWhereEqual("id", $typeIdValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); } // Delete the node's ancestory from the Ancestory table $this->clearNodeAncestory($idValue); }
/** * Set what module and action the plugin urls should use. This is needed when * generating markup to be used in another context. * * @param string $module * @param string $action * @return void * @access public * @since 2/18/08 */ public final function setLocalModuleAndAction($module, $action) { ArgumentValidator::validate($module, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($action, NonzeroLengthStringValidatorRule::getRule()); $this->localModule = $module; $this->localAction = $action; }
/** * Construct * * @param string $xmlSchemaPath * @return null * @access public * @since 5/19/08 */ public function __construct($xmlSchemaPath) { ArgumentValidator::validate($xmlSchemaPath, NonzeroLengthStringValidatorRule::getRule()); $this->xmlSchemaPath = $xmlSchemaPath; }
/** * Add a value, escaping it and surrounding it with quotes. * * @param string $column * @param string $value * @return void * @access public * @since 3/8/07 */ function addValue($column, $value) { ArgumentValidator::validate($column, NonzeroLengthStringValidatorRule::getRule()); ArgumentValidator::validate($value, StringValidatorRule::getRule()); $this->addRawValue($column, $this->_adapter->quote($value)); }
/** * 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() { $idManager = Services::getService("Id"); $setManager = Services::getService("Sets"); $repositoryManager = Services::getService("Repository"); $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository")); $slideshowAsset = $repository->getAsset($idManager->getId(RequestContext::value('slideshow_id'))); // Instantiate the wizard, then add our steps. // fetch current slideshow slides HERE!!! $wizard = SimpleStepWizard::withDefaultLayout(); // :: Name and Description :: $step = $wizard->addStep("namedescstep", new WizardStep()); $step->setDisplayName(_("Title & Description")); // Create the properties. $displayNameProp = $step->addComponent("display_name", new WTextField()); $displayNameProp->setValue($slideshowAsset->getDisplayName()); $displayNameProp->setErrorText("<nobr>" . _("A value for this field is required.") . "</nobr>"); $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); // $displayNameProp->setDefaultValue(_("Default Asset Name")); // $displayNameProp->setErrorString(" <span style='color: #f00'>* "._("The name must not start with a space.")."</span>"); $descriptionProp = $step->addComponent("description", WTextArea::withRowsAndColumns(5, 30)); $descriptionProp->setValue($slideshowAsset->getDescription()); // $descriptionProp->setDefaultValue(_("Default Asset description.")); // Create the step text ob_start(); print "\n<h2>" . _("Title") . "</h2>"; print "\n" . _("The title of this <em>SlideShow</em>: "); print "\n<br />[[display_name]]"; print "\n<h2>" . _("Description") . "</h2>"; print "\n" . _("A description of this <em>SlideShow</em>: "); print "\n<br />[[description]]"; print "\n<div style='width: 400px'> </div>"; $step->setContent(ob_get_contents()); ob_end_clean(); // :: Slides :: $slideStep = $wizard->addStep("slidestep", new WizardStep()); $slideStep->setDisplayName(_("Slides")); $multField = $slideStep->addComponent("slides", new SlideOrderedRepeatableComponentCollection()); $multField->setStartingNumber(0); $multField->setRemoveLabel(_("Remove Slide")); $property = $multField->addComponent("slideId", new AssetComponent()); $property->setParent($multField); $property = $multField->addComponent("title", new WTextField()); $property->setSize(20); $property = $multField->addComponent("caption", WTextArea::withRowsAndColumns(5, 30)); $property = $multField->addComponent("text_position", new WSelectList()); $property->setValue("right"); $property->addOption("right", _("text on right")); $property->addOption("left", _("text on left")); $property->addOption("bottom", _("text on bottom")); $property->addOption("top", _("text on top")); $property->addOption("none", _("no text (media-only)")); $property->addOption("center", _("text centered (no-media)")); $property = $multField->addComponent("show_target_metadata", new WCheckBox()); $property->setChecked(false); $property->setLabel(_("Display metadata from media?")); ob_start(); print "\n<table border=\"0\">"; print "\n<tr><td>"; print _("Title") . ": "; print "\n</td><td>"; print "[[title]]"; print "\n</td></tr>"; print "\n<tr><td>"; print _("Caption") . ": "; print "\n</td><td>"; print "[[caption]]"; print "\n</td></tr>"; print "\n<tr><td>"; print _("Text Position") . ": "; print "\n</td><td>"; print "[[text_position]]"; print "\n</td></tr>"; print "\n<tr><td>"; print "[[show_target_metadata]]"; print "\n</td><td>"; print "\n</td></tr>"; print "</table>"; $multField->setElementLayout(ob_get_contents()); ob_end_clean(); ob_start(); print "<h2>" . _("Slides") . "</h2>"; print "[[slides]]"; $slideStep->setContent(ob_get_contents()); ob_end_clean(); // Add the current assets to the list. $textPositionId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position"); $showMetadataId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata"); $targetId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id"); $slideIterator = $slideshowAsset->getAssets(); $slideOrder = $setManager->getPersistentSet($slideshowAsset->getId()); $orderedSlides = array(); $orderlessSlides = array(); while ($slideIterator->hasNext()) { $slideAsset = $slideIterator->next(); $slideId = $slideAsset->getId(); /* // DEBUG $records =$slideAsset->getRecordsByRecordStructure($idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure")); $myCrapRecord =$records->next(); require_once(POLYPHONY."/main/library/DataManagerGUI/SimpleRecordPrinter.class.php"); SimpleRecordPrinter::printRecord($myCrapRecord->_record); // END */ $collection = array(); $collection['slideId'] = $slideId; //->getIdString(); $collection['title'] = $slideAsset->getDisplayName(); $collection['caption'] = $slideAsset->getDescription(); $textPositionIterator = $slideAsset->getPartValuesByPartStructure($textPositionId); if ($textPositionIterator->hasNext()) { $textPosition = $textPositionIterator->next(); $collection['text_position'] = $textPosition->asString(); } else { $collection['text_position'] = "right"; } $showMetadataIterator = $slideAsset->getPartValuesByPartStructure($showMetadataId); if ($showMetadataIterator->hasNext()) { $showMetadata = $showMetadataIterator->next(); $collection['show_target_metadata'] = $showMetadata->value(); } else { $collection['show_target_metadata'] = FALSE; } $assetIdIterator = $slideAsset->getPartValuesByPartStructure($targetId); if ($assetIdIterator->hasNext()) { $id = $assetIdIterator->next(); $rule = NonzeroLengthStringValidatorRule::getRule(); if ($rule->check($id->asString())) { $collection['_assetId'] = new HarmoniId($id->asString()); } } if ($slideOrder->isInSet($slideId)) { $orderedSlides[$slideOrder->getPosition($slideId)] = $collection; } else { $orderlessSlides[] = $collection; } } // add them in order ksort($orderedSlides); foreach ($orderedSlides as $slide) { $multField->addValueCollection($slide); } foreach ($orderlessSlides as $slide) { $multField->addValueCollection($slide); } // :: Effective/Expiration Dates :: // $step =$wizard->addStep("datestep", new WizardStep()); // $step->setDisplayName(_("Effective Dates")." ("._("optional").")"); // // // Create the properties. // $property =$step->addComponent("effective_date", new WTextField()); // // $property->setDefaultValue(); // // $property->setErrorString(" <span style='color: #f00'>* "._("The date must be of the form YYYYMMDD, YYYYMM, or YYYY.")."</span>"); // // $property =$step->addComponent("expiration_date", new WTextField()); // // $property->setDefaultValue(); // // $property->setErrorString(" <span style='color: #f00'>* "._("The date must be of the form YYYYMMDD, YYYYMM, or YYYY.")."</span>"); // // // Create the step text // ob_start(); // print "\n<h2>"._("Effective Date")."</h2>"; // print "\n". // _("The date that this <em>Slide-Show</em> becomes effective: "); // print "\n<br />[[effective_date]]"; // // print "\n<h2>"._("Expiration Date")."</h2>"; // print "\n"._("The date that this <em>Slide-Show</em> expires: "); // print "\n<br />[[expiration_date]]"; // $step->setContent(ob_get_contents()); // ob_end_clean(); return $wizard; }
/** * Update the value for this Part. * * @param object mixed $value (original type: java.io.Serializable) * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT} * * @access public */ function updateValue($value) { if (!is_null($value)) { ArgumentValidator::validate($value, NonzeroLengthStringValidatorRule::getRule()); } // Store the name in the object in case its asked for again. $this->_type = $value; // then write it to the database. $dbHandler = Services::getService("DatabaseManager"); // If we have a key, make sure it exists. if ($this->_type && $this->_type != "NULL") { // Check to see if the type is in the database $query = new SelectQuery(); $query->addTable("dr_mime_type"); $query->addColumn("id"); $query->addWhere("type = '" . $this->_type . "'"); $result = $dbHandler->query($query, $this->_configuration->getProperty("database_index")); // If it doesn't exist, insert it. if (!$result->getNumberOfRows()) { $query = new InsertQuery(); $query->setTable("dr_mime_type"); $query->setAutoIncrementColumn("id", "dr_mime_type_id_seq"); $query->setColumns(array("type")); $query->setValues(array("'" . addslashes($this->_type) . "'")); $result2 = $dbHandler->query($query, $this->_configuration->getProperty("database_index")); $mimeId = "'" . $result2->getLastAutoIncrementValue() . "'"; } else { $mimeId = "'" . $result->field("id") . "'"; } $result->free(); } else { $mimeId = "NULL"; } // add its id to the file. $query = new UpdateQuery(); $query->setTable("dr_file"); $query->setColumns(array("fk_mime_type")); $query->setValues(array($mimeId)); $query->addWhere("id = '" . $this->_recordId->getIdString() . "'"); // run the query $dbHandler->query($query, $this->_configuration->getProperty("database_index")); $this->_asset->updateModificationDate(); }
/** * Get the unique Id with this String representation or create a new unique * Id with this representation. * * @param string $idString * * @return object Id * * @throws object IdException An exception with one of the following * messages defined in org.osid.id.IdException: {@link * org.osid.id.IdException#OPERATION_FAILED OPERATION_FAILED}, * {@link org.osid.id.IdException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.id.IdException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.id.IdException#UNIMPLEMENTED UNIMPLEMENTED}, {@link * org.osid.id.IdException#NULL_ARGUMENT NULL_ARGUMENT} * * @access public */ function getId($idString) { // if (isset($this->_ids[$idString])) { // print "id:". $idString." and ".$this->_ids[$idString]->getIdString()."<br/>"; // return $this->_ids[$idString]; // } ArgumentValidator::validate($idString, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), NumericValidatorRule::getRule())); $id = new HarmoniId($idString); // cache the id // $this->_ids[$idString] = $id; return $id; }
/** * Returns <code>true</code> if the node with the specified id (string) exists. * @access public * @param mixed id The id of the node. * @return boolean <code>true</code> if the node with the specified id is in the tree; else <code>false</code>. */ function nodeExists($id) { // ** parameter validation ArgumentValidator::validate($id, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), IntegerValidatorRule::getRule()), true); // ** end of parameter validation return isset($this->_nodes[$id]); }
/** * Returns a new {@link URLWriter} from the {@link RequestHandler}, assigning * the module/action passed or keeping the current module/action. The new url * will have the base specified rather than MYURL * This method will return a url with no context data, only the variables passed. * * @param optional string $module * @param optional string $action * @param optional array $variables * @return ref object URLWriter * @access public */ function mkURLWithoutContextWithBase($base, $module = null, $action = null, $variables = null) { ArgumentValidator::validate($base, NonzeroLengthStringValidatorRule::getRule()); // create a new URLWriter from the RequestHandler $this->_checkForHandler(); $url = $this->_requestHandler->createURLWriter($base); // Set the Module and Action if ($module != null && $action != null) { $url->setModuleAction($module, $action); } else { $harmoni = Harmoni::instance(); list($module, $action) = explode(".", $harmoni->getCurrentAction()); if (!$module) { list($module, $action) = explode(".", $this->getRequestedModuleAction()); } $url->setModuleAction($module, $action); } // Addition $variables passed if (is_array($variables)) { $url->setValues($variables); } // If the requested action requires a user request token to prevent // cross-site request forgeries, add the token. $harmoni = Harmoni::instance(); if ($harmoni->ActionHandler->requiresRequestToken($module, $action)) { $this->startNamespace('request'); $url->setValue('token', $harmoni->ActionHandler->getRequestToken()); $this->endNamespace(); } return $url; }
/** * Add a new image at the path specified. * * @param object Harmoni_Filing_FileInterface $image * @param string $filename * @param string $prefixPath * @return null * @access public * @since 5/15/08 */ public function addImage(Harmoni_Filing_FileInterface $image, $filename, $prefixPath = '') { if (!$this->canModify()) { throw new PermissionDeniedException(); } ArgumentValidator::validate($filename, NonzeroLengthStringValidatorRule::getRule()); $path = trim($prefixPath, '/'); if (strlen($path)) { $path = $path . '/' . $filename; } else { $path = $filename; } // Delete the old image $query = new DeleteQuery(); $query->setTable('segue_site_theme_image'); $query->addWhereEqual('fk_theme', $this->id); $query->addWhereEqual('path', $path); $dbc = Services::getService('DatabaseManager'); $dbc->query($query, $this->databaseIndex); $query = new InsertQuery(); $query->setTable('segue_site_theme_image'); $query->addValue('fk_theme', $this->id); $query->addValue('mime_type', $image->getMimeType()); $query->addValue('path', $path); $query->addValue('size', $image->getSize()); $query->addValue('data', base64_encode($image->getContents())); $dbc = Services::getService('DatabaseManager'); $dbc->query($query, $this->databaseIndex); }
/** * Answer the slot that matches the given site id * * @param string $siteId * @return object Slot * @access public * @since 8/16/07 */ public function getSlotBySiteId($siteId) { ArgumentValidator::validate($siteId, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), ExtendsValidatorRule::getRule('Id'))); if (is_object($siteId)) { $tmp = $siteId; unset($siteId); $siteId = $tmp->getIdString(); } // Check our cache foreach ($this->slots as $slot) { if ($slot->getSiteId() == $siteId && !$slot->isAlias()) { return $slot; } } // Look up the slot in the database; try { $result = $this->getSlotByIdResult_Harmoni_Db($siteId); } catch (UnknownIdException $e) { $result = $this->getSlotByIdResult($siteId); } if ($result->getNumberOfRows()) { $slots = $this->getSlotsFromQueryResult($result); if (count($slots) !== 1) { throw new Exception("Mismached number of slots."); } $slot = current($slots); $this->slots[$slot->getShortname()] = $slot; } else { throw new UnknownIdException("No Slot Found for site id, '{$siteId}'"); } return $slot; }