Thread: [fusionregistry-commitlog] SF.net SVN: fusionregistry: [8] branches/stable_3_0_x/upload/sources
Brought to you by:
copland007
From: SVN c. <fus...@li...> - 2007-06-15 05:12:18
|
Revision: 8 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=8&view=rev Author: copland007 Date: 2007-06-14 22:12:19 -0700 (Thu, 14 Jun 2007) Log Message: ----------- Remove trailing newline to prevent IPB Whitespace Checker from reporting these files. Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_permissions.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/session.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/upload.php branches/stable_3_0_x/upload/sources/tasks/registrysessions.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php 2007-06-15 05:12:19 UTC (rev 8) @@ -423,4 +423,4 @@ $this->ipsclass->admin->output(); } } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_permissions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_permissions.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_permissions.php 2007-06-15 05:12:19 UTC (rev 8) @@ -542,4 +542,4 @@ $this->ipsclass->admin->output(); } } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php 2007-06-15 05:12:19 UTC (rev 8) @@ -713,4 +713,4 @@ } } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2007-06-15 05:12:19 UTC (rev 8) @@ -1084,4 +1084,4 @@ } } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2007-06-15 05:12:19 UTC (rev 8) @@ -377,4 +377,4 @@ } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php 2007-06-15 05:12:19 UTC (rev 8) @@ -379,4 +379,4 @@ } } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/session.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/session.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/session.php 2007-06-15 05:12:19 UTC (rev 8) @@ -562,4 +562,4 @@ } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/upload.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/upload.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/upload.php 2007-06-15 05:12:19 UTC (rev 8) @@ -604,4 +604,4 @@ } -?> +?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/tasks/registrysessions.php =================================================================== --- branches/stable_3_0_x/upload/sources/tasks/registrysessions.php 2007-06-13 03:54:02 UTC (rev 7) +++ branches/stable_3_0_x/upload/sources/tasks/registrysessions.php 2007-06-15 05:12:19 UTC (rev 8) @@ -113,4 +113,4 @@ } } -?> +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. <fus...@li...> - 2008-02-10 07:18:59
|
Revision: 34 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=34&view=rev Author: copland007 Date: 2008-02-09 23:19:03 -0800 (Sat, 09 Feb 2008) Log Message: ----------- Introduced make/model cache 'registry_makemodel'. Implemented on 'add new item' and all acp make/model pages that modify database tables. Added an on-demand rebuild of registry_makemodel cache tool. Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php 2008-02-10 05:28:00 UTC (rev 33) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php 2008-02-10 07:19:03 UTC (rev 34) @@ -46,6 +46,7 @@ */ require_once( AD_REGISTRY_PATH.'ad_registry_loader.php' ); require_once( REGISTRY_PATH.'lib/custom_fields.php' ); +require_once( REGISTRY_PATH.'lib/functions.php' ); /** * Class ad_registry_makes_models deals with the vehicle makes & models of the Fusion Registry @@ -89,9 +90,11 @@ $this->ad_registry_loader->ipsclass =& $this->ipsclass; $this->ad_registry_loader->auto_run(&$this); - // Initialize custom_fields + // Initialize custom_fields and functions $this->lib['custom_fields'] = new registry_custom_fields(&$class); $this->lib['custom_fields']->ipsclass =& $this->ipsclass; + $this->lib['functions'] = new registry_functions(&$class); + $this->lib['functions']->ipsclass =& $this->ipsclass; switch($this->ipsclass->input['code']) { @@ -176,6 +179,9 @@ $added_makes .= "$make, "; } + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $added_makes = substr($added_makes, 0, -2); $text = "Added Fusion Registry Vehicle Make(s) '$added_makes'"; @@ -230,6 +236,9 @@ $added_models .= "$model, "; } + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $added_models = substr($added_models, 0, -2); $text = "Added Fusion Registry Vehicle Model(s) '$added_models'"; @@ -522,6 +531,9 @@ $this->ipsclass->DB->query("UPDATE ibf_registry_makes SET $db_string WHERE id='".$this->ipsclass->input['make_id']."'"); + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $text = "Modified Fusion Registry Make ID: '{$this->ipsclass->input['make_id']}' to '{$this->ipsclass->input['change_to']}'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=make_menu'; $time = 2; @@ -552,6 +564,9 @@ $this->ipsclass->DB->query("UPDATE ibf_registry_models SET $db_string WHERE id='".$this->ipsclass->input['model_id']."'"); + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $text = "Modified Fusion Registry Model ID: '{$this->ipsclass->input['model_id']}' to '{$this->ipsclass->input['change_to']}'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=model_menu&make_id='. $this->ipsclass->input['make_id']; $time = 2; @@ -719,6 +734,9 @@ // Delete any models of this make $this->ipsclass->DB->query("DELETE FROM ibf_registry_models WHERE make_id IN $sql_make_ids"); + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $text = "Deleted Fusion Registry Vehicle Make '$make_to_delete' and Models"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=make_menu'; $time = 2; @@ -886,6 +904,9 @@ // Bye-Bye... delete the model $this->ipsclass->DB->query("DELETE FROM ibf_registry_models WHERE id IN $sql_model_ids"); + // Rebuild cache + $this->lib['functions']->update_makemodel_cache(); + $text = "Deleted Fusion Registry Vehicle Model '$model_to_delete'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=model_menu&make_id='. $this->ipsclass->input['make_id']; $time = 2; Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php 2008-02-10 05:28:00 UTC (rev 33) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php 2008-02-10 07:19:03 UTC (rev 34) @@ -46,6 +46,7 @@ */ require_once( AD_REGISTRY_PATH.'ad_registry_loader.php' ); require_once( KERNEL_PATH.'class_image.php' ); +require_once( REGISTRY_PATH.'lib/functions.php' ); /**#@-*/ /** @@ -109,6 +110,10 @@ $this->db_remove_1742529(); break; + case 'rebuild_makemodel_cache': + $this->rebuild_makemodel_cache(); + break; + default: $this->main_menu(); break; @@ -401,6 +406,29 @@ /** + * Rebuild make/model cache + */ + function rebuild_makemodel_cache() + { + $registry_funcs = new registry_functions(); + $registry_funcs->ipsclass =& $this->ipsclass; + + $registry_funcs->update_makemodel_cache(); + + // Report our mischief ways :) + $text = "<b>Fusion Registry make/model cache rebuilt</b>"; + $url = "act=".REGISTRY_URL."§ion=components&menu=tools"; + $time = 5; + + // Big brother is watching :) + $this->ipsclass->admin->save_log("Rebuilt Fusion Registry make/model cache"); + + // End of the show, c'ya + $this->ipsclass->admin->redirect( $url, $text, 0, $time ); + } + + + /** * Rebuild All Thumbnails * * If the end user opted to create a log we will use function {@link _log} @@ -916,6 +944,26 @@ $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); + $this->ipsclass->html .= '<br />'; + + //------------------------------- + // Rebuild make/model cache tool + //------------------------------- + + $this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code', 'rebuild_makemodel_cache' ), + 2 => array( 'act' , REGISTRY_URL ), + 3 => array( 'menu', 'tools' ), + 4 => array( 'section', 'components' ), + ) ); + + $desc = 'The rebuild make/model cache tool will refresh the cache of all the makes and models in the database.'; + + $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Rebuild make/model cache", $desc ); + + $this->ipsclass->html .= $this->ipsclass->adskin->end_form('Rebuild make/model cache'); + + $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); + // That's all folk! $this->ipsclass->admin->output(); } Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-10 05:28:00 UTC (rev 33) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-10 07:19:03 UTC (rev 34) @@ -180,26 +180,24 @@ $return = ''; - $make_q_id = $this->ipsclass->DB->query("SELECT id, make FROM ibf_registry_makes ORDER BY make ASC"); + // Load the cache + $this->ipsclass->init_load_cache( array( 'registry_makemodel' ) ); // Loop through all the makes - while ( $make_row = $this->ipsclass->DB->fetch_row($make_q_id) ) + foreach ( $this->ipsclass->cache['registry_makemodel'] as $make_id => $make_array ) { // Start this makes' row in the output, this is where it gets confusing! - $return .= 'cars["'.$make_row['make'].'"] = new Array("'.$make_row['id'].'", new Array('; + $return .= 'cars["'.$make_array['name'].'"] = new Array("'.$make_id.'", new Array('; - $model_q_id = $this->ipsclass->DB->query("SELECT id, model FROM ibf_registry_models - WHERE make_id='".$make_row['id']."' ORDER BY model ASC"); - $model_string = ''; $model_id_string = ''; // Loop through all the models of this make - while ( $model_row = $this->ipsclass->DB->fetch_row($model_q_id) ) + foreach ( $make_array['models'] as $model_id => $model_name ) { // Create the arrays that we will use in the output - $model_string .= '"'.$model_row['model'].'",'; - $model_id_string .= '"'.$model_row['id'] .'",'; + $model_string .= '"'.$model_name.'",'; + $model_id_string .= '"'.$model_id .'",'; } // Strip off the last comma @@ -375,6 +373,40 @@ return TRUE; } + + /** + * Update/Rebuild make and model cache + * + * This gets run any time a change is made to makes/models, and + * on demand in the ACP tools. + */ + function update_makemodel_cache() + { + // Start with an empty cache + $this->ipsclass->cache['registry_makemodel'] = array(); + + // Loop through each make + $make_q_id = $this->ipsclass->DB->query("SELECT id, make FROM ibf_registry_makes"); + + // Loop through all the makes + while ( $make_row = $this->ipsclass->DB->fetch_row($make_q_id) ) + { + // Create the base make entry + $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ] = array( 'name' => $make_row['make'], + 'models' => array() ); + + $model_q_id = $this->ipsclass->DB->query("SELECT id, model FROM ibf_registry_models WHERE make_id='".$make_row['id']."'"); + + // Loop through all the models of this make + while ( $model_row = $this->ipsclass->DB->fetch_row($model_q_id) ) + { + $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ]['models'][ $model_row['id'] ] = $model_row['model']; + } + } + + // Save it back to the cache_store + $this->ipsclass->update_cache( array( 'name' => 'registry_makemodel', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. <fus...@li...> - 2008-02-11 07:39:40
|
Revision: 36 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=36&view=rev Author: copland007 Date: 2008-02-10 23:39:45 -0800 (Sun, 10 Feb 2008) Log Message: ----------- Implemented multi-cache support, add cache control to ACP Tools page. Support for new caches added not yet implemented (config, field_defs, rating_defs). Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_config.php 2008-02-11 07:39:45 UTC (rev 36) @@ -420,5 +420,29 @@ // That's all folk! $this->ipsclass->admin->output(); } + + + /** + * Update/Rebuild cache + * + * This gets run any time a change is made and on demand in the ACP tools. + */ + function update_cache() + { + // Start with an empty cache + $this->ipsclass->cache['registry_config'] = array(); + + $this->ipsclass->DB->simple_construct( array( 'select' => 'config_name,config_value', 'from' => 'registry_config' ) ); + $this->ipsclass->DB->simple_exec(); + + // Loop through each setting + while ( $row = $this->ipsclass->DB->fetch_row() ) + { + $this->ipsclass->cache['registry_config'][ $row['config_name'] ] = $row['config_value']; + } + + // Save it back to the cache_store + $this->ipsclass->update_cache( array( 'name' => 'registry_config', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + } } ?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-11 07:39:45 UTC (rev 36) @@ -787,5 +787,42 @@ return $field_array; } + + + /** + * Update/Rebuild cache + * + * This gets run any time a change is made and on demand in the ACP tools. + */ + function update_cache() + { + // Start with an empty cache + $this->ipsclass->cache['registry_field_defs'] = array(); + + $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'registry_field_defs' ) ); + $this->ipsclass->DB->simple_exec(); + + // Loop through each setting + while ( $row = $this->ipsclass->DB->fetch_row() ) + { + $this->ipsclass->cache['registry_field_defs'][ $row['field_id'] ] = array( 'field_name' => $row['field_name'], + 'field_type' => $row['field_type'], + 'field_options' => $row['field_options'], + 'field_default' => $row['field_default'], + 'field_required' => $row['field_required'], + 'field_size' => $row['field_size'], + 'field_rows' => $row['field_rows'], + 'field_cols' => $row['field_cols'], + 'field_order' => $row['field_order'], + 'field_browse' => $row['field_browse'], + 'field_group_id' => $row['field_group_id'], + 'field_highlight' => $row['field_highlight'], + 'field_search' => $row['field_search'], + ); + } + + // Save it back to the cache_store + $this->ipsclass->update_cache( array( 'name' => 'registry_field_defs', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + } } ?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_makes_models.php 2008-02-11 07:39:45 UTC (rev 36) @@ -90,11 +90,9 @@ $this->ad_registry_loader->ipsclass =& $this->ipsclass; $this->ad_registry_loader->auto_run(&$this); - // Initialize custom_fields and functions + // Initialize custom_fields $this->lib['custom_fields'] = new registry_custom_fields(&$class); $this->lib['custom_fields']->ipsclass =& $this->ipsclass; - $this->lib['functions'] = new registry_functions(&$class); - $this->lib['functions']->ipsclass =& $this->ipsclass; switch($this->ipsclass->input['code']) { @@ -180,7 +178,7 @@ } // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $added_makes = substr($added_makes, 0, -2); @@ -237,7 +235,7 @@ } // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $added_models = substr($added_models, 0, -2); @@ -532,7 +530,7 @@ $this->ipsclass->DB->query("UPDATE ibf_registry_makes SET $db_string WHERE id='".$this->ipsclass->input['make_id']."'"); // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $text = "Modified Fusion Registry Make ID: '{$this->ipsclass->input['make_id']}' to '{$this->ipsclass->input['change_to']}'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=make_menu'; @@ -565,7 +563,7 @@ $this->ipsclass->DB->query("UPDATE ibf_registry_models SET $db_string WHERE id='".$this->ipsclass->input['model_id']."'"); // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $text = "Modified Fusion Registry Model ID: '{$this->ipsclass->input['model_id']}' to '{$this->ipsclass->input['change_to']}'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=model_menu&make_id='. $this->ipsclass->input['make_id']; @@ -735,7 +733,7 @@ $this->ipsclass->DB->query("DELETE FROM ibf_registry_models WHERE make_id IN $sql_make_ids"); // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $text = "Deleted Fusion Registry Vehicle Make '$make_to_delete' and Models"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=make_menu'; @@ -905,7 +903,7 @@ $this->ipsclass->DB->query("DELETE FROM ibf_registry_models WHERE id IN $sql_model_ids"); // Rebuild cache - $this->lib['functions']->update_makemodel_cache(); + $this->update_cache(); $text = "Deleted Fusion Registry Vehicle Model '$model_to_delete'"; $url = 'act='.REGISTRY_URL.'§ion=components&menu=makes_models&code=model_menu&make_id='. $this->ipsclass->input['make_id']; @@ -917,4 +915,37 @@ // End of the show, c'ya $this->ipsclass->admin->redirect( $url, $text, 0, $time ); } + + /** + * Update/Rebuild cache + * + * This gets run any time a change is made and on demand in the ACP tools. + */ + function update_cache() + { + // Start with an empty cache + $this->ipsclass->cache['registry_makemodel'] = array(); + + // Loop through each make + $make_q_id = $this->ipsclass->DB->query("SELECT id, make FROM ibf_registry_makes"); + + // Loop through all the makes + while ( $make_row = $this->ipsclass->DB->fetch_row($make_q_id) ) + { + // Create the base make entry + $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ] = array( 'name' => $make_row['make'], + 'models' => array() ); + + $model_q_id = $this->ipsclass->DB->query("SELECT id, model FROM ibf_registry_models WHERE make_id='".$make_row['id']."'"); + + // Loop through all the models of this make + while ( $model_row = $this->ipsclass->DB->fetch_row($model_q_id) ) + { + $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ]['models'][ $model_row['id'] ] = $model_row['model']; + } + } + + // Save it back to the cache_store + $this->ipsclass->update_cache( array( 'name' => 'registry_makemodel', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + } } \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-11 07:39:45 UTC (rev 36) @@ -413,5 +413,31 @@ // End of the show, c'ya $this->ipsclass->admin->redirect( $url, $text, 0, $time ); } + + + /** + * Update/Rebuild cache + * + * This gets run any time a change is made and on demand in the ACP tools. + */ + function update_cache() + { + // Start with an empty cache + $this->ipsclass->cache['registry_rating_defs'] = array(); + + $this->ipsclass->DB->simple_construct( array( 'select' => 'rating_id,rating_name,rating_order', 'from' => 'registry_rating_defs' ) ); + $this->ipsclass->DB->simple_exec(); + + // Loop through each setting + while ( $row = $this->ipsclass->DB->fetch_row() ) + { + $this->ipsclass->cache['registry_rating_defs'][ $row['rating_id'] ] = array( 'rating_name' => $row['rating_name'], + 'rating_order' => $row['rating_order'], + ); + } + + // Save it back to the cache_store + $this->ipsclass->update_cache( array( 'name' => 'registry_rating_defs', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + } } ?> \ No newline at end of file Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_tools.php 2008-02-11 07:39:45 UTC (rev 36) @@ -46,7 +46,6 @@ */ require_once( AD_REGISTRY_PATH.'ad_registry_loader.php' ); require_once( KERNEL_PATH.'class_image.php' ); -require_once( REGISTRY_PATH.'lib/functions.php' ); /**#@-*/ /** @@ -61,11 +60,15 @@ var $ipsclass; var $ad_registry_loader; var $ad_registry_verify; + var $fr_cache; /**#@-*/ /** @var resource */ var $log_handle; + /** @var array */ + var $map; + /** * Intialization of ad_registry_tools * @@ -88,6 +91,18 @@ $this->ad_registry_loader->ipsclass =& $this->ipsclass; $this->ad_registry_loader->auto_run(&$this); + // Load the base skin_tools skin to piggy back the cache templates + $this->html = $this->ipsclass->acp_load_template('cp_skin_tools'); + $this->ipsclass->form_code .= "&menu=tools"; + $this->ipsclass->form_code_js .= "&menu=tools"; + + // Cache mappings + $this->map = array( 'registry_makemodel' => 'All automobile makes and models', + 'registry_config' => 'Runtime configuration', + 'registry_field_defs' => 'Custom field definitions', + 'registry_rating_defs' => 'Custom rating definitions', + ); + switch($this->ipsclass->input['code']) { case 'rebuild_thumbs': @@ -110,9 +125,21 @@ $this->db_remove_1742529(); break; - case 'rebuild_makemodel_cache': - $this->rebuild_makemodel_cache(); + case 'cacheend': + $this->cache_end(); break; + + case 'viewcache': + $this->view_cache(); + break; + + case 'cache_update_all': + $this->ipsclass->admin->output_multiple_redirect_init( $this->ipsclass->base_url.'&'.$this->ipsclass->form_code_js.'&code=cache_update_all_process&id=0' ); + break; + + case 'cache_update_all_process': + $this->cache_update_all_process(); + break; default: $this->main_menu(); @@ -406,29 +433,135 @@ /** - * Rebuild make/model cache + * Rebuild cache */ - function rebuild_makemodel_cache() + function cache_end( $cache_name='', $dontcancel=0 ) { - $registry_funcs = new registry_functions(); - $registry_funcs->ipsclass =& $this->ipsclass; + if ( ! $cache_name ) + { + $cache_name = $this->ipsclass->input['cache']; + } - $registry_funcs->update_makemodel_cache(); + switch ( $cache_name ) + { + case 'registry_makemodel': + require_once( AD_REGISTRY_PATH.'ad_makes_models.php' ); + $this->fr_cache = new ad_registry_makes_models(); + $this->fr_cache->ipsclass =& $this->ipsclass; - // Report our mischief ways :) - $text = "<b>Fusion Registry make/model cache rebuilt</b>"; - $url = "act=".REGISTRY_URL."§ion=components&menu=tools"; - $time = 5; + $this->fr_cache->update_cache(); + $this->ipsclass->main_msg = 'Registry Make/Model cache updated'; + break; - // Big brother is watching :) - $this->ipsclass->admin->save_log("Rebuilt Fusion Registry make/model cache"); + case 'registry_config': + require_once( AD_REGISTRY_PATH.'ad_config.php' ); + $this->fr_cache = new ad_registry_config(); + $this->fr_cache->ipsclass =& $this->ipsclass; - // End of the show, c'ya - $this->ipsclass->admin->redirect( $url, $text, 0, $time ); + $this->fr_cache->update_cache(); + $this->ipsclass->main_msg = 'Registry configuration cache updated'; + break; + + case 'registry_field_defs': + require_once( AD_REGISTRY_PATH.'ad_custom_fields.php' ); + $this->fr_cache = new ad_registry_custom_fields(); + $this->fr_cache->ipsclass =& $this->ipsclass; + + $this->fr_cache->update_cache(); + $this->ipsclass->main_msg = 'Registry custom field cache updated'; + break; + + case 'registry_rating_defs': + require_once( AD_REGISTRY_PATH.'ad_rating_fields.php' ); + $this->fr_cache = new ad_registry_rating_fields(); + $this->fr_cache->ipsclass =& $this->ipsclass; + + $this->fr_cache->update_cache(); + $this->ipsclass->main_msg = 'Registry custom field cache updated'; + break; + + default: + $this->ipsclass->main_msg = 'No valid cache was specified to update'; + break; + } + + if ( ! $dontcancel ) + { + $this->main_menu(); + } } /** + * View cache + */ + function view_cache() + { + if ( ! $this->ipsclass->input['cache'] ) + { + $this->ipsclass->main_msg = "No ID was passed, please try again"; + $this->cache_start(); + } + + $row = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'cs_array,cs_value', 'from' => 'cache_store', + 'where' => "cs_key='{$this->ipsclass->input['cache']}'" ) ); + + ob_start(); + if ( $row['cs_array'] ) + { + print_r( unserialize($this->ipsclass->txt_stripslashes($row['cs_value'])) ); + } + else + { + print $row['cs_value']; + } + + $out = ob_get_contents(); + ob_end_clean(); + + $this->ipsclass->html = "<pre>".htmlspecialchars($out)."</pre>"; + + $this->ipsclass->admin->print_popup(); + } + + + /** + * Update all caches + */ + function cache_update_all_process() + { + $id = intval( $this->ipsclass->input['id'] ); + $cache_name = ''; + $count = 0; + $img = '<img src="'.$this->ipsclass->skin_acp_url.'/images/aff_tick_small.png" border="0" alt="-" /> '; + + // Get cache name + foreach( $this->map as $name => $desc ) + { + if ( $count == $id ) + { + $cache_name = $name; + break; + } + + $count++; + } + + $id++; + if ( $cache_name ) + { + $this->cache_end( $cache_name, 1 ); + + $this->ipsclass->admin->output_multiple_redirect_hit( $this->ipsclass->base_url.'&'.$this->ipsclass->form_code_js.'&code=cache_update_all_process&id='.$id, $img.$cache_name.' processed...' ); + } + else + { + $this->ipsclass->admin->output_multiple_redirect_done(); + } + } + + + /** * Rebuild All Thumbnails * * If the end user opted to create a log we will use function {@link _log} @@ -878,6 +1011,53 @@ $this->ipsclass->html .= $this->ipsclass->skin_acp_global->information_box( "Fusion Registry Tools", "Below are tools that can help you keep your Fusion Registry running smooth.".'<br /> ' ) . "<br >"; //------------------------------- + // Cache + //------------------------------- + + $used = array(); + $cache_html = ""; + $cache_keys = implode("','", array_keys( $this->map ) ); + + $this->ipsclass->DB->simple_construct( array( 'select' => 'cs_key,cs_value,cs_array', 'from' => 'cache_store', + 'where' => "cs_key IN ('$cache_keys')", 'order' => 'cs_key' ) ); + $this->ipsclass->DB->simple_exec(); + + while ( $row = $this->ipsclass->DB->fetch_row() ) + { + // Keep track of the caches actually in the db + $used[ $row['cs_key'] ] = $row['cs_key']; + $row['_size'] = ceil( intval( strlen( $row['cs_value'] ) ) / 1024 ); + $row['_desc'] = $this->map[ $row['cs_key'] ]; + + $cache_html .= $this->html->cache_row( $row ); + } + + // cache entries in map that aren't in the db + if ( count( $used ) != count( $this->map ) ) + { + foreach( $this->map as $k => $v ) + { + if ( in_array( $k, array_keys( $used ) ) ) + { + continue; + } + else + { + $row['cs_key'] = $k; + $row['cs_value'] = $v; + $row['_size'] = 0; + $row['_desc'] = $this->map[ $row['cs_key'] ]; + + $cache_html .= $this->html->cache_row( $row ); + } + } + } + + $this->ipsclass->html .= $this->html->cache_overview( $cache_html ); + + $this->ipsclass->html .= '<br /><br />'; + + //------------------------------- // Rebuild Thumbs //------------------------------- @@ -944,26 +1124,6 @@ $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); - $this->ipsclass->html .= '<br />'; - - //------------------------------- - // Rebuild make/model cache tool - //------------------------------- - - $this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code', 'rebuild_makemodel_cache' ), - 2 => array( 'act' , REGISTRY_URL ), - 3 => array( 'menu', 'tools' ), - 4 => array( 'section', 'components' ), - ) ); - - $desc = 'The rebuild make/model cache tool will refresh the cache of all the makes and models in the database.'; - - $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Rebuild make/model cache", $desc ); - - $this->ipsclass->html .= $this->ipsclass->adskin->end_form('Rebuild make/model cache'); - - $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); - // That's all folk! $this->ipsclass->admin->output(); } Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-10 19:18:29 UTC (rev 35) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-11 07:39:45 UTC (rev 36) @@ -376,41 +376,6 @@ return TRUE; } - - - /** - * Update/Rebuild make and model cache - * - * This gets run any time a change is made to makes/models, and - * on demand in the ACP tools. - */ - function update_makemodel_cache() - { - // Start with an empty cache - $this->ipsclass->cache['registry_makemodel'] = array(); - - // Loop through each make - $make_q_id = $this->ipsclass->DB->query("SELECT id, make FROM ibf_registry_makes"); - - // Loop through all the makes - while ( $make_row = $this->ipsclass->DB->fetch_row($make_q_id) ) - { - // Create the base make entry - $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ] = array( 'name' => $make_row['make'], - 'models' => array() ); - - $model_q_id = $this->ipsclass->DB->query("SELECT id, model FROM ibf_registry_models WHERE make_id='".$make_row['id']."'"); - - // Loop through all the models of this make - while ( $model_row = $this->ipsclass->DB->fetch_row($model_q_id) ) - { - $this->ipsclass->cache['registry_makemodel'][ $make_row['id'] ]['models'][ $model_row['id'] ] = $model_row['model']; - } - } - - // Save it back to the cache_store - $this->ipsclass->update_cache( array( 'name' => 'registry_makemodel', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); - } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. <fus...@li...> - 2008-02-13 05:13:46
|
Revision: 40 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=40&view=rev Author: copland007 Date: 2008-02-12 21:13:52 -0800 (Tue, 12 Feb 2008) Log Message: ----------- Add cache support to build_category_html() Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-12 06:54:16 UTC (rev 39) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-13 05:13:52 UTC (rev 40) @@ -446,7 +446,7 @@ } // Save it back to the cache_store - $this->ipsclass->update_cache( array( 'name' => 'registry_rating_defs', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); + $this->ipsclass->update_cache( array( 'name' => 'registry_rating_defs', 'array' => 1, 'deletefirst' => 1, 'donow' => 0 ) ); } } -?> \ No newline at end of file +?> Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-12 06:54:16 UTC (rev 39) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-13 05:13:52 UTC (rev 40) @@ -106,20 +106,26 @@ */ function build_category_html($data = array()) { + // Load the cache + $this->ipsclass->init_load_cache( array( 'registry_categories' ) ); + // Build the category select HTML $categories_html = '<select name="category" class="forminput">'; - $this->ipsclass->DB->query("SELECT * FROM ibf_registry_categories ORDER BY title ASC"); - while ( $cat_row = $this->ipsclass->DB->fetch_row() ) + if ( isset( $this->ipsclass->cache['registry_categories'] ) && + is_array( $this->ipsclass->cache['registry_categories'] ) ) { - if ( $cat_row['id'] == $data['selected'] ) + foreach ( $this->ipsclass->cache['registry_categories'] as $cat_id => $cat_title ) { - $categories_html .= '<option value="'.$cat_row['id'].'" selected="selected">'.$cat_row['title'].'</option>'; + if ( $cat_id == $data['selected'] ) + { + $categories_html .= '<option value="'.$cat_id.'" selected="selected">'.$cat_title.'</option>'; + } + else + { + $categories_html .= '<option value="'.$cat_id.'">'.$cat_title.'</option>'; + } } - else - { - $categories_html .= '<option value="'.$cat_row['id'].'">'.$cat_row['title'].'</option>'; - } } // Finish off the category select HTML @@ -378,4 +384,4 @@ } } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. <fus...@li...> - 2008-02-16 20:58:32
|
Revision: 45 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=45&view=rev Author: copland007 Date: 2008-02-16 12:58:37 -0800 (Sat, 16 Feb 2008) Log Message: ----------- The first level key returned from any of the cf cache get routines is no longer the field_id, it is just a reference number. Switch all post-get logic to use sub key 'field_id' as the guaranteed field_id of what was retrieved. Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/main.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-16 20:58:37 UTC (rev 45) @@ -692,7 +692,7 @@ $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Fusion Registry Custom Fields" ); // Loop through our custom field definitions we got from up above - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_rum => $cf_row ) { $this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( '<center><a href="'.$this->ipsclass->base_url.'&act='.REGISTRY_URL.'§ion=components&menu=custom_fields&code=edit&f='.$cf_row['field_id'].'">'. $this->ad_registry_loader->imgs['edit'] .'</a></center>', '<center><a href="javascript:confirm_delete_field( '.$cf_row['field_id'].' )">'. $this->ad_registry_loader->imgs['delete'] .'</a></center>', Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php 2008-02-16 20:58:37 UTC (rev 45) @@ -333,18 +333,18 @@ $cf_required = array(); - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_num => $cf_row ) { if ( $cf_row['field_required'] == 1 ) { - $cf_required[$cf_id] = $cf_row; + $cf_required[ $cf_row['field_id'] ] = $cf_row; } } // Compile list of missing fields (if any) $missing_fields = ''; - foreach ( $cf_required as $cf_id => $cf_row ) + foreach ( $cf_required as $cf_num => $cf_row ) { // We have to special case the make/model since they don't use the field_id as the field name if ( $cf_row['field_options'] == 'make' or $cf_row['field_options'] == 'model' ) @@ -356,7 +356,7 @@ } else { - if ( !isset($this->ipsclass->input[$cf_id]) or empty($this->ipsclass->input[$cf_id]) ) + if ( !isset($this->ipsclass->input[ $cf_row['field_id'] ]) or empty($this->ipsclass->input[ $cf_row['field_id'] ]) ) { $missing_fields .= $cf_row['field_name'] . ', '; } @@ -394,17 +394,17 @@ unset($db_string); // Now save their custom field data - foreach ( $cf_input as $cf_id => $cf_value ) + foreach ( $cf_input as $cf_num => $cf_value ) { // Determine if we need to update or insert row - $rs = $this->ipsclass->DB->query("SELECT entry_id FROM ibf_registry_field_entries WHERE item_id = '". $this->ipsclass->input['CID'] ."' AND field_id = '$cf_id'"); + $rs = $this->ipsclass->DB->query("SELECT entry_id FROM ibf_registry_field_entries WHERE item_id = '". $this->ipsclass->input['CID'] ."' AND field_id = '". $cf_row['field_id'] ."'"); $existing = $this->ipsclass->DB->fetch_row($rs); if ( isset($existing['entry_id']) and !empty($existing['entry_id']) ) { // Update existing entry - $db_string = $this->ipsclass->DB->compile_db_update_string( array( 'field_id' => $cf_id, + $db_string = $this->ipsclass->DB->compile_db_update_string( array( 'field_id' => $cf_row['field_id'], 'item_id' => $this->ipsclass->input['CID'], 'field_value' => $cf_value, ) ); @@ -414,7 +414,7 @@ else { // Insert new entry - $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_id, + $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_row['field_id'], 'item_id' => $this->ipsclass->input['CID'], 'field_value' => $cf_value, ) ); @@ -473,18 +473,18 @@ $cf_required = array(); - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_num => $cf_row ) { if ( $cf_row['field_required'] == 1 ) { - $cf_required[$cf_id] = $cf_row; + $cf_required[ $cf_row['field_id'] ] = $cf_row; } } // Compile list of missing fields (if any) $missing_fields = ''; - foreach ( $cf_required as $cf_id => $cf_row ) + foreach ( $cf_required as $cf_num => $cf_row ) { // We have to special case the make/model since they don't use the field_id as the field name if ( $cf_row['field_options'] == 'make' or $cf_row['field_options'] == 'model' ) @@ -496,7 +496,7 @@ } else { - if ( !isset($this->ipsclass->input[$cf_id]) or empty($this->ipsclass->input[$cf_id]) ) + if ( !isset($this->ipsclass->input[ $cf_row['field_id'] ]) or empty($this->ipsclass->input[ $cf_row['field_id'] ]) ) { $missing_fields .= $cf_row['field_name'] . ', '; } @@ -545,9 +545,9 @@ $cid = $this->ipsclass->DB->get_insert_id(); // Now save their custom field data - foreach ( $cf_input as $cf_id => $cf_value ) + foreach ( $cf_input as $cf_num => $cf_value ) { - $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_id, + $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_row['field_id'], 'item_id' => $cid, 'field_value' => $cf_value, ) ); Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/content.php 2008-02-16 20:58:37 UTC (rev 45) @@ -132,7 +132,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // Grab the vehicle info and prep the HTML $this->ipsclass->DB->query("SELECT g.id, g.image_id, g.member_id, images.attach_id, images.attach_hits, @@ -256,9 +261,9 @@ // Process the highlight field values $vehicle_data['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $vehicle_data['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $vehicle_data['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $vehicle_data['highlight_fields'] .= ' '; } @@ -293,7 +298,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_lastcommented_limit'] ? $this->class->registry_config['tmpl_lastcommented_limit'] : 10; @@ -314,9 +324,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -358,7 +368,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_lastupdateditems_limit'] ? $this->class->registry_config['tmpl_lastupdateditems_limit'] : 10; @@ -378,9 +393,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -459,7 +474,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_mostmodded_limit'] ? $this->class->registry_config['tmpl_mostmodded_limit'] : 10; @@ -481,9 +501,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -520,7 +540,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_mostmoneyspent_limit'] ? $this->class->registry_config['tmpl_mostmoneyspent_limit'] : 10; @@ -542,9 +567,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -583,7 +608,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_mostviewed_limit'] ? $this->class->registry_config['tmpl_mostviewed_limit'] : 10; @@ -603,9 +633,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -641,7 +671,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // What's the count? Default to 10 $limit = $this->class->registry_config['tmpl_newestitems_limit'] ? $this->class->registry_config['tmpl_newestitems_limit'] : 10; @@ -661,9 +696,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2008-02-16 20:58:37 UTC (rev 45) @@ -146,7 +146,7 @@ * @param array $opts Optional custom cmd/value pair attributes * @return array An array of an array, outer key is field_id */ - function get_cf_defs($opts=array(), $live=0) + function get_cf_defs($opts=array()) { $results = $this->ipsclass->cache['registry_field_defs']; @@ -192,7 +192,7 @@ * @param array $opts Optional custom SQL cmd/value pair attributes * @return array An array of an array, outer key is field_id */ - function get_cf_defs_live($opts=array(), $live=0) + function get_cf_defs_live($opts=array()) { $query = "SELECT field_id, field_name, field_type, field_options, field_default, field_required, field_size, field_rows, @@ -328,7 +328,7 @@ if ( is_array($this->ipsclass->cache['registry_field_defs']) ) { - foreach ($this->ipsclass->cache['registry_field_defs'] as $field_id => $field_row) + foreach ($this->ipsclass->cache['registry_field_defs'] as $field_num => $field_row) { if ( $field_row['field_highlight'] == 1 ) { @@ -344,7 +344,7 @@ if ( count($this->_cf_highlight) < 1 ) { $field_id = end(array_slice(array_keys($this->ipsclass->cache['registry_field_defs']), 0, 1)); - $this->_cf_highlight[$field_id] = $this->ipsclass->cache['registry_field_defs'][$field_id]; + $this->_cf_highlight[ $field_row['field_id'] ] = $this->ipsclass->cache['registry_field_defs'][ $field_row['field_id'] ]; } return $this->_cf_highlight; @@ -728,7 +728,7 @@ if ( is_array($opts['cf_defs']) ) { - foreach ( $opts['cf_defs'] as $cf_id => $cf_row ) + foreach ( $opts['cf_defs'] as $cf_num => $cf_row ) { if ( $cf_row['field_type'] == 'S' ) { @@ -953,16 +953,16 @@ return $cf_input; } - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_rum => $cf_row ) { // This 'if' will fail for make & model, we need to special // case them afterwards! - if ( !empty( $this->ipsclass->input[$cf_id] ) ) + if ( !empty( $this->ipsclass->input[ $cf_row['field_id'] ] ) ) { if ( preg_match('/^(T|M)$/', $cf_row['field_type']) ) { // Single line text, or Textarea - $cf_input[$cf_id] = $this->class->lib['parser']->pre_db_parse( $this->ipsclass->input[$cf_id] ); + $cf_input[ $cf_row['field_id'] ] = $this->class->lib['parser']->pre_db_parse( $this->ipsclass->input[ $cf_row['field_id'] ] ); } elseif ( preg_match('/^(R|L)$/', $cf_row['field_type']) ) { @@ -970,16 +970,16 @@ $valid_options = $this->explode_assoc('|', $cf_row['field_options']); // Only configured values are valid! - $cf_input[$cf_id] = ( in_array( $this->ipsclass->input[$cf_id], array_keys($valid_options) ) ) - ? htmlspecialchars( $this->ipsclass->input[$cf_id] ) - : ''; + $cf_input[ $cf_row['field_id'] ] = ( in_array( $this->ipsclass->input[ $cf_row['field_id'] ], array_keys($valid_options) ) ) + ? htmlspecialchars( $this->ipsclass->input[ $cf_row['field_id'] ] ) + : ''; } elseif ( $cf_row['field_type'] == 'F' ) { // Money (floating point), make sure comma and dollar signs don't cause problems - $this->ipsclass->input[$cf_id] = preg_replace('/(\,|$)/', '', $this->ipsclass->input[$cf_id]); + $this->ipsclass->input[ $cf_row['field_id'] ] = preg_replace('/(\,|$)/', '', $this->ipsclass->input[ $cf_row['field_id'] ]); - $cf_input[$cf_id] = floatval( $this->ipsclass->input[$cf_id] ); + $cf_input[ $cf_row['field_id'] ] = floatval( $this->ipsclass->input[ $cf_row['field_id'] ] ); } elseif ( $cf_row['field_type'] == 'C' ) { @@ -989,7 +989,7 @@ // We need to loop through and only allow valid options through $options = array(); - foreach ( $this->ipsclass->input[$cf_id] as $cf_value ) + foreach ( $this->ipsclass->input[ $cf_row['field_id'] ] as $cf_value ) { $cf_value = htmlspecialchars( $cf_value ); @@ -1001,7 +1001,7 @@ } // We are returning a serialized data structure to store to the DB - $cf_input[$cf_id] = serialize($options); + $cf_input[ $cf_row['field_id'] ] = serialize($options); } elseif ( $cf_row['field_type'] == 'S' ) { @@ -1010,9 +1010,9 @@ if ( $cf_row['field_options'] == 'year' ) { // Validate year format - if ( preg_match('/^\d{4}$/', $this->ipsclass->input[$cf_id]) ) + if ( preg_match('/^\d{4}$/', $this->ipsclass->input[ $cf_row['field_id'] ]) ) { - $cf_input[$cf_id] = htmlspecialchars( $this->ipsclass->input[$cf_id] ); + $cf_input[ $cf_row['field_id'] ] = htmlspecialchars( $this->ipsclass->input[ $cf_row['field_id'] ] ); } } } @@ -1024,7 +1024,7 @@ if ( !empty( $this->ipsclass->input[$cf_row['field_options']] ) ) { // Type cast integer - $cf_input[$cf_id] = intval( $this->ipsclass->input[$cf_row['field_options']] ); + $cf_input[ $cf_row['field_id'] ] = intval( $this->ipsclass->input[$cf_row['field_options']] ); } } elseif ( $cf_row['field_type'] == 'C' ) @@ -1032,7 +1032,7 @@ // This elseif will catch any defined checkbox fields which did not // have any selected values. In this case the field is not returned // in the query string by the browser. - $cf_input[$cf_id] = ''; + $cf_input[ $cf_row['field_id'] ] = ''; } } Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/functions.php 2008-02-16 20:58:37 UTC (rev 45) @@ -249,7 +249,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); // Get data $query = $this->ipsclass->DB->query( "SELECT g.id, g.member_id, g.date_updated, m.members_display_name @@ -266,9 +271,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } @@ -296,7 +301,12 @@ $cf_highlight = $this->class->lib['custom_fields']->get_cf_highlight(); // Create our sql id list, this will be used when retrieving the custom field entries. - $cf_ids = "'". implode( "','", array_keys($cf_highlight) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_highlight as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id']. "','"; + } + $cf_ids = substr($cf_ids, 0, -2); $show_add = 0; @@ -325,9 +335,9 @@ // Process the highlight field values $row['highlight_fields'] = ''; - foreach ( $cf_highlight as $cf_id => $cf_row ) + foreach ( $cf_highlight as $cf_num => $cf_row ) { - $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[$cf_id]['field_value'], 'type' => 'view' ) ); + $row['highlight_fields'] .= $this->class->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view' ) ); $row['highlight_fields'] .= ' '; } Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/main.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/main.php 2008-02-15 00:15:56 UTC (rev 44) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/main.php 2008-02-16 20:58:37 UTC (rev 45) @@ -290,9 +290,13 @@ if ( is_array($cf_defs) ) { // Create our sql id list, this will be used when retrieving the custom field entries - $cf_ids = "'". implode( "','", array_keys($cf_defs) ) . "'"; + $cf_ids = "'"; + foreach ( $cf_defs as $cf_num => $cf_row ) + { + $cf_ids .= $cf_row['field_id'] ."','"; + } + $cf_ids = substr($cf_ids, 0, -2); - // Build our <th>'s for the custom fields $data['custom_field_th'] = ''; @@ -303,7 +307,7 @@ $cf_width .= '%'; // Loop through each one and add the <th> html to the output - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_num => $cf_row ) { $cf_data['field_name'] = $cf_row['field_name']; $cf_data['field_width'] = $cf_width; @@ -340,7 +344,7 @@ // Build our <td>'s for the custom fields $row['custom_fields'] = ''; - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_num => $cf_row ) { // Which css class should we be? This isn't perfect, but will have to do. $cf_data['field_class'] = $total_cars_printed % 2 ? 'row2' : 'row1'; @@ -348,7 +352,7 @@ $cf_data['item_id'] = $row['id']; $cf_data['field_value'] = $this->lib['custom_fields']->process_cf_value( array( 'def' => $cf_row, - 'value' => $cf_entries[$cf_id]['field_value'], + 'value' => $cf_entries[ $cf_row['field_id'] ]['field_value'], 'type' => 'view', ) ); @@ -516,17 +520,17 @@ $where_sql = ' WHERE '; - foreach ( $cf_defs as $cf_id => $cf_row ) + foreach ( $cf_defs as $cf_num => $cf_row ) { // Did they enter a keyword for this field, and did they choose this field? - if ( !empty($cf_input[$cf_id]) AND $this->ipsclass->input['search_' . $cf_id] == 1 ) + if ( !empty($cf_input[ $cf_row['field_id'] ]) AND $this->ipsclass->input['search_' . $cf_row['field_id']] == 1 ) { - $where_sql .= " ( field_id = '$cf_id' AND field_value LIKE '%$cf_input[$cf_id]%' ) OR "; + $where_sql .= " ( field_id = '". $cf_row['field_id'] ."' AND field_value LIKE '%". $cf_input[ $cf_row['field_id'] ] ."%' ) OR "; // This will be used later in our 'AND' logic if ( $this->ipsclass->input['search_logic'] == 'AND' ) { - array_push( $searched_fields, $cf_id ); + array_push( $searched_fields, $cf_row['field_id'] ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SVN c. <fus...@li...> - 2008-02-17 21:12:20
|
Revision: 50 http://fusionregistry.svn.sourceforge.net/fusionregistry/?rev=50&view=rev Author: copland007 Date: 2008-02-17 13:12:11 -0800 (Sun, 17 Feb 2008) Log Message: ----------- Implemented client side rating_def cache. ACP custom fields page, change get_cf_groups to get_cf_groups_live call to ensure database data not cache. Fix item modification not saving custom field data correctly. Added ksort to both rating_def and field_def cache retrieval routines for ASC sort type. Results were not being properly sorted from cache. Modified Paths: -------------- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-17 09:56:12 UTC (rev 49) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_custom_fields.php 2008-02-17 21:12:11 UTC (rev 50) @@ -643,7 +643,7 @@ { // Grab all the custom field definitions and groups first as they will be used by a few things below $cf_defs = $this->lib['custom_fields']->get_cf_defs_live( array( 'ORDER BY' => 'field_order ASC, field_name ASC' ) ); - $cf_groups = $this->lib['custom_fields']->get_cf_groups(); + $cf_groups = $this->lib['custom_fields']->get_cf_groups_live(); $this->ipsclass->html .= $this->ipsclass->skin_acp_global->information_box( "Fusion Registry Custom Fields Overview", "You can manage your garage custom fields from here.<br /><br /><span style='color:red'><b>PLEASE NOTE:</b> You must not configure the same order number for more than 1 custom field. Doing so will result in some of your custom fields not showing up!</span>".'<br /> ' ) . "<br >"; Modified: branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-17 09:56:12 UTC (rev 49) +++ branches/stable_3_0_x/upload/sources/components_acp/fusionscripts/fusionregistry/ad_rating_fields.php 2008-02-17 21:12:11 UTC (rev 50) @@ -206,9 +206,9 @@ } // Go get our Custom Field definition - $rating_data = $this->lib['rating_fields']->get_rating_defs( array( 'WHERE' => 'rating_id='.$this->ipsclass->input['r'] ) ); + $rating_data = $this->lib['rating_fields']->get_rating_defs_live( array( 'WHERE' => 'rating_id='.$this->ipsclass->input['r'] ) ); - // Since get_rating_defs() returns an array of arrays, we are removing a layer here. + // Since get_rating_defs_live() returns an array of arrays, we are removing a layer here. // The key is the rating_id which was passed in from the beginning ;) $rating = $rating_data[$this->ipsclass->input['r']]; @@ -365,7 +365,7 @@ $this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Fusion Registry Rating Fields" ); // Grab all the rating definitions - $rating_defs = $this->lib['rating_fields']->get_rating_defs( array( 'ORDER BY' => 'rating_order ASC, rating_name ASC' ) ); + $rating_defs = $this->lib['rating_fields']->get_rating_defs_live( array( 'ORDER BY' => 'rating_order ASC, rating_name ASC' ) ); // Loop through our custom field definitions we got from up above foreach ( $rating_defs as $rating_id => $rating_row ) Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php 2008-02-17 09:56:12 UTC (rev 49) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/item.php 2008-02-17 21:12:11 UTC (rev 50) @@ -394,17 +394,17 @@ unset($db_string); // Now save their custom field data - foreach ( $cf_input as $cf_num => $cf_value ) + foreach ( $cf_input as $cf_id => $cf_value ) { // Determine if we need to update or insert row - $rs = $this->ipsclass->DB->query("SELECT entry_id FROM ibf_registry_field_entries WHERE item_id = '". $this->ipsclass->input['CID'] ."' AND field_id = '". $cf_row['field_id'] ."'"); + $rs = $this->ipsclass->DB->query("SELECT entry_id FROM ibf_registry_field_entries WHERE item_id = '". $this->ipsclass->input['CID'] ."' AND field_id = '". $cf_id ."'"); $existing = $this->ipsclass->DB->fetch_row($rs); if ( isset($existing['entry_id']) and !empty($existing['entry_id']) ) { // Update existing entry - $db_string = $this->ipsclass->DB->compile_db_update_string( array( 'field_id' => $cf_row['field_id'], + $db_string = $this->ipsclass->DB->compile_db_update_string( array( 'field_id' => $cf_id, 'item_id' => $this->ipsclass->input['CID'], 'field_value' => $cf_value, ) ); @@ -414,7 +414,7 @@ else { // Insert new entry - $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_row['field_id'], + $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'field_id' => $cf_id, 'item_id' => $this->ipsclass->input['CID'], 'field_value' => $cf_value, ) ); @@ -639,11 +639,11 @@ $ratings_def = $this->lib['ratings']->get_rating_defs(); - foreach ( $ratings_def as $rating_id => $rating_row ) + foreach ( $ratings_def as $rating_num => $rating_row ) { - if ( !empty( $this->ipsclass->input[$rating_id] ) ) + if ( !empty( $this->ipsclass->input[ $rating_row['rating_id'] ] ) ) { - $user_ratings[$rating_id] = intval( $this->ipsclass->input[$rating_id] ); + $user_ratings[ $rating_row['rating_id'] ] = intval( $this->ipsclass->input[ $rating_row['rating_id'] ] ); } } @@ -1056,7 +1056,7 @@ } // Load the ratings defs - $rating_defs = $this->lib['ratings']->get_rating_defs( array( 'ORDER BY' => 'rating_order ASC' ) ); + $rating_defs = $this->lib['ratings']->get_rating_defs( array( 'ORDER BY' => array( 'rating_order' => 'ASC' ) ) ); // They shouldn't even get to this function if there aren't rating defs if ( empty($rating_defs) ) @@ -1067,7 +1067,7 @@ // Loop through and produce our inner html $inner_html = ''; - foreach ( $rating_defs as $rating_id => $rating_row ) + foreach ( $rating_defs as $rating_num => $rating_row ) { // Create our html select field $select_html = $this->lib['ratings']->build_rating_select( array( 'rating_row' => $rating_row ) ); @@ -1656,7 +1656,7 @@ { $ratings_html = ''; - foreach ( $rating_report as $rating_id => $rating_row ) + foreach ( $rating_report as $rating_num => $rating_row ) { $ratings_html .= $this->ipsclass->compiled_templates['skin_registry_item']->view_rating_row( array( 'rating_name' => $rating_row['rating_name'], 'rating_image' => $rating_row['rating_image'], Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2008-02-17 09:56:12 UTC (rev 49) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/custom_fields.php 2008-02-17 21:12:11 UTC (rev 50) @@ -179,10 +179,14 @@ $sorted[ intval($field_row[ $order_field ]) ] = $field_row; } - if ( $order_value == 'DESC' ) + if ( $order_value == 'ASC' ) { - $sorted = array_reverse($results); + ksort($sorted); } + elseif ( $order_value == 'DESC' ) + { + $sorted = array_reverse($sorted); + } } $results = $sorted; @@ -271,7 +275,7 @@ /** - * Get all the Custom Field Groups, cached if possible + * Get all the Custom Field Groups from the cache * * This function's job is only to retrieve the data from the database, * it should not process the returned data. If this data has already @@ -313,6 +317,40 @@ /** + * Get all the Custom Field Groups from the database + * + * This function's job is only to retrieve the data from the database, + * it should not process the returned data. If this data has already + * been retrieved and stored into cache it will not query the database. + * + * @return array|NULL Success returns an array of an array, outer key is field_group_id; Failure returns NULL. + */ + function get_cf_groups_live() + { + $query = 'SELECT field_id, field_name, field_type, field_options, '. + 'field_default, field_required, field_size, field_rows, '. + 'field_cols, field_order, field_browse, field_highlight, '. + 'field_group_id, field_search '. + 'FROM ibf_registry_field_defs '. + 'WHERE field_group_id IS NOT NULL '. + 'ORDER BY field_group_id ASC, field_order ASC, field_name ASC'; + + $rs = $this->ipsclass->DB->query($query); + + // Build our Custom Field Group data structure, we will be returning + // a complex structure of arrays of arrays + $this->_cf_groups = array(); + + while ( $row = $this->ipsclass->DB->fetch_row($rs) ) + { + $this->_cf_groups[$row['field_group_id']][] = $row; + } + + return $this->_cf_groups; + } + + + /** * Get the Custom Field or Group that has been chosen as the highlight item * * This function's job is only to retrieve the highlight group or item from Modified: branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php =================================================================== --- branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php 2008-02-17 09:56:12 UTC (rev 49) +++ branches/stable_3_0_x/upload/sources/components_public/fusionscripts/fusionregistry/lib/ratings.php 2008-02-17 21:12:11 UTC (rev 50) @@ -70,9 +70,9 @@ /** - * Get Rating definitions + * Get Rating definitions from cache * - * This function's job is only to retrieve the data from the database, + * This function's job is only to retrieve the data from the cache, * it should not process the returned data. * * @todo Cache just like get_field_defs, create new get_field_defs_live for ACP @@ -81,6 +81,67 @@ */ function get_rating_defs($opts=array()) { + $results = $this->ipsclass->cache['registry_rating_defs']; + + // Did we get any restrictions passed? + if ( count($opts) > 0 && is_array($this->ipsclass->cache['registry_rating_defs']) ) + { + // First handle the WHERE clause + if ( isset($opts['WHERE']) && is_array($opts['WHERE']) ) + { + foreach ( $opts['WHERE'] as $where_field => $where_value ) + { + foreach ( $results as $field_id => $field_row ) + { + if ( $field_row[ $where_field ] != $where_value ) + { + // WHERE did not match, remove from results + unset( $results[ $field_id ] ); + } + } + } + } + + // Now handle the ORDER BY clause + if ( isset($opts['ORDER BY']) && is_array($opts['ORDER BY']) ) + { + $sorted = array(); + foreach ( $opts['ORDER BY'] as $order_field => $order_value ) + { + foreach ( $results as $field_num => $field_row ) + { + $sorted[ intval($field_row[ $order_field ]) ] = $field_row; + } + + if ( $order_value == 'ASC' ) + { + ksort($sorted); + } + elseif ( $order_value == 'DESC' ) + { + $sorted = array_reverse($sorted); + } + } + + $results = $sorted; + } + } + + return $results; + } + + + /** + * Get Rating definitions live from database + * + * This function's job is only to retrieve the data from the database, + * it should not process the returned data. + * + * @param array $opts Optional custom SQL cmd/value pair attributes + * @return array An array of an array, outer key is field_id + */ + function get_rating_defs_live($opts=array()) + { $query = "SELECT rating_id,rating_name,rating_order FROM ibf_registry_rating_defs"; // Did we get any restrictions passed? @@ -207,40 +268,41 @@ $report = array(); // First get the current list of rating defs - $ratings_defs = $this->get_rating_defs( array( 'ORDER BY' => 'rating_order ASC' ) ); + $ratings_defs = $this->get_rating_defs( array( 'ORDER BY' => array( 'rating_order' => 'ASC' ) ) ); // Then get report for each of the rating defs for this item - foreach ( $ratings_defs as $rating_id => $rating_row ) + foreach ( $ratings_defs as $rating_num => $rating_row ) { // Initialize the report for this rating - $report[$rating_id] = array(); + $report[ $rating_num ] = array(); $query = "SELECT rating_count, rating_sum FROM ibf_registry_rating_reports ". - "WHERE item_id = '$item_id' AND rating_id = '$rating_id'"; + "WHERE item_id = '$item_id' AND rating_id = '".$rating_row['rating_id']."'"; $rs = $this->ipsclass->DB->query($query); // Add to report to be returned if ( $this->ipsclass->DB->get_num_rows() ) { - $report[$rating_id] = $this->ipsclass->DB->fetch_row($rs); + $report[ $rating_num ] = $this->ipsclass->DB->fetch_row($rs); } // While we are at it, let's generate the html here also. - if ( $report[$rating_id]['rating_count'] > 0 ) + if ( $report[ $rating_num ]['rating_count'] > 0 ) { // If there are votes, report real value - $report[$rating_id]['rating_image'] = $this->get_rating_image( $report[$rating_id]['rating_sum'] / $report[$rating_id]['rating_count'] ); + $report[ $rating_num ]['rating_image'] = $this->get_rating_image( $report[ $rating_num ]['rating_sum'] / $report[ $rating_num ]['rating_count'] ); } else { // If there aren't any votes report medium neutral value - $report[$rating_id]['rating_image'] = $this->get_rating_image( ($this->class->registry_config['rating_max'] + $this->class->registry_config['rating_min'])/2 ); + $report[ $rating_num ]['rating_image'] = $this->get_rating_image( ($this->class->registry_config['rating_max'] + $this->class->registry_config['rating_min'])/2 ); } // Also cram in rating info - $report[$rating_id]['rating_name'] = $rating_row['rating_name']; - $report[$rating_id]['rating_order'] = $rating_row['rating_order']; + $report[ $rating_num ]['rating_id'] = $rating_row['rating_id']; + $report[ $rating_num ]['rating_name'] = $rating_row['rating_name']; + $report[ $rating_num ]['rating_order'] = $rating_row['rating_order']; } return $report; @@ -282,14 +344,14 @@ $rating_default = round( ($this->class->registry_config['rating_min'] + $this->class->registry_config['rating_min'])/2 ); // Loop through each valid rating def and determine if they have voted before or not - foreach ( $ratings_def as $rating_id => $rating_row ) + foreach ( $ratings_def as $rating_num => $rating_row ) { // Determine rating value to be recorded - $rating_value = ( !empty( $user_ratings[$rating_id] ) ) ? $user_ratings[$rating_id] : $rating_default; + $rating_value = ( !empty( $user_ratings[ $rating_row['rating_id'] ] ) ) ? $user_ratings[ $rating_row['rating_id'] ] : $rating_default; // Have they voted for this before? $query = "SELECT entry_id,rating_value FROM ibf_registry_rating_entries ". - "WHERE item_id = '$item_id' AND rating_id = '$rating_id' AND member_id = '". $this->ipsclass->member['id'] ."'"; + "WHERE item_id = '$item_id' AND rating_id = '". $rating_row['rating_id'] ."' AND member_id = '". $this->ipsclass->member['id'] ."'"; $rs = $this->ipsclass->DB->query($query); @@ -298,7 +360,7 @@ // They have not voted for this before, add new entry $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'member_id' => $this->ipsclass->member['id'], 'item_id' => $item_id, - 'rating_id' => $rating_id, + 'rating_id' => $rating_row['rating_id'], 'rating_value' => $rating_value, 'rating_date' => $epoch_time, ) ); @@ -308,13 +370,13 @@ // Now we need to add this to the rating report. First see if a report exists, // if not create one. $rs2 = $this->ipsclass->DB->query("SELECT entry_id, rating_count, rating_sum FROM ibf_registry_rating_reports ". - "WHERE item_id = '$item_id' AND rating_id = '$rating_id'"); + "WHERE item_id = '$item_id' AND rating_id = '". $rating_row['rating_id'] ."'"); if ( !$this->ipsclass->DB->get_num_rows() ) { // No report yet, create new one $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'item_id' => $item_id, - 'rating_id' => $rating_id, + 'rating_id' => $rating_row['rating_id'], 'rating_count' => 1, 'rating_sum' => $rating_value, ) ); @@ -351,13 +413,13 @@ // we'll create a new one here just incase. This will patch a problem if it exists // but a clean up routine will need to be run to fix this items rating report. $rs2 = $this->ipsclass->DB->query("SELECT entry_id, rating_count, rating_sum FROM ibf_registry_rating_reports ". - "WHERE item_id = '$item_id' AND rating_id = '$rating_id'"); + "WHERE item_id = '$item_id' AND rating_id = '". $rating_row['rating_id'] ."'"); if ( !$this->ipsclass->DB->get_num_rows() ) { // No report yet, create new one $db_string = $this->ipsclass->DB->compile_db_insert_string( array( 'item_id' => $item_id, - 'rating_id' => $rating_id, + 'rating_id' => $rating_row['rating_id'], 'rating_count' => 1, 'rating_sum' => $rating_value, ) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |