[CS-Project-svn_notify] SF.net SVN: cs-project:[962] trunk/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-10 17:14:45
|
Revision: 962 http://cs-project.svn.sourceforge.net/cs-project/?rev=962&view=rev Author: crazedsanity Date: 2009-02-10 17:14:40 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Update setup to handle new config, fix accidental redirection after setup. /includes/setup.inc: * only redirect if DATABASE__DBNAME is set AND there's no "setup" array under $_SESSION. /includes/setup/5.inc: * Change message contents when POST is discovered * remove commented-out code * log unit test results. * __finalStep::write_config(): -- add tags for SITE_ROOT & such (from the config::convert_to_sections()) -- add attributes for setting things to global/constant as needed. -- move all config settings to /config/main instead of being directly under /config. -- add attribute "usecssiteconfig" to the root tag. /lib/config.class.php: * move call to get_config_contents() into the "if" tag that runs only when the config file exists. /lib/_unitTests_/cs-content_tests.php: * remove extra space from expected value to avoid test failure. Modified Paths: -------------- trunk/1.2/includes/setup/5.inc trunk/1.2/includes/setup.inc trunk/1.2/lib/_unitTests_/cs-content_tests.php trunk/1.2/lib/config.class.php Modified: trunk/1.2/includes/setup/5.inc =================================================================== --- trunk/1.2/includes/setup/5.inc 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/includes/setup/5.inc 2009-02-10 17:14:40 UTC (rev 962) @@ -10,29 +10,45 @@ $writeConfigResult = $obj->write_config($page); $page->set_message_wrapper(array( - 'title' => "Reloaded... ", + 'title' => "Setup Complete", 'message' => $writeConfigResult, 'type' => "status", - 'linkURL' => '/login' + 'linkText' => "Proceed To Login", + 'linkURL' => '/setup/5?removeData=1' )); $page->conditional_header("/setup/5", TRUE); } +elseif($_GET['removeData'] == 1) { + unset($_SESSION['setup']); + $page->conditional_header('/login.php'); +} else { if(get_setup_data(5, 'result')) { $page->clear_content(); - #$page->set_block_row('content', 'submitButton'); $test = &new TestSuite("All Tests"); $test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-content_tests.php'); - #$test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-arrayToPath_tests.php'); - #$test->addTestFile(dirname(__FILE__) .'/../../lib/_unitTests_/cs-phpxml_tests.php'); $display = new HtmlReporter(); $test->run($display); $page->gfObj->debug_print("Passes: (". $display->getPassCount() .")"); - } - else { + //log our result into the database. + $db = new cs_phpDB; + $db->connect(get_config_db_params()); + + $log = new logsClass($db, 'SETUP'); + $log->log_by_class('UNIT TEST DATA::: passes='. $display->getPassCount() .', fails='. $display->getFailCount() .', exceptions='. $display->getExceptionCount(), 'Information'); + + if(!is_array($_SESSION['message'])) { + $page->set_message_wrapper(array( + 'title' => "Setup Complete", + 'message' => "Setup has been completed successfully. If you would like to remove setup data and proceed to login, click the link below.", + 'type' => 'status', + 'linkText' => "Proceed to Login", + 'linkURL' => "/setup/5?removeData=1" + )); + } } } @@ -74,15 +90,49 @@ } //now that we've built the array successfully, now let's turn it into XML. - $xmlCreator = new cs_phpxmlCreator('config/main'); + $xmlCreator = new cs_phpxmlCreator('config'); + $tagPath = "/config/main"; + $xmlCreator->add_tag($tagPath); + $xmlCreator->add_attribute($tagPath, array('fix'=>"sanitizeDirs")); + $xmlCreator->set_tag_as_multiple($tagPath); + + //Special values (including vars that cs_siteConfig{} handles) + $specialValues = array( + 'site_root' => '{_DIRNAMEOFFILE_}/..', + 'document_root' => '{MAIN/SITE_ROOT}', + 'libdir' => '{MAIN/SITE_ROOT}/lib', + 'tmpldir' => '{MAIN/SITE_ROOT}/templates', + 'seq_helpdesk' => 'special__helpdesk_public_id_seq', + 'seq_project' => 'special__project_public_id_seq', + 'seq_main' => 'record_table_record_id_seq', + 'table_todocomment' => 'task_comment_table', + 'format_wordwrap' => '90' + ); + $defineAsGlobal=array('site_root', 'libdir', 'tmpldir'); + foreach($specialValues as $index=>$value) { + $xmlCreator->add_tag($tagPath .'/'. $index, $value); + $attributes = array('setconstant'=>1); + if(array_search($index, $defineAsGlobal)) { + $attributes['setglobal']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); + } + + $skipSetConstant = array('version_string', 'workingonit'); foreach($myData as $index=>$value) { - $xmlCreator->add_tag($index, $value); + $xmlCreator->add_tag($tagPath ."/". $index, $value); + $attributes=array(); + if(!strlen(array_search($index, $skipSetConstant))) { + $attributes['setconstant']=1; + } + $xmlCreator->add_attribute($tagPath .'/'. $index, $attributes); } $extraAttributes = array( - 'generated' => date('Y-m-d H:m:s'), - 'version' => $myData['version_string'] + 'generated' => date('Y-m-d H:m:s'), + 'version' => $myData['version_string'], + 'usecssiteconfig' => 1 ); - $xmlCreator->add_attribute('/config/main', $extraAttributes); + $xmlCreator->add_attribute('/config', $extraAttributes); //now, create an XML string... $xmlString = $xmlCreator->create_xml_string(); Modified: trunk/1.2/includes/setup.inc =================================================================== --- trunk/1.2/includes/setup.inc 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/includes/setup.inc 2009-02-10 17:14:40 UTC (rev 962) @@ -22,7 +22,7 @@ $configObj = new config(NULL, FALSE); $configData = $configObj->read_config_file(FALSE); -if(strlen($configData['DATABASE__DBNAME'])) { +if(strlen($configData['DATABASE__DBNAME']) && !is_array($_SESSION['setup'])) { //setup already complete. Stop 'em. $page->set_message_wrapper(array( 'title' => "Setup Unavailable", Modified: trunk/1.2/lib/_unitTests_/cs-content_tests.php =================================================================== --- trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/lib/_unitTests_/cs-content_tests.php 2009-02-10 17:14:40 UTC (rev 962) @@ -95,7 +95,7 @@ ), 'styles' => array( 'select' => "field1='value1' AND field2='value2'", - 'insert' => "(field1, field2) VALUES ('value1', 'value2')", + 'insert' => "(field1, field2) VALUES ('value1','value2')", 'update' => "field1='value1', field2='value2'" ) ), @@ -113,7 +113,7 @@ foreach($testData as $name=>$data) { foreach($data['styles'] as $styleName => $expectedOutput) { $realOutput = $this->gfObj->string_from_array($data['input'], $styleName, NULL, 'sql'); - $this->assertEqual($realOutput, $expectedOutput, "invalid output for style (".$styleName ."): ". $realOutput); + $this->assertEqual($realOutput, $expectedOutput); } } }//end testSQLCreation() Modified: trunk/1.2/lib/config.class.php =================================================================== --- trunk/1.2/lib/config.class.php 2009-02-10 16:06:42 UTC (rev 961) +++ trunk/1.2/lib/config.class.php 2009-02-10 17:14:40 UTC (rev 962) @@ -48,11 +48,9 @@ $this->gf->debug_print(__METHOD__ .": converting to use sections..."); $this->convert_to_sections(); } - parent::__construct($this->fs->realcwd .'/'. $this->fileName); + $this->config = $this->get_config_contents(TRUE); } - - $this->config = $this->get_config_contents(TRUE); }//end __construct() //------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |