public
Description: Midgard Components Framework 3rd generation
Homepage: http://www.midgard-project.org
Clone URL: git://github.com/bergie/midcom.git
Refactored PROPFIND to get data from controller and component instance
bergie (author)
Fri Jun 27 04:52:57 -0700 2008
commit  a34614e25e8c509b727d9d678a8aa26ef6e66d7a
tree    9b5c105cdb8e0a9b8b2fa9d22327ef9ba8dd8c48
parent  b3622d5782fbc3f32c5127bb2d02f3293b5ddfee
...
33
34
35
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
38
39
40
...
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
0
@@ -33,7 +33,29 @@ abstract class midcom_core_component_baseclass implements midcom_core_component_
0
     
0
     public function get_node_children(midgard_page $node)
0
     {
0
- return array();
0
+ // Load children for PROPFIND purposes
0
+ $children = array();
0
+ $mc = midgard_page::new_collector('up', $_MIDCOM->context->page['id']);
0
+ $mc->set_key_property('name');
0
+ $mc->add_value_property('title');
0
+ $mc->execute();
0
+ $pages = $mc->list_keys();
0
+ foreach ($pages as $name => $array)
0
+ {
0
+ if (empty($name))
0
+ {
0
+ continue;
0
+ }
0
+ $children[] = array
0
+ (
0
+ 'uri' => "{$_MIDCOM->context->prefix}{$name}/", // FIXME: dispatcher::generate_url
0
+ 'title' => $mc->get_subkey($name, 'title'),
0
+ 'mimetype' => 'httpd/unix-directory',
0
+ 'resource' => 'collection',
0
+ );
0
+ }
0
+
0
+ return $children;
0
     }
0
 }
0
 ?>
0
\ No newline at end of file
...
49
50
51
52
53
54
55
...
49
50
51
 
52
53
54
0
@@ -49,6 +49,5 @@ class midcom_core_controllers_page extends midcom_core_controllers_baseclasses_m
0
     public function populate_toolbar()
0
     {
0
     }
0
-
0
 }
0
 ?>
0
\ No newline at end of file
...
78
79
80
81
82
 
 
 
 
 
 
83
84
 
85
86
87
 
 
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
 
 
 
 
 
 
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
 
 
 
 
143
144
145
146
 
 
147
148
149
150
151
152
153
154
 
155
156
157
158
159
160
161
162
163
164
165
 
 
 
 
 
 
 
 
 
166
167
168
169
170
171
172
173
174
175
176
177
 
178
179
180
...
78
79
80
 
 
81
82
83
84
85
86
87
 
88
89
 
 
90
91
92
 
 
 
 
 
 
 
 
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
95
96
97
98
99
100
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
103
104
105
106
 
 
 
107
108
109
 
 
 
 
 
 
 
110
111
 
 
 
 
 
 
 
 
 
 
112
113
114
115
116
117
118
119
120
121
122
 
 
 
 
 
 
 
 
 
 
123
124
125
126
0
@@ -78,103 +78,49 @@ class midcom_core_helpers_webdav extends HTTP_WebDAV_Server
0
     function PROPFIND(&$options, &$files)
0
     {
0
         $_MIDCOM->authorization->require_user();
0
-
0
- $info = $this->get_path_info();
0
+
0
+ // Run the controller
0
+ $controller = $this->controller;
0
+ $action_method = $this->action_method;
0
+ $data = array();
0
+ $controller->$action_method($this->route_id, $data, $this->action_arguments);
0
         
0
- if (is_null($info['object']))
0
+ if (!isset($data['children']))
0
         {
0
- $this->logger->log("404 Not Found");
0
- throw new midcom_exception_notfound("Not found");
0
+ // Controller did not return children
0
+ $data['children'] = array();
0
         }
0
-
0
- /*if (substr($_MIDCOM->dispatcher->argv[0], 0, 1) == '.')
0
- {
0
- $this->logger->log("Skipping dotfile, object is {$info['object']->guid}");
0
- throw new midcom_exception_notfound("No dotfiles please");
0
- }*/
0
-
0
- $this->get_files_page($info['object'], &$files);
0
         
0
- return true;
0
- }
0
-
0
- private function get_files_page($page, &$files)
0
- {
0
- // Add the downloadable page itself
0
- $conf = $this->get_files_stub();
0
- $conf['props'][] = $this->mkprop('displayname', $page->title);
0
- $conf['props'][] = $this->mkprop('resourcetype', '');
0
- $conf['props'][] = $this->mkprop('getcontenttype', 'text/html');
0
- $conf['props'][] = $this->mkprop('getcontentlength', strlen($page->content));
0
- $conf['props'][] = $this->mkprop('getlastmodified', strtotime($page->metadata->revised));
0
- $conf['path'] = "{$_MIDCOM->context->prefix}__content.html";
0
- $files['files'][] = $conf;
0
-
0
- /*
0
- $conf = $this->get_files_stub();
0
- $conf['props'][] = $this->mkprop('displayname', $page->title);
0
- $conf['props'][] = $this->mkprop('resourcetype', '');
0
- $conf['props'][] = $this->mkprop('getcontenttype', 'text/xml');
0
- //$conf['props'][] = $this->mkprop('getcontentlength', strlen($page->serialize()));
0
- $conf['props'][] = $this->mkprop('getlastmodified', strtotime($page->metadata->revised));
0
- $conf['path'] = "{$_MIDCOM->context->prefix}__midgard_page.xml";
0
- $files['files'][] = $conf;
0
- */
0
-
0
- $mc = midgard_page::new_collector('up', $page->id);
0
- $mc->set_key_property('name');
0
- $mc->add_value_property('title');
0
- $mc->execute();
0
+ // Get children from component instance
0
+ $page = new midgard_page($_MIDCOM->context->page['guid']);
0
+ $data['children'] = array_merge
0
+ (
0
+ $data['children'],
0
+ $_MIDCOM->context->component_instance->get_node_children($page)
0
+ );
0
         
0
- $guids = $mc->list_keys();
0
- foreach ($guids as $name => $array)
0
- {
0
- if (empty($name))
0
- {
0
- continue;
0
- }
0
- $subpage = $this->get_files_stub();
0
- $subpage['props'][] = $this->mkprop('displayname', $mc->get_subkey($name, 'title'));
0
- $subpage['props'][] = $this->mkprop('resourcetype', 'collection');
0
- $subpage['props'][] = $this->mkprop('getcontenttype', 'httpd/unix-directory');
0
- $subpage['path'] = "{$_MIDCOM->context->prefix}{$name}/";
0
- $files['files'][] = $subpage;
0
- }
0
+ // Convert children to PROPFIND elements
0
+ $this->children_to_files($data['children'], &$files);
0
+
0
+ return true;
0
     }
0
-
0
- /*
0
- private function get_files_snippetdir($snippetdir_id, &$files)
0
+
0
+ private function children_to_files($children, &$files)
0
     {
0
- $this->logger->log("Snippetdir {$snippetdir_id}");
0
- $mc = midgard_snippetdir::new_collector('up', $snippetdir_id);
0
- $mc->set_key_property('name');
0
- $mc->execute();
0
-
0
- $guids = $mc->list_keys();
0
- foreach ($guids as $name => $array)
0
+ foreach ($children as $child)
0
         {
0
- if (empty($name))
0
- {
0
- continue;
0
- }
0
- $page = $this->get_files_stub();
0
- $page['props'][] = $this->mkprop('displayname', $name);
0
- $page['props'][] = $this->mkprop('resourcetype', 'collection');
0
- $page['props'][] = $this->mkprop('getcontenttype', 'httpd/unix-directory');
0
- $page['path'] = "{$_MIDCOM->context->prefix}__snippets/{$name}/";
0
- $files['files'][] = $page;
0
+ $child_props = array
0
+ (
0
+ 'props' => array(),
0
+ 'path' => $child['uri'],
0
+ );
0
+ $child_props['props'][] = $this->mkprop('displayname', $child['title']);
0
+ $child_props['props'][] = $this->mkprop('resourcetype', $child['resource']);
0
+ $child_props['props'][] = $this->mkprop('getcontenttype', $child['mimetype']);
0
+ $files['files'][] = $child_props;
0
         }
0
     }
0
- */
0
- private function get_files_stub()
0
- {
0
- return array
0
- (
0
- 'props' => array(),
0
- 'path' => array(),
0
- );
0
- }
0
-
0
+
0
     /**
0
      * GET method handler
0
      *
...
8
9
10
 
 
 
 
11
12
13
...
8
9
10
11
12
13
14
15
16
17
0
@@ -8,6 +8,10 @@ routes:
0
         action: latest
0
         route: /
0
         content_entry_point: nnn-show-latest
0
+ allowed_methods:
0
+ - OPTIONS
0
+ - GET
0
+ - PROPFIND
0
     latest:
0
         controller: net_nemein_news_controllers_index
0
         action: latest

Comments

    No one has commented yet.