Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Помогите исправить ошибки php в плагине jautometa для joomla
Форумы портала PHP.SU » » Если скрипт не работает » Помогите исправить ошибки php в плагине jautometa для joomla

Страниц (1): [1]
 

1. 1-F7 - 31 Июля, 2016 - 15:50:58 - перейти к сообщению
Помогите исправить ошибки php в плагине jautometa для joomla:

Strict Standards: Only variables should be assigned by reference in /kunden/112919_55497/kuehn/plugi ns/content/jautometa/jautometa.p hp on line 25:

CODE (text):
скопировать код в буфер обмена
  1. $app =& JFactory::getApplication();


Strict Standards: Only variables should be assigned by reference in /kunden/112919_55497/kuehn/plugi ns/content/jautometa/jautometa.p hp on line 71

CODE (text):
скопировать код в буфер обмена
  1. $document =& JFactory::getDocument();


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /kunden/112919_55497/kuehn/plugi ns/content/jautometa/jautometa.p hp on line 101

CODE (text):
скопировать код в буфер обмена
  1. content = preg_replace($regex, '', $content);


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /kunden/112919_55497/kuehn/plugi ns/content/jautometa/jautometa.p hp on line 141

CODE (text):
скопировать код в буфер обмена
  1. $keyw = preg_replace($regex, '', $keyw);



Вот весь файл jautometa.php:

