小璋丸 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/285153

Change subject: Follow coding conventions (Line: 201~345)
......................................................................

Follow coding conventions (Line: 201~345)

Change-Id: I2a53437b747e9dafc29e5306d2c6c6ec73cf728b
---
M QuickGV.body.php
1 file changed, 49 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickGV 
refs/changes/53/285153/1

diff --git a/QuickGV.body.php b/QuickGV.body.php
index 6a5704e..13c5644 100644
--- a/QuickGV.body.php
+++ b/QuickGV.body.php
@@ -201,15 +201,17 @@
         // Output SVG
         $mtime = filemtime($svgfile);
         $html  = sprintf(
-            '<p>' +
-                '<embed type="image/svg+xml" '+
-                    'src="%s?t=%d" ' +
-                    'style="border:1px solid #777;" />' +
+            '<p>' .
+                '<embed src="%s?t=%d" type="image/svg+xml" ' .
+                'style="border:1px solid #777; ' .
+                'border-right-color: #444; ' .
+                'border-bottom-color: #444; ' .
+                'box-shadow:6px 6px 10px #999;" />' .
             '</p>',
             $svgurl, $mtime
         );
 
-        if ($showmeta==='true') {
+        if ( $showmeta === 'true' ) {
             // Get Graphviz version
             $cmd = sprintf('%s -V', escapeshellarg($dotcmd));
             self::pipeExec($cmd, '', $out, $err);
@@ -220,25 +222,45 @@
             // Get SVG size
             $size = self::getFriendlySize(filesize($svgfile));
 
-            // Generate table of metadata
-            $table_html = array();
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('filepath'), $svgurl);
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('filesize')->plain(), $size);
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('filemtime')->plain(), date('Y-m-d H:i:s', $mtime));
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%.3f 
%s</td></tr>', wfMessage('exectime')->plain(), $elapsed, 
wfMessage('quickgv-sec')->plain());
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('md5sum')->plain(), $sum_curr);
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('graphviz-path')->plain(), $dotcmd);
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s</td></tr>', 
wfMessage('graphviz-ver')->plain(), $verstr);
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;"><a href="%s" 
target="_blank">%2$s</a></td></tr>', wfMessage('graphviz-ref')->plain(), 
'http://www.graphviz.org/doc/info/attrs.html');
-            $table_html[] = sprintf('<tr><th 
style="white-space:nowrap;">%s</th><td style="text-align:left;">%s - <a 
href="https://www.mediawiki.org/wiki/Extension:QuickGV"; 
target="_blank">%s</a></td></tr>', wfMessage('quickgv-ver')->plain(), 
self::$version, wfMessage('quickgv-about')->plain());
-            $table_html = implode("\n", $table_html);
-            $table_html = sprintf('<table class="mw_metadata" 
style="width:600px; margin:5px 0 0 0;"><tbody>%s</tbody></table>', $table_html);
-            $html .= $table_html;
-            unset($table_html);
+            // Prepare field name and data
+            $about = sprintf('%s - <a href="%s" target="_blank">%s</a>',
+                self::$version,
+                'https://www.mediawiki.org/wiki/Extension:QuickGV',
+                wfMessage('quickgv-about')->plain()
+            );
+
+            $ref = sprintf('<a href="%s" target="_blank">%1$s</a>',
+                'http://www.graphviz.org/doc/info/attrs.html'
+            );
+
+            $rows = array(
+                array('filepath'     , $svgurl),
+                array('filesize'     , $size),
+                array('filemtime'    , date('Y-m-d H:i:s', $mtime)),
+                array('exectime'     , sprintf('%.3f %s', $elapsed, 
wfMessage('quickgv-sec')->plain())),
+                array('md5sum'       , $sum_curr),
+                array('quickgv-ver'  , $about),
+                array('graphviz-path', $dotcmd),
+                array('graphviz-ver' , $verstr),
+                array('graphviz-ref' , $ref),
+            );
+
+            $html .= '<table class="mw_metadata" style="width:600px; 
margin:5px 0 0 0;">';
+            $html .= '<tbody>';
+            foreach ( $rows as $row ) {
+                $html .= '<tr><th style="white-space:nowrap;">';
+                $html .= wfMessage($row[0])->plain();
+                $html .= '</th><td style="text-align:left;">';
+                $html .= $row[1];
+                $html .= '</td>';
+            }
+            $html .= '</tbody>';
+            $html .= '</table>';
+            unset($rows);
         }
 
         // TODO: Integrate Genshi
-        if ($showdot==='true') {
+        if ( $showdot === 'true' ) {
             $html .= sprintf('<pre>%s</pre>', $dotcode);
         }
 
@@ -264,10 +286,10 @@
      */
     private static function showError($msg='') 
     {
-        if ($msg==='') {
-            if (count(self::$errmsgs)>0) {
+        if ( $msg ==='' ) {
+            if ( count(self::$errmsgs) > 0 ) {
                 $html = '';
-                foreach (self::$errmsgs as $cached_msg) {
+                foreach ( self::$errmsgs as $cached_msg ) {
                     $html .= "<p>$cached_msg</p>";
                 }
 
@@ -309,11 +331,11 @@
             'showmeta' => 'bool',
         );
 
-        foreach ($formats as $prmk => $patk) {
-            if (isset($params[$prmk])) {
+        foreach ( $formats as $prmk => $patk ) {
+            if ( isset($params[$prmk]) ) {
                 $param = $params[$prmk];
                 $pattern = $patterns[$patk];
-                if (!preg_match($pattern, $param)) {
+                if ( !preg_match($pattern, $param) ) {
                     // TODO: i18n
                     $msg = sprintf('Attribute %s="%s" needs %s.', $prmk, 
$param, $descs[$patk]);
                     self::addError($msg);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a53437b747e9dafc29e5306d2c6c6ec73cf728b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/QuickGV
Gerrit-Branch: master
Gerrit-Owner: 小璋丸 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to