[fusionregistry-commitlog] SF.net SVN: fusionregistry: [36] branches/stable_3_0_x/upload/sources
Brought to you by:
copland007
|
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.
|