Mercurial > hg > mpiwg_geobrowser
annotate plugins/tasks/mpiwg_geobrowser_view.inc @ 4:1b6cde0e4b83 default tip
merger
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 12 Oct 2015 08:38:25 +0200 |
parents | 19f75fe342eb ea066ce001bd |
children |
rev | line source |
---|---|
0 | 1 <?php |
2 | |
3 function mpiwg_geobrowser_mpiwg_geobrowser_view_page_manager_tasks() { | |
4 return array( | |
5 'task type' => 'page', | |
6 | |
7 'title' => t('mpiwg_geobrowser template'), | |
8 | |
9 'admin title' => t('mpiwg_geobrowser template'), | |
10 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying mpiwg_geobrowsers at <em>mpiwg_geobrowser/%mpiwg_geobrowser</em>. If you add variants, you may use selection criteria such as mpiwg_geobrowser type or language or user access to provide different views of mpiwg_geobrowsers. If no variant is selected, the default Drupal mpiwg_geobrowser view will be used. This page only affects mpiwg_geobrowsers viewed as pages, it will not affect mpiwg_geobrowsers viewed in lists or at other locations. Also please note that if you are using pathauto, aliases may make a mpiwg_geobrowser to be somewhere else, but as far as Drupal is concerned, they are still at mpiwg_geobrowser/%mpiwg_geobrowser.'), | |
11 'admin path' => 'mpiwg_geobrowser/%mpiwg_geobrowser', | |
12 | |
13 'hook menu' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_menu', | |
14 'hook menu alter' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_menu_alter', | |
15 | |
16 'handler type' => 'context', | |
17 'get arguments' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_get_arguments', | |
18 'get context placeholders' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_get_contexts', | |
19 | |
20 'disabled' => variable_get('mpiwg_geobrowser_mpiwg_geobrowser_view_disabled', FALSE), | |
21 'enable callback' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_enable', | |
22 'access callback' => 'mpiwg_geobrowser_mpiwg_geobrowser_view_access_check', | |
23 ); | |
24 } | |
25 | |
26 function mpiwg_geobrowser_mpiwg_geobrowser_view_menu_alter(&$items, $task) { | |
27 if (variable_get('mpiwg_geobrowser_mpiwg_geobrowser_view_disabled', FALSE)) { | |
28 return; | |
29 } | |
30 | |
31 $callback = $items['mpiwg_geobrowser/%mpiwg_geobrowser']['page callback']; | |
32 if ($callback == 'mpiwg_geobrowser_page_view' || variable_get('mpiwg_geobrowser_override_anyway', TRUE)) { | |
33 $items['mpiwg_geobrowser/%mpiwg_geobrowser']['page callback'] = 'mpiwg_geobrowser_mpiwg_geobrowser_view_page'; | |
34 $items['mpiwg_geobrowser/%mpiwg_geobrowser']['file path'] = $task['path']; | |
35 $items['mpiwg_geobrowser/%mpiwg_geobrowser']['file'] = $task['file']; | |
36 } | |
37 else { | |
38 variable_set('mpiwg_geobrowser_mpiwg_geobrowser_view_disabled', TRUE); | |
39 if (!empty($GLOBALS['mpiwg_geobrowser_enabling_mpiwg_geobrowser_view'])) { | |
40 drupal_set_message(t('Page manager module is unable to enable mpiwg_geobrowser/%mpiwg_geobrowser because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error'); | |
41 } | |
42 } | |
43 } | |
44 | |
45 function mpiwg_geobrowser_mpiwg_geobrowser_view_page($mpiwg_geobrowser) { | |
3 | 46 drupal_add_css(drupal_get_path('module', 'mpiwg_geobrowser') . '/css/mpiwg_geobrowser_style.css', array('group' => CSS_DEFAULT, 'type' => 'file')); |
0 | 47 drupal_add_js(drupal_get_path('module', "mpiwg_geobrowser") . '/lib/moment.min.js'); |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
48 drupal_add_js(drupal_get_path('module', "mpiwg_geobrowser") . '/lib/filesaver/FileSaver.min.js'); |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
49 #drupal_add_js(libraries_get_path("platin") . '/platin.js'); |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
50 drupal_add_js(libraries_get_path("platin") . '/devel/platin.js'); |
0 | 51 drupal_add_css(drupal_get_path('module', 'mpiwg_geobrowser') . '/lib/GeoTemCo/css/platin.css', array('group' => CSS_DEFAULT, 'type' => 'file')); |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
52 drupal_add_css(libraries_get_path("platin") . '/devel/css/platin.css'); |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
53 drupal_add_css(libraries_get_path("platin") . '/devel/css/style.css'); |
0 | 54 $task = page_manager_get_task('mpiwg_geobrowser_view'); |
3 | 55 dpm($task); |
0 | 56 ctools_include('context'); |
57 ctools_include('context-task-handler'); | |
58 | |
59 drupal_set_title($mpiwg_geobrowser->item_description); | |
3 | 60 dpm($mpiwg_geobrowser); |
0 | 61 $uri = entity_uri('mpiwg_geobrowser', $mpiwg_geobrowser); |
62 drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE); | |
63 drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); | |
64 $contexts = ctools_context_handler_get_task_contexts($task, '', array($mpiwg_geobrowser)); | |
65 $output = ctools_context_handler_render($task, '', $contexts, array($mpiwg_geobrowser->mpiwg_geobrowser_instance_id)); | |
3 | 66 dpm($contexts); |
67 dpm($output); | |
68 | |
0 | 69 $geoTemCoIntegration = ' |
70 <script type="text/javascript"> | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
71 |
0 | 72 var mpiwg_geobrowser_widgetsCount = 0; |
73 var mpiwg_geobrowser_widgetsLoaded = 0; | |
74 var mpiwg_geobrowser_noWidgetLoaded = true; | |
75 var widgetLoadedEvent = new Event("mpiwg_geobrowser_widget_loaded"); | |
76 var allWidgetsLoadedEvent = new Event("mpiwg_geobrowser_all_widgets_loaded"); | |
77 | |
78 Drupal.behaviors.mpiwg_geobrowser_entity = { | |
79 attach: function (context, settings) { | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
80 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
81 // jQuery(document).ready(function(){ |
0 | 82 if (context[0] !== undefined && context[0].attributes !== undefined) { |
83 var contextAttributes = context[0].attributes; | |
84 for (i=0; i<contextAttributes.length; i++) { | |
85 if (contextAttributes[i].name == "id" && contextAttributes[i].value == "panels-ipe-edit-control-form") { | |
86 window.location.reload(); | |
87 } | |
88 } | |
89 } | |
90 | |
91 document.addEventListener("mpiwg_geobrowser_widget_loaded", function (e) { | |
92 if (mpiwg_geobrowser_noWidgetLoaded) { | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
93 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
94 mpiwg_geobrowser_widgetsCount = mpiwg_geobrowser_widgetsCount; |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
95 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
96 |
0 | 97 mpiwg_geobrowser_noWidgetLoaded = false; |
98 } | |
99 mpiwg_geobrowser_widgetsLoaded++; | |
100 if (mpiwg_geobrowser_widgetsLoaded == mpiwg_geobrowser_widgetsCount) { | |
101 document.dispatchEvent(allWidgetsLoadedEvent); | |
102 } | |
103 }, false); | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
104 // }); |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
105 |
0 | 106 } |
107 } | |
108 </script> | |
109 '; | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
110 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
111 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
112 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
113 if (isset($output["content"])){ //unterschiedliches Verhalten, je nach dem ob der Inhalt noch in einen admin rahmen eingebettet ist |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
114 //$output["content"]["#markup"] = $geoTemCoIntegration . $output["content"]["#markup"]; |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
115 $output["content"]["#markup"] = $geoTemCoIntegration . $output["content"]["#markup"]; |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
116 |
0 | 117 if ($output != FALSE) { |
118 return $output; | |
119 } | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
120 } else { |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
121 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
122 return $geoTemCoIntegration . $output; |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
123 } |
0 | 124 |
125 $function = 'mpiwg_geobrowser_page_view'; | |
126 foreach (module_implements('mpiwg_geobrowser_override') as $module) { | |
127 $call = $module . '_mpiwg_geobrowser_override'; | |
128 if (($rc = $call('mpiwg_geobrowser_view')) && function_exists($rc)) { | |
129 $function = $rc; | |
130 break; | |
131 } | |
132 } | |
133 | |
134 return $function($mpiwg_geobrowser); | |
135 } | |
136 | |
137 function mpiwg_geobrowser_mpiwg_geobrowser_view_get_arguments($task, $subtask_id) { | |
138 return array( | |
139 array( | |
140 'keyword' => 'mpiwg_geobrowser', | |
141 'identifier' => t('mpiwg_geobrowser being viewed'), | |
142 'id' => 1, | |
143 'name' => 'entity_id:mpiwg_geobrowser', | |
144 'settings' => array(), | |
145 ), | |
146 ); | |
147 } | |
148 | |
149 function mpiwg_geobrowser_mpiwg_geobrowser_view_get_contexts($task, $subtask_id) { | |
150 return ctools_context_get_placeholders_from_argument(mpiwg_geobrowser_mpiwg_geobrowser_view_get_arguments($task, $subtask_id)); | |
151 } | |
152 | |
153 function mpiwg_geobrowser_mpiwg_geobrowser_view_enable($cache, $status) { | |
154 variable_set('mpiwg_geobrowser_mpiwg_geobrowser_view_disabled', $status); | |
155 | |
156 if (!$status) { | |
157 $GLOBALS['mpiwg_geobrowser_enabling_mpiwg_geobrowser_view'] = TRUE; | |
158 } | |
159 } | |
160 | |
161 function mpiwg_geobrowser_mpiwg_geobrowser_view_access_check($task, $subtask_id, $contexts) { | |
162 $context = reset($contexts); | |
163 return mpiwg_geobrowser_access('view', $context->data); | |
164 } |