r2187 - display line numbers in RackCode viewer
authorDenis Ovsienko <infrastation@yandex.ru>
Sat, 30 Aug 2008 11:06:51 +0000 (11:06 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Sat, 30 Aug 2008 11:06:51 +0000 (11:06 +0000)
 - make line numbers clickable in the warnings list

inc/code.php
inc/interface.php

index 07ea9636e69427423d9216d6609d9dd06f0f85f8..171ad5b444b8cf15f81386a96b5e79e345f2cbd7 100644 (file)
@@ -686,6 +686,12 @@ function locateSyntaxError ($stack)
        return 0;
 }
 
+function refRCLineno ($ln)
+{
+       global $root;
+       return "<a href='${root}?page=perms&tab=default#line${ln}'>line ${ln}</a>";
+}
+
 function getRackCodeWarnings ()
 {
        $ret = array();
@@ -747,7 +753,7 @@ function getRackCodeWarnings ()
                        }
                $ret[] = array
                (
-                       'header' => 'line ' . $lineno,
+                       'header' => refRCLineno ($lineno),
                        'class' => 'warning',
                        'text' => "Predicate '${pname}' is defined, but never used."
                );
@@ -759,7 +765,7 @@ function getRackCodeWarnings ()
                        case 'always true':
                                $ret[] = array
                                (
-                                       'header' => 'line ' . $sentence['lineno'],
+                                       'header' => refRCLineno ($sentence['lineno']),
                                        'class' => 'warning',
                                        'text' => "Expression is always true."
                                );
@@ -767,7 +773,7 @@ function getRackCodeWarnings ()
                        case 'always false':
                                $ret[] = array
                                (
-                                       'header' => 'line ' . $sentence['lineno'],
+                                       'header' => refRCLineno ($sentence['lineno']),
                                        'class' => 'warning',
                                        'text' => "Expression is always false."
                                );
@@ -785,7 +791,7 @@ function getRackCodeWarnings ()
                                if (isset ($fpcache[$sentence['type']][$fp]))
                                        $ret[] = array
                                        (
-                                               'header' => 'line ' . $sentence['lineno'],
+                                               'header' => refRCLineno ($sentence['lineno']),
                                                'class' => 'warning',
                                                'text' => 'Effective definition equals that at line ' . $fpcache[$sentence['type']][$fp]
                                        );
@@ -796,7 +802,7 @@ function getRackCodeWarnings ()
                                if (isset ($fpcache[$sentence['type']][$fp]))
                                        $ret[] = array
                                        (
-                                               'header' => 'line ' . $sentence['lineno'],
+                                               'header' => refRCLineno ($sentence['lineno']),
                                                'class' => 'warning',
                                                'text' => 'Effective condition equals that at line ' . $fpcache[$sentence['type']][$fp]
                                        );
@@ -831,7 +837,7 @@ function findAutoTagWarnings ($expr)
                                                return array();
                                        return array (array
                                        (
-                                               'header' => 'line ' . $expr['lineno'],
+                                               'header' => refRCLineno ($expr['lineno']),
                                                'class' => 'warning',
                                                'text' => "An object with ID '${recid}' does not exist."
                                        ));
@@ -841,7 +847,7 @@ function findAutoTagWarnings ($expr)
                                                return array();
                                        return array (array
                                        (
-                                               'header' => 'line ' . $expr['lineno'],
+                                               'header' => refRCLineno ($expr['lineno']),
                                                'class' => 'warning',
                                                'text' => "IPv4 network with ID '${recid}' does not exist."
                                        ));
@@ -851,7 +857,7 @@ function findAutoTagWarnings ($expr)
                                                return array();
                                        return array (array
                                        (
-                                               'header' => 'line ' . $expr['lineno'],
+                                               'header' => refRCLineno ($expr['lineno']),
                                                'class' => 'warning',
                                                'text' => "User account with ID '${recid}' does not exist."
                                        ));
@@ -862,7 +868,7 @@ function findAutoTagWarnings ($expr)
                                                return array();
                                        return array (array
                                        (
-                                               'header' => 'line ' . $expr['lineno'],
+                                               'header' => refRCLineno ($expr['lineno']),
                                                'class' => 'warning',
                                                'text' => "User account with name '${recid}' does not exist."
                                        ));
@@ -905,7 +911,7 @@ function findTagWarnings ($expr)
                                        return array();
                        return array (array
                        (
-                               'header' => 'line ' . $expr['lineno'],
+                               'header' => refRCLineno ($expr['lineno']),
                                'class' => 'warning',
                                'text' => "Tag '${expr['load']}' does not exist."
                        ));
index 9c4717560fe48699fa06693648abf276e4c034e5..491774f6c3f9f8dba15794e71f353881620b599e 100644 (file)
@@ -5072,7 +5072,14 @@ function dump ($var)
 function renderRackCodeViewer ()
 {
        $text = loadScript ('RackCode');
-       dump ($text);
+       echo '<table width="100%" border=0>';
+       $lineno = 1;
+       foreach (explode ("\n", $text) as $line)
+       {
+               echo "<tr><td class=tdright><a name=line${lineno}>${lineno}</td>";
+               echo "<td class=tdleft>${line}</td></tr>";
+               $lineno++;
+       }
 }
 
 function renderRackCodeEditor ()