source: extensions/skeleton/trunk/include/public_events.inc.php @ 21307

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

fix breadcrumb in 2.5 & add button with new template features

File size: 3.3 KB
Line 
1<?php
2defined('SKELETON_PATH') or die('Hacking attempt!');
3
4/**
5 * detect current section
6 */
7function skeleton_loc_end_section_init()
8{
9  global $tokens, $page, $conf;
10
11  if ($tokens[0] == 'skeleton')
12  {
13    $page['section'] = 'skeleton';
14   
15    // section_title is for breadcrumb, title is for page <title>
16    $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].'<a href="'.SKELETON_PUBLIC.'">'.l10n('Skeleton').'</a>';
17    $page['title'] = l10n('Skeleton');
18   
19    // define body_id
20    add_event_handler('loc_begin_page_header', 'skeleton_loc_begin_page_header');
21  }
22}
23
24function skeleton_loc_begin_page_header()
25{
26  global $page;
27  $page['body_id'] = 'theSkeletonPage';
28}
29
30/**
31 * include public page
32 */
33function skeleton_loc_end_page()
34{
35  global $page, $template;
36
37  if ( isset($page['section']) and $page['section']=='skeleton' )
38  {
39    include(SKELETON_PATH . 'include/skeleton_page.inc.php');
40  }
41}
42
43/*
44 * button on album and photos pages
45 */
46function skeleton_add_button()
47{
48  global $template;
49 
50  $template->assign('SKELETON_PATH', SKELETON_PATH);
51  $template->set_filename('skeleton_button', realpath(SKELETON_PATH.'template/my_button.tpl'));
52  $button = $template->parse('skeleton_button', true);
53 
54  if (script_basename()=='index')
55  {
56    $template->add_index_button('<li>'.$button.'</li>', EVENT_HANDLER_PRIORITY_NEUTRAL);
57  }
58  else
59  {
60    $template->add_picture_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL);
61  }
62}
63
64/**
65 * add link in existing menu
66 */
67function skeleton_blockmanager_apply1($menu_ref_arr)
68{
69  $menu = &$menu_ref_arr[0]; 
70 
71  if ( ($block = $menu->get_block('mbMenu')) != null )
72  {
73    array_push($block->data, array(
74      'URL' => SKELETON_PUBLIC,
75      'TITLE' => l10n('Skeleton'),
76      'NAME' => l10n('Skeleton'),
77    ));
78  }
79}
80
81/**
82 * add a nbew menu block
83 */
84function skeleton_blockmanager_register_blocks($menu_ref_arr)
85{
86  $menu = &$menu_ref_arr[0];
87 
88  if ($menu->get_id() == 'menubar')
89  {
90    $menu->register_block(new RegisteredBlock('mbSkeleton', l10n('Skeleton'), 'skeleton'));
91  }
92}
93
94/**
95 * fill the added menu block
96 */
97function skeleton_blockmanager_apply2($menu_ref_arr)
98{
99  $menu = &$menu_ref_arr[0];
100 
101  if ( ($block = $menu->get_block('mbSkeleton')) != null )
102  {
103    global $template;
104   
105    $block->set_title(l10n('Skeleton'));
106   
107    $block->data['link1'] =
108      array(
109        'URL' => get_absolute_root_url(),
110        'TITLE' => l10n('First link'),
111        'NAME' => l10n('Link 1'),
112        'REL'=> 'rel="nofollow"',
113      );
114
115    $block->data['link2'] =
116      array(
117        'URL' => SKELETON_PUBLIC,
118        'TITLE' => l10n('Second link'),
119        'NAME' => l10n('Link 2'),
120      );
121   
122    $template->set_template_dir(SKELETON_PATH . 'template/');
123    $block->template = 'menubar_skeleton.tpl';
124  }
125}
126
127/**
128 * add a prefilter on photo page
129 */
130function skeleton_loc_end_picture()
131{
132  global $template;
133 
134  $template->set_prefilter('picture', 'skeleton_picture_prefilter');
135}
136
137function skeleton_picture_prefilter($content)
138{
139  $search = '{if $display_info.author and isset($INFO_AUTHOR)}';
140  $replace = '<div id="Skeleton" class="imageInfo">
141                <dt>{\'Skeleton\'|@translate}</dt>
142                <dd style="color:orange;">{\'Piwigo rocks\'|@translate}</dd>
143        </div>
144'.$search;
145
146  return str_replace($search, $replace, $content);
147}
148 
149
150?>
Note: See TracBrowser for help on using the repository browser.