/** * Funkce pro úpravu anotace value description */ function addValueDescriptionValue() { require_once JPATH_COMPONENT . DS . 'models' . DS . 'bkef.php'; $model = new BkefModel(); if ($_POST['potvrzeni'] == 'value') { //skutecne smazeme $xml = $model->load(JRequest::getInt('article')); $maId = intval(JRequest::getInt('maId', -1)); $fId = intval(JRequest::getInt('fId', -1)); $vdId = intval(JRequest::getInt('vdId', -1)); $valueDescription = $xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format[$fId]->ValueDescriptions[0]->ValueDescription[$vdId]; $valueDescription->addChild('Value', checknumber(JRequest::getString('value'))); $model->save(JRequest::getInt('article'), $xml->asXML()); $this->_redirect = 'index.php?option=com_bkef&task=format&article=' . JRequest::getInt('article') . '&maId=' . $maId . '&fId=' . $fId . '#valueDescriptions'; } elseif ($_POST['potvrzeni'] == 'interval') { //skutecne smazeme $xml = $model->load(JRequest::getInt('article')); $maId = intval(JRequest::getInt('maId', -1)); $fId = intval(JRequest::getInt('fId', -1)); $vdId = intval(JRequest::getInt('vdId', -1)); $valueDescription = $xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format[$fId]->ValueDescriptions[0]->ValueDescription[$vdId]; $interval = $valueDescription->addChild('Interval'); $leftBound = $interval->addChild('LeftBound'); $leftBound['type'] = JRequest::getString('leftBoundType'); $leftBound['value'] = checknumber(JRequest::getString('leftBoundValue')); $rightBound = $interval->addChild('RightBound'); $rightBound['type'] = JRequest::getString('rightBoundType'); $rightBound['value'] = checknumber(JRequest::getString('rightBoundValue')); $model->save(JRequest::getInt('article'), $xml->asXML()); $this->_redirect = 'index.php?option=com_bkef&task=format&article=' . JRequest::getInt('article') . '&maId=' . $maId . '&fId=' . $fId . '#valueDescriptions'; } else { //zobrazime dotaz require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'addValueDescriptionValue.html.php'; $view = new BkefViewAddValueDescriptionValue(); $view->xml = $model->load(JRequest::getInt('article')); $view->article = JRequest::getInt('article'); $view->maId = JRequest::getInt('maId'); $view->fId = JRequest::getInt('fId'); $view->vdId = JRequest::getInt('vdId'); $view->potvrzeni = JRequest::getString('type'); $view->display(); } }
/** * Funkce pro přidání hodnoty do value description */ function addValueDescriptionValue() { /*DONE*/ require_once JPATH_COMPONENT . DS . 'models' . DS . 'bkef.php'; $model = new BkefModel(); if ($_POST['potvrzeni'] == 'value' || $_POST['potvrzeni'] == 'regex' || $_POST['potvrzeni'] == 'interval') { //skutecne ukladame $xml = $model->load(JRequest::getInt('article')); $maId = intval(JRequest::getInt('maId', -1)); $fId = intval(JRequest::getInt('fId', -1)); $vdId = intval(JRequest::getInt('vdId', -1)); $metaAttribute = $xml->MetaAttributes[0]->MetaAttribute[$maId]; $valueDescription = $metaAttribute->Formats[0]->Format[$fId]->ValueDescriptions[0]->ValueDescription[$vdId]; if (!isset($valueDescription->Scope)) { $scope = $valueDescription->addChild('Scope'); } else { $scope = $valueDescription->Scope[0]; } //ulozime dle zvolene varianty if ($_POST['potvrzeni'] == 'value') { //smazeme nadbytecne hodnoty while (isset($scope->Interval[0])) { unset($scope->Interval[0]); } while (isset($scope->Regex[0])) { unset($scope->Regex[0]); } //pridame hodnotu $scope->addChild('Value', checknumber(JRequest::getString('value'))); } elseif ($_POST['potvrzeni'] == 'regex') { //smazeme nadbytecne hodnoty while (isset($scope->Interval[0])) { unset($scope->Interval[0]); } while (isset($scope->Value[0])) { unset($scope->Value[0]); } while (isset($scope->Regex[0])) { unset($scope->Regex[0]); } //pridame hodnotu $scope->addChild('Value', checknumber(JRequest::getString('value'))); } elseif ($_POST['potvrzeni'] == 'interval') { //smazeme nadbytecne hodnoty while (isset($scope->Value[0])) { unset($scope->Value[0]); } while (isset($scope->Interval[0])) { unset($scope->Interval[0]); } while (isset($scope->Regex[0])) { unset($scope->Regex[0]); } //TODO doresit moznost vice intervalu //pridame hodnotu $interval = $valueDescription->addChild('Interval'); if (JRequest::getString('leftBoundType') == 'closed') { $intClosure = 'closed'; } else { $intClosure = 'open'; } if (JRequest::getString('rightBoundType') == 'closed') { $intClosure .= 'Closed'; } else { $intClosure .= 'Open'; } $interval->addAttribute('closure', $intClosure); $interval->addAttribute('leftMargin', checknumber(JRequest::getString('leftBoundValue'))); $interval->addAttribute('rightMargin', checknumber(JRequest::getString('rightBoundValue'))); } //aktualizace data/casu posledni zmeny $xml->Header[0]->LastModified[0]->Author = $this->getUserName(); $xml->Header[0]->LastModified[0]->Timestamp = date('c'); $metaAttribute->LastModified[0]->Author = $this->getUserName(); $metaAttribute->LastModified[0]->Timestamp = date('c'); $metaAttribute->Formats[0]->Format[$fId]->LastModified[0]->Author = $this->getUserName(); $metaAttribute->Formats[0]->Format[$fId]->LastModified[0]->Timestamp = date('c'); //save $model->save(JRequest::getInt('article'), $xml->asXML()); $this->_redirect = 'index.php?option=com_bkef&task=format&article=' . JRequest::getInt('article') . '&maId=' . $maId . '&fId=' . $fId . '#valueDescriptions'; //--skutecne ukladame } else { //zobrazime dotaz require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'addValueDescriptionValue.html.php'; $view = new BkefViewAddValueDescriptionValue(); $view->xml = $model->load(JRequest::getInt('article')); $view->article = JRequest::getInt('article'); $view->maId = JRequest::getInt('maId'); $view->fId = JRequest::getInt('fId'); $view->vdId = JRequest::getInt('vdId'); $view->potvrzeni = JRequest::getString('type'); $view->display(); } }