|
From: <dac...@us...> - 2007-09-04 17:58:18
|
Revision: 55
http://thevr.svn.sourceforge.net/thevr/?rev=55&view=rev
Author: dachebodt
Date: 2007-09-04 10:58:18 -0700 (Tue, 04 Sep 2007)
Log Message:
-----------
fixed a bug with the main menu. Also added functions to handle block admin that I forgot to commit earlier
Modified Paths:
--------------
mods/cms/trunk/modules/blocks/blocks/cms_main_menu.php
Added Paths:
-----------
mods/cms/trunk/modules/blocks/functions_blocks_admin.php
Modified: mods/cms/trunk/modules/blocks/blocks/cms_main_menu.php
===================================================================
--- mods/cms/trunk/modules/blocks/blocks/cms_main_menu.php 2007-09-03 11:34:57 UTC (rev 54)
+++ mods/cms/trunk/modules/blocks/blocks/cms_main_menu.php 2007-09-04 17:58:18 UTC (rev 55)
@@ -34,98 +34,98 @@
continue;
}
- // Skip branch
- if ($right_id !== false)
+ // Skip branch
+ if ($right_id !== false)
+ {
+ if ($item_ary['left'] < $right_id)
{
- if ($item_ary['left'] < $right_id)
- {
- continue;
- }
-
- $right_id = false;
+ continue;
}
- // Category with no members on their way down (we have to check every level)
- if (!$item_ary['name'])
+ $right_id = false;
+ }
+
+ // Category with no members on their way down (we have to check every level)
+ if (!$item_ary['name'])
+ {
+ $empty_category = true;
+
+ // We go through the branch and look for an activated module
+ foreach (array_slice($module->module_ary, $row_id + 1) as $temp_row)
{
- $empty_category = true;
-
- // We go through the branch and look for an activated module
- foreach (array_slice($module->module_ary, $row_id + 1) as $temp_row)
+ if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right'])
{
- if ($temp_row['left'] > $item_ary['left'] && $temp_row['left'] < $item_ary['right'])
+ // Module there and displayed?
+ if ($temp_row['name'] && $temp_row['display'])
{
- // Module there and displayed?
- if ($temp_row['name'] && $temp_row['display'])
- {
- $empty_category = false;
- break;
- }
- continue;
+ $empty_category = false;
+ break;
}
- break;
- }
-
- // Skip the branch
- if ($empty_category)
- {
- $right_id = $item_ary['right'];
continue;
}
+ break;
}
- // Select first id we can get
- if (!$current_id && (in_array($item_ary['id'], array_keys($module->module_cache['parents'])) || $item_ary['id'] == $module->p_id))
+ // Skip the branch
+ if ($empty_category)
{
- $current_id = $item_ary['id'];
+ $right_id = $item_ary['right'];
+ continue;
}
+ }
- $depth = $item_ary['depth'];
+ // Select first id we can get
+ if (!$current_id && (in_array($item_ary['id'], array_keys($module->module_cache['parents'])) || $item_ary['id'] == $module->p_id))
+ {
+ $current_id = $item_ary['id'];
+ }
- if ($depth > $current_depth)
+ $depth = $item_ary['depth'];
+
+ if ($depth > $current_depth)
+ {
+ $linear_offset = $linear_offset . '.l_block' . ($depth + 1);
+ $tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset;
+ }
+ else if ($depth < $current_depth)
+ {
+ for ($i = $current_depth - $depth; $i > 0; $i--)
{
- $linear_offset = $linear_offset . '.l_block' . ($depth + 1);
- $tabular_offset = ($depth + 1 > 2) ? $tabular_offset . '.t_block' . ($depth + 1) : $tabular_offset;
+ $linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.'));
+ $tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset;
}
- else if ($depth < $current_depth)
- {
- for ($i = $current_depth - $depth; $i > 0; $i--)
- {
- $linear_offset = substr($linear_offset, 0, strrpos($linear_offset, '.'));
- $tabular_offset = ($i + $depth > 1) ? substr($tabular_offset, 0, strrpos($tabular_offset, '.')) : $tabular_offset;
- }
- }
+ }
- $u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&mode=' . $item_ary['mode']);
+ $u_title = $module_url . $delim . 'i=' . (($item_ary['cat']) ? $item_ary['id'] : $item_ary['name'] . (($item_ary['is_duplicate']) ? '&icat=' . $current_id : '') . '&mode=' . $item_ary['mode']);
- // Was not allowed in categories before - /*!$item_ary['cat'] && */
- $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : '';
+ // Was not allowed in categories before - /*!$item_ary['cat'] && */
+ $u_title .= (isset($item_ary['url_extra'])) ? $item_ary['url_extra'] : '';
- // Only output a categories items if it's currently selected
- if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($module->module_cache['parents'])) || $item_ary['parent'] == $module->p_parent)))
- {
- $use_tabular_offset = (!$depth) ? 't_block1' : $tabular_offset;
+ // Only output a categories items if it's currently selected
+ if (!$depth || ($depth && (in_array($item_ary['parent'], array_values($module->module_cache['parents'])) || $item_ary['parent'] == $module->p_parent)))
+ {
+ $use_tabular_offset = (!$depth) ? 't_block1' : $tabular_offset;
- $tpl_ary = array(
- 'L_TITLE' => $item_ary['lang'],
- 'S_SELECTED' => (in_array($item_ary['id'], array_keys($module->module_cache['parents'])) || $item_ary['id'] == $module->p_id) ? true : false,
- 'U_TITLE' => $u_title
- );
-
- $mtemplate->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
- }
-
$tpl_ary = array(
'L_TITLE' => $item_ary['lang'],
'S_SELECTED' => (in_array($item_ary['id'], array_keys($module->module_cache['parents'])) || $item_ary['id'] == $module->p_id) ? true : false,
'U_TITLE' => $u_title
);
- $mtemplate->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
-
- $current_depth = $depth;
+ $mtemplate->assign_block_vars($use_tabular_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
}
+ $tpl_ary = array(
+ 'L_TITLE' => $item_ary['lang'],
+ 'S_SELECTED' => (in_array($item_ary['id'], array_keys($module->module_cache['parents'])) || $item_ary['id'] == $module->p_id) ? true : false,
+ 'U_TITLE' => $u_title
+ );
+
+ $mtemplate->assign_block_vars($linear_offset, array_merge($tpl_ary, array_change_key_case($item_ary, CASE_UPPER)));
+
+ $current_depth = $depth;
+ }
+
$mtemplate->set_filenames(array(
'content' => 'block_main_menu.html')
);
@@ -136,7 +136,7 @@
return $block;
}
-function calendar_block_config()
+function main_menu_block_config()
{
$block_config = array();
Added: mods/cms/trunk/modules/blocks/functions_blocks_admin.php
===================================================================
--- mods/cms/trunk/modules/blocks/functions_blocks_admin.php (rev 0)
+++ mods/cms/trunk/modules/blocks/functions_blocks_admin.php 2007-09-04 17:58:18 UTC (rev 55)
@@ -0,0 +1,87 @@
+<?
+
+function delete_blocks($module, $block = false, $style = false)
+{
+ global $db;
+
+ $where = "module = '" . $db->sql_escape($module) . "'";
+ $where .= ($block) ? ((is_numeric($block)) ? " AND bid=$block" : " AND name='" . $db->sql_escape($block) . "'") : '';
+ $where .= ($style) ? " AND style=$style" : '';
+
+ $sql = 'SELECT bid, name, module, position, weight, style
+ FROM ' . BLOCKS_TABLE . '
+ WHERE ' . $where;
+ $result = $db->sql_query($sql);
+
+ $block_ids = array();
+ while($row = $db->sql_fetchrow($result))
+ {
+ $style_id = $row['style'];
+ $weight = $row['weight'];
+ $position = $row['position'];
+
+ $sql = 'UPDATE ' . BLOCKS_TABLE . "
+ SET weight = weight - 1
+ WHERE weight > $weight
+ AND position = $position";
+ $sql .= ($style) ? ' AND style = ' . $style_id : '';
+
+ $db->sql_query($sql);
+ $block_ids[] = $row['bid'];
+ }
+ $db->sql_freeresult($result);
+
+ $sql = 'DELETE
+ FROM ' . BLOCKS_TABLE . '
+ WHERE ' . $where;
+ $db->sql_query($sql);
+
+ // get module modes since blocks are cached separately for each module mode
+ $sql = 'SELECT DISTINCT module_id, module_mode
+ FROM ' . MODULES_TABLE . "
+ WHERE module_dir = '" . $db->sql_escape($module) . "'
+ AND module_class = 'cms'";
+ $result = $db->sql_query($sql);
+
+ $mode_list = array();
+ while($row = $db->sql_fetchrow($result))
+ {
+ $mode_list[$row['module_id']]['mode'] = $row['module_mode'];
+ }
+ $db->sql_freeresult($result);
+
+ remove_cache_file($mode_list);
+ delete_block_config($block_ids);
+}
+
+/*
+params: mod_list
+*/
+function remove_cache_file($mod_list)
+{
+ global $cache;
+
+ if(!sizeof($mod_list))
+ {
+ return;
+ }
+
+ foreach($mod_list as $i => $module)
+ {
+ $cache->destroy('_block_' . $module['mode']);
+ }
+}
+
+function delete_block_config($bid)
+{
+ global $db, $cache;
+
+ if(!empty($bid))
+ {
+ $sql = 'DELETE FROM ' . BLOCKS_CONFIG_TABLE . ' WHERE ' . ((is_array($bid)) ? $db->sql_in_set('bid', $bid) : 'bid = ' . $bid);
+ $db->sql_query($sql);
+ $cache->destroy('_block_config');
+ }
+}
+
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|