Index: trunk/kernel/units/categories/cache_updater.php
===================================================================
diff -u -r5164 -r5165
--- trunk/kernel/units/categories/cache_updater.php (.../cache_updater.php) (revision 5164)
+++ trunk/kernel/units/categories/cache_updater.php (.../cache_updater.php) (revision 5165)
@@ -149,17 +149,22 @@
$this->iteration = 0;
$this->table = $this->Application->GetTempName('permCacheUpdate');
- if (!$continuing) {
- $this->Stack =& new clsRecursionStack();
- $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
- $this->Conn->Query($sql);
- $this->initData();
+ if ($continuing == 1) {
+ $this->InitUpdater();
}
- else {
+ elseif ($continuing == 2) {
$this->getData();
}
}
+ function InitUpdater($continue)
+ {
+ $this->Stack =& new clsRecursionStack();
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
+ $this->Conn->Query($sql);
+ $this->initData();
+ }
+
function getDonePercent()
{
if(!$this->totalCats)return 0;
@@ -179,7 +184,6 @@
else {
$this->Stack = & new clsRecursionStack();
}
-
}
function setData()
Index: trunk/core/units/categories/categories_config.php
===================================================================
diff -u -r5164 -r5165
--- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 5164)
+++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 5165)
@@ -59,7 +59,7 @@
'categories_properties' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Properties!"),
'categories_custom' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Custom!"),
- 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories! (0%)"),
+ 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories! "),
'tree_site' => Array('format' => '!la_selecting_categories!'),
),
Index: trunk/kernel/units/categories/categories_config.php
===================================================================
diff -u -r5164 -r5165
--- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5164)
+++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5165)
@@ -59,7 +59,7 @@
'categories_properties' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Properties!"),
'categories_custom' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Custom!"),
- 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories! (0%)"),
+ 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories! "),
'tree_site' => Array('format' => '!la_selecting_categories!'),
),
Index: trunk/kernel/units/categories/categories_tag_processor.php
===================================================================
diff -u -r5164 -r5165
--- trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5164)
+++ trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5165)
@@ -326,47 +326,50 @@
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
- $force = $this->Application->GetVar('force');
$continue = $this->Application->GetVar('continue');
+ $total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
+ if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) {
+ // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update
+ return true;
+ }
+
+ if ($continue === false) {
+ // if we don't have to ask, then assume user selected "Yes" in permcache update dialog
+ $continue = 1;
+ }
+
$updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue));
+ if ($continue === '0') { // No in dialog
+ $updater->clearData();
+ $this->Application->Redirect($params['destination_template']);
+ }
$ret = false; // don't ask for update
- if ($continue !== false) {
- if ($continue == 1) {
- if ($this->Application->GetVar('ajax')) {
- // call from AJAX request => returns percent
- $needs_more = true;
- while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) {
- // until proceeeded in this step category count exceeds category per step limit
- $needs_more = $updater->DoTheJob();
- }
-
- if ($needs_more) {
- // still some categories are left for next step
- $updater->setData();
- }
- else {
- $updater->clearData();
- $this->Application->StoreVar('PermCache_UpdateRequired', 0);
- $this->Application->Redirect($params['destination_template']);
- }
-
- $ret = $updater->getDonePercent();
- }
+ if ($continue == 1) { // Initial run
+ $updater->setData();
+ }
+ if ($continue == 2) { // Continuing
+ // called from AJAX request => returns percent
+ $needs_more = true;
+ while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) {
+ // until proceeeded in this step category count exceeds category per step limit
+ $needs_more = $updater->DoTheJob();
}
+
+ if ($needs_more) {
+ // still some categories are left for next step
+ $updater->setData();
+ }
else {
- // user selected "No" in perm cache update dialog
+ // all done -> redirect
$updater->clearData();
+ $this->Application->StoreVar('PermCache_UpdateRequired', 0);
$this->Application->Redirect($params['destination_template']);
}
+ $ret = $updater->getDonePercent();
}
- elseif (!$force && ($updater->totalCats > CACHE_PERM_CHUNK_SIZE)) {
- // ask before doing anything
- $updater->setData();
- $ret = true;
- }
return $ret;
}
}
Index: trunk/core/admin_templates/categories/cache_updater.tpl
===================================================================
diff -u -r5164 -r5165
--- trunk/core/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5164)
+++ trunk/core/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5165)
@@ -79,12 +79,12 @@
CacheUpdater.prototype.showProgress = function ($percent) {
$percent = parseInt($percent);
- document.getElementById('percents_done').innerHTML = $percent;
+ document.getElementById('percents_done').innerHTML = '(' + $percent + '%)';
document.getElementById('current_percent').style.width = $percent + '%';
document.getElementById('percents_left').style.width = (100 - $percent) + '%';
}
- $CacheUpdater = new CacheUpdater('');
+ $CacheUpdater = new CacheUpdater('');
Index: trunk/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r5164 -r5165
--- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5164)
+++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5165)
@@ -326,47 +326,50 @@
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
- $force = $this->Application->GetVar('force');
$continue = $this->Application->GetVar('continue');
+ $total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
+ if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) {
+ // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update
+ return true;
+ }
+
+ if ($continue === false) {
+ // if we don't have to ask, then assume user selected "Yes" in permcache update dialog
+ $continue = 1;
+ }
+
$updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue));
+ if ($continue === '0') { // No in dialog
+ $updater->clearData();
+ $this->Application->Redirect($params['destination_template']);
+ }
$ret = false; // don't ask for update
- if ($continue !== false) {
- if ($continue == 1) {
- if ($this->Application->GetVar('ajax')) {
- // call from AJAX request => returns percent
- $needs_more = true;
- while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) {
- // until proceeeded in this step category count exceeds category per step limit
- $needs_more = $updater->DoTheJob();
- }
-
- if ($needs_more) {
- // still some categories are left for next step
- $updater->setData();
- }
- else {
- $updater->clearData();
- $this->Application->StoreVar('PermCache_UpdateRequired', 0);
- $this->Application->Redirect($params['destination_template']);
- }
-
- $ret = $updater->getDonePercent();
- }
+ if ($continue == 1) { // Initial run
+ $updater->setData();
+ }
+ if ($continue == 2) { // Continuing
+ // called from AJAX request => returns percent
+ $needs_more = true;
+ while ($needs_more && $updater->iteration < CACHE_PERM_CHUNK_SIZE) {
+ // until proceeeded in this step category count exceeds category per step limit
+ $needs_more = $updater->DoTheJob();
}
+
+ if ($needs_more) {
+ // still some categories are left for next step
+ $updater->setData();
+ }
else {
- // user selected "No" in perm cache update dialog
+ // all done -> redirect
$updater->clearData();
+ $this->Application->StoreVar('PermCache_UpdateRequired', 0);
$this->Application->Redirect($params['destination_template']);
}
+ $ret = $updater->getDonePercent();
}
- elseif (!$force && ($updater->totalCats > CACHE_PERM_CHUNK_SIZE)) {
- // ask before doing anything
- $updater->setData();
- $ret = true;
- }
return $ret;
}
}
Index: trunk/core/units/categories/cache_updater.php
===================================================================
diff -u -r5164 -r5165
--- trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 5164)
+++ trunk/core/units/categories/cache_updater.php (.../cache_updater.php) (revision 5165)
@@ -149,17 +149,22 @@
$this->iteration = 0;
$this->table = $this->Application->GetTempName('permCacheUpdate');
- if (!$continuing) {
- $this->Stack =& new clsRecursionStack();
- $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
- $this->Conn->Query($sql);
- $this->initData();
+ if ($continuing == 1) {
+ $this->InitUpdater();
}
- else {
+ elseif ($continuing == 2) {
$this->getData();
}
}
+ function InitUpdater($continue)
+ {
+ $this->Stack =& new clsRecursionStack();
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
+ $this->Conn->Query($sql);
+ $this->initData();
+ }
+
function getDonePercent()
{
if(!$this->totalCats)return 0;
@@ -179,7 +184,6 @@
else {
$this->Stack = & new clsRecursionStack();
}
-
}
function setData()
Index: trunk/kernel/admin_templates/categories/cache_updater.tpl
===================================================================
diff -u -r5164 -r5165
--- trunk/kernel/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5164)
+++ trunk/kernel/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5165)
@@ -79,12 +79,12 @@
CacheUpdater.prototype.showProgress = function ($percent) {
$percent = parseInt($percent);
- document.getElementById('percents_done').innerHTML = $percent;
+ document.getElementById('percents_done').innerHTML = '(' + $percent + '%)';
document.getElementById('current_percent').style.width = $percent + '%';
document.getElementById('percents_left').style.width = (100 - $percent) + '%';
}
- $CacheUpdater = new CacheUpdater('');
+ $CacheUpdater = new CacheUpdater('');