'.print_r($result->GetRows(), true).''; - $result->MoveFirst(); - } - } - //echo "SQL: $sql
"; print_r($CountVal); echo "
'.print_r($result->GetRows(), true).''; + + $result->MoveFirst(); + + } + + } + + //echo "SQL: $sql
"; print_r($CountVal); echo "
- - | -
+ + + + | + +
";print_r($perms); echo ""; - foreach($perms as $PermName => $l) - { - $this->SetViewPerms($PermName,$l,$glist); - } - } - - function Cat_Link() - { - global $m_var_list_update; - - $m_var_list_update["cat"] = $this->Get("CategoryId"); - $ret = GetIndexURL()."?env=".BuildEnv(); - unset($m_var_list_update["cat"]); - return $ret; - } - - function Parent_Link() - { - global $m_var_list_update; - - $m_var_list_update["cat"] = $this->Get("ParentId"); - $ret = GetIndexURL()."?env=".BuildEnv(); - unset($m_var_list_update["cat"]); - return $ret; - } - - function Admin_Parent_Link($page=NULL) - { - global $m_var_list_update; - - if(!strlen($page)) - $page = $_SERVER["PHP_SELF"]; - $m_var_list_update["cat"] = $this->Get("ParentId"); - $ret = $page."?env=".BuildEnv(); - unset($m_var_list_update["cat"]); - return $ret; - } - - function StatusIcon() - { - global $imagesURL; - - $ret = $imagesURL."/itemicons/"; - - switch($this->Get("Status")) - { - case STATUS_DISABLED: - $ret .= "icon16_cat_disabled.gif"; - break; - case STATUS_PENDING: - $ret .= "icon16_cat_pending.gif"; - break; - case STATUS_ACTIVE: - $img = "icon16_cat.gif"; - if($this->IsPopItem()) - $img = "icon16_cat_pop.gif"; - if($this->IsHotItem()) - $img = "icon16_cat_hot.gif"; - if($this->IsNewItem()) - $img = "icon16_cat_new.gif"; - if($this->Is("EditorsPick")) - $img = "icon16_car_pick.gif"; - $ret .= $img; - break; - } - return $ret; - } - - function SubCatCount() - { - $ret = $this->Get("CachedDescendantCatsQty"); - - $sql = "SELECT COUNT(*) as SubCount FROM ".$this->tablename." WHERE ParentPath LIKE '".$this->Get("ParentPath")."%' AND CategoryId !=".$this->Get("CategoryId"); - $rs = $this->adodbConnection->Execute($sql); - if($rs && !$rs->EOF) - { - $val = $rs->fields["SubCount"]; - if($val != $this->Get("CachedDescendantCatsQty")) - { - $this->Set("CachedDescendantCatsQty",$val); - $this->Update(); - } - $ret = $this->Get("CachedDescendantCatsQty"); - } - return $ret; - } - - function GetSubCatIds() - { - $sql = "SELECT CategoryId FROM ".$this->tablename." WHERE ParentPath LIKE '".$this->Get("ParentPath")."%' AND CategoryId !=".$this->Get("CategoryId"); - $rs = $this->adodbConnection->Execute($sql); - $ret = array(); - while($rs && !$rs->EOF) - { - $ret[] = $rs->fields["CategoryId"]; - $rs->MoveNext(); - } - return $ret; - } - - function GetParentIds() - { - $Parents = array(); - $ParentPath = $this->Get("ParentPath"); - if(strlen($ParentPath)) - { - $ParentPath = substr($ParentPath,1,-1); - $Parents = explode("|",$ParentPath); - } - return $Parents; - } - - function ItemCount($ItemType="") - { - global $objItemTypes,$objCatList,$objCountCache; - - if(!is_numeric($ItemType)) - { - $TypeId = $objItemTypes->GetItemTypeValue($ItemType); - } - else - $TypeId = (int)$ItemType; - - //$path = $this->Get("ParentPath"); - //$path = substr($path,1,-1); - //$path = str_replace("|",",",$path); - $path = implode(",",$this->GetSubCatIds()); - if(strlen($path)) - { - $path = $this->Get("CategoryId").",".$path; - } - else - $path = $this->Get("CategoryId"); - - $res = TableCount(GetTablePrefix()."CategoryItems","CategoryId IN ($path)",FALSE); - - return $res; - } - - function ParseObject($element) - { - global $objConfig, $objCatList, $rootURL, $var_list, $var_list_update, $m_var_list_update, $objItemTypes,$objCountCache; - $extra_attribs = ExtraAttributes($element->attributes); - - //print_r($element); - if(strtolower($element->name)==$this->TagPrefix) - { - $field = strtolower( $element->GetAttributeByName('_field') ); - switch($field) - { - case "name": - case "Name": - /* - @field:cat.name - @description:Category name - */ - $ret = $this->HighlightField("Name"); - break; - case "description": - /* - @field:cat.description - @description:Category Description - */ - $ret = ($this->Get("Description")); - $ret = $this->HighlightText($ret); - break; - case "cachednavbar": - /* - @field:cat.cachednavbar - @description: Category cached navbar - */ - $ret = $this->HighlightField("CachedNavbar"); - if(!strlen($ret)) - { - $this->UpdateCachedPath(); - $ret = $this->HighlightField("CachedNavbar"); - } - break; - case "image": - /* - @field:cat.image - @description:Return an image associated with the category - @attrib:_default:bool:If true, will return the default image if the requested image does not exist - @attrib:_name::Return the image with this name - @attrib:_thumbnail:bool:If true, return the thumbnail version of the image - @attrib:_imagetag:bool:If true, returns a complete image tag. exta html attributes are passed to the image tag - */ - $default = $element->GetAttributeByName('_primary'); - $name = $element->GetAttributeByName('_name'); - if(strlen($name)) - { - $img = $this->GetImageByName($name); - } - else - { - if($default) - $img = $this->GetDefaultImage(); - } - if($img) - { - if( $element->GetAttributeByName('_thumbnail') ) - { - $url = $img->parsetag("thumb_url"); - } - else - $url = $img->parsetag("image_url"); - - } - else - { - $url = $element->GetAttributeByName('_defaulturl'); - } - - if( $element->GetAttributeByName('_imagetag') ) - { - if(strlen($url)) - { - $ret = ""; - } - else - $ret = ""; - } - else - $ret = $url; - break; - case "createdby": - /* - @field:cat.createdby - @description:parse a user field of the user that created the category - @attrib:_usertag::User field to return (defaults to login ID) - */ - $field = $element->GetAttributeByName('_usertag'); - if(!strlen($field)) - { - $field = "user_login"; - } - $u = $objUsers->GetUser($this->Get("CreatedById")); - $ret = $u->parsetag($field); - break; - case "custom": - /* - @field:cat.custom - @description:Returns a custom field - @attrib:_customfield::field name to return - @attrib:_default::default value - */ - $field = $element->GetAttributeByName('_customfield'); - $default = $element->GetAttributeByName('_default'); - $ret = $this->GetCustomFieldValue($field,$default); - break; - - case "catsubcats": - /* - @field:cat.catsubcats - @description:Returns a list of subcats of current category - @attrib:_limit:int:Number of categories to return - @attrib:_separator::Separator between categories - @attrib:_anchor:bool:Make an anchor (only if template is not specified) - @attrib:_TargetTemplate:tpl:Target template - @attrib:_Ending::Add special text at the end of subcategory list - @attrib:_Class::Specify stly sheet class for anchors (if used) or "span" object - */ - $limit = ((int)$element->attributes["_limit"]>0)? $element->attributes["_limit"] : NULL; - $separator = $element->attributes["_separator"]; - $anchor = (int)($element->attributes["_anchor"])? 1 : NULL; - $template = strlen($element->attributes["_TargetTemplate"])? $element->attributes["_TargetTemplate"] : NULL; - $ending = strlen($element->attributes["_ending"])? $element->attributes["_ending"] : NULL; - $class = strlen($element->attributes["_class"])? $element->attributes["_class"] : NULL; - - $ret = $this->GetSubCats($limit, $template, $separator, $anchor, $ending, $class); - - break; - - case "date": - /* - @field:cat.date - @description:Returns the date/time the category was created - @attrib:_tz:bool:Convert the date to the user's local time - @attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr - */ - $d = $this->Get("CreatedOn"); - - if( $element->GetAttributeByName('_tz') ) - { - $d = GetLocalTime($d,$objSession->Get("tz")); - } - - $part = strtolower( $element->GetAttributeByName('_part') ); - if(strlen($part)) - { - $ret = ExtractDatePart($part,$d); - } - else - { - if(!is_numeric($d)) - { - $ret = ""; - } - else - $ret = LangDate($d); - } - break; - case "link": - /* - @field:cat.link - @description:Returns a URL setting the category to the current category - @attrib:_template:tpl:Template URL should point to - @attrib:_mod_template:tpl:Template INSIDE a module to which the category belongs URL should point to - */ - if ( strlen( $element->GetAttributeByName('_mod_template') ) ){ - //will prefix the template with module template root path depending on category - $ids = $this->GetParentIds(); - $tpath = GetModuleArray("template"); - $roots = GetModuleArray("rootcat"); - - // get template path of module, by searching for moudle name - // in this categories first parent category - // and then using found moudle name as a key for module template paths array - $path = $tpath[array_search ($ids[0], $roots)]; - $t = $path . $element->GetAttributeByName('_mod_template'); - } - else - $t = $element->GetAttributeByName('_template'); - - - if(strlen($t)) - { - $var_list_update["t"] = $t; - } - else - $var_list_update["t"] = $var_list["t"]; - $m_var_list_update["cat"] = $this->Get("CategoryId"); - $ret = GetIndexURL()."?env=" . BuildEnv(); - unset($m_var_list_update["cat"], $var_list_update["t"]); - break; - case "adminlink": - $m_var_list_update["cat"] = $this->Get("CategoryId"); - $m_var_list_update["p"] = 1; - $ret = $_SERVER["PHP_SELF"]."?env=" . BuildEnv(); - unset($m_var_list_update["cat"]); - unset($m_var_list_update["p"]); - return $ret; - break; - case "customlink": - $t = $this->GetCustomFieldValue("indextemplate",""); - if(strlen($t)) - { - $var_list_update["t"] = $t; - } - else - $var_list_update["t"] = $var_list["t"]; - $m_var_list_update["cat"] = $this->Get("CategoryId"); - $ret = GetIndexURL()."?env=" . BuildEnv(); - unset($m_var_list_update["cat"], $var_list_update["t"]); - break; - case "link_selector": - $m_var_list_update["cat"] = $this->Get("CategoryId"); - $ret = $_SERVER["PHP_SELF"]."?env=" . BuildEnv(); - - // pass through selector - if( isset($_REQUEST['Selector']) ) $ret .= '&Selector='.$_REQUEST['Selector']; - - // pass new status - if( isset($_REQUEST['new']) ) $ret .= '&new='.$_REQUEST['new']; - - unset($m_var_list_update["cat"]); - return $ret; - break; - case "admin_icon": - if( $element->GetAttributeByName('fulltag') ) - { - $ret = "StatusIcon()."\">"; - } - else - $ret = $this->StatusIcon(); - break; - case "subcats": - /* - @field:cat.subcats - @description: Loads category's subcategories into a list and renders using the m_list_cats global tag - @attrib:_subcattemplate:tpl:Template used to render subcategory list elements - @attrib: _columns:int: Numver of columns to display the categories in (defaults to 1) - @attrib: _maxlistcount:int: Maximum number of categories to list - @attrib: _FirstItemTemplate:tpl: Template used for the first category listed - @attrib: _LastItemTemplate:tpl: Template used for the last category listed - @attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag - */ - $attr = array(); - $attr["_catid"] = $this->Get("CategoryId"); - $attr["_itemtemplate"] = $element->GetAttributeByName('_subcattemplate'); - if( $element->GetAttributeByName('_notable') ) - $attr["_notable"]=1; - $ret = m_list_cats($attr); - break; - case "subcatcount": - /* - @field:cat.subcatcount - @description:returns number of subcategories - */ - $GroupOnly = $element->GetAttributeByName('_grouponly') ? 1 : 0; - $txt = "
";print_r($ChildList); echo ""; - echo "Old Parent: $oldparent
";print_r($perms); echo ""; + + foreach($perms as $PermName => $l) + + { + + $this->SetViewPerms($PermName,$l,$glist); + + } + + } + + + + function Cat_Link() + + { + + global $m_var_list_update; + + + + $m_var_list_update["cat"] = $this->Get("CategoryId"); + + $ret = GetIndexURL()."?env=".BuildEnv(); + + unset($m_var_list_update["cat"]); + + return $ret; + + } + + + + function Parent_Link() + + { + + global $m_var_list_update; + + + + $m_var_list_update["cat"] = $this->Get("ParentId"); + + $ret = GetIndexURL()."?env=".BuildEnv(); + + unset($m_var_list_update["cat"]); + + return $ret; + + } + + + + function Admin_Parent_Link($page=NULL) + + { + + global $m_var_list_update; + + + + if(!strlen($page)) + + $page = $_SERVER["PHP_SELF"]; + + $m_var_list_update["cat"] = $this->Get("ParentId"); + + $ret = $page."?env=".BuildEnv(); + + unset($m_var_list_update["cat"]); + + return $ret; + + } + + + + function StatusIcon() + + { + + global $imagesURL; + + + + $ret = $imagesURL."/itemicons/"; + + + + switch($this->Get("Status")) + + { + + case STATUS_DISABLED: + + $ret .= "icon16_cat_disabled.gif"; + + break; + + case STATUS_PENDING: + + $ret .= "icon16_cat_pending.gif"; + + break; + + case STATUS_ACTIVE: + + $img = "icon16_cat.gif"; + + if($this->IsPopItem()) + + $img = "icon16_cat_pop.gif"; + + if($this->IsHotItem()) + + $img = "icon16_cat_hot.gif"; + + if($this->IsNewItem()) + + $img = "icon16_cat_new.gif"; + + if($this->Is("EditorsPick")) + + $img = "icon16_car_pick.gif"; + + $ret .= $img; + + break; + + } + + return $ret; + + } + + + + function SubCatCount() + + { + + $ret = $this->Get("CachedDescendantCatsQty"); + + + + $sql = "SELECT COUNT(*) as SubCount FROM ".$this->tablename." WHERE ParentPath LIKE '".$this->Get("ParentPath")."%' AND CategoryId !=".$this->Get("CategoryId"); + + $rs = $this->adodbConnection->Execute($sql); + + if($rs && !$rs->EOF) + + { + + $val = $rs->fields["SubCount"]; + + if($val != $this->Get("CachedDescendantCatsQty")) + + { + + $this->Set("CachedDescendantCatsQty",$val); + + $this->Update(); + + } + + $ret = $this->Get("CachedDescendantCatsQty"); + + } + + return $ret; + + } + + + + function GetSubCatIds() + + { + + $sql = "SELECT CategoryId FROM ".$this->tablename." WHERE ParentPath LIKE '".$this->Get("ParentPath")."%' AND CategoryId !=".$this->Get("CategoryId"); + + $rs = $this->adodbConnection->Execute($sql); + + $ret = array(); + + while($rs && !$rs->EOF) + + { + + $ret[] = $rs->fields["CategoryId"]; + + $rs->MoveNext(); + + } + + return $ret; + + } + + + + function GetParentIds() + + { + + $Parents = array(); + + $ParentPath = $this->Get("ParentPath"); + + if(strlen($ParentPath)) + + { + + $ParentPath = substr($ParentPath,1,-1); + + $Parents = explode("|",$ParentPath); + + } + + return $Parents; + + } + + + + function ItemCount($ItemType="") + + { + + global $objItemTypes,$objCatList,$objCountCache; + + + + if(!is_numeric($ItemType)) + + { + + $TypeId = $objItemTypes->GetItemTypeValue($ItemType); + + } + + else + + $TypeId = (int)$ItemType; + + + + //$path = $this->Get("ParentPath"); + + //$path = substr($path,1,-1); + + //$path = str_replace("|",",",$path); + + $path = implode(",",$this->GetSubCatIds()); + + if(strlen($path)) + + { + + $path = $this->Get("CategoryId").",".$path; + + } + + else + + $path = $this->Get("CategoryId"); + + + + $res = TableCount(GetTablePrefix()."CategoryItems","CategoryId IN ($path)",FALSE); + + + + return $res; + + } + + + + function ParseObject($element) + + { + + global $objConfig, $objCatList, $rootURL, $var_list, $var_list_update, $m_var_list_update, $objItemTypes,$objCountCache; + + $extra_attribs = ExtraAttributes($element->attributes); + + + + //print_r($element); + + if(strtolower($element->name)==$this->TagPrefix) + + { + + $field = strtolower( $element->GetAttributeByName('_field') ); + + switch($field) + + { + + case "name": + + case "Name": + + /* + + @field:cat.name + + @description:Category name + + */ + + $ret = $this->HighlightField("Name"); + + break; + + case "description": + + /* + + @field:cat.description + + @description:Category Description + + */ + + $ret = ($this->Get("Description")); + + $ret = $this->HighlightText($ret); + + break; + + case "cachednavbar": + + /* + + @field:cat.cachednavbar + + @description: Category cached navbar + + */ + + $ret = $this->HighlightField("CachedNavbar"); + + if(!strlen($ret)) + + { + + $this->UpdateCachedPath(); + + $ret = $this->HighlightField("CachedNavbar"); + + } + + break; + + case "image": + + /* + + @field:cat.image + + @description:Return an image associated with the category + + @attrib:_default:bool:If true, will return the default image if the requested image does not exist + + @attrib:_name::Return the image with this name + + @attrib:_thumbnail:bool:If true, return the thumbnail version of the image + + @attrib:_imagetag:bool:If true, returns a complete image tag. exta html attributes are passed to the image tag + + */ + + $default = $element->GetAttributeByName('_primary'); + + $name = $element->GetAttributeByName('_name'); + + if(strlen($name)) + + { + + $img = $this->GetImageByName($name); + + } + + else + + { + + if($default) + + $img = $this->GetDefaultImage(); + + } + + if($img) + + { + + if( $element->GetAttributeByName('_thumbnail') ) + + { + + $url = $img->parsetag("thumb_url"); + + } + + else + + $url = $img->parsetag("image_url"); + + + + } + + else + + { + + $url = $element->GetAttributeByName('_defaulturl'); + + } + + + + if( $element->GetAttributeByName('_imagetag') ) + + { + + if(strlen($url)) + + { + + $ret = ""; + + } + + else + + $ret = ""; + + } + + else + + $ret = $url; + + break; + + case "createdby": + + /* + + @field:cat.createdby + + @description:parse a user field of the user that created the category + + @attrib:_usertag::User field to return (defaults to login ID) + + */ + + $field = $element->GetAttributeByName('_usertag'); + + if(!strlen($field)) + + { + + $field = "user_login"; + + } + + $u = $objUsers->GetUser($this->Get("CreatedById")); + + $ret = $u->parsetag($field); + + break; + + case "custom": + + /* + + @field:cat.custom + + @description:Returns a custom field + + @attrib:_customfield::field name to return + + @attrib:_default::default value + + */ + + $field = $element->GetAttributeByName('_customfield'); + + $default = $element->GetAttributeByName('_default'); + + $ret = $this->GetCustomFieldValue($field,$default); + + break; + + + + case "catsubcats": + + /* + + @field:cat.catsubcats + + @description:Returns a list of subcats of current category + + @attrib:_limit:int:Number of categories to return + + @attrib:_separator::Separator between categories + + @attrib:_anchor:bool:Make an anchor (only if template is not specified) + + @attrib:_TargetTemplate:tpl:Target template + + @attrib:_Ending::Add special text at the end of subcategory list + + @attrib:_Class::Specify stly sheet class for anchors (if used) or "span" object + + */ + + $limit = ((int)$element->attributes["_limit"]>0)? $element->attributes["_limit"] : NULL; + + $separator = $element->attributes["_separator"]; + + $anchor = (int)($element->attributes["_anchor"])? 1 : NULL; + + $template = strlen($element->attributes["_TargetTemplate"])? $element->attributes["_TargetTemplate"] : NULL; + + $ending = strlen($element->attributes["_ending"])? $element->attributes["_ending"] : NULL; + + $class = strlen($element->attributes["_class"])? $element->attributes["_class"] : NULL; + + + + $ret = $this->GetSubCats($limit, $template, $separator, $anchor, $ending, $class); + + + + break; + + + + case "date": + + /* + + @field:cat.date + + @description:Returns the date/time the category was created + + @attrib:_tz:bool:Convert the date to the user's local time + + @attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr + + */ + + $d = $this->Get("CreatedOn"); + + + + if( $element->GetAttributeByName('_tz') ) + + { + + $d = GetLocalTime($d,$objSession->Get("tz")); + + } + + + + $part = strtolower( $element->GetAttributeByName('_part') ); + + if(strlen($part)) + + { + + $ret = ExtractDatePart($part,$d); + + } + + else + + { + + if(!is_numeric($d)) + + { + + $ret = ""; + + } + + else + + $ret = LangDate($d); + + } + + break; + + case "link": + + /* + + @field:cat.link + + @description:Returns a URL setting the category to the current category + + @attrib:_template:tpl:Template URL should point to + + @attrib:_mod_template:tpl:Template INSIDE a module to which the category belongs URL should point to + + */ + + if ( strlen( $element->GetAttributeByName('_mod_template') ) ){ + + //will prefix the template with module template root path depending on category + + $ids = $this->GetParentIds(); + + $tpath = GetModuleArray("template"); + + $roots = GetModuleArray("rootcat"); + + + + // get template path of module, by searching for moudle name + + // in this categories first parent category + + // and then using found moudle name as a key for module template paths array + + $path = $tpath[array_search ($ids[0], $roots)]; + + $t = $path . $element->GetAttributeByName('_mod_template'); + + } + + else + + $t = $element->GetAttributeByName('_template'); + + + + + + if(strlen($t)) + + { + + $var_list_update["t"] = $t; + + } + + else + + $var_list_update["t"] = $var_list["t"]; + + $m_var_list_update["cat"] = $this->Get("CategoryId"); + + $ret = GetIndexURL()."?env=" . BuildEnv(); + + unset($m_var_list_update["cat"], $var_list_update["t"]); + + break; + + case "adminlink": + + $m_var_list_update["cat"] = $this->Get("CategoryId"); + + $m_var_list_update["p"] = 1; + + $ret = $_SERVER["PHP_SELF"]."?env=" . BuildEnv(); + + unset($m_var_list_update["cat"]); + + unset($m_var_list_update["p"]); + + return $ret; + + break; + + case "customlink": + + $t = $this->GetCustomFieldValue("indextemplate",""); + + if(strlen($t)) + + { + + $var_list_update["t"] = $t; + + } + + else + + $var_list_update["t"] = $var_list["t"]; + + $m_var_list_update["cat"] = $this->Get("CategoryId"); + + $ret = GetIndexURL()."?env=" . BuildEnv(); + + unset($m_var_list_update["cat"], $var_list_update["t"]); + + break; + + case "link_selector": + + $m_var_list_update["cat"] = $this->Get("CategoryId"); + + $ret = $_SERVER["PHP_SELF"]."?env=" . BuildEnv(); + + + + // pass through selector + + if( isset($_REQUEST['Selector']) ) $ret .= '&Selector='.$_REQUEST['Selector']; + + + + // pass new status + + if( isset($_REQUEST['new']) ) $ret .= '&new='.$_REQUEST['new']; + + + + unset($m_var_list_update["cat"]); + + return $ret; + + break; + + case "admin_icon": + + if( $element->GetAttributeByName('fulltag') ) + + { + + $ret = "StatusIcon()."\">"; + + } + + else + + $ret = $this->StatusIcon(); + + break; + + case "subcats": + + /* + + @field:cat.subcats + + @description: Loads category's subcategories into a list and renders using the m_list_cats global tag + + @attrib:_subcattemplate:tpl:Template used to render subcategory list elements + + @attrib: _columns:int: Numver of columns to display the categories in (defaults to 1) + + @attrib: _maxlistcount:int: Maximum number of categories to list + + @attrib: _FirstItemTemplate:tpl: Template used for the first category listed + + @attrib: _LastItemTemplate:tpl: Template used for the last category listed + + @attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag + + */ + + $attr = array(); + + $attr["_catid"] = $this->Get("CategoryId"); + + $attr["_itemtemplate"] = $element->GetAttributeByName('_subcattemplate'); + + if( $element->GetAttributeByName('_notable') ) + + $attr["_notable"]=1; + + $ret = m_list_cats($attr); + + break; + + case "subcatcount": + + /* + + @field:cat.subcatcount + + @description:returns number of subcategories + + */ + + $GroupOnly = $element->GetAttributeByName('_grouponly') ? 1 : 0; + + $txt = "
";print_r($ChildList); echo ""; + + echo "Old Parent: $oldparent
- - | -
+ + + + | + +
";print_r($s); echo ""; - $txt = implode("+",$s); - //echo $txt."
";print_r($ifs); echo ""; - - /* add relevance formula for weighting hits & popularity */ - - if($weightsum==0) - $weightsum=1; - - if(strlen($PopField)>0 && $this->PctPop>0) - { - $popcalc = " + ((($PopField + 1) / (max($PopField)+1)*".$this->PctPop."))"; - } - else - $popcalc = ""; - - if(strlen($RateField)>0 && $this->PctRating>0) - { - $ratecalc = " + ((($RateField + 1) / (max($RateField)+1)*".$this->PctRating."))"; - } - else - $ratecalc = ""; - - if($this->PctRelevance>0) - { - $relcalc = "(((".implode("+",$ifs).")/$weightsum)*".$this->PctRelevance.")"; - } - else - $relcalc = "0"; - - $SelectSQL .= $relcalc.$popcalc.$ratecalc." as Relevance, "; - - $SelectSQL .= $this->SourceTable.".".$idField." as ItemId, ".$this->SourceTable.".ResourceId as ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." "; - - foreach($this->Relationships as $JoinTable=>$OnClause) - { - $SelectSQL .= "LEFT JOIN $JoinTable ON $OnClause "; - } - $first=1; - $where=0; - - foreach($this->FieldList as $field) - { - if(strpos($field,"as")>0) - { - $fparts = explode("as",$field,2); - $f = $fparts[1]; - $this->AddSearchWhereClause($field); - } - else { - $this->AddSearchWhereClause($field); - } - } - - $SelectSQL .= " WHERE "; - $SelectSQL .= implode(" or ",$this->WhereClauses); - - if(is_array($idlist)) - { - $SelectSQL .= " AND (ResourceId IN (".implode(",",$idlist)."))"; - } - } - $SelectSQL .= "GROUP BY $idField "; - //echo $SelectSQL."
";print_r($s); echo ""; + + $txt = implode("+",$s); + + //echo $txt."
";print_r($ifs); echo ""; + + + + /* add relevance formula for weighting hits & popularity */ + + + + if($weightsum==0) + + $weightsum=1; + + + + if(strlen($PopField)>0 && $this->PctPop>0) + + { + + $popcalc = " + ((($PopField + 1) / (max($PopField)+1)*".$this->PctPop."))"; + + } + + else + + $popcalc = ""; + + + + if(strlen($RateField)>0 && $this->PctRating>0) + + { + + $ratecalc = " + ((($RateField + 1) / (max($RateField)+1)*".$this->PctRating."))"; + + } + + else + + $ratecalc = ""; + + + + if($this->PctRelevance>0) + + { + + $relcalc = "(((".implode("+",$ifs).")/$weightsum)*".$this->PctRelevance.")"; + + } + + else + + $relcalc = "0"; + + + + $SelectSQL .= $relcalc.$popcalc.$ratecalc." as Relevance, "; + + + + $SelectSQL .= $this->SourceTable.".".$idField." as ItemId, ".$this->SourceTable.".ResourceId as ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." "; + + + + foreach($this->Relationships as $JoinTable=>$OnClause) + + { + + $SelectSQL .= "LEFT JOIN $JoinTable ON $OnClause "; + + } + + $first=1; + + $where=0; + + + + foreach($this->FieldList as $field) + + { + + if(strpos($field,"as")>0) + + { + + $fparts = explode("as",$field,2); + + $f = $fparts[1]; + + $this->AddSearchWhereClause($field); + + } + + else { + + $this->AddSearchWhereClause($field); + + } + + } + + + + $SelectSQL .= " WHERE "; + + $SelectSQL .= implode(" or ",$this->WhereClauses); + + + + if(is_array($idlist)) + + { + + $SelectSQL .= " AND (ResourceId IN (".implode(",",$idlist)."))"; + + } + + } + + $SelectSQL .= "GROUP BY $idField "; + + //echo $SelectSQL."