Skip to content

Commit

Permalink
Merge pull request #34 from FrankReisenhofer/main
Browse files Browse the repository at this point in the history
[Joomla 5] Solve 0 Class "JPlugin" not found error
  • Loading branch information
Tazzios committed Mar 2, 2024
2 parents f06d4d7 + fb93f93 commit a8a8c95
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions content_plugin/pdfviewer.php
Expand Up @@ -5,14 +5,17 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Version;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;


/**
* Plug-in to enable loading pdf files into content (e.g. articles)
* This uses the {pdfviewer} syntax
* Licensed under the GNU General Public License version 2 or later; see LICENSE.txt
*/
class PlgContentpdfviewer extends JPlugin

class PlgContentpdfviewer extends CMSPlugin
{
protected static $modules = array();

Expand Down Expand Up @@ -287,7 +290,7 @@ public function onContentPrepare($context, &$article, &$params, $page = 0)
$path= JPATH_ROOT . '/administrator/components/com_jdownloads';
if (file_exists( $path )) {
$jdownloadsid = trim($tagparameters['jdownloadsid']);
$filelink = JUri::base().'index.php?option=com_jdownloads&task=download.send&id='. $jdownloadsid ;
$filelink = Uri::base().'index.php?option=com_jdownloads&task=download.send&id='. $jdownloadsid ;
} else {
$showpdfpreview ='no';
$output = "jdownloads is not installed (anymore)";
Expand Down Expand Up @@ -344,18 +347,18 @@ function CreatePdfviewer($filelink,$pagereference,$pdfjsviewsettings,$height,$wi
// set Path to pdfjs viewer.html file and check if there is an override

//Set default path
$Path_pdfjs = JUri::base().'plugins/content/pdfviewer/assets/pdfjs/web/viewer.html' ;
$Path_pdfjs = Uri::base().'plugins/content/pdfviewer/assets/pdfjs/web/viewer.html' ;

// Get active template path from Joomla:
$app = JFactory::getApplication();
$path = JURI::base(true).'templates/'.$app->getTemplate().'/';
$app = Factory::getApplication();
$path = URI::base(true).'templates/'.$app->getTemplate().'/';

// determine override patch
$pdfjs_override = JPATH_ROOT .'/templates/'.$app->getTemplate(). '/html/plg_content_pdfviewer/assets/pdfjs/web/viewer.html';

//Check for override
if (file_exists($pdfjs_override)) {
$Path_pdfjs = JUri::base().'templates/'.$app->getTemplate(). '/html/plg_content_pdfviewer/assets/pdfjs/web/viewer.html';
$Path_pdfjs = Uri::base().'templates/'.$app->getTemplate(). '/html/plg_content_pdfviewer/assets/pdfjs/web/viewer.html';
}


Expand Down Expand Up @@ -433,7 +436,7 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) {
$files_uploaddir = $jdownloads_params->get( 'files_uploaddir' );

// get categorie path
$db = JFactory::getDbo();
$db = Factory::getDbo();
$db->setQuery("WITH RECURSIVE n AS
( SELECT id, parent_id, concat('/', title ,'/') AS path
FROM #__jdownloads_categories
Expand Down Expand Up @@ -548,7 +551,3 @@ function Createpdfimage($file_id,$pagenumber,$height,$width,$style,$linktext) {


}




0 comments on commit a8a8c95

Please sign in to comment.