Commit interim work before cleanup

This commit is contained in:
Chris 2016-12-11 11:35:13 +00:00
parent 2ca84af091
commit e6ce9c710b
2 changed files with 362 additions and 296 deletions

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,7 @@ sub new {
# ============================================================================ # ============================================================================
# HTML generation support # HTML generation support
## @method $ generate_cadence_page($title, $content, $extrahead, $doclink) ## @method $ generate_orb_page($title, $content, $extrahead, $extrajs, $doclink)
# A convenience function to wrap page content in the standard page template. This # A convenience function to wrap page content in the standard page template. This
# function allows blocks to embed their content in a page without having to build # function allows blocks to embed their content in a page without having to build
# the whole page including "common" items themselves. It should be called to wrap # the whole page including "common" items themselves. It should be called to wrap
@ -89,16 +89,18 @@ sub new {
# @param doclink The name of a document link to include in the userbar. If not # @param doclink The name of a document link to include in the userbar. If not
# supplied, no link is shown. # supplied, no link is shown.
# @return A string containing the page. # @return A string containing the page.
sub generate_cadence_page { sub generate_orb_page {
my $self = shift; my $self = shift;
my $title = shift; my $title = shift;
my $content = shift; my $content = shift;
my $extrahead = shift; my $extrahead = shift;
my $extrajs = shift;
my $doclink = shift; my $doclink = shift;
my $userbar = $self -> {"module"} -> load_module("ORB::Userbar"); my $userbar = $self -> {"module"} -> load_module("ORB::Userbar");
return $self -> {"template"} -> load_template("page.tem", {"%(extrahead)s" => $extrahead || "", return $self -> {"template"} -> load_template("page.tem", {"%(extrahead)s" => $extrahead || "",
"%(extrajs)s" => $extrajs || "",
"%(title)s" => $title || "", "%(title)s" => $title || "",
"%(userbar)s" => ($userbar ? $userbar -> block_display($title, $self -> {"block"}, $doclink) : "<!-- Userbar load failed: ".$self -> {"module"} -> errstr()." -->"), "%(userbar)s" => ($userbar ? $userbar -> block_display($title, $self -> {"block"}, $doclink) : "<!-- Userbar load failed: ".$self -> {"module"} -> errstr()." -->"),
"%(content)s" => $content}); "%(content)s" => $content});
@ -118,22 +120,23 @@ sub generate_errorbox {
$self -> log("error:fatal", $message); $self -> log("error:fatal", $message);
$message = $self -> {"template"} -> message_box($title, $message = $self -> message_boc($title,
"error", "error",
"{L_FATAL_ERROR_SUMMARY}", "{L_FATAL_ERROR_SUMMARY}",
$message, $message,
undef, undef,
"errorcore", "errorcore",
[ {"message" => $self -> {"template"} -> replace_langvar("SITE_CONTINUE"), [ {"message" => $self -> {"template"} -> replace_langvar("SITE_CONTINUE"),
"colour" => "blue", "colour" => "blue",
"action" => "location.href='{V_[scriptpath]}'"} ]); "action" => "location.href='{V_[scriptpath]}'"} ]);
my $userbar = $self -> {"module"} -> load_module("ORB::Userbar"); my $userbar = $self -> {"module"} -> load_module("ORB::Userbar");
# Build the error page... # Build the error page...
return $self -> {"template"} -> load_template("error/general.tem", return $self -> {"template"} -> load_template("page.tem",
{"%(title)s" => $title, {"%(title)s" => $title,
"%(message)s" => $message, "%(content)s" => $message,
"%(extrahead)s" => "", "%(extrahead)s" => "",
"%(extrajs)s" => "",
"%(userbar)s" => ($userbar ? $userbar -> block_display($title) : "<!-- Userbar load failed: ".$self -> {"module"} -> errstr()." -->"), "%(userbar)s" => ($userbar ? $userbar -> block_display($title) : "<!-- Userbar load failed: ".$self -> {"module"} -> errstr()." -->"),
}); });
} }
@ -177,6 +180,52 @@ sub generate_multiselect {
} }
## @method $ message_box($title, $type, $summary, $longdesc, $additional, $boxclass, $buttons)
# Create a message box block to include in a page. This generates a templated
# message box to include in a page. It assumes the presence of messagebox.tem
# in the template directory, containing markers for a title, type, summary,
# long description and additional data. The type argument should correspond
# to an image in the {template}/images/messages/ directory without an extension.
#
# @param title The title of the message box.
# @param type The message type.
# @param summary A summary version of the message.
# @param longdesc The full message body
# @param additional Any additional content to include in the message box.
# @param boxclass Optional additional classes to add to the messagebox container.
# @param buttons Optional reference to an array of hashes containing button data. Each
# hash in the array should contain three keys: `colour` which specifies
# the button colour; `action` which should contain javascript to run
# when the button is clicked; and `message` which should be the message
# to show in the button.
# @return A string containing the message box.
sub message_box {
my ($self, $title, $type, $summary, $longdesc, $additional, $boxclass, $buttons) = @_;
my $buttonbar = "";
# Has the caller specified any buttons?
if($buttons) {
# Build the list of buttons...
my $buttonlist = "";
for my $button (@{$buttons}) {
$buttonlist .= $self -> {"template"} -> load_template("messagebox_button.tem", {"%(colour)s" => $button -> {"colour"},
"%(onclick)s" => $button -> {"action"},
"%(message)s" => $button -> {"message"}});
}
# Shove into the bar
$buttonbar = $self -> {"template"} -> load_template("messagebox_buttonbar.tem", {"%(buttons)s" => $buttonlist});
}
return $self -> {"template"} -> load_template("messagebox.tem", { "%(title)s" => $title,
"%(icon)s" => $type,
"%(summary)s" => $summary,
"%(longdesc)s" => $longdesc,
"%(additional)s" => $additional,
"%(buttons)s" => $buttonbar,
"%(boxclass)s" => $boxclass});
}
# ============================================================================ # ============================================================================
# Permissions/Roles related. # Permissions/Roles related.
@ -222,15 +271,15 @@ sub check_login {
$self -> log("error:permission", "User does not have perission 'view'"); $self -> log("error:permission", "User does not have perission 'view'");
# Logged in, but permission failed # Logged in, but permission failed
my $message = $self -> {"template"} -> message_box("{L_PERMISSION_FAILED_TITLE}", my $message = $self -> message_boc("{L_PERMISSION_FAILED_TITLE}",
"error", "error",
"{L_PERMISSION_FAILED_SUMMARY}", "{L_PERMISSION_FAILED_SUMMARY}",
"{L_PERMISSION_VIEW_DESC}", "{L_PERMISSION_VIEW_DESC}",
undef, undef,
"errorcore", "errorcore",
[ {"message" => $self -> {"template"} -> replace_langvar("SITE_CONTINUE"), [ {"message" => $self -> {"template"} -> replace_langvar("SITE_CONTINUE"),
"colour" => "blue", "colour" => "blue",
"action" => "location.href='{V_[scriptpath]}'"} ]); "action" => "location.href='{V_[scriptpath]}'"} ]);
my $userbar = $self -> {"module"} -> load_module("ORB::Userbar"); my $userbar = $self -> {"module"} -> load_module("ORB::Userbar");
# Build the error page... # Build the error page...