%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/old/plugins/content/relatednews/ |
Upload File : |
<?php /** * @package Related News * @version 1.7.0 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL * @copyright (c) 2012 YouTech Company. All Rights Reserved. * @author YouTech Company http://www.smartaddons.com * */ defined('_JEXEC') or die; class plgContentRelatedNews extends JPlugin { /** * Plugin that loads content within content * * @param string The context of the content being passed to the plugin. * @param object The article object. Note $article->text is also available * @param object The article params * @param int The 'page' number */ public function onContentPrepare($context, &$article, &$params, $page=0) { // simple performance check to determine whether bot should process further $depends = $this->params->get('depends'); // var_dump($depends); // echo 'vao day'; if (!is_array($depends) || count($depends)==0 || !isset($article->catid) || !in_array($article->catid, $depends)){ return; } if ($context == 'com_content.article'){ // helper require_once dirname(__FILE__).'/core/helper.php'; // vars $article_id = $article->id; $category_id = $article->catid; // patterns $patterns = array(); $regex = "#{relatednews\s?(.*?)}#s"; preg_match_all($regex, $article->text, $matches); if (isset($matches[0]) && count($matches[0])){ foreach ($matches[0] as $i => $match) { $key = trim($matches[0][$i]); $val = trim($matches[1][$i]); $patterns[$key] = $val; } } // load template for each pattern $_load_templates = array(); if (count($patterns)){ foreach ($patterns as $replace => $_params) { $_params = $this->_parseParams($_params); $_params->set('catid', $category_id); $_params->def('template', 'default'); $items = RelatedNews::getList($_params); $patterns[$replace] = array($_params, $items); } } else { $this->params->set('catid', $category_id); $this->params->def('template', 'default'); $items = RelatedNews::getList($this->params); $patterns = array(); $patterns[] = array($this->params, $items); } // append template loaded to article content foreach ($patterns as $search => $vars){ $_params = $vars[0]; $items = $vars[1]; ob_start(); require $this->_getLayoutPath($_params->get('template')); $replace = ob_get_contents(); ob_end_clean(); if (is_string($search)){ $article->text = preg_replace("#$search#s", $replace, $article->text, 1); } else { $article->text .= $replace; } } } } private function _parseParams($_params){ $clone = clone($this->params); if (!empty($_params)){ $array = JUtility::parseAttributes($_params); count($array) && $clone->loadArray($array); // if (count($array)){ // foreach ($array as $param => $value){ // $clone->set($param, $value); // } // } } return $clone; } private function _getLayoutPath($tpl='default'){ $filename = $tpl . '.php'; $dirname = dirname(__FILE__).'/tmpl'; if (file_exists($dirname.'/'.$filename)){ return $dirname.'/'.$filename; } return $dirname.'/default.php'; } }