Friend
|
Fatal error: Cannot access protected property ContentViewArticle::$user in Z:\home\localhost\www\xxxxxx\functions.php on line 170
Help me please!
|
|
Garry
|
You should provide some more details like, what additional modules/plugins you are using.
|
|
Friend
|
- Default Joomla 1.6. No other modules/plugins
- Conver in 1.6 :
index.php
functions.php
component.php
defined('_JEXEC') or die;
$app = JFactory::getApplication();
rename $mainframe on $app
in
index.php
functions.php
component.php
templatedatails.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.6//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd">
If you click on the menu on the site or click on a link, then:
Fatal error: Cannot access protected property ContentViewArticle::$user in Z:\home\localhost\www\xxxxxx\functions.php on line 170
functions.php
<code>
<?php
defined('_JEXEC') or die;
$app = JFactory::getApplication();
if (!defined('_ARTX_FUNCTIONS')) {
define('_ARTX_FUNCTIONS', 1);
$GLOBALS['artx_settings'] = array(
'block' => array('has_header' => true),
'menu' => array('show_submenus' => true),
'vmenu' => array('show_submenus' => true, 'simple' => false)
);
class ArtxContentArticleView15
{
private $_document;
private $_data;
public $version;
public $params;
public $canEdit;
public $pageHeadingVisible;
public $pageHeading;
public $titleVisible;
public $titleLink;
public $title;
public $print;
public $pdf;
public $hits;
public $parentCategoryVisible;
public $categoryVisible;
function __construct(&$document, &$item, &$params) {
$this->_document = $document;
$this->_data = array();
$this->item = & $item;
$this->params = & $params;
$this->canEdit = $this->_document->user->authorize('com_content', 'edit', 'content', 'all') || $this->_document->user->authorize('com_content', 'edit', 'content', 'own');
$this->pageHeadingVisible = $this->params->get('show_page_title', 1) && $this->params->get('page_title') != $this->item->title;
$this->pageHeading = $this->params->get('page_title');
$this->titleVisible = $this->params->get('show_title');
$this->titleLink = ($this->params->get('link_titles') && !empty($this->item->readmore_link)) ? $this->item->readmore_link : '';
$this->title = $this->item->title;
$this->print = $this->print;
$this->pdf = true;
$this->hits = false;
$this->parentCategoryVisible = $this->params->get('show_section') && $this->item->sectionid && isset($this->item->section);
$this->categoryVisible = $this->params->get('show_category') && $this->item->catid;
}
function renderPageContainerBegin() {
return '';
}
function renderPageHeading() {
if ($this->pageHeadingVisible)
return artxPost(array('header-text' => $this->_document->escape($this->pageHeading)));
return '';
}
function getArticleViewParameters() {
return array('metadata-header-icons' => array(), 'metadata-footer-icons' => array());
}
function renderCreateDateInfo() {
return JHTML::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'));
}
function renderModifyDateInfo() {
return JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC2')));
}
function renderPublishDateInfo() {
return '';
}
function renderAuthorInfo() {
return JText::sprintf('Written by', (!empty($this->item->created_by_alias)
? $this->_document->escape($this->item->created_by_alias)
: $this->_document->escape($this->item->author)));
}
function renderPrintPopupIcon() {
return JHtml::_('icon.print_popup', $this->item, $this->params, $this->_document->access);
}
function renderPrintScreenIcon() {
return JHtml::_('icon.print_screen', $this->item, $this->params, $this->_document->access);
}
function renderEmailIcon() {
return JHtml::_('icon.email', $this->item, $this->params, $this->_document->access);
}
function renderEditIcon() {
return JHtml::_('icon.edit', $this->item, $this->params, $this->_document->access);
}
function renderPdfIcon() {
return JHTML::_('icon.pdf', $this->item, $this->params, $this->_document->access);
}
function renderHitsInfo() {
return '';
}
function renderCategories() {
$result = JText::_('Category') . ': ';
if ($this->parentCategoryVisible) {
$result .= '<span class="art-post-metadata-category-parent">';
$title = $this->_document->escape($this->item->section);
if ($this->params->get('link_section'))
$result .= '<a href="' . JRoute::_(ContentHelperRoute::getSectionRoute($this->item->sectionid)).'">' . $title . '</a>';
else
$result .= $title;
$result .= '</span>';
}
if ($this->parentCategoryVisible && $this->categoryVisible)
$result .= ' / ';
if ($this->categoryVisible) {
$result .= '<span class="art-post-metadata-category-name">';
$title = $this->_document->escape($this->item->category);
if ($this->params->get('link_category'))
$result .= '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug, $this->item->sectionid)) . '">' . $title . '</a>';
else
$result .= $title;
$result .= '</span>';
}
return $result;
}
function renderArticle($article) {
return artxPost($article);
}
function renderPageContainerEnd() {
return '';
}
}
class ArtxContentArticleView16
{
private $_document;
public $version;
public $params;
public $canEdit;
public $pageHeadingVisible;
public $pageHeading;
public $titleVisible;
public $titleLink;
public $title;
public $print;
public $pdf;
public $hits;
public $parentCategoryVisible;
public $categoryVisible;
function __construct(&$document, &$item, &$params) {
$this->_document = $document;
$this->item = & $item;
$this->params = & $params;
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' . $this->item->id);
$this->pageHeadingVisible = $this->params->get('show_page_heading', 1);
$this->pageHeading = $this->params->get('page_heading');
$this->titleVisible = $this->params->get('show_title') || $this->params->get('access-edit');
$this->titleLink = $this->params->get('link_titles') && !empty($this->item->readmore_link) ? $this->item->readmore_link : '';
$this->title = $this->item->title;
$this->print = $this->print;
$this->hits = true;
$this->pdf = false;
$this->parentCategoryVisible = $this->params->get('show_parent_category') && $this->item->parent_slug != '1:root';
$this->categoryVisible = $this->params->get('show_category');
}
function renderPageContainerBegin() {
return '<div class="item-page' . $this->params->get('pageclass_sfx') . '">';
}
function renderPageHeading() {
if ($this->pageHeadingVisible)
return artxPost(array('header-text' => $this->_document->escape($this->pageHeading)));
return '';
}
function getArticleViewParameters() {
return array('metadata-header-icons' => array(), 'metadata-footer-icons' => array());
}
function renderCreateDateInfo() {
return JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHTML::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2')));
}
function renderModifyDateInfo() {
return JText::sprintf('COM_CONTENT_LAST_UPDATED', JHTML::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC2')));
}
function renderPublishDateInfo() {
return JText::sprintf('COM_CONTENT_PUBLISHED_DATE', JHTML::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC2')));
}
function renderAuthorInfo() {
$author = $this->params->get('link_author', 0)
? JHTML::_('link', JRoute::_('index.php?option=com_users&view=profile&member_id=' . $this->item->created_by), $this->item->author)
: $this->item->author;
$author = $this->item->created_by_alias ? $this->item->created_by_alias : $author;
return JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
}
function renderPrintPopupIcon() {
return JHtml::_('icon.print_popup', $this->item, $this->params);
}
function renderPrintScreenIcon() {
return JHtml::_('icon.print_screen', $this->item, $this->params);
}
function renderEmailIcon() {
return JHtml::_('icon.email', $this->item, $this->params);
}
function renderEditIcon() {
return JHtml::_('icon.edit', $this->item, $this->params);
}
function renderPdfIcon() {
return '';
}
function renderHitsInfo() {
return JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits);
}
function renderCategories() {
$result = JText::_('Category') . ': ';
if ($this->parentCategoryVisible) {
$result .= '<span class="art-post-metadata-category-parent">';
$title = $this->_document->escape($this->item->parent_title);
if ($this->params->get('link_parent_category') && $this->item->parent_slug)
$result .= '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->parent_slug)) . '">' . $title . '</a>';
else
$result .= $title;
$result .= '</span>';
}
if ($this->parentCategoryVisible && $this->categoryVisible)
$result .= ' / ';
if ($this->categoryVisible) {
$result .= '<span class="art-post-metadata-category-name">';
$title = $this->_document->escape($this->item->category_title);
if ($this->params->get('link_category') && $this->item->catslug)
$result .= '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug)) . '">' . $title . '</a>';
else
$result .= $title;
$result .= '</span>';
}
return $result;
}
function renderArticle($article) {
return artxPost($article);
}
function renderPageContainerEnd() {
return '</div>';
}
}
function artxHasMessages()
{
if (isset($GLOBALS['mainframe'])) {
// Joomla 1.5
global $app;
$app = & $app;
} else
// Joomla 1.6
$app = JFactory::getApplication();
$messages = $app->getMessageQueue();
if (is_array($messages) && count($messages))
foreach ($messages as $msg)
if (isset($msg['type']) && isset($msg['message']))
return true;
return false;
}
/**
* Renders article or block in the Post style.
*
* Elements of the $data array:
* 'classes'
* 'header-text'
* 'header-icon'
* 'header-link'
* 'metadata-header-icons'
* 'metadata-footer-icons'
* 'content'
*/
function artxPost($data)
{
if (is_string($data))
$data = array('content' => $data);
$classes = isset($data['classes']) && strlen($data['classes']) ? $data['classes'] : '';
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"));
artxFragmentBegin("<h2 class=\"art-postheader\"> ");
artxFragmentBegin("");
if (isset($data['header-text']) && strlen($data['header-text'])) {
if (isset($data['header-link']) && strlen($data['header-link']))
artxFragmentContent('<a href="' . $data['header-link'] . '" class="PostHeader">' . $data['header-text'] . '</a>');
else
artxFragmentContent($data['header-text']);
}
artxFragmentEnd("\r\n");
artxFragmentEnd("</h2>\r\n");
artxFragmentBegin("<div class=\"art-postheadericons art-metadata-icons\">\r\n");
if (isset($data['metadata-header-icons']) && count($data['metadata-header-icons']))
foreach ($data['metadata-header-icons'] as $icon)
artxFragment('', $icon, '', ' | ');
artxFragmentEnd("\r\n</div>\r\n");
artxFragmentBegin("<div class=\"art-postcontent\">\r\n");
if (isset($data['content']) && strlen($data['content']))
artxFragmentContent($data['content']);
artxFragmentEnd("\r\n</div>\r\n<div class=\"cleared\"></div>\r\n");
artxFragmentBegin("<div class=\"art-postfootericons art-metadata-icons\">\r\n");
if (isset($data['metadata-footer-icons']) && count($data['metadata-footer-icons']))
foreach ($data['metadata-footer-icons'] as $icon)
artxFragment('', $icon, '', ' | ');
artxFragmentEnd("\r\n</div>\r\n");
return artxFragmentEnd("\r\n</div>\r\n\r\n <div class=\"cleared\"></div>\r\n </div>\r\n</div>\r\n", '', true);
}
function artxBlock($caption, $content, $classes = '')
{
$hasCaption = ($GLOBALS['artx_settings']['block']['has_header']
&& null !== $caption && strlen(trim($caption)) > 0);
$hasContent = (null !== $content && strlen(trim($content)) > 0);
if (!$hasCaption && !$hasContent)
return '';
ob_start();
?>
<?php ob_start(); ?>
<div class="art-block">
<div class="art-block-cc"></div>
<div class="art-block-body">
<?php echo str_replace('class="art-block">', 'class="art-block' . $classes . '">', ob_get_clean()); ?>
<?php if ($hasCaption): ?>
<div class="art-blockheader">
<div class="l"></div>
<div class="r"></div>
<h3 class="t">
<?php echo $caption; ?>
</h3>
</div>
<?php endif; ?>
<?php if ($hasContent): ?>
<div class="art-blockcontent">
<div class="art-blockcontent-cc"></div>
<div class="art-blockcontent-body">
<?php echo artxReplaceButtons($content); ?>
<div class="cleared"></div>
</div>
</div>
<?php endif; ?>
<div class="cleared"></div>
</div>
</div>
<?php
return ob_get_clean();
}
function artxVMenuBlock($caption, $content, $classes = '')
{
$hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
$hasContent = (null !== $content && strlen(trim($content)) > 0);
if (!$hasCaption && !$hasContent)
return '';
ob_start();
?>
<?php ob_start(); ?><div class="art-vmenublock">
<div class="art-vmenublock-cc"></div>
<div class="art-vmenublock-body">
<?php echo str_replace('class="art-vmenublock">', 'class="art-vmenublock' . $classes . '">', ob_get_clean()); ?>
<?php if ($hasCaption): ?><div class="art-vmenublockheader">
<div class="l"></div>
<div class="r"></div>
<h3 class="t">
<?php echo $caption; ?></h3>
</div>
<?php endif; ?>
<?php if ($hasContent): ?><div class="art-vmenublockcontent">
<div class="art-vmenublockcontent-body">
<?php echo $content; ?>
<div class="cleared"></div>
</div>
</div>
<?php endif; ?>
<div class="cleared"></div>
</div>
</div>
<?php
return ob_get_clean();
}
function artxPageTitle($page, $criteria = null, $key = null)
{
if ($criteria === null)
$criteria = $page->params->def('show_page_title', 1);
return $criteria
? ('<span class="componentheading' . $page->params->get('pageclass_sfx') . '">'
. $page->escape($page->params->get($key === null ? 'page_title' : $key)) . '</span>')
: '';
}
function artxCountModules(&$document, $position)
{
return $document->countModules($position);
}
function artxPositions(&$document, $positions, $style)
{
ob_start();
if (count($positions) == 3) {
if (artxCountModules($document, $positions[0])
&& artxCountModules($document, $positions[1])
&& artxCountModules($document, $positions[2]))
{
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td width="33%"><?php echo artxModules($document, $positions[1], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[1], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[1]) && artxCountModules($document, $positions[2])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="67%"><?php echo artxModules($document, $positions[1], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[2])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} else {
echo artxModules($document, $positions[0], $style);
echo artxModules($document, $positions[1], $style);
echo artxModules($document, $positions[2], $style);
}
} elseif (count($positions) == 2) {
if (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[1], $style); ?></td>
</tr>
</table>
<?php
} else {
echo artxModules($document, $positions[0], $style);
echo artxModules($document, $positions[1], $style);
}
} // count($positions)
return ob_get_clean();
}
function artxGetContentCellStyle(&$document)
{
$leftCnt = artxCountModules($document, 'left');
$rightCnt = artxCountModules($document, 'right');
if ($leftCnt > 0 && $rightCnt > 0)
return 'content';
if ($rightCnt > 0)
return 'content-sidebar1';
if ($leftCnt > 0)
return 'content-sidebar2';
return 'content-wide';
}
/**
* Wraps component content into article style unless it is not wrapped already.
*
* The artxComponentWrapper function gets the content of the 'component' buffer and search for the '<div class="art-post">' 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 artxComponentWrapper(&$document)
{
if ($document->getType() != 'html')
return;
$content = $document->getBuffer('component');
if (false === strpos($content, '<div class="art-post')) {
$title = null;
if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
$title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
}
$document->setBuffer(artxPost(array('header-text' => $title, 'content' => $content)), 'component');
}
}
function artxModules(&$document, $position, $style = null)
{
return '<jdoc:include type="modules" name="' . $position . '"' . (null != $style ? ' style="artstyle" artstyle="' . $style . '"' : '') . ' />';
}
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 '~<input\b[^>]*'
. '\bclass=(?")(?:[^"]*\s)?button(?:\s[^"]*)?"|(\')(?:[^\']*\s)?button(?:\s[^\']*)?\'|button(?=[/>\s]))'
. '[^>]*/?\s*>~i';
}
function artxReplaceButtons($content)
{
$re = artxReplaceButtonsRegex();
if (!preg_match_all($re, $content, $matches, PREG_OFFSET_CAPTURE))
return $content;
$result = '';
$position = 0;
for ($index = 0; $index < count($matches[0]); $index++) {
$match = $matches[0][$index];
if (is_array($matches[1][$index]) && strlen($matches[1][$index][0]) > 0)
$quote = $matches[1][$index][0];
else if (is_array($matches[2][$index]) && strlen($matches[2][$index][0]) > 0)
$quote = $matches[2][$index][0];
else
$quote = '"';
$result .= substr($content, $position, $match[1] - $position);
$position = $match[1] + strlen($match[0]);
$result .= str_replace('"', $quote, '<span class="art-button-wrapper"><span class="art-button-l"> </span><span class="art-button-r"> </span>')
. preg_replace('~\bclass=(?:"([^"]*\s)?button(\s[^"]*)?"|\'([^\']*\s)?button(\s[^\']*)?\'|button(?=[/>\s]))~i',
str_replace('"', $quote, 'class="\1\3button art-button\2\4"'), $match[0]) . '</span>';
}
$result .= substr($content, $position);
return $result;
}
function artxLinkButton($data = array())
{
return '<span class="art-button-wrapper"><span class="art-button-l"> </span><span class="art-button-r"> </span>'
. '<a class="' . (isset($data['classes']) && isset($data['classes']['a']) ? $data['classes']['a'] . ' ' : '')
. 'art-button" href="' . $data['link'] . '">' . $data['content'] . '</a></span>';
}
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;
}
function artxTagBuilder($tag, $attributes, $content) {
$result = '<' . $tag;
foreach ($attributes as $name => $value) {
if (is_string($value)) {
if (!empty($value))
$result .= ' ' . $name . '="' . $value . '"';
} else if (is_array($value)) {
$values = array_filter($value);
if (count($values))
$result .= ' ' . $name . '="' . implode(' ', $value) . '"';
}
}
$result .= '>' . $content . '</' . $tag . '>';
return $result;
}
$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 = '', $return = false)
{
global $artxFragments;
$fragment = array_pop($artxFragments);
$fragment['tail'] = $tail;
$content = trim($fragment['content']);
if (count($artxFragments) == 0) {
if ($return)
return (trim($content) == '') ? '' : ($fragment['head'] . $content . $fragment['tail']);
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 = '', $return = false)
{
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, $return);
}
}
</code>
|
|
Friend
|
In functions.php
tag <code></code> - none
(You should provide some more details like, what additional modules/plugins you are using.)
|
|
Castor
|
Testing Joomla 1.6 with Artisteer 3.0 last version, the functions.php on line 168 produces an error:
Fatal error: Cannot access protected property ContentViewArticle::$user in J:\xampp\htdocs\joomla1611\templates\joomla1620\functions.php on line 168
To prevent this I've changed this line:
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
into:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
For my purposes this works well.
You may have a better solution.
Sincerly
Castor
|
|
maru
|
Quote Castor:
Testing Joomla 1.6 with Artisteer 3.0 last version, the functions.php on line 168 produces an error:
Fatal error: Cannot access protected property ContentViewArticle::$user in J:\xampp\htdocs\joomla1611\templates\joomla1620\functions.php on line 168
To prevent this I've changed this line:
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
into:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
For my purposes this works well.
You may have a better solution.
Sincerly
Castor
Castor, which is the file to need modify the code? I have the same problem.
Thanks a lot!!!
|
|
dominique
|
Quote maru:
Quote Castor:
Testing Joomla 1.6 with Artisteer 3.0 last version, the functions.php on line 168 produces an error:
Fatal error: Cannot access protected property ContentViewArticle::$user in J:\xampp\htdocs\joomla1611\templates\joomla1620\functions.php on line 168
To prevent this I've changed this line:
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
into:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
For my purposes this works well.
You may have a better solution.
Sincerly
Castor
Castor, which is the file to need modify the code? I have the same problem.
Thanks a lot!!!
This is the solution, Castor, great & thanks!
maru > go to: templates / [the template you're using] / functions.php
search the line with search function and replace it with Castor's input
grtz
|
|
Juanjo
|
Great¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
|
|
SamJo
|
Hi,
at first a big THANK YOU for this Solution!
but i have one additional suggestion to prevent editing the "functions.php" in every created template:
Just goto
"c:\Program Files (x86)\Artisteer 3\Library\Data\Templates\Joomla\Export\" on your computer (this is the path for a windows 7/64bit-system, on a 32bit-system it is "c:\Program Files\Artisteer 3\Library\Data\Templates\Joomla\Export\") and edit the "functions.php" there. So you have it ready in every template you create after that!
Greetz,
SamJo
|
|
simsboard
|
sorry to reopen this old thread
but I've got the same problem as mentioned by the initiater of this thread
tried to solve it the same way as described here but unfortunatly my "functions.php" file does not have the lines:
===
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
===
=> so there is nothing I can exchange
I'm running artisteer 3.0.0
any hints?
thanks!
simsboard
|
|
Kampro
|
Artisteer! you have some work to do! You have to get you software to work with the new version of joomla. Joomla should have least gave you the heads up! if not the is .....up! I tried earlier version of Artisteer and same thing. Good luck, you have a great program. You may need to break them off with some cash!
Hit me up when you solve the problem. I will just use Joomla 1.5.
|
|
Garry
|
Contacting Artisteer support may be very helpful.
|
|
starmoca
|
i worked for me...
|
|
Henrik
|
Thank you Castor!
It worked for me to!
|
|
vero
|
Hi there, I have all the same problems above, no line
===
$this->canEdit .... to edit the file
any help around?
|
|
Deepak Kumar Bhanja
|
Quote Deepak Kumar Bhanja:
Testing Joomla 1.6 with Artisteer 3.0 last version, the functions.php on line 168 produces an error:
Fatal error: Cannot access protected property ContentViewArticle::$user in J:\xampp\htdocs\joomla1611\templates\joomla1620\functions.php on line 168
To prevent this I've changed this line:
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
into:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
For my purposes this works well.
You may have a better solution.
Sincerly
Deepak Kumar Bhanja
Systems Administrator
Delhi Public School Surat
|
|
Chris Richard
|
Good golly!
Do yourselves a huge favor:
UPGRADE to the topmost version under the "News" link right on this page! I did when I started seeing all these errors, and haven't had an issue since.
|
|
Mehdi
|
Quote :This is a best solution
hi my dear.
tnhx for your solution, i hope you have happy times for ever.
|
|
Adam Sikora
|
One should not perform the hack as described above...this is simply not the way to work with the Joomla! architecture. Permission is being given to random users to edit...
there is a simple problem, the article object passed to the template has a new structure, and needs to be treated as such...
in file /html/com_content/article/default.php
line 7 reads:
echo artxPost(artxPageTitle($this, $this->params->get('show_page_title', 1) && $this->params->get('page_title') != $this->article->title), null);
This incorrectly looks within a protected area for the page params. it should be changed to this:
echo artxPost(artxPageTitle($this->item, $this->item->params->get('show_page_title', 1) && $this->item->params->get('page_title') != $this->item->title), null);
This CORRECTLY passes the information needed without having to HACK the core permissions.
p.s. do not forget to add:
JHTML::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_content'.DS.'helpers');
to your functions.php file, this is needed to extend the JHTML class
Adam Sikora
ARS Web Development
|
|
Thobbe
|
Quote Adam Sikora:
One should not perform the hack as described above...this is simply not the way to work with the Joomla! architecture. Permission is being given to random users to edit...
there is a simple problem, the article object passed to the template has a new structure, and needs to be treated as such...
in file /html/com_content/article/default.php
line 7 reads:
echo artxPost(artxPageTitle($this, $this->params->get('show_page_title', 1) && $this->params->get('page_title') != $this->article->title), null);
This incorrectly looks within a protected area for the page params. it should be changed to this:
echo artxPost(artxPageTitle($this->item, $this->item->params->get('show_page_title', 1) && $this->item->params->get('page_title') != $this->item->title), null);
This CORRECTLY passes the information needed without having to HACK the core permissions.
p.s. do not forget to add:
JHTML::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_content'.DS.'helpers');
to your functions.php file, this is needed to extend the JHTML class
Adam Sikora
ARS Web Development
were i should add the line in functions.php ?
On line 168 ?
JHTML::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_content'.DS.'helpers');
|
|
Adam Sikora
|
at the very top, right below jexec or die.
Just so you know also, there are more references to incorrect objects throughout the html folder. I'm still going through it and marking the errors.
although there are many of the joomla 1.6 issues resolved in the newer versions of artisteer those who have older versions are SOL. In particular, people who have J1.5 Artisteer templates who want to upgrade to 1.6 without having to build a new template.
Once i have completed my search for errors i'll post them. I am using an artisteer 2.5 generated template.
|
|
moch84bdg
|
$user =& JFactory::getUser(); $this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' . $this->item->id);
It's works! Thank you...
|
|
Vella
|
Quote Friend:
Fatal error: Cannot access protected property ContentViewArticle::$user in Z:\home\localhost\www\xxxxxx\functions.php on line 170
Help me please!
Help me please!
I use Artisteer 2.3 at me.
Fatal error: Cannot access protected property ContentViewArticle::$params in /home/u18447/u18447.netangels.ru/www/templates/hram/functions.php on line 170
How to correct?
<?php
defined('_JEXEC') or die('Restricted access'); // no direct access
if (!defined('_ARTX_FUNCTIONS')) {
define('_ARTX_FUNCTIONS', 1);
function artxHasMessages()
{
$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;
}
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 '' .
'~<input\b[^>]*'
. '(?:'
. '[^>]*\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 .= '<span class="art-button-wrapper"><span class="l"> </span><span class="r"> </span>'
. preg_replace('~\bclass=(?:"([^"]*\s)?button(\s[^"]*)?"|\'([^\']*\s)?button(\s[^\']*)?\'|button\b)~i',
'class="\1\3button art-button\2\4"', $match[0]) . '</span>';
}
$result .= substr($content, $position);
return $result;
}
function artxPost($caption, $content)
{
$hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
$hasContent = (null !== $content && strlen(trim($content)) > 0);
if (!$hasCaption && !$hasContent)
return '';
ob_start();
?>
<div class="art-Post">
<div class="art-Post-body">
<div class="art-Post-inner">
<?php if ($hasCaption): ?>
<h2 class="art-PostHeader">
<?php echo $caption; ?>
</h2>
<?php endif; ?>
<?php if ($hasContent): ?>
<div class="art-PostContent">
<?php echo artxReplaceButtons($content); ?>
</div>
<div class="cleared"></div>
<?php endif; ?>
</div>
<div class="cleared"></div>
</div>
</div>
<?php
return ob_get_clean();
}
function artxBlock($caption, $content)
{
$hasCaption = (null !== $caption && strlen(trim($caption)) > 0);
$hasContent = (null !== $content && strlen(trim($content)) > 0);
if (!$hasCaption && !$hasContent)
return '';
ob_start();
?>
<div class="art-Block">
<div class="art-Block-body">
<?php if ($hasCaption): ?>
<div class="art-BlockHeader">
<div class="l"></div>
<div class="r"></div>
<div class="art-header-tag-icon">
<div class="t">
<?php echo $caption; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ($hasContent): ?>
<div class="art-BlockContent">
<div class="art-BlockContent-body">
<?php echo artxReplaceButtons($content); ?>
<div class="cleared"></div>
</div>
</div>
<?php endif; ?>
<div class="cleared"></div>
</div>
</div>
<?php
return ob_get_clean();
}
function artxPageTitle($page, $criteria = null, $key = null)
{
if ($criteria === null)
$criteria = $page->params->def('show_page_title', 1);
return $criteria
? ('<span class="componentheading' . $page->params->get('pageclass_sfx') . '">'
. $page->escape($page->params->get($key === null ? 'page_title' : $key)) . '</span>')
: '';
}
function artxCountModules(&$document, $position)
{
if (null === $document)
// for Joomla 1.0
return mosCountModules($position);
// for Joomla 1.5
return $document->countModules($position);
}
function artxPositions(&$document, $positions, $style)
{
ob_start();
if (count($positions) == 3) {
if (artxCountModules($document, $positions[0])
&& artxCountModules($document, $positions[1])
&& artxCountModules($document, $positions[2]))
{
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td width="33%"><?php echo artxModules($document, $positions[1], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="33%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[1], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[1]) && artxCountModules($document, $positions[2])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="67%"><?php echo artxModules($document, $positions[1], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} elseif (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[2])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[2], $style); ?></td>
</tr>
</table>
<?php
} else {
echo artxModules($document, $positions[0], $style);
echo artxModules($document, $positions[1], $style);
echo artxModules($document, $positions[2], $style);
}
} elseif (count($positions) == 2) {
if (artxCountModules($document, $positions[0]) && artxCountModules($document, $positions[1])) {
?>
<table class="position" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="50%"><?php echo artxModules($document, $positions[0], $style); ?></td>
<td><?php echo artxModules($document, $positions[1], $style); ?></td>
</tr>
</table>
<?php
} else {
echo artxModules($document, $positions[0], $style);
echo artxModules($document, $positions[1], $style);
}
} // count($positions)
return ob_get_clean();
}
function artxGetContentCellStyle(&$document)
{
$leftCnt = artxCountModules($document, 'left');
$rightCnt = artxCountModules($document, 'right');
if ($leftCnt > 0 && $rightCnt > 0)
return 'content';
if ($rightCnt > 0)
return 'content-sidebar1';
if ($leftCnt > 0)
return 'content-sidebar2';
return 'content-wide';
}
function artxHtmlFixMoveScriptToHead($re, $content)
{
if (preg_match($re, $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1])
. substr($content, $matches[0][1] + strlen($matches[0][0]));
$document =& JFactory::getDocument();
$document->addScriptDeclaration($matches[1][0]);
}
return $content;
}
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;
}
function artxHtmlFixRemove($re, $content)
{
if (preg_match($re, $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1])
. substr($content, $matches[0][1] + strlen($matches[0][0]));
}
return $content;
}
function artxComponentWrapper(&$document)
{
if (null === $document) {
// for Joomla 1.0
return;
}
// for Joomla 1.5
if ($document->getType() != 'html') return;
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
$content = $document->getBuffer('component');
// fixes for w3.org validation
if ('com_contact' == $option) {
if ('category' == $view) {
$content = artxHtmlFixFormAction($content);
} elseif ('contact' == $view) {
$content = artxHtmlFixMoveScriptToHead('~<script [^>]+>\s*(<!--[^>]*-->)\s*</script>~', $content);
}
} elseif ('com_content' == $option) {
if ('category' == $view) {
if ('' == $layout) {
$content = artxHtmlFixMoveScriptToHead('~<script [^>]+>([^<]*)</script>~', $content);
$content = artxHtmlFixFormAction($content);
}
} elseif ('archive' == $view) {
$content = artxHtmlFixRemove('~<ul id="archive-list" style="list-style: none;">\s*</ul>~', $content);
}
} elseif ('com_user' == $option) {
if ('user' == $view) {
if ('form' == $layout) {
$content = artxHtmlFixRemove('~autocomplete="off"~', $content);
}
}
}
if (false === strpos($content, '<div class="art-Post">')) {
$title = null;
if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
$title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
}
$document->setBuffer(artxPost($title, $content), 'component');
}
}
function artxComponent()
{
// for Joomla 1.0
ob_start();
mosMainBody();
$content = ob_get_clean();
if (false === strpos($content, '<div class="art-Post">')) {
$title = null;
if (preg_match('~<div\s+class="(componentheading[^"]*)"([^>]*)>([^<]+)</div>~', $content, $matches, PREG_OFFSET_CAPTURE)) {
$content = substr($content, 0, $matches[0][1]) . substr($content, $matches[0][1] + strlen($matches[0][0]));
$title = '<span class="' . $matches[1][0] . '"' . $matches[2][0] . '>' . $matches[3][0] . '</span>';
}
return artxPost($title, $content);
}
return $content;
}
function artxModules(&$document, $position, $style = null)
{
if (null === $document) {
// for Joomla 1.0
ob_start();
mosLoadModules($position, -2);
$content = ob_get_clean();
if (null == $style || 'xhtml' == $style)
return $content;
$decorator = 'artblock' == $style ? 'artxBlock' : ('artpost' == $style ? 'artxPost' : null);
$result = '';
$modules = preg_split('~</div>\s*<div class="moduletable">~', $content);
$lastModule = count($modules) - 1;
if ($lastModule > -1) {
$modules[0] = preg_replace('~^\s*<div class="moduletable">~', '', $modules[0]);
$modules[$lastModule] = preg_replace('~</div>\s*$~', '', $modules[$lastModule]);
foreach ($modules as $module) {
if (preg_match('~^\s*<h3>([^<]*)</h3>~', $module, $matches, PREG_OFFSET_CAPTURE)) {
$result .= $decorator($matches[1][0], substr($module, 0, $matches[0][1])
. substr($module, $matches[0][1] + strlen($matches[0][0])));
} else {
$result .= $decorator(null, $module);
}
}
}
return $result;
}
// for Joomla 1.5
return '<jdoc:include type="modules" name="' . $position . '"' . (null != $style ? ' style="artstyle" artstyle="' . $style . '"' : '') . ' />';
}
$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);
}
}
I will be very, very, very grateful for the help.
|
|
Nick V
|
Quote simsboard:
sorry to reopen this old thread
but I've got the same problem as mentioned by the initiater of this thread
tried to solve it the same way as described here but unfortunatly my "functions.php" file does not have the lines:
===
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
===
=> so there is nothing I can exchange
I'm running artisteer 3.0.0
any hints?
thanks!
simsboard
I'm having the same problem!
|
|
Vella
|
Quote Friend:
Fatal error: Cannot access protected property ContentViewArticle::$user in Z:\home\localhost\www\xxxxxx\functions.php on line 170
Help me please!
Tell please what версиею programs Artisteer you used?
In advance - thanks!
|
|
Vella
|
Quote Castor:
Testing Joomla 1.6 with Artisteer 3.0 last version, the functions.php on line 168 produces an error:
Fatal error: Cannot access protected property ContentViewArticle::$user in J:\xampp\htdocs\joomla1611\templates\joomla1620\functions.php on line 168
To prevent this I've changed this line:
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
into:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
For my purposes this works well.
You may have a better solution.
Sincerly
Castor
I have established Artister 3.0
Has created a template anew.
There was a code
$this->canEdit = $document->user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
With which it is necessary to replace on:
$user =& JFactory::getUser();
$this->canEdit = $user->authorise('core.edit', 'com_content.frontpage.' .
$this->item->id);
All has made so.
The error doesn't disappear.
Help me please.
|
|
Garry
|
Make sure you are running PHP 5 on your web host and have latest Artisteer "3.0.0.41778" update.
|
|
David
|
I have same problem with Wampserver 2.2d, Joomla 2.5, Artisteer 3.0. I need help??
|
|
Giuseppe
|
i'm testing artisteer 3 but i have this problem
what i must do?
I can't to understand where is the problem.
Thank for your collaboration
Fatal error: Cannot access protected property ContentViewArticle::$user in C:\xampp-joomla\htdocs\mercao\templates\mercao4\functions.php on line 40
My e-mail is joe1229@libero.it
|
|
Garry
|
@ Giuseppe
Contacting Artisteer support with your exported theme may be very helpful: http://www.artisteer.com/?p=support
|
|
|