<?php /* Htmlizes the definition and comment, then builds the SimilarRecord */ require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); $definitionId = util_getRequestParameter('definitionId'); $definitionInternalRep = util_getRequestParameter('definitionInternalRep'); $commentInternalRep = util_getRequestParameter('commentInternalRep'); $sourceId = util_getRequestParameter('sourceId'); $lexemIds = util_getRequestCsv('lexemIds'); $d = Definition::get_by_id($definitionId); $d->internalRep = AdminStringUtil::internalizeDefinition($definitionInternalRep, $sourceId); $d->htmlRep = AdminStringUtil::htmlize($d->internalRep, $sourceId); $d->sourceId = $sourceId; $commentInternalRep = AdminStringUtil::internalizeDefinition($commentInternalRep, $sourceId); $commentHtmlRep = AdminStringUtil::htmlize($commentInternalRep, $sourceId); $sim = SimilarRecord::create($d, $lexemIds); $data = $sim->getJsonFriendly(); $data['htmlRep'] = $d->htmlRep; $data['commentHtmlRep'] = $commentHtmlRep; print json_encode($data);
util_redirect('definitionEdit.php'); } } $source = Source::get_by_id($definition->sourceId); if (!$acceptButton && !$moveButton) { // If a button was pressed, then this is a POST request and the URL // does not contain the definition ID. RecentLink::createOrUpdate(sprintf("Definiție: %s (%s)", $definition->lexicon, $source->shortName)); } SmartyWrap::assign('isOCR', $isOCR); if ($definitionId) { SmartyWrap::assign('definitionId', $definitionId); } SmartyWrap::assign('def', $definition); SmartyWrap::assign('source', $source); SmartyWrap::assign('sim', SimilarRecord::create($definition, $lexemIds)); SmartyWrap::assign('user', User::get_by_id($definition->userId)); SmartyWrap::assign('comment', $comment); SmartyWrap::assign('commentUser', $commentUser); SmartyWrap::assign('lexemIds', $lexemIds); SmartyWrap::assign('typos', Typo::get_all_by_definitionId($definition->id)); SmartyWrap::assign('homonyms', loadSetHomonyms($lexems)); SmartyWrap::assign("allModeratorSources", Model::factory('Source')->where('canModerate', true)->order_by_asc('displayOrder')->find_many()); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::addCss('jqueryui', 'select2'); SmartyWrap::addJs('jquery', 'jqueryui', 'select2', 'select2Dev', 'definitionEdit'); SmartyWrap::displayAdminPage('admin/definitionEdit.tpl'); /** * Load all lexems having the same form as one of the given lexems, but exclude the given lexems. **/ function loadSetHomonyms($lexems)