0 Пользователей и 1 Гость просматривают эту тему.
  • 94 Ответов
  • 20476 Просмотров
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
При обновлении версии php с 7.0 на 7.1 или 7.2 на любой странице сайта пишет: Такой страницы не существует, и надпись: Ошибка: 0 - Using $this when not in object context.
Кто-нибудь знает в чем может быть проблема?
*

dmitry_stas

  • Легенда
  • 13151
  • 1234 / 8
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #1 : 01.10.2018, 20:50:07 »
99% в шаблоне
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #2 : 01.10.2018, 20:53:35 »
А как можно найти, или хотя бы что искать?
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #3 : 01.10.2018, 20:58:36 »
При обновлении версии php с 7.0 на 7.1 или 7.2 на любой странице сайта пишет: Такой страницы не существует, и надпись: Ошибка: 0 - Using $this when not in object context.
Кто-нибудь знает в чем может быть проблема?
Включи отладку системы в общих настройках сайта.
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

lexxbry

  • Живу я здесь
  • 2387
  • 67 / 8
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #4 : 01.10.2018, 20:58:58 »
Сначала обновляются шаблрн, компоненты, плагины, модули... Потом ядро....не факт что что то из установленного( проверять отключением) поддерживает php 7
SEO-оптимизация,продвижение
Создание и сопровождение сайтов на Joomla
Миграция
*

draff

  • Гуру
  • 5803
  • 434 / 7
  • ищу работу
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #5 : 01.10.2018, 21:08:57 »
А как можно найти, или хотя бы что искать?
Отключить все сторонние плагины, модули, переключить на стандартный шаблон. Если ошибка останется- ошибка в ядре Joomla. Но ошибка не вся, посмотрите в логе ошибок хостинга ошибки.
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #6 : 01.10.2018, 21:59:52 »
отключение всех сторонних плагинов к успеху не привело. Переключение на стандартный шаблон устраняет проблему. Включение отладки системы - не знаю что с ней делать, но когда сайт на 7.2 не работает, соответственно и отладка не работает
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #7 : 01.10.2018, 22:10:01 »
отключение всех сторонних плагинов к успеху не привело. Переключение на стандартный шаблон устраняет проблему. Включение отладки системы - не знаю что с ней делать, но когда сайт на 7.2 не работает, соответственно и отладка не работает
У тебя вот такой вид ошибки (не считая красные полосы) - это при включенной отладке
https://yadi.sk/d/-u-fCyxTtCg8Cw
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

lexxbry

  • Живу я здесь
  • 2387
  • 67 / 8
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #8 : 01.10.2018, 22:24:33 »
Значит шаб не тянет 7.2
SEO-оптимизация,продвижение
Создание и сопровождение сайтов на Joomla
Миграция
*

ProtectYourSite

  • Живу я здесь
  • 2355
  • 135 / 4
  • Безопасность вебсайтов
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #9 : 01.10.2018, 22:28:22 »
Вот открывать этот gallery.php и исправлять ошибку.
*

AlekVolsk

  • Гуру
  • 6915
  • 414 / 4
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #10 : 02.10.2018, 00:02:59 »
Рассказываю.

В PHP 7.2 режим типизации по умолчанию включен более строгий, нежели в предыдущих версиях, как его понизить - гуглите сами, но для этого нужен будет доступ к php.ini, которого на шареде как правило нет, да и настоятельно не рекомендуется править этот параметр из соображений безопасности.

В подавляющем большинстве случаев вышеуказанная ошибка кроется в некорректном обращении к объекту как к массиву или наоборот.

Если ошибка возникает только на конкретной странице сайта - смотреть компонент и модули, опубликованные на этой странице.

Если ошибка возникает на всех страницах сайта, но только на фронте - это либо шаблон, либо плагины, привязанные исключительно к фронту.

Если ошибка возникает везде, в т.ч. в админке - это 100% плагины, системные или контентные.

