Index: trunk/kernel/include/category.php
===================================================================
diff -u -N -r4446 -r5254
--- trunk/kernel/include/category.php (.../category.php) (revision 4446)
+++ trunk/kernel/include/category.php (.../category.php) (revision 5254)
@@ -9,11 +9,18 @@
class clsCategory extends clsItem
{
var $Permissions;
+
+ var $DescriptionField = '';
+
function clsCategory($CategoryId=NULL)
{
global $objSession;
$this->clsItem(TRUE);
-
+
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $this->TitleField = $ml_formatter->LangFieldName('Name');
+ $this->DescriptionField = $ml_formatter->LangFieldName('Description');
+
$this->tablename = GetTablePrefix()."Category";
$this->type=1;
$this->BasePermission ="CATEGORY";
@@ -93,7 +100,7 @@
}
else
{
- $name = $this->Get('Name');
+ $name = $this->Get($this->TitleField);
}
$name = $this->StripDisallowed($name);
@@ -229,7 +236,10 @@
{
global $m_var_list, $m_var_list_update, $var_list, $var_list_update;
- $sql = "SELECT CategoryId, Name from ".GetTablePrefix()."Category where ParentId=".$this->Get("CategoryId")." AND Status=1 ORDER BY Priority";
+ $sql = " SELECT CategoryId, ".$this->TitleField."
+ FROM ".GetTablePrefix()."Category
+ WHERE ParentId=".$this->Get("CategoryId")." AND Status=1
+ ORDER BY Priority";
if(isset($limit))
{
$rs = $this->adodbConnection->SelectLimit($sql, $limit, 0);
@@ -248,7 +258,7 @@
$var_list_update["t"] = !is_null($target_template)? $target_template : $var_list["t"];
$m_var_list_update["cat"] = $rs->fields["CategoryId"];
$m_var_list_update["p"] = "1";
- $cat_name = $rs->fields['Name'];
+ $cat_name = $rs->fields[$this->TitleField];
if (!is_null($anchor))
$ret .= "$cat_name";
else
@@ -318,9 +328,9 @@
$item_template = '';
do {
- $rs = $this->adodbConnection->Execute('SELECT ParentId, Name, Filename, CachedCategoryTemplate, CachedItemTemplate FROM '.$this->tablename.' WHERE CategoryId = '.$Id2);
+ $rs = $this->adodbConnection->Execute('SELECT ParentId, '.$this->TitleField.', Filename, CachedCategoryTemplate, CachedItemTemplate FROM '.$this->tablename.' WHERE CategoryId = '.$Id2);
$path_parts[] = $Id2;
- $nav_parts[] = $rs->fields['Name'];
+ $nav_parts[] = $rs->fields[$this->TitleField];
$named_parts[] = $rs->fields['Filename'];
if (!$cateogry_template && $rs->fields['CachedCategoryTemplate']) {
@@ -865,14 +875,14 @@
@field:cat.name
@description:Category name
*/
- $ret = $this->HighlightField("Name");
+ $ret = $this->HighlightField($this->TitleField);
break;
case "description":
/*
@field:cat.description
@description:Category Description
*/
- $ret = ($this->Get("Description"));
+ $ret = ($this->Get($this->DescriptionField));
$ret = $this->HighlightText($ret);
break;
case "cachednavbar":
@@ -1353,10 +1363,10 @@
return $this->Get("CachedNavbar");
break;
case "cat_name":
- return $this->Get("Name");
+ return $this->Get($this->TitleField);
break;
case "cat_desc":
- return $this->Get("Description");
+ return $this->Get($this->DescriptionField);
break;
case "cat_priority":
if($this->Get("Priority")!=0)
@@ -1374,7 +1384,7 @@
return $this->Get("Status");
break;
case "cat_Pending":
- return $this->Get("Name");
+ return $this->Get($this->TitleField);
break;
case "cat_pop":
@@ -1481,8 +1491,8 @@
$cat =& $objCatList->GetCategory($catid);
if(is_object($cat))
{
- if(strlen($cat->Get("Name")))
- $names[] = $cat->Get("Name");
+ if(strlen($cat->Get($this->TitleField)))
+ $names[] = $cat->Get($this->TitleField);
}
}
@@ -1534,13 +1544,20 @@
//var $Page; // no need because clsItemList class used instead of clsItemCollection
//var $PerPageVar;
+ var $TitleField = '';
+ var $DescriptionField = '';
+
function clsCatList()
{
global $m_var_list;
$this->clsItemCollection();
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $this->TitleField = $ml_formatter->LangFieldName('Name');
+ $this->DescriptionField = $ml_formatter->LangFieldName('Description');
+
$this->Prefix = 'c';
$this->classname="clsCategory";
- $this->AdminSearchFields = array("Name","Description");
+ $this->AdminSearchFields = array($this->TitleField, $this->DescriptionField);
$this->Page = (int)$m_var_list["p"];
$this->PerPageVar = "Perpage_Category";
$this->SourceTable = GetTablePrefix()."Category";
@@ -1975,7 +1992,7 @@
$r =& $this->GetCategory($root);
$rpath = $r->Get("ParentPath");
$nav_unparsed = substr($nav_unparsed,strlen($rpath),-1);
- $cat_name = $r->Get("Name");
+ $cat_name = $r->Get($this->TitleField);
$m_var_list_update["cat"] = $root;
if($cat == $catid && !$LinkLeaf)
{
@@ -2041,7 +2058,7 @@
$c =& $this->GetCategory($catid);
if(is_object($c))
{
- $cat_name = $c->Get("Name");
+ $cat_name = $c->Get($this->TitleField);
$m_var_list_update["cat"] = $catid;
if($catid==$modcat && strlen($ModTemplate)>0)
@@ -2127,7 +2144,7 @@
if( $d->UsingTempTable() ) $d->Set('CategoryId', -1);
$d->idfield = 'CategoryId';
- $d->Set(Array( 'ParentId', 'Name', 'Description', 'CreatedOn', 'EditorsPick', 'Status', 'HotItem',
+ $d->Set(Array( 'ParentId', $this->TitleField, $this->DescriptionField, 'CreatedOn', 'EditorsPick', 'Status', 'HotItem',
'NewItem','PopItem', 'Priority', 'MetaKeywords', 'MetaDescription', 'CreatedById',
'AutomaticFilename', 'Filename'),
Array( $ParentId, $Name, $Description, $CreatedOn, $EditorsPick, $Status, $Hot, $New,
@@ -2241,7 +2258,7 @@
$dest->Set("ParentId", $ParentTo);
if ($src->get("ParentId") == $ParentTo)
{
- $OldName = $src->Get("Name");
+ $OldName = $src->Get($this->TitleField);
if(substr($OldName,0,5)=="Copy ")
{
$parts = explode(" ",$OldName,4);
@@ -2260,7 +2277,7 @@
else
$Name = $OldName;
//echo "New Name: $Name
";
- $dest->Set("Name", $Name);
+ $dest->Set($this->TitleField, $Name);
$Names = CategoryNameCount($ParentTo,$Name);
//echo "Names Count: ".count($Names)."
";
if(count($Names)>0)
@@ -2294,7 +2311,7 @@
$NewName = "Copy $NameCount of $Name";
}
//echo "New Name: $NewName
";
- $dest->Set("Name",$NewName);
+ $dest->Set($this->TitleField, $NewName);
}
}
@@ -2372,7 +2389,7 @@
$filter = $$cat_filter;
$adodbConnection = &GetADODBConnection();
- $sql = "SELECT COUNT(Name) as children from ".$this->SourceTable." where ParentId=" . $ParentID . $filter;
+ $sql = "SELECT COUNT(*) as children from ".$this->SourceTable." where ParentId=" . $ParentID . $filter;
$result = $adodbConnection->Execute($sql);
return $result->fields["children"];
}