source: pvrrd/src/pvrrd/makeTagHTML.php @ 619

Last change on this file since 619 was 619, checked in by jemian, 12 years ago

relocate to more standard layout

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision Url Id
File size: 1.1 KB
Line 
1<?php
2
3//  purpose: formats an HTML (xml-compatible) tag (element).
4
5/*
6########### SVN repository information ###################
7# $Date: 2011-08-21 13:24:14 +0000 (Sun, 21 Aug 2011) $
8# $Author: jemian $
9# $Revision: 619 $
10# $HeadURL$
11# $Id: makeTagHTML.php 619 2011-08-21 13:24:14Z jemian $
12########### SVN repository information ###################
13*/
14
15  //-------------------------------------------------------------
16   
17function makeTagHTML ($fullTag, $content = '', $indent = 1) {
18    $parts = explode (" ", $fullTag);
19    $shortTag = $parts[0];
20    $tag = "<" . $fullTag . ">";
21    if (strlen($content)) {
22      if ($indent) {
23        $tag = $tag . "\n";
24        $indentation = "  ";
25        foreach (explode ("\n", $content) as $line) {
26          // indent each line of the content
27          if (strlen($line)) {
28            // printf ("%5d: <%s>\n", strlen($line), $line);
29            $tag = $tag . $indentation . $line . "\n";
30          }
31        }
32        $tag = $tag . "</" . $shortTag . ">";
33      } else {
34        $tag = $tag . $content . "</" . $shortTag . ">";
35      }
36    } else {
37      // short-form tag
38      $tag = "<" . $fullTag . " />";
39    }
40    return ($tag . "\n");
41  }
Note: See TracBrowser for help on using the repository browser.