Если с компонентами/модулями/шаблоном можно легко разобраться, включив отображение ошибок в админке в режим "для разработчиков", и просто внимательнее читать, что пишет, то с плагинами не все так просто: в админку не пробраться, изменить режим вывода ошибок ручной правкой помогает не всегда - кроме ошибки Joomla ничего не показывает, а php-лог еще не каждый найти сумеет. Выход: отключать все сторонние плаги и включать их по одному, на каком выдаст ошибку - там и искать.

К сожалению, PHP допускает изначально слабую типизацию, что пораждает много ***кода в сторонних расширениях, в результате чего при повышении версии PHP до 7.2 вылезают вышеописанные критические ошибки. которых может быть достаточно большое множество (лично столкнулся с плагином, в котором было 102 таких ошибки).

Пишите код грамотно и не устанавливайте на ваши сайты всякое дерьмо, непонятно откуда скаченное.


Ну и в догонку малосведущим, чтобы жизнь медом не казалась
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #11 : 05.10.2018, 16:23:02 »
Посмотрел логи, вот что появилось:

Deprecated: Non-static method Joomla\CMS\Application\SiteApplication::getMenu() should not be called statically, assuming $this from incompatible context in /home/teplichk/monetkin.by/modules/mod_icemegamenu/helper.php on line 118

Deprecated: Non-static method Joomla\CMS\Application\CMSApplication::getMenu() should not be called statically, assuming $this from incompatible context in /home/teplichk/monetkin.by/libraries/src/Application/SiteApplication.php on line 275

Кто-нибудь подскажет что с этим делать?
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #12 : 05.10.2018, 16:30:54 »
Замени
Код: php
&JSite::getMenu();
на
Код: php
JFactory::getApplication()->getMenu();
« Последнее редактирование: 05.10.2018, 16:34:59 от NewUsers »
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #13 : 05.10.2018, 17:10:08 »
Заменить только в helper.php?
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #14 : 05.10.2018, 17:15:26 »
Заменить только в helper.php?
Da.
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #15 : 05.10.2018, 17:20:54 »
спасибо, помогло
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #16 : 06.10.2018, 13:27:42 »
Блин на php 5.6 все ошибки исчезли, но при переходе на 7.0 опять повылазили:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgContentembed_google_map has a deprecated constructor in /home/teplichk/vkletke.by/plugins/content/embed_google_map/embed_google_map.php on line 18

Deprecated: call_user_func_array() expects parameter 1 to be a valid callback, non-static method modIceMegamenuHelper::buildXML() should not be called statically in /home/teplichk/vkletke.by/libraries/src/Cache/Controller/CallbackController.php on line 173

Deprecated: Non-static method Joomla\CMS\Application\SiteApplication::getMenu() should not be called statically in /home/teplichk/vkletke.by/modules/mod_icemegamenu/helper.php on line 46

Deprecated: Non-static method Joomla\CMS\Application\CMSApplication::getMenu() should not be called statically in /home/teplichk/vkletke.by/libraries/src/Application/SiteApplication.php on line 275

