/** * Calculates the difference between this DateSpan and another DateSpan * * @param QDateTimeSpan $dtsSpan * @return new QDateTimeSpan */ public function Difference(QDateTimeSpan $dtsSpan) { $intDifference = $this->Seconds - $dtsSpan->Seconds; $dtsDateSpan = new QDateTimeSpan(); $dtsDateSpan->AddSeconds($intDifference); return $dtsDateSpan; }
public function dtgTranslation_colAuthor_Render(NarroSuggestion $objSuggestion) { $objDateSpan = new QDateTimeSpan(time() - strtotime($objSuggestion->Created)); $strModifiedWhen = $objDateSpan->SimpleDisplay(); if (strtotime($objSuggestion->Modified) > 0 && $strModifiedWhen && $objSuggestion->User->RealName) { $strAuthorInfo = sprintf($objSuggestion->IsImported ? t('imported by <a href="%s" tabindex="-1">%s</a>, %s ago') : t('<a href="%s" tabindex="-1">%s</a>, %s ago'), NarroLink::UserProfile($objSuggestion->User->UserId), $objSuggestion->User->RealName, $strModifiedWhen); } elseif (strtotime($objSuggestion->Modified) > 0 && $strModifiedWhen && !$objSuggestion->User->RealName) { $strAuthorInfo = sprintf(t('%s ago'), $strModifiedWhen); } elseif ($objSuggestion->User) { $strAuthorInfo = sprintf($objSuggestion->IsImported ? t('imported by <a href="%s" tabindex="-1">%s</a>') : '<a href="%s" tabindex="-1">%s</a>', NarroLink::UserProfile($objSuggestion->User->UserId), $objSuggestion->User->RealName); } else { $strAuthorInfo = t('Unknown'); } if ($objSuggestion->SuggestionId == $this->objContextInfo->ValidSuggestionId && $this->objContextInfo->ValidatorUserId != NarroUser::ANONYMOUS_USER_ID) { $objDateSpan = new QDateTimeSpan(time() - strtotime($this->objContextInfo->Modified)); $strModifiedWhen = $objDateSpan->SimpleDisplay(); $strAuthorInfo .= ', ' . sprintf(sprintf(t('approved by <a href="%s" tabindex="-1">%s</a>'), NarroLink::UserProfile($this->objContextInfo->ValidatorUser->UserId), $this->objContextInfo->ValidatorUser->RealName . ' %s'), $objDateSpan->SimpleDisplay() ? sprintf(t('%s ago'), $objDateSpan->SimpleDisplay()) : ''); } return sprintf('<small>-- %s, %s</small>', $strAuthorInfo, sprintf(t('%d votes'), $objSuggestion->Votes)); }
protected function LendBasket() { foreach ($this->objBasket->GetBasket() as $item) { $objItem = Myassets::QuerySingle(QQ::Equal(QQN::Myassets()->Id, $item->Id)); $objPerson = Peopledetails::QuerySingle(QQ::Equal(QQN::Peopledetails()->Id, $this->strBorrower)); $objShareDetails = new Sharedetails(); $objShareDetails->Asin = $objItem->Asin; $objShareDetails->Email = $objPerson->Email; /*Logic to get the return date*/ $today = new QDateTime(QDateTime::Now); $daySpan = new QDateTimeSpan(); $daySpan->AddDays(30); $returnDate = $today->Add($daySpan); $objShareDetails->TakenDate = QDateTime::Now(false); $objShareDetails->ReturnDate = $returnDate; $objShareDetails->Title = $objItem->Title; $objShareDetails->FullName = $objPerson->FullName; $objShareDetails->Save(); } }
public function colCreated_Render(NarroLog $objLog) { $objDateSpan = new QDateTimeSpan(time() - $objLog->Date->Timestamp); $strModifiedWhen = $objDateSpan->SimpleDisplay(); return sprintf(t('%s ago'), $strModifiedWhen); }
public function Difference(QDateTime $dttDateTime) { $intDifference = $this->Timestamp - $dttDateTime->Timestamp; $dtsDateSpan = new QDateTimeSpan(); $dtsDateSpan->AddSeconds($intDifference); return $dtsDateSpan; }
public function colCreated_Render(NarroTextComment $objComment) { $objDateSpan = new QDateTimeSpan(time() - $objComment->Created->Timestamp); $strModifiedWhen = $objDateSpan->SimpleDisplay(); return sprintf(t('%s ago'), $strModifiedWhen); }
public function DisplayExportMessage(NarroProject $objProject, $strText = '') { $strArchiveName = __IMPORT_PATH__ . '/' . $objProject->ProjectId . '/' . $objProject->ProjectName . '-' . QApplication::$TargetLanguage->LanguageCode . '.zip'; if (file_exists($strArchiveName)) { $strDownloadUrl = sprintf(__HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__ . '/includes/narro/plugins/' . __CLASS__ . '.class.php?p=%d&pn=%s&l=%s', $objProject->ProjectId, $objProject->ProjectName, QApplication::$TargetLanguage->LanguageCode); $objDateSpan = new QDateTimeSpan(time() - filemtime($strArchiveName)); $strExportText = sprintf('<a href="%s">%s</a>, ' . t('exported %s ago'), $strDownloadUrl, basename($strArchiveName), $objDateSpan->SimpleDisplay()); } else { $strExportText = t('Failed to create an archive for download'); } return array($objProject, $strExportText); }
NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strSourceLanguage)); return false; } NarroLogger::LogInfo(sprintf('Source language is %s', $objNarroImporter->SourceLanguage->LanguageName)); $objNarroImporter->Project = $objProject; $objNarroImporter->User = $objUser; $objNarroImporter->TemplatePath = $objNarroImporter->Project->DefaultTemplatePath; $objNarroImporter->TranslationPath = $objNarroImporter->Project->DefaultTranslationPath; $intPid = NarroUtils::IsProcessRunning('export', $objNarroImporter->Project->ProjectId); if ($intPid && $intPid != getmypid()) { NarroLogger::LogInfo(sprintf('An export process is already running for this project with pid %d', $intPid)); } $strProcPidFile = __TMP_PATH__ . '/' . $objNarroImporter->Project->ProjectId . '-' . $objNarroImporter->TargetLanguage->LanguageCode . '-export-process.pid'; if (file_exists($strProcPidFile)) { unlink($strProcPidFile); } file_put_contents($strProcPidFile, getmypid()); chmod($strProcPidFile, 0666); $objNarroImporter->ExportProject(); unlink($strProcPidFile); } catch (Exception $objEx) { printf("\n%s: %s\n", $objEx->getMessage(), $objEx->getTraceAsString()); NarroLogger::LogError(sprintf('An error occurred during export: %s', $objEx->getMessage())); continue; } } } } $objDateSpan = new QDateTimeSpan(time() - $intStartTime); printf("Export started %s ago, finished in %d seconds\n", $objDateSpan->SimpleDisplay(), time() - $intStartTime); NarroLogger::LogInfo(sprintf('Export started %s ago, finished in %d seconds', $objDateSpan->SimpleDisplay(), time() - $intStartTime));
public function DisplayInProjectListInProgressColumn(NarroProject $objProject, $strText = '') { $strExportText = ''; $objCache = new NarroCache(QApplication::GetLanguageId() . '/' . $objProject->ProjectId, __CLASS__); $arrData = $objCache->GetData(); switch ($objProject->ProjectName) { case 'Fennec Aurora': if ($arrData) { return $arrData; } // set up basic connection $conn_id = ftp_connect('ftp.mozilla.org'); // login with username and password $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**'); // get contents of the current directory $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-linux-l10n"); if (is_array($contents)) { foreach ($contents as $strFile) { if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } } $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-win32-l10n"); if (is_array($contents)) { foreach ($contents as $strFile) { if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } } $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-macosx-l10n"); if (is_array($contents)) { foreach ($contents as $strFile) { if (preg_match('/\\/fennec\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } } $contents = ftp_nlist($conn_id, "/pub/mobile/nightly/latest-mozilla-aurora-android"); if (is_array($contents)) { foreach ($contents as $strFile) { if (preg_match('/\\/fennec\\-(.*)\\.multi\\.android\\-arm\\.apk$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">android</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } } $strLinks = join(', ', $arrLink); if ($strLinks != '') { $arrData = array($objProject, sprintf('nightly: %s', $strLinks)); $objCache->SaveData($arrData); return $arrData; } else { return array($objProject, ''); } case 'Firefox Aurora': if ($arrData) { return $arrData; } // set up basic connection $conn_id = ftp_connect('ftp.mozilla.org'); // login with username and password $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**'); // get contents of the current directory $contents = ftp_nlist($conn_id, "/pub/firefox/nightly/latest-mozilla-aurora-l10n/"); if (is_array($contents)) { foreach ($contents as $strFile) { if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-x86\\_64\\.tar\\.bz2$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux x86_64</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/firefox\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } } $strLinks = join(', ', $arrLink); if ($strLinks != '') { $arrData = array($objProject, sprintf('nightly: %s', $strLinks)); $objCache->SaveData($arrData); return $arrData; } else { return array($objProject, ''); } case 'Thunderbird Aurora': $strCacheId = __CLASS__ . QApplication::GetLanguageId() . 'p' . $objProject->ProjectId; if ($arrData) { return $arrData; } // set up basic connection $conn_id = ftp_connect('ftp.mozilla.org'); // login with username and password $login_result = ftp_login($conn_id, 'anonymous', '*****@*****.**'); // get contents of the current directory $contents = ftp_nlist($conn_id, "/pub/thunderbird/nightly/latest-comm-aurora-l10n/"); foreach ($contents as $strFile) { if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-i686\\.tar\\.bz2$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux i686</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.linux\\-x86\\_64\\.tar\\.bz2$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">linux x86_64</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.win32\\.zip$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">win32</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } foreach ($contents as $strFile) { if (preg_match('/\\/thunderbird\\-(.*)\\.' . preg_quote(QApplication::$TargetLanguage->LanguageCode) . '\\.mac\\.dmg$/', $strFile, $arrMatches)) { $objDateSpan = new QDateTimeSpan(time() - ftp_mdtm($conn_id, $strFile)); $arrLink[] = sprintf('<a title="Download a localized nightly build %s built %s ago" href="ftp://ftp.mozilla.org%s">mac</a>', $arrMatches[1], $objDateSpan->SimpleDisplay(), $strFile); } } $strLinks = join(', ', $arrLink); if ($strLinks != '') { $arrData = array($objProject, sprintf('nightly: %s', $strLinks)); $objCache->SaveData($arrData); return $arrData; } else { return array($objProject, ''); } default: return array($objProject, ''); } }
public function dtgProjectList_LastActivityColumn_Render(NarroProject $objProject) { if ($objProject->_NarroProjectProgressAsProject && $objProject->_NarroProjectProgressAsProject->LastModified->Timestamp > 0) { $objDateSpan = new QDateTimeSpan(time() - $objProject->_NarroProjectProgressAsProject->LastModified->Timestamp); $strModifiedWhen = $objDateSpan->SimpleDisplay(); return sprintf(t('%s ago'), $strModifiedWhen); } else { return t('never'); } }
public function colLastTranslation_Render(NarroLanguage $objLanguage) { $dttCreated = new QDateTimeSpan(time() - strtotime($objLanguage->GetVirtualAttribute('last_translation'))); return sprintf(t('%s ago'), $dttCreated->SimpleDisplay()); }
public function colModified_Render(NarroContextInfo $objContextInfo) { $objDateSpan = new QDateTimeSpan(time() - $objContextInfo->Modified->Timestamp); $strModifiedWhen = $objDateSpan->SimpleDisplay(); return sprintf(t('%s ago'), $strModifiedWhen); }