X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLayout%2FBase.pm;h=8e6acfc74df77aad58e15a073ee14228d3921be6;hb=70e00e04a44be5c1a53e4477a25354ecb2d5c1b1;hp=e39502f1f583a7136bf7b6ec897030322047327e;hpb=4247547d2a925ddad7006cae89e5f9f1fda7d469;p=kivitendo-erp.git diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index e39502f1f..8e6acfc74 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -3,11 +3,12 @@ package SL::Layout::Base; use strict; use parent qw(Rose::Object); +use File::Slurp qw(read_file); use List::MoreUtils qw(uniq); use Time::HiRes qw(); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(menu auto_reload_resources_param) ], + 'scalar --get_set_init' => [ qw(menu auto_reload_resources_param sub_layouts_by_name) ], 'scalar' => qw(focus), 'array' => [ 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' }, @@ -19,6 +20,7 @@ use Rose::Object::MakeMethods::Generic ( use SL::Menu; use SL::Presenter; +use SL::System::Process; my %menu_cache; @@ -32,9 +34,31 @@ sub init_menu { SL::Menu->new('user'); } +sub init_sublayouts_by_name { + {} +} + +sub get { + $_[0]->sub_layouts; + return grep { $_ } ($_[0]->sub_layouts_by_name->{$_[1]}); +} + sub init_auto_reload_resources_param { - return '' unless $::lx_office_conf{debug}->{auto_reload_resources}; - return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)); + return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)) if $::lx_office_conf{debug}->{auto_reload_resources}; + + my $git_dir = SL::System::Process::exe_dir() . '/.git'; + + return '' unless -d $git_dir; + + my $content = eval { scalar(read_file($git_dir . '/HEAD')) }; + + return '' unless ($content // '') =~ m{\Aref: ([^\r\n]+)}; + + $content = eval { scalar(read_file($git_dir . '/' . $1)) }; + + return '' unless ($content // '') =~ m{\A([0-9a-fA-F]+)}; + + return '?rand=' . $1; } ########################################## @@ -69,6 +93,8 @@ sub javascripts_inline { sub init_sub_layouts { [] } +sub init_sub_layouts_by_name { +{} } + ######################################### # Interface @@ -319,7 +345,12 @@ classes, which should be changed. The other points work pretty well. =head1 BUGS -None yet, if you don't count the horrible stylesheet/javascript interface. +* stylesheet/javascript interface is a horrible mess. + +* It's currently not possible to do compositor layouts without assupmtions +about the position of the content. That's because the content will return +control to the actual controller, so the layouts need to know where to split +pre- and post-content. =head1 AUTHOR