本文整理汇总了PHP中Phrase::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Phrase::create方法的具体用法?PHP Phrase::create怎么用?PHP Phrase::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phrase
的用法示例。
在下文中一共展示了Phrase::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPhrase
public function addPhrase($language, $id, $phraseKey, $payload, $groupID, $enabled = true, $createKeysOnly = false, $isUsingDefaultPhrase = false)
{
$this->languages[$language]->addPhrase(Phrase::create($id, $phraseKey, $payload, $groupID, $enabled, $createKeysOnly, $isUsingDefaultPhrase));
}
示例2: approveEditsByContributor
public static function approveEditsByContributor($repositoryID, $languageID, $contributorID)
{
$edits = self::getPendingEditsByRepositoryLanguageAndUser($repositoryID, $languageID, $contributorID);
foreach ($edits as $edit) {
$previousPhraseData = Database::getPhrase($repositoryID, $languageID, $edit['phraseKey']);
if (empty($previousPhraseData)) {
$phraseObject = Phrase::create(0, $edit['phraseKey'], $edit['payload'], 0, true);
} else {
$phraseObject = Phrase::create(0, $edit['phraseKey'], $previousPhraseData['payload'], 0);
}
$phraseObject->setPhraseValue($edit['phraseSubKey'], $edit['suggestedValue']);
self::updatePhrase($repositoryID, $languageID, $edit['phraseKey'], $phraseObject->getPayload());
self::updateContributor($repositoryID, $edit['userID']);
self::deleteEdit($edit['id']);
}
Authentication::setCachedLanguageProgress($repositoryID, NULL);
// unset cached version of this repository's progress
}
示例3: getPage_Phrase
public static function getPage_Phrase($contents, $containers)
{
$repositoryID = self::validateID(self::getDataGET('project'), true);
$languageID = self::validateID(self::getDataGET('language'), true);
$phraseID = self::validateID(self::getDataGET('phrase'), true);
$repositoryData = Database::getRepositoryData($repositoryID);
$phraseData = Database::getPhraseData($repositoryID, $phraseID);
if (empty($repositoryData) || empty($phraseData)) {
self::addBreadcrumbItem(URL::toProject($repositoryID), 'Phrase not found');
self::setTitle('Phrase not found');
$contents[] = new UI_Heading('Phrase not found', true);
$contents[] = new UI_Paragraph('We\'re sorry, but we could not find the phrase that you requested.');
$contents[] = new UI_Paragraph('Please check if you have made any typing errors.');
} else {
self::addBreadcrumbItem(URL::toProject($repositoryID), htmlspecialchars($repositoryData['name']));
self::addBreadcrumbItem(URL::toLanguage($repositoryID, $languageID), Language::getLanguageNameFull($languageID));
Authentication::saveCachedRepository($repositoryID, $repositoryData['name']);
$repository = new Repository($repositoryID, $repositoryData['name'], $repositoryData['visibility'], $repositoryData['defaultLanguage']);
$role = Database::getRepositoryRole(Authentication::getUserID(), $repositoryID);
$permissions = $repository->getPermissions(Authentication::getUserID(), $role);
if (Authentication::getUserID() <= 0) {
self::setTitle($repositoryData['name']);
$contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
$contents[] = self::getLoginForm();
} elseif ($permissions->isInvitationMissing()) {
self::setTitle($repositoryData['name']);
$contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
$contents[] = self::getInvitationForm($repositoryID);
} else {
$mayMovePhrases = Repository::isRoleAllowedToMovePhrases($role);
$currentPageURL = URL::toPhraseDetails($repositoryID, $languageID, $phraseID);
self::addBreadcrumbItem($currentPageURL, $phraseData['phraseKey']);
$phraseObject = Phrase::create($phraseID, $phraseData['phraseKey'], $phraseData['payload']);
$phraseObjectEntries = $phraseObject->getPhraseValues();
$phraseEntries = new UI_List();
foreach ($phraseObjectEntries as $phraseObjectEntry) {
$phraseEntries->addItem(nl2br(htmlspecialchars($phraseObjectEntry)));
}
if ($mayMovePhrases) {
$formMove = new UI_Form($currentPageURL, false);
$formMove->addContent(new UI_Form_Hidden('phraseMove[phraseKey]', $phraseData['phraseKey']));
$phraseGroupSelection = new UI_Form_Select('New group', 'phraseMove[groupID]');
$phraseGroupSelection->addOption('(Default group)', Phrase::GROUP_NONE);
$phraseGroups = Database::getPhraseGroups($repositoryID, $repositoryData['defaultLanguage']);
foreach ($phraseGroups as $phraseGroup) {
$phraseGroupSelection->addOption($phraseGroup['name'], $phraseGroup['id']);
}
$phraseGroupSelection->addDefaultOption($phraseData['groupID']);
$formMove->addContent($phraseGroupSelection);
$formButtonList = array(new UI_Form_Button('Update group', UI_Link::TYPE_SUCCESS), new UI_Link('Manage groups', URL::toEditProject($repositoryID, true), UI_Link::TYPE_UNIMPORTANT), new UI_Link('Cancel', URL::toLanguage($repositoryID, $languageID), UI_Link::TYPE_UNIMPORTANT));
$formMove->addContent(new UI_Form_ButtonGroup($formButtonList));
} else {
$formMove = NULL;
}
if ($mayMovePhrases) {
$formChange = new UI_Form($currentPageURL, false);
$formChange->addContent(new UI_Form_Hidden('phraseChange[phraseKey]', $phraseData['phraseKey']));
$actionTypeSelection = new UI_Form_Select('Operation', 'phraseChange[action]');
$actionTypeSelection->addOption('— Please choose —', '');
$actionTypeSelection->addOption('Untranslate: Remove all translations of this phrase only', 'untranslate');
$actionTypeSelection->addOption('Delete: Completely remove this phrase from the project', 'delete');
$formChange->addContent($actionTypeSelection);
$formButtonList = array(new UI_Form_Button('Execute', UI_Link::TYPE_DANGER, UI_Form_Button::ACTION_SUBMIT, '', '', 'return confirm(\'Are you sure you want to execute the selected operation? This cannot be undone!\');'), new UI_Link('Cancel', URL::toLanguage($repositoryID, $languageID), UI_Link::TYPE_UNIMPORTANT));
$formChange->addContent(new UI_Form_ButtonGroup($formButtonList));
} else {
$formChange = NULL;
}
self::setTitle('Phrase: ' . $phraseData['phraseKey']);
$contents[] = new UI_Heading('Phrase: ' . $phraseData['phraseKey'], true);
$contents[] = new UI_Heading('Contents', false, 3);
$contents[] = $phraseEntries;
if (isset($formMove)) {
$contents[] = new UI_Heading('Move phrase to another group', false, 3);
$contents[] = $formMove;
}
if (isset($formChange)) {
$contents[] = new UI_Heading('Untranslate or delete phrase', false, 3);
$contents[] = $formChange;
}
}
}
$cell = new UI_Cell($contents);
$row = new UI_Row(array($cell));
$containers[] = new UI_Container(array($row));
return new UI_Group($containers);
}