本文整理汇总了PHP中QQN::NarroText方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::NarroText方法的具体用法?PHP QQN::NarroText怎么用?PHP QQN::NarroText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQN
的用法示例。
在下文中一共展示了QQN::NarroText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
// }
// }
//
// $objSuggestion->Save();
// }
// }
$intDuplicateTextsDeleted = 0;
foreach (NarroText::LoadAll() as $intVal => $objText) {
if ($objText->TextValueMd5 == md5($objText->TextValue)) {
continue;
}
try {
$objText->Save();
} catch (Exception $objEx) {
if (strstr($objEx->getMessage(), 'Duplicate')) {
$arrDuplicateTexts = NarroText::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroText()->TextValue, $objText->TextValue), QQ::NotEqual(QQN::NarroText()->TextId, $objText->TextId)));
error_log(sprintf('Found duplicates for "%s": %d', $objText->TextValue, count($arrDuplicateTexts)));
foreach ($arrDuplicateTexts as $objDuplicateText) {
if ($objText->TextValue !== $objDuplicateText->TextValue) {
continue;
}
foreach (NarroTextComment::LoadArrayByTextId($objDuplicateText->TextId) as $objTextComment) {
error_log('Moving text comment');
$objTextComment->TextId = $objText->TextId;
$objTextComment->Save();
}
foreach (NarroSuggestion::LoadArrayByTextId($objDuplicateText->TextId) as $objSuggestion) {
error_log('Moving text from suggestion');
$arrDuplicateSuggestions = NarroSuggestion::QueryArray(QQ::AndCondition(QQ::NotEqual(QQN::NarroSuggestion()->SuggestionId, $objSuggestion->SuggestionId), QQ::Equal(QQN::NarroSuggestion()->SuggestionValue, $objSuggestion->SuggestionValue), QQ::Equal(QQN::NarroSuggestion()->TextId, $objText->TextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, $objSuggestion->LanguageId)));
if (count($arrDuplicateSuggestions)) {
error_log(sprintf('Found duplicates for "%s": %d', $objSuggestion->SuggestionValue, count($arrDuplicateSuggestions)));
示例2: LoadByTextValueMd5
/**
* Load a single NarroText object,
* by TextValueMd5 Index(es)
* @param string $strTextValueMd5
* @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
* @return NarroText
*/
public static function LoadByTextValueMd5($strTextValueMd5, $objOptionalClauses = null)
{
return NarroText::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroText()->TextValueMd5, $strTextValueMd5)), $objOptionalClauses);
}
示例3: btnTmx_Click
public function btnTmx_Click($strFormId, $strControlId, $intLanguageId)
{
set_time_limit(0);
$objLanguage = NarroLanguage::Load($intLanguageId);
if (!$objLanguage) {
return false;
}
header("Pragma: public");
// required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
// required for certain browsers
header("Content-Type: text/xml");
header("Content-Disposition: attachment; filename=\"" . sprintf('%s %s.tmx', preg_replace('/^[a-z]/i', '_', __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__), $objLanguage->LanguageName) . "\";");
ob_clean();
$strXml = NarroLanguage::GetTmx(QQ::Equal(QQN::NarroText()->NarroSuggestionAsText->LanguageId, $intLanguageId));
header("Content-Length: " . strlen($strXml));
echo $strXml;
exit;
}
示例4: ResolveContentItem
/**
* Used internally by the Meta-based Add Column tools.
*
* Given a QQNode or a Text String, this will return a NarroText-based QQNode.
* It will also verify that it is a proper NarroText-based QQNode, and will throw an exception otherwise.
*
* @param mixed $mixContent
* @return QQNode
*/
protected function ResolveContentItem($mixContent)
{
if ($mixContent instanceof QQNode) {
if (!$mixContent->_ParentNode) {
throw new QCallerException('Content QQNode cannot be a Top Level Node');
}
if ($mixContent->_RootTableName == 'narro_text') {
if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
$objCurrentNode = $mixContent;
while ($objCurrentNode = $objCurrentNode->_ParentNode) {
if (!$objCurrentNode instanceof QQNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
}
}
return $mixContent;
} else {
throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "narro_text".');
}
} else {
if (is_string($mixContent)) {
switch ($mixContent) {
case 'TextId':
return QQN::NarroText()->TextId;
case 'TextValue':
return QQN::NarroText()->TextValue;
case 'TextValueMd5':
return QQN::NarroText()->TextValueMd5;
case 'TextCharCount':
return QQN::NarroText()->TextCharCount;
case 'TextWordCount':
return QQN::NarroText()->TextWordCount;
case 'HasComments':
return QQN::NarroText()->HasComments;
case 'Created':
return QQN::NarroText()->Created;
case 'Modified':
return QQN::NarroText()->Modified;
default:
throw new QCallerException('Simple Property not found in NarroTextDataGrid content: ' . $mixContent);
}
} else {
if ($mixContent instanceof QQAssociationNode) {
throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
} else {
throw new QCallerException('Invalid Content type');
}
}
}
}
示例5: GetTmx
/**
* Returns a tmx file
* @param QQCondition $objLangCondition e.g. QQ::In(QQN::NarroText()->NarroSuggestionAsText->LanguageId, QApplication::GetLanguageId());
* @return a tmx file, formatted as a string
*/
public static function GetTmx($objLangCondition)
{
$tmx = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE tmx SYSTEM "tmx13.dtd"><tmx />');
$tmx->addAttribute('version', '1.3');
$header = $tmx->addChild('header');
// mandatory
$header->addAttribute('creationtool', "Narro");
$header->addAttribute('creationtoolversion', NARRO_VERSION);
$header->addAttribute('segtype', "sentence");
$header->addAttribute('o-tmf', "ABCTransMem");
$header->addAttribute('adminlang', NarroLanguage::SOURCE_LANGUAGE_CODE);
$header->addAttribute('srclang', NarroLanguage::SOURCE_LANGUAGE_CODE);
$header->addAttribute('datatype', "PlainText");
// optional
$header->addAttribute('creationdate', QDateTime::NowToString('YYYYMMDDThhmmssZ'));
if (QApplication::$User) {
$header->addAttribute('creationid', QApplication::$User->Username);
}
$header->addAttribute('changedate', "19970314T023401Z");
$header->addAttribute('o-encoding', "utf-8");
$body = $tmx->addChild('body');
$strQuery = NarroText::GetQueryStatement($objQueryBuilder, QQ::AndCondition(QQ::IsNotNull(QQN::NarroText()->NarroSuggestionAsText->SuggestionId), $objLangCondition), array(QQ::ExpandAsArray(QQN::NarroText()->NarroSuggestionAsText)), array(), false);
$objDbResult = NarroText::GetDatabase()->Query($strQuery);
$intRowCount = $objDbResult->CountRows();
$intLastTextId = 0;
while ($objDbRow = $objDbResult->GetNextRow()) {
$objText = NarroText::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, null, $objQueryBuilder->ColumnAliasArray);
if ($intLastTextId != $objText->TextId) {
$intLastTextId = $objText->TextId;
$tu = $body->addChild('tu');
$tu->addAttribute('tuid', $objText->TextId);
$tu->addAttribute('datatype', 'Text');
// $tu->addAttribute('usagecount', $objText->CountNarroContextsAsText());
// $objLastContext = NarroContext::QuerySingle(QQ::Equal(QQN::NarroContext()->TextId, $objText->TextId), array(QQ::OrderBy(QQN::NarroContext()->Created, 0)));
// if ($objLastContext && $objLastContext->Created instanceof QDateTime)
// $tu->addAttribute('lastusagedate', $objLastContext->Created->qFormat('YYYYMMDDThhmmssZ'));
$tuv = $tu->addChild('tuv');
$tuv->addAttribute('xml:lang', NarroLanguage::SOURCE_LANGUAGE_CODE);
$seg = $tuv->addChild('seg');
$tuv->seg = $objText->TextValue;
if ($objText->Created instanceof QDateTime) {
$tuv->addAttribute('creationdate', $objText->Created->qFormat('YYYYMMDDThhmmssZ'));
}
if ($objText->Modified instanceof QDateTime) {
$tuv->addAttribute('changedate', $objText->Modified->qFormat('YYYYMMDDThhmmssZ'));
}
}
foreach ($objText->_NarroSuggestionAsTextArray as $objSuggestion) {
/* @var $objSuggestion NarroSuggestion */
$tuv = $tu->addChild('tuv');
$tuv->addAttribute('xml:lang', $objSuggestion->Language->LanguageCode);
$seg = $tuv->addChild('seg');
$tuv->seg = $objSuggestion->SuggestionValue;
if ($objSuggestion->Created instanceof QDateTime) {
$tuv->addAttribute('creationdate', $objSuggestion->Created->qFormat('YYYYMMDDThhmmssZ'));
}
if ($objSuggestion->Modified instanceof QDateTime) {
$tuv->addAttribute('changedate', $objSuggestion->Modified->qFormat('YYYYMMDDThhmmssZ'));
}
if ($objSuggestion->User instanceof NarroUser) {
$tuv->addAttribute('creationid', $objSuggestion->User->RealName);
}
// $tuv->addAttribute('usagecount', $objSuggestion->CountNarroContextInfosAsValidSuggestion());
// $objLastContextInfo = NarroContextInfo::QuerySingle(QQ::Equal(QQN::NarroContextInfo()->ValidSuggestionId, $objSuggestion->SuggestionId), array(QQ::OrderBy(QQN::NarroContextInfo()->Created, 0)));
// if ($objLastContextInfo && $objLastContextInfo->Created instanceof QDateTime)
// $tuv->addAttribute('lastusagedate', $objLastContextInfo->Created->qFormat('YYYYMMDDThhmmssZ'));
}
}
return $tmx->asXML();
}