Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
New: Improvements to 'essential_edit_button' for child themes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Sep 29, 2016
1 parent 7f50aed commit dca223d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New in 3.1.0.9
- FIX: Issue #765: Link font family is wrong.
- FIX: Breadcrumb style two fixes.
- NEW: Issue #738: Fixes #736 add extra urlcolor for stripes.
- NEW: Improvements to 'essential_edit_button' for child themes.

New in 3.1.0.8
==============
Expand Down
44 changes: 41 additions & 3 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2024,23 +2024,61 @@ public function essential_marketing_button($spot) {
$url .= \theme_essential\toolbox::get_setting('marketing'.$spot.'buttontext', true);
$url .= '</a>';
}
$edit = $this->essential_edit_button('theme_essential_frontpage');
$edit = $this->essential_edit_button('frontpage');
if ((!empty($url)) || (!empty($edit))) {
$o = '<div class="marketing-buttons">'.$url.$edit.'</div>';
}

return $o;
}

public function essential_edit_button($section) {
/**
* Generates the edit button markup.
*
* Ensure that the 'essential_edit_button_settingspage' method has the 'keys' and values for the sections
* in the settings.php file of the theme that the layout and tile files call this method for.
*
* @param string $sectionkey settings section key.
* @return string or null of not needed.
*/
public function essential_edit_button($sectionkey) {
global $CFG;
if ($this->page->user_is_editing() && is_siteadmin()) {
$themesectionkey = $this->essential_edit_button_settingspage($sectionkey);
$url = preg_replace("(https?:)", "", $CFG->wwwroot . '/admin/settings.php?section=');
return '<a class="btn btn-success" href="'.$url.$section.'">'.get_string('edit').'</a>';
return '<a class="btn btn-success" href="'.$url.$themesectionkey.'">'.get_string('edit').'</a>';
}
return null;
}


/**
* Finds the setting section for the given section key.
*
* This must match the ones in the settings.php file of the theme that the layout and tile files
* call the 'essential_edit_button' method for.
*
* @param string $sectionkey settings section key.
* @return string or false if not found.
*/
protected function essential_edit_button_settingspage($sectionkey) {
$themesectionkey = false;

switch ($sectionkey) {
case 'frontpage':
$themesectionkey = 'theme_essential_frontpage';
break;
case 'footer':
$themesectionkey = 'theme_essential_footer';
break;
case 'slideshow':
$themesectionkey = 'theme_essential_slideshow';
break;
}

return $themesectionkey;
}

public function get_title($location) {
global $CFG, $SITE;
$title = '';
Expand Down
2 changes: 1 addition & 1 deletion layout/frontpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<div class="bor"></div>
<?php
echo \theme_essential\toolbox::get_setting('frontcontentarea', 'format_html');
echo $OUTPUT->essential_edit_button('theme_essential_frontpage');
echo $OUTPUT->essential_edit_button('frontpage');
?>
<div class="bor"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion layout/tiles/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
if (empty($PAGE->layout_options['nofooter'])) { ?>
<footer role="contentinfo" id="page-footer">
<div class="container-fluid">
<?php echo $OUTPUT->essential_edit_button('theme_essential_footer'); ?>
<?php echo $OUTPUT->essential_edit_button('footer'); ?>
<div class="row-fluid footerblocks">
<div class="footerblock span4">
<?php echo $OUTPUT->blocks('footer-left'); ?>
Expand Down
2 changes: 1 addition & 1 deletion layout/tiles/slideshow.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="row-fluid">
<div class="span12">
<div id="essentialCarousel" class="carousel slide" data-interval="<?php echo $slideinterval;?>">
<?php echo $OUTPUT->essential_edit_button('theme_essential_slideshow');?>
<?php echo $OUTPUT->essential_edit_button('slideshow');?>
<ol class="carousel-indicators">
<?php echo \theme_essential\toolbox::render_indicators($numberofslides); ?>
</ol>
Expand Down

0 comments on commit dca223d

Please sign in to comment.