Beispiel #1
0
 /**
  * Pull data from currently loaded page into the context.
  */
 public function populate_environment_data()
 {
     $page_data = array();
     $mc = midgard_page::new_collector('id', $_MIDGARD['page']);
     $mc->set_key_property('guid');
     $mc->add_value_property('title');
     $mc->add_value_property('content');
     $mc->add_value_property('component');
     // Style handling
     $style_id = $_MIDGARD['style'];
     $mc->add_value_property('style');
     $mc->execute();
     $guids = $mc->list_keys();
     foreach ($guids as $guid => $array) {
         $page_data['guid'] = $guid;
         $page_data['title'] = $mc->get_subkey($guid, 'title');
         $page_data['content'] = $mc->get_subkey($guid, 'content');
         $page_style = $mc->get_subkey($guid, 'style');
         if ($page_style) {
             $style_id = $page_style;
         }
         $_MIDCOM->context->component = $mc->get_subkey($guid, 'component');
     }
     $_MIDCOM->context->page = $page_data;
     $_MIDCOM->context->prefix = $_MIDGARD['self'];
     // Append styles from context
     $_MIDCOM->templating->append_style($style_id);
     $_MIDCOM->templating->append_page($_MIDGARD['page']);
     // Populate page to toolbar
     $this->populate_node_toolbar();
 }
Beispiel #2
0
 protected function _get_children($parent_id)
 {
     $mc = midgard_page::new_collector('up', $parent_id);
     $mc->set_key_property('id');
     $mc->add_value_property('id');
     $mc->add_value_property('name');
     $mc->add_value_property('title');
     $mc->add_value_property('component');
     $mc->execute();
     $child_ids = $mc->list_keys();
     $children = array();
     foreach ($child_ids as $cid => $data) {
         $children[] = $this->_prepare_page_data($mc->get_subkey($cid, 'id'), $mc->get_subkey($cid, 'name'), $mc->get_subkey($cid, 'title'), $mc->get_subkey($cid, 'component'));
     }
     return $children;
 }
Beispiel #3
0
 private function get_element_page($page_id, $element)
 {
     switch ($element) {
         case 'title':
         case 'content':
             $mc = midgard_page::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 = midgard_pageelement::new_collector('page', $page_id);
             $mc->add_constraint('name', '=', $element);
             $mc->set_key_property('value');
             $mc->execute();
             $keys = $mc->list_keys();
             if (count($keys) == 0) {
                 return null;
             }
             foreach ($keys as $value => $array) {
                 return $value;
             }
     }
 }
Beispiel #4
0
 private function get_page_prefix()
 {
     if (!$this->page) {
         throw new Exception("No page set for the manual dispatcher");
     }
     $prefix = "{$_MIDGARD['prefix']}/";
     $host_mc = midgard_host::new_collector('id', $_MIDGARD['host']);
     $host_mc->set_key_property('root');
     $host_mc->execute();
     $roots = $host_mc->list_keys();
     if (!$roots) {
         throw new Exception("Failed to load root page data for host {$_MIDGARD['host']}");
     }
     $root_id = null;
     foreach ($roots as $root => $array) {
         $root_id = $root;
         break;
     }
     if ($this->page->id == $root_id) {
         return $prefix;
     }
     $page_path = '';
     $page_id = $this->page->id;
     while ($page_id && $page_id != $root_id) {
         $parent_mc = midgard_page::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}";
         }
     }
     return $prefix . $page_path;
 }