public
Description: Midgard Components Framework 3rd generation
Homepage: http://www.midgard-project.org
Clone URL: git://github.com/bergie/midcom.git
Proper environment data in Midgard 2
bergie (author)
Thu Apr 24 14:57:28 -0700 2008
commit  b0d820e66676171e50b55369b464e000b592d921
tree    e4e64ec1c748ba4a88c0c5c39deee9d1f6759e3f
parent  420d5799d47ed553e78ac07b45f038f1d548245c
...
5
6
7
8
 
9
10
11
12
13
14
15
16
17
18
19
 
 
 
 
 
20
21
22
23
 
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
39
40
41
42
 
 
43
44
45
46
47
48
49
50
51
52
53
54
 
 
 
55
...
5
6
7
 
8
9
 
 
 
 
 
 
 
 
 
 
10
11
12
13
14
15
 
 
 
16
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
20
21
 
 
 
22
23
24
 
 
 
 
 
 
 
 
 
 
25
26
27
28
29
0
@@ -5,49 +5,23 @@
0
  * @copyright The Midgard Project, http://www.midgard-project.org
0
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
0
  *
0
- * MidgardRootFile for running MidCOM 3 under Apache
0
+ * MidgardRootFile for running MidCOM 3 under FastCGI setups like lighttpd
0
  */
0
-// If code-compat is defined we use that, otherwise we load MidCOM 3
0
-if (mgd_is_element_loaded('code-compat'))
0
-{
0
- ?><(code-compat)><?php
0
-}
0
-else
0
-{
0
- // Note: your MidCOM base directory has to be in PHP include_path
0
- require('midcom_core/framework.php');
0
- $_MIDCOM = new midcom_core_midcom('midgard2');
0
+
0
+// Load MidCOM 3
0
+// Note: your MidCOM base directory has to be in PHP include_path
0
+require('midcom_core/framework.php');
0
+$_MIDCOM = new midcom_core_midcom('midgard2');
0
     
0
- // FIXME: Remove this once midgard_user::auth works in Midgard 2.x
0
- $_MIDCOM->authorization->enter_sudo('midcom_core');
0
-}
0
+// FIXME: Remove this once midgard_user::auth works in Midgard 2.x
0
+$_MIDCOM->authorization->enter_sudo('midcom_core');
0
 
0
-// code- elements used for things run before output
0
-if (mgd_is_element_loaded('code-global'))
0
-{
0
- ?><(code-global)><?php
0
-}
0
-if (mgd_is_element_loaded('code-init'))
0
-{
0
- ?><(code-init)><?php
0
-}
0
-elseif (isset($_MIDCOM))
0
-{
0
- // Call the controller if available
0
- $_MIDCOM->process();
0
-}
0
+// Process the request
0
+$_MIDCOM->process();
0
 
0
-if (isset($_MIDCOM))
0
-{
0
- $_MIDCOM->templating->template();
0
+// Prepare the template
0
+$_MIDCOM->templating->template();
0
 
0
- // Read contents from the output buffer and pass to MidCOM rendering
0
- $_MIDCOM->templating->display();
0
-}
0
-else
0
-{
0
- ?><(ROOT)><?php
0
-}
0
-// code-finish can be used for custom caching etc
0
-?>
0
-<(code-finish)>
0
\ No newline at end of file
0
+// Render the template
0
+$_MIDCOM->templating->display();
0
+?>
0
\ No newline at end of file
...
92
93
94
95
 
96
97
98
...
92
93
94
 
95
96
97
98
0
@@ -92,7 +92,7 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
         $this->populate_node_toolbar();
0
     }
0
     
0
- private function populate_node_toolbar()
0
+ protected function populate_node_toolbar()
0
     {
0
         $_MIDCOM->toolbar->add_item
0
         (
...
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
0
@@ -29,5 +29,39 @@ class midcom_core_services_dispatcher_midgard2 extends midcom_core_services_disp
0
 
0
         $this->argv = $_MIDGARD_CONNECTION->request_config->argv;
0
     }
0
+
0
+ /**
0
+ * Pull data from currently loaded page into the context.
0
+ */
0
+ public function populate_environment_data()
0
+ {
0
+ $page_data = array();
0
+
0
+ $prefix = "{$_MIDGARD_CONNECTION->request_config->host->prefix}/";
0
+ foreach ($_MIDGARD_CONNECTION->request_config->pages as $page)
0
+ {
0
+ if ($page->id != $_MIDGARD_CONNECTION->request_config->host->root)
0
+ {
0
+ $prefix = "{$prefix}{$page->name}/";
0
+ }
0
+ $current_page = $page;
0
+ }
0
+
0
+ $page_data['guid'] = $current_page->guid;
0
+ $page_data['title'] = $current_page->title;
0
+ $page_data['content'] = $current_page->content;
0
+
0
+ $_MIDCOM->context->component = $current_page->component;
0
+
0
+ $_MIDCOM->context->page = $page_data;
0
+ $_MIDCOM->context->prefix = $prefix;
0
+
0
+ // Append styles from context
0
+ $_MIDCOM->templating->append_style($_MIDGARD_CONNECTION->request_config->style->id);
0
+ $_MIDCOM->templating->append_page($current_page->id);
0
+
0
+ // Populate page to toolbar
0
+ $this->populate_node_toolbar();
0
+ }
0
 }
0
 ?>
0
\ No newline at end of file

Comments

    No one has commented yet.