'.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 = "
";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 = "
";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."