Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F775810
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Feb 6, 6:46 AM
Size
146 KB
Mime Type
text/x-diff
Expires
Sat, Feb 8, 6:46 AM (1 d, 14 h)
Engine
blob
Format
Raw Data
Handle
558322
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php (revision 5636)
@@ -1,210 +1,221 @@
<?php
class ConfigurationTagProcessor extends kDBTagProcessor {
function Init($prefix,$special,$event_params=null)
{
parent::Init($prefix, $special, $event_params);
$this->Application->LinkVar('module_key');
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$o = '';
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
// $block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$block_params['IdField'] = $list->IDField;
$prev_heading = '';
$next_block = $params['full_block'];
$this->groupRecords($list->Records, 'heading');
$field_values = $this->Application->GetVar($this->getPrefixSpecial(true));
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
// using 2 blocks for drawing o row in case if current & next record titles match
$next_item_prompt = $list->CurrentIndex + 1 < $list->RecordsCount ? $list->Records[$list->CurrentIndex + 1]['prompt'] : '';
$this_item_prompt = $list->GetDBField('prompt');
if ($next_item_prompt == $this_item_prompt) {
$curr_block = $params['half_block1'];
$next_block = $params['half_block2'];
} else {
$curr_block = $next_block;
$next_block = $params['full_block'];
}
$block_params['name'] = $curr_block;
$block_params['show_heading'] = ($prev_heading != $list->GetDBField('heading') ) ? 1 : 0;
// set values from submit if any
if ($field_values) {
$list->SetDBField('VariableValue', $field_values[$list->GetDBField('VariableName')]['VariableValue']);
}
$o.= $this->Application->ParseBlock($block_params, 1);
$prev_heading = $list->GetDBField('heading');
$list->GoNext();
}
$this->Application->RemoveVar('ModuleRootCategory');
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
function getModuleItemName()
{
$module = $this->Application->GetVar('module');
$table = $this->Application->getUnitOption('confs', 'TableName');
$sql = 'SELECT ConfigHeader
FROM '.$table.'
WHERE ModuleName = '.$this->Conn->qstr($module);
return $this->Conn->GetOne($sql);
}
function PrintConfList($params)
{
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$list->PerPage = -1;
$list->Query();
$o = '';
$list->GoFirst();
$tmp_row = Array();
while (!$list->EOL()) {
$rec = $list->getCurrentRecord();
$tmp_row[0][$rec['VariableName']] = $rec['VariableValue'];
$tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['prompt'];
$list->GoNext();
}
$list->Records = $tmp_row;
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['module_key'] = $this->Application->GetVar('module_key');
$block_params['module_item'] = $this->getModuleItemName();
$list->GoFirst();
return $this->Application->ParseBlock($block_params, 1);
}
function ShowRelevance($params)
{
return $this->Application->GetVar('module_key') != '_';
}
function ConfigValue($params)
{
return $this->Application->ConfigValue($params['name']);
}
function Error($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
$field = $object->GetDBField($params['id_field']);
$errors = $this->Application->GetVar('errormsgs');
$errors = $errors[$this->getPrefixSpecial()];
if (isset($errors[$field])) {
$msg = $this->Application->Phrase($errors[$field]);
}
else {
$msg = '';
}
return $msg;
}
/**
* Allows to show category path of selected module
*
* @param Array $params
* @return string
*/
function CategoryPath($params)
{
+ $block_params['separator'] = $params['separator'];
+
if (!isset($params['cat_id'])) {
$params['cat_id'] = $this->ModuleRootCategory( Array() );
}
-
- $block_params['current'] = 1;
- $block_params['separator'] = $params['separator'];
+
if ($params['cat_id'] == 0) {
- $block_params['name'] = $params['rootcatblock'];
+ $block_params['cat_id'] = 0;
+ $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
+ $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as');
return $this->Application->ParseBlock($block_params);
}
else {
- $cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
-
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$params['cat_id'];
- $res = $this->Conn->GetRow($sql);
- if ($res === false) {
- // in case if category is deleted
- return '';
+ $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
+
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $sql = 'SELECT '.$navbar_field.', ParentPath
+ FROM '.$table_name.'
+ WHERE '.$id_field.' = '.$params['cat_id'];
+ $category_data = $this->Conn->GetRow($sql);
+ $ret = '';
+ if ($category_data) {
+ $category_names = explode('|', $category_data[$navbar_field]);
+ $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
+
+ // add "Home" category at beginning of path
+ array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
+ array_unshift($category_ids, 0);
+
+ foreach ($category_ids as $category_pos => $category_id) {
+ $block_params['cat_id'] = $category_id;
+ $block_params['cat_name'] = $category_names[$category_pos];
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+
+ $this->Application->SetVar($this->Prefix.'_id', $category_id);
+ $ret .= $this->Application->ParseBlock($block_params, 1);
+ }
}
- $block_params['name'] = $params['block'];
- $block_params['cat_name'] = $res['Name'];
- $block_params['separator'] = $params['separator'];
- $block_params['cat_id'] = $res['CategoryId'];
- $next_params['separator'] = $params['separator'];
- $next_params['rootcatblock'] = $params['rootcatblock'];
- $next_params['block'] = $params['block'];
- $next_params['cat_id'] = $res['ParentId'];
- return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_params);
+
+ return $ret;
}
}
/**
* Shows edit warning in case if module root category changed but not saved
*
* @param Array $params
* @return string
*/
function SaveWarning($params)
{
$temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
if ($temp_category_id !== false) {
return $this->Application->ParseBlock($params);
}
return '';
}
function ModuleRootCategory($params)
{
$category_id = $this->Application->RecallVar('ModuleRootCategory');
if ($category_id === false) {
$category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
}
return $category_id;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.13
\ No newline at end of property
+1.13.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php (revision 5636)
@@ -1,210 +1,221 @@
<?php
class ConfigurationTagProcessor extends kDBTagProcessor {
function Init($prefix,$special,$event_params=null)
{
parent::Init($prefix, $special, $event_params);
$this->Application->LinkVar('module_key');
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$o = '';
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
// $block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$block_params['IdField'] = $list->IDField;
$prev_heading = '';
$next_block = $params['full_block'];
$this->groupRecords($list->Records, 'heading');
$field_values = $this->Application->GetVar($this->getPrefixSpecial(true));
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
// using 2 blocks for drawing o row in case if current & next record titles match
$next_item_prompt = $list->CurrentIndex + 1 < $list->RecordsCount ? $list->Records[$list->CurrentIndex + 1]['prompt'] : '';
$this_item_prompt = $list->GetDBField('prompt');
if ($next_item_prompt == $this_item_prompt) {
$curr_block = $params['half_block1'];
$next_block = $params['half_block2'];
} else {
$curr_block = $next_block;
$next_block = $params['full_block'];
}
$block_params['name'] = $curr_block;
$block_params['show_heading'] = ($prev_heading != $list->GetDBField('heading') ) ? 1 : 0;
// set values from submit if any
if ($field_values) {
$list->SetDBField('VariableValue', $field_values[$list->GetDBField('VariableName')]['VariableValue']);
}
$o.= $this->Application->ParseBlock($block_params, 1);
$prev_heading = $list->GetDBField('heading');
$list->GoNext();
}
$this->Application->RemoveVar('ModuleRootCategory');
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
function getModuleItemName()
{
$module = $this->Application->GetVar('module');
$table = $this->Application->getUnitOption('confs', 'TableName');
$sql = 'SELECT ConfigHeader
FROM '.$table.'
WHERE ModuleName = '.$this->Conn->qstr($module);
return $this->Conn->GetOne($sql);
}
function PrintConfList($params)
{
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$list->PerPage = -1;
$list->Query();
$o = '';
$list->GoFirst();
$tmp_row = Array();
while (!$list->EOL()) {
$rec = $list->getCurrentRecord();
$tmp_row[0][$rec['VariableName']] = $rec['VariableValue'];
$tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['prompt'];
$list->GoNext();
}
$list->Records = $tmp_row;
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['module_key'] = $this->Application->GetVar('module_key');
$block_params['module_item'] = $this->getModuleItemName();
$list->GoFirst();
return $this->Application->ParseBlock($block_params, 1);
}
function ShowRelevance($params)
{
return $this->Application->GetVar('module_key') != '_';
}
function ConfigValue($params)
{
return $this->Application->ConfigValue($params['name']);
}
function Error($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
$field = $object->GetDBField($params['id_field']);
$errors = $this->Application->GetVar('errormsgs');
$errors = $errors[$this->getPrefixSpecial()];
if (isset($errors[$field])) {
$msg = $this->Application->Phrase($errors[$field]);
}
else {
$msg = '';
}
return $msg;
}
/**
* Allows to show category path of selected module
*
* @param Array $params
* @return string
*/
function CategoryPath($params)
{
+ $block_params['separator'] = $params['separator'];
+
if (!isset($params['cat_id'])) {
$params['cat_id'] = $this->ModuleRootCategory( Array() );
}
-
- $block_params['current'] = 1;
- $block_params['separator'] = $params['separator'];
+
if ($params['cat_id'] == 0) {
- $block_params['name'] = $params['rootcatblock'];
+ $block_params['cat_id'] = 0;
+ $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
+ $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as');
return $this->Application->ParseBlock($block_params);
}
else {
- $cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
-
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$params['cat_id'];
- $res = $this->Conn->GetRow($sql);
- if ($res === false) {
- // in case if category is deleted
- return '';
+ $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
+
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $sql = 'SELECT '.$navbar_field.', ParentPath
+ FROM '.$table_name.'
+ WHERE '.$id_field.' = '.$params['cat_id'];
+ $category_data = $this->Conn->GetRow($sql);
+ $ret = '';
+ if ($category_data) {
+ $category_names = explode('|', $category_data[$navbar_field]);
+ $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
+
+ // add "Home" category at beginning of path
+ array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
+ array_unshift($category_ids, 0);
+
+ foreach ($category_ids as $category_pos => $category_id) {
+ $block_params['cat_id'] = $category_id;
+ $block_params['cat_name'] = $category_names[$category_pos];
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+
+ $this->Application->SetVar($this->Prefix.'_id', $category_id);
+ $ret .= $this->Application->ParseBlock($block_params, 1);
+ }
}
- $block_params['name'] = $params['block'];
- $block_params['cat_name'] = $res['Name'];
- $block_params['separator'] = $params['separator'];
- $block_params['cat_id'] = $res['CategoryId'];
- $next_params['separator'] = $params['separator'];
- $next_params['rootcatblock'] = $params['rootcatblock'];
- $next_params['block'] = $params['block'];
- $next_params['cat_id'] = $res['ParentId'];
- return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_params);
+
+ return $ret;
}
}
/**
* Shows edit warning in case if module root category changed but not saved
*
* @param Array $params
* @return string
*/
function SaveWarning($params)
{
$temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
if ($temp_category_id !== false) {
return $this->Application->ParseBlock($params);
}
return '';
}
function ModuleRootCategory($params)
{
$category_id = $this->Application->RecallVar('ModuleRootCategory');
if ($category_id === false) {
$category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
}
return $category_id;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.13
\ No newline at end of property
+1.13.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php
===================================================================
--- branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php (revision 5636)
@@ -1,379 +1,379 @@
<?php
class clsRecursionStack
{
var $Stack;
function clsRecursionStack()
{
$this->Stack = Array();
}
function Push($values)
{
array_push($this->Stack, $values);
}
function Pop()
{
if ($this->Count() > 0) {
return array_pop($this->Stack);
}
else {
return false;
}
}
function Get()
{
if ($this->Count() > 0) {
// return end($this->Stack);
return $this->Stack[count($this->Stack)-1];
}
else {
return false;
}
}
function Update($values)
{
$this->Stack[count($this->Stack)-1] = $values;
}
function Count()
{
return count($this->Stack);
}
}
class clsCachedPermissions
{
var $Allow = Array();
var $Deny = Array();
var $CatId;
function clsCachedPermissions($CatId)
{
$this->CatId = $CatId;
}
function SetCatId($CatId)
{
$this->CatId = $CatId;
}
function CheckPermArray($Perm)
{
if (!isset($this->Allow[$Perm])) {
$this->Allow[$Perm] = array();
$this->Deny[$Perm] = array();
}
}
function AddAllow($Perm, $GroupId)
{
$this->CheckPermArray($Perm);
if (!in_array($GroupId, $this->Allow[$Perm])) {
array_push($this->Allow[$Perm], $GroupId);
$this->RemoveDeny($Perm, $GroupId);
}
}
function AddDeny($Perm, $GroupId)
{
$this->CheckPermArray($Perm);
if (!in_array($GroupId, $this->Deny[$Perm])) {
array_push($this->Deny[$Perm], $GroupId);
$this->RemoveAllow($Perm, $GroupId);
}
}
function RemoveDeny($Perm, $GroupId)
{
if (in_array($GroupId, $this->Deny[$Perm])) {
array_splice($this->Deny[$Perm], array_search($GroupId, $this->Deny[$Perm]), 1);
}
}
function RemoveAllow($Perm, $GroupId)
{
if (in_array($GroupId, $this->Allow[$Perm])) {
array_splice($this->Allow[$Perm], array_search($GroupId, $this->Allow[$Perm]), 1);
}
}
function GetInsertSQL()
{
$values = array();
$has_deny = array();
// don't write DACL at all
/*foreach ($this->Deny as $perm => $groups) {
if (count($groups) > 0) {
$values[] = '('.$this->CatId.', '.$perm.', "", "'.join(',', $groups).'")';
$has_deny[] = $perm;
}
}*/
foreach ($this->Allow as $perm => $groups) {
// if (in_array($perm, $has_deny)) continue;
if (count($groups) > 0) {
$values[] = '(' .$this->CatId. ', ' .$perm. ', "' .join(',', $groups). '", "")';
}
}
if (!$values) return '';
$sql = 'INSERT INTO '.TABLE_PREFIX.'PermCache (CategoryId, PermId, ACL, DACL) VALUES '.join(',', $values);
return $sql;
}
}
class kPermCacheUpdater extends kHelper
{
var $Stack;
var $iteration;
var $totalCats;
var $doneCats;
var $table;
var $primaryLanguageId = 0;
var $languageCount = 0;
var $root_prefixes = Array();
function Init($prefix, $special, $event_params = null)
{
parent::Init($prefix, $special, $event_params);
$continuing = $event_params['continue'];
// cache widely used values to speed up process: begin
$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
$this->languageCount = $ml_helper->getLanguageCount();
$this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
// cache widely used values to speed up process: end
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
$this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var'];
}
$this->iteration = 0;
$this->table = $this->Application->GetTempName('permCacheUpdate');
if ($continuing == 1) {
$this->InitUpdater();
}
elseif ($continuing == 2) {
$this->getData();
}
}
function InitUpdater()
{
$this->Stack =& new clsRecursionStack();
$sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
$this->Conn->Query($sql);
$this->initData();
}
function getDonePercent()
{
if(!$this->totalCats)return 0;
return intval( round( $this->doneCats / $this->totalCats * 100 ) );
}
function getData()
{
$tmp = $this->Conn->GetOne('SELECT data FROM '.$this->table);
if ($tmp) $tmp = unserialize($tmp);
$this->totalCats = isset($tmp['totalCats']) ? $tmp['totalCats'] : 0;
$this->doneCats = isset($tmp['doneCats']) ? $tmp['doneCats'] : 0;
if (isset($tmp['stack'])) {
$this->Stack = $tmp['stack'];
}
else {
$this->Stack = & new clsRecursionStack();
}
}
function setData()
{
$tmp = Array (
'totalCats' => $this->totalCats,
'doneCats' => $this->doneCats,
'stack' => $this->Stack,
);
$this->Conn->Query('DELETE FROM '.$this->table);
$fields_hash = Array('data' => serialize($tmp));
$this->Conn->doInsert($fields_hash, $this->table);
}
function initData()
{
$this->clearData(); // drop table before starting anyway
$this->Conn->Query('CREATE TABLE '.$this->table.'(data LONGTEXT)');
$this->totalCats = (int)$this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
$this->doneCats = 0;
}
function clearData()
{
$this->Conn->Query('DROP TABLE IF EXISTS '.$this->table);
}
function DoTheJob()
{
$data = $this->Stack->Get();
if ($data === false) { //If Stack is empty
$data['current_id'] = 0;
$data['titles'] = Array();
$data['parent_path'] = Array();
$data['named_path'] = Array();
$data['category_template'] = '';
$data['item_template'] = '';
$this->Stack->Push($data);
}
if (!isset($data['queried'])) {
$this->QueryTitle($data);
$this->QueryChildren($data);
$this->QueryPermissions($data);
$data['queried'] = 1;
if ($sql = $data['perms']->GetInsertSQL()) {
$this->Conn->Query($sql);
$this->doneCats++;
}
$this->iteration++;
}
// start with first child if we haven't started yet
if (!isset($data['current_child'])) $data['current_child'] = 0;
// if we have more children
if (isset($data['children'][$data['current_child']])) {
$next_data = Array();
$next_data['titles'] = $data['titles'];
$next_data['parent_path'] = $data['parent_path'];
$next_data['named_path'] = $data['named_path'];
$next_data['category_template'] = $data['category_template'];
$next_data['item_template'] = $data['item_template'];
$next_data['current_id'] = $data['children'][ $data['current_child'] ]; //next iteration should process child
$next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance
$next_data['perms']->SetCatId($next_data['current_id']);
$data['current_child']++;
$this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child
$this->Stack->Push($next_data); //next iteration should process this child
return true;
}
else {
$this->UpdateCachedPath($data);
$this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none)
// we are getting here if we finished with current level, so check if it's first level - then bail out.
return $this->Stack->Count() > 0;
}
}
function UpdateCachedPath(&$data)
{
$fields_hash = Array (
'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
'NamedParentPath' => implode('/', $data['named_path'] ),
'CachedCategoryTemplate' => $data['category_template'],
'CachedItemTemplate' => $data['item_template'],
);
$i = 1;
while ($i <= $this->languageCount) {
- $fields_hash['l'.$i.'_CachedNavbar'] = implode('>', $data['titles'][$i]);
+ $fields_hash['l'.$i.'_CachedNavbar'] = implode('|', $data['titles'][$i]);
$i++;
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']);
}
function QueryTitle(&$data)
{
$category_id = $data['current_id'];
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Category
WHERE CategoryId = '.$category_id;
$record = $this->Conn->GetRow($sql);
if ($record) {
$i = 1;
while ($i <= $this->languageCount) {
$data['titles'][$i][] = $record['l'.$i.'_Name'] ? $record['l'.$i.'_Name'] : $record['l'.$this->primaryLanguageId.'_Name'];
$i++;
}
$data['parent_path'][] = $category_id;
$data['named_path'][] = $record['Filename'];
// it is one of the modules root category
$root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false;
if ($root_prefix) {
$fields_hash = Array();
if (!$record['CategoryTemplate']) {
$record['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate');
$fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
}
if (!$record['ItemTemplate']) {
$record['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate');
$fields_hash['ItemTemplate'] = $record['ItemTemplate'];
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
}
// if explicitly set, then use it; use parent template otherwise
if ($record['CategoryTemplate']) {
$data['category_template'] = $record['CategoryTemplate'];
}
if ($record['ItemTemplate']) {
$data['item_template'] = $record['ItemTemplate'];
}
}
}
function QueryChildren(&$data)
{
$sql = 'SELECT CategoryId
FROM '.TABLE_PREFIX.'Category
WHERE ParentId = '.$data['current_id'];
$data['children'] = $this->Conn->GetCol($sql);
}
function QueryPermissions(&$data)
{
// don't search for section "view" permissions here :)
$sql = 'SELECT ipc.PermissionConfigId, ip.GroupId, ip.PermissionValue
FROM '.TABLE_PREFIX.'Permissions AS ip
LEFT JOIN '.TABLE_PREFIX.'PermissionConfig AS ipc ON ipc.PermissionName = ip.Permission
WHERE (CatId = '.$data['current_id'].') AND (Permission LIKE "%.VIEW") AND (ip.Type = 0)';
$records = $this->Conn->Query($sql);
//create permissions array only if we don't have it yet (set by parent)
if (!isset($data['perms'])) {
$data['perms'] = new clsCachedPermissions($data['current_id']);
}
foreach ($records as $record) {
if ($record['PermissionValue'] == 1) {
$data['perms']->AddAllow($record['PermissionConfigId'], $record['GroupId']);
}
else {
$data['perms']->AddDeny($record['PermissionConfigId'], $record['GroupId']);
}
}
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.6.2/kernel/units/categories/cache_updater.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6.2.3
\ No newline at end of property
+1.6.2.4
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php
===================================================================
--- branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php (revision 5636)
@@ -1,379 +1,379 @@
<?php
class clsRecursionStack
{
var $Stack;
function clsRecursionStack()
{
$this->Stack = Array();
}
function Push($values)
{
array_push($this->Stack, $values);
}
function Pop()
{
if ($this->Count() > 0) {
return array_pop($this->Stack);
}
else {
return false;
}
}
function Get()
{
if ($this->Count() > 0) {
// return end($this->Stack);
return $this->Stack[count($this->Stack)-1];
}
else {
return false;
}
}
function Update($values)
{
$this->Stack[count($this->Stack)-1] = $values;
}
function Count()
{
return count($this->Stack);
}
}
class clsCachedPermissions
{
var $Allow = Array();
var $Deny = Array();
var $CatId;
function clsCachedPermissions($CatId)
{
$this->CatId = $CatId;
}
function SetCatId($CatId)
{
$this->CatId = $CatId;
}
function CheckPermArray($Perm)
{
if (!isset($this->Allow[$Perm])) {
$this->Allow[$Perm] = array();
$this->Deny[$Perm] = array();
}
}
function AddAllow($Perm, $GroupId)
{
$this->CheckPermArray($Perm);
if (!in_array($GroupId, $this->Allow[$Perm])) {
array_push($this->Allow[$Perm], $GroupId);
$this->RemoveDeny($Perm, $GroupId);
}
}
function AddDeny($Perm, $GroupId)
{
$this->CheckPermArray($Perm);
if (!in_array($GroupId, $this->Deny[$Perm])) {
array_push($this->Deny[$Perm], $GroupId);
$this->RemoveAllow($Perm, $GroupId);
}
}
function RemoveDeny($Perm, $GroupId)
{
if (in_array($GroupId, $this->Deny[$Perm])) {
array_splice($this->Deny[$Perm], array_search($GroupId, $this->Deny[$Perm]), 1);
}
}
function RemoveAllow($Perm, $GroupId)
{
if (in_array($GroupId, $this->Allow[$Perm])) {
array_splice($this->Allow[$Perm], array_search($GroupId, $this->Allow[$Perm]), 1);
}
}
function GetInsertSQL()
{
$values = array();
$has_deny = array();
// don't write DACL at all
/*foreach ($this->Deny as $perm => $groups) {
if (count($groups) > 0) {
$values[] = '('.$this->CatId.', '.$perm.', "", "'.join(',', $groups).'")';
$has_deny[] = $perm;
}
}*/
foreach ($this->Allow as $perm => $groups) {
// if (in_array($perm, $has_deny)) continue;
if (count($groups) > 0) {
$values[] = '(' .$this->CatId. ', ' .$perm. ', "' .join(',', $groups). '", "")';
}
}
if (!$values) return '';
$sql = 'INSERT INTO '.TABLE_PREFIX.'PermCache (CategoryId, PermId, ACL, DACL) VALUES '.join(',', $values);
return $sql;
}
}
class kPermCacheUpdater extends kHelper
{
var $Stack;
var $iteration;
var $totalCats;
var $doneCats;
var $table;
var $primaryLanguageId = 0;
var $languageCount = 0;
var $root_prefixes = Array();
function Init($prefix, $special, $event_params = null)
{
parent::Init($prefix, $special, $event_params);
$continuing = $event_params['continue'];
// cache widely used values to speed up process: begin
$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
$this->languageCount = $ml_helper->getLanguageCount();
$this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
// cache widely used values to speed up process: end
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
$this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var'];
}
$this->iteration = 0;
$this->table = $this->Application->GetTempName('permCacheUpdate');
if ($continuing == 1) {
$this->InitUpdater();
}
elseif ($continuing == 2) {
$this->getData();
}
}
function InitUpdater()
{
$this->Stack =& new clsRecursionStack();
$sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
$this->Conn->Query($sql);
$this->initData();
}
function getDonePercent()
{
if(!$this->totalCats)return 0;
return intval( round( $this->doneCats / $this->totalCats * 100 ) );
}
function getData()
{
$tmp = $this->Conn->GetOne('SELECT data FROM '.$this->table);
if ($tmp) $tmp = unserialize($tmp);
$this->totalCats = isset($tmp['totalCats']) ? $tmp['totalCats'] : 0;
$this->doneCats = isset($tmp['doneCats']) ? $tmp['doneCats'] : 0;
if (isset($tmp['stack'])) {
$this->Stack = $tmp['stack'];
}
else {
$this->Stack = & new clsRecursionStack();
}
}
function setData()
{
$tmp = Array (
'totalCats' => $this->totalCats,
'doneCats' => $this->doneCats,
'stack' => $this->Stack,
);
$this->Conn->Query('DELETE FROM '.$this->table);
$fields_hash = Array('data' => serialize($tmp));
$this->Conn->doInsert($fields_hash, $this->table);
}
function initData()
{
$this->clearData(); // drop table before starting anyway
$this->Conn->Query('CREATE TABLE '.$this->table.'(data LONGTEXT)');
$this->totalCats = (int)$this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
$this->doneCats = 0;
}
function clearData()
{
$this->Conn->Query('DROP TABLE IF EXISTS '.$this->table);
}
function DoTheJob()
{
$data = $this->Stack->Get();
if ($data === false) { //If Stack is empty
$data['current_id'] = 0;
$data['titles'] = Array();
$data['parent_path'] = Array();
$data['named_path'] = Array();
$data['category_template'] = '';
$data['item_template'] = '';
$this->Stack->Push($data);
}
if (!isset($data['queried'])) {
$this->QueryTitle($data);
$this->QueryChildren($data);
$this->QueryPermissions($data);
$data['queried'] = 1;
if ($sql = $data['perms']->GetInsertSQL()) {
$this->Conn->Query($sql);
$this->doneCats++;
}
$this->iteration++;
}
// start with first child if we haven't started yet
if (!isset($data['current_child'])) $data['current_child'] = 0;
// if we have more children
if (isset($data['children'][$data['current_child']])) {
$next_data = Array();
$next_data['titles'] = $data['titles'];
$next_data['parent_path'] = $data['parent_path'];
$next_data['named_path'] = $data['named_path'];
$next_data['category_template'] = $data['category_template'];
$next_data['item_template'] = $data['item_template'];
$next_data['current_id'] = $data['children'][ $data['current_child'] ]; //next iteration should process child
$next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance
$next_data['perms']->SetCatId($next_data['current_id']);
$data['current_child']++;
$this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child
$this->Stack->Push($next_data); //next iteration should process this child
return true;
}
else {
$this->UpdateCachedPath($data);
$this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none)
// we are getting here if we finished with current level, so check if it's first level - then bail out.
return $this->Stack->Count() > 0;
}
}
function UpdateCachedPath(&$data)
{
$fields_hash = Array (
'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
'NamedParentPath' => implode('/', $data['named_path'] ),
'CachedCategoryTemplate' => $data['category_template'],
'CachedItemTemplate' => $data['item_template'],
);
$i = 1;
while ($i <= $this->languageCount) {
- $fields_hash['l'.$i.'_CachedNavbar'] = implode('>', $data['titles'][$i]);
+ $fields_hash['l'.$i.'_CachedNavbar'] = implode('|', $data['titles'][$i]);
$i++;
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']);
}
function QueryTitle(&$data)
{
$category_id = $data['current_id'];
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Category
WHERE CategoryId = '.$category_id;
$record = $this->Conn->GetRow($sql);
if ($record) {
$i = 1;
while ($i <= $this->languageCount) {
$data['titles'][$i][] = $record['l'.$i.'_Name'] ? $record['l'.$i.'_Name'] : $record['l'.$this->primaryLanguageId.'_Name'];
$i++;
}
$data['parent_path'][] = $category_id;
$data['named_path'][] = $record['Filename'];
// it is one of the modules root category
$root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false;
if ($root_prefix) {
$fields_hash = Array();
if (!$record['CategoryTemplate']) {
$record['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate');
$fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
}
if (!$record['ItemTemplate']) {
$record['ItemTemplate'] = $this->Application->ConfigValue($root_prefix.'_ItemTemplate');
$fields_hash['ItemTemplate'] = $record['ItemTemplate'];
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
}
// if explicitly set, then use it; use parent template otherwise
if ($record['CategoryTemplate']) {
$data['category_template'] = $record['CategoryTemplate'];
}
if ($record['ItemTemplate']) {
$data['item_template'] = $record['ItemTemplate'];
}
}
}
function QueryChildren(&$data)
{
$sql = 'SELECT CategoryId
FROM '.TABLE_PREFIX.'Category
WHERE ParentId = '.$data['current_id'];
$data['children'] = $this->Conn->GetCol($sql);
}
function QueryPermissions(&$data)
{
// don't search for section "view" permissions here :)
$sql = 'SELECT ipc.PermissionConfigId, ip.GroupId, ip.PermissionValue
FROM '.TABLE_PREFIX.'Permissions AS ip
LEFT JOIN '.TABLE_PREFIX.'PermissionConfig AS ipc ON ipc.PermissionName = ip.Permission
WHERE (CatId = '.$data['current_id'].') AND (Permission LIKE "%.VIEW") AND (ip.Type = 0)';
$records = $this->Conn->Query($sql);
//create permissions array only if we don't have it yet (set by parent)
if (!isset($data['perms'])) {
$data['perms'] = new clsCachedPermissions($data['current_id']);
}
foreach ($records as $record) {
if ($record['PermissionValue'] == 1) {
$data['perms']->AddAllow($record['PermissionConfigId'], $record['GroupId']);
}
else {
$data['perms']->AddDeny($record['PermissionConfigId'], $record['GroupId']);
}
}
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.6.2/core/units/categories/cache_updater.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6.2.3
\ No newline at end of property
+1.6.2.4
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.61.2/core/kernel/processors/main_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.61.2/core/kernel/processors/main_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.61.2/core/kernel/processors/main_processor.php (revision 5636)
@@ -1,864 +1,870 @@
<?php
class kMainTagProcessor extends TagProcessor {
function Init($prefix, $special, $event_params = null)
{
parent::Init($prefix, $special, $event_params);
$actions =& $this->Application->recallObject('kActions');
$actions->Set('t', $this->Application->GetVar('t'));
$actions->Set('sid', $this->Application->GetSID());
$actions->Set('m_opener', $this->Application->GetVar('m_opener') );
}
/**
* Used to handle calls where tag name
* match with existing php function name
*
* @param Tag $tag
* @return string
*/
function ProcessTag(&$tag)
{
if ($tag->Tag=='include') $tag->Tag='MyInclude';
return parent::ProcessTag($tag);
}
/**
* Base folder for all template includes
*
* @param Array $params
* @return string
*/
function TemplatesBase($params)
{
if ($this->Application->IsAdmin()) {
$module = isset($params['module']) ? $params['module'] : 'kernel';
$path = preg_replace('/\/(.*?)\/(.*)/', $module.'/\\2', THEMES_PATH); // remove leading slash + substitute module
}
else {
$path = substr(THEMES_PATH, 1);
}
return $this->Application->BaseURL().$path;
}
/**
* Creates <base href ..> HTML tag for all templates
* affects future css, js files and href params of links
*
* @return string
* @access public
*/
function Base_Ref($params)
{
return '<base href="'.$this->TemplatesBase($params).'/" />';
}
/**
* Returns base url for web-site
*
* @return string
* @access public
*/
function BaseURL()
{
return $this->Application->BaseURL();
}
function ProjectBase($params)
{
return $this->Application->BaseURL();
}
/*function Base($params)
{
return $this->Application->BaseURL().$params['add'];
}*/
/**
* Used to create link to any template.
* use "pass" paramter if "t" tag to specify
* prefix & special of object to be represented
* in resulting url
*
* @param Array $params
* @return string
* @access public
*/
function T($params)
{
//by default link to current template
$t = $this->SelectParam($params, 't,template');
unset($params['t']);
unset($params['template']);
$prefix=isset($params['prefix']) ? $params['prefix'] : ''; unset($params['prefix']);
$index_file = isset($params['index_file']) ? $params['index_file'] : null; unset($params['index_file']);
return $this->Application->HREF($t, $prefix, $params, $index_file);
}
function Link($params)
{
if (isset($params['template'])) {
$params['t'] = $params['template'];
unset($params['template']);
}
if (!isset($params['pass']) && !isset($params['no_pass'])) $params['pass'] = 'm';
if (isset($params['no_pass'])) unset($params['no_pass']);
if( $this->Application->GetVar('admin') ) $params['admin'] = 1;
return $this->T($params);
}
function Env($params)
{
$t = $params['template'];
unset($params['template']);
return $this->Application->BuildEnv($t, $params, 'm', null, false);
}
function FormAction($params)
{
return $this->Application->ProcessParsedTag('m', 't', Array( 'pass'=>'all,m' ) );
}
/*// NEEDS TEST
function Config($params)
{
return $this->Application->ConfigOption($params['var']);
}
function Object($params)
{
$name = $params['name'];
$method = $params['method'];
$tmp =& $this->Application->recallObject($name);
if ($tmp != null) {
if (method_exists($tmp, $method))
return $tmp->$method($params);
else
echo "Method $method does not exist in object ".get_class($tmp)." named $name<br>";
}
else
echo "Object $name does not exist in the appliaction<br>";
}*/
/**
* Tag, that always returns true.
* For parser testing purposes
*
* @param Array $params
* @return bool
* @access public
*/
function True($params)
{
return true;
}
/**
* Tag, that always returns false.
* For parser testing purposes
*
* @param Array $params
* @return bool
* @access public
*/
function False($params)
{
return false;
}
/**
* Returns block parameter by name
*
* @param Array $params
* @return stirng
* @access public
*/
function Param($params)
{
//$parser =& $this->Application->recallObject('TemplateParser');
$res = $this->Application->Parser->GetParam($params['name']);
if ($res === false) $res = '';
if (isset($params['plus']))
$res += $params['plus'];
return $res;
}
function DefaultParam($params)
{
foreach ($params as $key => $val) {
if ($this->Application->Parser->GetParam($key) === false) {
$this->Application->Parser->SetParam($key, $val);
}
}
}
/**
* Gets value of specified field from specified prefix_special and set it as parser param
*
* @param Array $params
*/
/*function SetParam($params)
{
// <inp2:m_SetParam param="custom_name" src="cf:FieldName"/>
list($prefix_special, $field_name) = explode(':', $params['src']);
$object =& $this->Application->recallObject($prefix_special);
$name = $this->SelectParam($params, 'param,name,var');
$this->Application->Parser->SetParam($name, $object->GetField($field_name) );
}*/
/**
* Compares block parameter with value specified
*
* @param Array $params
* @return bool
* @access public
*/
function ParamEquals($params)
{
//$parser =& $this->Application->recallObject('TemplateParser');
$name = $this->SelectParam($params, 'name,var,param');
$value = $params['value'];
return ($this->Application->Parser->GetParam($name) == $value);
}
/*function PHP_Self($params)
{
return $HTTP_SERVER_VARS['PHP_SELF'];
}
*/
/**
* Returns session variable value by name
*
* @param Array $params
* @return string
* @access public
*/
function Recall($params)
{
$ret = $this->Application->RecallVar( $this->SelectParam($params,'name,var,param') );
$ret = ($ret === false && isset($params['no_null'])) ? '' : $ret;
if( getArrayValue($params,'special') || getArrayValue($params,'htmlchars')) $ret = htmlspecialchars($ret);
if ( getArrayValue($params, 'urlencode') ) $ret = urlencode($ret);
return $ret;
}
// bad style to store something from template to session !!! (by Alex)
// Used here only to test how session works, nothing more
function Store($params)
{
//echo"Store $params[name]<br>";
$name = $params['name'];
$value = $params['value'];
$this->Application->StoreVar($name,$value);
}
/**
* Sets application variable value(-s)
*
* @param Array $params
* @access public
*/
function Set($params)
{
foreach ($params as $param => $value) {
$this->Application->SetVar($param, $value);
}
}
/**
* Increment application variable
* specified by number specified
*
* @param Array $params
* @access public
*/
function Inc($params)
{
$this->Application->SetVar($params['param'], $this->Application->GetVar($params['param']) + $params['by']);
}
/**
* Retrieves application variable
* value by name
*
* @param Array $params
* @return string
* @access public
*/
function Get($params)
{
$ret = $this->Application->GetVar($this->SelectParam($params, 'name,var,param'), '');
return getArrayValue($params, 'htmlchars') ? htmlspecialchars($ret) : $ret;
}
/**
* Retrieves application constant
* value by name
*
* @param Array $params
* @return string
* @access public
*/
function GetConst($params)
{
return defined($this->SelectParam($params, 'name,const')) ? constant($this->SelectParam($params, 'name,const,param')) : '';
}
/**
* Retrieves configuration variable value by name
*
* @param Array $params
* @return string
* @access public
*/
function GetConfig($params)
{
$config_name = $this->SelectParam($params, 'name,var');
$ret = $this->Application->ConfigValue($config_name);
if( getArrayValue($params, 'escape') ) $ret = addslashes($ret);
return $ret;
}
function ConfigEquals($params)
{
$option = $this->SelectParam($params, 'name,option,var');
return $this->Application->ConfigValue($option) == getArrayValue($params, 'value');
}
/**
* Creates all hidden fields
* needed for kernel_form
*
* @param Array $params
* @return string
* @access public
*/
function DumpSystemInfo($params)
{
$actions =& $this->Application->recallObject('kActions');
$actions->Set('t', $this->Application->GetVar('t') );
$params = $actions->GetParams();
$o='';
foreach ($params AS $name => $val)
{
$o .= "<input type='hidden' name='$name' id='$name' value='$val'>\n";
}
return $o;
}
function GetFormHiddens($params)
{
$sid = $this->Application->GetSID();
$t = $this->SelectParam($params, 'template,t');
unset($params['template']);
$env = $this->Application->BuildEnv($t, $params, 'm', null, false);
$o = '';
if ( $this->Application->RewriteURLs() )
{
$session =& $this->Application->recallObject('Session');
if ($session->NeedQueryString()) {
$o .= "<input type='hidden' name='sid' id='sid' value='$sid'>\n";
}
}
else {
$o .= "<input type='hidden' name='env' id='env' value='$env'>\n";
}
return $o;
}
function Odd_Even($params)
{
$odd = $params['odd'];
$even = $params['even'];
if (!isset($params['var'])) {
$var = 'odd_even';
}
else {
$var = $params['var'];
}
if ($this->Application->GetVar($var) == 'even') {
if (!isset($params['readonly']) || !$params['readonly']) {
$this->Application->SetVar($var, 'odd');
}
return $even;
}
else {
if (!isset($params['readonly']) || !$params['readonly']) {
$this->Application->SetVar($var, 'even');
}
return $odd;
}
}
/**
* Returns phrase translation by name
*
* @param Array $params
* @return string
* @access public
*/
function Phrase($params)
{
// m:phrase name="phrase_name" default="Tr-alala" updated="2004-01-29 12:49"
if (array_key_exists('default', $params)) return $params['default']; //backward compatibility
$translation = $this->Application->Phrase($this->SelectParam($params, 'label,name,title'));
if (getArrayValue($params, 'escape')) {
$translation = htmlspecialchars($translation);
$translation = str_replace('\'', ''', $translation);
$translation = addslashes($translation);
}
return $translation;
}
// for tabs
function is_active($params)
{
$test_templ = $this->SelectParam($params, 'templ,template,t');
if ( !getArrayValue($params,'allow_empty') )
{
$if_true=getArrayValue($params,'true') ? $params['true'] : 1;
$if_false=getArrayValue($params,'false') ? $params['false'] : 0;
}
else
{
$if_true=$params['true'];
$if_false=$params['false'];
}
if ( preg_match("/^".str_replace('/', '\/', $test_templ)."/", $this->Application->GetVar('t'))) {
return $if_true;
}
else {
return $if_false;
}
}
function IsNotActive($params)
{
return !$this->is_active($params);
}
function IsActive($params)
{
return $this->is_active($params);
}
function is_t_active($params)
{
return $this->is_active($params);
}
function CurrentTemplate($params)
{
return $this->is_active($params);
}
/**
* Checks if session variable
* specified by name value match
* value passed as parameter
*
* @param Array $params
* @return string
* @access public
*/
function RecallEquals($params)
{
$name = $this->SelectParam($params, 'name,var');
$value = $params['value'];
return ($this->Application->RecallVar($name) == $value);
}
/**
* Checks if application variable
* specified by name value match
* value passed as parameter
*
* @param Array $params
* @return bool
* @access public
*/
function GetEquals($params)
{
$name = $this->SelectParam($params, 'var,name,param');
$value = $params['value'];
if ($this->Application->GetVar($name) == $value) {
return 1;
}
}
/**
* Includes template
* and returns it's
* parsed version
*
* @param Array $params
* @return string
* @access public
*/
function MyInclude($params)
{
$BlockParser =& $this->Application->makeClass('TemplateParser');
$BlockParser->SetParams($params);
$parser =& $this->Application->Parser;
$this->Application->Parser =& $BlockParser;
$t = $this->SelectParam($params, 't,template,block,name');
$t = eregi_replace("\.tpl$", '', $t);
$templates_cache =& $this->Application->recallObject('TemplatesCache');
$res = $BlockParser->Parse( $templates_cache->GetTemplateBody($t, getArrayValue($params, 'is_silent')), $t );
if ( !$BlockParser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) {
if ($block_no_data = getArrayValue($params, 'block_no_data')) {
$res = $BlockParser->Parse(
$templates_cache->GetTemplateBody($block_no_data, getArrayValue($params, 'is_silent') ),
$t
);
}
else {
$res = '';
}
}
$this->Application->Parser =& $parser;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
return $res;
}
function ModuleInclude($params)
{
$ret = '';
$block_params = array_merge($params, Array('is_silent' => 2)); // don't make fatal errors in case if template is missing
$current_template = $this->Application->GetVar('t');
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
$module_key = strtolower($module_name);
if ($module_name == 'In-Portal') {
$module_prefix = '';
}
else {
$module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : $module_data['TemplatePath'].'/';
}
$block_params['t'] = $module_prefix.$this->SelectParam($params, $module_key.'_template,'.$module_key.'_t,template,t');
if ($block_params['t'] == $current_template) continue;
$no_data = $this->SelectParam($params, $module_key.'_block_no_data,block_no_data');
if ($no_data) {
$block_params['block_no_data'] = $module_prefix.'/'.$no_data;
}
$ret .= $this->MyInclude($block_params);
}
return $ret;
}
/*function Kernel_Scripts($params)
{
return '<script type="text/javascript" src="'.PROTOCOL.SERVER_NAME.BASE_PATH.'/kernel3/js/grid.js"></script>';
}*/
/*function GetUserPermission($params)
{
// echo"GetUserPermission $params[name]";
if ($this->Application->RecallVar('user_type') == 1)
return 1;
else {
$perm_name = $params[name];
$aPermissions = unserialize($this->Application->RecallVar('user_permissions'));
if ($aPermissions)
return $aPermissions[$perm_name];
}
}*/
/**
* Set's parser block param value
*
* @param Array $params
* @access public
*/
function AddParam($params)
{
$parser =& $this->Application->Parser; // recallObject('TemplateParser');
foreach ($params as $param => $value) {
$this->Application->SetVar($param, $value);
$parser->SetParam($param, $value);
$parser->AddParam('/\$'.$param.'/', $value);
}
}
/*function ParseToVar($params)
{
$var = $params['var'];
$tagdata = $params['tag'];
$parser =& $this->Application->Parser; //recallObject('TemplateParser');
$res = $this->Application->ProcessTag($tagdata);
$parser->SetParam($var, $res);
$parser->AddParam('/\$'.$var.'/', $res);
return '';
}*/
/*function TagNotEmpty($params)
{
$tagdata = $params['tag'];
$res = $this->Application->ProcessTag($tagdata);
return $res != '';
}*/
/*function TagEmpty($params)
{
return !$this->TagNotEmpty($params);
}*/
/**
* Parses block and returns result
*
* @param Array $params
* @return string
* @access public
*/
function ParseBlock($params)
{
$parser =& $this->Application->Parser; // recallObject('TemplateParser');
return $parser->ParseBlock($params);
}
function RenderElement($params)
{
return $this->ParseBlock($params);
}
/**
* Checks if debug mode is on
*
* @return bool
* @access public
*/
function IsDebugMode()
{
return $this->Application->isDebugMode();
}
function MassParse($params)
{
$qty = $params['qty'];
$block = $params['block'];
$mode = $params['mode'];
$o = '';
if ($mode == 'func') {
$func = create_function('$params', '
$o = \'<tr>\';
$o.= \'<td>a\'.$params[\'param1\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param2\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param3\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param4\'].\'</td>\';
$o.= \'</tr>\';
return $o;
');
for ($i=1; $i<$qty; $i++) {
$block_params['param1'] = rand(1, 10000);
$block_params['param2'] = rand(1, 10000);
$block_params['param3'] = rand(1, 10000);
$block_params['param4'] = rand(1, 10000);
$o .= $func($block_params);
}
return $o;
}
$block_params['name'] = $block;
for ($i=0; $i<$qty; $i++) {
$block_params['param1'] = rand(1, 10000);
$block_params['param2'] = rand(1, 10000);
$block_params['param3'] = rand(1, 10000);
$block_params['param4'] = rand(1, 10000);
$block_params['passed'] = $params['passed'];
$block_params['prefix'] = 'm';
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
function LoggedIn($params)
{
return $this->Application->LoggedIn();
}
/**
* Allows to check if permission exists directly in template and perform additional actions if required
*
* @param Array $params
* @return bool
*/
function CheckPermission($params)
{
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
return $perm_helper->TagPermissionCheck($params, 'm_CheckPermission');
}
/**
* Checks if user is logged in and if not redirects it to template passed
*
* @param Array $params
*/
function RequireLogin($params)
{
$t = $this->Application->GetVar('t');
if ($next_t = getArrayValue($params, 'next_template')) {
$t = $next_t;
}
// check by permissions: begin
if ((isset($params['perm_event']) && $params['perm_event']) || (isset($params['permissions']) && $params['permissions'])) {
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
$perm_status = $perm_helper->TagPermissionCheck($params, 'm_RequireLogin');
if (!$perm_status) {
list($redirect_template, $redirect_params) = $perm_helper->getPermissionTemplate($params);
$this->Application->Redirect($redirect_template, $redirect_params);
}
else {
return ;
}
}
// check by permissions: end
// check by configuration value: begin
$condition = getArrayValue($params, 'condition');
if (!$condition) {
$condition = true;
}
else {
if (substr($condition, 0, 1) == '!') {
$condition = !$this->Application->ConfigValue(substr($condition, 1));
}
else {
$condition = $this->Application->ConfigValue($condition);
}
}
// check by configuration value: end
// check by belonging to group: begin
$group = $this->SelectParam($params, 'group');
$group_access = true;
if ($group) {
$conn =& $this->Application->GetADODBConnection();
$group_id = $conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'PortalGroup WHERE Name = '.$conn->qstr($group));
if ($group_id) {
$groups = explode(',', $this->Application->RecallVar('UserGroups'));
$group_access = in_array($group_id, $groups);
}
}
// check by belonging to group: end
if ((!$this->Application->LoggedIn() || !$group_access) && $condition) {
if ( $this->Application->LoggedIn() && !$group_access) {
$this->Application->Redirect( $params['no_group_perm_template'], Array('next_template'=>$t) );
}
$redirect_params = Array('next_template' => $t);
$session_expired = $this->Application->GetVar('expired');
if ($session_expired) {
$redirect_params['expired'] = $session_expired;
}
$this->Application->Redirect($params['login_template'], $redirect_params);
}
}
function IsMember($params)
{
$group = getArrayValue($params, 'group');
$conn =& $this->Application->DB;
$group_id = $conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'PortalGroup WHERE Name = '.$conn->qstr($group));
if ($group_id) {
$groups = explode(',', $this->Application->RecallVar('UserGroups'));
$group_access = in_array($group_id, $groups);
}
return $group_access;
}
/**
* Checks if SSL is on and redirects to SSL URL if needed
* If SSL_URL is not defined in config - the tag does not do anything
* If for_logged_in_only="1" exits if user is not logged in.
* If called without params forces https right away. If called with by_config="1" checks the
* Require SSL setting from General Config and if it is ON forces https
*
* @param unknown_type $params
*/
function CheckSSL($params)
{
$ssl = $this->Application->ConfigValue('SSL_URL');
if (!$ssl) return; //SSL URL is not set - no way to require SSL
$require = false;
if ($params['mode'] == 'required') {
$require = true;
if (isset($params['for_logged_in_only']) && $params['for_logged_in_only'] && !$this->Application->LoggedIn()) {
$require = false;
}
if (isset($params['condition'])) {
if (!$this->Application->ConfigValue($params['condition'])) {
$require = false;
}
}
}
$http_query =& $this->Application->recallObject('HTTPQuery');
$pass = $http_query->getRedirectParams();
if ($require) {
if (PROTOCOL == 'https://') {
$this->Application->SetVar('__KEEP_SSL__', 1);
return;
}
$this->Application->Redirect('', array_merge_recursive2($pass, Array('__SSL__' => 1)));
}
else {
if (PROTOCOL == 'https://' && $this->Application->ConfigValue('Force_HTTP_When_SSL_Not_Required')) {
if ($this->Application->GetVar('__KEEP_SSL__')) return;
$this->Application->Redirect('', array_merge_recursive2($pass, Array('__SSL__' => 0)));
}
}
}
function ConstOn($params)
{
$name = $this->SelectParam($params,'name,const');
return constOn($name);
}
function SetDefaultCategory($params)
{
$module_name = $params['module'];
$module =& $this->Application->recallObject('mod.'.$module_name);
$this->Application->SetVar('m_cat_id', $module->GetDBField('RootCat') );
}
function XMLTemplate($params)
{
define('DBG_SKIP_REPORTING', 1);
$lang =& $this->Application->recallObject('lang.current');
header('Content-type: text/xml; charset='.$lang->GetDBField('Charset'));
}
+
+ function RootCategoryName($params)
+ {
+ $root_phrase = $this->Application->ConfigValue('Root_Name');
+ return $this->Application->Phrase($root_phrase);
+ }
}
?>
Property changes on: branches/unlabeled/unlabeled-1.61.2/core/kernel/processors/main_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.61
\ No newline at end of property
+1.61.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js
===================================================================
--- branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (revision 5635)
+++ branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (revision 5636)
@@ -1,291 +1,291 @@
var $is_catalog = true;
function Catalog($url_mask, $cookie_prefix) {
this.CookiePrefix = $cookie_prefix ? $cookie_prefix : '';
this.BusyRequest = new Array();
this.URLMask = $url_mask;
this.Separator = '#separator#';
this.ParentCategoryID = 0;
this.OnResponceMethod = null;
this.TabShift = 1; // start from 2nd tab (index starting from 0)
this.TabRegistry = new Array();
this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix');
this.PreviousPrefix = this.ActivePrefix;
$ViewMenus = new Array('c');
}
Catalog.prototype.Init = function () {
var $prefix = this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix');
if ($prefix !== this.ActivePrefix && this.TabRegistry.length > this.TabShift) {
// ActivePrefix not set or has non-existing prefix value
this.ActivePrefix = this.TabRegistry[this.TabShift]['prefix'];
}
this.SetAlternativeTabs();
this.go_to_cat();
}
Catalog.prototype.SetAlternativeTabs = function () {
// set alternative grids between all items (catalog is set when tab is loaded via AJAX first time)
var $i = this.TabShift;
while ($i < this.TabRegistry.length) {
// run through all prefixes
var $j = this.TabShift;
while ($j < this.TabRegistry.length) {
if (this.TabRegistry[$i]['prefix'] == this.TabRegistry[$j]['prefix']) {
$j++;
continue;
}
// and set alternative to all other prefixes
$GridManager.AddAlternativeGrid(this.TabRegistry[$i]['prefix'], this.TabRegistry[$j]['prefix']);
$j++;
}
$i++;
}
}
Catalog.prototype.submit_kernel_form = function($tab_id) {
var $prefix = 'dummy';
var $result_div = '';
if (isset($tab_id)) {
// responce result + progress are required
$prefix = this.queryTabRegistry('tab_id', $tab_id, 'prefix');
$result_div = $tab_id + '_div';
}
var $kf = document.getElementById($form_name);
Request.params = Request.serializeForm($kf);
Request.method = $kf.method.toUpperCase();
this.BusyRequest[$prefix] = false;
Request.makeRequest($kf.action, this.BusyRequest[$prefix], $result_div, this.successCallback, this.errorCallback, $result_div, this);
$form_name = 'kernel_form'; // restore back to main form with current category id of catalog
};
Catalog.prototype.successCallback = function($request, $params, $object) {
var $text = $request.responseText;
var $match_redirect = new RegExp('^#redirect#(.*)').exec($text);
if ($match_redirect != null) {
// redirect to external template requested
window.location.href = $match_redirect[1];
return false;
}
$params = $params.split(',');
var $js_end = $text.indexOf($object.Separator);
if ($js_end != -1) {
// allow to detect if output is permitted by ajax request parameters
var $request_visible = '$request_visible = ' + ($params[0].length ? 'true' : 'false') + "\n";
if ($params[0].length) {
document.getElementById($params[0]).innerHTML = $text.substring($js_end + $object.Separator.length);
eval($request_visible + $text.substring(0, $js_end));
}
else {
// eval JS only & set mark that js should not use HTML as usual in grids
eval($request_visible + $text.substring(0, $js_end));
}
}
else if ($params[0].length) {
document.getElementById($params[0]).innerHTML = $text;
}
if (typeof($object.OnResponceMethod) == 'function') {
$object.OnResponceMethod($object);
$object.OnResponceMethod = null;
}
if (typeof($Debugger) != 'undefined') {
$Debugger.Clear();
}
}
Catalog.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX ERROR: ' + Request.getErrorHtml($request));
}
Catalog.prototype.submit_event = function($prefix_special, $event, $t, $OnResponceMethod) {
if (typeof($OnResponceMethod) == 'function') {
this.OnResponceMethod = $OnResponceMethod;
}
var $prev_template = get_hidden_field('t');
if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix();
var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id');
$form_name = $tab_id + '_form'; // set firstly, because set_hidden_field uses it
if (isset($event)) set_hidden_field('events[' + $prefix_special + ']', $event);
if (isset($t)) set_hidden_field('t', $t);
this.submit_kernel_form($tab_id);
set_hidden_field('t', $prev_template);
}
Catalog.prototype.go_to_cat = function($cat_id) {
if (!isset($cat_id)) {
// gets current category
$cat_id = get_hidden_field('m_cat_id');
}
else {
// sets new category to kernel_form in case if item tab
// loads faster and will check if it's category is same
// as parent category of categories list
if (get_hidden_field('m_cat_id') == $cat_id) {
// it's the same category, then don't reload category list
- return true;
+ return ;
}
set_hidden_field('m_cat_id', $cat_id);
}
this.resetTabs(false);
// query sub categories of $cat_id
var $url = this.URLMask.replace('#TEMPLATE_NAME#', 'xml/categories_list').replace('#CATEGORY_ID#', $cat_id);
var $prefix = this.TabRegistry[0]['prefix'];
var $tab_id = this.TabRegistry[0]['tab_id'];
this.BusyRequest[$prefix] = false;
Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this);
this.switchTab(); // refresh current item tab
}
// set all item tabs counters to "?" before quering catagories
Catalog.prototype.resetTabs = function($reset_content) {
var $i = this.TabShift;
while ($i < this.TabRegistry.length) {
this.setItemCount(this.TabRegistry[$i]['prefix'], '?');
$i++;
}
if ($reset_content) {
// set category for all tabs to -1 (forces reload next time)
$i = this.TabShift;
while ($i < this.TabRegistry.length) {
document.getElementById(this.TabRegistry[$i]['tab_id'] + '_div').setAttribute('category_id', -1);
$i++;
}
}
}
Catalog.prototype.switchTab = function($prefix, $force) {
if (this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix') != this.ActivePrefix) {
// active prefix is not registred -> cookie left, but not modules installed/enabled at the moment
return false;
}
if (!isset($prefix)) $prefix = this.ActivePrefix;
if (this.BusyRequest[$prefix]) {
alert('prefix: ['+$prefix+']; request busy: ['+this.BusyRequest[$prefix]+']');
}
if (this.ActivePrefix != $prefix) {
// hide source tab
this.PreviousPrefix = this.ActivePrefix;
document.getElementById(this.PreviousPrefix + '_tab').className = 'catalog-tab-unselected';
document.getElementById(this.queryTabRegistry('prefix', this.PreviousPrefix, 'tab_id') + '_div').style.display = 'none';
this.HideDependentButtons(this.PreviousPrefix);
}
// show destination tab
this.ActivePrefix = $prefix;
document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-selected';
var $div_id = this.queryTabRegistry('prefix', this.ActivePrefix, 'tab_id') + '_div'; // destination tab
document.getElementById($div_id).style.display = 'block';
this.ShowDependentButtons(this.ActivePrefix);
this.setViewMenu(this.ActivePrefix);
setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix);
this.refreshTab($prefix, $div_id, $force);
}
Catalog.prototype.refreshTab = function($prefix, $div_id, $force) {
var $cat_id = get_hidden_field('m_cat_id');
var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id');
if ($cat_id != $tab_cat_id || $force) {
// query tab content only in case if not queried or category don't match
var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab');
$url = $url.replace('#CATEGORY_ID#', $cat_id);
this.BusyRequest[$prefix] = false;
Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id, this);
}
/*else {
alert('refresh disabled = {tab: '+this.ActivePrefix+'; cat_id: '+$cat_id+'}');
}*/
}
// adds information about tab to tab_registry
Catalog.prototype.registerTab = function($tab_id) {
var $tab = document.getElementById($tab_id + '_div');
var $index = this.TabRegistry.length;
this.TabRegistry[$index] = new Array();
this.TabRegistry[$index]['tab_id'] = $tab_id;
this.TabRegistry[$index]['prefix'] = $tab.getAttribute('prefix');
this.TabRegistry[$index]['module_path'] = $tab.getAttribute('edit_template').substring(0, $tab.getAttribute('edit_template').indexOf('/'));
this.TabRegistry[$index]['view_template'] = $tab.getAttribute('view_template');
this.TabRegistry[$index]['edit_template'] = $tab.getAttribute('edit_template');
this.TabRegistry[$index]['dep_buttons'] = $tab.getAttribute('dep_buttons').split(',');
this.TabRegistry[$index]['index'] = $index;
}
// allows to get any information about tab
Catalog.prototype.queryTabRegistry = function($search_key, $search_value, $return_key) {
var $i = 0;
while ($i < this.TabRegistry.length) {
if (this.TabRegistry[$i][$search_key] == $search_value) {
return this.TabRegistry[$i][$return_key];
break;
}
$i++;
}
return false;
}
Catalog.prototype.ShowDependentButtons = function($prefix) {
var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons');
var $i = 0;
while ($i < $dep_buttons.length) {
a_toolbar.ShowButton($dep_buttons[$i]);
$i++;
}
}
Catalog.prototype.HideDependentButtons = function($prefix) {
var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons');
var $i = 0;
while ($i < $dep_buttons.length) {
a_toolbar.HideButton($dep_buttons[$i]);
$i++;
}
}
Catalog.prototype.setItemCount = function($prefix, $count) {
setInnerHTML($prefix + '_item_count', $count);
}
Catalog.prototype.getCurrentPrefix = function() {
if (isset(Grids[this.ActivePrefix]) && (Grids[this.ActivePrefix].SelectedCount > 0)) {
// item tab grid exists and some items are selected
return this.ActivePrefix;
}
else {
// return prefix of first registred tab -> categories
return this.TabRegistry[0]['prefix'];
}
}
Catalog.prototype.setViewMenu = function($item_prefix) {
$ViewMenus = isset($item_prefix) ? new Array('c', $item_prefix) : new Array('c');
}
Catalog.prototype.reflectPasteButton = function($status) {
a_toolbar.SetEnabled('paste', $status);
a_toolbar.SetEnabled('clear_clipboard', $status);
}
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.27.2.4
\ No newline at end of property
+1.27.2.5
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js
===================================================================
--- branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js (revision 5635)
+++ branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js (revision 5636)
@@ -1,291 +1,291 @@
var $is_catalog = true;
function Catalog($url_mask, $cookie_prefix) {
this.CookiePrefix = $cookie_prefix ? $cookie_prefix : '';
this.BusyRequest = new Array();
this.URLMask = $url_mask;
this.Separator = '#separator#';
this.ParentCategoryID = 0;
this.OnResponceMethod = null;
this.TabShift = 1; // start from 2nd tab (index starting from 0)
this.TabRegistry = new Array();
this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix');
this.PreviousPrefix = this.ActivePrefix;
$ViewMenus = new Array('c');
}
Catalog.prototype.Init = function () {
var $prefix = this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix');
if ($prefix !== this.ActivePrefix && this.TabRegistry.length > this.TabShift) {
// ActivePrefix not set or has non-existing prefix value
this.ActivePrefix = this.TabRegistry[this.TabShift]['prefix'];
}
this.SetAlternativeTabs();
this.go_to_cat();
}
Catalog.prototype.SetAlternativeTabs = function () {
// set alternative grids between all items (catalog is set when tab is loaded via AJAX first time)
var $i = this.TabShift;
while ($i < this.TabRegistry.length) {
// run through all prefixes
var $j = this.TabShift;
while ($j < this.TabRegistry.length) {
if (this.TabRegistry[$i]['prefix'] == this.TabRegistry[$j]['prefix']) {
$j++;
continue;
}
// and set alternative to all other prefixes
$GridManager.AddAlternativeGrid(this.TabRegistry[$i]['prefix'], this.TabRegistry[$j]['prefix']);
$j++;
}
$i++;
}
}
Catalog.prototype.submit_kernel_form = function($tab_id) {
var $prefix = 'dummy';
var $result_div = '';
if (isset($tab_id)) {
// responce result + progress are required
$prefix = this.queryTabRegistry('tab_id', $tab_id, 'prefix');
$result_div = $tab_id + '_div';
}
var $kf = document.getElementById($form_name);
Request.params = Request.serializeForm($kf);
Request.method = $kf.method.toUpperCase();
this.BusyRequest[$prefix] = false;
Request.makeRequest($kf.action, this.BusyRequest[$prefix], $result_div, this.successCallback, this.errorCallback, $result_div, this);
$form_name = 'kernel_form'; // restore back to main form with current category id of catalog
};
Catalog.prototype.successCallback = function($request, $params, $object) {
var $text = $request.responseText;
var $match_redirect = new RegExp('^#redirect#(.*)').exec($text);
if ($match_redirect != null) {
// redirect to external template requested
window.location.href = $match_redirect[1];
return false;
}
$params = $params.split(',');
var $js_end = $text.indexOf($object.Separator);
if ($js_end != -1) {
// allow to detect if output is permitted by ajax request parameters
var $request_visible = '$request_visible = ' + ($params[0].length ? 'true' : 'false') + "\n";
if ($params[0].length) {
document.getElementById($params[0]).innerHTML = $text.substring($js_end + $object.Separator.length);
eval($request_visible + $text.substring(0, $js_end));
}
else {
// eval JS only & set mark that js should not use HTML as usual in grids
eval($request_visible + $text.substring(0, $js_end));
}
}
else if ($params[0].length) {
document.getElementById($params[0]).innerHTML = $text;
}
if (typeof($object.OnResponceMethod) == 'function') {
$object.OnResponceMethod($object);
$object.OnResponceMethod = null;
}
if (typeof($Debugger) != 'undefined') {
$Debugger.Clear();
}
}
Catalog.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX ERROR: ' + Request.getErrorHtml($request));
}
Catalog.prototype.submit_event = function($prefix_special, $event, $t, $OnResponceMethod) {
if (typeof($OnResponceMethod) == 'function') {
this.OnResponceMethod = $OnResponceMethod;
}
var $prev_template = get_hidden_field('t');
if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix();
var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id');
$form_name = $tab_id + '_form'; // set firstly, because set_hidden_field uses it
if (isset($event)) set_hidden_field('events[' + $prefix_special + ']', $event);
if (isset($t)) set_hidden_field('t', $t);
this.submit_kernel_form($tab_id);
set_hidden_field('t', $prev_template);
}
Catalog.prototype.go_to_cat = function($cat_id) {
if (!isset($cat_id)) {
// gets current category
$cat_id = get_hidden_field('m_cat_id');
}
else {
// sets new category to kernel_form in case if item tab
// loads faster and will check if it's category is same
// as parent category of categories list
if (get_hidden_field('m_cat_id') == $cat_id) {
// it's the same category, then don't reload category list
- return true;
+ return ;
}
set_hidden_field('m_cat_id', $cat_id);
}
this.resetTabs(false);
// query sub categories of $cat_id
var $url = this.URLMask.replace('#TEMPLATE_NAME#', 'xml/categories_list').replace('#CATEGORY_ID#', $cat_id);
var $prefix = this.TabRegistry[0]['prefix'];
var $tab_id = this.TabRegistry[0]['tab_id'];
this.BusyRequest[$prefix] = false;
Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this);
this.switchTab(); // refresh current item tab
}
// set all item tabs counters to "?" before quering catagories
Catalog.prototype.resetTabs = function($reset_content) {
var $i = this.TabShift;
while ($i < this.TabRegistry.length) {
this.setItemCount(this.TabRegistry[$i]['prefix'], '?');
$i++;
}
if ($reset_content) {
// set category for all tabs to -1 (forces reload next time)
$i = this.TabShift;
while ($i < this.TabRegistry.length) {
document.getElementById(this.TabRegistry[$i]['tab_id'] + '_div').setAttribute('category_id', -1);
$i++;
}
}
}
Catalog.prototype.switchTab = function($prefix, $force) {
if (this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix') != this.ActivePrefix) {
// active prefix is not registred -> cookie left, but not modules installed/enabled at the moment
return false;
}
if (!isset($prefix)) $prefix = this.ActivePrefix;
if (this.BusyRequest[$prefix]) {
alert('prefix: ['+$prefix+']; request busy: ['+this.BusyRequest[$prefix]+']');
}
if (this.ActivePrefix != $prefix) {
// hide source tab
this.PreviousPrefix = this.ActivePrefix;
document.getElementById(this.PreviousPrefix + '_tab').className = 'catalog-tab-unselected';
document.getElementById(this.queryTabRegistry('prefix', this.PreviousPrefix, 'tab_id') + '_div').style.display = 'none';
this.HideDependentButtons(this.PreviousPrefix);
}
// show destination tab
this.ActivePrefix = $prefix;
document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-selected';
var $div_id = this.queryTabRegistry('prefix', this.ActivePrefix, 'tab_id') + '_div'; // destination tab
document.getElementById($div_id).style.display = 'block';
this.ShowDependentButtons(this.ActivePrefix);
this.setViewMenu(this.ActivePrefix);
setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix);
this.refreshTab($prefix, $div_id, $force);
}
Catalog.prototype.refreshTab = function($prefix, $div_id, $force) {
var $cat_id = get_hidden_field('m_cat_id');
var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id');
if ($cat_id != $tab_cat_id || $force) {
// query tab content only in case if not queried or category don't match
var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab');
$url = $url.replace('#CATEGORY_ID#', $cat_id);
this.BusyRequest[$prefix] = false;
Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id, this);
}
/*else {
alert('refresh disabled = {tab: '+this.ActivePrefix+'; cat_id: '+$cat_id+'}');
}*/
}
// adds information about tab to tab_registry
Catalog.prototype.registerTab = function($tab_id) {
var $tab = document.getElementById($tab_id + '_div');
var $index = this.TabRegistry.length;
this.TabRegistry[$index] = new Array();
this.TabRegistry[$index]['tab_id'] = $tab_id;
this.TabRegistry[$index]['prefix'] = $tab.getAttribute('prefix');
this.TabRegistry[$index]['module_path'] = $tab.getAttribute('edit_template').substring(0, $tab.getAttribute('edit_template').indexOf('/'));
this.TabRegistry[$index]['view_template'] = $tab.getAttribute('view_template');
this.TabRegistry[$index]['edit_template'] = $tab.getAttribute('edit_template');
this.TabRegistry[$index]['dep_buttons'] = $tab.getAttribute('dep_buttons').split(',');
this.TabRegistry[$index]['index'] = $index;
}
// allows to get any information about tab
Catalog.prototype.queryTabRegistry = function($search_key, $search_value, $return_key) {
var $i = 0;
while ($i < this.TabRegistry.length) {
if (this.TabRegistry[$i][$search_key] == $search_value) {
return this.TabRegistry[$i][$return_key];
break;
}
$i++;
}
return false;
}
Catalog.prototype.ShowDependentButtons = function($prefix) {
var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons');
var $i = 0;
while ($i < $dep_buttons.length) {
a_toolbar.ShowButton($dep_buttons[$i]);
$i++;
}
}
Catalog.prototype.HideDependentButtons = function($prefix) {
var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons');
var $i = 0;
while ($i < $dep_buttons.length) {
a_toolbar.HideButton($dep_buttons[$i]);
$i++;
}
}
Catalog.prototype.setItemCount = function($prefix, $count) {
setInnerHTML($prefix + '_item_count', $count);
}
Catalog.prototype.getCurrentPrefix = function() {
if (isset(Grids[this.ActivePrefix]) && (Grids[this.ActivePrefix].SelectedCount > 0)) {
// item tab grid exists and some items are selected
return this.ActivePrefix;
}
else {
// return prefix of first registred tab -> categories
return this.TabRegistry[0]['prefix'];
}
}
Catalog.prototype.setViewMenu = function($item_prefix) {
$ViewMenus = isset($item_prefix) ? new Array('c', $item_prefix) : new Array('c');
}
Catalog.prototype.reflectPasteButton = function($status) {
a_toolbar.SetEnabled('paste', $status);
a_toolbar.SetEnabled('clear_clipboard', $status);
}
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.27.2/core/admin_templates/js/catalog.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.27.2.4
\ No newline at end of property
+1.27.2.5
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.15.2/kernel/admin_templates/xml/categories_list.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.15.2/kernel/admin_templates/xml/categories_list.tpl (revision 5635)
+++ branches/unlabeled/unlabeled-1.15.2/kernel/admin_templates/xml/categories_list.tpl (revision 5636)
@@ -1,76 +1,69 @@
<inp2:m_include t="incs/blocks"/>
<inp2:m_include t="incs/grid_blocks"/>
<inp2:c_InitList no_special="1" per_page="-1"/>
Grids['c'] = new Grid('c', 'table_white_selected', ':original', edit, a_toolbar);
Grids['c'].AddItemsByIdMask('td', /^c_([0-9-]+)/, 'c[$$ID$$][CategoryId]');
Grids['c'].InitItems();
Grids['c'].SetDependantToolbarButtons( new Array('edit','delete','approve','decline','sep3','cut','copy','move_up','move_down','sep6'));
<inp2:c_ViewMenu block="viewmenu_declaration" grid="Default" no_special="1" menu_perpage="no" menu_filters="yes" ajax="1"/>
<!-- substiture form action, like from was created from here -->
document.getElementById('categories_form').action = '<inp2:m_t pass="all" js_escape="1"/>';
$Catalog.setItemCount('c', '<inp2:c_TotalRecords no_special="1"/>');
$Catalog.ParentCategoryID = <inp2:c_GetParentCategory/>;
document.getElementById('c_search_warning').style.display = '<inp2:m_if check="m_RecallEquals" var="c_search_keyword" value="" inverse="inverse">block<inp2:m_else/>none</inp2:m_if>';
document.getElementById('c_search_keyword').value = '<inp2:c_SearchKeyword no_special="1" js_escape="1"/>';
-<inp2:m_DefineElement name="root_cat_caption">
- <span class="NAV_CURRENT_ITEM">
- <inp2:m_if check="m_ParamEquals" name="current" value="1">
- <inp2:c_RootCategoryName />
- <inp2:m_else/>
- <a class="control_link" href="javascript:$Catalog.go_to_cat(0);"><inp2:c_RootCategoryName /></a>
- </inp2:m_if>
- </span>
-</inp2:m_DefineElement>
<inp2:m_DefineElement name="category_caption">
<span class="NAV_CURRENT_ITEM">
- <inp2:m_param name="separator"/>
+ <inp2:m_if check="m_ParamEquals" name="cat_id" value="0" inverse="inverse">
+ <inp2:m_param name="separator"/>
+ </inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="current" value="1" inverse="1">
<a class="control_link" href="javascript:$Catalog.go_to_cat(<inp2:m_param name="cat_id"/>);"><inp2:m_param name="cat_name"/></a>
<inp2:m_else/>
<inp2:m_param name="cat_name"/>
</inp2:m_if>
</span>
</inp2:m_DefineElement>
-setInnerHTML('category_path', '<inp2:c_CategoryPath separator=">" rootcatblock="root_cat_caption" rootmoduleblock="category_caption" currentblock="category_caption" block="category_caption" js_escape="1"/>');
+setInnerHTML('category_path', '<inp2:c_CategoryPath separator=">" render_as="category_caption" js_escape="1"/>');
<inp2:m_if check="m_GetEquals" name="m_cat_id" value="0">
a_toolbar.DisableButton('upcat');
a_toolbar.DisableButton('homecat');
<inp2:m_else/>
a_toolbar.EnableButton('upcat');
a_toolbar.EnableButton('homecat');
</inp2:m_if>
$Catalog.reflectPasteButton(<inp2:c_HasClipboard/>);
#separator#
<inp2:c_UpdateLastTemplate template="catalog"/>
<inp2:m_include t="categories/ci_blocks"/>
<br />
<table border="0" width="100%">
<inp2:m_DefineElement name="category_td">
<td valign="top" class="table_white text" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:Field field="CategoryId"/>" width="50%">
<input type="checkbox" name="<inp2:InputName field="$IdField"/>" id="<inp2:InputName field="$IdField"/>">
<img src="<inp2:ModulePath />img/itemicons/<inp2:ItemIcon grid="Default"/>"> <span class="priority"><inp2:m_if check="FieldEquals" field="Priority" value="0" inverse="inverse"><sup><inp2:Field field="Priority"/></sup></inp2:m_if></span>
<a class="link" href="javascript:$Catalog.go_to_cat(<inp2:m_get name="c_id"/>);"><b><inp2:Field name="Name" no_special="1"/></b></a><span class="cat_desc">:</span>
<inp2:m_RenderElement name="status_mark" field="EditorsPick" type="pick" PrefixSpecial="$PrefixSpecial"/>
<inp2:m_RenderElement name="status_mark" field="IsNew" type="new" PrefixSpecial="$PrefixSpecial"/>
<span class="cats_stats">(<inp2:SubCatCount/> / <inp2:ItemCount/>)</span><br>
<div style="padding-left: 3px;">
<span class="cat_desc"><inp2:Field field="Description" no_special="1"/></span><br>
<inp2:m_if check="m_IsDebugMode">
<span class="cat_desc">ParentPath: <b><inp2:Field name="ParentPath"/></b></span><br />
</inp2:m_if>
<span class="cats_stats">(<inp2:Field field="CreatedOn" format="_regional_DateFormat"/>)</span>
</div>
</td>
</inp2:m_DefineElement>
<inp2:m_if check="c_TotalRecords" no_special="1">
<inp2:c_CategoryList no_special="1" block_main="category_td" per_page="-1" columns="2" direction="V" IdField="CategoryId" />
<inp2:m_else/>
<tr>
<td class="text">
<inp2:m_phrase name="la_text_NoCategories"/>
</td>
</tr>
</inp2:m_if>
</table></br>
Property changes on: branches/unlabeled/unlabeled-1.15.2/kernel/admin_templates/xml/categories_list.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.15.2.5
\ No newline at end of property
+1.15.2.6
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.15.2/core/admin_templates/categories/xml/categories_list.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.15.2/core/admin_templates/categories/xml/categories_list.tpl (revision 5635)
+++ branches/unlabeled/unlabeled-1.15.2/core/admin_templates/categories/xml/categories_list.tpl (revision 5636)
@@ -1,76 +1,69 @@
<inp2:m_include t="incs/blocks"/>
<inp2:m_include t="incs/grid_blocks"/>
<inp2:c_InitList no_special="1" per_page="-1"/>
Grids['c'] = new Grid('c', 'table_white_selected', ':original', edit, a_toolbar);
Grids['c'].AddItemsByIdMask('td', /^c_([0-9-]+)/, 'c[$$ID$$][CategoryId]');
Grids['c'].InitItems();
Grids['c'].SetDependantToolbarButtons( new Array('edit','delete','approve','decline','sep3','cut','copy','move_up','move_down','sep6'));
<inp2:c_ViewMenu block="viewmenu_declaration" grid="Default" no_special="1" menu_perpage="no" menu_filters="yes" ajax="1"/>
<!-- substiture form action, like from was created from here -->
document.getElementById('categories_form').action = '<inp2:m_t pass="all" js_escape="1"/>';
$Catalog.setItemCount('c', '<inp2:c_TotalRecords no_special="1"/>');
$Catalog.ParentCategoryID = <inp2:c_GetParentCategory/>;
document.getElementById('c_search_warning').style.display = '<inp2:m_if check="m_RecallEquals" var="c_search_keyword" value="" inverse="inverse">block<inp2:m_else/>none</inp2:m_if>';
document.getElementById('c_search_keyword').value = '<inp2:c_SearchKeyword no_special="1" js_escape="1"/>';
-<inp2:m_DefineElement name="root_cat_caption">
- <span class="NAV_CURRENT_ITEM">
- <inp2:m_if check="m_ParamEquals" name="current" value="1">
- <inp2:c_RootCategoryName />
- <inp2:m_else/>
- <a class="control_link" href="javascript:$Catalog.go_to_cat(0);"><inp2:c_RootCategoryName /></a>
- </inp2:m_if>
- </span>
-</inp2:m_DefineElement>
<inp2:m_DefineElement name="category_caption">
<span class="NAV_CURRENT_ITEM">
- <inp2:m_param name="separator"/>
+ <inp2:m_if check="m_ParamEquals" name="cat_id" value="0" inverse="inverse">
+ <inp2:m_param name="separator"/>
+ </inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="current" value="1" inverse="1">
<a class="control_link" href="javascript:$Catalog.go_to_cat(<inp2:m_param name="cat_id"/>);"><inp2:m_param name="cat_name"/></a>
<inp2:m_else/>
<inp2:m_param name="cat_name"/>
</inp2:m_if>
</span>
</inp2:m_DefineElement>
-setInnerHTML('category_path', '<inp2:c_CategoryPath separator=">" rootcatblock="root_cat_caption" rootmoduleblock="category_caption" currentblock="category_caption" block="category_caption" js_escape="1"/>');
+setInnerHTML('category_path', '<inp2:c_CategoryPath separator=">" render_as="category_caption" js_escape="1"/>');
<inp2:m_if check="m_GetEquals" name="m_cat_id" value="0">
a_toolbar.DisableButton('upcat');
a_toolbar.DisableButton('homecat');
<inp2:m_else/>
a_toolbar.EnableButton('upcat');
a_toolbar.EnableButton('homecat');
</inp2:m_if>
$Catalog.reflectPasteButton(<inp2:c_HasClipboard/>);
#separator#
<inp2:c_UpdateLastTemplate template="catalog"/>
<inp2:m_include t="categories/ci_blocks"/>
<br />
<table border="0" width="100%">
<inp2:m_DefineElement name="category_td">
<td valign="top" class="table_white text" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:Field field="CategoryId"/>" width="50%">
<input type="checkbox" name="<inp2:InputName field="$IdField"/>" id="<inp2:InputName field="$IdField"/>">
<img src="<inp2:ModulePath />img/itemicons/<inp2:ItemIcon grid="Default"/>"> <span class="priority"><inp2:m_if check="FieldEquals" field="Priority" value="0" inverse="inverse"><sup><inp2:Field field="Priority"/></sup></inp2:m_if></span>
<a class="link" href="javascript:$Catalog.go_to_cat(<inp2:m_get name="c_id"/>);"><b><inp2:Field name="Name" no_special="1"/></b></a><span class="cat_desc">:</span>
<inp2:m_RenderElement name="status_mark" field="EditorsPick" type="pick" PrefixSpecial="$PrefixSpecial"/>
<inp2:m_RenderElement name="status_mark" field="IsNew" type="new" PrefixSpecial="$PrefixSpecial"/>
<span class="cats_stats">(<inp2:SubCatCount/> / <inp2:ItemCount/>)</span><br>
<div style="padding-left: 3px;">
<span class="cat_desc"><inp2:Field field="Description" no_special="1"/></span><br>
<inp2:m_if check="m_IsDebugMode">
<span class="cat_desc">ParentPath: <b><inp2:Field name="ParentPath"/></b></span><br />
</inp2:m_if>
<span class="cats_stats">(<inp2:Field field="CreatedOn" format="_regional_DateFormat"/>)</span>
</div>
</td>
</inp2:m_DefineElement>
<inp2:m_if check="c_TotalRecords" no_special="1">
<inp2:c_CategoryList no_special="1" block_main="category_td" per_page="-1" columns="2" direction="V" IdField="CategoryId" />
<inp2:m_else/>
<tr>
<td class="text">
<inp2:m_phrase name="la_text_NoCategories"/>
</td>
</tr>
</inp2:m_if>
</table></br>
Property changes on: branches/unlabeled/unlabeled-1.15.2/core/admin_templates/categories/xml/categories_list.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.15.2.5
\ No newline at end of property
+1.15.2.6
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php (revision 5636)
@@ -1,447 +1,445 @@
<?php
class CategoriesTagProcessor extends kDBTagProcessor {
function &GetList($params)
{
$special = $this->BuildListSpecial($params);
$prefix_special = $this->Prefix.'.'.$special;
$this->Special = $special;
$params['skip_counting'] = true;
$list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List',$params);
// $list->clearFilters();
// $list->addFilter('parent_filter', 'ParentId = '.$parent_cat_id, WHERE_FILTER, FLT_SYSTEM);
//unset($params['skip_counting']);
// $this->Application->HandleEvent($event, $prefix_special.':SetPagination', $params );
$list->Query();
return $list;
}
function SubCatCount($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$sql = ' SELECT COUNT(*) - 1
FROM '.$cat_object->TableName.'
WHERE ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"';
return $this->Conn->GetOne($sql);
}
function IsNew($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$ret = $object->GetDBField('IsNew') ? 1 : 0;
return $ret;
}
function IsPick($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$ret = $object->GetDBField('EditorsPick') ? 1 : 0;
return $ret;
}
function ItemIcon($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$status = $object->GetDBField('Status');
if($status == 1)
{
$ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_cat.gif';
}
else
{
$ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif';
}
return $ret;
}
function ItemCount($params)
{
$cat_object =& $this->getObject($params);
$ci_table = $this->Application->getUnitOption('l-ci', 'TableName');
$sql = ' SELECT COUNT(*)
FROM '.$cat_object->TableName.' c
LEFT JOIN '.$ci_table.' ci
ON c.CategoryId=ci.CategoryId
WHERE c.ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"
AND NOT (ci.CategoryId IS NULL)';
return $this->Conn->GetOne($sql);
}
function ListCategories($params)
{
return $this->PrintList2($params);
}
function RootCategoryName($params)
{
- $root_phrase = $this->Application->ConfigValue('Root_Name');
- $ret = $this->Application->Phrase($root_phrase);
- return $ret;
+ return $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
}
function CheckModuleRoot($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
$module =& $this->Application->recallObject('mod.'.$module_name);
$module_root_cat = $module->GetDBField('RootCat');
$additional_cats = $this->SelectParam($params, 'add_cats');
if ($additional_cats) {
$additional_cats = explode(',', $additional_cats);
}
else {
$additional_cats = array();
}
if ($this->Application->GetVar('m_cat_id') == $module_root_cat || in_array($this->Application->GetVar('m_cat_id'), $additional_cats)) {
$home_template = getArrayValue($params, 'home_template');
if (!$home_template) return;
$this->Application->Redirect($home_template, Array('pass'=>'all'));
};
}
function CategoryPath($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
- $module =& $this->Application->recallObject('mod.'.$module_name);
- $module_root_cat = $module->GetDBField('RootCat');
+ $module_category_id = $this->Application->findModule('Name', $module_name, 'RootCat');
+ $module_item_id = $this->Application->GetVar($this->Application->findModule('Name', $module_name, 'Var').'_id');
- $block_params['current'] = 0;
$block_params['separator'] = $params['separator'];
- if(!isset($params['cat_id']))
- {
+ if (!isset($params['cat_id'])) {
$params['cat_id'] = getArrayValue($params, 'cat_id') ? $params['cat_id'] : $this->Application->GetVar('m_cat_id');
- $block_params['current'] = 1;
- }
- $product_id = $this->Application->GetVar('p_id');
- if ($product_id) {
- $block_params['current'] = 0;
}
- $block_params['is_module_root'] = ($params['cat_id'] == $module_root_cat) ? 1 : 0;
-
- if($params['cat_id'] == 0)
- {
- $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock');
+ if ($params['cat_id'] == 0) {
+ $block_params['current'] = 1;
+ $block_params['cat_id'] = 0;
+ $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
+ $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as');
return $this->Application->ParseBlock($block_params);
}
- else
- {
- $block_params['name'] = $this->SelectParam($params,'render_as,block');
- // $cat_object = &$this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' );
- $sql = 'SELECT CategoryId, ParentId, '.$this->getTitleField().' AS Name
- FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').'
- WHERE CategoryId = '.$params['cat_id'];
- $res = $this->Conn->GetRow($sql);
- if ($res === false) {
- // in case if category is deleted
- return '';
- }
-
- $block_params['cat_name'] = $res['Name'];
- $block_params['cat_id'] = $res['CategoryId'];
-
- $parent_params = $params;
- $parent_params['cat_id'] = $res['ParentId'];
-
- // which block to parse as current ?
- if ($block_params['is_module_root'] == 1) { // module root
- $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock');
- }
- if ($block_params['current'] == 1) { // current cat (label)
- $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock');
+ else {
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
+
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $sql = 'SELECT '.$navbar_field.', ParentPath
+ FROM '.$table_name.'
+ WHERE '.$id_field.' = '.$params['cat_id'];
+ $category_data = $this->Conn->GetRow($sql);
+ $ret = '';
+ if ($category_data) {
+ $category_names = explode('|', $category_data[$navbar_field]);
+ $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
+
+ // add "Home" category at beginning of path
+ array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
+ array_unshift($category_ids, 0);
+
+ foreach ($category_ids as $category_pos => $category_id) {
+ $block_params['cat_id'] = $category_id;
+ $block_params['cat_name'] = $category_names[$category_pos];
+ $block_params['current'] = ($params['cat_id'] == $category_id) && !$module_item_id ? 1 : 0;
+ $block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0;
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+
+ // which block to parse as current ?
+ if ($block_params['is_module_root'] == 1) { // module root
+ $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock,render_as');
+ }
+
+ if ($block_params['current'] == 1) { // current cat (label)
+ $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock,render_as');
+ }
+
+ $this->Application->SetVar($this->Prefix.'_id', $category_id);
+ $ret .= $this->Application->ParseBlock($block_params, 1);
+ }
}
-
- $this->Application->SetVar($this->Prefix.'_id', $res['CategoryId']);
- $current_cat = $this->Application->ParseBlock($block_params, 1);
-
- $this->Application->SetVar($this->Prefix.'_id', $res['ParentId']);
- $parent_cat = $this->CategoryPath($parent_params);
-
- return $parent_cat.$current_cat;
+
+ return $ret;
}
}
function CurrentCategoryName($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
$sql = 'SELECT '.$this->getTitleField().'
FROM '.$cat_object->TableName.'
WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
return $this->Conn->GetOne($sql);
}
function getTitleField()
{
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
return $ml_formatter->LangFieldName('Name');
}
function CategoryLink($params)
{
// 'p_id'=>'0', ??
$params = array_merge(array('pass'=>'m'), $params);
$cat_id = getArrayValue($params,'cat_id');
if ($cat_id === false) {
// $cat_id = $this->Application->Parser->GetParam('cat_id');
$cat_id = $this->Application->GetVar($this->Prefix.'_id');
}
if($cat_id == 'Root')
{
$object =& $this->Application->recallObject('mod.'.$params['module']);
$params['m_cat_id'] = $object->GetDBField('RootCat');
unset($params['module']);
}
else{
$params['m_cat_id'] = $cat_id;
}
unset($params['cat_id']);
$main_processor =& $this->Application->recallObject('m_TagProcessor');
return $main_processor->T($params);
}
function CategoryList($params)
{
//$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
$object =& $this->GetList($params);
if ($object->RecordsCount == 0)
{
if (isset($params['block_no_cats'])) {
$params['name'] = $params['block_no_cats'];
return $this->Application->ParseBlock($params);
}
else {
return '';
}
}
if (isset($params['block'])) {
return $this->PrintList($params);
}
else {
$params['block'] = $params['block_main'];
if (isset($params['block_row_start'])) {
$params['row_start_block'] = $params['block_row_start'];
}
if (isset($params['block_row_end'])) {
$params['row_end_block'] = $params['block_row_end'];
}
return $this->PrintList2($params);
}
}
function Meta($params)
{
$name = getArrayValue($params, 'name');
$object =& $this->Application->recallObject($this->Prefix.'.-item');
$field = $object->GetField('Meta'.$name);
if ($field) return $field;
switch ($name) {
case 'Description':
$conf = 'Category_MetaDesc';
break;
case 'Keywords':
$conf = 'Category_MetaKey';
break;
}
return $this->Application->ConfigValue($conf);
}
function BuildListSpecial($params)
{
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar($this->Prefix.'_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
$types = $this->SelectParam($params, 'types');
$except = $this->SelectParam($params, 'except');
$no_special = isset($params['no_special']) && $params['no_special'];
if ($types.$except.$parent_cat_id == '' || $no_special) {
return parent::BuildListSpecial($params);
}
$special = crc32($types.$except.$parent_cat_id);
return $special;
}
function IsCurrent($params)
{
return false;
}
/**
* Substitutes category in last template base on current category
*
* @param Array $params
*/
function UpdateLastTemplate($params)
{
$category_id = $this->Application->GetVar('m_cat_id');
list($index_file, $env) = explode('|', $this->Application->RecallVar('last_template'), 2);
$this->Application->SetVar(ENV_VAR_NAME, $env);
$this->Application->HttpQuery->processQueryString();
// update required fields
$this->Application->SetVar('m_cat_id', $category_id);
$this->Application->Session->SaveLastTemplate($params['template']);
}
function GetParentCategory($params)
{
$parent_id = 0;
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table = $this->Application->getUnitOption($this->Prefix,'TableName');
$cat_id = $this->Application->GetVar('m_cat_id');
if ($cat_id > 0) {
$sql = 'SELECT ParentId
FROM '.$table.'
WHERE '.$id_field.' = '.$cat_id;
$parent_id = $this->Conn->GetOne($sql);
}
return $parent_id;
}
function InitCacheUpdater($params)
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
$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 == 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 {
// all done -> redirect
$updater->clearData();
$this->Application->RemoveVar('PermCache_UpdateRequired');
$this->Application->Redirect($params['destination_template']);
}
$ret = $updater->getDonePercent();
}
return $ret;
}
function SaveWarning($params)
{
$main_prefix = getArrayValue($params, 'main_prefix');
if ($main_prefix && $main_prefix != '$main_prefix') {
$top_prefix = $main_prefix;
}
else {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if (!$temp_tables) {
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
$block_name = $this->SelectParam($params, 'render_as,name');
if ($block_name) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $block_name;
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
$block_params['display'] = $temp_tables && $modified ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
else {
return $temp_tables && $modified ? 1 : 0;
}
return ;
}
/**
* Allows to detect if this prefix has something in clipboard
*
* @param Array $params
* @return bool
*/
function HasClipboard($params)
{
$clipboard = $this->Application->RecallVar('clipboard');
if ($clipboard) {
$clipboard = unserialize($clipboard);
foreach ($clipboard as $prefix => $clipboard_data) {
foreach ($clipboard_data as $mode => $ids) {
if (count($ids)) return 1;
}
}
}
return 0;
}
/**
* Allows to detect if root category being edited
*
* @param Array $params
*/
function IsRootCategory($params)
{
$object =& $this->getObject($params);
return $object->IsRoot();
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.28.2/kernel/units/categories/categories_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.28.2.5
\ No newline at end of property
+1.28.2.6
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php (revision 5636)
@@ -1,447 +1,445 @@
<?php
class CategoriesTagProcessor extends kDBTagProcessor {
function &GetList($params)
{
$special = $this->BuildListSpecial($params);
$prefix_special = $this->Prefix.'.'.$special;
$this->Special = $special;
$params['skip_counting'] = true;
$list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List',$params);
// $list->clearFilters();
// $list->addFilter('parent_filter', 'ParentId = '.$parent_cat_id, WHERE_FILTER, FLT_SYSTEM);
//unset($params['skip_counting']);
// $this->Application->HandleEvent($event, $prefix_special.':SetPagination', $params );
$list->Query();
return $list;
}
function SubCatCount($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$sql = ' SELECT COUNT(*) - 1
FROM '.$cat_object->TableName.'
WHERE ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"';
return $this->Conn->GetOne($sql);
}
function IsNew($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$ret = $object->GetDBField('IsNew') ? 1 : 0;
return $ret;
}
function IsPick($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$ret = $object->GetDBField('EditorsPick') ? 1 : 0;
return $ret;
}
function ItemIcon($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$status = $object->GetDBField('Status');
if($status == 1)
{
$ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_cat.gif';
}
else
{
$ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif';
}
return $ret;
}
function ItemCount($params)
{
$cat_object =& $this->getObject($params);
$ci_table = $this->Application->getUnitOption('l-ci', 'TableName');
$sql = ' SELECT COUNT(*)
FROM '.$cat_object->TableName.' c
LEFT JOIN '.$ci_table.' ci
ON c.CategoryId=ci.CategoryId
WHERE c.ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"
AND NOT (ci.CategoryId IS NULL)';
return $this->Conn->GetOne($sql);
}
function ListCategories($params)
{
return $this->PrintList2($params);
}
function RootCategoryName($params)
{
- $root_phrase = $this->Application->ConfigValue('Root_Name');
- $ret = $this->Application->Phrase($root_phrase);
- return $ret;
+ return $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
}
function CheckModuleRoot($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
$module =& $this->Application->recallObject('mod.'.$module_name);
$module_root_cat = $module->GetDBField('RootCat');
$additional_cats = $this->SelectParam($params, 'add_cats');
if ($additional_cats) {
$additional_cats = explode(',', $additional_cats);
}
else {
$additional_cats = array();
}
if ($this->Application->GetVar('m_cat_id') == $module_root_cat || in_array($this->Application->GetVar('m_cat_id'), $additional_cats)) {
$home_template = getArrayValue($params, 'home_template');
if (!$home_template) return;
$this->Application->Redirect($home_template, Array('pass'=>'all'));
};
}
function CategoryPath($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
- $module =& $this->Application->recallObject('mod.'.$module_name);
- $module_root_cat = $module->GetDBField('RootCat');
+ $module_category_id = $this->Application->findModule('Name', $module_name, 'RootCat');
+ $module_item_id = $this->Application->GetVar($this->Application->findModule('Name', $module_name, 'Var').'_id');
- $block_params['current'] = 0;
$block_params['separator'] = $params['separator'];
- if(!isset($params['cat_id']))
- {
+ if (!isset($params['cat_id'])) {
$params['cat_id'] = getArrayValue($params, 'cat_id') ? $params['cat_id'] : $this->Application->GetVar('m_cat_id');
- $block_params['current'] = 1;
- }
- $product_id = $this->Application->GetVar('p_id');
- if ($product_id) {
- $block_params['current'] = 0;
}
- $block_params['is_module_root'] = ($params['cat_id'] == $module_root_cat) ? 1 : 0;
-
- if($params['cat_id'] == 0)
- {
- $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock');
+ if ($params['cat_id'] == 0) {
+ $block_params['current'] = 1;
+ $block_params['cat_id'] = 0;
+ $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
+ $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as');
return $this->Application->ParseBlock($block_params);
}
- else
- {
- $block_params['name'] = $this->SelectParam($params,'render_as,block');
- // $cat_object = &$this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' );
- $sql = 'SELECT CategoryId, ParentId, '.$this->getTitleField().' AS Name
- FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName').'
- WHERE CategoryId = '.$params['cat_id'];
- $res = $this->Conn->GetRow($sql);
- if ($res === false) {
- // in case if category is deleted
- return '';
- }
-
- $block_params['cat_name'] = $res['Name'];
- $block_params['cat_id'] = $res['CategoryId'];
-
- $parent_params = $params;
- $parent_params['cat_id'] = $res['ParentId'];
-
- // which block to parse as current ?
- if ($block_params['is_module_root'] == 1) { // module root
- $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock');
- }
- if ($block_params['current'] == 1) { // current cat (label)
- $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock');
+ else {
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
+
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $sql = 'SELECT '.$navbar_field.', ParentPath
+ FROM '.$table_name.'
+ WHERE '.$id_field.' = '.$params['cat_id'];
+ $category_data = $this->Conn->GetRow($sql);
+ $ret = '';
+ if ($category_data) {
+ $category_names = explode('|', $category_data[$navbar_field]);
+ $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
+
+ // add "Home" category at beginning of path
+ array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
+ array_unshift($category_ids, 0);
+
+ foreach ($category_ids as $category_pos => $category_id) {
+ $block_params['cat_id'] = $category_id;
+ $block_params['cat_name'] = $category_names[$category_pos];
+ $block_params['current'] = ($params['cat_id'] == $category_id) && !$module_item_id ? 1 : 0;
+ $block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0;
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+
+ // which block to parse as current ?
+ if ($block_params['is_module_root'] == 1) { // module root
+ $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock,render_as');
+ }
+
+ if ($block_params['current'] == 1) { // current cat (label)
+ $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock,render_as');
+ }
+
+ $this->Application->SetVar($this->Prefix.'_id', $category_id);
+ $ret .= $this->Application->ParseBlock($block_params, 1);
+ }
}
-
- $this->Application->SetVar($this->Prefix.'_id', $res['CategoryId']);
- $current_cat = $this->Application->ParseBlock($block_params, 1);
-
- $this->Application->SetVar($this->Prefix.'_id', $res['ParentId']);
- $parent_cat = $this->CategoryPath($parent_params);
-
- return $parent_cat.$current_cat;
+
+ return $ret;
}
}
function CurrentCategoryName($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
$sql = 'SELECT '.$this->getTitleField().'
FROM '.$cat_object->TableName.'
WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
return $this->Conn->GetOne($sql);
}
function getTitleField()
{
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
return $ml_formatter->LangFieldName('Name');
}
function CategoryLink($params)
{
// 'p_id'=>'0', ??
$params = array_merge(array('pass'=>'m'), $params);
$cat_id = getArrayValue($params,'cat_id');
if ($cat_id === false) {
// $cat_id = $this->Application->Parser->GetParam('cat_id');
$cat_id = $this->Application->GetVar($this->Prefix.'_id');
}
if($cat_id == 'Root')
{
$object =& $this->Application->recallObject('mod.'.$params['module']);
$params['m_cat_id'] = $object->GetDBField('RootCat');
unset($params['module']);
}
else{
$params['m_cat_id'] = $cat_id;
}
unset($params['cat_id']);
$main_processor =& $this->Application->recallObject('m_TagProcessor');
return $main_processor->T($params);
}
function CategoryList($params)
{
//$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
$object =& $this->GetList($params);
if ($object->RecordsCount == 0)
{
if (isset($params['block_no_cats'])) {
$params['name'] = $params['block_no_cats'];
return $this->Application->ParseBlock($params);
}
else {
return '';
}
}
if (isset($params['block'])) {
return $this->PrintList($params);
}
else {
$params['block'] = $params['block_main'];
if (isset($params['block_row_start'])) {
$params['row_start_block'] = $params['block_row_start'];
}
if (isset($params['block_row_end'])) {
$params['row_end_block'] = $params['block_row_end'];
}
return $this->PrintList2($params);
}
}
function Meta($params)
{
$name = getArrayValue($params, 'name');
$object =& $this->Application->recallObject($this->Prefix.'.-item');
$field = $object->GetField('Meta'.$name);
if ($field) return $field;
switch ($name) {
case 'Description':
$conf = 'Category_MetaDesc';
break;
case 'Keywords':
$conf = 'Category_MetaKey';
break;
}
return $this->Application->ConfigValue($conf);
}
function BuildListSpecial($params)
{
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar($this->Prefix.'_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
$types = $this->SelectParam($params, 'types');
$except = $this->SelectParam($params, 'except');
$no_special = isset($params['no_special']) && $params['no_special'];
if ($types.$except.$parent_cat_id == '' || $no_special) {
return parent::BuildListSpecial($params);
}
$special = crc32($types.$except.$parent_cat_id);
return $special;
}
function IsCurrent($params)
{
return false;
}
/**
* Substitutes category in last template base on current category
*
* @param Array $params
*/
function UpdateLastTemplate($params)
{
$category_id = $this->Application->GetVar('m_cat_id');
list($index_file, $env) = explode('|', $this->Application->RecallVar('last_template'), 2);
$this->Application->SetVar(ENV_VAR_NAME, $env);
$this->Application->HttpQuery->processQueryString();
// update required fields
$this->Application->SetVar('m_cat_id', $category_id);
$this->Application->Session->SaveLastTemplate($params['template']);
}
function GetParentCategory($params)
{
$parent_id = 0;
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table = $this->Application->getUnitOption($this->Prefix,'TableName');
$cat_id = $this->Application->GetVar('m_cat_id');
if ($cat_id > 0) {
$sql = 'SELECT ParentId
FROM '.$table.'
WHERE '.$id_field.' = '.$cat_id;
$parent_id = $this->Conn->GetOne($sql);
}
return $parent_id;
}
function InitCacheUpdater($params)
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
$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 == 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 {
// all done -> redirect
$updater->clearData();
$this->Application->RemoveVar('PermCache_UpdateRequired');
$this->Application->Redirect($params['destination_template']);
}
$ret = $updater->getDonePercent();
}
return $ret;
}
function SaveWarning($params)
{
$main_prefix = getArrayValue($params, 'main_prefix');
if ($main_prefix && $main_prefix != '$main_prefix') {
$top_prefix = $main_prefix;
}
else {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if (!$temp_tables) {
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
$block_name = $this->SelectParam($params, 'render_as,name');
if ($block_name) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $block_name;
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
$block_params['display'] = $temp_tables && $modified ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
else {
return $temp_tables && $modified ? 1 : 0;
}
return ;
}
/**
* Allows to detect if this prefix has something in clipboard
*
* @param Array $params
* @return bool
*/
function HasClipboard($params)
{
$clipboard = $this->Application->RecallVar('clipboard');
if ($clipboard) {
$clipboard = unserialize($clipboard);
foreach ($clipboard as $prefix => $clipboard_data) {
foreach ($clipboard_data as $mode => $ids) {
if (count($ids)) return 1;
}
}
}
return 0;
}
/**
* Allows to detect if root category being edited
*
* @param Array $params
*/
function IsRootCategory($params)
{
$object =& $this->getObject($params);
return $object->IsRoot();
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.28.2/core/units/categories/categories_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.28.2.5
\ No newline at end of property
+1.28.2.6
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/config/config_general.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/config/config_general.tpl (revision 5635)
+++ branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/config/config_general.tpl (revision 5636)
@@ -1,126 +1,125 @@
<inp2:m_RequireLogin perm_event="conf:OnLoad" system="1"/>
<inp2:m_include t="incs/header" nobody="yes"/>
<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
<inp2:m_ParseBlock name="section_header" prefix="conf" icon="icon46_settings_general" title="!la_tab_ConfigGeneral!"/>
<inp2:m_ParseBlock name="blue_bar" prefix="conf" title_preset="config_list_general" icon="icon46_settings_general"/>
<!-- ToolBar --->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
function ValidatePassFld(fieldId){
var passFld=document.getElementById(fieldId);
var passVerifyFld=document.getElementById('verify_'+fieldId);
if (passFld && passVerifyFld && passFld.value == passVerifyFld.value) {
return true;
}
else {
var passErrorCell=document.getElementById('error_'+fieldId);
if (passErrorCell){
passErrorCell.innerHTML='<inp2:m_phrase name="la_error_PasswordMatch" />';
}
return false;
}
}
function ValidatePassFields(){
var el=false;
var validated=true;
for (var i=0; i<document.forms.kernel_form.elements.length; i++){
el=document.forms.kernel_form.elements[i];
if (el.getAttribute('primarytype')=='password'){
if (!ValidatePassFld(el.id)){
validated=false;
}
}
}
return validated;
}
function toggle_section($label) {
var $table = document.getElementById('config_table');
var $row = null;
var $is_visible = false;
for (var $i = 0; $i < $table.rows.length; $i++) {
$row = $table.rows[$i];
if ($row.getAttribute('header_label') != $label) {
continue;
}
if (!$row.style.display) {
$row.style.display = document.all ? 'block' : 'table-row';
}
$is_visible = !($row.style.display == 'none');
$row.style.display = $is_visible ? 'none' : (document.all ? 'block' : 'table-row');
document.getElementById('toggle_mark['+$label+']').innerHTML = '[' + ($is_visible ? '+' : '-') + ']';
}
}
var a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
if (ValidatePassFields()){
submit_event('conf','<inp2:conf_SaveEvent/>');
}
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('conf','OnCancel');
}
) );
a_toolbar.Render();
</script>
</td>
</tr>
</tbody>
</table>
<inp2:m_include t="incs/config_blocks"/>
<inp2:conf_SaveWarning name="grid_save_warning"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder" id="config_table">
<!-- module root category selector: begin -->
<tr class="subsectiontitle">
<td colspan="2">
<inp2:m_phrase name="la_Text_RootCategory" />
</td>
<td align="right">
<a class="config-header" href="javascript:toggle_section('la_Text_RootCategory');" id="toggle_mark[la_Text_RootCategory]" title="Collapse/Expand Section">[-]</a>
</td>
</tr>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" header_label="la_Text_RootCategory">
<td>
<span class="text"><inp2:m_phrase name="la_prompt_RootCategory" /></span>
</td>
<td>
<inp2:m_DefineElement name="category_caption">
- <inp2:m_param name="separator"/><inp2:m_param name="cat_name"/>
- </inp2:m_DefineElement>
-
- <inp2:m_DefineElement name="root_cat_caption" />
+ <inp2:m_if check="m_ParamEquals" name="cat_id" value="0" inverse="inverse">
+ <inp2:m_param name="separator"/>
+ </inp2:m_if>
<inp2:m_param name="cat_name"/>
</inp2:m_DefineElement>
- <b><inp2:c_RootCategoryName/><inp2:conf_CategoryPath separator=" > " rootcatblock="root_cat_caption" block="category_caption" /></b>
+ <b><inp2:conf_CategoryPath separator=" > " render_as="category_caption" /></b>
<input type="hidden" name="conf[ModuleRootCategory][VariableValue]" value="<inp2:conf_ModuleRootCategory/>"/>
<a href="javascript:openSelector('conf', '<inp2:m_t t="category_selector" pass="all,conf"/>', 'ModuleRootCategory');"><img src="img/icons/icon24_cat.gif" border="0" align="absmiddle" /></a>
</td>
<td class="error"> </td>
</tr>
<!-- module root category selector: end -->
<inp2:conf_PrintList block="config_block" per_page="-1" full_block="config_block" half_block1="config_block1" half_block2="config_block2"/>
</table>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/config/config_general.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.4.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php (revision 5636)
@@ -1,187 +1,188 @@
<?php
class PermissionsTagProcessor extends kDBTagProcessor {
function HasPermission($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
return array_search($params['perm_name'], $section_data['permissions']) !== false;
}
function HasAdvancedPermissions($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
$ret = false;
foreach ($section_data['permissions'] as $perm_name) {
if (preg_match('/^advanced:(.*)/', $perm_name)) {
$ret = true;
break;
}
}
return $ret;
}
function PermissionValue($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
$perm_name = $params['perm_name'];
$permissions_helper =& $this->Application->recallObject('PermissionsHelper');
if (!$permissions_helper->isOldPermission($section_name, $perm_name)) {
$perm_name = $section_name.'.'.$perm_name;
}
return $permissions_helper->getPermissionValue($perm_name);
}
function LoadPermissions($params)
{
$permissions_helper =& $this->Application->recallObject('PermissionsHelper');
$prefix_parts = explode('-', $this->Prefix, 2);
$permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1);
}
function LevelIndicator($params)
{
return $params['level'] * $params['multiply'];
}
function PrintPermissions($params)
{
$category =& $this->Application->recallObject('c');
$group_id = $this->Application->GetVar('group_id');
$prefix = $this->Application->GetVar('item_prefix');
$module = $this->Application->findModule('Var', $prefix, 'Name');
$perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName');
$perm_temp_table = $this->Application->GetTempName($perm_live_table);
if ($category->GetID() == 0) {
$categories = Array(0);
}
else {
$categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1));
}
if (count($categories) == 1 || $category->GetID() == 0) {
// category located in root category ("Home") => then add it to path virtually
array_unshift($categories, 0);
}
$this_cat = array_pop($categories);
// get permission name + category position in parent path that has value set for that permission
$case = 'MAX(CASE c.CategoryId';
foreach ($categories as $pos => $cat_id) {
$case .= ' WHEN '.$cat_id.' THEN '.$pos;
}
$case .= ' END) AS InheritedPosition';
$sql = 'SELECT '.$case.', p.Permission AS Perm
FROM '.TABLE_PREFIX.'Category c
LEFT JOIN '.$perm_live_table.' p ON p.CatId = c.CategoryId
LEFT JOIN '.TABLE_PREFIX.'PermissionConfig pc ON pc.PermissionName = p.Permission
WHERE
CategoryId IN ('.implode(',', $categories).') AND
ModuleId = "'.$module.'" AND
(
(p.GroupId = '.$group_id.' AND p.Type = 0)
)
GROUP BY Perm';
$perm_positions = $this->Conn->GetCol($sql, 'Perm');
$pos_sql = '';
foreach ($perm_positions as $perm_name => $category_pos) {
$pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR ';
}
$pos_sql = $pos_sql ? preg_replace('/(.*) OR $/', '\\1', $pos_sql) : '0';
// get all permissions list with iheritence status, inherited category id and permission value
$sql = 'SELECT pc.PermissionName,
pc.Description,
IF (tmp_p.PermissionValue IS NULL AND p.PermissionValue IS NULL,
0,
IF (tmp_p.PermissionValue IS NOT NULL, tmp_p.PermissionValue, p.PermissionValue)
) AS Value,
IF (tmp_p.CatId IS NOT NULL, tmp_p.CatId, IF(p.CatId IS NOT NULL, p.CatId, 0) ) AS InheritedFrom,
IF(tmp_p.CatId = '.$category->GetID().', 0, 1) AS Inherited,
IF(p.PermissionValue IS NOT NULL, p.PermissionValue, 0) AS InheritedValue
FROM '.TABLE_PREFIX.'PermissionConfig pc
LEFT JOIN '.$perm_live_table.' p
ON (p.Permission = pc.PermissionName) AND ('.str_replace('#TABLE_PREFIX#', 'p', $pos_sql).') AND (p.GroupId = '.$group_id.')
LEFT JOIN '.$perm_temp_table.' tmp_p
ON (tmp_p.Permission = pc.PermissionName) AND (tmp_p.CatId = '.$this_cat.') AND (tmp_p.GroupId = '.$group_id.')
WHERE ModuleId = "'.$module.'"';
$permissions = $this->Conn->Query($sql);
$ret = '';
$block_params = array_merge_recursive2( $this->prepareTagParams($params), Array('name' => $params['render_as']));
foreach ($permissions as $perm_record) {
$block_params = array_merge_recursive2($block_params, $perm_record);
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Print module tab for each module
*
* @param Array $params
* @return string
*/
function PrintTabs($params)
{
$ret = '';
$block_params = $params;
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
$params['item_prefix'] = $module_data['Var'];
$ret .= $this->Application->ProcessParsedTag('m', 'MyInclude', $params);
}
return $ret;
}
/**
* Returns category name by ID
*
* @param Array $params
*/
function CategoryPath($params)
{
$category_id = $params['cat_id'];
$category_path = $this->Application->getCache('category_paths', $category_id);
if ($category_path === false) {
// not chached
if ($category_id > 0) {
$id_field = $this->Application->getUnitOption('c', 'IDField');
$table_name = $this->Application->getUnitOption('c', 'TableName');
- $sql = 'SELECT CachedNavbar
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT '.$ml_formatter->LangFieldName('CachedNavbar').'
FROM '.$table_name.'
WHERE '.$id_field.' = '.$category_id;
- $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).'>'.$this->Conn->GetOne($sql), '>');
+ $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).' > '.str_replace('|', ' > ', $this->Conn->GetOne($sql)), ' > ');
}
else {
$category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
}
$this->Application->setCache('category_paths', $category_id, $category_path);
}
return $category_path;
}
function PermInputName($params)
{
return $this->Prefix.'['.$this->Application->GetVar('group_id').']['.$this->Application->Parser->GetParam('PermissionName').']['.$params['sub_key'].']';
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8.2.1
\ No newline at end of property
+1.8.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php (revision 5635)
+++ branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php (revision 5636)
@@ -1,187 +1,188 @@
<?php
class PermissionsTagProcessor extends kDBTagProcessor {
function HasPermission($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
return array_search($params['perm_name'], $section_data['permissions']) !== false;
}
function HasAdvancedPermissions($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
$ret = false;
foreach ($section_data['permissions'] as $perm_name) {
if (preg_match('/^advanced:(.*)/', $perm_name)) {
$ret = true;
break;
}
}
return $ret;
}
function PermissionValue($params)
{
$section_name = $params['section_name'];
$sections_helper =& $this->Application->recallObject('SectionsHelper');
$section_data =& $sections_helper->getSectionData($section_name);
$perm_name = $params['perm_name'];
$permissions_helper =& $this->Application->recallObject('PermissionsHelper');
if (!$permissions_helper->isOldPermission($section_name, $perm_name)) {
$perm_name = $section_name.'.'.$perm_name;
}
return $permissions_helper->getPermissionValue($perm_name);
}
function LoadPermissions($params)
{
$permissions_helper =& $this->Application->recallObject('PermissionsHelper');
$prefix_parts = explode('-', $this->Prefix, 2);
$permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1);
}
function LevelIndicator($params)
{
return $params['level'] * $params['multiply'];
}
function PrintPermissions($params)
{
$category =& $this->Application->recallObject('c');
$group_id = $this->Application->GetVar('group_id');
$prefix = $this->Application->GetVar('item_prefix');
$module = $this->Application->findModule('Var', $prefix, 'Name');
$perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName');
$perm_temp_table = $this->Application->GetTempName($perm_live_table);
if ($category->GetID() == 0) {
$categories = Array(0);
}
else {
$categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1));
}
if (count($categories) == 1 || $category->GetID() == 0) {
// category located in root category ("Home") => then add it to path virtually
array_unshift($categories, 0);
}
$this_cat = array_pop($categories);
// get permission name + category position in parent path that has value set for that permission
$case = 'MAX(CASE c.CategoryId';
foreach ($categories as $pos => $cat_id) {
$case .= ' WHEN '.$cat_id.' THEN '.$pos;
}
$case .= ' END) AS InheritedPosition';
$sql = 'SELECT '.$case.', p.Permission AS Perm
FROM '.TABLE_PREFIX.'Category c
LEFT JOIN '.$perm_live_table.' p ON p.CatId = c.CategoryId
LEFT JOIN '.TABLE_PREFIX.'PermissionConfig pc ON pc.PermissionName = p.Permission
WHERE
CategoryId IN ('.implode(',', $categories).') AND
ModuleId = "'.$module.'" AND
(
(p.GroupId = '.$group_id.' AND p.Type = 0)
)
GROUP BY Perm';
$perm_positions = $this->Conn->GetCol($sql, 'Perm');
$pos_sql = '';
foreach ($perm_positions as $perm_name => $category_pos) {
$pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR ';
}
$pos_sql = $pos_sql ? preg_replace('/(.*) OR $/', '\\1', $pos_sql) : '0';
// get all permissions list with iheritence status, inherited category id and permission value
$sql = 'SELECT pc.PermissionName,
pc.Description,
IF (tmp_p.PermissionValue IS NULL AND p.PermissionValue IS NULL,
0,
IF (tmp_p.PermissionValue IS NOT NULL, tmp_p.PermissionValue, p.PermissionValue)
) AS Value,
IF (tmp_p.CatId IS NOT NULL, tmp_p.CatId, IF(p.CatId IS NOT NULL, p.CatId, 0) ) AS InheritedFrom,
IF(tmp_p.CatId = '.$category->GetID().', 0, 1) AS Inherited,
IF(p.PermissionValue IS NOT NULL, p.PermissionValue, 0) AS InheritedValue
FROM '.TABLE_PREFIX.'PermissionConfig pc
LEFT JOIN '.$perm_live_table.' p
ON (p.Permission = pc.PermissionName) AND ('.str_replace('#TABLE_PREFIX#', 'p', $pos_sql).') AND (p.GroupId = '.$group_id.')
LEFT JOIN '.$perm_temp_table.' tmp_p
ON (tmp_p.Permission = pc.PermissionName) AND (tmp_p.CatId = '.$this_cat.') AND (tmp_p.GroupId = '.$group_id.')
WHERE ModuleId = "'.$module.'"';
$permissions = $this->Conn->Query($sql);
$ret = '';
$block_params = array_merge_recursive2( $this->prepareTagParams($params), Array('name' => $params['render_as']));
foreach ($permissions as $perm_record) {
$block_params = array_merge_recursive2($block_params, $perm_record);
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Print module tab for each module
*
* @param Array $params
* @return string
*/
function PrintTabs($params)
{
$ret = '';
$block_params = $params;
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
$params['item_prefix'] = $module_data['Var'];
$ret .= $this->Application->ProcessParsedTag('m', 'MyInclude', $params);
}
return $ret;
}
/**
* Returns category name by ID
*
* @param Array $params
*/
function CategoryPath($params)
{
$category_id = $params['cat_id'];
$category_path = $this->Application->getCache('category_paths', $category_id);
if ($category_path === false) {
// not chached
if ($category_id > 0) {
$id_field = $this->Application->getUnitOption('c', 'IDField');
$table_name = $this->Application->getUnitOption('c', 'TableName');
- $sql = 'SELECT CachedNavbar
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT '.$ml_formatter->LangFieldName('CachedNavbar').'
FROM '.$table_name.'
WHERE '.$id_field.' = '.$category_id;
- $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).'>'.$this->Conn->GetOne($sql), '>');
+ $category_path = trim($this->CategoryPath( Array('cat_id' => 0) ).' > '.str_replace('|', ' > ', $this->Conn->GetOne($sql)), ' > ');
}
else {
$category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
}
$this->Application->setCache('category_paths', $category_id, $category_path);
}
return $category_path;
}
function PermInputName($params)
{
return $this->Prefix.'['.$this->Application->GetVar('group_id').']['.$this->Application->Parser->GetParam('PermissionName').']['.$params['sub_key'].']';
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8.2.1
\ No newline at end of property
+1.8.2.2
\ No newline at end of property
Event Timeline
Log In to Comment