Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admin page enhancements #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Addon.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Addon_Name = 'Cookie Compliance Message'
Addon_Unique_ID = 5648878
# Addon_Unique_ID = 5648878
Addon_Version = 1.12
min_gpeasy_version = 5.0

Expand Down
94 changes: 81 additions & 13 deletions Admin_CookieCompliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,95 @@ function __construct() {
}

function showForm() {
global $langmessage;
echo '<h1>EU Cookie Compliance</h1>';
global $page, $langmessage;
echo '<h2 class="hqmargin">EU Cookie Compliance</h2>';
echo '<h4 style="margin:1em 0;">Set up your cookie compliance message below</h4>';

echo '<form action="' . common::GetUrl('Admin_CookieCompliance') . '" method="post">';

echo '<p>Set up your cookie compliance message below.</p>';
echo '<table class="bordered" style="width:90%">';

echo '<div><label>Button Background Color (Hex):</label><input type="text" name="button_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->button_color) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Button Text Color (Hex):</label><input type="text" name="button_text_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->button_text_color) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Background Color (Hex):</label><input type="text" name="background_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->background_color) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Text Color (Hex):</label><input type="text" name="text_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->text_color) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Header Text:</label><input type="text" name="header_text" value="' . htmlspecialchars($this->header_text) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Text:</label><input type="text" name="text" value="' . htmlspecialchars($this->text) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Agree Button Text:</label><input type="text" name="agree_button_text" value="' . htmlspecialchars($this->agree_button_text) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Policy Button Text:</label><input type="text" name="policy_button_text" value="' . htmlspecialchars($this->policy_button_text) . '" class="gpinput" style="width:200px" /></div>';
echo '<div><label>Policy URL (relative or full):</label><input type="text" name="policy_url" value="' . htmlspecialchars($this->policy_url) . '" class="gpinput" style="width:200px" /></div>';
echo '<tr>';
echo '<th style="width:25%;">' . $langmessage['options'] . '</th>';
echo '<th style="width:75%;">' . $langmessage['Current_Value'] . '</th>';
echo '</tr>';

echo '<input type="hidden" name="cmd" value="saveConfig" />';
echo '<tr>';
echo '<td><label>Button Background Color (Hex)</label></td>';
echo '<td>#<input type="text" name="button_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->button_color) . '" class="gpinput" style="width:60px" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Button Text Color (Hex)</label></td>';
echo '<td>#<input type="text" name="button_text_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->button_text_color) . '" class="gpinput" style="width:60px" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Background Color (Hex)</label></td>';
echo '<td>#<input type="text" name="background_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->background_color) . '" class="gpinput" style="width:60px" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Text Color (Hex)</label></td>';
echo '<td>#<input type="text" name="text_color" placeholder="000000" maxlength="6" value="' . htmlspecialchars($this->text_color) . '" class="gpinput" style="width:60px" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Header Text</label></td>';
echo '<td><input type="text" name="header_text" value="' . htmlspecialchars($this->header_text) . '" class="gpinput" style="width:100%" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Text</label></td>';
echo '<td><textarea name="text" rows="4" class="gptextarea" style="width:100%">' . htmlspecialchars($this->text) . '</textarea></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Agree Button Text</label></td>';
echo '<td><input type="text" name="agree_button_text" value="' . htmlspecialchars($this->agree_button_text) . '" class="gpinput" style="width:100%" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Policy Button Text</label></td>';
echo '<td><input type="text" name="policy_button_text" value="' . htmlspecialchars($this->policy_button_text) . '" class="gpinput" style="width:100%" /></td>';
echo '</tr>';

echo '<tr>';
echo '<td><label>Policy URL (relative or full)</label></td>';
echo '<td><input type="text" name="policy_url" value="' . htmlspecialchars($this->policy_url) . '" class="gpinput" style="width:100%" /></td>';
echo '</tr>';

echo '</table>';

echo '<input type="hidden" name="cmd" value="saveConfig" />';
echo '<input type="submit" value="' . htmlspecialchars($langmessage['save_changes']) . '" class="gpsubmit" style="margin-top:2em; "/>';
echo '</form>';

\gp\tool::LoadComponents('autocomplete');
$page->head_script .= \gp\tool\Editing::AutoCompleteValues(true);
$page->jQueryCode .= '
$("input[name=\"policy_url\"]")
.autocomplete({
source : gptitles,
appendTo : "#gp_admin_html",
delay : 100,
minLength : 0,
select : function(event,ui){
if( ui.item ){
$(this).val(encodeURI(ui.item[1]));
$(this).trigger("change");
event.stopPropagation();
return false;
}
}
}).data("ui-autocomplete")._renderItem = function(ul,item) {
return $("<li></li>")
.data("ui-autocomplete-item", item[1])
.append("<a>" + $gp.htmlchars(item[0]) + "<span>" + $gp.htmlchars(item[1]) +"</span></a>")
.appendTo(ul);
};
';

}

function saveConfig() {
Expand Down
9 changes: 7 additions & 2 deletions Get_Head_CookieCompliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ function Get_Cookie_Compliance_Head()
global $page;
global $addonPathData;

if( $page->requested != 'Admin_CookieCompliance' && ! $page->title )
{
// don't show on other admin pages ( ! $page->title ==> admin page )
return;
}

$configFile = $addonPathData.'/config.php';
if( ! file_exists( $configFile ) )
{
return;
}

include_once $configFile;
include $configFile;

if( ! isset( $config ) )
{
Expand Down Expand Up @@ -65,4 +71,3 @@ function Get_Cookie_Compliance_Head()
$page->head .= "\n</script>";
$page->head .= "\n";
}
?>