changed git call from https to git readonly
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / core_XmlTag.php
1 <?php\r
2 // \r
3 /**\r
4  * XML Parser: this class defines an XML Tag   \r
5  */\r
6 \r
7 class XmlTag\r
8 {\r
9         private $tagName;\r
10         private $tagType;\r
11         private $tagLevel;\r
12         private $tagValue;\r
13         private $tagAttrib = array();\r
14 \r
15         // working on...\r
16         private $tagState; // True or false ; \r
17         //private $tagState; // 1=complete, 2=open, 3=cdata, 4=close\r
18         \r
19         /**\r
20          * Constructor: creates a XML tag object\r
21          *\r
22          * @param String $theTagName\r
23          * @param String $theTagType\r
24          * @param String $theTagLevel\r
25          * @param String $theTagValue\r
26          * @param Array $theTagAtrib\r
27          */\r
28         function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue,$theTagAtrib)\r
29 \r
30         // Constructor without attributes\r
31         //function __construct($theTagName,$theTagType,$theTagLevel,$theTagValue)\r
32         {\r
33                 $this->tagName = $theTagName;\r
34                 $this->tagType = $theTagType;\r
35                 $this->tagLevel = $theTagLevel;\r
36                 $this->tagValue = $theTagValue;\r
37                 $this->tagAttrib = $theTagAtrib;\r
38                 \r
39         } // __construct() end\r
40                 \r
41         public function getTagValue()\r
42         {\r
43                 return $this->tagValue;         \r
44         }\r
45         \r
46         public function getTagAttribute($attribName)\r
47         {\r
48                 if (isset($this->tagAttrib[$attribName]))\r
49                 {\r
50                         return $this->tagAttrib[$attribName];\r
51                 } else {\r
52                         return '';\r
53                 }\r
54 \r
55         }\r
56          \r
57         /**\r
58          * Adds a value to the xml tagValue\r
59          *\r
60          * @param String $theTagValueAdded The value to be added\r
61          */\r
62         public function addToTagValue($theTagValueAdded)\r
63         {\r
64                 $this->tagValue .= $theTagValueAdded;\r
65         }\r
66 \r
67         /**\r
68          * Adds a child xml tag as a value to other parent tag value. \r
69          * \r
70          * @param String $theTagAdded The tag yo be \r
71          * @param String $theTagState\r
72          */\r
73         public function addChildTagAsValue($theTagAdded,$theTagState,$theTagValue)\r
74         {\r
75                 \r
76                 // add <BR> Tag\r
77                 if (($theTagAdded=='BR') && ($theTagState=='complete'))\r
78                 {\r
79                         $this->tagValue .= '<BR/>'.$theTagValue;\r
80                 }\r
81                 \r
82                 // open and close Bold tag \r
83                 if (($theTagAdded=='B') && ($theTagState=='complete'))\r
84                 {\r
85                         $this->tagValue .= '<b>'.$theTagValue.'</b>';\r
86                 }\r
87 \r
88                 // open and close Italics tag \r
89                 if (($theTagAdded=='I') && ($theTagState=='complete'))\r
90                 {\r
91                         $this->tagValue .= '<i>'.$theTagValue.'</i>';\r
92                 }\r
93 \r
94                 if (($theTagAdded=='U') && ($theTagState=='complete'))\r
95                 {\r
96                         $this->tagValue .= '<u>'.$theTagValue.'</u>';\r
97                 }\r
98                 \r
99         } // end addChildTagAsValue\r
100 \r
101 \r
102         /**\r
103          * Adds an attribute and value to the XML tag   \r
104          *\r
105          * @param String $attName\r
106          * @param String $attValue\r
107          */\r
108         public function addAttribute($attName,$attValue)\r
109         {\r
110                 $this->tagAttrib[$attName] = $attValue;\r
111                 \r
112         } // end addAttribute()\r
113         \r
114         /**\r
115          * Set the state of the XML tag\r
116          *\r
117          * @param Boolean $theState True or False\r
118          */\r
119         public function setTagState($theState)\r
120         {\r
121                 $this->tagState = $theState;\r
122                 \r
123         } // end setTagState()\r
124 \r
125         /**\r
126          * Print all values of the XML tag as a String\r
127          */     \r
128         public function toString()\r
129         {\r
130                 // check if the tag is ready to show\r
131                 if ($this->tagState==true)\r
132                 {\r
133                         echo "<br><br><b>Tag Name: </b>". $this->tagName;\r
134                         echo "<br><b>Tag Type: </b>". $this->tagType;\r
135                         echo "<br><b>Tag Level: </b>". $this->tagLevel;\r
136                         echo "<br><b>Tag Value: </b>". $this->tagValue;\r
137                         \r
138                         // print data if the tag has attributes\r
139                         if (count($this->tagAttrib!=0))\r
140                         {\r
141                                 echo '<br/><b>Tag Attributes: </b>';\r
142                                 \r
143                                 // Display all tag attributes; name and value\r
144                                 foreach ($this->tagAttrib as $attribName => $attribValue)\r
145                                 {\r
146                                         echo '<br/>------'.$attribName.' = '.$attribValue;\r
147                                 } // foreach end\r
148                         \r
149                         } else {\r
150                                 echo '<br/>NO Attributes found.';\r
151                         } //end if attributes\r
152                         \r
153                 // end if is tag is ready\r
154                 } else {\r
155                         echo '<br/><br/> --- ops!! The XML tag is not ready .... Showing NO data';\r
156                 } // end if XML tag is ready\r
157                 \r
158         }// toString() end\r
159         \r
160         \r
161 } // end class XmlParse\r
162 ?>