Cheetah
ThingPage.php
Go to the documentation of this file.
1 <?php
2 
8 // parent object for all pages classes
9 
10 class ThingPage extends Thing
11 {
12 
13 // public functions
14 
18  function __construct ()
19  {
20  }
21 
22  function getLangs ()
23  {
24  global $gConf;
25 
26  $a = array ();
27  if (isset($gConf['dir']['langs'])) {
28  $d = dir($gConf['dir']['langs']);
29  while (FALSE !== ($entry = $d->read())) {
30  if ($entry[0] == '.')
31  continue;
32  $a[] = substr($entry, 0, 2);
33  }
34  }
35  return $a;
36  }
37 
38  function getLangsXml ()
39  {
40  return '<langs>' . array2xml($this->getLangs(), 'lang') . '</langs>';
41  }
42 
43  function getUrlsXml ()
44  {
45  global $gConf;
46 
47  $ret = '';
48 
49  $ret .= "<urls>";
50  $ret .= "<base>{$gConf['url']['base']}</base>\n";
51  $ret .= "<xsl_mode>{$gConf['xsl_mode']}</xsl_mode>";
52  $ret .= "<icon>{$gConf['url']['icon']}</icon>";
53  $ret .= "<img>{$gConf['url']['img']}</img>";
54  $ret .= "<css>{$gConf['url']['css']}</css>";
55  $ret .= "<xsl>{$gConf['url']['xsl']}</xsl>";
56  $ret .= "<js>{$gConf['url']['js']}</js>";
57  $ret .= "<editor>{$gConf['url']['editor']}</editor>";
58  $ret .= "</urls>\n";
59 
60  return $ret;
61  }
62 
63  function addHeaderFooter (&$li, $content)
64  {
65  global $gConf, $l;
66  global $glBeforeContent;
67  global $glAfterContent;
68  global $glAddToHeadSection;
69 
70  $ret = '';
71 
72  $ret .= "<root>\n";
73 
74  $ret .= '<index_begin><![CDATA[' . $GLOBALS['glIndexBegin'] . ']]></index_begin>';
75  $ret .= '<index_end><![CDATA[' . $GLOBALS['glIndexEnd'] . ']]></index_end>';
76 
77  $ret .= '<before_content><![CDATA['.$glBeforeContent.']]></before_content>';
78  $ret .= '<after_content><![CDATA['.$glAfterContent.']]></after_content>';
79  $ret .= '<add_to_head_section><![CDATA['.$glAddToHeadSection.']]></add_to_head_section>';
80 
81  $ret .= "<min_point>{$gConf['min_point']}</min_point>\n";
82 
83  $ret .= "<base>{$gConf['url']['base']}</base>\n";
84 
85  $ret .= "<title>" . (isset($gConf['title']) && $gConf['title'] ? $gConf['title'] : $gConf['def_title']) . "</title>\n";
86 
87  $integration_xml = '';
88  @include ($gConf['dir']['base'] . 'integrations/' . CH_ORCA_INTEGRATION . '/xml.php');
90 
91  $ret .= $this->getUrlsXml ();
92 
93  if (is_array($li)) {
94  $ret .= "<logininfo>";
95  foreach ($li as $k => $v) {
96  if ('role' == $k)
97  encode_post_text ($v);
98  elseif ('profile_title' == $k)
99  encode_post_text ($v);
100  $ret .= "<$k>$v</$k>";
101  }
102  $ret .= "</logininfo>";
103 
104  if (1 == $li['admin']) {
105  $ret .= $this->getLangsXml();
106  }
107  }
108 
109  $ret .= "<page>\n";
110 
111  $ret .= $content;
112 
113  $ret .= "</page>\n";
114 
115  $ret .= "</root>\n";
116 
117  return $ret;
118  }
119 
123  function getPageXML ($first_load = 1, &$p)
124  {
125  return $this->addHeaderFooter ($p, $this->content);
126  }
127 
133  function cacheWrite ($fn, $s)
134  {
135  global $gConf;
136 
137  if (!$gConf['cache']['on']) return;
138 
139  $f = fopen ($gConf['dir']['xmlcache'] . $fn, "w");
140 
141  if (!$f) {
142  $mk = new Mistake ();
143  $mk->log ("ThingPage::readCache - can not open file({$gConf['dir']['xmlcache']}$fn) for writing");
144  $mk->displayError ("[L[Site is unavailable]]");
145  }
146 
147  fwrite ($f, $s);
148 
149  fclose ($f);
150  }
151 
157  function cacheRead ($fn)
158  {
159  global $gConf;
160 
161  $f = fopen ($gConf['dir']['xmlcache'] . $fn, "r");
162 
163  if (!$f) {
164  $mk = new Mistake ();
165  $mk->log ("ThingPage::readCache - can not open file({$gConf['dir']['xmlcache']}$fn) for reading");
166  $mk->displayError ("[L[Site is unavailable]]");
167  }
168 
169  $s = '';
170  while ($st = fread ($f, 1024)) $s .= $st;
171 
172  fclose ($f);
173 
174  return $s;
175  }
176 
182  function cacheExists ($fn)
183  {
184  global $gConf;
185  return file_exists ($gConf['dir']['xmlcache'] . $fn);
186  }
187 
191  function cacheEnabled ()
192  {
193  global $gConf;
194  return $gConf['cache']['on'];
195  }
196 
197 // private functions
198 
199 }
$f
global $f
Definition: callback.php:13
encode_post_text
encode_post_text(&$s, $bEncodeSpecialChars=false, $bAutohyperlink=false)
Definition: util.inc.php:146
$ret
$ret
Definition: index.php:39
array2xml
array2xml($arr, $tag=false)
Definition: util.inc.php:60
ThingPage\cacheRead
cacheRead($fn)
Definition: ThingPage.php:157
CH_ORCA_INTEGRATION
const CH_ORCA_INTEGRATION
Definition: ChForumSiteMaps.php:10
php
Thing
Definition: Thing.php:9
Mistake
Definition: Mistake.php:11
ThingPage\cacheEnabled
cacheEnabled()
Definition: ThingPage.php:191
content
AutoFormat RemoveEmpty HTML Purifier will attempt to remove empty elements that contribute no semantic information to the document The following types of nodes will be and that are not empty and</li >< li > Tags with no content
Definition: AutoFormat.RemoveEmpty.txt:17
ThingPage\getUrlsXml
getUrlsXml()
Definition: ThingPage.php:43
ThingPage\cacheWrite
cacheWrite($fn, $s)
Definition: ThingPage.php:133
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$s
$s
Definition: embed.php:13
ThingPage\getLangs
getLangs()
Definition: ThingPage.php:22
ThingPage\getLangsXml
getLangsXml()
Definition: ThingPage.php:38
ThingPage\cacheExists
cacheExists($fn)
Definition: ThingPage.php:182
ThingPage
Definition: ThingPage.php:11
$integration_xml
$integration_xml
Definition: xml.php:23
ThingPage\getPageXML
getPageXML($first_load=1, &$p)
Definition: ThingPage.php:123
$gConf
global $gConf
Definition: header.inc.php:8
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ThingPage\__construct
__construct()
Definition: ThingPage.php:18
ThingPage\addHeaderFooter
addHeaderFooter(&$li, $content)
Definition: ThingPage.php:63
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10