@@ -43,8 +43,12 @@ public function onAfterRoute()
4343 \JDPageBuilder \Helper::loadLanguage ();
4444
4545 $ style = '.jdb-version-label{padding: 0px 8px; display: inline-block; background: #84d155; border-radius: 100px;margin: 0px 5px;color: #fff;font-weight: bold;line-height: 16px;font-size: 10px;vertical-align: baseline;position: relative;top: -2px;} ' ;
46- $ docuemnt = \JFactory::getDocument ();
47- $ docuemnt ->addStyleDeclaration ($ style );
46+ $ document = \JFactory::getDocument ();
47+ $ document ->addStyleDeclaration ($ style );
48+ }
49+
50+ if (!$ this ->app ->isClient ('administrator ' )) {
51+ \JDPageBuilder \Builder::beforeRenderHead ();
4852 }
4953 }
5054
@@ -66,8 +70,6 @@ public function onAfterDispatch()
6670 $ jdfinderdoc ->addScript (Juri::root () . 'media/jdbuilder/js/jdfinder.js ' , ['version ' => JDB_MEDIA_VERSION ]);
6771 $ jdfinderdoc ->addScriptDeclaration (" var jdfinderSearch = ' $ jdfinderBaseURL'; " );
6872 }
69- // $document = JFactory::getDocument();
70- // $document->addScriptDeclaration("var _JDB = {};");
7173 }
7274
7375 public function onBeforeRender ()
@@ -158,48 +160,21 @@ public function onAfterRender()
158160 if (!$ this ->app ->isClient ('administrator ' ) || !$ this ->isValidView ()) {
159161 return ;
160162 }
161- if ($ this ->isPageEdit ()) {
162- $ id = $ this ->app ->input ->get ('id ' , 0 , 'INT ' );
163- $ this ->addBuilder ($ id );
164- return ;
165- }
166163 if ($ this ->isModuleEdit ()) {
167164 $ this ->addBodyClass ();
168165 }
169166 }
170167
171- public function setLinkAndLabel ()
172- {
173- $ articleLayouts = self ::$ article_layouts ;
174- $ body = $ this ->app ->getBody ();
175- $ body = preg_replace_callback ('/(<a\s[^>]*href=")([^"]*)("[^>]*>)(.*)(<\/a>)/siU ' , function ($ matches ) use ($ articleLayouts ) {
176- $ html = $ matches [0 ];
177- if (strpos ($ matches [2 ], 'task=article.edit ' )) {
178- $ uri = new JUri ($ matches [2 ]);
179- $ id = (int ) $ uri ->getVar ('id ' );
180- if ($ uri ->getVar ('option ' ) == "com_content " && in_array ($ id , $ articleLayouts )) {
181- $ html = $ matches [1 ] . $ uri . '&jdb=1 ' . $ matches [3 ] . $ matches [4 ] . $ matches [5 ];
182- if (JDB_JOOMLA_VERSION == 3 ) {
183- $ html .= ' <span class="label label-info">JD Page</span> ' ;
184- } else {
185- $ html .= ' <span class="badge badge-info">JD Page</span> ' ;
186- }
187- } else {
188- $ html = '<a title=" ' . JText::_ ('JDBUILDER_EDIT_TITLE ' ) . '" class="btn btn-micro btn-sm btn-info hasTooltip" href=" ' . $ uri . '&jdb=1 ' . '"><span class="icon-pencil"></span></a> ' ;
189- $ html .= $ matches [1 ] . $ uri . $ matches [3 ] . $ matches [4 ] . $ matches [5 ];
190- }
191- }
192- return $ html ;
193- }, $ body );
194- $ this ->app ->setBody ($ body );
195- }
196-
197168 public function onBeforeCompileHead ()
198169 {
199- $ docuemnt = \JFactory::getDocument ();
170+ $ document = \JFactory::getDocument ();
171+
172+ if (!$ this ->app ->isClient ('administrator ' )) {
173+ \JDPageBuilder \Builder::afterRenderHead ();
174+ }
200175
201176 if (JDB_JOOMLA_VERSION == 3 ) {
202- $ docuemnt ->addScript (JURI ::root () . 'media/system/js/core.js ' );
177+ $ document ->addScript (JURI ::root () . 'media/system/js/core.js ' );
203178 }
204179 if (!$ this ->app ->isClient ('administrator ' ) || !$ this ->isValidView ()) {
205180 return ;
@@ -217,11 +192,11 @@ public function onBeforeCompileHead()
217192 $ id = $ this ->app ->input ->get ('id ' , 0 );
218193 $ style = '#jdbuilder-area{display: none;}#jdbuilder-area.active{display: block;}#jdbuilder-area.active~div{display: none;}#jdbuilder-area{position: relative;}#jdbuilder-area.loading{height: 400px; overflow: hidden}#jdbuilder-controls .btn-jdb-exit{display: none;}#jdbuilder-controls .btn-jdb-fs{display: none;}#jdbuilder-controls.active .btn-jdb-exit{display: inline-block;}#jdbuilder-controls.active .btn-jdb-edit{display: none;}#jdbuilder-controls.active .btn-jdb-fs{display: inline-block;} ' ;
219194
220- $ docuemnt ->addStyleDeclaration ($ style );
221- $ docuemnt ->addStyleSheet ('//fonts.googleapis.com/css?family=Noto+Sans:400,700 ' );
222- $ docuemnt ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/css/style.min.css ' , ['version ' => JDB_MEDIA_VERSION ]);
223- $ docuemnt ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/css/rtl.css ' , ['version ' => JDB_MEDIA_VERSION ]);
224- $ docuemnt ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/js/builder/styles.css ' , ['version ' => JDB_MEDIA_VERSION ]);
195+ $ document ->addStyleDeclaration ($ style );
196+ $ document ->addStyleSheet ('//fonts.googleapis.com/css?family=Noto+Sans:400,700 ' );
197+ $ document ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/css/style.min.css ' , ['version ' => JDB_MEDIA_VERSION ]);
198+ $ document ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/css/rtl.css ' , ['version ' => JDB_MEDIA_VERSION ]);
199+ $ document ->addStyleSheet (JURI ::root (true ) . '/media/jdbuilder/js/builder/styles.css ' , ['version ' => JDB_MEDIA_VERSION ]);
225200 }
226201 }
227202
@@ -230,7 +205,7 @@ public function onBeforeCompileHead()
230205 public function isValidView ()
231206 {
232207 $ option = $ this ->app ->input ->get ('option ' , '' );
233- return ($ option == "com_jdbuilder " || $ option == "com_content " || $ option == "com_modules " || $ option == 'com_advancedmodules ' || $ option == " com_hikashop " );
208+ return ($ option == "com_jdbuilder " || $ option == "com_content " || $ option == "com_modules " || $ option == 'com_advancedmodules ' );
234209 }
235210
236211 public function isPageView ()
@@ -481,15 +456,6 @@ public function addAdminMenu()
481456 $ this ->app ->setBody ($ body );
482457 }
483458
484- public function onContentBeforeSave ($ context , $ article , $ isNew )
485- {
486- if ($ context == 'com_advancedmodules.module ' ) {
487- return $ this ->onExtensionBeforeSave ($ context , $ article , $ isNew );
488- }
489-
490- return true ;
491- }
492-
493459 public function onExtensionBeforeSave ($ context , $ item , $ isNew )
494460 {
495461 if (($ context !== 'com_modules.module ' && $ context != 'com_advancedmodules.module ' ) || $ item ->module !== 'mod_jdbuilder ' ) {
0 commit comments