array('has_header' => true),
'menu' => array('show_submenus' => false),
'vmenu' => array('show_submenus' => true, 'simple' => false)
);
function artxHasMessages()
{
global $mainframe;
$messages = $mainframe->getMessageQueue();
if (is_array($messages) && count($messages))
foreach ($messages as $msg)
if (isset($msg['type']) && isset($msg['message']))
return true;
return false;
}
function artxPost($caption, $content)
{
$hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
$hasContent = (null !== $content && strlen(trim($content)) > 0);
if (!$hasCaption && !$hasContent)
return '';
ob_start();
?>
')) {
$title = null;
if (preg_match('~
]*)>([^<]+)
~', $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
$title = '
' . $matches[3][0] . '';
}
$document->setBuffer(artxPost($title, $content), 'component');
}
}
function artxModules(&$document, $position, $style = null)
{
return '
';
}
function artxUrlToHref($url)
{
$result = '';
$p = parse_url($url);
if (isset($p['scheme']) && isset($p['host'])) {
$result = $p['scheme'] . '://';
if (isset($p['user'])) {
$result .= $p['user'];
if (isset($p['pass']))
$result .= ':' . $p['pass'];
$result .= '@';
}
$result .= $p['host'];
if (isset($p['port']))
$result .= ':' . $p['port'];
if (!isset($p['path']))
$result .= '/';
}
if (isset($p['path']))
$result .= $p['path'];
if (isset($p['query'])) {
$result .= '?' . str_replace('&', '&', $p['query']);
}
if (isset($p['fragment']))
$result .= '#' . $p['fragment'];
return $result;
}
function artxReplaceButtonsRegex() {
return '' .
'~
]*'
. '(?:'
. '[^>]*\bclass=(?:"(?:[^"]*\s)?button(?:\s[^"]*)?"|\'(?:[^\']*\s)?button(?:\s[^\']*)?\'|button\b)[^>]*'
. '(?:\bvalue=(?:"[^"]*"|\'[^\']*\'|[^>\s]*))'
. '|'
. '(?:\bvalue=(?:"[^"]*"|\'[^\']*\'|[^>\s]*))'
. '[^>]*\bclass=(?:"(?:[^"]*\s)?button(?:\s[^"]*)?"|\'(?:[^\']*\s)?button(?:\s[^\']*)?\'|button\b)[^>]*'
. '|'
. '[^>]*\bclass=(?:"(?:[^"]*\s)?button(?:\s[^"]*)?"|\'(?:[^\']*\s)?button(?:\s[^\']*)?\'|button\b)[^>]*'
. ')'
. '[^>]*/?\s*>~i';
}
function artxReplaceButtons($content)
{
$re = artxReplaceButtonsRegex();
if (!preg_match_all($re, $content, $matches, PREG_OFFSET_CAPTURE))
return $content;
$result = '';
$position = 0;
foreach ($matches[0] as $match) {
$result .= substr($content, $position, $match[1] - $position);
$position = $match[1] + strlen($match[0]);
$result .= '
'
. preg_replace('~\bclass=(?:"([^"]*\s)?button(\s[^"]*)?"|\'([^\']*\s)?button(\s[^\']*)?\'|button\b)~i',
'class="\1\3button art-button\2\4"', $match[0]) . '';
}
$result .= substr($content, $position);
return $result;
}
function artxHtmlFixFormAction($content)
{
if (preg_match('~ action="([^"]+)" ~', $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1])
. ' action="' . artxUrlToHref($matches[1][0]) . '" '
. substr($content, $matches[0][1] + strlen($matches[0][0]));
}
return $content;
}
$artxFragments = array();
function artxFragmentBegin($head = '')
{
global $artxFragments;
$artxFragments[] = array('head' => $head, 'content' => '', 'tail' => '');
}
function artxFragmentContent($content = '')
{
global $artxFragments;
$artxFragments[count($artxFragments) - 1]['content'] = $content;
}
function artxFragmentEnd($tail = '', $separator = '')
{
global $artxFragments;
$fragment = array_pop($artxFragments);
$fragment['tail'] = $tail;
$content = trim($fragment['content']);
if (count($artxFragments) == 0) {
echo (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
} else {
$result = (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
$fragment =& $artxFragments[count($artxFragments) - 1];
$fragment['content'] .= (trim($fragment['content']) == '' ? '' : $separator) . $result;
}
}
function artxFragment($head = '', $content = '', $tail = '', $separator = '')
{
global $artxFragments;
if ($head != '' && $content == '' && $tail == '' && $separator == '') {
$content = $head;
$head = '';
} elseif ($head != '' && $content != '' && $tail == '' && $separator == '') {
$separator = $content;
$content = $head;
$head = '';
}
artxFragmentBegin($head);
artxFragmentContent($content);
artxFragmentEnd($tail, $separator);
}
}