Skip to content

Commit

Permalink
Pagetree output vars (#315)
Browse files Browse the repository at this point in the history
* Added page tree and backend JS as output vars (#312), (#313) and (#314)
  • Loading branch information
Christoph Bleiweis authored Nov 21, 2017
1 parent ed2ab01 commit 078fb64
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
40 changes: 27 additions & 13 deletions wbce/admin/pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,29 @@
// Include the WB functions file
require_once(WB_PATH.'/framework/functions.php');

/**
* Include PageTree script
*
*/
if (file_exists(THEME_PATH.'/patch/page_tree.php')) :
// Include page tree and define output
ob_start();
if (file_exists(THEME_PATH.'/patch/page_tree.php')) {
require_once(THEME_PATH.'/patch/page_tree.php');
else :
} else {
require_once(dirname(__FILE__).'/page_tree/page_tree.php');
endif;
}
$pageTreeOutput = ob_get_clean();

// Setup template object
$template = new Template(dirname($admin->correct_theme_source('pages.htt')));

// Disable removing of unknown vars
$template->set_unknowns('keep');

$template->set_file('page', 'pages.htt');
$template->set_block('page', 'main_block', 'main');
$template->set_var('FTAN', $admin->getFTAN());

// Set page tree as var
$template->set_var('PAGE_TREE', $pageTreeOutput);


/**
* Insert values into the add page form
*
Expand Down Expand Up @@ -238,6 +244,7 @@ function parent_list($parent){
);
// Insert language text and messages
$template->set_var(array(
'TEXT_PAGES' => $MENU['PAGES'],
'TEXT_TITLE' => $TEXT['TITLE'],
'TEXT_TYPE' => $TEXT['TYPE'],
'TEXT_PARENT' => $TEXT['PARENT'],
Expand Down Expand Up @@ -267,17 +274,24 @@ function parent_list($parent){
$template->set_var('DISPLAY_INTRO', 'hide');
}

// Include JavaScript backend includes and define output
ob_start();
$jsadminFile = WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php';
if(is_file($jsadminFile)) {
include($jsadminFile);
}
$jsAdminOutput = ob_get_clean();

// Oadd eggsurplus Javascript to output
$jsAdminOutput .= PHP_EOL . '<script type="text/javascript" src="eggsurplus.js"></script>';

// Set JavaScript backend as var
$template->set_var('JS_ADMIN', $jsAdminOutput);

// Parse template object
$template->parse('main', 'main_block', false);
$template->pparse('output', 'page');

// include the required file for Javascript admin
$jsadmin_file = WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php';
if($jsadmin_file) include($jsadmin_file);
?>
<script type="text/javascript" src="eggsurplus.js"></script>
<?php
// Print admin
$admin->print_footer();
?>
3 changes: 3 additions & 0 deletions wbce/templates/argos_theme_reloaded/templates/pages.htt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- BEGIN main_block -->
{PAGE_TREE}
<!--- !!! relevant table cell for drag'n'drop sorting: #7 (0-indexed) -->
<div class="clearfix"></div>
<section class="{DISPLAY_ADD}">
Expand Down Expand Up @@ -132,4 +133,6 @@
}
});
</script>

{JS_ADMIN}
<!-- END main_block -->
4 changes: 3 additions & 1 deletion wbce/templates/wbce_flat_theme/templates/pages.htt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- BEGIN main_block -->

{PAGE_TREE}
<div id="pagesPage">
<div id="pageListCard" class="card">
<h2 class="page_titel card-header">{PAGES}</h2>
Expand Down Expand Up @@ -276,4 +276,6 @@
}

</script>

{JS_ADMIN}
<!-- END main_block -->

0 comments on commit 078fb64

Please sign in to comment.