/* Name: Business logic Encapsulation for classification operations
*
* Author: Handsome like scum qq:1191391 e-mail:netcat2@21cn.com
*
* Completion Date: 2003-12-18 13:33
*
* Description: The other classes referenced in this class (DB, Table, Item) are not provided, so this class can only do a reference, can not directly apply the
* is not my stingy do not provide other classes, it is because those are a year or two ago written class, very rotten. I'm afraid everyone will look after the big
* leads to misleading. This class is published here, only hope that you can learn some programming methods.
* teach people to fish than to teach people to fishing ~
*
* Features:
* Using recursive method, only one database query can be used to classify data to generate a tree-like structure. Infinite recursive hierarchy (depending on the machine stack)
*
* Database definition:
* ID smallint unsigned primary #如果数据量很大可用int
* parentid smallint unsigned index #如果数据量很大可用int, click this field
* #如果为根分类, then ParentID = 0
*
* rootid smallint unsigned index #如果数据量很大可用int, click this field
* If there is any other field definition attached to the back
* Precautions:
* Do not attempt to call this class directly unless you have an interface that corresponds to the other classes that I define, otherwise it will not succeed
* Define dbtable_category This constant in the appropriate place to point to your categorical data table name
*
* Program framework:
*├─ Basic Class <!--complete operation of underlying database operations, data abstraction, language, templates, exceptions, miscellaneous, etc.-->
*│
*│
*└─ business Logic Layer (hierarchy of this class) <!--use classes such as data manipulation, data abstraction, and so on, to complete data processing according to the parameters passed by the presentation layer and return data or operational results-->
*│
*│
*└─── Presentation layer (user interface) <!--Use the business logic layer to display the results of data or operational data obtained through classes such as interfaces in the underlying class-->
*/
define (' dbtable_category ', ' xxx ');
class Category_logic
{
var $KernelRef = NULL; Reference to the core of the system
var $tblObj = NULL; Contains an instance of the current categorical data Table class
var $_currentitem = NULL; Contains an instance of the current classification data TItem class
var $CategoryID = 0; Current Category ID, if there is no current category this item is 0
//private array getnodedata (array $Data, int $ParentNode)
///The ID of the tree and the current category based on a given root and the sibling parent method, which returns the position of the current category in the entire taxonomy
//
//@param: $Data 2-D array of arrays (
//Array (
//' ID ' => category ID,
//' ParentID ' => parent category ID,
//' Rootid ' => root category ID,
//' CategoryName ' => category name,
// ),
// ......
// );
//represented by a tree
//
//@param: $ParentNode The parent classification ID, which is given by the caller each time, and is passed by the program at recursion
//
//Return value: Returns the tree
of all categories as expressed in sibling parental law
//Note: Make sure the current classification is set, otherwise this function does not return
///The ID of the tree and the current category based on a given root and the sibling parent method, which returns the position of the current category in the entire taxonomy
//
//@param: A tree that is represented by the $Data sibling parent law, passed by the caller
//
//@param: $Current The current classification ID, given by the caller on the first call, and calculated recursively by the program
//
@param: $ProcessFunc Specify the processing function for the categorical data, the definition of the function prototype
the annotation in the->printcurrentlevel $this
//
//Return value: Returns the position of the current category in the classification tree
//Note: Make sure the current classification is set, otherwise this function does not return
//Returns a list of the entire taxonomy's tree structure placed in optionlist
//
//@param: $Data This parameter is returned by $this->dumptypedatatotree ()
//
//@param: $ProcessFunc handles the callback function that displays the classification information, the function prototype please refer to: $this->printcurrentlevel ()
//
//@param: $floor This parameter can not be artificially given, is the program automatic calculation of the median
//
//return value:
//structure a tree
of the representation of a sibling's parents
//Returns a list of the entire taxonomy's tree structure placed in optionlist
//
//@param: $Data This parameter is returned by $this->dumptypedatatotree ()
//
//@param: $ProcessFunc handles the callback function that displays the classification information, the function prototype please refer to: $this->printcurrentlevel ()
//
//@param: $floor This parameter can not be artificially given, is the program automatic calculation of the median
//
//Return value: Returns a <option> category name 1</option> ... <option> category name N</option>
//Returns the tree-structured view of the entire category
//
//@param: $Data This parameter is returned by $this->dumptypedatatotree ()
//
//@param: $ProcessFunc handles the callback function that displays the classification information, the function prototype please refer to: $this->printcurrentlevel ()
//
//Return value: Returns the generated HTML form of the tree
//Generate current position string for multilevel classification
//Set such as the classification data below, the current classification is 3 level classification, then call returns 1 level classification-> 2 class-> 3 classification
//├──1 Level Classification
//│
//│
//│
//├─2 Level Classification
//││
//│└─3 Level Classification
//│
//└─2 Level Classification
//
//
//
//
@param: $ProcessFunc This is the callback function for how the sorted data is displayed and the category name is displayed directly without setting
//function defines the prototype as a function (& $arr);
//Where the $arr parameter is a one-dimensional array of each of the classification information is as follows:
The
//return value is the result of the above data processing, such as returning the categorized name with the link, changing the display color, and so on
//
//Return value: Returns the position of the current category in the entire classification tree
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.