[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1334] trunk



Revision: 1334
          http://svn.sourceforge.net/ledger-smb/?rev=1334&view=rev
Author:   einhverfr
Date:     2007-06-27 08:19:55 -0700 (Wed, 27 Jun 2007)

Log Message:
-----------
Moving menu.pl to old-handler.pl and adjusting top level scripts accordingly.
Including also an unfinished and inactive version of the menu system running under the new architecture.

Modified Paths:
--------------
    trunk/LedgerSMB/Menu.pm
    trunk/LedgerSMB.pm
    trunk/UI/menu_expand.html
    trunk/menu.pl
    trunk/scripts/menu.pl

Modified: trunk/LedgerSMB/Menu.pm
===================================================================
--- trunk/LedgerSMB/Menu.pm	2007-06-27 01:28:23 UTC (rev 1333)
+++ trunk/LedgerSMB/Menu.pm	2007-06-27 15:19:55 UTC (rev 1334)
@@ -48,19 +48,18 @@
                 my $orig_key = $key;
                 my $ref = $self;
                 while ($key =~ s/^([^-]*)--//){
-                    if (!defined $ref->{$1}){
-                        $ref->{$1} = {};
-                    }
-                    if (!defined $ref->{$1}->{subs}){
-                        $ref->{$1}->{subs} = {};
-                    }
-                    $ref = $ref->{$1}->{subs};
+                    $ref->{subs} ||= {};
+                    $ref->{subs}->{$1} ||= {};
+                    $ref = $ref->{subs}->{$1};
                 }
-                for (keys %{$config->{$orig_key}}){
-                     $ref->{$_} = $config{$orig_key}->{$_};
+                $ref->{subs} ||= {};
+		$ref->{subs}->{key} ||= {};
+                $ref = $ref->{subs}->{$key};
+                for (keys %{$config{$orig_key}}){
+                     $ref->{$_} = ${$config{$orig_key}}{$_};
                 }
-                $ref->{$key}{id} = $index;
-                $ref->{$key}{label} = $key;
+                $ref->{id} = $index;
+                $ref->{label} = $key;
                 ++$index;
             }
         }

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-06-27 01:28:23 UTC (rev 1333)
+++ trunk/LedgerSMB.pm	2007-06-27 15:19:55 UTC (rev 1334)
@@ -214,6 +214,9 @@
             exit;
         }
     }
+
+    $self->{stylesheet} = $self->{_user}->{stylesheet};
+
     $self->_db_init;
 
     $self;
@@ -248,7 +251,7 @@
     my $args = shift @_;
     my $file;
     if (scalar keys %$args){
-        my $file = $args->{'file'};
+        $file = $args->{'file'};
     }
     my $d    = Data::Dumper->new( [$self] );
     $d->Sortkeys(1);

Modified: trunk/UI/menu_expand.html
===================================================================
--- trunk/UI/menu_expand.html	2007-06-27 01:28:23 UTC (rev 1333)
+++ trunk/UI/menu_expand.html	2007-06-27 15:19:55 UTC (rev 1334)
@@ -34,38 +34,34 @@
 
 		<body class="menu">
 		<img class="cornderlogo" src="images/ledgersmb_small.png" width="100" height="50" border="1" alt="ledger-smb" />
-		 <div id="div_0" class="container">
-		<?lsmb MACRO menu(section) BLOCK ?>
-			<?lsmb IF item.id ?>
-				<div id="menu<?lsmb section.id ?>" class="menuOut" 
-					onclick="SwitchMenu('sub_<?lsmb section.id ?>')"> 
-					<?lsmb text(section.label) ?></div>
-				<div class="submenu" id="sub<?lsmb item.id ?>"> 
-				<div id="div_<?lsmb item.id ?>"> 
+	<?lsmb FOREACH item = subs ?>
+		<?lsmb old_id = id ?><?lsmb old_path = path ?>
+		<?lsmb id = item.id ?><?lsmb path = item.path ?>
+		<?lsmb IF (id != old_id) AND id ?>
+			<?lsmb desc_ids = [id, ''] ?>
+			<?lsmb asc_ids = [old_id, ''] ?>
+                	<?lsmb IF old_id.search(desc_ids.join('--')) ?>
+				<div id="sub_<?lsmb old_id ?>" class="Submenu">
+			<?lsmb ELSIF id.search(asc_ids.join('--')) ?>
+				</div>
 			<?lsmb END ?>
