/[drupal]/contributions/modules/gitbrowser/lb.module
ViewVC logotype

Diff of /contributions/modules/gitbrowser/lb.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Tue Sep 15 13:54:52 2009 UTC revision 1.4, Wed Nov 4 06:23:36 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: lb.module,v 1.2 2009/08/05 13:20:05 gordon Exp $  // $Id: lb.module,v 1.3 2009/09/15 13:54:52 gordon Exp $
3  /**  /**
4   * @file   * @file
5   * Provide module to allow the browsing of the git repository which was used   * Provide module to allow the browsing of the git repository which was used
# Line 16  function lb_menu() { Line 16  function lb_menu() {
16      'repos' => './.git',      'repos' => './.git',
17      'module' => 'lb',      'module' => 'lb',
18    );    );
19    $items = gb_build_git_menus($params);    $items = lb_build_git_menus($params);
20    
21    $items['admin/srm']['options']['admin'] = TRUE;    $items['admin/srm']['options']['admin'] = TRUE;
22    
# Line 24  function lb_menu() { Line 24  function lb_menu() {
24  }  }
25    
26  /**  /**
27     * Build menu links
28     */
29    function lb_build_git_menus($params = array()) {
30      module_load_include('inc', 'gb', 'gb');
31      $default = array(
32        'title' => 'Git Repository',
33        'repos' => './.git',
34      );
35      $params+= $default;
36      $path = $params['path'];
37      $path_count = count(explode('/', $path));
38    
39      $items = array();
40    
41      $items[$path] = array(
42        'title' => $params['title'],
43        'page callback' => 'gb_summary',
44        'page arguments' => array($path, $params['repos']),
45        'access arguments' => array('access repository'),
46        'file' => 'gb.inc',
47      );
48    
49      $hash_arg = count(explode('/', $path))+1;
50    
51      $items[$path .'/commit/%'] = array(
52        'title' => 'Commit Info',
53        'page callback' => 'gb_commit_page',
54        'page arguments' => array($path, $params['repos'], $hash_arg),
55        'access arguments' => array('access commit log'),
56        'file' => 'gb.inc',
57        'type' => MENU_CALLBACK,
58      );
59      $items[$path .'/commit/%/details'] = array(
60        'title' => 'Details',
61        'access arguments' => array('access commit'),
62        'page callback' => 'gb_commit_page',
63        'page arguments' => array($path, $params['repos'], $hash_arg),
64        'type' => MENU_DEFAULT_LOCAL_TASK,
65        'file' => 'gb.inc',
66        'weight' => -9,
67      );
68      $items[$path .'/commit/%/diff'] = array(
69        'title' => 'Commit Diff',
70        'access arguments' => array('access commit diff'),
71        'page callback' => 'gb_commit_diff',
72        'page arguments' => array($path, $params['repos'], $hash_arg),
73        'file' => 'gb.inc',
74        'type' => MENU_LOCAL_TASK,
75      );
76      for ($i = 0; $i < 5; $i++) {
77        $items[$path .'/commit/%/diff/'. $i] = array(
78          'title callback' => '_gb_parent_hash_title',
79          'title arguments' => array($params['repos'], $hash_arg, (string)$i),
80          'access callback' => '_gb_access_parent',
81          'access arguments' => array($params['repos'], $hash_arg, (string)$i, 'access commit diff'),
82          'page callback' => 'gb_commit_diff',
83          'page arguments' => array($path, $params['repos'], $hash_arg, (string)$i),
84          'file' => 'gb.inc',
85          'type' => $i ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK,
86        );
87      }
88    
89      $items[$path .'/commit/%/tag'] = array(
90        'title' => 'Tag',
91        'access arguments' => array('access create commit tag'),
92        'page callback' => 'drupal_get_form',
93        'page arguments' => array('gb_create_tag', $path, $params['repos'], $hash_arg),
94        'file' => 'gb.inc',
95        'type' => MENU_LOCAL_TASK,
96      );
97      $items[$path .'/download/%'] = array(
98        'title' => 'Download',
99        'access arguments' => array('download archive'),
100        'page callback' => 'gb_download',
101        'page arguments' => array($params['repos'], $hash_arg, $hash_arg+1),
102        'file' => 'gb.inc',
103        'type' => MENU_CALLBACK,
104      );
105      $items[$path .'/fetch/%'] = array(
106        'title' => 'Download',
107        'access arguments' => array('fetch commits'),
108        'page callback' => 'gb_fetch',
109        'page arguments' => array($params['repos'], $hash_arg),
110        'file' => 'gb.inc',
111        'type' => MENU_CALLBACK,
112      );
113    
114      $items[$path .'/checkout/%'] = array(
115        'title' => 'Checkout',
116        'access arguments' => array('checkout tag'),
117        'page callback' => 'drupal_get_form',
118        'page arguments' => array('gb_checkout', $params['repos'], $hash_arg),
119        'file' => 'gb.inc',
120        'type' => MENU_CALLBACK,
121      );
122    
123      $items[$path .'/tag/%'] = array(
124        'title' => 'Tag Info',
125        'page callback' => 'gb_tag_page',
126        'page arguments' => array($path, $params['repos'], $hash_arg),
127        'access arguments' => array('access tag details'),
128        'file' => 'gb.inc',
129        'type' => MENU_CALLBACK,
130      );
131    
132      $items+= lb_build_git_tabs($path, $params['repos'], $path, 'HEAD');
133    
134      $info = gb_get_commit_info($params['repos'], 'HEAD');
135      foreach (gb_show_ref($params['repos']) as $head) {
136        if ($head['hash'] != $info['hash']) {
137          $items[$path .'/'. $head['path']] = array(
138            'title' => $head['name'],
139            'page callback' => 'gb_summary',
140            'page arguments' => array($path, $params['repos'], $head['fullname']),
141            'access arguments' => array('access repository'),
142            'file' => 'gb.inc',
143            'type' => ($head['type'] == 'heads' ? MENU_NORMAL_ITEM : MENU_CALLBACK),
144          );
145    
146          $items+= lb_build_git_tabs($path, $params['repos'], $path .'/'. $head['path'], $head['fullname']);
147        }
148      }
149    
150      foreach ($items as $path => $item) {
151        if (isset($params['menu options'])) {
152          $items[$path]+= $params['menu options'];
153        }
154      }
155      return $items;
156    }
157    
158    function lb_build_git_tabs($menu_path, $repos, $path, $head = 'HEAD') {
159      $items = array();
160    
161      $items[$path .'/summary'] = array(
162        'title' => 'Summary',
163        'page callback' => 'gb_summary',
164        'page arguments' => array($menu_path, $repos, $head),
165        'access arguments' => array('access repository'),
166        'type' => MENU_DEFAULT_LOCAL_TASK,
167        'weight' => -1,
168        'file' => 'gb.inc',
169      );
170      $items[$path .'/shortlog'] = array(
171        'title' => 'Short log',
172        'page callback' => 'gb_shortlog',
173        'page arguments' => array($menu_path, $repos, $head),
174        'access arguments' => array('access commit log'),
175        'type' => MENU_LOCAL_TASK,
176        'file' => 'gb.inc',
177      );
178      $items[$path .'/tag'] = array(
179        'title' => 'Tag',
180        'access arguments' => array('access create head tag'),
181        'page callback' => 'drupal_get_form',
182        'page arguments' => array('gb_create_tag', $path, $repos, $head),
183        'file' => 'gb.inc',
184        'type' => MENU_LOCAL_TASK,
185      );
186      $items[$path .'/tools'] = array(
187        'title' => 'Tools',
188        'access arguments' => array('access git tools'),
189        'page callback' => 'gb_tools',
190        'page arguments' => array($path, $repos, $head),
191        'file' => 'gb.inc',
192        'type' => MENU_LOCAL_TASK,
193      );
194    
195      return $items;
196    }
197    
198    /**
199   * Implementation of hook_xmlrpc().   * Implementation of hook_xmlrpc().
200   */   */
201  function lb_xmlrpc() {  function lb_xmlrpc() {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2