예제 #1
0
 public function prepare_stack(midgardmvc_core_helpers_request $request)
 {
     // Set up initial templating stack
     if ($this->midgardmvc->configuration->services_templating_components && is_array($this->midgardmvc->configuration->services_templating_components)) {
         foreach ($this->midgardmvc->configuration->services_templating_components as $templating_component) {
             $this->midgardmvc->templating->append_directory($this->midgardmvc->componentloader->component_to_filepath($templating_component) . '/templates');
         }
     }
     // Add component (tree) to templating stack
     $components = $this->midgardmvc->componentloader->get_tree($request->get_component());
     if (count($components) == 1) {
         // This component doesn't inherit anything
         if (!in_array($request->get_component(), $this->midgardmvc->configuration->services_templating_components)) {
             $this->midgardmvc->templating->append_directory($this->midgardmvc->componentloader->component_to_filepath($this->midgardmvc->context->component) . '/templates');
         }
     } else {
         $components = array_reverse($components);
         foreach ($components as $component) {
             // Walk through the inheritance tree and add all components to stack
             if (!in_array($component, $this->midgardmvc->configuration->services_templating_components)) {
                 $this->midgardmvc->templating->append_directory($this->midgardmvc->componentloader->component_to_filepath($component) . '/templates');
             }
         }
     }
     if ($this->midgardmvc->configuration->services_templating_database_enabled) {
         // Add style and page to templating stack
         if (isset($this->midgardmvc->context->templatedir_id) && $this->midgardmvc->context->templatedir_id) {
             $this->midgardmvc->templating->append_style($this->midgardmvc->context->templatedir_id);
         }
         if (isset($this->midgardmvc->context->page) && $this->midgardmvc->context->page) {
             $this->midgardmvc->templating->append_page($this->midgardmvc->context->page->id);
         }
     }
 }
예제 #2
0
 public function initialize(midgardmvc_core_helpers_request $request)
 {
     // In main Midgard request we dispatch the component in connection to a page
     $this->midgardmvc->context->component = $request->get_component();
     $this->midgardmvc->context->component_instance = $this->midgardmvc->componentloader->load($this->midgardmvc->context->component);
     $this->midgardmvc->templating->prepare_stack($request);
 }