jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/391561 )
Change subject: Added _lastUploadDate, _numPages fields to _fileData table
......................................................................
Added _lastUploadDate, _numPages fields to _fileData table
Code for _numPages field comes from a patch by Paul Troughton.
Change-Id: I7d4761ce536893ec71e04cadb7749056337c521a
---
M includes/CargoFileData.php
1 file changed, 32 insertions(+), 1 deletion(-)
Approvals:
Yaron Koren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/CargoFileData.php b/includes/CargoFileData.php
index 7f4012a..5fae9ea 100644
--- a/includes/CargoFileData.php
+++ b/includes/CargoFileData.php
@@ -21,8 +21,14 @@
if ( in_array( 'path', $wgCargoFileDataColumns ) ) {
$fieldTypes['_path'] = array( 'String', false );
}
+ if ( in_array( 'lastUploadDate', $wgCargoFileDataColumns ) ) {
+ $fieldTypes['_lastUploadDate'] = array( 'Date', false );
+ }
if ( in_array( 'fullText', $wgCargoFileDataColumns ) ) {
$fieldTypes['_fullText'] = array( 'Searchtext', false );
+ }
+ if ( in_array( 'numPages', $wgCargoFileDataColumns ) ) {
+ $fieldTypes['_numPages'] = array( 'Integer', false );
}
$tableSchema = new CargoTableSchema();
@@ -75,11 +81,15 @@
$fileDataValues['_path'] = $file->getLocalRefPath();
}
+ if ( in_array( 'lastUploadDate', $wgCargoFileDataColumns ) ) {
+ $fileDataValues['_lastUploadDate'] =
$file->getTimestamp();
+ }
+
if ( in_array( 'fullText', $wgCargoFileDataColumns ) ) {
global $wgCargoPDFToText;
if ( $wgCargoPDFToText == '' ) {
- // Display an error message/
+ // Display an error message?
} elseif ( $file->getMimeType() != 'application/pdf' ) {
// We only handle PDF files.
} else {
@@ -96,6 +106,27 @@
}
}
+ if ( in_array( 'numPages', $wgCargoFileDataColumns ) ) {
+ global $wgCargoPDFInfo;
+ if ( $wgCargoPDFInfo == '' ) {
+ // Display an error message?
+ } elseif ( $file->getMimeType() != 'application/pdf' ) {
+ // We only handle PDF files.
+ } else {
+ $filePath = $file->getLocalRefPath();
+ $cmd = wfEscapeShellArg( $wgCargoPDFInfo ) . '
'. wfEscapeShellArg( $filePath );
+ $retval = '';
+ $txt = wfShellExec( $cmd, $retval );
+ if ( $retval == 0 ) {
+ $lines = explode( PHP_EOL, $txt );
+ $matched = preg_grep( '/^Pages\:/',
$lines );
+ foreach ( $matched as $line ) {
+ $fileDataValues['_numPages'] =
intval( trim( substr( $line, 7 ) ) );
+ }
+ }
+ }
+ }
+
CargoStore::storeAllData( $title, '_fileData', $fileDataValues,
$tableSchemas['_fileData'] );
}
--
To view, visit https://gerrit.wikimedia.org/r/391561
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7d4761ce536893ec71e04cadb7749056337c521a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits