2 defined('_JEXEC') or die;
4 if (!defined('_ARTX_FUNCTIONS')) {
6 define('_ARTX_FUNCTIONS', 1);
8 $GLOBALS['artx_settings'] = array(
9 'block' => array('has_header' => true),
10 'menu' => array('show_submenus' => true),
11 'vmenu' => array('show_submenus' => true, 'simple' => false)
15 * Base class with index.php view routines. Contains method for placing positions,
16 * calculating classes, decorating components. Version-specific routines are defined
17 * in subclasses: ArtxPage15 and ArtxPage16.
19 abstract class ArtxPageView
24 protected function __construct($page) {
29 * Returns version-specific body class: joomla15 or joomla16.
32 * <body class="joomla15">
34 abstract function bodyClass();
37 * Checks whether Joomla! has system messages to display.
39 abstract function hasMessages();
42 * Returns true when one of the given positions contains at least one module.
44 * if ($obj->containsModules('top1', 'top2', 'top3')) {
45 * // the following code will be executed when one of the positions contain modules:
49 function containsModules()
51 foreach (func_get_args() as $position)
52 if (0 != $this->page->countModules($position))
58 * Builds list of positions, collapsing the empty ones.
62 * No empty positions: 25%:25%:25%:25%
63 * With one empty positions: -:50%:25%:25%, 50%:-:25%:25%, 25%:50%:-:25%, 25%:25%:50%:-
64 * With two empty positions: -:-:75%:25%, -:50%:-:50%, -:50%:50%:-, -:50%:50%:-, 75%:-:-:25%, 50%:-:50%:-, 25%:75%:-:-
65 * One non-empty position: 100%
67 * No empty positions: 33%:33%:34%
68 * With one empty position: -:66%:34%, 50%:-:50%, 33%:67%:-
69 * One non-empty position: 100%
71 function positions($positions, $style) {
72 // Build $cells by collapsing empty positions:
76 foreach ($positions as $name => $width) {
77 if ($this->containsModules($name)) {
78 $cells[$name] = $buffer + $width;
81 } else if (null == $cell)
84 $cells[$cell] += $width;
87 // Backward compatibility:
88 // For three equal width columns with empty center position width should be 50/50:
89 if (3 == count($positions) && 2 == count($cells)) {
90 $columns1 = array_keys($positions);
91 $columns2 = array_keys($cells);
92 if (33 == $positions[$columns1[0]] && 33 == $positions[$columns1[1]] && 34 == $positions[$columns1[2]]
93 && $columns2[0] == $columns1[0] && $columns2[1] == $columns1[2])
94 $cells[$columns2[0]] = 50;
95 $cells[$columns2[1]] = 50;
99 if (count($cells) == 0)
101 if (count($cells) == 1)
102 foreach ($cells as $name => $width)
103 return $this->position($name, $style);
104 $result = '<table class="position" cellpadding="0" cellspacing="0" border="0">';
105 $result .= '<tr valign="top">';
106 foreach ($cells as $name => $width)
107 $result .='<td width="' . $width. '%">' . $this->position($name, $style) . '</td>';
109 $result .= '</table>';
113 function position($position, $style = null)
115 return '<jdoc:include type="modules" name="' . $position . '"' . (null != $style ? ' style="artstyle" artstyle="' . $style . '"' : '') . ' />';
119 * Preprocess component content before printing it.
121 function componentWrapper()
126 * Checks layout sidebar cells and returns content cell class that expands content cell over empty sidebar.
128 function contentCellClass($cells)
130 $nonEmptyCells = array();
131 $emptyCells = array();
132 foreach ($cells as $name => $class) {
133 if ('content' == $name)
135 if ($this->containsModules($name))
136 $nonEmptyCells[] = $class;
138 $emptyCells[] = $class;
140 switch (count($emptyCells)) {
142 return 'content-wide';
144 if (count($nonEmptyCells))
145 return 'content-' . $emptyCells[0];
152 class ArtxPage15 extends ArtxPageView
154 public function __construct($page) {
155 parent::__construct($page);
158 function bodyClass() {
162 function hasMessages()
165 $messages = $mainframe->getMessageQueue();
166 if (is_array($messages) && count($messages))
167 foreach ($messages as $msg)
168 if (isset($msg['type']) && isset($msg['message']))
174 * Wraps component content into article style unless it is not wrapped already.
176 * The componentWrapper method gets the content of the 'component' buffer and search for the '<div class="art-post">' string in it.
177 * Then it replaces the componentheading DIV tag with span (to fix the w3.org validation) and replaces content of the buffer with
180 function componentWrapper()
182 if ($this->page->getType() != 'html')
184 $option = JRequest::getCmd('option');
185 $view = JRequest::getCmd('view');
186 $layout = JRequest::getCmd('layout');
187 if ('com_content' == $option && ('frontpage' == $view || 'article' == $view || ('category' == $view && 'blog' == $layout)))
189 $content = $this->page->getBuffer('component');
190 if (false === strpos($content, '<div class="art-post')) {
192 if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
193 $content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
194 $title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
196 $this->page->setBuffer(artxPost(array('header-text' => $title, 'content' => $content)), 'component');
201 class ArtxPage16 extends ArtxPageView
203 public function __construct($page) {
204 parent::__construct($page);
207 function bodyClass() {
211 function hasMessages()
213 $messages = JFactory::getApplication()->getMessageQueue();
214 if (is_array($messages) && count($messages))
215 foreach ($messages as $msg)
216 if (isset($msg['type']) && isset($msg['message']))
222 * Wraps component content into article style unless it is not wrapped already.
224 * The componentWrapper method gets the content of the 'component' buffer and search for the '<div class="art-post">' string in it.
225 * Then it wraps content of the buffer with art-post.
227 function componentWrapper()
229 if ($this->page->getType() != 'html')
231 $option = JRequest::getCmd('option');
232 $view = JRequest::getCmd('view');
233 $layout = JRequest::getCmd('layout');
234 if ('com_content' == $option && ('featured' == $view || 'article' == $view || ('category' == $view && 'blog' == $layout)))
236 $content = $this->page->getBuffer('component');
237 if (false === strpos($content, '<div class="art-post'))
238 $this->page->setBuffer(artxPost(array('header-text' => null, 'content' => $content)), 'component');
243 * Base class with content page routines for rendering page header and article factory.
245 abstract class ArtxContentView
247 protected $_component;
248 protected $_componentParams;
251 * Component page class suffix.
254 public $pageClassSfx;
259 public $showPageHeading;
262 * Page heading (or page title).
267 protected function __construct($component, $params)
269 $this->_component = $component;
270 $this->_componentParams = $params;
273 abstract function pageHeading($heading = null);
274 abstract function article($article, $print);
275 abstract function articleListItem($item);
277 public function beginPageContainer($class)
279 return '<div class="' . $class . $this->pageClassSfx .'">';
282 public function endPageContainer()
288 class ArtxContent15 extends ArtxContentView
290 public function __construct($component, $params)
292 parent::__construct($component, $params);
293 $this->pageClassSfx = $this->_componentParams->get('pageclass_sfx');
294 $this->showPageHeading = $this->_componentParams->def('show_page_title', 1);
295 $this->pageHeading = $this->showPageHeading ? $this->_componentParams->get('page_title') : '';
298 function pageHeading($heading = null)
300 return artxPost(array('header-text' => null == $heading ? $this->pageHeading : $heading));
303 function article($article, $print)
305 return new ArtxContentArticleView15($this->_component, $this->_componentParams, $article, $print);
308 function articleListItem($item)
310 return new ArtxContentFrontpageItemView15($this->_component, $this->_componentParams, $item);
314 class ArtxContent16 extends ArtxContentView
316 public function __construct($component, $params)
318 parent::__construct($component, $params);
319 $this->pageClassSfx = $this->_component->pageclass_sfx;
320 $this->showPageHeading = $this->_componentParams->def('show_page_heading', 1);
321 $this->pageHeading = $this->showPageHeading ? $this->_componentParams->get('page_heading') : '';
324 function pageHeading($heading = null)
326 return artxPost(array('header-text' => null == $heading ? $this->pageHeading : $heading));
329 function article($article, $print)
331 return new ArtxContentArticleView16($this->_component, $this->_componentParams, $article, $print);
334 function articleListItem($item)
336 return new ArtxContentFeaturedItemView16($this->_component, $this->_componentParams, $item);
340 abstract class ArtxContentGeneralArticleView
342 protected $_component;
343 protected $_componentParams;
350 public $titleVisible;
354 public $showCreateDate;
355 public $showModifyDate;
356 public $showPublishDate;
359 public $showPrintIcon;
360 public $showEmailIcon;
364 public $showReadmore;
365 public $showParentCategory;
366 public $parentCategoryLink;
367 public $parentCategory;
368 public $showCategory;
369 public $categoryLink;
372 protected function __construct($component, $componentParams, $article)
375 $this->_component = $component;
376 $this->_componentParams = $componentParams;
377 $this->_article = $article;
378 // Calculate properties:
379 $this->isPublished = 0 != $this->_article->state;
382 public function introText() { return ''; }
383 public function createDateInfo() { return ''; }
384 public function modifyDateInfo() { return ''; }
385 public function publishDateInfo() { return ''; }
386 public function authorInfo() { return ''; }
387 public function hitsInfo() { return ''; }
388 public function pdfIcon() { return ''; }
389 public function emailIcon() { return ''; }
390 public function editIcon() { return ''; }
391 public function printPopupIcon() { return ''; }
392 public function printScreenIcon() { return ''; }
393 public function readmore() { return ''; }
395 public function beginUnpublishedArticle() { return '<div class="system-unpublished">'; }
396 public function endUnpublishedArticle() { return '</div>'; }
397 public function articleSeparator() { return '<div class="item-separator"></div>'; }
399 public function categories()
401 $showParentCategory = $this->showParentCategory && !empty($this->parentCategory);
402 $showCategory = $this->showCategory && !empty($this->category);
403 $result = JText::_('Category') . ': ';
404 if ($showParentCategory) {
405 $result .= '<span class="art-post-metadata-category-parent">';
406 $title = $this->_component->escape($this->parentCategory);
407 if (!empty($this->parentCategoryLink))
408 $result .= '<a href="' . $this->parentCategoryLink . '">' . $title . '</a>';
411 $result .= '</span>';
413 if ($showParentCategory && $showCategory)
416 $result .= '<span class="art-post-metadata-category-name">';
417 $title = $this->_component->escape($this->category);
418 if (!empty($this->categoryLink))
419 $result .= '<a href="' . $this->categoryLink . '">' . $title . '</a>';
422 $result .= '</span>';
427 public function urlInfo()
429 return '<a href="http://' . $this->_component->escape($this->_article->urls) . '" target="_blank">'
430 . $this->_component->escape($this->_article->urls) . '</a>';
433 public function getArticleViewParameters()
435 return array('metadata-header-icons' => array(), 'metadata-footer-icons' => array());
438 public function event($name)
440 return $this->_article->event->{$name};
443 public function article($article)
445 return artxPost($article);
448 public function content()
450 return (isset($this->_article->toc) ? $this->_article->toc : '') . "<div class=\"art-article\">" . $this->_article->text . "</div>";
455 class ArtxContentArticleView15 extends ArtxContentGeneralArticleView
457 function __construct($component, $componentParams, $article, $print)
459 parent::__construct($component, $componentParams, $article);
461 $this->print = $print;
462 $this->canEdit = $this->_component->user->authorize('com_content', 'edit', 'content', 'all')
463 || $this->_component->user->authorize('com_content', 'edit', 'content', 'own');
464 $this->title = $this->_article->title;
465 $this->titleVisible = $this->_componentParams->get('show_title') && strlen($this->title);
466 $this->titleLink = $this->_componentParams->get('link_titles') && '' != $this->_article->readmore_link
467 ? $this->_article->readmore_link : '';
468 $this->showCreateDate = $this->_componentParams->get('show_create_date');
469 $this->showModifyDate = 0 != intval($this->_article->modified) && $this->_componentParams->get('show_modify_date');
470 $this->showPublishDate = false; // - not available in J! 1.5
471 $this->showAuthor = $this->_componentParams->get('show_author') && '' != $this->_article->author;
472 $this->showPdfIcon = $this->_componentParams->get('show_pdf_icon');
473 $this->showPrintIcon = $this->_componentParams->get('show_print_icon');
474 $this->showEmailIcon = $this->_componentParams->get('show_email_icon');
475 $this->showHits = false; // - not available in J! 1.5
476 $this->showUrl = $this->_componentParams->get('show_url') && $this->_article->urls;
477 $this->showIntro = $this->_componentParams->get('show_intro');
478 $this->showReadmore = false; // - no readmore in article
480 $this->showParentCategory = $this->_componentParams->get('show_section') && $this->_article->sectionid && isset($this->_article->section);
481 $this->parentCategory = $this->showParentCategory ? $this->_article->section : '';
482 $this->parentCategoryLink = ($this->showParentCategory && $this->_componentParams->get('link_section'))
483 ? JRoute::_(ContentHelperRoute::getSectionRoute($this->_article->sectionid)) : '';
484 $this->showCategory = $this->_componentParams->get('show_category') && $this->_article->catid;
485 $this->category = $this->showCategory ? $this->_article->category : '';
486 $this->categoryLink = ($this->showCategory && $this->_componentParams->get('link_category'))
487 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug, $this->_article->sectionid)) : '';
490 public function createDateInfo()
492 return JHTML::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
495 public function modifyDateInfo()
497 return JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
500 public function authorInfo()
502 return JText::sprintf('Written by', $this->_component->escape($this->_article->created_by_alias
503 ? $this->_article->created_by_alias : $this->_article->author));
506 public function pdfIcon()
508 return JHTML::_('icon.pdf', $this->_article, $this->_componentParams, $this->_component->access);
511 public function emailIcon()
513 return JHTML::_('icon.email', $this->_article, $this->_componentParams, $this->_component->access);
516 public function editIcon()
518 return JHTML::_('icon.edit', $this->_article, $this->_componentParams, $this->_component->access);
521 public function printPopupIcon()
523 return JHTML::_('icon.print_popup', $this->_article, $this->_componentParams, $this->_component->access);
526 public function printScreenIcon()
528 return JHtml::_('icon.print_screen', $this->_article, $this->_componentParams, $this->_component->access);
532 class ArtxContentArticleView16 extends ArtxContentGeneralArticleView
534 function __construct($component, $componentParams, $article, $print)
536 parent::__construct($component, $componentParams, $article);
538 $this->print = $print;
539 $this->canEdit = $this->_article->params->get('access-edit');
540 $this->title = $this->_article->title;
541 $this->titleVisible = $this->_article->params->get('show_title') || $this->_article->params->get('access-edit');
542 $this->titleLink = $this->_article->params->get('link_titles') && !empty($this->_article->readmore_link)
543 ? $this->_article->readmore_link : '';
544 $this->hits = $this->_article->hits;
545 $this->showCreateDate = $this->_article->params->get('show_create_date');
546 $this->showModifyDate = $this->_article->params->get('show_modify_date');
547 $this->showPublishDate = $this->_article->params->get('show_publish_date');
548 $this->showAuthor = $this->_article->params->get('show_author') && !empty($this->_article->author);
549 $this->showPdfIcon = false; // - not available in J! 1.6
550 $this->showPrintIcon = $this->_article->params->get('show_print_icon');
551 $this->showEmailIcon = $this->_article->params->get('show_email_icon');
552 $this->showHits = $this->_article->params->get('show_hits');
553 $this->showUrl = false; // - not available in J! 1.6
554 $this->showIntro = $this->_article->params->get('show_intro');
555 $this->showReadmore = false; // - no readmore in article
557 $this->showParentCategory = $this->_article->params->get('show_parent_category') && $this->_article->parent_slug != '1:root';
558 $this->parentCategory = $this->showParentCategory ? $this->_article->parent_title : '';
559 $this->parentCategoryLink = ($this->showParentCategory && $this->_article->params->get('link_parent_category') && $this->_article->parent_slug)
560 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
561 $this->showCategory = $this->_article->params->get('show_category');
562 $this->category = $this->showCategory ? $this->_article->category_title : '';
563 $this->categoryLink = ($this->showCategory && $this->_article->params->get('link_category') && $this->_article->catslug)
564 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
567 public function createDateInfo()
569 return JHtml::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
572 public function modifyDateInfo()
574 return JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
577 public function publishDateInfo()
579 return JText::sprintf('COM_CONTENT_PUBLISHED_DATE', JHtml::_('date', $this->_article->publish_up, JText::_('DATE_FORMAT_LC2')));
582 public function authorInfo()
584 $author = $this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author;
585 if (!empty($this->_article->contactid) && $this->_article->params->get('link_author'))
586 return JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link',
587 JRoute::_('index.php?option=com_contact&view=contact&id=' . $this->_article->contactid), $author));
588 return JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
591 public function emailIcon()
593 return JHtml::_('icon.email', $this->_article, $this->_article->params);
596 public function editIcon()
598 return JHtml::_('icon.edit', $this->_article, $this->_article->params);
601 public function printPopupIcon()
603 return JHtml::_('icon.print_popup', $this->_article, $this->_article->params);
606 public function printScreenIcon()
608 return JHtml::_('icon.print_screen', $this->_article, $this->_article->params);
611 public function hitsInfo()
613 return JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->_article->hits);
618 * Based on Joomla 1.5.22.
620 class ArtxContentFrontpageItemView15 extends ArtxContentGeneralArticleView
622 function __construct($component, $componentParams, $article)
624 parent::__construct($component, $componentParams, $article);
626 $this->canEdit = $this->_component->user->authorize('com_content', 'edit', 'content', 'all')
627 || $this->_component->user->authorize('com_content', 'edit', 'content', 'own');
628 $this->title = $this->_article->title;
629 $this->titleVisible = $this->_article->params->get('show_title') && strlen($this->title);
630 $this->titleLink = $this->_article->params->get('link_titles') && '' != $this->_article->readmore_link
631 ? $this->_article->readmore_link : '';
632 $this->showCreateDate = $this->_article->params->get('show_create_date');
633 $this->showModifyDate = 0 != intval($this->_article->modified) && $this->_article->params->get('show_modify_date');
634 $this->showPublishDate = false; // - not available in J! 1.5
635 $this->showAuthor = $this->_article->params->get('show_author') && '' != $this->_article->author;
636 $this->showPdfIcon = $this->_article->params->get('show_pdf_icon');
637 $this->showPrintIcon = $this->_article->params->get('show_print_icon');
638 $this->showEmailIcon = $this->_article->params->get('show_email_icon');
639 $this->showHits = false; // - not available in J! 1.5
640 $this->showUrl = $this->_componentParams->get('show_url') && $this->_article->urls;
641 $this->showIntro = $this->_article->params->get('show_intro');
642 $this->showReadmore = $this->_article->params->get('show_readmore') && $this->_article->readmore;
644 $this->showParentCategory = $this->_article->params->get('show_section') && $this->_article->sectionid && isset($this->_article->section);
645 $this->parentCategory = $this->showParentCategory ? $this->_article->section : '';
646 $this->parentCategoryLink = ($this->showParentCategory && $this->_article->params->get('link_section'))
647 ? JRoute::_(ContentHelperRoute::getSectionRoute($this->_article->sectionid)) : '';
648 $this->showCategory = $this->_article->params->get('show_category') && $this->_article->catid;
649 $this->category = $this->showCategory ? $this->_article->category : '';
650 $this->categoryLink = ($this->showCategory && $this->_article->params->get('link_category'))
651 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug, $this->_article->sectionid)) : '';
654 public function createDateInfo()
656 return JHTML::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
659 public function modifyDateInfo()
661 return JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
664 public function authorInfo()
666 return JText::sprintf('Written by', $this->_component->escape($this->_article->created_by_alias
667 ? $this->_article->created_by_alias : $this->_article->author));
670 public function pdfIcon()
672 return JHTML::_('icon.pdf', $this->_article, $this->_article->params, $this->_component->access);
675 public function emailIcon()
677 return JHTML::_('icon.email', $this->_article, $this->_article->params, $this->_component->access);
680 public function editIcon()
682 return JHTML::_('icon.edit', $this->_article, $this->_article->params, $this->_component->access);
685 public function printPopupIcon()
687 return JHTML::_('icon.print_popup', $this->_article, $this->_article->params, $this->_component->access);
690 public function introText()
692 return "<div class=\"art-article\">" . $this->_article->text . "</div>";
695 public function readmore()
697 if ($this->_article->readmore_register)
698 $text = JText::_('Register to read more...');
699 elseif ($readmore = $this->_article->params->get('readmore'))
702 $text = JText::sprintf('Read more...');
703 return '<p class="readmore">' . artxLinkButton(array(
704 'classes' => array('a' => 'readon'),
705 'link' => $this->_article->readmore_link,
706 'content' => str_replace(' ', ' ', $text))) . '</p>';
711 * Based on Joomla 1.6 RC1.
713 class ArtxContentFeaturedItemView16 extends ArtxContentGeneralArticleView
715 function __construct($component, $componentParams, $article)
717 parent::__construct($component, $componentParams, $article);
719 $this->canEdit = $this->_article->params->get('access-edit');
720 $this->title = $this->_article->title;
721 $this->titleVisible = $this->_article->params->get('show_title') && strlen($this->title);
722 $this->titleLink = $this->_article->params->get('link_titles') && $this->_article->params->get('access-view')
723 ? JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid)) : '';
724 $this->hits = $this->_article->hits;
725 $this->showCreateDate = $this->_article->params->get('show_create_date');
726 $this->showModifyDate = $this->_article->params->get('show_modify_date');
727 $this->showPublishDate = $this->_article->params->get('show_publish_date');
728 $this->showAuthor = $this->_article->params->get('show_author') && !empty($this->_article->author);
729 $this->showPdfIcon = false; // - not available in J! 1.6
730 $this->showPrintIcon = $this->_article->params->get('show_print_icon');
731 $this->showEmailIcon = $this->_article->params->get('show_email_icon');
732 $this->showHits = $this->_article->params->get('show_hits');
733 $this->showUrl = false; // - not available in J! 1.6
734 $this->showIntro = $this->_article->params->get('show_intro');
735 $this->showReadmore = $this->_article->params->get('show_readmore') && $this->_article->readmore;
737 // Because category blog layout view does not support catslug:
738 if (!isset($this->_article->catslug))
739 $this->_article->catslug = $this->_article->category_alias ? ($this->_article->catid . ':' . $this->_article->category_alias) : $this->_article->catid;
740 if (!isset($this->_article->parent_slug))
741 $this->_article->parent_slug = $this->_article->parent_alias ? ($this->_article->parent_id . ':' . $this->_article->parent_alias) : $this->_article->parent_id;
743 $this->showParentCategory = $this->_article->params->get('show_parent_category');
744 $this->parentCategory = $this->showParentCategory ? $this->_article->parent_title : '';
745 $this->parentCategoryLink = ($this->showParentCategory && $this->_article->params->get('link_parent_category') && $this->_article->parent_slug)
746 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
747 $this->showCategory = $this->_article->params->get('show_category');
748 $this->category = $this->showCategory ? $this->_article->category_title : '';
749 $this->categoryLink = ($this->showCategory && $this->_article->params->get('link_category') && $this->_article->catslug)
750 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
753 public function createDateInfo()
755 return JHtml::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
758 public function modifyDateInfo()
760 return JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
763 public function publishDateInfo()
765 return JText::sprintf('COM_CONTENT_PUBLISHED_DATE', JHtml::_('date', $this->_article->publish_up, JText::_('DATE_FORMAT_LC2')));
768 public function authorInfo()
770 $author = $this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author;
771 if (!empty($this->_article->contactid) && $this->_article->params->get('link_author'))
772 return JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link',
773 JRoute::_('index.php?option=com_contact&view=contact&id=' . $this->_article->contactid), $author));
774 return JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
777 public function emailIcon()
779 return JHtml::_('icon.email', $this->_article, $this->_article->params);
782 public function editIcon()
784 return JHtml::_('icon.edit', $this->_article, $this->_article->params);
787 public function printPopupIcon()
789 return JHtml::_('icon.print_popup', $this->_article, $this->_article->params);
792 public function hitsInfo()
794 return JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->_article->hits);
797 public function introText()
799 return "<div class=\"art-article\">" . $this->_article->introtext . "</div>";
802 public function readmore()
804 if ($this->_article->params->get('access-view')) {
805 $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid));
807 $menu = JFactory::getApplication()->getMenu();
808 $active = $menu->getActive();
809 $itemId = $active->id;
810 $link1 = JRoute::_('index.php?option=com_users&view=login&&Itemid=' . $itemId);
811 $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catid));
812 $link = new JURI($link1);
813 $link->setVar('return', base64_encode($returnURL));
815 if (!$this->_article->params->get('access-view'))
816 $text = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
817 elseif ($readmore = $this->_article->alternative_readmore)
818 $text = $readmore . JHtml::_('string.truncate', ($this->_article->title), $this->_article->params->get('readmore_limit'));
819 elseif ($this->_article->params->get('show_readmore_title', 0) == 0)
820 $text = JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
822 $text = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $this->_article->title, $this->_article->params->get('readmore_limit'));
823 return '<p class="readmore">' . artxLinkButton(array(
824 'classes' => array('a' => 'readon'),
826 'content' => str_replace(' ', ' ', $text))) . '</p>';
832 * Renders article or block in the Post style.
834 * Elements of the $data array:
839 * 'metadata-header-icons'
840 * 'metadata-footer-icons'
843 function artxPost($data)
845 if (is_string($data))
846 $data = array('content' => $data);
847 $classes = isset($data['classes']) && strlen($data['classes']) ? $data['classes'] : '';
848 artxFragmentBegin(str_replace('class="art-post">', 'class="art-post' . $classes . '">', "<div class=\"art-post\">\r\n <div class=\"art-post-tl\"></div>\r\n <div class=\"art-post-tr\"></div>\r\n <div class=\"art-post-bl\"></div>\r\n <div class=\"art-post-br\"></div>\r\n <div class=\"art-post-tc\"></div>\r\n <div class=\"art-post-bc\"></div>\r\n <div class=\"art-post-cl\"></div>\r\n <div class=\"art-post-cr\"></div>\r\n <div class=\"art-post-cc\"></div>\r\n <div class=\"art-post-body\">\r\n<div class=\"art-post-inner\">\r\n"));
849 artxFragmentBegin("<h2 class=\"art-postheader\"> ");
850 artxFragmentBegin("");
851 if (isset($data['header-text']) && strlen($data['header-text'])) {
852 if (isset($data['header-link']) && strlen($data['header-link']))
853 artxFragmentContent('<a href="' . $data['header-link'] . '" class="PostHeader">' . $data['header-text'] . '</a>');
855 artxFragmentContent($data['header-text']);
857 artxFragmentEnd("\r\n");
858 artxFragmentEnd("</h2>\r\n");
859 artxFragmentBegin("<div class=\"art-postheadericons art-metadata-icons\">\r\n");
860 if (isset($data['metadata-header-icons']) && count($data['metadata-header-icons']))
861 foreach ($data['metadata-header-icons'] as $icon)
862 artxFragment('', $icon, '', ' | ');
863 artxFragmentEnd("\r\n</div>\r\n");
864 artxFragmentBegin("<div class=\"art-postcontent\">\r\n <!-- article-content -->\r\n");
865 if (isset($data['content']) && strlen($data['content']))
866 artxFragmentContent($data['content']);
867 artxFragmentEnd("\r\n <!-- /article-content -->\r\n</div>\r\n<div class=\"cleared\"></div>\r\n");
868 artxFragmentBegin("<div class=\"art-postmetadatafooter\">\r\n");
869 artxFragmentBegin("<div class=\"art-postfootericons art-metadata-icons\">\r\n");
870 if (isset($data['metadata-footer-icons']) && count($data['metadata-footer-icons']))
871 foreach ($data['metadata-footer-icons'] as $icon)
872 artxFragment('', $icon, '', ' | ');
873 artxFragmentEnd("\r\n</div>\r\n");
874 artxFragmentEnd("\r\n</div>\r\n");
875 return artxFragmentEnd("\r\n</div>\r\n\r\n <div class=\"cleared\"></div>\r\n </div>\r\n</div>\r\n", '', true);
878 function artxBlock($caption, $content, $classes = '')
880 $hasCaption = ($GLOBALS['artx_settings']['block']['has_header']
881 && null !== $caption && strlen(trim($caption)) > 0);
882 $hasContent = (null !== $content && strlen(trim($content)) > 0);
884 if (!$hasCaption && !$hasContent)
890 <div class="art-block">
891 <div class="art-block-body">
893 <?php echo str_replace('class="art-block">', 'class="art-block' . $classes . '">', ob_get_clean()); ?>
894 <?php if ($hasCaption): ?>
895 <div class="art-blockheader">
896 <div class="l"></div>
897 <div class="r"></div>
899 <?php echo $caption; ?>
904 <?php if ($hasContent): ?>
905 <div class="art-blockcontent">
906 <div class="art-blockcontent-body">
907 <!-- block-content -->
909 <?php echo artxReplaceButtons($content); ?>
911 <!-- /block-content -->
913 <div class="cleared"></div>
919 <div class="cleared"></div>
924 return ob_get_clean();
928 function artxVMenuBlock($caption, $content)
930 if (null === $content || strlen(trim($content)) == 0)
933 ?><div class="art-vmenublock">
934 <div class="art-vmenublock-body">
935 <div class="art-vmenublockcontent">
936 <div class="art-vmenublockcontent-body">
937 <!-- block-content -->
939 <?php echo $content; ?>
940 <!-- /block-content -->
942 <div class="cleared"></div>
946 <div class="cleared"></div>
951 return ob_get_clean();
955 * Depricated since Artisteer 3.0.
957 function artxCountModules(&$document, $position)
959 return $document->artx->countModules($position);
963 * Depricated since Artisteer 3.0.
965 function artxPositions(&$document, $positions, $style)
968 if (count($positions) == 3) {
969 if (artxCountModules($document, $positions[0])
970 && artxCountModules($document, $positions[1])
971 && artxCountModules($document, $positions[2]))
974 <table class="position" cellpadding="0" cellspacing="0" border="0">
976 <td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
977 <td width="33%"><?php echo artxModules($document, $positions[1], $style); ?></td>
978 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
982 } elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
984 <table class="position" cellpadding="0" cellspacing="0" border="0">
986 <td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
987 <td><?php echo artxModules($document, $positions[1], $style); ?></td>
991 } elseif (artxCountModules($document, $positions[1]) && artxCountModules($document, $positions[2])) {
993 <table class="position" cellpadding="0" cellspacing="0" border="0">
995 <td width="67%"><?php echo artxModules($document, $positions[1], $style); ?></td>
996 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
1000 } elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[2])) {
1002 <table class="position" cellpadding="0" cellspacing="0" border="0">
1004 <td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
1005 <td><?php echo artxModules($document, $positions[2], $style); ?></td>
1010 echo artxModules($document, $positions[0], $style);
1011 echo artxModules($document, $positions[1], $style);
1012 echo artxModules($document, $positions[2], $style);
1014 } elseif (count($positions) == 2) {
1015 if (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
1017 <table class="position" cellpadding="0" cellspacing="0" border="0">
1019 <td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
1020 <td><?php echo artxModules($document, $positions[1], $style); ?></td>
1025 echo artxModules($document, $positions[0], $style);
1026 echo artxModules($document, $positions[1], $style);
1028 } // count($positions)
1029 return ob_get_clean();
1033 * Depricated since Artisteer 3.0.
1035 function artxComponentWrapper(&$document)
1037 $this->artx->componentWrapper();
1041 * Depricated since Artisteer 3.0.
1043 function artxModules(&$document, $position, $style = null)
1045 $this->artx->position($position, $style);
1049 function artxUrlToHref($url)
1052 $p = parse_url($url);
1053 if (isset($p['scheme']) && isset($p['host'])) {
1054 $result = $p['scheme'] . '://';
1055 if (isset($p['user'])) {
1056 $result .= $p['user'];
1057 if (isset($p['pass']))
1058 $result .= ':' . $p['pass'];
1061 $result .= $p['host'];
1062 if (isset($p['port']))
1063 $result .= ':' . $p['port'];
1064 if (!isset($p['path']))
1067 if (isset($p['path']))
1068 $result .= $p['path'];
1069 if (isset($p['query'])) {
1070 $result .= '?' . str_replace('&', '&', $p['query']);
1072 if (isset($p['fragment']))
1073 $result .= '#' . $p['fragment'];
1077 function artxReplaceButtonsRegex() {
1078 return '~<input\b[^>]*'
1079 . '\bclass=(?:(")(?:[^"]*\s)?button(?:\s[^"]*)?"|(\')(?:[^\']*\s)?button(?:\s[^\']*)?\'|button(?=[/>\s]))'
1083 function artxReplaceButtons($content)
1085 $re = artxReplaceButtonsRegex();
1086 if (!preg_match_all($re, $content, $matches, PREG_OFFSET_CAPTURE))
1090 for ($index = 0; $index < count($matches[0]); $index++) {
1091 $match = $matches[0][$index];
1092 if (is_array($matches[1][$index]) && strlen($matches[1][$index][0]) > 0)
1093 $quote = $matches[1][$index][0];
1094 else if (is_array($matches[2][$index]) && strlen($matches[2][$index][0]) > 0)
1095 $quote = $matches[2][$index][0];
1098 $result .= substr($content, $position, $match[1] - $position);
1099 $position = $match[1] + strlen($match[0]);
1100 $result .= str_replace('"', $quote, '<span class="art-button-wrapper"><span class="l"> </span><span class="r"> </span>')
1101 . preg_replace('~\bclass=(?:"([^"]*\s)?button(\s[^"]*)?"|\'([^\']*\s)?button(\s[^\']*)?\'|button(?=[/>\s]))~i',
1102 str_replace('"', $quote, 'class="\1\3button art-button\2\4"'), $match[0]) . '</span>';
1104 $result .= substr($content, $position);
1108 function artxLinkButton($data = array())
1110 return '<span class="art-button-wrapper"><span class="l"> </span><span class="r"> </span>'
1111 . '<a class="' . (isset($data['classes']) && isset($data['classes']['a']) ? $data['classes']['a'] . ' ' : '')
1112 . 'art-button" href="' . $data['link'] . '">' . $data['content'] . '</a></span>';
1115 function artxHtmlFixFormAction($content)
1117 if (preg_match('~ action="([^"]+)" ~', $content, $matches, PREG_OFFSET_CAPTURE)) {
1118 $content = substr($content, 0, $matches[0][1])
1119 . ' action="' . artxUrlToHref($matches[1][0]) . '" '
1120 . substr($content, $matches[0][1] + strlen($matches[0][0]));
1125 function artxTagBuilder($tag, $attributes, $content) {
1126 $result = '<' . $tag;
1127 foreach ($attributes as $name => $value) {
1128 if (is_string($value)) {
1130 $result .= ' ' . $name . '="' . $value . '"';
1131 } else if (is_array($value)) {
1132 $values = array_filter($value);
1134 $result .= ' ' . $name . '="' . implode(' ', $value) . '"';
1137 $result .= '>' . $content . '</' . $tag . '>';
1141 $artxFragments = array();
1143 function artxFragmentBegin($head = '')
1145 global $artxFragments;
1146 $artxFragments[] = array('head' => $head, 'content' => '', 'tail' => '');
1149 function artxFragmentContent($content = '')
1151 global $artxFragments;
1152 $artxFragments[count($artxFragments) - 1]['content'] = $content;
1155 function artxFragmentEnd($tail = '', $separator = '', $return = false)
1157 global $artxFragments;
1158 $fragment = array_pop($artxFragments);
1159 $fragment['tail'] = $tail;
1160 $content = trim($fragment['content']);
1161 if (count($artxFragments) == 0) {
1163 return (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
1164 echo (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
1166 $result = (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
1167 $fragment =& $artxFragments[count($artxFragments) - 1];
1168 $fragment['content'] .= (trim($fragment['content']) == '' ? '' : $separator) . $result;
1172 function artxFragment($head = '', $content = '', $tail = '', $separator = '', $return = false)
1174 global $artxFragments;
1175 if ($head != '' && $content == '' && $tail == '' && $separator == '') {
1178 } elseif ($head != '' && $content != '' && $tail == '' && $separator == '') {
1179 $separator = $content;
1183 artxFragmentBegin($head);
1184 artxFragmentContent($content);
1185 artxFragmentEnd($tail, $separator, $return);