array('has_header' => true),
'menu' => array('show_submenus' => true),
'vmenu' => array('show_submenus' => true, 'simple' => false)
);
/**
* Base class with index.php view routines. Contains method for placing positions,
* calculating classes, decorating components. Version-specific routines are defined
* in subclasses: ArtxPage15 and ArtxPage16.
*/
abstract class ArtxPageView
{
public $page;
protected function __construct($page) {
$this->page = $page;
}
/**
* Returns version-specific body class: joomla15 or joomla16.
*
* Example:
*
*/
abstract function bodyClass();
/**
* Checks whether Joomla! has system messages to display.
*/
abstract function hasMessages();
/**
* Returns true when one of the given positions contains at least one module.
* Example:
* if ($obj->containsModules('top1', 'top2', 'top3')) {
* // the following code will be executed when one of the positions contain modules:
* ...
* }
*/
function containsModules()
{
foreach (func_get_args() as $position)
if (0 != $this->page->countModules($position))
return true;
return false;
}
/**
* Builds list of positions, collapsing the empty ones.
*
* Samples:
* Four positions:
* No empty positions: 25%:25%:25%:25%
* With one empty positions: -:50%:25%:25%, 50%:-:25%:25%, 25%:50%:-:25%, 25%:25%:50%:-
* With two empty positions: -:-:75%:25%, -:50%:-:50%, -:50%:50%:-, -:50%:50%:-, 75%:-:-:25%, 50%:-:50%:-, 25%:75%:-:-
* One non-empty position: 100%
* Three positions:
* No empty positions: 33%:33%:34%
* With one empty position: -:66%:34%, 50%:-:50%, 33%:67%:-
* One non-empty position: 100%
*/
function positions($positions, $style) {
// Build $cells by collapsing empty positions:
$cells = array();
$buffer = 0;
$cell = null;
foreach ($positions as $name => $width) {
if ($this->containsModules($name)) {
$cells[$name] = $buffer + $width;
$buffer = 0;
$cell = $name;
} else if (null == $cell)
$buffer += $width;
else
$cells[$cell] += $width;
}
// Backward compatibility:
// For three equal width columns with empty center position width should be 50/50:
if (3 == count($positions) && 2 == count($cells)) {
$columns1 = array_keys($positions);
$columns2 = array_keys($cells);
if (33 == $positions[$columns1[0]] && 33 == $positions[$columns1[1]] && 34 == $positions[$columns1[2]]
&& $columns2[0] == $columns1[0] && $columns2[1] == $columns1[2])
$cells[$columns2[0]] = 50;
$cells[$columns2[1]] = 50;
}
// Render $cells:
if (count($cells) == 0)
return '';
if (count($cells) == 1)
foreach ($cells as $name => $width)
return $this->position($name, $style);
$result = '
';
$result .= '
';
foreach ($cells as $name => $width)
$result .='
' . $this->position($name, $style) . '
';
$result .= '
';
$result .= '
';
return $result;
}
function position($position, $style = null)
{
return '';
}
/**
* Preprocess component content before printing it.
*/
function componentWrapper()
{
}
/**
* Checks layout sidebar cells and returns content cell class that expands content cell over empty sidebar.
*/
function contentCellClass($cells)
{
$nonEmptyCells = array();
$emptyCells = array();
foreach ($cells as $name => $class) {
if ('content' == $name)
continue;
if ($this->containsModules($name))
$nonEmptyCells[] = $class;
else
$emptyCells[] = $class;
}
switch (count($emptyCells)) {
case 2:
return 'content-wide';
case 1:
if (count($nonEmptyCells))
return 'content-' . $emptyCells[0];
return 'content';
}
return 'content';
}
}
class ArtxPage15 extends ArtxPageView
{
public function __construct($page) {
parent::__construct($page);
}
function bodyClass() {
return 'joomla15';
}
function hasMessages()
{
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;
}
/**
* Wraps component content into article style unless it is not wrapped already.
*
* The componentWrapper method gets the content of the 'component' buffer and search for the '
' string in it.
* Then it replaces the componentheading DIV tag with span (to fix the w3.org validation) and replaces content of the buffer with
* wrapped content.
*/
function componentWrapper()
{
if ($this->page->getType() != 'html')
return;
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if ('com_content' == $option && ('frontpage' == $view || 'article' == $view || ('category' == $view && 'blog' == $layout)))
return;
$content = $this->page->getBuffer('component');
if (false === strpos($content, '
]*)>([^<]+)
~', $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] . '';
}
$this->page->setBuffer(artxPost(array('header-text' => $title, 'content' => $content)), 'component');
}
}
}
class ArtxPage16 extends ArtxPageView
{
public function __construct($page) {
parent::__construct($page);
}
function bodyClass() {
return 'joomla16';
}
function hasMessages()
{
$messages = JFactory::getApplication()->getMessageQueue();
if (is_array($messages) && count($messages))
foreach ($messages as $msg)
if (isset($msg['type']) && isset($msg['message']))
return true;
return false;
}
/**
* Wraps component content into article style unless it is not wrapped already.
*
* The componentWrapper method gets the content of the 'component' buffer and search for the '
' string in it.
* Then it wraps content of the buffer with art-post.
*/
function componentWrapper()
{
if ($this->page->getType() != 'html')
return;
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if ('com_content' == $option && ('featured' == $view || 'article' == $view || ('category' == $view && 'blog' == $layout)))
return;
$content = $this->page->getBuffer('component');
if (false === strpos($content, '
pageClassSfx .'">';
}
public function endPageContainer()
{
return '
';
}
}
class ArtxContent15 extends ArtxContentView
{
public function __construct($component, $params)
{
parent::__construct($component, $params);
$this->pageClassSfx = $this->_componentParams->get('pageclass_sfx');
$this->showPageHeading = $this->_componentParams->def('show_page_title', 1);
$this->pageHeading = $this->showPageHeading ? $this->_componentParams->get('page_title') : '';
}
function pageHeading($heading = null)
{
return artxPost(array('header-text' => null == $heading ? $this->pageHeading : $heading));
}
function article($article, $print)
{
return new ArtxContentArticleView15($this->_component, $this->_componentParams, $article, $print);
}
function articleListItem($item)
{
return new ArtxContentFrontpageItemView15($this->_component, $this->_componentParams, $item);
}
}
class ArtxContent16 extends ArtxContentView
{
public function __construct($component, $params)
{
parent::__construct($component, $params);
$this->pageClassSfx = $this->_component->pageclass_sfx;
$this->showPageHeading = $this->_componentParams->def('show_page_heading', 1);
$this->pageHeading = $this->showPageHeading ? $this->_componentParams->get('page_heading') : '';
}
function pageHeading($heading = null)
{
return artxPost(array('header-text' => null == $heading ? $this->pageHeading : $heading));
}
function article($article, $print)
{
return new ArtxContentArticleView16($this->_component, $this->_componentParams, $article, $print);
}
function articleListItem($item)
{
return new ArtxContentFeaturedItemView16($this->_component, $this->_componentParams, $item);
}
}
abstract class ArtxContentGeneralArticleView
{
protected $_component;
protected $_componentParams;
protected $_article;
public $params;
public $isPublished;
public $canEdit;
public $title;
public $titleVisible;
public $titleLink;
public $hits;
public $print;
public $showCreateDate;
public $showModifyDate;
public $showPublishDate;
public $showAuthor;
public $showPdfIcon;
public $showPrintIcon;
public $showEmailIcon;
public $showHits;
public $showUrl;
public $showIntro;
public $showReadmore;
public $showParentCategory;
public $parentCategoryLink;
public $parentCategory;
public $showCategory;
public $categoryLink;
public $category;
protected function __construct($component, $componentParams, $article)
{
// Initialization:
$this->_component = $component;
$this->_componentParams = $componentParams;
$this->_article = $article;
// Calculate properties:
$this->isPublished = 0 != $this->_article->state;
}
public function introText() { return ''; }
public function createDateInfo() { return ''; }
public function modifyDateInfo() { return ''; }
public function publishDateInfo() { return ''; }
public function authorInfo() { return ''; }
public function hitsInfo() { return ''; }
public function pdfIcon() { return ''; }
public function emailIcon() { return ''; }
public function editIcon() { return ''; }
public function printPopupIcon() { return ''; }
public function printScreenIcon() { return ''; }
public function readmore() { return ''; }
public function beginUnpublishedArticle() { return '
'; }
public function endUnpublishedArticle() { return '
'; }
public function articleSeparator() { return ''; }
public function categories()
{
$showParentCategory = $this->showParentCategory && !empty($this->parentCategory);
$showCategory = $this->showCategory && !empty($this->category);
$result = JText::_('Category') . ': ';
if ($showParentCategory) {
$result .= '';
$title = $this->_component->escape($this->parentCategory);
if (!empty($this->parentCategoryLink))
$result .= '' . $title . '';
else
$result .= $title;
$result .= '';
}
if ($showParentCategory && $showCategory)
$result .= ' / ';
if ($showCategory) {
$result .= '';
$title = $this->_component->escape($this->category);
if (!empty($this->categoryLink))
$result .= '' . $title . '';
else
$result .= $title;
$result .= '';
}
return $result;
}
public function urlInfo()
{
return ''
. $this->_component->escape($this->_article->urls) . '';
}
public function getArticleViewParameters()
{
return array('metadata-header-icons' => array(), 'metadata-footer-icons' => array());
}
public function event($name)
{
return $this->_article->event->{$name};
}
public function article($article)
{
return artxPost($article);
}
public function content()
{
return (isset($this->_article->toc) ? $this->_article->toc : '') . "
" . $this->_article->text . "
";
}
}
class ArtxContentArticleView15 extends ArtxContentGeneralArticleView
{
function __construct($component, $componentParams, $article, $print)
{
parent::__construct($component, $componentParams, $article);
$this->print = $print;
$this->canEdit = $this->_component->user->authorize('com_content', 'edit', 'content', 'all')
|| $this->_component->user->authorize('com_content', 'edit', 'content', 'own');
$this->title = $this->_article->title;
$this->titleVisible = $this->_componentParams->get('show_title') && strlen($this->title);
$this->titleLink = $this->_componentParams->get('link_titles') && '' != $this->_article->readmore_link
? $this->_article->readmore_link : '';
$this->showCreateDate = $this->_componentParams->get('show_create_date');
$this->showModifyDate = 0 != intval($this->_article->modified) && $this->_componentParams->get('show_modify_date');
$this->showPublishDate = false; // - not available in J! 1.5
$this->showAuthor = $this->_componentParams->get('show_author') && '' != $this->_article->author;
$this->showPdfIcon = $this->_componentParams->get('show_pdf_icon');
$this->showPrintIcon = $this->_componentParams->get('show_print_icon');
$this->showEmailIcon = $this->_componentParams->get('show_email_icon');
$this->showHits = false; // - not available in J! 1.5
$this->showUrl = $this->_componentParams->get('show_url') && $this->_article->urls;
$this->showIntro = $this->_componentParams->get('show_intro');
$this->showReadmore = false; // - no readmore in article
$this->showParentCategory = $this->_componentParams->get('show_section') && $this->_article->sectionid && isset($this->_article->section);
$this->parentCategory = $this->showParentCategory ? $this->_article->section : '';
$this->parentCategoryLink = ($this->showParentCategory && $this->_componentParams->get('link_section'))
? JRoute::_(ContentHelperRoute::getSectionRoute($this->_article->sectionid)) : '';
$this->showCategory = $this->_componentParams->get('show_category') && $this->_article->catid;
$this->category = $this->showCategory ? $this->_article->category : '';
$this->categoryLink = ($this->showCategory && $this->_componentParams->get('link_category'))
? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug, $this->_article->sectionid)) : '';
}
public function createDateInfo()
{
return JHTML::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
}
public function modifyDateInfo()
{
return JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
}
public function authorInfo()
{
return JText::sprintf('Written by', $this->_component->escape($this->_article->created_by_alias
? $this->_article->created_by_alias : $this->_article->author));
}
public function pdfIcon()
{
return JHTML::_('icon.pdf', $this->_article, $this->_componentParams, $this->_component->access);
}
public function emailIcon()
{
return JHTML::_('icon.email', $this->_article, $this->_componentParams, $this->_component->access);
}
public function editIcon()
{
return JHTML::_('icon.edit', $this->_article, $this->_componentParams, $this->_component->access);
}
public function printPopupIcon()
{
return JHTML::_('icon.print_popup', $this->_article, $this->_componentParams, $this->_component->access);
}
public function printScreenIcon()
{
return JHtml::_('icon.print_screen', $this->_article, $this->_componentParams, $this->_component->access);
}
}
class ArtxContentArticleView16 extends ArtxContentGeneralArticleView
{
function __construct($component, $componentParams, $article, $print)
{
parent::__construct($component, $componentParams, $article);
$this->print = $print;
$this->canEdit = $this->_article->params->get('access-edit');
$this->title = $this->_article->title;
$this->titleVisible = $this->_article->params->get('show_title') || $this->_article->params->get('access-edit');
$this->titleLink = $this->_article->params->get('link_titles') && !empty($this->_article->readmore_link)
? $this->_article->readmore_link : '';
$this->hits = $this->_article->hits;
$this->showCreateDate = $this->_article->params->get('show_create_date');
$this->showModifyDate = $this->_article->params->get('show_modify_date');
$this->showPublishDate = $this->_article->params->get('show_publish_date');
$this->showAuthor = $this->_article->params->get('show_author') && !empty($this->_article->author);
$this->showPdfIcon = false; // - not available in J! 1.6
$this->showPrintIcon = $this->_article->params->get('show_print_icon');
$this->showEmailIcon = $this->_article->params->get('show_email_icon');
$this->showHits = $this->_article->params->get('show_hits');
$this->showUrl = false; // - not available in J! 1.6
$this->showIntro = $this->_article->params->get('show_intro');
$this->showReadmore = false; // - no readmore in article
$this->showParentCategory = $this->_article->params->get('show_parent_category') && $this->_article->parent_slug != '1:root';
$this->parentCategory = $this->showParentCategory ? $this->_article->parent_title : '';
$this->parentCategoryLink = ($this->showParentCategory && $this->_article->params->get('link_parent_category') && $this->_article->parent_slug)
? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
$this->showCategory = $this->_article->params->get('show_category');
$this->category = $this->showCategory ? $this->_article->category_title : '';
$this->categoryLink = ($this->showCategory && $this->_article->params->get('link_category') && $this->_article->catslug)
? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
}
public function createDateInfo()
{
return JHtml::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
}
public function modifyDateInfo()
{
return JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
}
public function publishDateInfo()
{
return JText::sprintf('COM_CONTENT_PUBLISHED_DATE', JHtml::_('date', $this->_article->publish_up, JText::_('DATE_FORMAT_LC2')));
}
public function authorInfo()
{
$author = $this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author;
if (!empty($this->_article->contactid) && $this->_article->params->get('link_author'))
return JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link',
JRoute::_('index.php?option=com_contact&view=contact&id=' . $this->_article->contactid), $author));
return JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
}
public function emailIcon()
{
return JHtml::_('icon.email', $this->_article, $this->_article->params);
}
public function editIcon()
{
return JHtml::_('icon.edit', $this->_article, $this->_article->params);
}
public function printPopupIcon()
{
return JHtml::_('icon.print_popup', $this->_article, $this->_article->params);
}
public function printScreenIcon()
{
return JHtml::_('icon.print_screen', $this->_article, $this->_article->params);
}
public function hitsInfo()
{
return JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->_article->hits);
}
}
/**
* Based on Joomla 1.5.22.
*/
class ArtxContentFrontpageItemView15 extends ArtxContentGeneralArticleView
{
function __construct($component, $componentParams, $article)
{
parent::__construct($component, $componentParams, $article);
$this->canEdit = $this->_component->user->authorize('com_content', 'edit', 'content', 'all')
|| $this->_component->user->authorize('com_content', 'edit', 'content', 'own');
$this->title = $this->_article->title;
$this->titleVisible = $this->_article->params->get('show_title') && strlen($this->title);
$this->titleLink = $this->_article->params->get('link_titles') && '' != $this->_article->readmore_link
? $this->_article->readmore_link : '';
$this->showCreateDate = $this->_article->params->get('show_create_date');
$this->showModifyDate = 0 != intval($this->_article->modified) && $this->_article->params->get('show_modify_date');
$this->showPublishDate = false; // - not available in J! 1.5
$this->showAuthor = $this->_article->params->get('show_author') && '' != $this->_article->author;
$this->showPdfIcon = $this->_article->params->get('show_pdf_icon');
$this->showPrintIcon = $this->_article->params->get('show_print_icon');
$this->showEmailIcon = $this->_article->params->get('show_email_icon');
$this->showHits = false; // - not available in J! 1.5
$this->showUrl = $this->_componentParams->get('show_url') && $this->_article->urls;
$this->showIntro = $this->_article->params->get('show_intro');
$this->showReadmore = $this->_article->params->get('show_readmore') && $this->_article->readmore;
$this->showParentCategory = $this->_article->params->get('show_section') && $this->_article->sectionid && isset($this->_article->section);
$this->parentCategory = $this->showParentCategory ? $this->_article->section : '';
$this->parentCategoryLink = ($this->showParentCategory && $this->_article->params->get('link_section'))
? JRoute::_(ContentHelperRoute::getSectionRoute($this->_article->sectionid)) : '';
$this->showCategory = $this->_article->params->get('show_category') && $this->_article->catid;
$this->category = $this->showCategory ? $this->_article->category : '';
$this->categoryLink = ($this->showCategory && $this->_article->params->get('link_category'))
? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug, $this->_article->sectionid)) : '';
}
public function createDateInfo()
{
return JHTML::_('date', $this->_article->created, JText::_('DATE_FORMAT_LC2'));
}
public function modifyDateInfo()
{
return JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->_article->modified, JText::_('DATE_FORMAT_LC2')));
}
public function authorInfo()
{
return JText::sprintf('Written by', $this->_component->escape($this->_article->created_by_alias
? $this->_article->created_by_alias : $this->_article->author));
}
public function pdfIcon()
{
return JHTML::_('icon.pdf', $this->_article, $this->_article->params, $this->_component->access);
}
public function emailIcon()
{
return JHTML::_('icon.email', $this->_article, $this->_article->params, $this->_component->access);
}
public function editIcon()
{
return JHTML::_('icon.edit', $this->_article, $this->_article->params, $this->_component->access);
}
public function printPopupIcon()
{
return JHTML::_('icon.print_popup', $this->_article, $this->_article->params, $this->_component->access);
}
public function introText()
{
return "
" . $this->_article->text . "
";
}
public function readmore()
{
if ($this->_article->readmore_register)
$text = JText::_('Register to read more...');
elseif ($readmore = $this->_article->params->get('readmore'))
$text = $readmore;
else
$text = JText::sprintf('Read more...');
return '