head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2006.07.28.09.53.35;	author rse;	state Exp;
branches;
next	1.1;
commitid	4J7yMKSAHh8tWBGr;

1.1
date	2006.03.14.21.40.30;	author rse;	state Exp;
branches;
next	;
commitid	zIew5Rj5zfd1ecpr;


desc
@@


1.2
log
@avoid variable 'this' as this is a PHP5 OO feature
@
text
@<script language="php">
##
##  Copyright (c) 2005-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
##  Copyright (c) 2005-2006 Ralf S. Engelschall <http://engelschall.com/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  canvas-nav-xref.php: canvas navigation cross-referencing links
##
</script>

<script language="php">
  divert("css");
</script>

div.nav_seealso {
    color:       #605040;
}

div.nav_seealso a {
    font-weight: normal;
    color:       #000000;
}

div.nav_path {
    color:       #605040;
}
div.nav_path a {
    font-weight: normal;
    color:       #000000;
}

<script language="php">
  function navpage($html, $id, $txt) {
      $result = null;
      if (preg_match('/<li id="'.$id.'"><a href="([^"]+)">(.+?)<\/a>/s', $html, $match)) {
          $href = $match[1];
          if ($txt == "")
              $txt = $match[2];
          $result = array("href" => $href, "txt" => $txt);
      }
      return $result;
  }

  function nav_paths($html, $ini, $here) {
      $keys = array_keys($ini);
      for ($i = 0; $i < count($keys); $i++) {
          if (preg_match('/^path:\s+(.+?)\s*$/s', $keys[$i], $match)) {
              $name = $match[1];
              $path = array_keys($ini[$keys[$i]]);
              for ($j = 0; $j < count($path); $j++) {
                  if ($path[$j] == $here) {
                      echo "<p/>\n";
                      echo "<div class=\"nav_path\">\n";
                      echo "$name:<br/>\n";
                      if ($j-1 >= 0) {
                          $page = navpage($html, $path[$j-1], $ini[$keys[$i]][$path[$j-1]]);
                          if (!is_null($page))
                              echo "&larr; <a href=\"".$page["href"]."\">".$page["txt"]."</a><br/>\n";
                      }
                      if ($j+1 <= count($path)) {
                          $page = navpage($html, $path[$j+1], $ini[$keys[$i]][$path[$j+1]]);
                          if (!is_null($page))
                              echo "&rarr; <a href=\"".$page["href"]."\">".$page["txt"]."</a><br/>\n";
                      }
                      echo "</div>\n";
                  }
              }
          }
      }
  }

  function nav_seealso($html, $ini, $here) {
      $seealso = Array();
      $also = $ini["also: $here"];
      if (!is_null($also)) {
          $keys = array_keys($also);
          for ($i = 0; $i < count($keys); $i++) {
              $page = navpage($html, $keys[$i], $also[$keys[$i]]);
              if (!is_null($page))
                  array_push($seealso, "<a href=\"".$page["href"]."\">".$page["txt"]."</a>");
          }
      }
      $seealso = implode(", ", $seealso);
      if ($seealso != "") {
          echo "<p/>\n";
          echo "<div class=\"nav_seealso\">\n";
          echo "See Also:<br/>\n" . $seealso;
          echo "</div>\n";
      }
  }

  $html = undivert("nav");
  $ini = parse_ini_file("canvas-nav.ini", TRUE);
  divert("canvas-nav");
  nav_paths($html, $ini, $opt["path"]);
  nav_seealso($html, $ini, $opt["path"]);
</script>

@


1.1
log
@first cut for page cross-referencing support
@
text
@d61 1
a61 1
  function nav_paths($html, $ini, $this) {
d68 1
a68 1
                  if ($path[$j] == $this) {
d89 1
a89 1
  function nav_seealso($html, $ini, $this) {
d91 1
a91 1
      $also = $ini["also: $this"];
@