-			<?lsmb IF section.subs.size > 0 ?>
-				<?lsmb FOREACH key = section.subs.keys.sort ?>
-					<?lsmb item = section.subs.$key ?>
-					<?lsmb IF item.subs ?>
-						<?lsmb subs = items.subs ?>
-						<?lsmb FOREACH subkey = subs.keys.sort ?>
-							<?lsmb sub = item.sub.$key ?>
-							<?lsmb menu(item) ?>
-						<?lsmb END ?>
-					<?lsmb ELSE ?>
-						<div class="submenu"> 
-						<a class="submenu" 
-							href="<?lsmb item.module ?>?login=<?lsmb login ?><?lsmb FOREACH key = item.keys ?>&<?lsmb key ?>=<?lsmb item.$key ?><?lsmb END ?>" 
-							target="main_window"><?lsmb text(item.label)?></a>
-						</div>
-					<?lsmb END ?>
-				<?lsmb END ?>
-			<?lsmb END  ?>
-				  			</div>
-				 			</div>
-                <?lsmb END ?>
-		<?lsmb menu(menu_items) ?>
+		<?lsmb END ?>
+		<div class="Menu" id="menu_<?lsmb id ?>">
+			<a href="<?lsmb IF item.module ?><?lsmb item.module 
+				?><?lsmb ELSE ?>menu.pl<?lsmb END 
+				?>?login=<?lsmb login 
+				?><?lsmb FOREACH key IN item.keys ?>&<?lsmb key
+				?>=<?lsmb item.$key ?><?lsmb END ?>"
+				target = "main_window"
+				onclick="return <?lsmb IF item.module 
+					?>SwitchMenu(<?lsmb id ?>)<?lsmb END ?>"
+				class = "<?lsmb IF item.module ?>Menu<?lsmb
+					ELSE ?>Item<?lsmb END ?>"
+				><?lsmb text(item.label) ?></a>
 		</div>
+	<?lsmb END ?>
+                
+                
 </body>
 
 </html>

Modified: trunk/menu.pl
===================================================================
--- trunk/menu.pl	2007-06-27 01:28:23 UTC (rev 1333)
+++ trunk/menu.pl	2007-06-27 15:19:55 UTC (rev 1334)
@@ -1,3 +1,3 @@
 #!/usr/bin/perl
 
-require "lsmb-request.pl";
+require "old-handler.pl";

Modified: trunk/scripts/menu.pl
===================================================================
--- trunk/scripts/menu.pl	2007-06-27 01:28:23 UTC (rev 1333)
+++ trunk/scripts/menu.pl	2007-06-27 15:19:55 UTC (rev 1334)
@@ -44,15 +44,42 @@
          template => 'menu_expand',
          format => 'HTML',
     );
-    $request->{menu_items} = [];
-    for (keys %$menu){
-        push @{$request->{menu_items}}, $menu->{$_};
-    }
+    $request->{subs} = [];
+    _attach_references({source => $menu, dest => $request->{subs}, path => ""});
     $menu->debug({file => '/tmp/debug-menu'});
-    $request->{menu_items} = {};
-    $request->{menu_items}->{subs} = $menu;
     $request->debug({file => '/tmp/debug'});
     $template->render($request);
 }
 
+sub _attach_references {
+    no strict qw(refs);
+    my ($args) = @_;
+    my ($source, $dest, $path) 
+	= ($args->{source}, $args->{dest}, $args->{path});
+    my %hash;
+    if ($path and $source->{id}){
+        for (sort keys %$source){
+            next if $_ eq 'subs';
+            $hash{$_} = $source->{$_};
+        }
+        $hash{path} = $path;
+        push @{$dest}, \%hash;
+        foreach (sort keys %{$source->{subs}}) {
+            _attach_references({
+                 source => $source->{subs}->{$_}, 
+                 dest => $dest,
+                 path => "$path--$_",
+            });
+        }
+    } else {
+        foreach (sort keys %$source){
+            _attach_references({
+                source => $source->{$_},
+                dest => $dest,
+                path => "$_",
+            });
+        }
+    }
+}
+
 1;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.