За последние 24 часа нас посетили 20467 программистов и 1085 роботов. Сейчас ищут 814 программистов ...

Подскажите пожалуйста.

Тема в разделе "PHP для новичков", создана пользователем Trulala, 3 фев 2023.

  1. Trulala

    Trulala Новичок

    С нами с:
    3 фев 2023
    Сообщения:
    1
    Симпатии:
    0
    Сайт на Joomla 3.10. Перешел с PHP 7.4 на PHP 8.1 и получаю на сайте, на некоторых!!! страницах, сообщение:
    Warning: Undefined property: stdClass::$contactid in /home/f/funnystudy/public_html/templates/behealthy7/library/Artx/Content/SingleArticle.php on line 42

    Код SingleArticle.php:

    PHP:
    1. <?php
    2. defined('_JEXEC') or die;
    3.  
    4. Artx::load("Artx_Content_Item");
    5.  
    6. class ArtxContentSingleArticle extends ArtxContentItem
    7. {
    8.     public $print;
    9.  
    10.     public $toc;
    11.  
    12.     public $intro;
    13.  
    14.     public $text;
    15.  
    16.     public function __construct($component, $componentParams, $article, $articleParams, $properties)
    17.     {
    18.         parent::__construct($component, $componentParams, $article, $articleParams);
    19.         $this->print = isset($properties['print']) ? $properties['print'] : '';
    20.         $this->pageHeading = $this->_componentParams->get('show_page_heading', 1)
    21.                                ? $this->_componentParams->get('page_heading') : '';
    22.         $this->titleLink = $this->_articleParams->get('link_titles') && !empty($this->_article->readmore_link)
    23.                              ? $this->_article->readmore_link : '';
    24.         $this->emailIconVisible = $this->emailIconVisible && !$this->print;
    25.         $this->editIconVisible = $this->editIconVisible && !$this->print;
    26.         $this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug
    27.                                 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug))
    28.                                 : '';
    29.         $this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
    30.         $this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug
    31.                                 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug))
    32.                                 : '';
    33.         $this->parentCategory = $this->_articleParams->get('show_parent_category') && $this->_article->parent_slug != '1:root'
    34.                                   ? $this->_article->parent_title : '';
    35.         $this->parentCategoryLink = $this->_articleParams->get('link_parent_category') && $this->_article->parent_slug
    36.                                       ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug))
    37.                                       : '';
    38.         $this->author = $this->_articleParams->get('show_author') && !empty($this->_article->author)
    39.                           ? ($this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author)
    40.                           : '';
    41.         if (strlen($this->author) && $this->_articleParams->get('link_author')) {
    42.             $needle = 'index.php?option=com_contact&view=contact&id=' . $this->_article->contactid;
    43.             $menu = JFactory::getApplication()->getMenu();
    44.             $item = $menu->getItems('link', $needle, true);
    45.             $this->authorLink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
    46.         } else
    47.             $this->authorLink = '';
    48.         $this->toc = isset($this->_article->toc) ? $this->_article->toc : '';
    49.         $this->text = $this->_articleParams->get('access-view') ? $this->_article->text : '';
    50.         $user = JFactory::getUser();
    51.         $this->introVisible = !$this->_articleParams->get('access-view') && $this->_articleParams->get('show_noauth') && $user->get('guest');
    52.         $this->intro = $this->_article->introtext;
    53.         if (!$this->_articleParams->get('access-view') && $this->_articleParams->get('show_noauth') && $user->get('guest')
    54.             && $this->_articleParams->get('show_readmore') && $this->_article->fulltext != null)
    55.         {
    56.             $attribs = json_decode($this->_article->attribs);
    57.             if ($attribs->alternative_readmore == null)
    58.                 $this->readmore = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
    59.             elseif ($this->readmore = $this->_article->alternative_readmore) {
    60.                 if ($this->_articleParams->get('show_readmore_title', 0) != 0)
    61.                     $this->readmore .= JHtml::_('string.truncate', ($this->_article->title), $this->_articleParams->get('readmore_limit'));
    62.             } elseif ($this->_articleParams->get('show_readmore_title', 0) == 0)
    63.                 $this->readmore = JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
    64.             else
    65.                 $this->readmore = JText::_('COM_CONTENT_READ_MORE')
    66.                                     . JHtml::_('string.truncate', $this->_article->title,
    67.                                                $this->_articleParams->get('readmore_limit'));
    68.             $link = new JURI(JRoute::_('index.php?option=com_users&view=login'));
    69.             $this->readmoreLink = $link->__toString();
    70.         } else {
    71.             $this->readmore = '';
    72.             $this->readmoreLink = '';
    73.         }
    74.         $this->paginationPosition = (isset($this->_article->pagination) && $this->_article->pagination && isset($this->_article->paginationposition))
    75.             ? (($this->_article->paginationposition ? 'below' : 'above') . ' ' . ($this->_article->paginationrelative ? 'full article' : 'text'))
    76.             : '';
    77.         $this->showLinks = isset($this->_article->urls) && is_string($this->_article->urls) && !empty($this->_article->urls);
    78.     }
    79.  
    80.     public function printIcon()
    81.     {
    82.         $text =  JHTML::_($this->print ? 'icon.print_screen' : 'icon.print_popup', $this->_article, $this->_articleParams);
    83.         if ($this->showIcons) {
    84.             $text = str_replace('&#160;' . JText::_('JGLOBAL_PRINT') . '&#160;', '', $text);
    85.             $text = str_replace('icon-print', 'fs-postprinticon', $text);
    86.         }
    87.         return $text;
    88.     }
    89.  
    90.     public function toc($toc)
    91.     {
    92.         return '<div class="fs-article">' . $toc . '</div>';
    93.     }
    94.  
    95.     public function intro($intro)
    96.     {
    97.         return '<div class="fs-article">' . $intro . '</div>';
    98.     }
    99.  
    100.     public function text($text)
    101.     {
    102.         return '<div class="fs-article">' . $text . '</div>';
    103.     }
    104.  
    105.     public function pagination() {
    106.         $count = preg_match_all('/<a[^>]*>.*?<\/a>/', $this->_article->pagination, $matches);
    107.         $content = '';
    108.         if (false !== $count  && $count > 0){
    109.             $content = '<div class="fs-pager">';
    110.             foreach($matches[0] as $value){
    111.                 $content .= $value;
    112.             }
    113.             $content .= '</div>';
    114.         }
    115.         return $content ? $content : $this->_article->pagination;
    116.     }
    117. }
    Я в PHP мало, что понимаю. Может быть кто-нибудь подскажет в чем дело?
     
    #1 Trulala, 3 фев 2023
    Последнее редактирование: 3 фев 2023
  2. ADSoft

    ADSoft Старожил

    С нами с:
    12 мар 2007
    Сообщения:
    3.817
    Симпатии:
    735
    Адрес:
    Татарстан
    Дело в переходе на другую версию php.
     
  3. don.bidon

    don.bidon Активный пользователь

    С нами с:
    28 мар 2021
    Сообщения:
    847
    Симпатии:
    131
    Почему вопрос здесь, а не на форумах за жумлу?