За последние 24 часа нас посетили 17672 программиста и 1721 робот. Сейчас ищут 807 программистов ...

ошибка php7

Тема в разделе "Сделайте за меня", создана пользователем wolope, 27 ноя 2017.

  1. wolope

    wolope Новичок

    С нами с:
    27 ноя 2017
    Сообщения:
    1
    Симпатии:
    0
    Здравствуйте переходим на php 7. Вылазит ошибка. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgSystemJAPopup has a deprecated constructor. Как исправить?

    PHP:
    1. <?php
    2. /**
    3. * ------------------------------------------------------------------------
    4. * JA Popup Plugin for J25 & J32
    5. * ------------------------------------------------------------------------
    6. * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
    7. * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
    8. * Author: J.O.O.M Solutions Co., Ltd
    9. * Websites: http://www.joomlart.com - http://www.joomlancers.com
    10. * ------------------------------------------------------------------------
    11. */
    12.  
    13. defined('_JEXEC') or die();
    14. jimport('joomla.plugin.plugin');
    15. jimport('joomla.application.module.helper');
    16. // Import library dependencies
    17. jimport('joomla.event.plugin');
    18. jimport('joomla.filesystem.file');
    19. jimport('joomla.filesystem.folder');
    20.  
    21. /**
    22. * JAPopup Content Plugin
    23. *
    24. * @package        Joomla
    25. * @subpackage    Content
    26. * @since         1.7
    27. */
    28. class plgSystemJAPopup extends JPlugin
    29. {
    30.  
    31.     /** @var object $_modalObject  */
    32.     protected $_params;
    33.     protected $_includeScripts = array();
    34.  
    35.  
    36.     /**
    37.      * Constructor
    38.      *
    39.      * For PHP 5 compatability we must not use the __constructor as a constructor for plugins
    40.      * because func_get_args ( void ) returns a copy of all passed arguments, NOT references.
    41.      * This causes problems with cross-referencing necessary for the observer design pattern.
    42.      *
    43.      * @param    object    $subject The object to observe
    44.      */
    45.      function plgSystemJAPopup(&$subject)
    46. //      function __construct();
    47.     {
    48.        parent::__construct($subject);
    49.  
    50.         // load plugin parameters
    51.         $this->_plugin = JPluginHelper::getPlugin('system', 'japopup');
    52.         $this->_params = new JRegistry();
    53.         $this->_params->loadString($this->_plugin->params);
    54.  
    55.  
    56.         // Require library for each Popup type
    57.         require_once (dirname(__FILE__) . '/popupHelper.php');
    58.     }
    59.  
    60.     /**
    61.      *
    62.      * Process data when after render
    63.      */
    64.     function onAfterRender()
    65.     {
    66.         // Return if page is not html
    67.         $app = JFactory::getApplication();
    68.  
    69.         if ($app->isAdmin()) {
    70.             return;
    71.         }
    72.  
    73.         if (!isset($this->_plugin))
    74.             return;
    75.  
    76.         $body = JResponse::getBody();
    77.        
    78.  
    79.         // Replace {japopup} tag by appropriate content to show popup
    80.         $pattern = '#\{japopup([^}]*)\}([\s\S]*?)\{/japopup\}#i';
    81.         $body = preg_replace_callback($pattern, array($this, 'renderPopup'), $body);
    82.        
    83.         if(count($this->_includeScripts)) {
    84.             //var_dump($this->_includeScripts);
    85.             $script = '';
    86.             $jquery = 0;
    87.             foreach ($this->_includeScripts as $resouces) {
    88.                 foreach ($resouces as $link) {
    89.                     if($link == '<!--jquery-->') {
    90.                         $jquery = 1;
    91.                     } else {
    92.                         $script .= $link . "\n";
    93.                     }
    94.                 }
    95.             }
    96.             if($jquery) {
    97.                 $pattern = '/(^|\/)jquery([-_]*\d+(\.\d+)+)?(\.min)?\.js/i';//is jquery core
    98.                 if(!preg_match($pattern, $body)) {
    99.                    
    100.                     $base = JURI::base() . 'plugins/system/japopup/asset/jquery/';
    101.                     $jqueryScript = '
    102.                        <script type="text/javascript" src="' . $base . 'jquery.min.js"></script>
    103.                        <script type="text/javascript" src="' . $base . 'jquery-noconflict.js"></script>
    104.                        ';
    105.                     $script = $jqueryScript . $script;
    106.                 }
    107.             }
    108.             $body = str_replace('</head>', $script . "\n</head>", $body);
    109.         }
    110.  
    111.         if ($body) {
    112.             JResponse::setBody($body);
    113.         }
    114.         return true;
    115.     }
    116.    
    117.     /**
    118.      * Get an instance of Popup class depend on given popup type
    119.      *
    120.      * @param string $ptype - Popup type
    121.      */
    122. function getPopupModal($ptype) {
    123.         static $instances = array();
    124.         if(!isset($instances[$ptype]) || !$instances[$ptype]) {
    125.             $file = dirname(__FILE__) . '/' . $ptype . '/' . $ptype . '.php';
    126.             if (JFile::exists($file)) {
    127.                 include_once($file);
    128.                
    129.                 $cls = $ptype . "Class";
    130.                 if(class_exists($cls)) {
    131.                     $instances[$ptype] = new $cls($this->_params);
    132.                 }
    133.             }
    134.         }
    135.         return @$instances[$ptype];
    136.     }
    137.    
    138.     /**
    139.      * Parse user config
    140.      * @param string $params
    141.      * @return array
    142.      */
    143. function parseParams($params)
    144.     {
    145.         $params = html_entity_decode($params, ENT_QUOTES);
    146.         $regex = "/([a-zA-Z0-9_-]+)\s*=\s*('([^']*)'|\"([^\"]*)\"|([^\s]*))/";
    147.         preg_match_all($regex, $params, $matches);
    148.  
    149.         $arr = array();
    150.         if (count($matches)) {
    151.             $arr = array();
    152.             for ($i = 0; $i < count($matches[1]); $i++) {
    153.                 $key = $matches[1][$i];
    154.                 $val = $matches[3][$i] ? $matches[3][$i] : ($matches[4][$i] ? $matches[4][$i] : $matches[5][$i]);
    155.                 $arr[$key] = $val;
    156.             }
    157.         }
    158.         return $arr;
    159.     }
    160.    
    161.     public function renderPopup($matches) {
    162.         $params = $this->parseParams($matches[1]);
    163.         $content = $matches[2];
    164.        
    165.         //group
    166.         if(!isset($params['group'])) {
    167.             $params['group'] = 'popupgroup';
    168.         }
    169.        
    170.         $modal = isset($params['modal']) ? $params['modal'] : $this->_params->get("group1", "fancybox");
    171.         $obj = $this->getPopupModal($modal);
    172.         if($obj) {
    173.             $content = $obj->getContent($params, $content);
    174.             $this->_includeScripts[$modal] = $obj->getHeaderLibrary();
    175.             return $content;
    176.         } else {
    177.             return $matches[0];
    178.         }
    179.     }
    180. }
     
  2. igordata

    igordata Суперстар
    Команда форума Модератор

    С нами с:
    18 мар 2010
    Сообщения:
    32.408
    Симпатии:
    1.768
    доброе утро
     
  3. Sail

    Sail Старожил

    С нами с:
    1 ноя 2016
    Сообщения:
    1.593
    Симпатии:
    362
    @wolope, просто объявите конструктор конструктором, а не методом с идентичным названию класса именем.
     
    Maputo нравится это.
  4. MouseZver

    MouseZver Суперстар

    С нами с:
    1 апр 2013
    Сообщения:
    7.818
    Симпатии:
    1.333
    Адрес:
    Лень
    Author: J.O.O.M Solutions Co., Ltd GovnoCode (c)