本文整理汇总了PHP中TBGContext::reinitializei18n方法的典型用法代码示例。如果您正苦于以下问题:PHP TBGContext::reinitializei18n方法的具体用法?PHP TBGContext::reinitializei18n怎么用?PHP TBGContext::reinitializei18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBGContext
的用法示例。
在下文中一共展示了TBGContext::reinitializei18n方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addNewCommit
public function addNewCommit($project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author)
{
/* Find issues to update */
$fixes_grep = "#((bug|issue|ticket|fix|fixes|fixed|fixing|applies to|closes|references|ref|addresses|re|see|according to|also see)\\s\\#?(([A-Z0-9]+\\-)?\\d+))#ie";
$output = '';
$f_issues = array();
try {
TBGContext::getI18n();
} catch (Exception $e) {
TBGContext::reinitializei18n();
}
try {
$project = new TBGProject($project);
} catch (Exception $e) {
return TBGContext::getI18n()->__('Error: Invalid project ID');
}
if (preg_match_all($fixes_grep, $commit_msg, $f_issues)) {
// Github
if (is_array($changed)) {
$entries = $changed;
$changed = '';
// Now handle changed files
foreach ($entries[0] as $file) {
$changed .= 'M' . $file . "\n";
}
// Now handle new files
foreach ($entries[1] as $file) {
$changed .= 'A' . $file . "\n";
}
// Now handle deleted files
foreach ($entries[2] as $file) {
$changed .= 'D' . $file . "\n";
}
}
$f_issues = array_unique($f_issues[3]);
$file_lines = preg_split('/[\\n\\r]+/', $changed);
$files = array();
foreach ($file_lines as $aline) {
$action = substr($aline, 0, 1);
if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
$theline = trim(substr($aline, 1));
$files[] = array($action, $theline);
}
}
foreach ($f_issues as $issue_no) {
TBGContext::setCurrentProject($project);
$theIssue = TBGIssue::getIssueFromLink($issue_no, true);
if ($theIssue instanceof TBGIssue) {
$uid = 0;
/*
* Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
* Joe Bloggs <me@example.com>, instead of a classic username. Therefore a user will be found via 4 queries:
* a) First we extract the email if there is one, and find a user with that email
* b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
* c) the username or full name is checked against the friendly name field
* d) and if we still havent found one, then we check against the username
* e) and if we STILL havent found one, we just say the user is id 0 (unknown user).
*/
if (preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
$email = $matches[0];
// a)
$crit = new B2DBCriteria();
$crit->setFromTable(TBGUsersTable::getTable());
$crit->addSelectionColumn(TBGUsersTable::ID);
$crit->addWhere(TBGUsersTable::EMAIL, $email);
$row = TBGUsersTable::getTable()->doSelectOne($crit);
if ($row != null) {
$uid = $row->get(TBGUsersTable::ID);
} else {
// Not found by email
preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
$author = $matches[0];
}
}
// b)
if ($uid == 0) {
$crit = new B2DBCriteria();
$crit->setFromTable(TBGUsersTable::getTable());
$crit->addSelectionColumn(TBGUsersTable::ID);
$crit->addWhere(TBGUsersTable::REALNAME, $author);
$row = TBGUsersTable::getTable()->doSelectOne($crit);
if ($row != null) {
$uid = $row->get(TBGUsersTable::ID);
}
}
// c)
if ($uid == 0) {
$crit = new B2DBCriteria();
$crit->setFromTable(TBGUsersTable::getTable());
$crit->addSelectionColumn(TBGUsersTable::ID);
$crit->addWhere(TBGUsersTable::BUDDYNAME, $author);
$row = TBGUsersTable::getTable()->doSelectOne($crit);
if ($row != null) {
$uid = $row->get(TBGUsersTable::ID);
}
}
// d)
if ($uid == 0) {
$crit = new B2DBCriteria();
$crit->setFromTable(TBGUsersTable::getTable());
//.........这里部分代码省略.........