/[drupal]/contributions/modules/nodeprofile/content_profile.theme.inc
ViewVC logotype

Contents of /contributions/modules/nodeprofile/content_profile.theme.inc

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


Revision 1.1 - (show annotations) (download) (as text)
Fri Jan 25 10:57:36 2008 UTC (22 months ago) by fago
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
checked in a first prototype of content profile
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Theme and template preprocessing code
7 */
8
9 /**
10 * Themes the add link.
11 */
12 function theme_content_profile_display_add_link($element) {
13 $type = $element['#content_type'];
14 return l(t("Create your @profile_node.", array('@profile_node' => node_get_types('name', $type))), content_profile_get_add_path($type), array('query' => drupal_get_destination()));
15 }
16
17 /**
18 * Theme function for the content_profile display as link
19 */
20 function theme_content_profile_display_link($element) {
21 if ($node = content_profile_load($element['#content_type'], $element['#uid'])) {
22 if (node_access('view', $node)) {
23 $output = l(node_get_types('name', $node->type), 'node/'. $node->nid);
24 if ($element['#edit_link'] && node_access('update', $node)) {
25 $output .= ' '. l('['. t('edit') .']', content_profile_get_edit_path($node), array('query' => drupal_get_destination()));
26 }
27 return $output;
28 }
29 }
30 }
31
32 /**
33 * Implementation of template_preprocess_HOOK()
34 */
35 function template_preprocess_content_profile_display_view(&$variables) {
36 $element = $variables['element'];
37 $node = content_profile_load($element['#content_type'], $element['#uid']);
38 $variables['node'] = &$node;
39
40 $path = drupal_get_path('module', 'content_profile') .'/content_profile.css';
41 drupal_add_css($path, 'module', 'all', FALSE);
42
43 $variables['title'] = check_plain(node_get_types('name', $node->type));
44
45 $tabs = array();
46 if ($element['#edit_link'] || $element['#style'] == 'teaser') {
47 $tabs[] = theme('content_profile_display_tab_view', $node);
48 }
49 if ($element['#edit_link']) {
50 $tabs[] = theme('content_profile_display_tab_edit', $node);
51 }
52 if (count($tabs) > 0) {
53 $variables['tabs'] = $tabs;
54 }
55 $variables['content'] = node_view($node, ($element['#style'] == 'teaser'), TRUE, FALSE);
56 }
57
58 /**
59 * Themes the view tab
60 */
61 function theme_content_profile_display_tab_view($node) {
62 return l(t('View'), 'node/'. $node->nid);
63 }
64
65 /**
66 * Themes the edit tab
67 */
68 function theme_content_profile_display_tab_edit($node) {
69 if (node_access('update', $node)) {
70 return l(t('Edit'), content_profile_get_edit_path($node), array('query' => drupal_get_destination()));
71 }
72 }
73
74 /**
75 * Gets the edit path for a content_profile
76 */
77 function content_profile_get_edit_path($node) {
78 $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_hanlder');
79 return $handler('edit', $node);
80 }
81
82 /**
83 * Gets the add path for a content_profile of the active user
84 */
85 function content_profile_get_add_path($type) {
86 $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_hanlder');
87 return $handler('add', $type);
88 }
89
90 /**
91 * Default path handler for content profile, which uses the default system paths
92 *
93 * @param $action 'add' or 'edit
94 * @param $arg For 'add' the content type, for 'edit' the node to be edited
95 */
96 function content_profile_default_path_hanlder($action, $arg) {
97 switch ($action) {
98 case 'add':
99 return 'node/add/'. $arg;
100 case 'edit':
101 return 'node/'. $arg->nid .'/edit';
102 }
103 }

  ViewVC Help
Powered by ViewVC 1.1.2