public function process($content) { preg_match_all($this->_shortcodeSyntax, $content, $out); if (count($out[0])) { $elemenPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/element.php'; $childPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/child.php'; $parentPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/parent.php'; if (file_exists($elemenPath) && file_exists($childPath) && file_exists($parentPath)) { include_once $elemenPath; include_once $parentPath; include_once $childPath; // Autoload all helper classes. JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder', 'JSNPagebuilder'); // Autoload all shortcode JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode', 'JSNPBShortcode'); // Backward compatible for all JSN PageBuilder version =< 1.0.4 if (is_dir(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements')) { JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/', 'JSNPBShortcode'); } else { JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode'); } global $JSNPbElements; $pcontent = ''; $this->addScript(); $JSNPbElements = new JSNPagebuilderHelpersElements(); $objJSNPagebuilderHelpersBuilder = new JSNPagebuilderHelpersBuilder(); $objJSNPagebuilderHelpersShortcode = new JSNPagebuilderHelpersShortcode(); $content = $objJSNPagebuilderHelpersShortcode::removeAutop($content); $pcontent .= $objJSNPagebuilderHelpersBuilder->generateShortCode($content); $content = '<div id="jsnpa-pagebuilder-form-container" class="jsn-layout">' . $pcontent . '</div>'; } } return $content; }
public function onJSNPAPBReplaceContent($content) { //Check if the component is not installed. $isInstalledComponent = $this->isInstalledComponent(); if ($isInstalledComponent != null && $isInstalledComponent == '1') { $apiPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/joomlashine/api/api.php'; if (file_exists($apiPath)) { include_once $apiPath; $objJSNPageBuilderAPI = new JSNPageBuilderAPI(); $content = $objJSNPageBuilderAPI->process($content); } else { //Backward compatible for JSN PageBuilder < 1.0.5 preg_match_all('#\\[(\\[?)(pb_row)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)#', $content, $out); if (count($out[0])) { $elemenPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/element.php'; $childPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/child.php'; $parentPath = JPATH_ROOT . '/administrator/components/com_pagebuilder/libraries/innotheme/shortcode/parent.php'; if (file_exists($elemenPath) && file_exists($childPath)) { include_once $elemenPath; if (file_exists($parentPath)) { include_once $parentPath; } include_once $childPath; // Autoload all helper classes. JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder', 'JSNPagebuilder'); // Autoload all shortcode JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode', 'JSNPBShortcode'); // Backward compatible for all JSN PageBuilder version =< 1.0.4 if (is_dir(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements')) { JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/', 'JSNPBShortcode'); } else { JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode'); } global $JSNPbElements; $pcontent = ''; $this->addScript(); $JSNPbElements = new JSNPagebuilderHelpersElements(); $objJSNPagebuilderHelpersBuilder = new JSNPagebuilderHelpersBuilder(); $objJSNPagebuilderHelpersShortcode = new JSNPagebuilderHelpersShortcode(); $content = $objJSNPagebuilderHelpersShortcode::removeAutop($content); $pcontent .= $objJSNPagebuilderHelpersBuilder->generateShortCode($content); $content = '<div id="jsnpa-pagebuilder-form-container" class="jsn-layout">' . $pcontent . '</div>'; } } } } return $content; }
*/ public static function get_path($file) { foreach (array_reverse(self::$paths) as $base => $prefix) { if (@is_file($base . '/' . $file)) { return $base . '/' . $file; } } return null; } } // Register class autoloader with PHP spl_autoload_register(array('JSN_Loader', 'load')); } // Register path to JSN Extension Framework's libraries JSN_Loader::register(dirname(__FILE__) . '/joomlashine'); /** * Manually import class file of JSN Framework. * * Besides auto-loader, JSN Framework provides <b>jsnimport</b> function * for manually load class declaration file using dot syntax as following: * * <dl> * <dt>jsnimport('joomlashine.config.helper');</dt> * <dd>will load the following file: <q>libraries/joomlashine/config/helper.php</q></dd> * <dt>jsnimport('somevendor.somelib.someclass');</dt> * <dd>will load the following file:<q>libraries/somevendor/somelib/someclass.php</q></dd> * </dl> * * This function also supports loading class file from component directory * instead of framework directory. For example, in the administration section
require_once dirname(__FILE__) . '/libraries/joomlashine/base/controller.php'; // Initialize common assets require_once JPATH_COMPONENT_ADMINISTRATOR . '/bootstrap.php'; // Check if all dependency is installed require_once JPATH_COMPONENT_ADMINISTRATOR . '/dependency.php'; // Require base shorcode element // TODO: under included files will be packed in a loader class require_once dirname(__FILE__) . '/libraries/innotheme/shortcode/element.php'; require_once dirname(__FILE__) . '/libraries/innotheme/shortcode/parent.php'; require_once dirname(__FILE__) . '/libraries/innotheme/shortcode/child.php'; // Check if JoomlaShine extension framework is exists? if ($framework->extension_id) { // Autoload all helper classes. JSN_Loader::register(dirname(__FILE__), 'JSNPagebuilder'); // Autoload all shortcode JSN_Loader::register(dirname(__FILE__) . '/helpers/shortcode', 'JSNPBShortcode'); //JSN_Loader::register(JPATH_ROOT . '/plugins/pagebuilder/' , 'JSNPBShortcode'); //JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/' , 'JSNPBShortcode'); JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode'); // Store all PageBuilder's shortcode into an object. global $JSNPbElements; $JSNPbElements = new JSNPagebuilderHelpersElements(); } if (strpos('installer + update + upgrade', $input->getCmd('view')) !== false or JSNVersion::isJoomlaCompatible(JSN_PAGEBUILDER_REQUIRED_JOOMLA_VER)) { // Get the appropriate controller $controller = JSNBaseController::getInstance('JSNPagebuilder'); // Perform the request task $controller->execute($input->getCmd('task')); // Redirect if set by the controller $controller->redirect(); }
/** * This method is to load neccessary access * for PageBuilder need * * @return void */ public function onBeforeRender() { // Check if JoomlaShine extension framework is enabled? $framework = JTable::getInstance('Extension'); $framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system')); // Do nothing if JSN Extension framework not found. if (!$framework->extension_id) { return; } $app = JFactory::getApplication(); $tpl = $app->input->getInt('tp', 0); if ($app->isAdmin() || $tpl) { return; } // Get requested component, view and task $option = $app->input->getCmd('option', ''); $view = $app->input->getCmd('view', ''); $layout = $app->input->getCmd('layout', ''); $user = JFactory::getUser(); if ($app->isSite() && $option == 'com_content' && $view == 'form' && $layout == 'edit' && $user->get('id') > 0) { return; } $doc = JFactory::getDocument(); if (get_class($doc) != "JDocumentHTML") { return; } if ($app->isSite() && $option == 'com_k2' && $view == 'item' && $app->input->getInt('id', 0)) { if (file_exists(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php')) { if (class_exists('K2HelperUtilities')) { include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/shortcode.php'; $shortCodeRegex = JSNPagebuilderHelpersShortcode::getShortcodeRegex(); JModelLegacy::addIncludePath(JPATH_ROOT . '/components/com_k2/models'); $K2ModelItem = JModelLegacy::getInstance('k2modelitem'); $k2Item = $K2ModelItem->getData(); if (count($k2Item)) { $metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $k2Item->introtext . ' ' . $k2Item->fulltext); $metaDescItem = strip_tags($metaDescItem); $k2params = K2HelperUtilities::getParams('com_k2'); $metaDescItem = self::removeShortCode($metaDescItem, $shortCodeRegex); $metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $k2params->get('metaDescLimit', 150)); if ($doc->getMetaData('og:description') != null) { $doc->setMetaData('og:description', $metaDescItem); } if ($doc->getDescription() != '') { $doc->setDescription($metaDescItem); } } } } } // Get PageBuilder configuration. $params = JSNConfigHelper::get('com_pagebuilder'); // Check if it's enabled or not. $isEnabled = $params->get('enable_pagebuilder', 1); // Do nothing if PageBuilder not enabled; if (!$isEnabled) { } // Register autoloaded classes JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers', 'JSNPagebuilderHelpers'); JSN_Loader::register(JSNPB_ADMIN_ROOT . '/helpers/shortcode', 'JSNPBShortcode'); //JSN_Loader::register(JPATH_ROOT . '/plugins/pagebuilder/' , 'JSNPBShortcode'); //JSN_Loader::register(JPATH_ROOT . '/administrator/components/com_pagebuilder/elements/' , 'JSNPBShortcode'); JSN_Loader::register(JPATH_ROOT . '/plugins/jsnpagebuilder/defaultelements/', 'JSNPBShortcode'); //load ElementAssets self::loadElementAssets(); /* * Move all css files of PageBuilder * to the end of css list * */ $data = $doc->getHeadData(); $styleSheetList = $data['styleSheets']; $_tmpList = array(); if (count($styleSheetList)) { foreach ($styleSheetList as $cssUrl => $css) { // Check if the file belongs to PageBuilder if (strpos($cssUrl, 'plugins/pagebuilder/') !== false || strpos($cssUrl, 'com_pagebuilder') !== false) { $_tmpList[$cssUrl] = $css; unset($styleSheetList[$cssUrl]); } } } $styleSheetList = array_merge($styleSheetList, $_tmpList); $data['styleSheets'] = $styleSheetList; $doc->setHeadData($data); }