Changeset 22748
- Timestamp:
- 06/30/09 17:13:39 (9 months ago)
- Files:
-
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator.php (modified) (3 diffs)
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_host.php (modified) (3 diffs)
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_sitegroup.php (modified) (3 diffs)
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_structure.php (modified) (12 diffs)
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_setup_app.php (modified) (6 diffs)
- branches/ragnaroek/midgard/data/midgard/setup/php/midgard_setup_wizard.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator.php
r17512 r22748 21 21 protected $links = array(); 22 22 23 protected $sitegroup = null; 24 25 protected $sitegroup_name = null; 26 23 27 public function __construct(midgard_setup_config &$config, $parent_link = null) 24 28 { … … 42 46 } 43 47 44 final function add_link($object)48 final public function add_link($object) 45 49 { 46 50 $this->links[] = $object; 47 51 } 48 52 49 final function cleanup_links()53 final public function cleanup_links() 50 54 { 51 55 if(empty($this->links)) … … 56 60 $link->cleanup(); 57 61 } 62 } 63 64 final public function set_sitegroup($identifier) 65 { 66 if($identifier == MIDGARD_SITEGROUP_0) 67 { 68 $this->sitegroup = new midgard_sitegroup(); 69 $this->sitegroup->name = null; 70 71 $this->sitegroup_name = null; 72 73 return; 74 } 75 76 if($this->sitegroup == null) 77 { 78 try 79 { 80 $this->sitegroup = new midgard_sitegroup($identifier); 81 } 82 catch (midgard_error_exception $e) { 83 84 $this->sitegroup = new midgard_sitegroup(); 85 $this->sitegroup_name = $this->sitegroup->name; 86 } 87 } 88 } 89 90 final public function get_sitegroup() 91 { 92 return $this->sitegroup; 58 93 } 59 94 branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_host.php
r20751 r22748 14 14 15 15 final class midgard_admin_sitewizard_creator_host extends midgard_admin_sitewizard_creator 16 { 17 private $sitegroup = null; 18 16 { 19 17 private $host = null; 20 18 … … 257 255 if(!$created) 258 256 { 259 $this->setup_config->ui->warning(_("Failed to create root topic") );257 $this->setup_config->ui->warning(_("Failed to create root topic") . " " . midgard_connection::get_error_string()); 260 258 return FALSE; 261 259 } … … 505 503 return $this->host; 506 504 } 507 508 public function get_sitegroup() 509 { 510 return $this->sitegroup; 511 } 512 513 public function set_sitegroup(midgard_sitegroup $sitegroup) 514 { 515 $this->sitegroup = $sitegroup; 516 } 517 505 518 506 public function get_root_page() 519 507 { branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_sitegroup.php
r21945 r22748 13 13 14 14 class midgard_admin_sitewizard_creator_sitegroup extends midgard_admin_sitewizard_creator 15 { 16 private $sitegroup = null; 17 18 private $sitegroup_name = 'midgard-project.org'; 19 15 { 20 16 private $sitegroup_admin_username = 'admin'; 21 17 … … 39 35 // Do nothing 40 36 } 41 42 public function set_sitegroup_name($sitegroup_name) 43 { 44 $this->verbose("Setting new sitegroup name \"" . $sitegroup_name . "\""); 45 $this->sitegroup_name = $sitegroup_name; 46 47 if($sitegroup_name == MIDGARD_SITEGROUP_0) 48 { 49 $this->sitegroup = new midgard_sitegroup(); 50 $this->sitegroup->name = null; 51 52 $this->sitegroup_name = null; 53 54 return; 55 } 56 57 if($this->sitegroup == null) 58 { 59 try 60 { 61 $sg = new midgard_sitegroup($sitegroup_name); 62 } 63 catch (midgard_error_exception $e) { 64 65 /* We're in creation mode (probably). */ 66 $sg = new midgard_sitegroup(); 67 $sg->name = $sitegroup_name; 68 } 69 70 $this->sitegroup = $sg; 71 } 72 } 73 37 74 38 public function set_sitegroup_admin_username($admin_name) 75 39 { … … 186 150 } 187 151 } 188 189 public function get_sitegroup() 190 { 191 return $this->sitegroup; 192 } 193 152 194 153 /** 195 154 * Check if the user is in sitegroup zero. branches/ragnaroek/midgard/data/midgard/setup/php/midgard_admin_sitewizard_creator_structure.php
r22737 r22748 24 24 private $host_creator = null; 25 25 26 private $root_topic_name = null; 27 26 28 private $root_topic = null; 27 29 … … 31 33 32 34 private $creation_root_group = null; 33 34 private $sitegroup = null;35 35 36 36 private $config = null; … … 110 110 } 111 111 } 112 112 113 public function set_root_topic_name($name) 114 { 115 /* Should be null special, not allowed case */ 116 $this->root_topic_name = $name; 117 } 118 119 public function get_root_topic_name() 120 { 121 if ($this->root_topic_name != null) 122 { 123 return $this->root_topic_name; 124 } 125 126 return $this->replace($this->structure['root']['name']) . $this->get_host_prefix(); 127 } 128 129 private function get_host_name() 130 { 131 if (is_object($this->host)) 132 { 133 return $this->host->name; 134 } 135 136 return exec('hostname'); 137 } 138 139 private function get_host_prefix() 140 { 141 if (is_object($this->host)) 142 { 143 return $this->host->prefix; 144 } 145 146 return ""; 147 } 148 149 private function get_host_style() 150 { 151 if (is_object($this->host)) 152 { 153 return $this->host->style; 154 } 155 156 return 0; 157 } 158 113 159 public function set_sitegroup_creator($object) 114 160 { … … 370 416 $this->creation_root_topic = new midgard_topic(); 371 417 $this->creation_root_topic->extra = $topic_title; 372 $this->creation_root_topic->name = $t opic_name;418 $this->creation_root_topic->name = $this->get_root_topic_name(); 373 419 $this->creation_root_topic->sitegroup = $this->sitegroup->id; 374 420 $this->creation_root_topic->component = $component; … … 421 467 private function replace($string) 422 468 { 423 $result = str_replace('__HOSTNAME__', $this-> host->name, $string);469 $result = str_replace('__HOSTNAME__', $this->get_host_name(), $string); 424 470 /* $result = str_replace('__HOSTTITLE__', $this->root_page->title, $result); */ 425 471 … … 448 494 $topic = new midgard_topic(); 449 495 $topic->up = $parent_node->id; 450 $topic->name = $this-> replace($node['name']);496 $topic->name = $this->get_root_topic_name(); 451 497 $topic->extra = $this->replace($node['title']); 452 498 $topic->sitegroup = $this->sitegroup->id; … … 643 689 $this->creation_root_topic->sitegroup = $this->sitegroup->id; 644 690 $this->creation_root_topic->extra = $this->replace($this->structure['root']['title']); 645 $this->creation_root_topic->name = $this-> replace($this->structure['root']['name']) . $this->host->prefix;691 $this->creation_root_topic->name = $this->get_root_topic_name(); 646 692 $this->creation_root_topic->component = $this->structure['root']['component']; 647 693 … … 654 700 else 655 701 { 656 $this->verbose("Setting style for topic " . $this->structure['root']['name'] . ": (" . $this-> host->style. ")");702 $this->verbose("Setting style for topic " . $this->structure['root']['name'] . ": (" . $this->get_host_style() . ")"); 657 703 658 704 if (isset($this->structure['root']['use_inherited_style']) && $this->structure['root']['use_inherited_style'] == false) … … 662 708 else 663 709 { 664 $this->creation_root_topic->style = "/" . $this->get_host_style_name($this-> host->style);710 $this->creation_root_topic->style = "/" . $this->get_host_style_name($this->get_host_style()); 665 711 } 666 712 } … … 674 720 { 675 721 throw new midgard_admin_sitewizard_exception("Failed to create root topic \"" 676 . $this->structure['root']['name'] . "\" for structure creation" );722 . $this->structure['root']['name'] . "\" for structure creation" . ". " . midgard_connection::get_error_string()); 677 723 678 724 return false; … … 693 739 else 694 740 { 695 $this->creation_root_topic->parameter('midcom', 'style', "/" . $this->get_host_style_name($this-> host->style));741 $this->creation_root_topic->parameter('midcom', 'style', "/" . $this->get_host_style_name($this->get_host_style())); 696 742 } 697 743 } … … 1028 1074 catch(midgard_admin_sitewizard_exception $e) 1029 1075 { 1030 $e->error();1031 1076 //$this->parent_link->cleanup() 1032 1077 $this->cleanup(); 1033 1034 throw new midgard_admin_sitewizard_exception("Failed to create structure");1078 1079 $this->setup_config->ui->error(_("Failed to create structure") . $e->error()); 1035 1080 1036 1081 return false; branches/ragnaroek/midgard/data/midgard/setup/php/midgard_setup_app.php
r22734 r22748 10 10 private $_apps = array(); 11 11 private $_setup_config = null; 12 private $_app = null; 13 private $_app_name; 14 private $_sitegroup_name; 12 15 13 16 public function __construct(midgard_setup_config $config) … … 39 42 } 40 43 41 public function install($name = null) 44 private function configure_sitegroup() 45 { 46 $this->_setup_config->ui->message(_("Configure target Midgard domain (sitegroup) ")); 47 48 $sg_names = ''; 49 $i = 0; 50 51 $sg_array = midgard_sitegroup::list_names(); 52 53 if (!empty($sg_array)) 54 { 55 foreach ($sg_array as $name) 56 { 57 if ($i >= 1) 58 { 59 $sg_names .= ", "; 60 } 61 62 $sg_names .= $name; 63 $i++; 64 } 65 } 66 67 if ($i == 0) 68 { 69 $sg_names .= 'none'; 70 } 71 72 $this->_sitegroup_name = $this->_setup_config->ui->get_text(_("Target Midgard domain (sitegroup) name ?"), "", $sg_names); 73 74 if ($this->_sitegroup_name === "") 75 { 76 $this->_setup_config->ui->message(_("Target Midgard domain (sitegroup) not selected")); 77 $this->configure_sitegroup(); 78 } 79 } 80 81 final public function install($name = null) 42 82 { 43 83 if ($name == null 44 84 || $name === "") 45 85 { 46 midgard_setup_ui_cli::warning(_("Expected Midgard application name to be installed."));86 $this->_setup_config->ui->warning(_("Expected Midgard application name to be installed.")); 47 87 return; 48 88 } … … 50 90 if (!array_key_exists($name, $this->_apps)) 51 91 { 52 midgard_setup_ui_cli::warning(_("Can not install {$name}. It is not registered as Midgard application."));92 $this->_setup_config->ui->warning(_("Can not install {$name}. It is not registered as Midgard application.")); 53 93 return; 54 94 } 55 95 56 $app = $this->_apps[$name]; 96 $this->_app = $this->_apps[$name]; 97 $this->_app_name = $name; 57 98 99 $this->install_pear_packages(); 100 $this->configure_sitegroup(); 101 $this->install_structure(); 102 } 103 104 private function install_pear_packages() 105 { 58 106 $msp = new midgard_setup_pear(); 59 107 $msp->prepare_pear(); … … 61 109 62 110 /* Install required packages from PEAR*/ 63 if (!empty($ app['packages']))111 if (!empty($this->_app['packages'])) 64 112 { 65 foreach ($ app['packages'] as $key => $name)113 foreach ($this->_app['packages'] as $key => $name) 66 114 { 67 115 if (!$msp->install_midcom_package($name)) … … 76 124 if (!empty($app['templates'])) 77 125 { 78 foreach ($ app['templates'] as $key => $name)126 foreach ($this->_app['templates'] as $key => $name) 79 127 { 80 128 if (!$msp->install_midcom_package($name, true)) … … 85 133 } 86 134 } 135 } 136 137 private function install_structure() 138 { 139 if ($this->_app == null) 140 { 141 $this->_setup_config->ui->error(_("Can not install application structure. No application selected.")); 142 return; 143 } 87 144 88 145 $sc = new midgard_admin_sitewizard_creator_structure($this->_setup_config); 89 $sc->read_config(MIDGARD_SETUP_ROOT_DIR . "/" . $app['structure']); 146 $sc->set_sitegroup($this->_sitegroup_name); 147 $sc->set_root_topic_name($this->_app_name . " root topic"); 148 $sc->read_config(MIDGARD_SETUP_ROOT_DIR . "/" . $this->_app['structure']); 90 149 $sc->execute(); 150 151 $this->_setup_config->ui->message($this->_app_name . _(" successfully installed")); 91 152 } 92 153 } branches/ragnaroek/midgard/data/midgard/setup/php/midgard_setup_wizard.php
r22729 r22748 118 118 $this->midgard_password = $this->setup_config->midgard_config->midgardpassword; 119 119 120 $this->sitegroup_creator->set_sitegroup _name(MIDGARD_SITEGROUP_0);120 $this->sitegroup_creator->set_sitegroup(MIDGARD_SITEGROUP_0); 121 121 $this->sitegroup_creator->set_sitegroup_admin_username($this->midgard_username); 122 122 $this->sitegroup_creator->set_sitegroup_admin_password($this->midgard_password);
