Yaron Koren has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/391561 )
Change subject: Added _lastUploadDate, _numPages fields to _fileData table ...................................................................... Added _lastUploadDate, _numPages fields to _fileData table Change-Id: I7d4761ce536893ec71e04cadb7749056337c521a --- M includes/CargoFileData.php 1 file changed, 32 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/61/391561/2 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: newchange Gerrit-Change-Id: I7d4761ce536893ec71e04cadb7749056337c521a Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits