source: extensions/skeleton/trunk/include/menu_events.class.php @ 24182

Last change on this file since 24182 was 24182, checked in by mistic100, 11 years ago

remove php end tags, remove at symbol in template, add example of class handlers, remove useless files

File size: 2.0 KB
Line 
1<?php
2defined('SKELETON_PATH') or die('Hacking attempt!');
3
4/*
5 * there is two ways to use class methods as event handlers:
6 *
7 **   add_event_handler('blockmanager_apply', array('SkeletonMenu', 'blockmanager_apply'));
8 *      in this case the method 'blockmanager_apply' must be a static method of the class 'SkeletonMenu'
9 *
10 **   $myObj = new SkeletonMenu();
11 **   add_event_handler('blockmanager_apply', array(&$myObj, 'blockmanager_apply') );
12 *      in this case the method 'blockmanager_apply' must be a public method of the object '$myObj'
13 */
14
15class SkeletonMenu
16{
17  /**
18   * add link in existing menu
19   */
20  static function blockmanager_apply1($menu_ref_arr)
21  {
22    $menu = &$menu_ref_arr[0]; 
23   
24    if ( ($block = $menu->get_block('mbMenu')) != null )
25    {
26      array_push($block->data, array(
27        'URL' => SKELETON_PUBLIC,
28        'TITLE' => l10n('Skeleton'),
29        'NAME' => l10n('Skeleton'),
30      ));
31    }
32  }
33
34  /**
35   * add a new menu block
36   */
37  static function blockmanager_register_blocks($menu_ref_arr)
38  {
39    $menu = &$menu_ref_arr[0];
40   
41    if ($menu->get_id() == 'menubar')
42    {
43      $menu->register_block(new RegisteredBlock('mbSkeleton', l10n('Skeleton'), 'skeleton'));
44    }
45  }
46
47  /**
48   * fill the added menu block
49   */
50  static function blockmanager_apply2($menu_ref_arr)
51  {
52    $menu = &$menu_ref_arr[0];
53   
54    if ( ($block = $menu->get_block('mbSkeleton')) != null )
55    {
56      global $template;
57     
58      $block->set_title(l10n('Skeleton'));
59     
60      $block->data['link1'] =
61        array(
62          'URL' => get_absolute_root_url(),
63          'TITLE' => l10n('First link'),
64          'NAME' => l10n('Link 1'),
65          'REL'=> 'rel="nofollow"',
66        );
67
68      $block->data['link2'] =
69        array(
70          'URL' => SKELETON_PUBLIC,
71          'TITLE' => l10n('Second link'),
72          'NAME' => l10n('Link 2'),
73        );
74     
75      $block->template = realpath(SKELETON_PATH . 'template/menubar_skeleton.tpl');
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.