Hiong3-eng5 has uploaded a new change for review. https://gerrit.wikimedia.org/r/79176
Change subject: OWD CSV ...................................................................... OWD CSV Change-Id: I9d5b496d7bd09aecb49c3a8e2e41f785399ae42c --- M OmegaWiki/Attribute.php M OmegaWiki/DefinedMeaning.php M OmegaWiki/Expression.php M includes/formatCSV.php A includes/jobs/OWOwdListJob.php M includes/setup/OWJobs.php M includes/specials/SpecialOWDownloads.php 7 files changed, 598 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLexicalData refs/changes/76/79176/1 diff --git a/OmegaWiki/Attribute.php b/OmegaWiki/Attribute.php index 8c4b661..91391c4 100644 --- a/OmegaWiki/Attribute.php +++ b/OmegaWiki/Attribute.php @@ -6,15 +6,15 @@ public $type = ""; /** - * @param $id (String) or null if - * @param $name (String) - * @param $type (String or Structure) + * @param $id (String) or null if + * @param $name (String) + * @param $type (String or Structure) * If String, can be "language", "spelling", "boolean", - * "defined-meaning", "defining-expression", "relation-type", "attribute", + * "defined-meaning", "defining-expression", "relation-type", "attribute", * "collection", "short-text", "text" * * If Structure, see below. - */ + */ public function __construct( $id, $name, $type ) { $this->id = $id; $this->name = $name; @@ -29,7 +29,7 @@ $this->type = $type; } - // Since the attribute is a structure and unnamed, we use + // Since the attribute is a structure and unnamed, we use // the default label associated with it. if ( is_null( $this->id ) && ( $this->type instanceof Structure ) ) { $this->id = $this->type->getStructureType(); @@ -38,7 +38,7 @@ $this->type->setStructureType( $this->id ); } } - + public function getId() { return $this->id; } @@ -54,7 +54,7 @@ class Structure { private $attributes; private $type; - + public function getAttributes() { return $this->attributes; } @@ -80,7 +80,7 @@ * 'anonymous-structure' unless there is only a * a single Attribute object, in which case the structure * will inherit its ID. Do not pass null. - * @param $structure (Array or Parameter list) One or more Attribute objects. + * @param $structure (Array or Parameter list) One or more Attribute objects. * */ public function __construct( $argumentList ) { @@ -88,7 +88,7 @@ # We're trying to be clever. $args = func_get_args(); $this->attributes = null; - + if ( $args[0] instanceof Attribute ) { $this->attributes = $args; } elseif ( is_array( $args[0] ) ) { @@ -125,34 +125,208 @@ public function supportsAttributeId( $attributeId ) { // $result = false; // $i = 0; -// +// // while (!$result && $i < count($this->attributes)) { // $result = $this->attributes[$i]->id == $attributeId; // $i++; // } -// +// // return $result; return true; } - + public function supportsAttribute( Attribute $attribute ) { return $this->supportsAttributeId( $attribute->id ); } - + public function __tostring() { $result = "{"; if ( count( $this->attributes ) > 0 ) { $result .= $this->attributes[0]->id; - + for ( $i = 1; $i < count( $this->attributes ); $i++ ) $result .= ", " . $this->attributes[$i]->id; } $result .= "}"; - + return $result; } } +class Attributes { + public function __construct() { + } + + /** + * returns an array of the Text Attributes name and the text itself + * for a language + * + * else returns array() + * + * Note: $options can be used to introduce new variables + */ + public static function getTextAttributes( $objectId, $options = array(), $dc = null ) { + if ( is_null( $dc ) ) { + $dc = wdGetDataSetContext(); + } + $dbr = wfGetDB( DB_SLAVE ); + + $cond = array(); + if ( isset( $options['ORDER BY'] ) ) { + $cond['ORDER BY']= $options['ORDER BY']; + } else { + $cond['ORDER BY']= 'text'; + } + + if ( isset( $options['LIMIT'] ) ) { + $cond['LIMIT']= $options['LIMIT']; + } + if ( isset( $options['OFFSET'] ) ) { + $cond['OFFSET']= $options['OFFSET']; + } + + $languageId = null; + if ( isset( $options['languageId'] ) ) { + $languageId = $options['languageId']; + } + + $queryResult = $dbr->select( + "{$dc}_text_attribute_values", + array( + 'text', + 'attribute_mid', + ), + array( + 'object_id' => $objectId, + 'remove_transaction_id' => null + ), + __METHOD__, + $cond + ); + + $textAttributes = array(); + $attributes = new Attributes; + foreach ( $queryResult as $ta ) { + $textAttributes[] = array( + 'text' => $ta->text, + 'attribute_name' => $attributes->getAttributeName( $ta->attribute_mid, $languageId ) + ); + } + + if ( $textAttributes ) { + return $textAttributes; + } + return array(); + } + + /** + * returns the Attribute Name + * + * else returns null + * + */ + public static function getAttributeName( $attributeId, $languageId = null, $dc = null ) { + if ( is_null( $dc ) ) { + $dc = wdGetDataSetContext(); + } + $dbr = wfGetDB( DB_SLAVE ); + + $vars = array( + 'synt.defined_meaning_id' => $attributeId, + 'synt.expression_id = exp.expression_id', + 'synt.remove_transaction_id' => null, + 'exp.remove_transaction_id' => null + ); + + if ( $languageId ) { + $vars['exp.language_id'] = $languageId; + } + + $attributeName = $dbr->selectField( + array( + 'exp' => "{$dc}_expression", + 'synt' => "{$dc}_syntrans", + ), + 'spelling', + $vars, + __METHOD__ + ); + + if ( $attributeName ) { + return $attributeName; + } + return null; + } + + /** + * returns an array of the Options Attributes Values etc name and the text itself + * for a language + * + * @param $objectId can be either syntransId or definedMeaningId + * + * else returns array() + * + * Note: $options can be used to introduce new variables + */ + public static function getOptionAttributes( $objectId, $options = array(), $dc = null ) { + if ( is_null( $dc ) ) { + $dc = wdGetDataSetContext(); + } + $dbr = wfGetDB( DB_SLAVE ); + + $vars = array( + 'oav.object_id' => $objectId, + 'oav.option_id = oao.option_id', + 'ca.object_id = oao.attribute_id', + 'oav.remove_transaction_id' => null, + 'oao.remove_transaction_id' => null, + 'ca.remove_transaction_id' => null + ); + + $cond = array(); + if ( isset( $options['LIMIT'] ) ) { + $cond['LIMIT'] = $options['LIMIT']; + } + if ( isset( $options['OFFSET'] ) ) { + $cond['OFFSET'] = $options['OFFSET']; + } + + $languageId = null; + if ( isset( $options['languageId'] ) ) { + $languageId = $options['languageId']; + } + + $queryResult = $dbr->select( + array( + 'oav' => "{$dc}_option_attribute_values", + 'oao' => "{$dc}_option_attribute_options", + 'ca' => "{$dc}_class_attributes" + ), + array( + 'attribute_mid', + 'option_mid' + ), + $vars, + __METHOD__, + $cond + ); + + $optionAttributes = array(); + $attributes = new Attributes; + foreach ( $queryResult as $oa ) { + $optionAttributes[] = array( + 'attribute_name' => $attributes->getAttributeName( $oa->attribute_mid, $languageId ), + 'attribute_option_name' => $attributes->getAttributeName( $oa->option_mid, $languageId ) + ); + } + + if ( $optionAttributes ) { + return $optionAttributes; + } + return array(); + } + +} diff --git a/OmegaWiki/DefinedMeaning.php b/OmegaWiki/DefinedMeaning.php index dff52a9..ae8651b 100644 --- a/OmegaWiki/DefinedMeaning.php +++ b/OmegaWiki/DefinedMeaning.php @@ -42,7 +42,7 @@ $dmInfo["expression"] = null; $match = $this->definedMeaningModel->checkExistence( true, true ); } - + // The defining expression is either bad or missing. Let's redirect // to the correct URL. if ( empty( $dmInfo["expression"] ) && !is_null( $match ) ) { @@ -111,7 +111,7 @@ $wgOut->addHTML( wfMessage( "ow_db_consistency__not_found" )->text() . " ID:$definedMeaningId" ); return; } - + $wgOut->addHTML( getDefinedMeaningEditor( $this->viewInformation )->edit( $this->getIdStack( $dmModel->getId() ), @@ -120,7 +120,7 @@ ); $this->outputEditFooter(); } - + public function history() { global $wgOut, $wgTitle ; @@ -167,7 +167,7 @@ $this->getIdStack( $definedMeaningId ), $dmModel->getRecord() ); - + } public function getTitle() { @@ -182,10 +182,10 @@ $definedMeaningIdStructure = new Structure( $o->definedMeaningId ); $definedMeaningIdRecord = new ArrayRecord( $definedMeaningIdStructure, $definedMeaningIdStructure ); $definedMeaningIdRecord->definedMeaningId = $definedMeaningId; - + $idStack = new IdStack( WLD_DEFINED_MEANING ); $idStack->pushKey( $definedMeaningIdRecord ); - + return $idStack; } @@ -202,13 +202,13 @@ return $this->getDefinedMeaningIdFromTitle( $wgTitle->getText() ); } - /** + /** * Creates sidebar HTML for indicating concepts which exist * in multiple datasets, and providing a link to add new * mappings. * * Potential refactor candidate! - */ + */ protected function getConceptPanel() { global $wgTitle, $wgUser, $wdShowCopyPanel; $active = true; # wrong place, but hey @@ -226,7 +226,7 @@ $active = ( $dataset->getPrefix() == $dc->getPrefix() ); $name = $dataset->fetchName(); $prefix = $dataset->getPrefix(); - + $class = $active ? 'dataset-panel-active' : 'dataset-panel-inactive'; $slot = $active ? "$name" : $sk->makeLinkObj( $dm->getTitleObject(), $name, "dataset=$prefix" ); $html .= "<tr><td class=\"$class\">$slot</td></tr>"; @@ -246,15 +246,15 @@ $html .= "</div>\n"; return $html; } - + /** @returns user interface html for copying Defined Meanings * between datasets. returns an empty string if the user * actually doesn't have permission to edit. */ protected function getCopyPanel() { - # mostly same code as in SpecialAddCollection... possibly might - # make a nice separate function + # mostly same code as in SpecialAddCollection... possibly might + # make a nice separate function global $wgUser; @@ -269,7 +269,7 @@ } /* Deprecated for now - + $html= getOptionPanel( array ( 'Copy to' => getSelect('CopyTo', $datasetarray) )); @@ -277,7 +277,7 @@ $html = $this->getCopyPanel2(); return $html; } - + /** links to futt bugly alternate copy mechanism, the * latter being something that actually is somewhat * understandable (though not yet refactored into @@ -286,7 +286,7 @@ protected function getCopyPanel2() { global $wgScriptPath, $wgCommunity_dc; - + $html = "Copy to:<br />\n"; $datasets = wdGetDatasets(); $dataset = $datasets[$wgCommunity_dc]; @@ -301,3 +301,64 @@ } +class DefinedMeanings { + + public function __construct() { + } + + /** + * returns an array of "Defined Meaning Id" objects + * for a language + * + * else returns null + */ + public static function getLanguageIdDefinedMeaningId( $languageId, $options = array(), $dc = null ) { + if ( is_null( $dc ) ) { + $dc = wdGetDataSetContext(); + } + $dbr = wfGetDB( DB_SLAVE ); + + if ( isset( $options['ORDER BY'] ) ) { + $cond['ORDER BY']= $options['ORDER BY']; + } else { + $cond['ORDER BY']= 'defined_meaning_id'; + } + + if ( isset( $options['LIMIT'] ) ) { + $cond['LIMIT']= $options['LIMIT']; + } + if ( isset( $options['OFFSET'] ) ) { + $cond['OFFSET']= $options['OFFSET']; + } + + $cond[] = 'DISTINCT'; + + $queryResult = $dbr->select( + array( + 'synt' => "{$dc}_syntrans", + 'exp' => "{$dc}_expression" + ), + 'defined_meaning_id', + array( + 'synt.expression_id = exp.expression_id', + 'language_id' => $languageId, + 'synt.remove_transaction_id' => null, + 'exp.remove_transaction_id' => null + ), + __METHOD__, + $cond + ); + + + $definedMeaningId = array(); + foreach ( $queryResult as $dm ) { + $definedMeaningId[] = $dm->defined_meaning_id; + } + $queryResult = array(); + + if ( $definedMeaningId ) { + return $definedMeaningId; + } + return null; + } +} diff --git a/OmegaWiki/Expression.php b/OmegaWiki/Expression.php index 01a0fd8..6fe9a5c 100644 --- a/OmegaWiki/Expression.php +++ b/OmegaWiki/Expression.php @@ -75,6 +75,8 @@ $cond['OFFSET']= $options['OFFSET']; } + $cond[] = 'DISTINCT'; + $queryResult = $dbr->select( "{$dc}_expression", 'spelling', @@ -96,4 +98,60 @@ } return null; } + + /** + * returns an array of "Expression" objects + * for a defined meaning id for a language + * + * else returns null + */ + public static function getDefinedMeaningIdAndLanguageIdExpressions( $languageId, $definedMeaningId, $options = array(), $dc = null ) { + if ( is_null( $dc ) ) { + $dc = wdGetDataSetContext(); + } + $dbr = wfGetDB( DB_SLAVE ); + + if ( isset( $options['ORDER BY'] ) ) { + $cond['ORDER BY']= $options['ORDER BY']; + } else { + $cond['ORDER BY']= 'spelling'; + } + + if ( isset( $options['LIMIT'] ) ) { + $cond['LIMIT']= $options['LIMIT']; + } + if ( isset( $options['OFFSET'] ) ) { + $cond['OFFSET']= $options['OFFSET']; + } + + $cond[] = 'DISTINCT'; + + $queryResult = $dbr->select( + array( + 'synt' => "{$dc}_syntrans", + 'exp' => "{$dc}_expression" + ), + 'spelling', + array( + 'synt.expression_id = exp.expression_id', + 'language_id' => $languageId, + 'defined_meaning_id' => $definedMeaningId, + 'synt.remove_transaction_id' => null, + 'exp.remove_transaction_id' => null + ), + __METHOD__, + $cond + ); + + $expression = array(); + foreach ( $queryResult as $exp ) { + $expression[] = $exp->spelling; + } + + if ( $expression ) { + return $expression; + } + return null; + } + } diff --git a/includes/formatCSV.php b/includes/formatCSV.php index f6e2771..9a61ce4 100644 --- a/includes/formatCSV.php +++ b/includes/formatCSV.php @@ -16,6 +16,10 @@ if( preg_match( '/\"/', $column ) ) { $column = str_replace( '"', '""', $column ); } - return '"' . $column . '"'; + $column = '"' . $column . '"'; + if ( $column == '""') { + return ''; + } + return $column; } } diff --git a/includes/jobs/OWOwdListJob.php b/includes/jobs/OWOwdListJob.php new file mode 100644 index 0000000..59b7c56 --- /dev/null +++ b/includes/jobs/OWOwdListJob.php @@ -0,0 +1,239 @@ +<?php +/** + * Create a list of OmegaWiki Developer data which can be used to generate + * Dictionaries. + * + * TODO + * Monolingual: + * Final download file would be compressed as owl_fra_csv.zip + * + */ + +global $wgWldOwScriptPath, $wgWldIncludesScriptPath; +require_once( $wgWldOwScriptPath . 'Attribute.php' ); +require_once( $wgWldOwScriptPath . 'DefinedMeaning.php' ); +require_once( $wgWldOwScriptPath . 'Expression.php' ); +require_once( $wgWldIncludesScriptPath . 'formatCSV.php' ); + +Class CreateOwdListJob extends Job { + + public function __construct( $title, $params ) { + parent::__construct( 'CreateOwdList', $title, $params ); + } + + /** + * Execute the job + * @return bool + */ + public function run() { + // Load data from $this->params and $this->title + if ( isset( $this->params['langcode'] ) ) { + $languageId = $this->params['langcode']; + } + + if ( isset( $this->params['type'] ) ) { + $type = $this->params['type']; + } + + if ( isset( $this->params['format'] ) ) { + $format = $this->params['format']; + } + + if ( isset( $this->params['start'] ) ) { + $start = $this->params['start']; + } + + // Perform your updates + + if ( $type && $languageId && $format && $start ) { + $this->createList( $type, $languageId, $format, $start ); + return true; + } + return false; + + } + + protected function createList( $type, $code, $format, $start ) { + global $wgWldDownloadScriptPath; + $csv = new WldFormatCSV(); + + // the greater the value of $sqlLimit the faster the download file is + // finished but the slower each web page loads while the job is being + // processed. + $sqlLimit = 100; + $ctrOver = $sqlLimit + 1; + + $options['OFFSET'] = $start; + + $options['LIMIT'] = $sqlLimit; + + // Why order by defined_meaning_id? To avoid duplication of words + // and skipping of some. When a language is constantly edited, + // order by spelling would not accurately get all unique expressions + // when job queued. + $options['ORDER BY'] = 'defined_meaning_id'; + + // language specifics + $languageId = getLanguageIdForIso639_3( $code ); + if ( !$languageId ) { + return false; + } + $this->DefinedMeanings = new DefinedMeanings; + $languageDefinedMeaningIds = DefinedMeanings::getLanguageIdDefinedMeaningId( $languageId, $options ); + + // create File name + $zippedAs = $type . "_$code" . ".$format"; + $synZippedAs = $type . '_syn_' . $code . ".$format"; + + $zipName = $wgWldDownloadScriptPath . $type . "_$code" . "_$format" . ".zip"; + + // When someone updates the file while someone is + // downloading the file, the file may ( in my mind ), + // be corrupted. So process it first as a temporary file, + // delete the original file, and rename the temporary file ~he + $tempFileName = $wgWldDownloadScriptPath; + $tempFileName .= $format . "_$type" . "_$code.tmp"; + $tempSynFileName = $wgWldDownloadScriptPath; + $tempSynFileName .= $format . "_$type" . '_syn_' . "$code.tmp"; + + if ( $start == 1 ) { + $translations = array(); + $fh = fopen ( $tempFileName, 'w' ); + $fhsyn = fopen ( $tempSynFileName, 'w' ); + } else { + $fh = fopen ( $tempFileName, 'a' ); + $fhsyn = fopen ( $tempSynFileName, 'a' ); + } + // Add data + $ctr = 0; + if ( $start != 0 ) { + + foreach ( $languageDefinedMeaningIds as $definedMeaningId ) { + + if ( $ctr != $ctrOver ) { + $text = getDefinedMeaningDefinitionForLanguage( $definedMeaningId, $languageId ); + $text = preg_replace( '/\n/', '\\n', $text ); + $text = $csv->formatCSVcolumn( $text ); + + $this->Expressions = new Expressions; + $expressions = Expressions::getDefinedMeaningIdAndLanguageIdExpressions( $languageId, $definedMeaningId ); + + $this->Attributes = new Attributes; + foreach ( $expressions as $spelling ) { + $IPA = null; + $hyphenation = null; + $example = null; + $usage = null; + + $expressionId = getExpressionId( $spelling, $languageId ); + $syntransId = getSynonymId( $definedMeaningId, $expressionId ); + $textAttributes = Attributes::getTextAttributes( $syntransId, array( 'languageId' => WLD_ENGLISH_LANG_ID ) ); + foreach ( $textAttributes as $row ) { + $row['text'] = preg_replace( '/\n/', '\\n', $row['text'] ); + $row['text'] = preg_replace( '/\t/', '\\t', $row['text'] ); + if ( $row['attribute_name'] == 'International Phonetic Alphabet') { + $IPA .= $row['text'] . ';'; + $row = array( 'text' => null, 'attribute_name' => null ); + } + if ( $row['attribute_name'] == 'hyphenation') { + $hyphenation .= $row['text'] . ';'; + $row = array( 'text' => null, 'attribute_name' => null ); + } + if ( $row['attribute_name'] == 'example sentence') { + $example .= $row['text'] . ';'; + $row = array( 'text' => null, 'attribute_name' => null ); + } + if ( $row['attribute_name'] == 'usage') { + $usage .= $row['text'] . ';'; + $row = array( 'text' => null, 'attribute_name' => null ); + } + // if ( $row['text'] != null ) { + // echo "TEXT: " . $row['attribute_name'] . " => "; + // echo $row['text'] . "\n"; + // } + } + $textAttributes = array(); + $IPA = preg_replace( '/;$/', '', $IPA ); + $hyphenation = preg_replace( '/;$/', '', $hyphenation ); + $example = preg_replace( '/;$/', '', $example ); + $usage = preg_replace( '/;$/', '', $usage ); + + $POS = null; + $oUsage = null; + $optionAttributes = Attributes::getOptionAttributes( $syntransId, array( 'languageId' => WLD_ENGLISH_LANG_ID ) ); + foreach ( $optionAttributes as $row ) { + $row['attribute_option_name'] = preg_replace( '/\n/', '\\n', $row['attribute_option_name'] ); + $row['attribute_option_name'] = preg_replace( '/\t/', '\\t', $row['attribute_option_name'] ); + if ( $row['attribute_name'] == 'part of speech' ) { + $POS .= $row['attribute_option_name'] . ';'; + $row = array( 'attribute_option_name' => null, 'attribute_name' => null ); + } + if ( $row['attribute_name'] == 'usage' ) { + $oUsage .= $row['attribute_option_name'] . ';'; + $row = array( 'attribute_option_name' => null, 'attribute_name' => null ); + } + // if ( $row['attribute_name'] != null ) { + // echo "OPTN: " . $row['attribute_name'] . " => "; + // echo $row['attribute_option_name'] . "\n"; + // } + } + $optionAttributes = array(); + $POS = preg_replace( '/;$/', '', $POS ); + $oUsage = preg_replace( '/;$/', '', $oUsage ); + + fwrite( $fhsyn, + $definedMeaningId . + ',' . $languageId . + ',' . $syntransId . + ',' . $csv->formatCSVcolumn( $spelling ) . + ',' . $csv->formatCSVcolumn( $IPA ) . + ',' . $csv->formatCSVcolumn( $hyphenation ) . + ',' . $csv->formatCSVcolumn( $example ) . + ',' . $csv->formatCSVcolumn( $usage ) . + ',' . $csv->formatCSVcolumn( $POS ) . + ',' . $csv->formatCSVcolumn( $oUsage ) . + "\n" + ); + + } + + fwrite( $fh, + $definedMeaningId . + ',' . $languageId . + ',' . $text . + "\n" + ); + } + $ctr ++; + + } + + } + fclose( $fh ); + fclose( $fhsyn ); + + // incomplete job + if ( $ctr == $sqlLimit ) { + $jobParams = array( 'type' => $type, 'langcode' => $code, 'format' => $format ); + $jobParams['start'] = $start + $sqlLimit; + $jobName = 'User:JobQuery/' . $type . '_' . $code . '.' . $format; + $title = Title::newFromText( $jobName ); + $job = new CreateOwdListJob( $title, $jobParams ); + JobQueueGroup::singleton()->push( $job ); // mediawiki >= 1.21 + } else { // complete job + // Zip file + if ( file_exists( $zipName ) ) { + unlink( $zipName ); + } + $zip = new ZipArchive(); + $zip->open( $zipName, ZipArchive::CREATE ); + $zip->addfile( $tempFileName, $zippedAs ); + $zip->addfile( $tempSynFileName, $synZippedAs ); + $zip->close(); + unlink( $tempFileName ); + unlink( $tempSynFileName ); + } + + } + +} diff --git a/includes/setup/OWJobs.php b/includes/setup/OWJobs.php index 4f1ff76..5422366 100644 --- a/includes/setup/OWJobs.php +++ b/includes/setup/OWJobs.php @@ -17,10 +17,14 @@ # Location of the job classes (Tell MediaWiki to load this file) $wgAutoloadClasses['CreateExpressionListJob'] = $wgWldJobsScriptPath . 'OWExpressionListJob.php'; $wgAutoloadClasses['CreateDefinedExpressionListJob'] = $wgWldJobsScriptPath . 'OWDefinedExpressionListJob.php'; +$wgAutoloadClasses['CreateOwdListJob'] = $wgWldJobsScriptPath . 'OWOwdListJob.php'; +//$wgAutoloadClasses['CreateSynTransListJob'] = $wgWldJobsScriptPath . 'OWSynTransListJob.php'; # Tell MediaWiki about the jobs and its class name $wgJobClasses['CreateExpressionList'] = 'CreateExpressionListJob'; $wgJobClasses['CreateDefinedExpressionList'] = 'CreateDefinedExpressionListJob'; +$wgJobClasses['CreateOwdList'] = 'CreateOwdListJob'; +//$wgJobClasses['CreateSynTransList'] = 'CreateSynTransListJob'; // Return true so that MediaWiki continues to load extensions. return true; diff --git a/includes/specials/SpecialOWDownloads.php b/includes/specials/SpecialOWDownloads.php index 709cd33..e790415 100644 --- a/includes/specials/SpecialOWDownloads.php +++ b/includes/specials/SpecialOWDownloads.php @@ -59,6 +59,18 @@ JobQueueGroup::singleton()->push( $job ); // mediawiki >= 1.21 } } + // update Owd + if ( preg_match( '/^owd_/', $fileName ) ) { + preg_match( '/_(.+)\.(.+)/', $fileName, $match ); + $jobName = 'JobQuery/' . $fileName; + $jobParams = array( 'type' => 'owd', 'langcode' => $match[1], 'format' => $match[2], 'start' => '1' ); + $jobExist = $wldJobs->downloadJobExist( $jobName ); + if ( $jobExist == false ) { + $title = Title::newFromText( 'User:' . $jobName ); + $job = new CreateOwdListJob( $title, $jobParams ); + JobQueueGroup::singleton()->push( $job ); // mediawiki >= 1.21 + } + } } // Segregate by groups @@ -74,6 +86,10 @@ // translations if ( preg_match( '/^trans_/', $files ) ) { $translations[] = "$files"; + } + // OmegaWiki Development + if ( preg_match( '/^owd_.+zip$/', $files ) ) { + $development[] = "$files"; } } @@ -98,6 +114,13 @@ $wikitext[] = $myLine . "\n|}\n"; } + // Process Development + if ( $development ) { + $wikitext[] = '===Development==='; + $myLine = $this->processText( $development ); + $wikitext[] = $myLine . "\n|}\n"; + } + // output wikitext foreach( $wikitext as $wikilines ) { $output->addWikiText( $wikilines ); @@ -116,6 +139,9 @@ if ( preg_match( '/^def_(.+)\./', $line, $match ) ) { $language = $match[1]; } + if ( preg_match( '/^owd_(.+)_csv\./', $line, $match ) ) { + $language = $match[1]; + } $languageId = getLanguageIdForIso639_3( $language ); // TODO: How to internationalize $nameLanguageId? $nameLanguageId = WLD_ENGLISH_LANG_ID; -- To view, visit https://gerrit.wikimedia.org/r/79176 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9d5b496d7bd09aecb49c3a8e2e41f785399ae42c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikiLexicalData Gerrit-Branch: master Gerrit-Owner: Hiong3-eng5 <hiong3.e...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits