2 defined('_JEXEC') or die('Restricted access'); // no direct access
4 if (!defined('_ARTX_FUNCTIONS')) {
6 define('_ARTX_FUNCTIONS', 1);
8 function artxHasMessages()
11 $messages = $mainframe->getMessageQueue();
12 if (is_array($messages) && count($messages))
13 foreach ($messages as $msg)
14 if (isset($msg['type']) && isset($msg['message']))
19 function artxUrlToHref($url)
23 if (isset($p['scheme']) && isset($p['host'])) {
24 $result = $p['scheme'] . '://';
25 if (isset($p['user'])) {
26 $result .= $p['user'];
27 if (isset($p['pass']))
28 $result .= ':' . $p['pass'];
31 $result .= $p['host'];
32 if (isset($p['port']))
33 $result .= ':' . $p['port'];
34 if (!isset($p['path']))
37 if (isset($p['path']))
38 $result .= $p['path'];
39 if (isset($p['query'])) {
40 $result .= '?' . str_replace('&', '&', $p['query']);
42 if (isset($p['fragment']))
43 $result .= '#' . $p['fragment'];
47 function artxPost($caption, $content)
49 $hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
50 $hasContent = (null !== $content && strlen(trim($content)) > 0);
52 if (!$hasCaption && !$hasContent)
58 <div class="Post-body">
59 <div class="Post-inner">
61 <?php if ($hasCaption): ?>
62 <h2 class="PostHeaderIcon-wrapper"> <span class="PostHeader">
63 <?php echo $caption; ?>
68 <?php if ($hasContent): ?>
69 <div class="PostContent">
71 <?php echo $content; ?>
74 <div class="cleared"></div>
84 return ob_get_clean();
87 function artxBlock($caption, $content)
89 $hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
90 $hasContent = (null !== $content && strlen(trim($content)) > 0);
92 if (!$hasCaption && !$hasContent)
98 <div class="Block-tl"></div>
99 <div class="Block-tr"></div>
100 <div class="Block-bl"></div>
101 <div class="Block-br"></div>
102 <div class="Block-tc"></div>
103 <div class="Block-bc"></div>
104 <div class="Block-cl"></div>
105 <div class="Block-cr"></div>
106 <div class="Block-cc"></div>
107 <div class="Block-body">
109 <?php if ($hasCaption): ?>
110 <div class="BlockHeader">
111 <div class="l"></div>
112 <div class="r"></div>
113 <div class="header-tag-icon">
115 <?php echo $caption; ?>
120 <?php if ($hasContent): ?>
121 <div class="BlockContent">
122 <div class="BlockContent-body">
124 <?php echo $content; ?>
135 return ob_get_clean();
138 function artxPageTitle($page, $criteria = null, $key = null)
140 if ($criteria === null)
141 $criteria = $page->params->def('show_page_title', 1);
143 ? ('<span class="componentheading' . $page->params->get('pageclass_sfx') . '">'
144 . $page->escape($page->params->get($key === null ? 'page_title' : $key)) . '</span>')
148 function artxCountModules($document, $position)
150 if (null == $document)
152 return mosCountModules($position);
154 return $document->countModules($position);
157 function artxPositions($document, $positions, $style)
160 if (count($positions) == 3) {
161 if (artxCountModules($document, $positions[0])
162 && artxCountModules($document, $positions[1])
163 && artxCountModules($document, $positions[2]))
166 <table class="position" cellpadding="0" cellspacing="0" border="0">
168 <td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
169 <td width="33%"><?php echo artxModules($document, $positions[1], $style); ?></td>
170 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
174 } elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
176 <table class="position" cellpadding="0" cellspacing="0" border="0">
178 <td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
179 <td><?php echo artxModules($document, $positions[1], $style); ?></td>
183 } elseif (artxCountModules($document, $positions[1]) && artxCountModules($document, $positions[2])) {
185 <table class="position" cellpadding="0" cellspacing="0" border="0">
187 <td width="67%"><?php echo artxModules($document, $positions[1], $style); ?></td>
188 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
192 } elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[2])) {
194 <table class="position" cellpadding="0" cellspacing="0" border="0">
196 <td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
197 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
202 echo artxModules($document, $positions[0], $style);
203 echo artxModules($document, $positions[1], $style);
204 echo artxModules($document, $positions[2], $style);
206 } elseif (count($positions) == 2) {
207 if (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
209 <table class="position" cellpadding="0" cellspacing="0" border="0">
211 <td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
212 <td><?php echo artxModules($document, $positions[1], $style); ?></td>
217 echo artxModules($document, $positions[0], $style);
218 echo artxModules($document, $positions[1], $style);
220 } // count($positions)
221 return ob_get_clean();
224 function artxGetContentCellStyle($document)
226 $leftCnt = artxCountModules($document, 'left');
227 $rightCnt = artxCountModules($document, 'right');
228 if ($leftCnt > 0 && $rightCnt > 0)
231 return 'content-sidebar1';
233 return 'content-sidebar2';
234 return 'content-wide';
237 function artxHtmlFixMoveScriptToHead($re, $content)
239 if (preg_match($re, $content, $matches, PREG_OFFSET_CAPTURE)) {
240 $content = substr($content, 0, $matches[0][1])
241 . substr($content, $matches[0][1] + strlen($matches[0][0]));
242 $document =& JFactory::getDocument();
243 $document->addScriptDeclaration($matches[1][0]);
248 function artxHtmlFixFormAction($content)
250 if (preg_match('~ action="([^"]+)" ~', $content, $matches, PREG_OFFSET_CAPTURE)) {
251 $content = substr($content, 0, $matches[0][1])
252 . ' action="' . artxUrlToHref($matches[1][0]) . '" '
253 . substr($content, $matches[0][1] + strlen($matches[0][0]));
258 function artxHtmlFixRemove($re, $content)
260 if (preg_match($re, $content, $matches, PREG_OFFSET_CAPTURE)) {
261 $content = substr($content, 0, $matches[0][1])
262 . substr($content, $matches[0][1] + strlen($matches[0][0]));
267 function artxComponentWrapper($document)
269 if (null == $document) {
274 if ($document->getType() != 'html') return;
275 $option = JRequest::getCmd('option');
276 $view = JRequest::getCmd('view');
277 $layout = JRequest::getCmd('layout');
278 $content = $document->getBuffer('component');
279 // fixes for w3.org validation
280 if ('com_contact' == $option) {
281 if ('category' == $view) {
282 $content = artxHtmlFixFormAction($content);
283 } elseif ('contact' == $view) {
284 $content = artxHtmlFixMoveScriptToHead('~<script [^>]+>\s*(<!--[^>]*-->)\s*</script>~', $content);
286 } elseif ('com_content' == $option) {
287 if ('category' == $view) {
289 $content = artxHtmlFixMoveScriptToHead('~<script [^>]+>([^<]*)</script>~', $content);
290 $content = artxHtmlFixFormAction($content);
292 } elseif ('archive' == $view) {
293 $content = artxHtmlFixRemove('~<ul id="archive-list" style="list-style: none;">\s*</ul>~', $content);
295 } elseif ('com_user' == $option) {
296 if ('user' == $view) {
297 if ('form' == $layout) {
298 $content = artxHtmlFixRemove('~autocomplete="off"~', $content);
302 if (false === strpos($content, '<div class="Post">')) {
304 if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
305 $content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
306 $title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
308 $document->setBuffer(artxPost($title, $content), 'component');
312 function artxComponent()
317 $content = ob_get_clean();
318 if (false === strpos($content, '<div class="Post">')) {
320 if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
321 $content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
322 $title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
324 return artxPost($title, $content);
329 function artxModules($document, $position, $style = null)
331 if ($document == null) {
334 mosLoadModules($position, -2);
335 $content = ob_get_clean();
336 if (null == $style || 'xhtml' == $style)
338 $decorator = 'artblock' == $style ? 'artxBlock' : ('artpost' == $style ? 'artxPost' : null);
340 $modules = preg_split('~</div>\s*<div class="moduletable">~', $content);
341 $lastModule = count($modules) - 1;
342 if ($lastModule > -1) {
343 $modules[0] = preg_replace('~^\s*<div class="moduletable">~', '', $modules[0]);
344 $modules[$lastModule] = preg_replace('~</div>\s*$~', '', $modules[$lastModule]);
345 foreach ($modules as $module) {
346 if (preg_match('~^\s*<h3>([^<]*)</h3>~', $module, $matches, PREG_OFFSET_CAPTURE)) {
347 $result .= $decorator($matches[1][0], substr($module, 0, $matches[0][1])
348 . substr($module, $matches[0][1] + strlen($matches[0][0])));
350 $result .= $decorator(null, $module);
357 return '<jdoc:include type="modules" name="' . $position . '"' . (null != $style ? ' style="' . $style . '"' : '') . ' />';