Changeset 11345

Show
Ignore:
Timestamp:
07/24/07 15:55:58 (1 year ago)
Author:
juhana
Message:

Made some changes to the sitewizard advanced mode

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midgard.admin.sitewizard/handler/host.php

    r11125 r11345  
    1919    var $_schema = null; 
    2020    var $_schemadb = null; 
     21    var $_root_topic = null; 
    2122 
    2223    /** 
     
    7778            $session = new midcom_service_session(); 
    7879            $session->set("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}", $host_settings); 
    79              
    80             // Relocate user to template selection 
    81             $_MIDCOM->relocate("{$prefix}template/{$this->_request_data['sitegroup']->id}/"); 
    82             // This will exit 
     80            
     81            if ($this->_config->get('mode') == 'advanced') 
     82            { 
     83                // Relocate user to structure selection 
     84                $_MIDCOM->relocate("{$prefix}structure/{$this->_request_data['sitegroup']->id}/"); 
     85                // This will exit 
     86            } 
     87            else 
     88            { 
     89                // Relocate user to template selection 
     90                $_MIDCOM->relocate("{$prefix}template/{$this->_request_data['sitegroup']->id}/"); 
     91                // This will exit 
     92            } 
    8393        } 
    8494         
     
    113123 
    114124    /** 
    115      * Selects a templat
    116      */ 
    117     function _handler_template($handler_id, $args, &$data) 
     125     * Select a structur
     126     */ 
     127    function _handler_structure($handler_id, $args, &$data) 
    118128    { 
    119129        $this->_request_data['sitegroup'] = mgd_get_sitegroup($args[0]); 
     
    140150                $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
    141151                // This will exit         
    142             } 
    143  
    144             // Read form contents             
    145             if (array_key_exists('midgard_admin_sitewizard_select_template', $_POST)) 
    146             { 
    147                 if ($_POST['midgard_admin_sitewizard_select_template'] == 'custom') 
    148                 { 
    149                     if (array_key_exists('template', $host_settings)) 
    150                     { 
    151                         unset($host_settings['template']); 
    152                     } 
    153                 } 
    154                 else 
    155                 { 
    156                     $host_settings['template'] = $_POST['midgard_admin_sitewizard_select_template']; 
    157  
    158                     // Lets find out if we are using an advanced template 
    159                     $qb = midcom_db_style::new_query_builder(); 
    160                     $qb->add_constraint('sitegroup', '=', 0); 
    161                     $qb->add_constraint('name', '=', $host_settings['template']); 
    162  
    163                     $template_style_obj = $qb->execute(); 
    164  
    165                     if ($template_style_obj[0]->parameter('midgard.admin.sitewizard', 'template_type') == "advanced") 
    166                     { 
    167                         $host_settings['template_type'] = "advanced"; 
    168                     } 
    169                     else 
    170                     { 
    171                         $host_settings['template_type'] = "simple"; 
    172                     } 
    173                 } 
    174152            } 
    175153 
     
    191169            // Save information into session 
    192170            $session->set("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}", $host_settings); 
     171            $_MIDCOM->set_pagetitle($this->_l10n->get('create website')); 
     172 
    193173             
    194             // Relocate user to host creation 
     174            // Relocate user to host creation 
     175            $_MIDCOM->relocate("{$prefix}template/{$this->_request_data['sitegroup']->id}/"); 
     176            // This will exit 
     177        } 
     178 
     179        $this->_request_data['structures_array'] = array_merge( 
     180        $this->_get_template_structures_filesystem(), $this->_get_template_structures_snippet()); 
     181         
     182        return true; 
     183    } 
     184 
     185    function _show_structure($handler_id, &$data) 
     186    { 
     187        midcom_show_style('show-wizard-header'); 
     188        midcom_show_style('wizard-select-structure'); 
     189        midcom_show_style('show-wizard-footer'); 
     190    } 
     191 
     192    /** 
     193     * Selects a template 
     194     */ 
     195    function _handler_template($handler_id, $args, &$data) 
     196    { 
     197        $this->_request_data['sitegroup'] = mgd_get_sitegroup($args[0]); 
     198        if (!$this->_request_data['sitegroup']) 
     199        { 
     200            return false; 
     201        } 
     202 
     203        $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX);     
     204        $session = new midcom_service_session(); 
     205        if (!$session->exists("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}")) 
     206        { 
     207            // Relocate user back to host settings 
     208            $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
     209            // This will exit 
     210        } 
     211         
     212        if (array_key_exists('midgard_admin_sitewizard_process', $_POST)) 
     213        { 
     214            $host_settings = $session->get("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}"); 
     215            if (!is_array($host_settings)) 
     216            { 
     217                // Corrupt data, relocate back to host settings 
     218                $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
     219                // This will exit         
     220            } 
     221 
     222            // Read form contents             
     223            if (array_key_exists('midgard_admin_sitewizard_select_template', $_POST)) 
     224            { 
     225                if ($_POST['midgard_admin_sitewizard_select_template'] == 'custom') 
     226                { 
     227                    if (array_key_exists('template', $host_settings)) 
     228                    { 
     229                        unset($host_settings['template']); 
     230                    } 
     231                } 
     232                else 
     233                { 
     234                    $host_settings['template'] = $_POST['midgard_admin_sitewizard_select_template']; 
     235 
     236                    // Lets find out if we are using an advanced template 
     237                    $qb = midcom_db_style::new_query_builder(); 
     238                    $qb->add_constraint('sitegroup', '=', 0); 
     239                    $qb->add_constraint('name', '=', $host_settings['template']); 
     240 
     241                    $template_style_obj = $qb->execute(); 
     242 
     243                    $qb = midcom_db_element::new_query_builder(); 
     244                    $qb->add_constraint('sitegroup', '=', 0); 
     245                    $qb->add_constraint('style', '=', $template_style_obj[0]->id); 
     246                    $qb->add_constraint('name', '=', '__schemadb'); 
     247 
     248                    $schema = $qb->execute(); 
     249 
     250                    if (count($schema) > 0) 
     251                    { 
     252                        $host_settings['template_type'] = "advanced"; 
     253                        $host_settings['template_schemadb'] = $schema[0]; 
     254                    } 
     255                    else 
     256                    { 
     257                        $host_settings['template_type'] = "simple"; 
     258                    } 
     259                } 
     260            } 
     261             
     262            // Save information into session 
     263            $session->set("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}", $host_settings); 
     264            $_MIDCOM->set_pagetitle($this->_l10n->get('create website')); 
     265             
     266            // Relocate user to host creation 
    195267            $_MIDCOM->relocate("{$prefix}create/{$this->_request_data['sitegroup']->id}/"); 
    196268            // This will exit 
     
    204276        // TODO: Check for sitegroups? 
    205277        $this->_request_data['templates'] = $qb->execute(); 
    206  
    207         $this->_request_data['structures_array'] = array_merge($this->_get_template_structures_filesystem(), $this->_get_template_structures_snippet()); 
    208278 
    209279        return true; 
     
    219289     * The operations are done on all available schemas within the DB. 
    220290     */ 
    221      function _load_schemadb() 
    222      { 
    223          $this->_schemadb =& $this->_request_data['schemadb']; 
    224      } 
     291    function _load_schemadb() 
     292    { 
     293        $session = new midcom_service_session(); 
     294        if (!$session->exists("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}")) 
     295        { 
     296            // Relocate user back to host settings 
     297            $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
     298            // This will exit 
     299        } 
     300 
     301        $host_settings = $session->get("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}"); 
     302        if (!is_array($host_settings)) 
     303        { 
     304            // Corrupt data, relocate back to host settings 
     305            $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
     306            // This will exit         
     307        } 
     308 
     309        if (is_string($host_settings['template_schemadb']->value)) 
     310        { 
     311            $result = eval ("\$raw_schemadb = Array ( {$host_settings['template_schemadb']->value}\n );"); 
     312            if ($result === false) 
     313            { 
     314                $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 
     315                "Failed to parse the schema definition from style element, see above for PHP errors."); 
     316                // This will exit. 
     317            } 
     318        } 
     319 
     320        $this->_schemadb = midcom_helper_datamanager2_schema::load_database($raw_schemadb); 
     321    } 
    225322 
    226323    /** 
     
    229326     * @access private 
    230327     */ 
    231    function _load_controller() 
    232    
    233        $this->_load_schemadb(); 
    234        $this->_controller =& midcom_helper_datamanager2_controller::create('simple'); 
    235        $this->_controller->schemadb =& $this->_schemadb; 
    236        $this->_controller->set_storage($this->_host); 
    237        if (! $this->_controller->initialize()) 
    238        
    239            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for host {$this->_host->id}."); 
    240           // This will exit. 
    241        
    242    
     328    function _load_controller() 
     329   
     330        $this->_load_schemadb(); 
     331        $this->_controller =& midcom_helper_datamanager2_controller::create('simple'); 
     332        $this->_controller->schemadb =& $this->_schemadb; 
     333        $this->_controller->set_storage($this->_root_topic); 
     334        if (! $this->_controller->initialize()) 
     335       
     336            $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for topic {$this->_root_topic->id}."); 
     337            // This will exit. 
     338       
     339   
    243340 
    244341    // Handles customization of advanced style templates 
     
    252349        } 
    253350 
    254         //$schemadb_contents = midcom_get_snippet_content($this->_config->get("schemadb")); 
    255         //eval("\$schemadb = Array ( {$schemadb_contents} );"); 
    256  
    257         //$this->_schemadb = $schemadb; 
    258         //$this->_request_data['schemadb'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb')); 
    259  
    260 /* 
    261         // Instantiate datamanager 
    262         $datamanager = new midcom_helper_datamanager($schemadb); 
    263  
    264         if (!$datamanager) { 
    265             debug_pop(); 
    266             $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Datamanager could not be instantinated with schema ".$this->_config->get("schemadb")); 
    267             // This will exit.    
    268         } 
    269 */ 
    270351        $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX);     
    271352        $session = new midcom_service_session(); 
     
    278359 
    279360        $host_settings = $session->get("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}"); 
    280  
    281         $qb = midcom_db_host::new_query_builder(); 
    282         $qb->add_constraint('sitegroup', '=', $this->_request_data['sitegroup']->id); 
    283         $qb->add_constraint('name', '=', $host_settings['hostname']); 
    284         $hosts = $qb->execute(); 
    285  
    286         $this->_host = $hosts[0]; 
    287  
    288         //$datamanager->init($host); 
    289  
     361echo "<pre>"; 
     362print_r($host_settings); 
     363echo "</pre>"; 
     364        $this->_root_topic = new midcom_db_topic(); 
     365        $this->_root_topic->get_by_guid($host_settings['root_topic_guid']); 
     366 
     367        $this->_host = new midcom_db_host(); 
     368        $this->_host->get_by_guid($host_settings['hostguid']); 
     369         
    290370        $this->_load_controller(); 
    291371 
     
    295375                // The document has been saved, relocate the user 
    296376                debug_pop(); 
     377                //$this->_root_topic->update(); 
    297378                $_MIDCOM->relocate("{$prefix}finish/{$this->_host->id}/"); 
    298379                // This will exit 
     
    300381            case 'cancel': 
    301382                // User has cancelled without saving 
     383                debug_pop(); 
     384                //$this->_root_topic->update(); 
     385                $_MIDCOM->relocate("{$prefix}finish/{$this->_host->id}/"); 
     386                // This will exit 
    302387                break; 
    303388            case 'failed': 
     
    308393        } 
    309394 
    310         $this->_request_data['datamanager'] =& $this->_controller; 
     395        $this->_request_data['controller'] =& $this->_controller; 
     396        $this->_request_data['root_topic'] =& $this->_root_topic; 
    311397 
    312398        return true; 
     
    318404    function _get_template_structures_filesystem() 
    319405    { 
    320         $dir = MIDCOM_ROOT . "/midgard/admin/sitewizard/config/"; 
     406        $dir = MIDCOM_ROOT . "/midgard/admin/sitewizard/config/templates/"; 
    321407        $structures_array = array(); 
    322408 
     
    324410            if ($dh = opendir($dir)) { 
    325411                while (($file = readdir($dh)) !== false) { 
    326                     if (ereg("structure_template_", $file)) 
    327                     { 
    328                         $path = $dir . $file; 
    329                         eval('$evaluated = array(' . file_get_contents($path) . ');'); 
     412                    $path = $dir . $file; 
     413                    eval('$evaluated = array(' . file_get_contents($path) . ');'); 
    330414                         
    331                         $keys = array_keys($evaluated); 
    332                         if (count($keys) != 0) 
    333                         { 
    334                             if (array_key_exists('title', $evaluated[$keys[0]]) && array_key_exists('description', $evaluated[$keys[0]])) 
    335                             { 
    336                                 $structures_array = array_merge($structures_array, $evaluated);            
    337                             } 
    338                         } 
    339                     } 
     415                    $keys = array_keys($evaluated); 
     416                    if (count($keys) != 0) 
     417                    { 
     418                        if (array_key_exists('title', $evaluated[$keys[0]]) && array_key_exists('description', $evaluated[$keys[0]])) 
     419                        { 
     420                            $structures_array = array_merge($structures_array, $evaluated);            
     421                        } 
     422                    } 
    340423                } 
    341424                closedir($dh); 
     
    353436        $qb = midcom_baseclasses_database_snippet::new_query_builder(); 
    354437        $qb->add_constraint('sitegroup', '=', 0); 
    355         $qb->add_constraint('name', 'LIKE', 'structure_template_%'); 
     438        $qb->add_constraint('up.name', '=', 'templates'); 
    356439 
    357440        $structures_obj_array = $qb->execute(); 
     
    372455        } 
    373456        return $structures_array; 
    374 
    375  
    376     /** 
    377      * Creates the template structure 
    378      */ 
    379     function _create_structure($host_settings, $runner) 
    380     { 
    381         $created_groups = array(); 
    382         $structures_array = array_merge($this->_get_template_structures_filesystem(), $this->_get_template_structures_snippet()); 
    383         $structure = $structures_array[$host_settings['structure_template']]; 
    384  
    385         $root_topic_guid = $runner->topic->guid; 
    386         $root_topic_id = $runner->topic->id; 
    387         $sitegroup = $runner->config->sitegroup_id; 
    388  
    389         // Lets find out admin group id 
    390         $qb = midcom_db_group::new_query_builder(); 
    391         $qb->add_constraint('sitegroup', '=', $sitegroup); 
    392         $qb->add_constraint('owner', '=', 0); 
    393         $admin_group = $qb->execute(); 
    394  
    395         $admin_group = $admin_group[0]; 
    396  
    397         // And the same thing with admin user 
    398         $qb = midcom_db_member::new_query_builder(); 
    399         $qb->add_constraint('sitegroup', '=', $sitegroup); 
    400         $qb->add_constraint('gid', '=', $admin_group->id); 
    401         $admin_user = $qb->execute(); 
    402  
    403         $admin_user = $admin_user[0]; 
    404  
    405         echo "<pre>"; 
    406         //print_r($admin_user); 
    407         //print_r($admin_group); 
    408         echo "</pre>"; 
    409  
    410  
    411         // OK, that should be all we need to create topics and groups 
    412  
    413         // Creating groups 
    414         foreach($structure['groups'] as $group_name) 
    415         { 
    416             $newgroup = new midcom_db_group(); 
    417             $newgroup->name = sprintf($group_name); 
    418             $newgroup->owner = $admin_group->id; 
    419             $newgroup->sitegroup = $sitegroup; 
    420  
    421             if (!$newgroup->create()) 
    422             { 
    423                 echo "Error"; 
    424                  
    425                 // TODO: handle error 
    426             } 
    427             else 
    428             { 
    429                 $created_groups[$newgroup->name] = $newgroup->guid; 
    430             } 
    431         } 
    432  
     457    } 
     458 
     459    function _create_topics_recursive($nodes, $created_groups, $sitegroup, $root_topic_id, $admin_group) 
     460    { 
    433461        // Creating topics 
    434        foreach($structure['nodes'] as $node) 
     462        foreach ($nodes as $node) 
    435463        { 
    436464            $newtopic = new midcom_db_topic(); 
     
    454482                    if (!$newtopic->component = $node['component']) 
    455483                    { 
    456                     echo "Setting param"; 
    457484                        $newtopic->parameter('midcom', 'component', $node['component']); 
    458485                    } 
    459486                    else 
    460487                    { 
    461                     echo "Setting done"; 
    462488                        $newtopic->update(); 
    463489                    } 
     
    482508                foreach($node['acl'] as $group_name => $privilege) 
    483509                { 
    484  
    485510                    foreach($privilege as $name => $value) 
    486511                    { 
     
    490515                        } 
    491516                    } 
     517                } 
     518            } 
     519 
     520            if (isset($node['nodes'])) 
     521            { 
     522                $this->_create_topics_recursive($node['nodes'], $created_groups, $sitegroup, $root_topic_id, $admin_group); 
     523            } 
     524        } 
     525    } 
     526 
     527 
     528    /** 
     529     * Creates the template structure 
     530     */ 
     531    function _create_structure($host_settings, $runner) 
     532    { 
     533        $created_groups = array(); 
     534        $structures_array = array_merge($this->_get_template_structures_filesystem(), $this->_get_template_structures_snippet()); 
     535        $structure = $structures_array[$host_settings['structure_template']]; 
     536 
     537        $root_topic_guid = $runner->topic->guid; 
     538        $root_topic_id = $runner->topic->id; 
     539        $sitegroup = $runner->config->sitegroup_id; 
     540 
     541        $session = new midcom_service_session(); 
     542        if (!$session->exists("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}")) 
     543        { 
     544            // Relocate user back to host settings 
     545            $_MIDCOM->relocate("{$prefix}host/{$this->_request_data['sitegroup']->id}/"); 
     546            // This will exit 
     547        } 
     548 
     549        $host_settings = $session->get("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}"); 
     550        $host_settings['root_topic_guid'] = $root_topic_guid; 
     551        $session->set("midgard_admin_sitewizard_{$this->_request_data['sitegroup']->id}", $host_settings); 
     552 
     553        // Updating root topic 
     554        $root_topic = new midcom_db_topic(); 
     555        $root_topic->get_by_guid($root_topic_guid); 
     556                
     557        // Setting component here 
     558        if (isset($structure['root']['component'])) 
     559        { 
     560            if (!$root_topic->component = $structure['root']['component']) 
     561            { 
     562                $newtopic->parameter('midcom', 'component', $structure['root']['component']); 
     563            } 
     564        } 
     565                 
     566        // Setting additional parameters here 
     567        if (isset($structure['root']['parameters']) && count($structure['root']['parameters']) != 0) 
     568        { 
     569             foreach($structure['root']['parameters'] as $domain => $parameter) 
     570             { 
     571                 foreach($parameter as $name => $value) 
     572                 { 
     573                     $root_topic->parameter($domain, $name, $value); 
     574                 } 
     575             } 
     576        } 
     577         
     578        // TODO: str_replaces 
     579         
     580 
     581        // Lets find out admin group id 
     582        $qb = midcom_db_group::new_query_builder(); 
     583        $qb->add_constraint('sitegroup', '=', $sitegroup); 
     584        $qb->add_constraint('owner', '=', 0); 
     585        $admin_group = $qb->execute(); 
     586 
     587        $admin_group = $admin_group[0]; 
     588 
     589        // And the same thing with admin user 
     590        $qb = midcom_db_member::new_query_builder(); 
     591        $qb->add_constraint('sitegroup', '=', $sitegroup); 
     592        $qb->add_constraint('gid', '=', $admin_group->id); 
     593        $admin_user = $qb->execute(); 
     594 
     595        $admin_user = $admin_user[0]; 
     596 
     597        echo "<pre>"; 
     598        //print_r($admin_user); 
     599        //print_r($admin_group); 
     600        echo "</pre>"; 
     601 
     602        // OK, that should be all we need to create topics and groups 
     603        // Creating groups 
     604        foreach($structure['groups'] as $group_name) 
     605        { 
     606            // TODO: maybe check if a group by the name of $group_name exists and use that 
     607 
     608            $newgroup = new midcom_db_group(); 
     609            $newgroup->name = sprintf($group_name); 
     610            $newgroup->owner = $admin_group->id; 
     611            $newgroup->sitegroup = $sitegroup; 
     612 
     613            if (!$newgroup->create()) 
     614            { 
     615                echo "Error"; 
     616                 
     617                // TODO: handle error 
     618            } 
     619            else 
     620            { 
     621                $created_groups[$newgroup->name] = $newgroup->guid; 
     622            } 
     623        } 
     624 
     625        // Ok, it's time to set up root topic ACL privileges 
     626        if (isset($structure['root']['acl']) && count($structure['root']['acl']) != 0) 
     627        { 
     628            foreach($structure['root']['acl'] as $group_name => $privilege) 
     629            { 
     630                foreach($privilege as $name => $value) 
     631                { 
     632                    if (array_key_exists($group_name, $created_groups)) 
     633                    { 
     634                        $root_topic->set_privilege($name, "group:{$created_groups[$group_name]}", $value); 
     635                    } 
    492636                } 
    493             } 
     637            } 
     638        } 
     639 
     640        if (!$root_topic->update()) 
     641        { 
     642            // TODO: handle error 
    494643        } 
     644 
     645        // Creating topics 
     646        if (isset($structure['root']['nodes'])) 
     647        { 
     648            $this->_create_topics_recursive($structure['root']['nodes'], $created_groups, $sitegroup, $root_topic_id, $admin_group); 
     649        } 
    495650    } 
    496651 
     
    511666    { 
    512667        midcom_show_style('show-wizard-header'); 
    513  
    514         // Check if advanced style should be shown 
    515         switch($this->_config->get('mode')) 
    516         { 
    517                 case 'simple': 
    518                         midcom_show_style('wizard-select-style'); 
    519                         break; 
    520                 case 'advanced': 
    521                         midcom_show_style('wizard-select-structure'); 
    522                         break; 
    523                 default: 
    524                         midcom_show_style('wizard-select-style'); 
    525                         break; 
    526         } 
    527  
     668        midcom_show_style('wizard-select-style'); 
    528669        midcom_show_style('show-wizard-footer'); 
    529670    } 
     
    596737        if (array_key_exists('structure_template', $host_settings)) 
    597738        { 
    598             $this->_create_structure($host_settings, $runner); 
     739           $this->_create_structure($host_settings, $runner); 
    599740        } 
    600741 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/locale/default.en.txt

    r11125 r11345  
    33---CVS $Id$ 
    44---LANGUAGE en 
     5 
     6---STRING show all info 
     7Show all info 
     8---STRINGEND 
     9 
     10---STRING whois 
     11Whois 
     12---STRINGEND 
    513 
    614---STRING template structures 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/locale/default.fi.txt

    r3621 r11345  
    33---CVS $Id$ 
    44---LANGUAGE fi 
     5 
     6 
     7---STRING show all info 
     8Nayta kaikki tiedot 
     9---STRINGEND 
     10 
     11---STRING whois 
     12Whois (domainkysely) 
     13---STRINGEND 
    514 
    615---STRING advanced options 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/static/sitewizard.css

    r11125 r11345  
    8181#midgard_admin_sitewizard fieldset.style div.structure_wrapper { 
    8282    float: left; 
    83     width: 20%; 
     83    //width: 30%; 
    8484    margin: 20px; 
    8585} 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/style/wizard-create-host.php

    r11042 r11345  
    22//$data =& $_MIDCOM->get_custom_context_data('request_data'); 
    33$view_form_prefix = 'midgard_admin_sitewizard_'; 
     4 
     5include(MIDCOM_ROOT . "/midgard/admin/sitewizard/whois_class.php"); 
     6include(MIDCOM_ROOT . "/midgard/admin/sitewizard/server_list.php"); 
     7 
     8$my_whois = new Whois_domain; 
     9$my_whois->possible_tlds = array_keys($servers); // this is the array from the included server list 
     10 
     11if (isset($_POST['submit'])) { 
     12    $my_whois->tld = $_POST['tld']; 
     13    $my_whois->domain = $_POST['domain']; 
     14    $my_whois->free_string = $servers[$_POST['tld']]['free']; 
     15    $my_whois->whois_server = $servers[$_POST['tld']]['address']; 
     16    $my_whois->whois_param = $servers[$_POST['tld']]['param']; 
     17    $my_whois->full_info = (isset($_POST['all_info'])) ? $_POST['all_info'] : "no"; // between "no" and "yes" to get all whois information 
     18    $my_whois->process(); 
     19} 
     20 
    421?> 
    522<script type="text/javascript"> 
     
    2441</script> 
    2542 
    26 <!-- 
    27   <fieldset> 
     43  <div style="position: absolute; background-color: white; top: 180px; right: 20px; width: 400px;"> 
     44  <fieldset>  
    2845    <div class="explanation"> 
    2946            <?php  $data['l10n']->get("dns whois lookup"); ?> 
    3047     </div> 
    31      <label for="&(view_form_prefix);site_name"><?php echo $data['l10n']->get("Whois"); ?></label> 
     48     <label for="&(view_form_prefix);site_name"><?php echo $data['l10n']->get("whois"); ?></label> 
    3249 
    33      <input type="text"/> 
     50     <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form"> 
     51       <input type="text" name="domain" size="14" maxlength="63" value="<?php echo (isset($_POST['domain'])) ? $_POST['domain'] : ""; ?>"> 
     52          <?php echo $my_whois->create_tld_select(); // this method generates the select menu woth all tld's ?> 
     53           
     54          <input name="submit" type="submit" value="Whois"> 
     55          <br/> 
     56          <?php echo $data['l10n']->get("show all info") . "?"; ?> 
     57          <input name="all_info" type="checkbox" value="yes"> 
     58     </form> 
     59     <br/> 
     60     <p><?php echo ($my_whois->msg != "") ? $my_whois->msg : ""; ?></p> 
     61 
     62      <!-- this will show up all info from the whois server --> 
     63 
     64       <?php if ($my_whois->info != "") { ?> 
     65       <h2><?php echo "Whois ".$my_whois->compl_domain."?" ?></h2> 
     66       <blockquote> 
     67       
     68         <?php echo nl2br($my_whois->info); ?> 
     69                 
     70       </blockquote> 
     71       <?php } ?> 
     72      
    3473  </fieldset> 
    35 --> 
    36  
     74  </div> 
    3775<form method="post" name="&(view_form_prefix);sitegroup_select" action="&(_MIDGARD['uri']);"> 
    3876 
     
    5795     
    5896    <label for="&(view_form_prefix);host_component"><?php echo $data['l10n']->get("host template"); ?></label> 
     97     
     98    <?php 
     99    if (!$data['config']->get('mode') == 'advanced') 
     100    { 
     101    ?> 
     102 
    59103    <select name="&(view_form_prefix);host_component" id="&(view_form_prefix);host_component" disabled="disabled"> 
    60104    <?php 
     
    70114    ?> 
    71115    </select> 
     116 
     117    <?php 
     118    } 
     119    ?> 
    72120  </fieldset> 
    73      
    74   <input type="submit" name="&(view_form_prefix);process" class="&(view_form_prefix);next" value="<?php echo $data['l10n_midcom']->get("next"); ?> &raquo;" /> 
     121 
     122  <input type="submit" name="&(view_form_prefix);process" class="&(view_form_prefix);next" value=" 
     123  <?php echo $data['l10n_midcom']->get("next"); ?> &raquo;" /> 
     124   
    75125</form> 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/style/wizard-select-structure.php

    r11125 r11345  
    22//$data =& $_MIDCOM->get_custom_context_data('request_data'); 
    33$view_form_prefix = 'midgard_admin_sitewizard_'; 
    4 ?> 
    5 <form method="post" name="&(view_form_prefix);sitegroup_select" action="<?php echo $_MIDGARD['uri']; ?>"> 
    6     <fieldset class="style"> 
    7       <img src="<?php echo MIDCOM_STATIC_URL; ?>/midgard.admin.sitewizard/no-style-preview.jpg" width="130" alt="Custom" /> 
    8       <label for="&(view_form_prefix);select_template_custom" class="action_select"> 
    9       <input type="radio" checked="checked" name="&(view_form_prefix);select_template" value="custom" 
    10       id="&(view_form_prefix);select_template_custom" /><?php echo $data['l10n']->get('custom'); ?></label> 
    11       <div class="description"><?php echo $data['l10n']->get('completely empty style'); ?></div> 
    12     </fieldset> 
    134 
    14 <?php 
    15 foreach ($data['templates'] as $template) 
    16 
    17     if ($template->parameter('midgard.admin.sitewizard', 'template_type') == "advanced") 
    18     { 
    19         $customizable = "Customizable"; 
    20     } 
    21     else 
    22     { 
    23        $customizable = "Not customizable"; 
    24     } 
     5          function sitewizard_show_nodes($structure) 
     6          {  
     7              echo "<ul>"; 
     8              if (isset($structure['root'])) 
     9              { 
     10                  echo "<li>" . $structure['root']['title'] . "</li>"; 
     11                  if (isset($structure['root']['nodes'])) 
     12                  { 
     13                      echo "<ul>"; 
     14                      foreach($structure['root']['nodes'] as $node) 
     15                      { 
     16                          echo "<li>" . $node['title'] . "</li>"; 
     17                          sitewizard_show_nodes($node); 
     18                      } 
     19                      echo "</ul>"; 
     20                  }               
     21              } 
     22              elseif (isset($structure['nodes'])) 
     23              { 
     24                  foreach($structure['nodes'] as $node) 
     25                  { 
     26                      echo "<li>" . $node['title'] . "</li>"; 
     27                  }                
     28              } 
     29              echo "</ul>"; 
     30          } 
    2531 
    26     // Clean up the template display name 
    27     $template_name = str_replace("template_","",$template->name); 
    28      
    29     // template metadata 
    30     // TODO: Get from PEAR 
    31     $template_description = $template->parameter('midgard.admin.sitewizard', 'template_description'); 
    32     $template_credits = $template->parameter('midgard.admin.sitewizard', 'template_credits'); 
    33      
    34     // template preview thumbnail 
    35     $template_image = $template->getattachment('__preview.jpg'); 
    36     if ($template_image) 
    37     { 
    38         $template_image_url = "{$_MIDGARD['self']}midcom-serveattachmentguid-{$template_image->guid}/{$template_image->name}"; 
    39     } 
    40     else 
    41     { 
    42         $template_image_url = MIDCOM_STATIC_URL."/midgard.admin.sitewizard/no-style-preview.jpg"; 
    43     } 
    44     ?> 
    45     <fieldset class="style"> 
    46       <img src="&(template_image_url);" width="130" alt="&(template_name);" /> 
    47       <label for="&(view_form_prefix);select_template_&(template.id);" class="action_select"> 
    48       <input type="radio" name="&(view_form_prefix);select_template" value="&(template.name);" 
    49       id="&(view_form_prefix);select_template_&(template.id);" />&(template_name); (&(customizable);)</label> 
    50       <div class="credits">&(template_credits);</div> 
    51       <div class="description">&(template_description);</div> 
    52     </fieldset> 
    53     <?php 
    54 }  
    5532?> 
    5633<br/><br/> 
    5734<h2><?php echo $data['l10n']->get('template structures'); ?></h2> 
    58  
     35<form method="post" name="&(view_form_prefix);sitegroup_select" action="<?php echo $_MIDGARD['uri']; ?>"> 
    5936    <fieldset class="style"> 
    6037      <label for="&(view_form_prefix);select_structure_template_custom" class="action_select"> 
     
    9875          <legend>Folders</legend> 
    9976          <?php 
    100           foreach ($structure['nodes'] as $node) 
    101           { 
    102               echo "-" . $node['title'] . "<br/>";  
    103           } 
     77           
     78          sitewizard_show_nodes($structure); 
     79           
    10480echo "<pre>"; 
    10581//print_r($structure); 
    10682echo "</pre>"; 
    10783          ?> 
     84          </fieldset> 
     85          </div> 
     86          <div class="structure_wrapper"> 
     87          <fieldset class="structure"> 
     88          <legend>Examples</legend> 
     89          <?php 
     90 
     91          if (isset($structure['examples'])) 
     92          { 
     93              foreach($structure['examples'] as $url => $example) 
     94              { 
     95                  echo "<a href=\"{$url}\" target=\"_blank\">{$example}</a><br/>"; 
     96              } 
     97          } 
     98 
     99          ?> 
    108100          </fieldset> 
    109101          </div> 
  • branches/MidCOM_2_8/midgard.admin.sitewizard/style/wizard-select-style.php

    r5048 r11345  
    1515foreach ($data['templates'] as $template) 
    1616{ 
     17    $qb = midcom_db_element::new_query_builder(); 
     18    $qb->add_constraint('sitegroup', '=', 0); 
     19    $qb->add_constraint('style', '=', $template->id); 
     20    $qb->add_constraint('name', '=', '__schemadb'); 
     21 
     22    $schema = $qb->execute(); 
     23 
     24    if (count($schema) > 0) 
     25    { 
     26        $customizable = "Customizable"; 
     27    } 
     28    else 
     29    { 
     30       $customizable = "Not customizable"; 
     31    } 
     32 
     33    // Clean up the template display name 
     34    $template_name = $template->name;  // str_replace("template_","",$template->name); 
     35     
     36    // template metadata 
     37    // TODO: Get from PEAR 
     38    $template_description = $template->parameter('midgard.admin.sitewizard', 'template_description'); 
     39    $template_credits = $template->parameter('midgard.admin.sitewizard', 'template_credits'); 
    1740    // Clean up the template display name 
    1841    $template_name = str_replace("template_","",$template->name); 
     
    3861      <label for="&(view_form_prefix);select_template_&(template.id);" class="action_select"> 
    3962      <input type="radio" name="&(view_form_prefix);select_template" value="&(template.name);" 
    40       id="&(view_form_prefix);select_template_&(template.id);" />&(template_name);</label> 
     63      id="&(view_form_prefix);select_template_&(template.id);" />&(template_name); (&(customizable);)</label> 
    4164      <div class="credits">&(template_credits);</div> 
    4265      <div class="description">&(template_description);</div>