[CS-Project-svn_notify] SF.net SVN: cs-project: [838] trunk/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-02-14 07:05:13
|
Revision: 838 http://cs-project.svn.sourceforge.net/cs-project/?rev=838&view=rev Author: crazedsanity Date: 2008-02-13 23:05:11 -0800 (Wed, 13 Feb 2008) Log Message: ----------- Move building of update settings interface into config{}. NOTE::: some updates may need to be done to keep from segfaulting (through the need of config{} to create possibly multiple instances of itself within itself. Also, config::__construct() may need to be a bit less strict in order to avoid those same problems. Modified Paths: -------------- trunk/1.2/includes/content/settings.inc trunk/1.2/lib/config.class.php Modified: trunk/1.2/includes/content/settings.inc =================================================================== --- trunk/1.2/includes/content/settings.inc 2008-02-11 03:11:01 UTC (rev 837) +++ trunk/1.2/includes/content/settings.inc 2008-02-14 07:05:11 UTC (rev 838) @@ -131,61 +131,11 @@ if(count($page->ftsSections) == 3 && $page->ftsSections[2] == 'admin') { if($user->is_admin() == 1) { - //read the sample config. - require_once(dirname(__FILE__) .'/../../lib/config.class.php'); - $config = new config(dirname(__FILE__) .'/../../lib/config.xml', FALSE); - $myData = $config->get_config_contents(FALSE); + #debug_print(get_class($page)); - $mainAttributes = $myData['attributes']; - unset($myData['type'], $myData['attributes']); + $config = new config(); + $config->build_update_interface($page); - $parsedRows = ""; - $defaultRowName = 'setting_text'; - foreach($myData as $indexName=>$data) { - $attributes = $data['attributes']; - $value = $data['value']; - unset($data['type'], $data['attributes'], $data['value']); - $indexName = strtolower($indexName); - - //pull the appropriate template row. - $rowName = $defaultRowName; - if(strlen($attributes['TYPE'])) { - $rowName = 'setting_'. $attributes['TYPE']; - - $optionList = NULL; - if($attributes['TYPE'] == 'select' && isset($attributes['OPTIONS'])) { - #debug_print(explode('|', $attributes['OPTIONS'])); - $tmpOptionList = explode('|', $attributes['OPTIONS']); - $optionList = array(); - foreach($tmpOptionList as $optionInfo) { - $x = explode('=', $optionInfo); - $optionList[$x[0]] = $x[1]; - } - $optionList = $page->gfObj->array_as_option_list($optionList, $attributes['DEFAULT']); - } - } - - if(!isset($page->templateRows[$rowName])) { - throw new exception(__METHOD__ .": failed to retrieve block row named (". $rowName .")"); - } - - //now parse stuff into the row... - $repArr = array( - 'disabled' => $attributes['disabled'], - 'index' => $indexName, - 'title' => $attributes['TITLE'], - 'description' => $attributes['DESCRIPTION'], - 'value' => $value - ); - if(!is_null($optionList)) { - $repArr['setting_select__normal'] = $optionList; - } - $parsedRows .= $page->mini_parser($page->templateRows[$rowName], $repArr); - } - #debug_print($parsedRows); - $page->add_template_var($defaultRowName, $parsedRows); - - //create an object with administrative capabilities. $adminUserClass = new adminUserClass($page->db); Modified: trunk/1.2/lib/config.class.php =================================================================== --- trunk/1.2/lib/config.class.php 2008-02-11 03:11:01 UTC (rev 837) +++ trunk/1.2/lib/config.class.php 2008-02-14 07:05:11 UTC (rev 838) @@ -93,5 +93,68 @@ return($config); }//end read_config_file() //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Create a page (portion of a page, actually) to set/update config settings. + */ + public function build_update_interface(cs_genericPage &$page) { + + //read the sample config. + $config = new config(dirname(__FILE__) .'/config.xml', FALSE); + $myData = $config->get_config_contents(FALSE); + + $mainAttributes = $myData['attributes']; + unset($myData['type'], $myData['attributes']); + + $parsedRows = ""; + $defaultRowName = 'setting_text'; + foreach($myData as $indexName=>$data) { + $attributes = $data['attributes']; + $value = $data['value']; + unset($data['type'], $data['attributes'], $data['value']); + $indexName = strtolower($indexName); + + //pull the appropriate template row. + $rowName = $defaultRowName; + if(strlen($attributes['TYPE'])) { + $rowName = 'setting_'. $attributes['TYPE']; + + $optionList = NULL; + if($attributes['TYPE'] == 'select' && isset($attributes['OPTIONS'])) { + #debug_print(explode('|', $attributes['OPTIONS'])); + $tmpOptionList = explode('|', $attributes['OPTIONS']); + $optionList = array(); + foreach($tmpOptionList as $optionInfo) { + $x = explode('=', $optionInfo); + $optionList[$x[0]] = $x[1]; + } + $optionList = $page->gfObj->array_as_option_list($optionList, $attributes['DEFAULT']); + } + } + + if(!isset($page->templateRows[$rowName])) { + throw new exception(__METHOD__ .": failed to retrieve block row named (". $rowName .")"); + } + + //now parse stuff into the row... + $repArr = array( + 'disabled' => $attributes['disabled'], + 'index' => $indexName, + 'title' => $attributes['TITLE'], + 'description' => $attributes['DESCRIPTION'], + 'value' => $value + ); + if(!is_null($optionList)) { + $repArr['setting_select__normal'] = $optionList; + } + $parsedRows .= $page->mini_parser($page->templateRows[$rowName], $repArr); + } + #debug_print($parsedRows); + $page->add_template_var($defaultRowName, $parsedRows); + }//end build_update_interface() + //------------------------------------------------------------------------- }//end config{} ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |