Beispiel #1
0
 private function get_element_page($page_id, $element)
 {
     switch ($element) {
         case 'title':
         case 'content':
             $mc = midgardmvc_core_node::new_collector('id', $page_id);
             $mc->set_key_property($element);
             $mc->execute();
             $keys = $mc->list_keys();
             if (count($keys) == 0) {
                 return null;
             }
             foreach ($keys as $value => $array) {
                 return $value;
             }
         default:
             $mc = midgardmvc_core_node_template::new_collector('node', $page_id);
             $mc->add_constraint('name', '=', $element);
             $mc->set_key_property('content');
             $mc->add_value_property('guid');
             $mc->execute();
             $keys = $mc->list_keys();
             if (count($keys) == 0) {
                 return null;
             }
             foreach ($keys as $value => $array) {
                 // Register element to template cache
                 $this->midgardmvc->cache->template->register($this->get_cache_identifier(), array($mc->get_subkey($value, 'guid')));
                 return $value;
             }
     }
 }
Beispiel #2
0
 private function get_node_children(midgardmvc_core_node $node)
 {
     // Load children for PROPFIND purposes
     $children = array();
     $mc = midgardmvc_core_node::new_collector('up', $node->id);
     $mc->set_key_property('name');
     $mc->add_value_property('title');
     $mc->execute();
     $pages = $mc->list_keys();
     foreach ($pages as $name => $array) {
         if (empty($name)) {
             continue;
         }
         $children[] = array('uri' => "{midgardmvc_core::get_instance()->context->prefix}{$name}/", 'title' => $mc->get_subkey($name, 'title'), 'mimetype' => 'httpd/unix-directory', 'resource' => 'collection');
     }
     if (midgardmvc_core::get_instance()->context->page->id == midgardmvc_core::get_instance()->context->root_page->id) {
         // Additional "special" URLs
         $children[] = array('uri' => "{midgardmvc_core::get_instance()->context->prefix}mgd:snippets/", 'title' => 'Code Snippets', 'mimetype' => 'httpd/unix-directory', 'resource' => 'collection');
         $children[] = array('uri' => "{midgardmvc_core::get_instance()->context->prefix}mgd:styles/", 'title' => 'Style Templates', 'mimetype' => 'httpd/unix-directory', 'resource' => 'collection');
     }
     return $children;
 }
Beispiel #3
0
 private function get_page_prefix()
 {
     $context = $this->midgardmvc->context;
     if (!$context->page) {
         throw new Exception("No page set for the manual dispatcher");
     }
     static $prefixes = array();
     if (isset($prefixes[$context->page->id])) {
         return $prefixes[$context->page->id];
     }
     $prefix = '/';
     $root_id = 0;
     if (isset($context->host)) {
         $host_mc = midgard_host::new_collector('id', $context->host->id);
         $host_mc->set_key_property('root');
         $host_mc->add_value_property('prefix');
         $host_mc->execute();
         $roots = $host_mc->list_keys();
         if (!$roots) {
             throw new Exception("Failed to load root page data for host {$context->host->id}");
         }
         $root_id = null;
         foreach ($roots as $root => $array) {
             $root_id = $root;
             $prefix = $host_mc->get_subkey($root, 'prefix') . '/';
             break;
         }
     }
     $root_id = $this->midgardmvc->context->root_page->id;
     if ($context->page->id == $root_id) {
         // We're requesting prefix for the root page
         $prefixes[$context->page->id] = $prefix;
         return $prefix;
     }
     $page_path = '';
     $page_id = $context->page->id;
     while ($page_id && $page_id != $root_id) {
         $parent_mc = midgardmvc_core_node::new_collector('id', $page_id);
         $parent_mc->set_key_property('up');
         $parent_mc->add_value_property('name');
         $parent_mc->execute();
         $parents = $parent_mc->list_keys();
         foreach ($parents as $parent => $array) {
             $page_id = $parent;
             $page_path = $parent_mc->get_subkey($parent, 'name') . "/{$page_path}";
         }
     }
     $prefixes[$context->page->id] = $prefix . $page_path;
     return $prefix . $page_path;
 }