Changeset 13068

Show
Ignore:
Timestamp:
10/24/07 17:40:44 (1 year ago)
Author:
juhana
Message:

Enhancements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/data/midgard_admin_sitewizard_creator_host.php

    r12966 r13068  
    3030     
    3131    private $page_title = ''; 
     32     
     33    private $copy_host = null; 
     34     
     35    private $make_host_copy = false; 
     36     
     37    private $copy_host_url = ''; 
     38     
     39    private $copy_host_prefix = ''; 
     40     
     41    private $copy_host_port = ''; 
    3242       
    3343 
     
    8595                $extend_style->sitegroup = $this->sitegroup->id; 
    8696                $extend_style->name = sprintf('%s for %s', $styles[0]->name,  
    87                     $this->host_url . str_replace('/', ':', $this->host_prefix)); 
     97                $this->host_url . str_replace('/', ':', $this->host_prefix)); 
    8898                              
    8999                if (!$extend_style->create()) 
     
    120130    } 
    121131     
     132    private function copy_host() 
     133    { 
     134        $this->verbose("Starting to create copy host for sitegroup GUID: " . $this->sitegroup->guid); 
     135     
     136        $this->copy_host = new midgard_host(); 
     137        $this->copy_host->sitegroup = $this->host->sitegroup; 
     138         
     139        if (!empty($this->copy_host_url)) 
     140        { 
     141            $this->copy_host->name = $this->copy_host_url; 
     142        } 
     143        else 
     144        { 
     145            $this->copy_host->name = $this->host->name; 
     146        } 
     147         
     148        if (!empty($this->copy_host_port)) 
     149        { 
     150            $this->copy_host->port = $this->copy_host_port; 
     151        } 
     152        else 
     153        { 
     154            $this->copy_host->name = $this->host->port; 
     155        } 
     156         
     157        if (!empty($this->copy_host_prefix)) 
     158        { 
     159            $this->copy_host->prefix = $this->copy_host_prefix; 
     160        } 
     161        else 
     162        { 
     163            $this->copy_host->prefix = $this->host->prefix; 
     164        } 
     165        $this->copy_host->online = 1; 
     166        $this->copy_host->owner = $this->host->owner; 
     167        $this->copy_host->style = $this->host->style; 
     168        $this->copy_host->root = $this->host->root; 
     169         
     170        if (!$this->copy_host->create()) 
     171        { 
     172            throw new midgard_admin_sitewizard_exception("Failed to create host copy of host GUID "  
     173                . $this->shost->guid); 
     174        } 
     175    } 
     176     
    122177    private function create_root_page() 
    123178    { 
     
    128183        $this->root_page->up = 0; 
    129184        $this->root_page->name = $this->host->name . $this->host->prefix . " root"; 
     185        $this->root_page->content = "<?php \$_MIDCOM->content(); ?>\n"; 
     186        $this->root_page->author = 1; 
     187        $this->root_page->info = 'active'; 
    130188         
    131189        if ($this->page_title == '') 
     
    148206         
    149207            $this->host->root = $this->root_page->id; 
     208             
     209            $code_finish = new midgard_pageelement(); 
     210            $code_finish->name = "code-finish"; 
     211            $code_finish->page = $this->root_page->id; 
     212            $code_finish->info = 'inherit'; 
     213            $code_finish->value = "<?php \$_MIDCOM->finish(); ?>\n"; 
     214             
     215            if (!$code_finish->create()) 
     216            { 
     217                throw new midgard_admin_sitewizard_exception("Failed to create code-finish. Reason: "  
     218                    . mgd_errstr());             
     219            } 
    150220 
    151221            if (!$this->host->update()) 
     
    194264    { 
    195265        $this->page_title = $page_title; 
     266    } 
     267     
     268    public function set_make_host_copy($make_host_copy) 
     269    { 
     270        $this->make_host_copy = $make_host_copy; 
     271    } 
     272     
     273    public function set_copy_host_url($url) 
     274    { 
     275        $this->copy_host_url = $url; 
     276    } 
     277     
     278    public function set_copy_host_port($port) 
     279    { 
     280        $this->copy_host_port = $port; 
     281    } 
     282     
     283    public function set_copy_host_prefix($prefix) 
     284    { 
     285        $this->copy_host_prefix = $prefix; 
    196286    } 
    197287     
     
    267357                $this->create_host(); 
    268358                $this->create_root_page(); 
     359                 
     360                if ($this->make_host_copy) 
     361            { 
     362                $this->copy_host(); 
     363            } 
    269364 
    270365                $this->verbose("Sitewizard created host successfully."); 
  • trunk/midgard/data/midgard_admin_sitewizard_creator_structure.php

    r12966 r13068  
    3535     
    3636    private $schemavalues = array(); 
     37     
     38    private $midcom_path = ''; 
    3739 
    3840    public function __construct($parent_link = null) 
     
    159161        $article->title = $title; 
    160162        $article->name = 'index'; 
     163        $article->sitegroup = $this->sitegroup->id; 
    161164         
    162165        if (!$article->create()) 
     
    493496            $this->creation_root_topic->extra = $this->replace($this->structure['root']['title']);  
    494497            $this->creation_root_topic->name = $this->replace($this->structure['root']['name']); 
     498            $this->creation_root_topic->component = $this->structure['root']['component']; 
    495499             
    496500            if (isset($node['root']['style']) && !empty($node['root']['style'])) 
     
    530534                if (isset($this->structure['root']['create_index']) && $this->structure['root']['create_index'] == true) 
    531535                { 
    532                     $this->create_index_article($this->creation_root_topic->id, $this->replace($node['root']['title'])); 
     536                    $this->create_index_article($this->creation_root_topic->id, $this->replace($this->structure['root']['title'])); 
    533537                } 
    534538            } 
     
    724728        return $this->creation_root_group; 
    725729    }    
     730     
     731    public function set_midcom_path($path) 
     732    { 
     733        $this->midcom_path = $path; 
     734    } 
     735     
     736    private function create_code_init() 
     737    { 
     738        $code_init = new midgard_pageelement(); 
     739        $code_init->name = 'code-init'; 
     740        $code_init->page = $this->root_page->id; 
     741        $code_init->info = 'inherit'; 
     742        $code_init->value = "<?php 
     743             
     744\$GLOBALS['midcom_config_local']['cache_base_directory'] = '/var/cache/midgard/midcom/'; 
     745\$GLOBALS['midcom_config_local']['log_filename'] = '/var/log/midgard/midcom/{$this->host->name}.log'; 
     746\$GLOBALS['midcom_config_local']['log_level'] = '0'; 
     747\$GLOBALS['midcom_config_local']['midcom_root_topic_guid'] = '{$this->creation_root_topic->guid}'; 
     748 
     749define ('MIDCOM_ROOT', '{$this->midcom_path}'); 
     750 
     751?><(code-init-before-midcom)><?php 
     752 
     753require 'midcom/lib/midcom.php'; 
     754 
     755?><(code-init-after-midcom)><?php 
     756 
     757\$_MIDCOM->codeinit(); 
     758             
     759?>"; 
     760         
     761        $code_init->create(); 
     762    } 
    726763 
    727764    public function execute() 
     
    756793            $this->create_group_structure(); 
    757794            $this->create_topic_structure(); 
     795            $this->create_code_init(); 
    758796 
    759797            $this->verbose("Sitewizard created website structure successfully.");