本文整理汇总了PHP中Phrase::markEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP Phrase::markEntities方法的具体用法?PHP Phrase::markEntities怎么用?PHP Phrase::markEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phrase
的用法示例。
在下文中一共展示了Phrase::markEntities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPage_Review
//.........这里部分代码省略.........
// user is a staff member allowed to review phrases
UI::redirectToURL(URL::toReview($repositoryID));
// redirect to review index page
} else {
// user is a guest taking part in the discussion only
$contents[] = new UI_Heading($languageData->getNameFull(), true);
$contents[] = new UI_Paragraph('This link has expired and is not valid anymore.');
$contents[] = new UI_Paragraph('The discussion has been closed. Thanks for your collaboration!');
}
} else {
// edits available for review
$form = new UI_Form(htmlspecialchars($currentPageURL), false);
$table = new UI_Table(array('', ''));
$table->setColumnPriorities(3, 9);
$contributorName = empty($editData[0]['real_name']) ? '<span class="text-muted">' . htmlspecialchars($editData[0]['username']) . '</span>' : htmlspecialchars($editData[0]['real_name']) . ' <span class="text-muted">(' . htmlspecialchars($editData[0]['username']) . ')</span>';
$buttonApprove = new UI_Form_Button('Approve', UI_Link::TYPE_SUCCESS, UI_Form_Button::ACTION_SUBMIT, 'review[action]', 'approve');
$buttonReviewLater = new UI_Form_Button('Review later', UI_Link::TYPE_UNIMPORTANT, UI_Form_Button::ACTION_SUBMIT, 'review[action]', 'reviewLater');
$buttonReject = new UI_Form_Button('Reject', UI_Link::TYPE_WARNING, UI_Form_Button::ACTION_SUBMIT, 'review[action]', 'reject');
$buttonApproveAllByContributor = new UI_Form_Button('Approve all from this contributor', UI_Link::TYPE_SUCCESS, UI_Form_Button::ACTION_SUBMIT, 'review[action]', 'approveAllFromThisContributor', 'return confirm(\'Are you sure you want to execute this batch operation? Danger: Validity checks (e.g. placeholders, whitespace, HTML) will not be performed!\');');
$buttonRejectAllByContributor = new UI_Form_Button('Reject all from this contributor', UI_Link::TYPE_DANGER, UI_Form_Button::ACTION_SUBMIT, 'review[action]', 'rejectAllFromThisContributor', 'return confirm(\'Are you sure you want to execute this batch operation?\');');
$actionButtons = new UI_Form_ButtonGroup(array($buttonApprove, $buttonReviewLater, $buttonReject), true);
if ($isAllowedToReview) {
$newValueEdit = new UI_Form_Textarea('', 'review[newValue]', $editData[0]['suggestedValue'], '', true, htmlspecialchars($editData[0]['suggestedValue']), UI_Form_Textarea::getOptimalRowCount($editData[0]['suggestedValue'], 2), Language::isLanguageRTL($languageID));
$newValueHTML = $newValueEdit->getHTML();
} else {
$newValueHTML = '<span dir="' . (Language::isLanguageRTL($languageID) ? 'rtl' : 'ltr') . '">' . nl2br(htmlspecialchars($editData[0]['suggestedValue'])) . '</span>';
}
$referencedPhrase = Phrase::create(0, $editData[0]['phraseKey'], $editData[0]['payload']);
$previousPhraseData = Database::getPhrase($repositoryID, $languageID, $editData[0]['phraseKey']);
if (empty($previousPhraseData)) {
$previousPhrase = Phrase::create(0, $editData[0]['phraseKey'], $editData[0]['payload'], 0, true);
} else {
$previousPhrase = Phrase::create(0, $editData[0]['phraseKey'], $previousPhraseData['payload']);
}
$valuesReference = $referencedPhrase->getPhraseValues();
$valueReference = isset($valuesReference[$editData[0]['phraseSubKey']]) && is_string($valuesReference[$editData[0]['phraseSubKey']]) ? $valuesReference[$editData[0]['phraseSubKey']] : '';
$valuesPrevious = $previousPhrase->getPhraseValues();
$valuePrevious = isset($valuesPrevious[$editData[0]['phraseSubKey']]) && is_string($valuesPrevious[$editData[0]['phraseSubKey']]) ? trim($valuesPrevious[$editData[0]['phraseSubKey']]) : '';
$pendingEditsCount = Database::getPendingEditsByRepositoryAndLanguageCount($repositoryID, $languageID);
$pendingEditsCountHTML = $pendingEditsCount . ' edit' . ($pendingEditsCount == 1 ? '' : 's') . ' to review';
$contents[] = new UI_Heading($languageData->getNameFull(), true, 1, $pendingEditsCountHTML);
// mark placeholders and HTML tags in the reference phrase
$phraseWithMarkedEntities = htmlspecialchars($valueReference);
$phraseWithMarkedEntities = Phrase::markEntities($phraseWithMarkedEntities, Phrase_Android::getPlaceholders($valueReference), 'text-primary', true);
$phraseWithMarkedEntities = Phrase::markEntities($phraseWithMarkedEntities, Phrase_Android::getHTMLTags($valueReference), 'text-success', true);
// mark placeholders and HTML tags in the current (old) value of the phrase
$originalWithMarkedEntities = htmlspecialchars($valuePrevious);
$originalWithMarkedEntities = Phrase::markEntities($originalWithMarkedEntities, Phrase_Android::getPlaceholders($valueReference), 'text-primary', true);
$originalWithMarkedEntities = Phrase::markEntities($originalWithMarkedEntities, Phrase_Android::getHTMLTags($valueReference), 'text-success', true);
$fullyQualifiedName = Phrase_Android::getFullyQualifiedName($referencedPhrase, $editData[0]['phraseSubKey']);
$fullyQualifiedNameHTML = '<span dir="ltr" class="small" style="display:block; color:#999; margin-top:4px;">' . htmlspecialchars($fullyQualifiedName) . '</span>';
$translateBackLink = self::linkToTranslationService('Check', $languageID, $repositoryData['defaultLanguage'], $editData[0]['suggestedValue']);
$translateBackLink->setSize(UI_Link::SIZE_SMALL);
$table->addRow(array('<strong>' . Language::getLanguageNameFull($repositoryData['defaultLanguage']) . '</strong>' . $fullyQualifiedNameHTML, '<span dir="' . (Language::isLanguageRTL($repositoryData['defaultLanguage']) ? 'rtl' : 'ltr') . '">' . nl2br($phraseWithMarkedEntities) . '</span>'));
$table->addRow(array('<strong>Old value</strong>' . $fullyQualifiedNameHTML, '<span dir="' . (Language::isLanguageRTL($languageID) ? 'rtl' : 'ltr') . '">' . nl2br($originalWithMarkedEntities) . '</span>'));
$table->addRow(array('<strong>Applied changes</strong>', '<div dir="' . (Language::isLanguageRTL($languageID) ? 'rtl' : 'ltr') . '">' . nl2br(htmlDiff(htmlspecialchars($valuePrevious), htmlspecialchars($editData[0]['suggestedValue']))) . '</div>'));
$table->addRow(array('<strong>New value</strong>' . $fullyQualifiedNameHTML . '<br />' . $translateBackLink->getHTML(), $newValueHTML));
$table->addRow(array('<strong>Submit time</strong>', date('d.m.Y H:i', $editData[0]['submit_time'])));
if ($isAllowedToReview) {
$table->addRow(array('<strong>Contributor</strong>', $contributorName));
}
if ($isAllowedToReview) {
$form->addContent(new UI_Form_Hidden('review[editID]', URL::encodeID($editData[0]['id'])));
$form->addContent(new UI_Form_Hidden('review[referenceValue]', $valueReference));
$form->addContent(new UI_Form_Hidden('review[phraseObject]', base64_encode(serialize($previousPhrase))));
$form->addContent(new UI_Form_Hidden('review[phraseKey]', htmlspecialchars($editData[0]['phraseKey'])));
$form->addContent(new UI_Form_Hidden('review[phraseSubKey]', htmlspecialchars($editData[0]['phraseSubKey'])));
$form->addContent(new UI_Form_Hidden('review[contributorID]', URL::encodeID($editData[0]['userID'])));
}
if ($isAllowedToReview) {
$form->addContent($actionButtons);
}
$form->addContent($table);
if ($isAllowedToReview) {
$form->addContent($actionButtons);
$form->addContent(new UI_Form_ButtonGroup(array($buttonApproveAllByContributor, $buttonRejectAllByContributor), true));
}
$contents[] = $form;
if ($editID > 0 || $isAllowedToReview) {
// only for guest users who have the direct link to this edit ID and staff members who are allowed to review phrases
$contents[] = new UI_Heading('Discussion', true, UI_Heading::LEVEL_MIN, URL::toReviewLanguage($repositoryID, $languageID, $editData[0]['id']));
$discussion = new UI_Form(htmlspecialchars($currentPageURL), false);
$discussion->addContent(new UI_Form_Text('Your message', 'discussion[message]', 'Type here ...'));
$discussion->addContent(new UI_Form_Hidden('discussion[editID]', URL::encodeID($editData[0]['id'])));
$discussion->addContent(new UI_Form_ButtonGroup(array(new UI_Form_Button('Send'))));
$contents[] = $discussion;
$discussionEntries = Database::getDiscussionEntries($editData[0]['id']);
foreach ($discussionEntries as $discussionEntry) {
$contents[] = new UI_Paragraph('<strong>' . htmlspecialchars($discussionEntry['username']) . '</strong> (' . Time::getTimeAgo($discussionEntry['timeSent']) . '):<br />' . htmlspecialchars($discussionEntry['content']));
}
}
}
}
}
}
$cell = new UI_Cell($contents);
$row = new UI_Row(array($cell));
$containers[] = new UI_Container(array($row));
return new UI_Group($containers);
}