Помогите, пожалуйста(...
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #17 : 06.10.2018, 13:43:57 »
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgContentembed_google_map has a deprecated constructor in /home/teplichk/vkletke.by/plugins/content/embed_google_map/embed_google_map.php on line 18
покажи файл!

Deprecated: Non-static method Joomla\CMS\Application\SiteApplication::getMenu() should not be called statically in /home/teplichk/vkletke.by/modules/mod_icemegamenu/helper.php on line 46
Здесь тоже надо менять
Код: php
&JSite::getMenu();
на
Код: php
JFactory::getApplication()->getMenu();
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #18 : 06.10.2018, 13:49:19 »
Код
<?php
/**
* @version $Id: Embed Google Map v1.2.1 2012-12-31 17:05 $
* @package Joomla 1.6
* [member=126442]copyright[/member] Copyright (C) 2012 Petteri Kivimдki. All rights reserved.
* @author Petteri Kivimдki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
 
 
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.plugin.plugin');

class plgContentembed_google_map extends JPlugin
{
function plgContentembed_google_map( &$subject, $params )
{
parent::__construct( $subject, $params );
}

function onContentPrepare($context, &$row, &$params, $limitstart)
{
$output = $row->text;
$regex = "#{google_map}(.*?){/google_map}#s";
$found = preg_match_all($regex, $output, $matches);

$count = 0;

if ( $found )
{
foreach ( $matches[0] as $value )
{
// Load plugin params info
$map_type = $this->params->def('map_type', 'm');
$zoom_level = $this->params->def('zoom', 14);
$language = $this->params->def('language', '-');
$add_link =  $this->params->def('add_link', 1);
$link_label = $this->params->def('link_label', 'View Larger Map');
$show_info =  $this->params->def('show_info', 0);
$height = $this->params->def('height', 300);
$width =  $this->params->def('width', 400);
$border =  $this->params->def('border', 0);
$url = "http://maps.google.com/";

$map = $value;
$map = str_replace('{google_map}','', $map);
$map = str_replace('{/google_map}','', $map);
$address = $map;
$find = '|';

if( strstr($map, $find) )
{
$arr = explode('|',$map);
$address = $arr[0];

foreach ( $arr as $phrase ) {
if ( strstr(strtolower($phrase), 'type:') )
{
$tpm1 = explode(':',$phrase);
  $tmp1 = trim($tpm1[1], '"');
if(strcmp(strtolower($tmp1),'normal') == 0) {
$map_type = 'm';
} else if(strcmp(strtolower($tmp1),'satellite') == 0) {
$map_type = 'k';
} else if(strcmp(strtolower($tmp1),'hybrid') == 0) {
$map_type = 'h';
} else if(strcmp(strtolower($tmp1),'terrain') == 0) {
$map_type = 'p';
}
}

if ( strstr(strtolower($phrase), 'zoom:') )
{       
$tpm1 = explode(':',$phrase);
$zoom_level = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'height:') )
{       
$tpm1 = explode(':',$phrase);
$height = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'width:') )
{
$tpm1 = explode(':',$phrase);
$width = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'border:') )
{       
$tpm1 = explode(':',$phrase);
$border = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'lang:') )
{       
$tpm1 = explode(':',$phrase);
$language = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'link:') )
{
$tpm1 = explode(':',$phrase);
  $tmp1 = trim($tpm1[1], '"');
if(strcmp(strtolower($tmp1),'yes') == 0) {
$add_link = 0;
} else {
$add_link = 1;
}
}

if ( strstr(strtolower($phrase), 'link_label:') )
{       
$tpm1 = explode(':',$phrase);
$link_label = trim($tpm1[1], '"');
}

if ( strstr(strtolower($phrase), 'show_info:') )
{
$tpm1 = explode(':',$phrase);
  $tmp1 = trim($tpm1[1], '"');
if(strcmp(strtolower($tmp1),'yes') == 0) {
$show_info = 0;
} else {
$show_info = 1;
}
}
}
}

if(strcmp($language,'-')!= 0) {
$language = "&hl=$language";
} else {
$language = "";
}
if(preg_match('/^http(s|):\/\//i', $address)) {
$url = $address;
} else {
$url .= "?q=$address";
}

$info = ($show_info == 0)? "" : "&iwloc=near";

if (preg_match('/^[^A-Za-z]+$/i', $address)) {
$info = ($show_info == 0)? "&iwloc=near" : "";
}

$replacement[$count] = "\n<iframe width='$width' height='$height' style='border: ".$border."px solid #000000' ";
$replacement[$count] .= "src='$url&z=$zoom_level&output=embed$language&t=$map_type$info'></iframe>\n";
if($add_link == 0) {
$replacement[$count] .= "<div><a href='$url&z=$zoom_level$language&t=$map_type$info' target='new'>$link_label</a></div>\n";
}
$count++;
}
for( $i = 0; $i < count($replacement); $i++ )
{
$row->text = preg_replace( $regex, $replacement[$i], $row->text,1);
}
}
return true;
}
}

?>
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #19 : 06.10.2018, 14:03:14 »
Замени
Код: php
function plgContentembed_google_map( &$subject, $params )
на
Код: php
function __construct(&$subject, $params)
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #20 : 06.10.2018, 14:09:23 »
Спасибо, супер, осталась последняя:

Deprecated: call_user_func_array() expects parameter 1 to be a valid callback, non-static method modIceMegamenuHelper::buildXML() should not be called statically in /home/teplichk/vkletke.by/libraries/src/Cache/Controller/CallbackController.php on line 173
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #21 : 06.10.2018, 14:18:45 »
Deprecated: call_user_func_array() expects parameter 1 to be a valid callback, non-static method modIceMegamenuHelper::buildXML() should not be called statically in /home/teplichk/vkletke.by/libraries/src/Cache/Controller/CallbackController.php on line 173
Это в каком расширении?
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #22 : 06.10.2018, 14:28:58 »
Я в этом не сильно силен, а как посмотреть?
А вот этот файл на всякий случай
Код
<?php
/**
 * Joomla! Content Management System
 *
 * [member=126442]copyright[/member]  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Cache\Controller;

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Cache\Cache;
use Joomla\CMS\Cache\CacheController;

/**
 * Joomla! Cache callback type object
 *
 * @since  11.1
 */
class CallbackController extends CacheController
{
/**
* Executes a cacheable callback if not found in cache else returns cached output and result
*
* Since arguments to this function are read with func_get_args you can pass any number of arguments to this method
* as long as the first argument passed is the callback definition.
*
* The callback definition can be in several forms:
* - Standard PHP Callback array see <https://secure.php.net/callback> [recommended]
* - Function name as a string eg. 'foo' for function foo()
* - Static method name as a string eg. 'MyClass::myMethod' for method myMethod() of class MyClass
*
* @return  mixed  Result of the callback
*
* @since   11.1
* @deprecated  4.0
*/
public function call()
{
// Get callback and arguments
$args     = func_get_args();
$callback = array_shift($args);

return $this->get($callback, $args);
}

/**
* Executes a cacheable callback if not found in cache else returns cached output and result
*
* @param   mixed    $callback    Callback or string shorthand for a callback
* @param   array    $args        Callback arguments
* @param   mixed    $id          Cache ID
* @param   boolean  $wrkarounds  True to use wrkarounds
* @param   array    $woptions    Workaround options
*
* @return  mixed  Result of the callback
*
* @since   11.1
*/
public function get($callback, $args = array(), $id = false, $wrkarounds = false, $woptions = array())
{
// Normalize callback
if (is_array($callback) || is_callable($callback))
{
// We have a standard php callback array -- do nothing
}
elseif (strstr($callback, '::'))
{
// This is shorthand for a static method callback classname::methodname
list ($class, $method) = explode('::', $callback);
$callback = array(trim($class), trim($method));
}
elseif (strstr($callback, '->'))
{
/*
* This is a really not so smart way of doing this... we provide this for backward compatability but this
* WILL! disappear in a future version.  If you are using this syntax change your code to use the standard
* PHP callback array syntax: <https://secure.php.net/callback>
*
* We have to use some silly global notation to pull it off and this is very unreliable
*/
list ($object_123456789, $method) = explode('->', $callback);
global $$object_123456789;
$callback = array($$object_123456789, $method);
}

if (!$id)
{
// Generate an ID
$id = $this->_makeId($callback, $args);
}

$data = $this->cache->get($id);

$locktest = (object) array('locked' => null, 'locklooped' => null);

if ($data === false)
{
$locktest = $this->cache->lock($id);

// If locklooped is true try to get the cached data again; it could exist now.
if ($locktest->locked === true && $locktest->locklooped === true)
{
$data = $this->cache->get($id);
}
}

if ($data !== false)
{
if ($locktest->locked === true)
{
$this->cache->unlock($id);
}

$data = unserialize(trim($data));

if ($wrkarounds)
{
echo Cache::getWorkarounds(
$data['output'],
array('mergehead' => isset($woptions['mergehead'])? $woptions['mergehead'] : 0)
);
}
else
{
echo $data['output'];
}

return $data['result'];
}

if (!is_array($args))
{
$referenceArgs = !empty($args)? array(&$args) : array();
}
else
{
$referenceArgs = &$args;
}

if ($locktest->locked === false && $locktest->locklooped === true)
{
// We can not store data because another process is in the middle of saving
return call_user_func_array($callback, $referenceArgs);
}

$coptions = array();

if (isset($woptions['modulemode']) && $woptions['modulemode'] == 1)
{
$document = \JFactory::getDocument();

if (method_exists($document, 'getHeadData'))
{
$coptions['headerbefore'] = $document->getHeadData();
}

$coptions['modulemode'] = 1;
}
else
{
$coptions['modulemode'] = 0;
}

$coptions['nopathway'] = isset($woptions['nopathway'])? $woptions['nopathway'] : 1;
$coptions['nohead']    = isset($woptions['nohead'])    ? $woptions['nohead'] : 1;
$coptions['nomodules'] = isset($woptions['nomodules'])? $woptions['nomodules'] : 1;

ob_start();
ob_implicit_flush(false);

$result = call_user_func_array($callback, $referenceArgs);
$output = ob_get_clean();

$data = array('result' => $result);

if ($wrkarounds)
{
$data['output'] = Cache::setWorkarounds($output, $coptions);
}
else
{
$data['output'] = $output;
}

// Store the cache data
$this->cache->store(serialize($data), $id);

if ($locktest->locked === true)
{
$this->cache->unlock($id);
}

echo $output;

return $result;
}

/**
* Generate a callback cache ID
*
* @param   callback  $callback  Callback to cache
* @param   array     $args      Arguments to the callback method to cache
*
* @return  string  MD5 Hash
*
* @since   11.1
*/
protected function _makeId($callback, $args)
{
if (is_array($callback) && is_object($callback[0]))
{
$vars        = get_object_vars($callback[0]);
$vars[]      = strtolower(get_class($callback[0]));
$callback[0] = $vars;
}

// A Closure can't be serialized, so to generate the ID we'll need to get its hash
if (is_a($callback, 'closure'))
{
$hash = spl_object_hash($callback);

return md5($hash . serialize(array($args)));
}

return md5(serialize(array($callback, $args)));
}
}
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #23 : 06.10.2018, 14:41:48 »
тогда покажи результаты поиска по всему сайту modIceMegamenuHelper
Желательно скриншот программы
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #24 : 06.10.2018, 14:48:02 »
Можете объяснить конкретнее что мне нужно сделать?
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #25 : 06.10.2018, 14:52:18 »
Можете объяснить конкретнее что мне нужно сделать?
Ладно! Есть у тебя модули мега меню?
Сделай скрин
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #26 : 06.10.2018, 15:01:46 »

*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #27 : 06.10.2018, 15:03:14 »
Покажи файл helper.php этого модуля
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
*

Kadimp

  • Захожу иногда
  • 180
  • 2 / 0
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #28 : 06.10.2018, 15:05:58 »
Код
<?php 
/**
 * IceMegaMenu Extension for Joomla 3.0 By IceTheme
 *
 *
 * [member=126442]copyright[/member] Copyright (C) 2008 - 2012 IceTheme.com. All rights reserved.
 * @license GNU General Public License version 2
 *
 * @Website http://www.icetheme.com/Joomla-Extensions/icemegamenu.html
 * [member=200179]Support[/member] http://www.icetheme.com/Forums/IceMegaMenu/
 *
 */
 
 
/* no direct access*/
defined('_JEXEC') or die('Restricted access');


require_once JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php';

jimport('joomla.base.tree');
jimport('joomla.utilities.simplexml');
require_once("libs/menucore.php");

class modIceMegamenuHelper
{

var $_params = null;
var $moduleid = 0;
var $_module = null;

public function __construct($module = null, $params = array())
{
if(!empty($module))
{
$this->_module = $module;
$this->moduleid = $module->id;
$this->loadMediaFiles($params, $module);
}
$this->_params = $params;
}

function buildXML($params)
{
$menu = new IceMenuTree($params);
$items = JFactory::getApplication()->getMenu();
        $start  = $params->get('startLevel');
        $end    = $params->get('endLevel');
        $sChild = $params->get('showAllChildren');         
       
        if($end<$start && $end!=0){ return ""; }
           
        if(!$sChild){ $end = $start;} 
         
// Get Menu Items
$rows = $items->getItems('menutype', $params->get('menutype'));
        foreach($rows as $key=>$val)
        {             
            if(!(($end!=0 && $rows[$key]->level>=$start && $rows[$key]->level<=$end) ||($end==0 && $rows[$key]->level>=$start)))
            {
                unset($rows[$key]);
            }
        }         
$maxdepth = $params->get('maxdepth',10);

// Build Menu Tree root down(orphan proof - child might have lower id than parent)
$user = &JFactory::getUser();
$ids = array();
$ids[1] = true;
$last = null;
$unresolved = array();

// pop the first item until the array is empty if there is any item
if(is_array($rows))
{
while(count($rows) && !is_null($row = array_shift($rows)))
{
if(array_key_exists($row->parent_id, $ids))
{
$row->ionly = $params->get('menu_images_link');
$menu->addNode($params, $row);
// record loaded parents
$ids[$row->id] = true;
}
else
{
// no parent yet so push item to back of list
// SAM: But if the key isn't in the list and we dont _add_ this is infinite, so check the unresolved queue
if(!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth)
{
array_push($rows, $row);
// so let us do max $maxdepth passes
// TODO: Put a time check in this loop in case we get too close to the PHP timeout
if(!isset($unresolved[$row->id])) $unresolved[$row->id] = 1;
else $unresolved[$row->id]++;
}
}
}
}
return $menu->toXML();
}

function &getXML($type, &$params, $decorator)
{
static $xmls;

if(!isset($xmls[$type]))
{
$cache = &JFactory::getCache('mod_icemegamenu');
$string = $cache->call(array('modIceMegamenuHelper', 'buildXML'), $params);
$xmls[$type] = $string;
}
// Get document
require_once(JPATH_BASE.DS."modules".DS."mod_icemegamenu".DS."libs".DS."simplexml.php");
$xml = new JSimpleXML;
$xml->loadString($xmls[$type]);
$doc = &$xml->document;
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$start = $params->get('startLevel');
$end = $params->get('endLevel');
$sChild = $params->get('showAllChildren');
$path = array();

// Get subtree
if($doc && is_callable($decorator))
{
$doc->map($decorator, array('end'=>$end, 'children'=>$sChild));
}
return $doc;
}

function render(&$params, $callback)
{
switch($params->get('menu_style', 'list'))
{
case 'list_flat' :
break;

case 'horiz_flat' :
break;

case 'vert_indent' :
break;

default :
// Include the new menu class
$xml = modIceMegamenuHelper::getXML($params->get('menutype'), $params, $callback);
if($xml)
{
$class = $params->get('class_sfx');
$xml->addAttribute('class', 'icemegamenu'.$class);

if($tagId = $params->get('tag_id'))
{
$xml->addAttribute('id', $tagId);
}
$result = JFilterOutput::ampReplace($xml->toString((bool)$params->get('show_whitespace')));
$result = str_replace(array('&gt;','&lt;','&quot;'), array('>','<','"'), $result);
$result = str_replace(array('<ul/>', '<ul />'), '', $result);
echo $result;
}
break;
}
}

/**
* check K2 Existed ?
*/
public static function isK2Existed()
{
return is_file(JPATH_SITE.DS.  "components" . DS . "com_k2" . DS . "k2.php");
}
/**
*  check the folder is existed, if not make a directory and set permission is 755
*
*
* @param array $path
* [member=16271]access[/member] public,
* @return boolean.
*/
public static function makeDir($path)
{
$folders = explode('/', ($path));
$tmppath =  JPATH_SITE.DS.'images'.DS.'icethumbs'.DS;

if(!file_exists($tmppath))
{
JFolder::create($tmppath, 0755);
}
for($i = 0; $i < count($folders) - 1; $i ++)
{
if(! file_exists($tmppath . $folders [$i]) && ! JFolder::create($tmppath . $folders [$i], 0755))
{
return false;
}
$tmppath = $tmppath . $folders [$i] . DS;
}
return true;
}
/**
*  check the folder is existed, if not make a directory and set permission is 755
*
*
* @param array $path
* [member=16271]access[/member] public,
* @return boolean.
*/
public static function renderThumb($path, $width=100, $height=100, $title='', $isThumb=true)
{

if($isThumb&& $path)
{
$path = str_replace(JURI::base(), '', $path);
$imagSource = JPATH_SITE.DS. str_replace('/', DS,  $path);

if(file_exists($imagSource))
{
$path =  $width."x".$height.'/'.$path;
$thumbPath = JPATH_SITE.DS.'images'.DS.'icethumbs'.DS. str_replace('/', DS,  $path);

if(!file_exists($thumbPath))
{
$thumb = PhpThumbFactory::create($imagSource); 
if(!self::makeDir($path))
{
return '';
}
$thumb->adaptiveResize($width, $height);
$thumb->save($thumbPath);
}
$path = JURI::base().'images/icethumbs/'.$path;
}
}
return $path;
}
/**
* Load Modules Joomla By position's name
*/
public function loadModulesByPosition($position='')
{
$modules = JModuleHelper::getModules($position);
if($modules)
{
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$output='';
foreach($modules  as $module)
{
$output .= '<div class="lof-module">'.$renderer->render($module, array('style' => 'raw')).'</div>';
}
return $output;
}
return ;
}
/**
* load CSS - javascript file.
*
* @param JParameter $params;
* @param JModule $module
* @return void.
*/
public function loadMediaFiles($params, $module)
{
global $app;
$app = JFactory::getApplication();
$theme_style = $params->get("theme_style","default");

$enable_bootrap = $params->get("enable_bootrap", 0);
$resizable_menu = $params->get("resizable_menu", 0);

$document = &JFactory::getDocument();
if($enable_bootrap == 1){
$document->addStyleSheet(JURI::base()."media/jui/css/bootstrap.css");
$document->addStyleSheet(JURI::base()."media/jui/css/bootstrap-responsive.css");
$document->addScript(JURI::base()."media/jui/js/bootstrap.min.js");
}

if(!defined("MOD_ICEMEGAMENU"))
{

$css = "templates/".$app->getTemplate()."/html/".$module->module."/css/".$theme_style."_icemegamenu.css";
$css2 = "templates/".$app->getTemplate()."/html/".$module->module."/css/".$theme_style."_icemegamenu-ie.css";
if($resizable_menu == 1){
$css3 = "templates/".$app->getTemplate()."/html/".$module->module."/css/".$theme_style."_icemegamenu-reponsive.css";
}
if(is_file($css)) {
$document->addStyleSheet($css);
} else {
$css = JURI::base().'modules/'.$module->module.'/themes/'.$params->get('theme_style','default').'/css/'.$theme_style.'_icemegamenu.css';
$document->addStyleSheet($css);
}
if(is_file($css3)) {
$document->addStyleSheet($css3);
} else {
if($resizable_menu == 1){
$css3 = JURI::base().'modules/'.$module->module.'/themes/'.$params->get('theme_style','default').'/css/'.$theme_style.'_icemegamenu-reponsive.css';
}
$document->addStyleSheet($css3);
}
define("MOD_ICEMEGAMENU", 1);
}

}

/**
* get a subtring with the max length setting.
*
* @param string $text;
* @param int $length limit characters showing;
* @param string $replacer;
* @return tring;
*/
public static function substring($text, $length = 100, $isStripedTags=true,  $replacer='...')
{
$string = $isStripedTags? strip_tags($text):$text;
return JString::strlen($string) > $length ? JString::substr($string, 0, $length).$replacer: $string;
}
}

if(!defined('modIceMegaMenuXMLCallbackDefined'))
{
function modIceMegaMenuXMLCallbackDefinedXMLCallback(&$node, $args)
{
$user = &JFactory::getUser();
$menu = &JSite::getMenu();
$active = $menu->getActive();
$path = isset($active)? array_reverse($active->tree) : null;

if(($args['end']) &&($node->attributes('level') >= $args['end']))
{
$children = $node->children();
foreach($node->children() as $child)
{
if($child->name() == 'ul')
{
$node->removeChild($child);
}
}
}

if($node->name() == 'ul')
{
foreach($node->children() as $child)
{
if($child->attributes('access') > $user->get('aid', 0))
{
$node->removeChild($child);
}
}
}

if(($node->name() == 'li') && isset($node->ul))
{
$node->addAttribute('class', 'parent');
}

if(isset($path) &&(in_array($node->attributes('id'), $path) || in_array($node->attributes('rel'), $path)))
{
if($node->attributes('class'))
{
$node->addAttribute('class', $node->attributes('class').' active');
}
else
{
$node->addAttribute('class', 'active');
}
}
else
{
if(isset($args['children']) && !$args['children'])
{
$children = $node->children();
foreach($node->children() as $child)
{
if($child->name() == 'ul')
{
$node->removeChild($child);
}
}
}
}

if(($node->name() == 'li') &&($id = $node->attributes('id')))
{
if($node->attributes('class'))
{
$node->addAttribute('class', $node->attributes('class').' item'.$id);
}
else
{
$node->addAttribute('class', 'item'.$id);
}
}

if(isset($path) && $node->attributes('id') == $path[0])
{
$node->addAttribute('id', 'current');
}
else
{
$node->removeAttribute('id');
}
$node->removeAttribute('rel');
$node->removeAttribute('level');
$node->removeAttribute('access');
}
define('modIceMegaMenuXMLCallbackDefined', true);
}
?>
*

NewUsers

  • Живу я здесь
  • 2307
  • 214 / 0
  • +375 (25) 627-16-99 (WhatsApp, Telegram)
Re: Ошибка: 0 - Using $this when not in object context
« Ответ #29 : 06.10.2018, 15:09:05 »
Код: php
static function buildXML($params)
Занимаюсь создание расширений для Joomla 3.10.x и 4.2.x | Доработка и настройка сайтов. Занимаюсь создание Интернет магазинов с нуля на собственном компоненте + оптимизация загрузки страницы (после предоставляю техподдержку).
Работа с DOM деревом на PHP
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Прошу помощи. Ошибка при обновлении на Joomla 4

Автор wmsonic

Ответов: 1
Просмотров: 773
Последний ответ 29.10.2023, 22:07:23
от Kukush
Выходит ошибка в админской панели

Автор daymarus

Ответов: 0
Просмотров: 1388
Последний ответ 10.08.2023, 12:43:43
от daymarus
При обновлении ошибка 403 Forbidden Request forbidden by administrative rules

Автор THeCMeX

Ответов: 18
Просмотров: 2121
Последний ответ 14.07.2023, 17:13:19
от art22
Ошибка при обновлении с 3.10.10. до 4.х

Автор svd2014

Ответов: 1
Просмотров: 1414
Последний ответ 13.02.2023, 19:53:08
от weser
Ошибка libraries/joomla/session/handler/native.php

Автор rezchik

Ответов: 2
Просмотров: 852
Последний ответ 17.01.2023, 22:02:31
от rezchik