/** * Save changes to context. * @return int the context ID */ function execute() { $rtDao =& DAORegistry::getDAO('RTDAO'); $context = $this->context; if (!isset($context)) { $context = new RTContext(); $context->setVersionId($this->versionId); } $context->setTitle($this->getData('title')); $context->setAbbrev($this->getData('abbrev')); $context->setCitedBy($this->getData('citedBy') == true); $context->setAuthorTerms($this->getData('authorTerms') == true); $context->setGeoTerms($this->getData('geoTerms') == true); $context->setDefineTerms($this->getData('defineTerms') == true); $context->setDescription($this->getData('description')); if (!isset($this->context)) { $context->setOrder(-1); } if (isset($this->context)) { $rtDao->updateContext($context); } else { $rtDao->insertContext($context); $this->contextId = $context->getContextId(); } return $this->contextId; }
/** * Parse context entity. * @param $context XMLNode * @return RTContext */ function &parseContext(&$context) { $newContext = new RTContext(); $numSearches = 0; foreach ($context->getChildren() as $attrib) { switch ($attrib->getName()) { case 'context_title': $newContext->title = $attrib->getValue(); break; case 'context_abbrev': $newContext->abbrev = $attrib->getValue(); break; case 'context_description': $newContext->description = $attrib->getValue(); break; case 'cites_context': $newContext->citedBy = true; break; case 'author_terms': $newContext->authorTerms = true; break; case 'geo_terms': $newContext->geoTerms = true; break; case 'define_terms': $newContext->defineTerms = true; break; case 'search': $newSearch =& $this->parseSearch($attrib); $newSearch->order = $numSearches++; $newContext->addSearch($newSearch); break; } } return $newContext; }
/** * Return RTContext object from database row. * @param $row array * @return RTContext */ function &_returnContextFromRow(&$row) { $context = new RTContext(); $context->setContextId($row['context_id']); $context->setVersionId($row['version_id']); $context->setTitle($row['title']); $context->setAbbrev($row['abbrev']); $context->setDescription($row['description']); $context->setCitedBy($row['cited_by']); $context->setAuthorTerms($row['author_terms']); $context->setGeoTerms($row['geo_terms']); $context->setDefineTerms($row['define_terms']); $context->setOrder($row['seq']); if (!HookRegistry::call('RTDAO::_returnContextFromRow', array(&$context, &$row))) { $searchesIterator =& $this->getSearches($row['context_id']); $context->setSearches($searchesIterator->toArray()); } return $context; }