/** * Generate html for PageBuilder layout. * * @return string */ public function html() { $helper = new JSNPagebuilderHelpersBuilder(); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/elements-lang.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/handle.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/shortcodesetting/settings-handler.js'); // Genrate pagebuilder element template. $helper->generateElementColumnTemplate(); $helper->generateElementRowTemplate(); $source_content = ''; $data = array(); $source_content = $_POST['form_data']; // Remove all p tags which auto added by the editor $source_content = JSNPagebuilderHelpersShortcode::removeAutop($source_content); $source_content = html_entity_decode($source_content, ENT_COMPAT, 'UTF-8'); $html[] = '<link rel="stylesheet" href="' . JSNPB_ADMIN_URL . '/assets/css/jsn-element-font.css' . '" type="text/css" />'; $html[] = '<link rel="stylesheet" href="' . JSNPB_ADMIN_URL . '/assets/css/pb-layout-font.css' . '" type="text/css" />'; $html[] = '<div id="form-container" class="jsn-layout jsn-section-content">'; if ($source_content) { //$shortcodeTags = $helper->getShortcodeTags(); $html[] = $helper->generateShortCode($source_content); } else { $html[] = $helper->getRowStructure(); } $html[] = '<a href="javascript:void(0);" id="jsn-add-container" class="jsn-add-more jsn-add-more-row"><i class="icon-plus"></i> Add Row </a>'; /** * Show thumbnail for default layouts */ $html[] = '<div class="row-fluid pb-layout-thumbs">'; $layouts = JSNPBShortcodeRow::$layouts; foreach ($layouts as $columns) { $columns_name = implode('x', $columns); $icon_class = implode('-', $columns); $data_columns = implode(',', $columns); $icon_class = 'pb-layout-' . $icon_class; $icon = '<i class="' . $icon_class . '"></i>'; $html[] = '<div class="thumb-wrapper" data-columns="' . $data_columns . '" title="' . $columns_name . '">' . $icon . '</div>'; } $html[] = '</div>'; $html[] = JSNHtmlGenerate::footer(array(), false); $html[] = '</div>'; $html[] = $helper->getAddShortcodesPopup(); if (defined("JSN_PAGEBUILDER_EDITION")) { if (strtolower(JSN_PAGEBUILDER_EDITION) == "free") { if (file_exists(JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php')) { include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php'; $pbTotal = JSNPagebuilderHelpersArticles::getCountArticleUsedPageBuilderFromPlugin(); if ($pbTotal >= 5 && !JFactory::getApplication()->input->getInt('article_id') && JFactory::getApplication()->input->getInt('is_com_modules') != 1) { $html = array(); $html[] = '<div class="jsn-bootstrap3"><div class="pb-element-container"><p class="jsn-bglabel">You have reached 5 pages limit of using JSN PageBuilder.</p><p style="font-size: 20px;text-align: center;color: #d3d3d3;">Please to upgrade <a target=\'_blank\' href=\'' . JSN_PAGEBUILDER_INFO_LINK . '\'>Pro version</a> or remove your old pages that used JSN PageBuilder.</p><div style="text-align: center"><a href="index.php?option=com_pagebuilder&view=upgrade" target="_blank" class="btn-primary btn-large btn"> Upgrade </a></div></div></div>'; } } } } print_r(implode("\n", $html)); exit; }
/** * Display the button * * @return */ function onDisplay($name) { $app = JFactory::getApplication(); if ($app->isSite()) { return; } include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php'; $listId = JSNPagebuilderHelpersArticles::getListArticleUedPagebuilderFromPlugin(); $pbTotal = JSNPagebuilderHelpersArticles::getCountArticleUsedPageBuilderFromPlugin(); JSNPagebuilderHelpersArticles::updateArticleUsedPageBuilderToPlugin(); //Check if JoomlaShine extension framework is enabled? global $id, $option, $framework, $conf, $supported_list, $params, $random_id; // Check if JoomlaShine extension framework is enabled? $framework = JTable::getInstance('Extension'); $framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system')); $isInstalledPbExtension = false; $option = JRequest::getVar('option'); $com_advancedmodules = JSNPagebuilderHelpersPagebuilder::checkComponentEnabled('com_advancedmodules') ? array('com_advancedmodules') : ''; $flexiContent = JSNPagebuilderHelpersPagebuilder::checkComponentEnabled('com_flexicontent') ? array('com_flexicontent') : ''; $supported_list = array('com_content', 'com_modules'); if ($com_advancedmodules != '') { $supported_list = array_merge($supported_list, $com_advancedmodules); } if ($flexiContent != '') { $supported_list = array_merge($supported_list, $flexiContent); } if (isset($params)) { if ($params->extension_support != '') { $supported_list = json_decode($params->extension_support); } } $installedPbExtensions = JSNPagebuilderHelpersExtensions::getPbExtensions(); if (count($installedPbExtensions)) { foreach ($installedPbExtensions as $installedPbExtension) { if ($option == "com_" . $installedPbExtension->element) { if (!$installedPbExtension->enabled) { $app->enqueueMessage(sprintf('Please enable the %s plugin before using. How to enable it, click <a href="%s" target="_blank">here</a>', 'JSN PageBuilder ' . strtoupper($installedPbExtension->element) . ' element', 'index.php?option=com_pagebuilder&view=configuration&s=maintainence&g=extensions'), 'warning'); return; } else { $isInstalledPbExtension = true; } break; } } } if ($isInstalledPbExtension) { if (!in_array($option, $supported_list)) { $app->enqueueMessage(sprintf('Please enable the JSN PageBuilder %s Extention Support before using. How to enable it, click <a href="%s" target="_blank">here</a>', strtoupper($installedPbExtension->element), 'index.php?option=com_pagebuilder&view=configuration&s=configuration&g=msgs'), 'warning'); return; } } if ($framework->extension_id && in_array($option, $supported_list)) { // Get PageBuilder configuration if (!in_array($option, $supported_list)) { $isInstalled = JSNPagebuilderHelpersExtensions::checkInstalledPlugin(str_replace('com_', '', $option)); if (!$isInstalled['isInstalled']) { return; } } // Check if it's enabled or not $isEnabled = $params->get('enable_pagebuilder', 1); if ($isEnabled) { $conf = JFactory::getConfig(); $editor = $conf->get('editor'); // Inlcude the entry js file. JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/joomlashine.noconflict.js'); JSNHtmlAsset::addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/jquery-ui/js/jquery-ui-1.10.3.custom.js'); JSNHtmlAsset::addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/jquery-livequery/jquery.livequery.min.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/builder-layout.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/joomlashine/js/jsn-modal.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/elements-lang.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/jquery.alphanumeric/jquery.alphanumeric.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/shortcodesetting/settings-handler.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/handle.js'); // Include supoported editor script switch ($editor) { case 'codemirror': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/codemirror.js'); break; case 'tinymce': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/tiny-mce.js'); break; case 'jce': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/jce.js'); break; case 'jckeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/jckeditor.js'); break; case 'ckeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/ckeditor.js'); break; case 'artofeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/artofeditor.js'); break; case 'arkeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/arkeditor.js'); break; default: JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/default.js'); break; } // Generate random string to assign to switcher button $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/entry.js'); $js = "\n\t\t\t\t\tvar Pb_Ajax\t= {};\n\n\t\t\t\t\tvar JSNPbParams = {pbstrings:{}};\n\t\t\t\t\tJSNPbParams.rootUrl = '" . JUri::root() . "';\n\t\t\t\t\tJSNPbParams.pbstrings.COPY = '" . JText::_('copy') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.EMPTY = '" . JText::_('(Untitled)') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_ROW = '" . JText::_('Are you sure you want to delete the whole row including all elements it contains?') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_COLUMN = '" . JText::_('Are you sure you want to delete the whole column including all elements it contains?') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_ELEMENT = '" . JText::_('Are you sure you want to delete the element?') . "';\n\t\t\t\t\tvar pb;\n\t\t\t\t\tvar pbContentStatus_{$random_id}\t= 'normal';\n\n\t\t\t\t\t// Set global pagebuilder instance\n\t\t\t\t\tvar jsnpb_{$random_id};\n\n\t\t\t\t\t// Method to switch between Joomla editor and PageBuilder\n\t\t\t\t\tfunction switchPagebuilder(id, status){\n\t\t\t\t\t\t(function (\$){\n\t\t\t\t\t\t\tif (status == 'on') {\n\t\t\t\t\t\t\t\tjsnpb_{$random_id}\t= new \$.JSNPageBuilder(id);\n\t\t\t\t\t\t\t\tpbContentStatus_{$random_id} = 'pb';\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tjsnpb_{$random_id}.transformToSource();\n\t\t\t\t\t\t\t\tpbContentStatus_{$random_id} = 'normal';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})(JoomlaShine.jQuery);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Entry button group structure which will be appended to the aditor\n\t\t\t\t\tvar pbEntryButtons\t= '<div class=\"jsn-form-bar pb-switcher-group\">'\n\t\t\t\t\t\t\t+ '<div id=\"pb-editor-switcher\" class=\"btn-group\">'\n\t\t\t\t\t\t\t+\t'<button type=\"button\" class=\"switchmode-button pb-off btn active btn-success\" id=\"pagebuilder-off-{$random_id}\" >Default Editor</button>'\n\t\t\t\t\t\t\t+\t'<button type=\"button\" class=\"switchmode-button pb-on btn\" id=\"pagebuilder-on-{$random_id}\" >PageBuilder</button>'\n\t\t\t\t\t\t\t+'</div>'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_pb_total\" name=\"jform_pb_total\" value=\"{$pbTotal}\">'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_content_id\" name=\"jform_content_id\" value=\"{$id}\">'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_list_id\" name=\"jform_list_id\" value=\"{$listId}\">'\n\t\t\t\t\t\t\t+'<div class=\"pull-right\" id=\"top-btn-actions\">'\n +'<!--<button class=\"btn btn-default page-custom-css\" onclick=\"return false;\">Custom CSS</button>-->'\n + '<input type=\"hidden\" id=\"pb_content_id\" name=\"pb_content_id\" value=\"{$id}\">'\n +'</div>'\n\t\t\t\t\t\t+'</div>';\n\n\t\t\t\t\t(function (\$){\n\t\t\t\t\t\t\$(window).load(function (){\n\t\t\t\t\t\t\$('body').find('ul#myTabTabs li:first').on('click', function(){\n\t\t\t\t\t\t\t\$('.switchmode-button.pb-off').click();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (\$('#jform_module').length)\n\t\t\t\t\t\t \t\t{\n\t\t\t\t\t\t\t\t\tif (\$('#jform_module').val() != 'mod_custom')\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t \treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\tvar editorHelper_{$random_id}\t= new \$.JSNPbEditorHelper();\n\t\t\t\t\t\t\tvar buttonGroups\t= editorHelper_{$random_id}.initEntryButtons('" . $name . "', pbEntryButtons);\n\n\t\t\t\t\t\t\t//Auto switch to PageBuilder if shortcode structure detected\n\t\t\t\t\t\t\tvar _content\t= \$('#" . $name . "').val();\n\t\t\t\t\t\t\tif (_content.indexOf('[pb_row') >= 0) {\n\t\t\t\t\t\t\t\t//setTimeout(function (){\n\t\t\t\t\t\t\t\t\t\$('.switchmode-button.pb-on', buttonGroups).click();\n\t\t\t\t\t\t\t\t//}, 500);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t})(JoomlaShine.jQuery);\n\t\t\t\t"; JSNHtmlAsset::addInlineScript($js); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-ui/css/ui-bootstrap/jquery-ui-1.9.0.custom.css'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-gui.css'); JSNHtmlAsset::addStyle(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/pagebuilder.css'); JSNHtmlAsset::addStyle(JSNPB_ADMIN_URL . '/assets/css/jsn-element-font.css'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-advanced-parameters.css'); // for text, JSNHtmlAsset::addStyle(JSNPB_ADMIN_URL . '/assets/css/settings.css'); } } }