File manager - Edit - /home/jardides/www/Jardi-design/j37/plugins/system/pagebuilderck/pagebuilderck.php
Back
<?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.plugin.plugin'); include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/defines.php'; //include_once JPATH_ROOT . '/components/com_pagebuilderck/models/page.php'; class plgSystemPagebuilderck extends JPlugin { public $pluginPath; /* * Constructor */ function __construct(&$subject, $config) { $this->pluginPath = '/plugins/system/pagebuilderck'; parent :: __construct($subject, $config); } /** * @param JForm The form to be altered. * @param array The associated data for the form. * @return boolean */ public function onContentPrepareForm($form, $data) { if ($form->getName() != 'com_content.article') return; $conf = JFactory::getConfig(); $app = JFactory::getApplication(); $input = $app->input; // save the default editor value $conf->set('pagebuilderck_replaced_editor', $conf->get('editor')); // tells the system that page builder ck editor is allowed here for the editor button $conf->set('pagebuilderck_allowed', '1'); // get the language $this->loadLanguage(); // load the additional options in the module JForm::addFormPath(JPATH_SITE . $this->pluginPath . '/params'); $form->loadFile('pagebuilderck_article_params', false); // on page load, force the editor to switch on page builder if needed if (count($data)) { // get article params // make JObject-Array check because of issue in J!3.7 if (method_exists($data,'get')) { $attribs = $data->get('attribs'); } else if (isset($data['attribs'])) { $attribs = $data['attribs']; } // on front end the params are not array, so we must do it yourself if (! is_array($attribs)) { $attribs = json_decode($attribs, true); } // if the user has switched to the pbck editor if ($input->get('pbck') == '1') { $attribs['pagebuilderck_editor'] = '1'; // set article params // make JObject-Array check because of issue in J!3.7 if (method_exists($data,'get')) { $data->set('attribs', $attribs); } else if (isset($data['attribs'])) { $data['attribs'] = $attribs; } $conf->set('editor', 'none'); } // if the article has already been saved with pbck if (isset($attribs['pagebuilderck_editor']) && $attribs['pagebuilderck_editor'] == '1') { $conf->set('editor', 'none'); $input->set('pbck', '1'); } // if (isset($data->introtext)) { // $data->introtext = str_replace("|URIROOT|", JUri::root(true), $data->introtext); // } } } /* * Look for the tag for replacement * */ // public function onAfterRender() { public function onContentPrepare($context, &$article, &$params, $page = 0) { // if ($context == 'mod_pagebuilderck.content' // || $context == 'com_pagebuilderck.page') return; $app = JFactory::getApplication(); // get the page code $body = $article->text; // test if the page is integrated into the article if (stristr($article->text, "class=\"rowck") && $app->isSite() && $context != 'mod_pagebuilderck.content' && $context != 'com_pagebuilderck.page' ) { // if we call a page inside the interface using tag if (stristr($article->text, "{pagebuilderck")) { $this->callAssets(); // look for the tags and replace $regex = "#{pagebuilderck(.*?)}#s"; // masque de recherche pour le tag $body = preg_replace_callback($regex, array($this, 'callPageFromTag'), $body); $article->text = $body; } include_once JPATH_ROOT . '/components/com_pagebuilderck/models/page.php'; $this->callAssets(); $model = JModelLegacy::getInstance('Page', 'PagebuilderckModel'); $model->parseHtml($article->text); $article->text = '<div class="pagebuilderck">' . $article->text . '</div>'; } // test if the tag if called from a normal article, if not then return directly else if (stristr($article->text, "{pagebuilderck")) { $this->callAssets(); // look for the tags and replace $regex = "#{pagebuilderck(.*?)}#s"; // masque de recherche pour le tag $body = preg_replace_callback($regex, array($this, 'callPageFromTag'), $body); $article->text = $body; } return; } /* * Replace the tag by the page html * * @matches Array of found tags * * return string the html code of the page to load in the final body */ private function callPageFromTag($matches) { if (isset($matches[1])) { $id = (int)trim($matches[1]); } else { return false; } $html = $this->getPageHtml($id); /*if ($html) { $this->callAssets(); }*/ return '<div class="pagebuilderck pagebuilderck' . $id . '">' . $html . '</div>'; } /* * Get the page html from the component * * @id int the page ID * * return string the html code of the page */ private function getPageHtml($id) { include_once JPATH_ROOT . '/components/com_pagebuilderck/models/page.php'; $model = JModelLegacy::getInstance('Page', 'PagebuilderckModel'); $page = $model->getItem($id); if (isset($page->htmlcode) && $page->htmlcode) { return $page->htmlcode; } return ''; } private function callAssets() { $doc = JFactory::getDocument(); $doc->addScript(JUri::root(true) . '/media/jui/js/jquery.min.js'); $doc->addStyleSheet(JUri::root(true) . '/components/com_pagebuilderck/assets/pagebuilderck.css'); $doc->addStyleSheet(JUri::root(true) . '/components/com_pagebuilderck/assets/font-awesome.min.css'); $doc->addScript(JUri::root(true) . '/components/com_pagebuilderck/assets/jquery-uick.js'); $doc->addScript(JUri::root(true) . '/components/com_pagebuilderck/assets/pagebuilderck.js'); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings