]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_xml_language.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugSrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
24 // -------------------------------------------------------------------
26 // -------------------------------------------------------------------
29 if (empty($this->path
) AND empty($this->xmldata
))
34 if (!empty($this->path
))
36 if (($fdata = @file_get_contents($this->path
)) !== false)
38 $this->xmldata
= $fdata;
52 // -------------------------------------------------------------------
53 // -- Parses the XML data
54 // -------------------------------------------------------------------
59 if (empty($this->xmldata
))
64 $this->phrases
= array();
65 $this->languageinfo
= array();
67 if (!$bugsys->is_loaded('xml'))
72 $data = $bugsys->xml
->parse($this->xmldata
);
74 foreach ($data AS $tag)
76 if ($tag['tagname'] == 'language')
78 $this->languageinfo
= $tag['attributes'];
79 if ($this->languageinfo
['MASTER'] == 'MASTER')
82 unset($this->languageinfo
['MASTER']);
85 else if ($tag['tagname'] == 'phrase')
87 $this->phrases
[ $tag['attributes']['name'] ] = $tag['data'];
92 // -------------------------------------------------------------------
93 // -- Returns a query that creates a language
94 // -------------------------------------------------------------------
100 INSERT INTO " . TABLE_PREFIX
. "language
101 (title, languagecode, charset, direction, default, userselect)
103 ('" . $bugsys->escape($this->languageinfo
['title']) . "',
104 '" . $bugsys->escape($this->languageinfo
['languagecode']) . "',
105 '" . $bugsys->escape($this->languageinfo
['charset']) . "',
106 '" . $bugsys->escape($this->languageinfo
['direction']) . "', 0, 0
112 // -------------------------------------------------------------------
113 // -- Constructs the MySQL query to insert phrases
114 // -------------------------------------------------------------------
122 INSERT INTO " . TABLE_PREFIX
. "phrase
123 (varname, phrasetext, imported)
126 foreach ($this->phrases
AS $name => $text)
129 ('" . $bugsys->escape($name) . "', '" . $bugsys->escape($text) . "', " . time() . ")";
132 $query .= implode(',', $querybuild);
136 if (!$this->languageid
)
142 INSERT INTO " . TABLE_PREFIX
. "locale
143 (languageid, varname, phrasetext)
146 foreach ($this->phrases
AS $name => $text)
149 ({$this->languageid}, '" . $bugsys->escape($name) . "', '" . $bugsys->escape($text) . "')";
152 $query .= implode(',', $querybuild);
158 // -------------------------------------------------------------------
159 // -- Constructs XML data for export
160 // -------------------------------------------------------------------
161 function export($languageid)
165 // attributes for the root tag
168 if ($languageid != -1)
170 $language = $bugsys->db
->query_first("SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . intval($languageid));
176 $attrs['title'] = $language['title'];
177 $attrs['languagecode'] = $language['languagecode'];
178 $attrs['charset'] = $language['charset'];
179 $attrs['direction'] = $language['direction'];
181 $phrasefetch = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "locale WHERE languageid = $language[languageid] ORDER BY varname ASC");
182 while ($phrase = $bugsys->db
->fetch_array($phrasefetch))
184 $phrases["$phrase[varname]"] = $phrase['phrasetext'];
186 $bugsys->db
->free_result($phrasefetch);
190 $attrs['MASTER'] = 'MASTER';
192 $phrasefetch = $bugsys->db
->query("SELECT * FROM " . TABLE_PREFIX
. "phrase ORDER BY varname ASC");
193 while ($phrase = $bugsys->db
->fetch_array($phrasefetch))
195 $phrases["$phrase[varname]"] = $phrase['phrasetext'];
197 $bugsys->db
->free_result($phrasefetch);
200 // construct the top notice
201 $xmlout = (($languageid == -1) ? '<!-- $' . 'HeadURL$
-->' . "\n" . '<!-- $' . 'Id$ -->' : '<!-- This file was automatically generated by BugStrike [#]version[#] -->') . "\n\n";
203 // construct the root tag
204 foreach ($attrs AS $name => $value)
206 $outattrs[] = $name . '="' . $bugsys->escape($value) . '"';
208 $xmlout .= '<language ' . implode(' ', $outattrs) . ">\n";
210 // construct the phrases
211 foreach ($phrases AS $varname => $text)
213 $xmlout .= "\t<phrase name=\"" . $bugsys->escape($varname) . "\"><![CDATA[$text]]></phrase>\n";
216 // construct the end root tag
217 $xmlout .= '</language>';
224 /*=====================================================================*\
225 || ###################################################################
228 || ###################################################################
229 \*=====================================================================*/