/**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 3
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));
         }
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 8
0
 /**
  * Constructor.
  * 
  * @param string $idString
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 2/24/06
  */
 function LDAPGroup($idString, $type, $configuration, $authNMethod)
 {
     ArgumentValidator::validate($idString, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($type, ExtendsValidatorRule::getRule("Type"), true);
     ArgumentValidator::validate($configuration, ExtendsValidatorRule::getRule("Properties"), true);
     ArgumentValidator::validate($authNMethod, ExtendsValidatorRule::getRule("LDAPAuthNMethod"), true);
     $this->_type = $type;
     $this->_idString = $idString;
     $this->_configuration = $configuration;
     $this->_authNMethod = $authNMethod;
 }
Esempio n. 9
0
 /**
  * Answer a new MediaAsset that wraps the Asset identified with the passed Ids.
  * 
  * @param object Id $repositoryId
  * @param object Id $assetId
  * @return object MediaAsset
  * @access public
  * @since 4/27/07
  * @static
  */
 public static function withIds($repositoryId, $assetId, $recordId)
 {
     ArgumentValidator::validate($repositoryId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($assetId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($recordId, ExtendsValidatorRule::getRule("Id"));
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($repositoryId);
     $asset = $repository->getAsset($assetId);
     $mediaFile = new MediaFile(MediaAsset::withAsset($asset), $asset->getRecord($recordId));
     return $mediaFile;
 }
Esempio n. 10
0
 /**
  * Prints current debug output using NewWindowDebugHandlerPrinter
  * @access public
  * @return void
  * @static
  */
 static function printAll($debugPrinter = null)
 {
     // ** parameter validation
     $extendsRule = ExtendsValidatorRule::getRule("DebugHandlerPrinterInterface");
     ArgumentValidator::validate($debugPrinter, OptionalRule::getRule($extendsRule), true);
     // ** end of parameter validation
     if (is_null($debugPrinter)) {
         $debugPrinter = new NewWindowDebugHandlerPrinter();
     }
     $debugPrinter->printDebugHandler(Services::getService("Debug"));
 }
Esempio n. 11
0
 /**
  * The constructor.
  * @param object Hierarchy $hierarchy
  * @param object Node $node
  * @access public
  */
 function HarmoniAgent($hierarchy, $node)
 {
     // ** parameter validation
     ArgumentValidator::validate($node, ExtendsValidatorRule::getRule("Node"), true);
     ArgumentValidator::validate($hierarchy, ExtendsValidatorRule::getRule("Hierarchy"), true);
     $this->_hierarchy = $hierarchy;
     $this->_node = $node;
     // set the local _idString
     $id = $this->getId();
     $this->_idString = $id->getIdString();
 }
Esempio n. 12
0
 function assertNotEqualIds($idA, $idB)
 {
     //parameter validation
     ArgumentValidator::validate($idA, ExtendsValidatorRule::getRule("Id"), true);
     ArgumentValidator::validate($idB, ExtendsValidatorRule::getRule("Id"), true);
     if ($idA->isEqual($idB)) {
         $this->assertFalse(true);
         print "<p align=center><font size=4 color=#FF4444>The Ids with strings '" . $idA->getIdString() . "' and '" . $idB->getIdString() . "' <b>should NOT</b> be equal. </font></p>\n";
     } else {
         $this->assertFalse(false);
     }
 }
Esempio n. 13
0
 /**
  * adds a new $rule to $key, which if fails when validated throws $error
  * @param string $key the key to associate the rule with
  * @param ref object ValidatorRule $rule the ValidatorRule object to be added
  * @param optional string $message the error to throw if the validation fails
  * @access public
  * @return void 
  **/
 function addRule($key, $rule, $message = null, $type = '')
 {
     ArgumentValidator::validate($rule, ExtendsValidatorRule::getRule("ValidatorRuleInterface"));
     ArgumentValidator::validate($key, StringValidatorRule::getRule());
     if ($message !== null) {
         ArgumentValidator::validate($message, StringValidatorRule::getRule(), true);
     }
     if (!isset($this->_rules[$key])) {
         $this->_rules[$key] = array();
     }
     $this->_rules[$key][] = array($rule, $message, $type);
 }
 /**
  * Create wizard steps for editing the values of the specified Record and
  * add them to the wizard.
  * 
  * @param object $record
  * @param object $wizard The wizard to add the steps to.
  * @param array $partStructures An ordered array of the partStructures to include.
  * @return void
  * @access public
  * @since 10/19/04
  */
 function createWizardStepsForPartStructures(Record $record, Wizard $wizard, array $partStructures)
 {
     ArgumentValidator::validate($partStructures, ArrayValidatorRuleWithRule::getRule(ExtendsValidatorRule::getRule("PartStructure")));
     $recordStructure = $record->getRecordStructure();
     $recordStructureId = $recordStructure->getId();
     /* build an interface for editing this record! */
     $m = '';
     $step = $wizard->addStep("record", new WizardStep());
     $step->setDisplayName(dgettext("polyphony", "Edit Record"));
     // Go through each of the PartStructures and create a component for it
     foreach (array_keys($partStructures) as $key) {
         $partStructure = $partStructures[$key];
         $m .= $this->_addComponentForPartStructure($step, $record, $partStructure);
         $m .= "<br/>";
     }
     $step->setContent($m);
 }
 function returnSearchString()
 {
     $mgr = Services::getService("SchemaManager");
     $typeMgr = Services::getService("DataTypeManager");
     $def = $mgr->getSchemaByID($this->_schemaID);
     $def->load();
     $fieldID = $def->getFieldIDFromLabel($this->_label);
     $field = $def->getField($fieldID);
     // first check if the $value we have is of the correct data type
     $extendsRule = ExtendsValidatorRule::getRule("HarmoniIterator");
     if (!$typeMgr->isObjectOfDataType($this->_value, $field->getType()) && !$extendsRule->check($this->_value)) {
         throwError(new Error("Cannot take a '" . get_class($this->_value) . "' object as search criteria\n\t\t\tfor field '{$this->_label}'; a '" . $field->getType() . "' is required.", "FieldValueSearch", true));
     }
     $class = $typeMgr->storablePrimitiveClassForType($field->getType());
     eval('$string = ' . $class . '::makeSearchString($this->_value, $this->_comparison);');
     return "(dm_record_field.fk_schema_field='" . addslashes($fieldID) . "' AND " . $string . " AND dm_record_field.active=1)";
 }
Esempio n. 16
0
 /**
  * Adds the given menu item to this container. The only difference from the
  * familiar <code>add()</code> method of the Container class is that now
  * explicit checking is performed to make sure that the given component
  * is indeed a <code>menuItem</code> and not just any component.
  * <br /><br />
  * Warning: The <code>add()</code> method allows the user to add the same
  * instance of an object multiple times. With menus, this is extremely unadvised because
  * the menu might end up with multiple selected menu items at the same time.
  * @access public
  * @param ref object menuItem The menuItem to add. If it is selected, then the
  * old selected menu item will be automatically deselected.
  * @param string width The available width for the added menuItem. If null, will be ignored.
  * @param string height The available height for the added menuItem. If null, will be ignored.
  * @param integer alignmentX The horizontal alignment for the added menuItem. Allowed values are 
  * <code>LEFT</code>, <code>CENTER</code>, and <code>RIGHT</code>.
  * If null, will be ignored.
  * @param integer alignmentY The vertical alignment for the added menuItem. Allowed values are 
  * <code>TOP</code>, <code>CENTER</code>, and <code>BOTTOM</code>.
  * If null, will be ignored.
  * @return ref object The menuItem that was just added.
  **/
 function add($menuItem, $width = null, $height = null, $alignmentX = null, $alignmentY = null)
 {
     // ** parameter validation
     // some weird class checking here - would have been much simpler if PHP
     // supported multiple inheritance
     $rule1 = ExtendsValidatorRule::getRule("MenuItemLink");
     $rule2 = ExtendsValidatorRule::getRule("MenuItemHeading");
     $rule3 = ExtendsValidatorRule::getRule("MenuItem");
     $rule4 = ExtendsValidatorRule::getRule("SubMenu");
     ArgumentValidator::validate($menuItem, OrValidatorRule::getRule(OrValidatorRule::getRule(OrValidatorRule::getRule($rule1, $rule2), $rule3), $rule4), true);
     // ** end of parameter validation
     parent::add($menuItem, $width, $height, $alignmentX, $alignmentY);
     // if the given menuItem is selected, then select it
     if ($menuItem instanceof MenuItemLink) {
         if ($menuItem->isSelected()) {
             $id = $this->getComponentsCount();
             $this->select($id);
         }
     }
     return $menuItem;
 }
 /**
  * Constructor
  * 
  * @param object $iterator The iterator to print.
  * @param integer $numColumns The number of result columns to print on each page.
  * @param integer $numResultsPerPage The number of iterator items to print on a page.
  * @param mixed $callbackFunction The name of the function that will be called to
  *			to print each result. If null, the first parameter is assumed to be an
  *			array of gui components that can be rendered without further processing.
  * @param optional mixed $callbackArgs Any additional arguements will be stored
  *			and passed on to the callback function.
  * @access public
  * @date 8/5/04
  */
 function ArrayResultPrinter($array, $numColumns, $numResultsPerPage, $callbackFunction = NULL)
 {
     ArgumentValidator::validate($array, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($numColumns, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($numResultsPerPage, IntegerValidatorRule::getRule());
     //		ArgumentValidator::validate($callbackFunction, StringValidatorRule::getRule());
     if (is_null($callbackFunction)) {
         ArgumentValidator::validate($array, ArrayValidatorRuleWithRule::getRule(ExtendsValidatorRule::getRule("ComponentInterface")));
     }
     $this->_array = $array;
     $this->_numColumns = $numColumns;
     $this->_pageSize = $numResultsPerPage;
     $this->_callbackFunction = $callbackFunction;
     $this->_callbackParams = array();
     $args = func_get_args();
     for ($i = 4; $i < count($args); $i++) {
         $this->_callbackParams[] = $args[$i];
     }
     $this->_resultLayout = new TableLayout($this->_numColumns);
     $this->_resultLayout->printEmptyCells = false;
     $this->_linksStyleCollection = new StyleCollection("*.result_page_links", "result_page_links", "Result Page Links", "Links to other pages of results.");
     // 		$this->_linksStyleCollection->addSP(new MarginTopSP("10px"));
 }
Esempio n. 18
0
 /**
  * Adds a new menu to this theme.
  * @access public
  * @param ref object menu A <code>Menu</code> object to be added to this theme.
  * @param integer level A positive integer specifying the <code>level</code> of the
  * menu that is being added. Only one menu can exist at any given level. 
  * Levels cannot be skipped. Levels allow the user to create a hierarchy of menus.
  **/
 function addMenu($menu, $level)
 {
     // ** parameter validation
     ArgumentValidator::validate($menu, ExtendsValidatorRule::getRule("Menu"), true);
     $greaterThanZero = $level > 0;
     ArgumentValidator::validate($greaterThanZero, TrueValidatorRule::getRule(), true);
     // ** end of parameter validation
     // two things need to be true in order for this menu to be added
     // 1) no levels before the given are empty
     // 2) no menu has been set for this level already
     if ($level > 1 && !isset($this->_menus[$level - 1])) {
         $err = "Error when adding a menu to a theme: all prior menu levels must be non-empty.";
         throwError(new Error($err, "GUIManager", false));
         return;
     }
     if (isset($this->_menus[$level])) {
         $err = "A menu has already been set for the given level.";
         throwError(new Error($err, "GUIManager", false));
         return;
     }
     // now add the menu
     $this->_menus[$level] = $menu;
 }
 /**
  * Wrap the given component as a droppable element (that can have draggables dropped on it.
  * 
  * @param object Component $component
  * @param string $id
  * @return void
  * @access public
  * @since 4/7/06
  */
 function wrapAsDroppable($component, $id, $allowedDraggables)
 {
     ArgumentValidator::validate($component, ExtendsValidatorRule::getRule("Component"));
     if (!count($allowedDraggables)) {
         return;
     }
     // Note: Ids are prepended with 'comp_' due to XHTML requiring the Id to start with a letter.
     $draggablesArray = "new Array('comp_" . implode("', 'comp_", $allowedDraggables) . "')";
     $component->setPreHTML("<div id='comp_{$id}'>" . $component->getPreHTML($null = null));
     $dropConfirm = _('Are you sure that you want to move this element here?');
     $harmoni = Harmoni::instance();
     $url = str_replace("XXXdraggableXXX", "' + draggableElement.id.replace(/^comp_/, '') + '", str_replace("XXXdroppableXXX", "' + droppableElement.id.replace(/^comp_/, '') + '", str_replace('&amp;', '&', $harmoni->request->quickURL('ui2', 'moveComponent', array('component' => "XXXdraggableXXX", 'destination' => "XXXdroppableXXX", 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->_action)))));
     $component->setPostHTML($component->getPostHTML($null = null) . "\n</div>\n\n<script type='text/javascript'>\n/* <![CDATA[ */\n\t\n\tDroppables.add('comp_{$id}', {\n\t\t\taccept: " . $draggablesArray . ",\n\t\t\thoverclass: 'drop_hover',\n\t\t\tonDrop: function (draggableElement, droppableElement) {\n\t\t\t\tDraggables.deactivate();\n\t\t\t\t\n// \t\t\t\tif (confirm ('{$dropConfirm}'))\n// \t\t\t\t{\t\t\t\t\t\n\t\t\t\t\tDraggables.drags.each(function(draggable) {draggable.options.revert = false;});\n\t\t\t\t\t\n\t\t\t\t\tdroppableElement.style.border ='4px inset #F00';\n\t\t\t\t\t\n\t\t\t\t\tvar moveUrl = '" . $url . "';\n\t\t\t\t\twindow.location = moveUrl;\n// \t\t\t\t}\n\t\t\t}\n\t\t});\n\n/* ]]> */\n</script>\n");
 }
Esempio n. 20
0
 /**
  * Adds one StyleComponent to this StyleProperty.
  * @access public
  * @param ref object A StyleComponent object.
  **/
 function addSC($sc)
 {
     ArgumentValidator::validate($sc, ExtendsValidatorRule::getRule("StyleComponentInterface"), true);
     //		$this->_SCs[] =$sc;
     //		print "_SCs[".get_class($sc)."] = ".$sc->getDisplayName().";<br/>";
     $this->_SCs[get_class($sc)] = $sc;
 }
 /**
  * WARNING: NOT IN OSID!
  * 
  * Returns a list of all explicit authorizations for a given user across all functions and qualifiers.
  * @param ref object $agentId The agent's ID.
  * @param boolean $isActiveNowOnly Include only active authorizations.
  *
  * @return ref object Iterator
  **/
 function getAllExplicitAZsForAgent(Id $agentId, $isActiveNowOnly)
 {
     // ** parameter validation
     ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"), true);
     ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
     // ** end
     $authorizations = $this->_cache->getAZs($agentId->getIdString(), null, null, null, true, $isActiveNowOnly);
     // isActiveNowOnly
     $iter = new AuthZ2_AuthorizationIterator($authorizations);
     return $iter;
 }
Esempio n. 22
0
 /**
  * Sets the Id for this component to store and display
  * @param object Id $id
  * @access public
  * @return void
  */
 function setValue($id)
 {
     ArgumentValidator::validate($id, ExtendsValidatorRule::getRule("Id"), true);
     $this->_id = $id;
 }
 /**
  * Set the input component
  * 
  * @param object WComponent $input
  * @return object WComponent
  * @access public
  * @since 10/20/05
  */
 function setInputComponent($input)
 {
     ArgumentValidator::validate($input, ExtendsValidatorRule::getRule("WizardComponent"));
     ArgumentValidator::validate($input, HasMethodsValidatorRule::getRule("addOnChange"));
     $this->_input = $input;
     $this->_input->setParent($this);
     return $this->_input;
 }
Esempio n. 24
0
 /**
  *  Fetches and returns an array of DMRecord IDs from the database in one Query.
  * @return ref array Indexed by DMRecord ID, values are {@link DMRecord}s.
  * @param array $IDs
  * @param optional int $mode Specifies the mode the record should be fetched.
  * @param optional object $limitResults NOT YET IMPLEMENTED
  * criteria. If not specified, will fetch all IDs.
  */
 function fetchRecords($IDs, $mode = RECORD_CURRENT, $limitResults = null)
 {
     ArgumentValidator::validate($IDs, ArrayValidatorRuleWithRule::getRule(OrValidatorRule::getRule(StringValidatorRule::getRule(), IntegerValidatorRule::getRule())));
     ArgumentValidator::validate($mode, IntegerValidatorRule::getRule());
     $IDs = array_unique($IDs);
     // let's weed out those IDs that we can take from cache
     $fromCacheIDs = array();
     $fromDBIDs = array();
     if (count($this->_recordCache)) {
         foreach ($IDs as $id) {
             // only take from the cache if we have it cached, AND
             // what is cached is fetched at a higher/equal data-mode than what's requested
             if (isset($this->_recordCache[$id]) && $this->_recordCache[$id]->getFetchMode() >= $mode) {
                 $fromCacheIDs[] = $id;
             } else {
                 $fromDBIDs[] = $id;
             }
         }
     } else {
         $fromDBIDs = $IDs;
     }
     $records = array();
     // put all the records from the cache into the array
     foreach ($IDs as $id) {
         if (isset($this->_recordCache[$id])) {
             $records[$id] = $this->_recordCache[$id];
         }
     }
     if (count($fromDBIDs)) {
         // first, make the new query
         $query = new SelectQuery();
         $this->_setupSelectQuery($query, $mode);
         // and now, go through the records we already have cached but are fetching more information for,
         // and make sure that we don't fetch information for fields that are already fetched.
         $alreadyFetchedFields = array();
         // and, build the WHERE clause while we're at it.
         $t = array();
         foreach ($fromDBIDs as $id) {
             $t[] = "dm_record.id='" . addslashes($id) . "'";
             if (isset($this->_recordCache[$id])) {
                 $alreadyFetchedFields = array_unique(array_merge($alreadyFetchedFields, $this->_recordCache[$id]->getFetchedFieldIDs()));
             }
         }
         $query->addWhere("(" . implode(" OR ", $t) . ")");
         if (count($alreadyFetchedFields)) {
             $temp = array();
             foreach ($alreadyFetchedFields as $id) {
                 $temp[] = "dm_record_field.id != '" . addslashes($id) . "'";
             }
             $query->addWhere('(' . implode(" AND ", $temp) . ')');
         }
         $dbHandler = Services::getService("DatabaseManager");
         //			print "<PRE>" . MySQL_SQLGenerator::generateSQLQuery($query)."</PRE>";
         $result = $dbHandler->query($query, DATAMANAGER_DBID);
         if (!$result) {
             throwError(new UnknownDBError("RecordManager"));
         }
         // now, we need to parse things out and distribute the lines accordingly
         while ($result->hasMoreRows()) {
             $a = $result->getCurrentRow();
             $result->advanceRow();
             $id = $a['record_id'];
             $type = $a['fk_schema'];
             $vcontrol = $a['record_ver_control'];
             if (!isset($records[$id])) {
                 $schemaManager = Services::getService("SchemaManager");
                 $schema = $schemaManager->getSchemaByID($type);
                 $schema->load();
                 $records[$id] = new DMRecord($schema, $vcontrol ? true : false, $mode);
                 if ($this->_cacheMode) {
                     $this->_recordCache[$id] = $records[$id];
                 }
             }
             $records[$id]->takeRow($a);
             unset($a);
         }
         $result->free();
     }
     // make sure we found the data sets
     $rule = ExtendsValidatorRule::getRule("DMRecord");
     foreach ($IDs as $id) {
         if (!isset($records[$id]) || !$rule->check($records[$id])) {
             throw new UnknownIdException("DMRecord {$id} was requested, but not found.");
         }
         // and set the fetch mode.
         $records[$id]->setFetchMode($mode);
         //			print "<pre>";print_r($records[$id]);print "</pre>";
     }
     return $records;
 }
Esempio n. 25
0
    /**
     * Output the content that was returned from an action. This content should
     * have been created such that it is a type that this OutputHandler can deal
     * with.
     * 
     * @param mixed $returnedContent Content returned by the action
     * @param string $printedContent Additional content printed, but not returned.
     * @return void
     * @access public
     * @since 4/4/05
     */
    function output($returnedContent, $printedContent)
    {
        ArgumentValidator::validate($returnedContent, ExtendsValidatorRule::getRule("ComponentInterface"));
        $osidContext = $this->getOsidContext();
        $harmoni = $osidContext->getContext('harmoni');
        $doctypeDef = $this->_configuration->getProperty('document_type_definition');
        $doctype = $this->_configuration->getProperty('document_type');
        $characterSet = $this->_configuration->getProperty('character_set');
        try {
            $xmlns = " xmlns=\"" . $this->_configuration->getProperty('xmlns') . "\"";
        } catch (Exception $e) {
            $xmlns = "";
        }
        $head = $this->getHead();
        $cssBaseUrl = $this->_configuration->getProperty('css_url');
        $themeProperty = $this->_configuration->getProperty('css_url_theme_property');
        // Link to a CSS file if possible to enable browser caching.
        if (is_object($cssBaseUrl) && $cssBaseUrl instanceof UrlWriter && strlen($themeProperty)) {
            $theme = $this->getCurrentTheme();
            $harmoni->request->startNamespace(null);
            $cssBaseUrl->setValue($themeProperty, $theme->getIdString());
            $harmoni->request->endNamespace();
            // If the theme has non-default options, we need to pass those.
            if ($theme->supportsOptions()) {
                $optionsSess = $theme->getOptionsSession();
                if (!$optionsSess->usesDefaults()) {
                    $harmoni->request->startNamespace('theme_options');
                    foreach ($optionsSess->getOptions() as $option) {
                        if ($option->getValue() != $option->getDefaultValue()) {
                            $cssBaseUrl->setValue($option->getIdString(), $option->getValue());
                        }
                    }
                    $harmoni->request->endNamespace();
                }
            }
            // Add a dummy property to the end of the URL that looks like a .css
            // filename. Without this, archives of the site might not be hostable
            // since the webserver won't send the correct content-type for the CSS.
            $harmoni->request->startNamespace(null);
            $cssBaseUrl->setValue('css', $theme->getIdString() . '.css');
            $harmoni->request->endNamespace();
            $css = "<link rel='stylesheet' type='text/css' href='" . $cssBaseUrl->write() . "'/>";
        } else {
            $css = "<style type=\"text/css\">\n\t\t\t";
            $css .= str_replace("\n", "\n\t\t\t", $this->getCurrentTheme()->getCss());
            $css .= "\n\t\t</style>";
        }
        if (!headers_sent()) {
            header("Content-type: {$doctype}; charset={$characterSet}");
        }
        print <<<END
{$doctypeDef}
<html{$xmlns}>
\t<head>
\t\t<meta http-equiv="Content-Type" content="{$doctype}; charset={$characterSet}" />
\t\t
\t\t{$head}
\t\t
\t\t{$css}
\t</head>
\t<body>
\t\t{$printedContent}
\t\t
END;
        $this->getCurrentTheme()->printPage($returnedContent);
        print <<<END
\t</body>
</html>
END;
    }
Esempio n. 26
0
 /**
  * Sets the <code>Layout</code> of this container
  * @access public
  * @param ref object layout The Layout to assign to this container.
  **/
 function setLayout($layout)
 {
     // ** parameter validation
     $rule = ExtendsValidatorRule::getRule("LayoutInterface");
     ArgumentValidator::validate($layout, $rule, true);
     // ** end of parameter validation
     $this->_layout = $layout;
 }
Esempio n. 27
0
 /**
  * Checks if the given node is a parent of this node.
  * @access public
  * @param ref object node The child node to check.
  * @return boolean <code>true</code> if <code>$node</code> is a parent of this node.
  **/
 function isParent($node)
 {
     $extendsRule = ExtendsValidatorRule::getRule("TreeNodeInterface");
     ArgumentValidator::validate($node, $extendsRule, true);
     if (!isset($this->_parents[$node->_id])) {
         return false;
     }
     return $this->_parents[$node->_id]->_id === $node->_id;
 }
 /**
  * Tells the wizard component to update itself - this may include getting
  * form post data or validation - whatever this particular component wants to
  * do every pageload. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return boolean - TRUE if everything is OK
  */
 function update($fieldName)
 {
     $idManager = Services::getService("Id");
     $ok = true;
     //		$this->_removeElements(array(2));
     // first update all our components in the collections
     $toRemove = array();
     foreach (array_keys($this->_collections) as $key) {
         foreach (array_keys($this->_collections[$key]) as $name) {
             // 				print "$name in $key is a ".gettype($this->_collections[$key][$name])."<br/>";
             $rule = ExtendsValidatorRule::getRule("WizardComponent");
             if (!$rule->check($this->_collections[$key][$name])) {
                 continue;
             }
             if (!$this->_collections[$key][$name]->update($fieldName . "_" . $key . "_" . $name)) {
                 $ok = false;
             }
         }
         if ($this->_collections[$key]["_remove"]->getAllValues()) {
             $toRemove[] = $key;
         }
         $id = $idManager->getId(strval($key));
         if (isset($this->_collections[$key]["_moveToPosition"]) && isset($this->_collections[$key]["_moveToPositionChoice"]) && $this->_collections[$key]["_moveToPositionChoice"]->getAllValues() == 'true') {
             $this->_orderedSet->moveToPosition($id, $this->_collections[$key]["_moveToPosition"]->getAllValues());
         }
     }
     $this->_removeElements($toRemove);
     // then, check if any "buttons" or anything were pressed to add/remove elements
     $this->_addButton->update($fieldName . "_add");
     if ($this->_addButton->getAllValues()) {
         //			print "adding element.<br/>";
         $this->_addElement();
     }
     $this->rebuildPositionSelects();
     return $ok;
 }
 /**
  * Answer the length of time that this item should be cached for before checking
  * for a 304.
  * 
  * @return object Duration
  * @access private
  * @since 5/14/08
  */
 private function getValidDuration()
 {
     // Get the time from the call back and validate it.
     $valid = call_user_func($this->getValidDurationCallback);
     ArgumentValidator::validate($valid, ExtendsValidatorRule::getRule('Duration'));
     return $valid;
 }
Esempio n. 30
0
 /**
  * Answer all the items with this tag that match a particular list
  * 
  * @param array $items An array of TaggedItem objects
  * @return object TaggedItemIterator
  * @access public
  * @since 4/9/08
  */
 public function getItemsInList(array $items)
 {
     ArgumentValidator::validate($items, ArrayValidatorRuleWithRule::getRule(ExtendsValidatorRule::getRule('TaggedItem')));
     if (!count($items)) {
         return new HarmoniIterator(array());
     }
     $id = array();
     $system = $items[0]->getSystem();
     foreach ($items as $item) {
         if ($system != $item->getSystem()) {
             throw new Exception("getItemsInList() currently only supports items from the same system. If needed, this method should be updated.");
         }
         $ids[] = $item->getId();
     }
     return new HarmoniIterator($ids);
 }