Mercurial > hg > mpiwg_geobrowser
annotate plugins/tasks/mpiwg_geobrowser_view.inc @ 1:ea066ce001bd
bug fixes, works now without admin rights
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 29 May 2015 13:59:32 +0200 |
parents | b57c7821382f |
children | 1b6cde0e4b83 |
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) { | |
46 drupal_add_css(drupal_get_path('module', 'mpiwg_geobrowser') . '/css/mpiwg_geobrowser_style.css', array('group' => CSS_DEFAULT, 'type' => 'file')); | |
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'); |
55 | |
56 ctools_include('context'); | |
57 ctools_include('context-task-handler'); | |
58 | |
59 drupal_set_title($mpiwg_geobrowser->item_description); | |
60 $uri = entity_uri('mpiwg_geobrowser', $mpiwg_geobrowser); | |
61 drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE); | |
62 drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); | |
63 $contexts = ctools_context_handler_get_task_contexts($task, '', array($mpiwg_geobrowser)); | |
64 $output = ctools_context_handler_render($task, '', $contexts, array($mpiwg_geobrowser->mpiwg_geobrowser_instance_id)); | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
65 |
0 | 66 $geoTemCoIntegration = ' |
67 <script type="text/javascript"> | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
68 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
69 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
70 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
71 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
72 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
73 |
0 | 74 var mpiwg_geobrowser_widgetsCount = 0; |
75 var mpiwg_geobrowser_widgetsLoaded = 0; | |
76 var mpiwg_geobrowser_noWidgetLoaded = true; | |
77 var widgetLoadedEvent = new Event("mpiwg_geobrowser_widget_loaded"); | |
78 var allWidgetsLoadedEvent = new Event("mpiwg_geobrowser_all_widgets_loaded"); | |
79 | |
80 Drupal.behaviors.mpiwg_geobrowser_entity = { | |
81 attach: function (context, settings) { | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
82 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
83 // jQuery(document).ready(function(){ |
0 | 84 if (context[0] !== undefined && context[0].attributes !== undefined) { |
85 var contextAttributes = context[0].attributes; | |
86 for (i=0; i<contextAttributes.length; i++) { | |
87 if (contextAttributes[i].name == "id" && contextAttributes[i].value == "panels-ipe-edit-control-form") { | |
88 window.location.reload(); | |
89 } | |
90 } | |
91 } | |
92 | |
93 document.addEventListener("mpiwg_geobrowser_widget_loaded", function (e) { | |
94 if (mpiwg_geobrowser_noWidgetLoaded) { | |
1
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 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
|
97 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
98 |
0 | 99 mpiwg_geobrowser_noWidgetLoaded = false; |
100 } | |
101 mpiwg_geobrowser_widgetsLoaded++; | |
102 if (mpiwg_geobrowser_widgetsLoaded == mpiwg_geobrowser_widgetsCount) { | |
103 document.dispatchEvent(allWidgetsLoadedEvent); | |
104 } | |
105 }, false); | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
106 // }); |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
107 |
0 | 108 } |
109 } | |
110 </script> | |
111 '; | |
1
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 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
114 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
115 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
|
116 //$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
|
117 $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
|
118 |
0 | 119 if ($output != FALSE) { |
120 return $output; | |
121 } | |
1
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
122 } else { |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
123 |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
124 return $geoTemCoIntegration . $output; |
ea066ce001bd
bug fixes, works now without admin rights
Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
125 } |
0 | 126 |
127 $function = 'mpiwg_geobrowser_page_view'; | |
128 foreach (module_implements('mpiwg_geobrowser_override') as $module) { | |
129 $call = $module . '_mpiwg_geobrowser_override'; | |
130 if (($rc = $call('mpiwg_geobrowser_view')) && function_exists($rc)) { | |
131 $function = $rc; | |
132 break; | |
133 } | |
134 } | |
135 | |
136 return $function($mpiwg_geobrowser); | |
137 } | |
138 | |
139 function mpiwg_geobrowser_mpiwg_geobrowser_view_get_arguments($task, $subtask_id) { | |
140 return array( | |
141 array( | |
142 'keyword' => 'mpiwg_geobrowser', | |
143 'identifier' => t('mpiwg_geobrowser being viewed'), | |
144 'id' => 1, | |
145 'name' => 'entity_id:mpiwg_geobrowser', | |
146 'settings' => array(), | |
147 ), | |
148 ); | |
149 } | |
150 | |
151 function mpiwg_geobrowser_mpiwg_geobrowser_view_get_contexts($task, $subtask_id) { | |
152 return ctools_context_get_placeholders_from_argument(mpiwg_geobrowser_mpiwg_geobrowser_view_get_arguments($task, $subtask_id)); | |
153 } | |
154 | |
155 function mpiwg_geobrowser_mpiwg_geobrowser_view_enable($cache, $status) { | |
156 variable_set('mpiwg_geobrowser_mpiwg_geobrowser_view_disabled', $status); | |
157 | |
158 if (!$status) { | |
159 $GLOBALS['mpiwg_geobrowser_enabling_mpiwg_geobrowser_view'] = TRUE; | |
160 } | |
161 } | |
162 | |
163 function mpiwg_geobrowser_mpiwg_geobrowser_view_access_check($task, $subtask_id, $contexts) { | |
164 $context = reset($contexts); | |
165 return mpiwg_geobrowser_access('view', $context->data); | |
166 } |