Kipcool has submitted this change and it was merged.

Change subject: API:SynonymsTranslation - corrections etal
......................................................................


API:SynonymsTranslation - corrections etal

Change-Id: I8842cc163505a67803bc319ab50243b6a9606e43
---
M includes/api/owSyntrans.php
1 file changed, 28 insertions(+), 9 deletions(-)

Approvals:
  Kipcool: Verified; Looks good to me, approved



diff --git a/includes/api/owSyntrans.php b/includes/api/owSyntrans.php
index 8a46872..e201016 100644
--- a/includes/api/owSyntrans.php
+++ b/includes/api/owSyntrans.php
@@ -9,11 +9,12 @@
  *     @param  opt'l   str     part    'synonym or translation'
  *
  * HISTORY
+ * - 2013-06-13: Minimized data output, corrections. Error were
+ *             generated last time.
  * - 2013-06-11:
  *             * simplified synTrans function
  *             * renamed part_lang_id to lang
  *             * added option to exclude an expression from synonyms
- *
  * - 2013-06-08: Added
  *             @param  opt'l   str     part    'synonym or translation'
  *             @param  opt'l   int     prtlangid       'the param part's 
language id'
@@ -25,7 +26,8 @@
  * - Integrate with Define Class
  * - Transfer getSynonymAndTranslation function to WikiDataAPI when ready
  * - Add parameter
- *             @param  opt'l   str     e       'the expression spelling'
+ *             see below.
+ * - Add parameters to include sid, langid and im to output.
  *
  * QUESTION
  * - none
@@ -182,16 +184,28 @@
                $syntrans = array();
                $stList = getSynonymAndTranslation( $definedMeaningId );
 
+               $ctr = 1;
                foreach ( $stList as $row ) {
                        $language = getLanguageIdLanguageNameFromIds( $row[1], 
WLD_ENGLISH_LANG_ID );
 
                        $syntransRow = array (
-                               'syntrans_sid' => $row[3],
-                               'e' => $row[0],
+                               'sid' => $row[3],
                                'langid' => $row[1],
                                'lang' => $language,
+                               'e' => $row[0],
                                'im' => $row[2]
                        );
+
+                       // Minimal output
+                       if ( !isset( $options['iLangId'] ) ) {
+                               unset( $syntransRow['langid'] );
+                       }
+                       if ( !isset( $options['iSId'] ) ) {
+                               unset( $syntransRow['sid'] );
+                       }
+                       if ( !isset( $options['iIm'] ) ) {
+                               unset( $syntransRow['im'] );
+                       }
 
                        if ( isset( $options['part'] ) ) {
                                if ( $options['part'] == 'syn' and 
$options['lang'] == $row[1] ) {
@@ -199,25 +213,30 @@
                                                // skip the expression for the 
language id
                                                if ( $options['lang'] == 
$row[1] && $options['e'] == $row[0] ) {
                                                } else {
-                                                       $syntrans[] = 
$syntransRow;
+                                                       $syntrans["$ctr."] = 
$syntransRow;
+                                                       $ctr ++;
                                                }
                                        } else {
-                                               $syntrans[] = $syntransRow;
+                                               $syntrans["$ctr."] = 
$syntransRow;
+                                               $ctr ++;
                                        }
                                }
 
                                if ( $options['part'] == 'trans' and 
$options['lang'] != $row[1] ) {
-                                       $syntrans[] = $syntransRow;
+                                       $syntrans["$ctr."] = $syntransRow;
+                                       $ctr ++;
                                }
                        } else {
                                if ( isset( $options['lang']) && isset( 
$options['e'] ) ) {
                                        // skip the expression for the language 
id
                                        if ( $options['lang'] == $row[1] && 
$options['e'] == $row[0] ) {
                                        } else {
-                                               $syntrans[] = $syntransRow;
+                                               $syntrans["$ctr."] = 
$syntransRow;
+                                               $ctr ++;
                                        }
                                } else {
-                                       $syntrans[] = $syntransRow;
+                                       $syntrans["$ctr."] = $syntransRow;
+                                       $ctr ++;
                                }
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/68336
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8842cc163505a67803bc319ab50243b6a9606e43
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiLexicalData
Gerrit-Branch: master
Gerrit-Owner: Hiong3-eng5 <hiong3.e...@gmail.com>
Gerrit-Reviewer: Hiong3-eng5 <hiong3.e...@gmail.com>
Gerrit-Reviewer: Kipcool <kipmas...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to