/** * Save changes to version. * @return int the version ID */ function execute() { $rtDao =& DAORegistry::getDAO('RTDAO'); $version = $this->version; if (!isset($version)) { $version = new RTVersion(); } $version->setTitle($this->getData('title')); $version->setKey($this->getData('key')); $version->setLocale($this->getData('locale')); $version->setDescription($this->getData('description')); if (isset($this->version)) { $rtDao->updateVersion($this->journalId, $version); } else { $rtDao->insertVersion($this->journalId, $version); $this->versionId = $version->getVersionId(); } return $this->versionId; }
/** * Parse version entity. * @param $version XMLNode * @return RTVersion */ function &parseVersion(&$version) { $newVersion = new RTVersion(); $numContexts = 0; $newVersion->key = $version->getAttribute('id'); $newVersion->locale = $version->getAttribute('locale'); foreach ($version->getChildren() as $attrib) { switch ($attrib->getName()) { case 'version_title': $newVersion->title = $attrib->getValue(); break; case 'version_description': $newVersion->description = $attrib->getValue(); break; case 'context': $newContext =& $this->parseContext($attrib); $newContext->order = $numContexts++; $newVersion->addContext($newContext); break; } } return $newVersion; }
/** * Return RTVersion object from database row. * @param $row array * @return RTVersion */ function &_returnVersionFromRow(&$row) { $version = new RTVersion(); $version->setVersionId($row['version_id']); $version->setKey($row['version_key']); $version->setLocale($row['locale']); $version->setTitle($row['title']); $version->setDescription($row['description']); if (!HookRegistry::call('RTDAO::_returnVersionFromRow', array(&$version, &$row))) { $contextsIterator =& $this->getContexts($row['version_id']); $version->setContexts($contextsIterator->toArray()); } return $version; }