CODE (text):
скопировать код в буфер обмена
  1. <?php
  2. /**
  3. * @version              2.2 jAutoMeta.php 2013-08-01
  4. * @package              Joomla
  5. * @subpackage   jAutoMeta
  6. * @author               VMLab
  7. * @link                 http://www.vmlab.it/
  8. * @copyright    Copyright (C) 2012 - 2013 VMLab. All rights reserved.
  9. * @license              GNU/GPL
  10. * This plugin will automatically generate Meta Tags from your articles content.
  11. */
  12.  
  13. // no direct access
  14. defined( '_JEXEC' ) or die( 'Restricted access' );
  15.  
  16. jimport( 'joomla.plugin.plugin' );
  17.  
  18. class  plgContentJautometa extends JPlugin {
  19.  
  20.         public function __construct(&$subject, $config){
  21.                         parent::__construct($subject, $config);
  22.         }
  23.        
  24.         public function onContentPrepare($context, &$article, &$params, $page=0 ){
  25.                 $app =& JFactory::getApplication();
  26.         /* @var $app JApplication */
  27.  
  28.         if($app->isAdmin()) {
  29.             return;
  30.         }
  31.        
  32.         $doc     = JFactory::getDocument();
  33.         /* @var $doc JDocumentHtml */
  34.         $docType = $doc->getType();
  35.        
  36.         // Check document type
  37.         if(strcmp("html", $docType)!= 0){
  38.             return;
  39.         }
  40.                
  41.                 $currentOption = JRequest::getCmd("option");
  42.         $currentView = JRequest::getCmd("view");
  43.                        
  44.         if( $currentOption != "com_content" || $currentView != "article" || !isset($this->params)) {
  45.             return;            
  46.         }
  47.                
  48.                 if($article->id==""){return;}
  49.                
  50.                 if ($context = 'com_content.article') {
  51.                         $catsID = $this->params->get("category");
  52.                         if($catsID){
  53.                                 $catsID = '@,'.str_replace(' ','',$catsID).',';
  54.                                 $artcatID = ','.$article->catid.',';
  55.                                 $selectedcategory = strpos($catsID,$artcatID);
  56.                                 if($selectedcategory > 0){
  57.                                         $replacemeta = true;
  58.                                 }else{
  59.                                         $replacemeta = false;
  60.                                 }
  61.                         }else{
  62.                                 $replacemeta = true;
  63.                         }
  64.                        
  65.                         if($replacemeta){
  66.                                                                
  67.                                 $charset = $this->params->get("charset");
  68.                                 $length = $this->params->get("length");
  69.                                 $minlength = $this->params->get("minlength");
  70.                                 $count = $this->params->get("count");
  71.                                 $document =& JFactory::getDocument();
  72.                                
  73.                                 $description = $this->generateDescription($article->text,$charset);
  74.                                
  75.                                 $toKey = $description;
  76.                                
  77.                                 $description = rtrim(substr($description,0,$length));
  78.                                
  79.                                 $document->setMetaData('description', $description);
  80.                                
  81.                                 if($this->params->get("keywords") == "title")$generateKey = $article->title;
  82.                                 if($this->params->get("keywords") == "content")$generateKey = $toKey;
  83.                                 if($this->params->get("keywords") == "both")$generateKey = $article->title.' '.$toKey;
  84.                                                                
  85.                                 $keywords = $this->generateKeywords($generateKey,$minlength,$count,$charset);
  86.                                 $document->setMetaData('keywords', $keywords);
  87.                         }
  88.                 }
  89.         }
  90.                
  91.         public function generateDescription($content,$charset){
  92.                 $content = preg_replace( "'<script[^>]*>.*?</script>'si", '', $content );              
  93.                 $content = preg_replace( '/<!--.+?-->/', '', $content );
  94.                 $content = preg_replace( '/{.+?}/', '', $content );
  95.                 $content = strip_tags( $content );
  96.                 $content = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $content );
  97.                 $content = preg_replace('/<[^>]*>/', ' ', $content);
  98.                
  99.                 // Remove any email addresses
  100.                 $regex = '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex';
  101.                 $content = preg_replace($regex, '', $content);
  102.                
  103.                 // convert HTML entities to chars
  104.                 $content = html_entity_decode($content,ENT_QUOTES,$charset);
  105.  
  106.        
  107.                 $content = str_replace('"', '\'', $content); //Make sure all quotes play nice with meta.
  108.                                 $content = str_replace(array("\r\n", "\r", "\n", "\t"), " ", $content); //Change spaces to spaces
  109.                
  110.                 // remove any extra spaces
  111.                 while (strchr($content,"  ")) {
  112.                         $content = str_replace("  ", " ",$content);
  113.                 }
  114.                
  115.                 // general sentence tidyup
  116.                 for ($cnt = 1; $cnt < JString::strlen($content)-1; $cnt++) {
  117.                         // add a space after any full stops or comma's for readability
  118.                         // added as strip_tags was often leaving no spaces
  119.                         if ( ($content{$cnt} == '.') || (($content{$cnt} == ',') && !(is_numeric($content{$cnt+1})))) {
  120.                                 if ($content{$cnt+1} != ' ') {
  121.                                         $content = JString::substr_replace($content, ' ', $cnt + 1, 0);
  122.                                 }
  123.                         }
  124.                 }
  125.                
  126.                 return trim($content);
  127.        
  128.         }
  129.        
  130.         public function generateKeywords($keyw,$minlength,$count,$charset){
  131.                 $keyw = str_replace(array(",",".",";",":","!","(",")","?")," ",$keyw);
  132.                 $keyw = preg_replace( "'<script[^>]*>.*?</script>'si", '', $keyw );            
  133.                 $keyw = preg_replace( '/<!--.+?-->/', '', $keyw );
  134.                 $keyw = preg_replace( '/{.+?}/', '', $keyw );
  135.                 //$keyw = strip_tags( $keyw );
  136.                 $keyw = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $keyw );
  137.                 $keyw = preg_replace('/<[^>]*>/', ' ', $keyw);
  138.                
  139.                 // Remove any email addresses
  140.                 $regex = '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex';
  141.                 $keyw = preg_replace($regex, '', $keyw);
  142.                
  143.                 // convert HTML entities to chars
  144.                 $keyw = html_entity_decode($keyw,ENT_QUOTES,$charset);
  145.  
  146.                
  147.                 $keyw = str_replace('"', '\'', $keyw); //Make sure all quotes play nice with meta.
  148.                                 $keyw = str_replace(array("\r\n", "\r", "\n", "\t"), " ", $keyw); //Change spaces to spaces
  149.                
  150.                 // remove any extra spaces
  151.                 while (strchr($keyw,"  ")) {
  152.                         $keyw = str_replace("  ", " ",$keyw);
  153.                 }
  154.                        
  155.                 // general sentence tidyup
  156.                 for ($cnt = 1; $cnt < JString::strlen($keyw)-1; $cnt++) {
  157.                         // add a space after any full stops or comma's for readability
  158.                         // added as strip_tags was often leaving no spaces
  159.                         if ( ($keyw{$cnt} == '.') || (($keyw{$cnt} == ',') && !(is_numeric($keyw{$cnt+1})))) {
  160.                                 if ($keyw{$cnt+1} != ' ') {
  161.                                         $keyw = JString::substr_replace($keyw, ' ', $cnt + 1, 0);
  162.                                 }
  163.                         }
  164.                 }
  165.                
  166.                 $keyw = str_replace(" ", ",", trim($keyw));
  167.                
  168.                 $stickArray = explode(",", $keyw);
  169.                
  170.                 $keysArray = array_count_values($stickArray);
  171.                
  172.                 arsort($keysArray);
  173.                 $i = 1;
  174.                 $keywords = "";
  175.                 $gkeywords = "";
  176.                
  177.                 if (JString::strlen($keyw)>0) {
  178.                  foreach($keysArray as $word => $instances){
  179.                         if(JString::strlen(trim($word)) >= $minlength && is_string($word)){
  180.                         if($i > $count)
  181.                                 break;
  182.                                 if(in_array($word,$stickArray)) {
  183.                                 $gkeywords .= $word . ",";
  184.                                 $i++;
  185.                          }
  186.                         }
  187.                  }
  188.                 }
  189.                 $keywords = $gkeywords;
  190.                 $keywords = JString::rtrim($keywords, ",");
  191.                 return $keywords;
  192.         }
  193. }
  194. ?>


Заранее благодарен за помощь.
(Добавление)
Решил вопрос.

 

Powered by ExBB FM 1.0 RC1