Novice beginner design, hope that we have a lot of guidance and help to achieve. Thanks, _php.

Source: Internet
Author: User
Write the comparative norms, clear thinking. I hope we all---nagging
================================================


Classification Management (Incomplete Design-Overview) (1)
Qzhl Posted in 2002-3-13 17:57 PHP programming ← Back to Layout

Class.id//Category number unique
CLASS.CLASSSTR//categorical string = parent categorical string + "," + Parent ID used to select all sub-categories
Class.parentid//Parent ID can be used in the above fields to get not necessarily implemented


Function Module Description:

AddClass//Add Category
Entrance:
[ParentID]//Parent class number
Class name
[Other fields]//non-mandatory fields
Export:
ListClass//Output classification according to the stencil style
Entrance:
< $rootId >//To display the ID of the root node of the taxonomy displays all Rootid child nodes
[$tree]//whether all expand
The default template variable is used to determine the template
Modiclass//Modify individual classified information
Entrance:

<必要的字段>
[Optional Fields]
Modiclassform
Entrance
[$id]//category number
Export
Each field value is sent to Modiclass
Delclass//Delete classification does not allow deletion if it contains sub-classifications
Entrance:
< $id >



Classification Management (incomplete design-data structure) (2)

Classification table

CREATE TABLE Class (
CLASSSTR varchar (TEN) not NULL default ' 0 ', categorical string *
ParentID Int (one) default ' 0 ', parent class number
ID Int (one) not NULL default ' 0 ', class number *//auto-Grow
Logo varchar (+) default NULL, icon
Name varchar () not NULL default ', class name *
Description varchar (+) Default ' Welcome ', description
Disporder Int (one) default NULL, display order
MasterID Int (one) default NULL, administrator number
Mastername varchar (default) NULL, administrator name
[The name of the speaker can be expanded here to be used in the management of statements]
Childnum Int (one) default NULL, number of child nodes
Moditime datetime default NULL, Last modified time
Unique KEY ID (ID) Classification number only
) Type=myisam;

List of speakers

CREATE TABLE msg (
Bid int (one) not NULL default ' 0 ', class number
ID Int (one) not NULL default ' 0 ', ordinal in category
Topic varchar (+) not NULL default ', theme
Context text, Content
Author varchar () not NULL default ', author
Email varchar (+) default ', email
wdate datetime not NULL default ' 0000-00-00 00:00:00 ',
Speaking time
Levelnum tinyint (3) unsigned not NULL default ' 0 ',
Reply level
OrderID float not NULL default ' 0 ' sort number
) Type=myisam;


Classification Management (Incomplete design-add categories) (3)

Function:

Add Category (AddClass)
0. Function Description:


1 Interface Parameters

1.1 Entrance

[ParentID]//Parent class number

Class name
[Other fields]//non-mandatory fields

1.2 Export

[ErrNo]//error code with include send to error display function (language-sensitive)

2 Variable Declaration

var ParentID;
var classstr;

3 Function implementation

if (empty ($name)) {
ErrNo = N;
Include_once (Error function page); Error page output error according to language and return (see Func.txt)
}
if (empty ($parentId)):

$parentId = 0;//default is 0 This sentence does not need to write
ID set to Auto grow
INSERT into Class (classstr,parentid,name,[other fields]) VALUES (0,0, $name, [other fields]);

if (!empty ($parentId)):
SELECT @classStr: =concat (Classstr, ', ', id) from class WHERE id= $parentId; CONCAT Connection string
INSERT into Class (classstr,parentid,name,[other fields]) VALUES (@classStr, $parentId, $name, [other fields]);


Classification Management (Incomplete design-rights Management) (4)

Rights Management
Chkpower function
0 feature Brief
According to the management mode to determine whether the current user can pass this module.
1 Interface Parameters
1.1 Entrance
Session (user[' ID ')
< $id >/ID of the category that requires permission to be judged
Session (user[' power ')//user[' power '] = ' id,id,id '
1.2 Export
ErrNo//No permissions
user[' power ']. = ', id '//authentication passed
2 implementation

Determine if the ID is in session (user[' power ')
Yes: by
No: Management mode 0:
SELECT @classStr: =classstr from class WHERE id = $id
Determines whether the classification string for the current class contains user[id] any one of the categories managed by means of the current classification is sub-classification
SELECT <任何字段> From class WHERE @classStr like CONCAT ('% ', id, '% ') and MasterID = Session (User[id])
Passed if the recordset returned is not empty.
and user[' power ']. = $id;
Management Mode 1:
Determines whether the current user is passed in the current class administrator list.
SELECT <任何字段> From class WHERE MasterID like CONCAT ('% ', user[' id '], '% ') and id = $id
If not passed:
ErrNo = n;
Include (error.php)


Classification Management (incomplete design-show categories) (5)

Show Categories (ListClass)

0 Function Description

1 Interface Parameters

1.1 Entrance

$rootId to display the ID of the root node of the taxonomy displays all Rootid child nodes
Whether $tree all expanded
Default Template variables
1.2 Export
Errno

2 Variable Declaration

var $result; Record set
var $nodeNum; Number of nodes
var $allNodeArray; All node arrays
var $html; Template variables

3 function declarations

function GetResult (rootid,tree)
Get a set of required records
function PAllNode1 (level,rootnodeid,nodearray[][])
Traversal function level represents the output hierarchy Nodearray recordset array
function Buildtree (Black,currentnode)
Output function call template class Call template Assignment template variable append block get tree structure

4 function implementation
Connecting to a database
$result = GetResult ($rootId, $tree);
$nodeNum = mysql_num_rows ($result);
$allNodeArray = Array (nodenum);
$html = new Template ();
Put the recordset into a two-dimensional array. Put the parent ID into the first element of the array
for (i=0;i <>
$allNodeArray [i] = mysql_fetch_array ($result);
}
Close the database
$html->set_file (' ListClass ', ' listclass.tpl ');
$html->set_block (' listclass ', ' node ', ' nodes ');

PAllNode1 (0,n, $allNodeArray);

$html->pparse (' Out ', ' listclass ');

/*********** function **********************************************/

Get a set of required records
function GetResult (rootid,tree) {
Parameter description:
Rootid to display the ID of the root node of the taxonomy displays all Rootid child nodes
Whether the tree is all expanded

if (empty ($rootId)) $rootId = 0;

if (tree=false) {//Only one layer is listed
strSQL =
SELECT @classStr: =classstr from class WHERE id= $rootId;
SELECT name,classstr,[other fields] from class
WHERE classstr like CONCAT (@classStr, ', ', '% ') and classstr don't like CONCAT (@classStr, ', ', '%,% ');
}
if (tree=true) {//List whole tree
strSQL =
SELECT @classStr: =classstr from class WHERE id= $rootId;
SELECT name,classstr,[other fields] from class
WHERE classstr like CONCAT (@classStr, ', ', '% ')
}
Return Mysql_quary (strSQL);
}

Traversal function level represents the output hierarchy Nodearray recordset array

function Pallnode (Level,rootnodeid,nodearray) {
If the parent ID of the current node equals the node ID
while (current (Nodearray) [0]==rootnodeid) {
Output current node
Recursive invocation, current (Nodearray) [1] means: ID of node, array unchanged
Pallnode (Level+1,current (Nodearray) [1],nodearray];
Next (Nodearray);
}
}

Traversal function 1
function PAllNode1 (level,rootnodeid,nodearray[][]) {
i=0;
Elements for storing this layer
Tmparr = Array ();
Search all elements from an array to generate the first layer of elements
while (list ($k, $v) =each (Nodearray)) {
If the parent ID of the element is nodearray[][0] or $v [0]==rootnodeid
if ($v [0]==rootnodeid) {
Generates a new array that contains only the first-level elements, that is, the parent node is Rootnodeid
Tmparr[i]= $v [0];
Delete selected elements from the original array
Unset (nodearray[$k]);
The subscript of the new array plus a
i++;
}
}
while (list ($k, $v) =each (Tmparr)) {
Generate indentation
for (i=0;i
Establish current node
Buildtree ($str, $v [2]);
At this point the array nodearray has removed elements from the first layer
PAllNode1 (level+1, $v [1],nodearray);
}
}

Output function call template class Call template Assignment template variable append block get tree structure
Replacing templates for all required variables generates two types of pages (only the tree structure of the class name, with a list of detailed information)
Black-generated indent spaces
function Buildtree (black,currentnode) {
Set_var (' link ', currentnode[1]);
Set_var (' name ', currentnode[2]);
Set_var (' Black ', black):
Parse (' Nodes ', ' Row ', ture);
}
Block structure

{Black Indent space} {Name} [Other content that needs to be output]


/*******************************************************************/



Classification Management (Incomplete design-modified categories) (6)

Modify classification Information (Modiclass)
0. Implementation brief:


1 Interface Parameters

1.1 Entrance

<必要的字段>
[Optional Fields]

1.2 Export

[ErrNo]

2 Variable Declaration


3 Function implementation
if ( <必要字段> Not present) ErrNo = n include (Error handling function)

Update data where id = $id;



Classification Management (Incomplete design-Modify form) (7)

Modify Form (Modiclassform)
0. Implementation brief:


1 Interface Parameters

1.1 Entrance

[$id]//category number

1.2 Export
Each field value is sent to Modiclass

2 Variable Declaration


3 Function implementation

According to the $ID query the database to get the corresponding information
Call the Modify Class form template to replace the corresponding form element values with the found data.
Output to the user.
The user is modified and submitted to the Modiclass function.


Classification Management (Incomplete design-traversal function) (8)

function Pallnode ($level, $rootNodeId, $nodeArray) {
Reset ($nodeArray);
$i = 0;
Elements for storing this layer
$TMPARR = Array ();
Search all elements from an array to generate the first layer of elements
while (list ($k, $v) =each ($nodeArray)) {
If the parent ID of the element is nodearray[][0] or $v [0]==rootnodeid
if ($v [0]== $rootNodeId) {
Generates a new array that contains only the first-level elements, that is, the parent node is Rootnodeid
$TMPARR [$i]= $v;
Delete selected elements from the original array
Unset ($nodeArray [$k]);
The subscript of the new array plus a
$i + +;
}
}
Reset ($TMPARR);
Generate indentation
for ($j =0; $j < $level; $j + +) $str. = "";
while (list ($k, $v) =each ($TMPARR)) {
Output current node
Print ($str. $v [1]. $v [2]. "
");
At this point the array nodearray has removed elements from the first layer
Pallnode ($level +1, $v [1], $nodeArray);
}
}

$tt = Array (
Array (0,1, "B"),
Array (0,2, "B"),
Array (1,3, "B"),
Array (1,4, "B"),
Array (0,5, "B"),
Array (2,6, "B"),
Array (6,7, "B")
);
Pallnode (0,0, $TT);

?>


Classification Management (Incomplete design-configuration files) (9)

Configuration file Description:
/* Local information content that needs to be initialized when installing *************************************/
Catalog information for classification management
Global $PATH _info;
$PATH _info = Array ();
Database configuration information
Global $DB _info;
$DB _info = Array ();
/********************************************************************/
/* Template settings available to add *************************************************/
Template style Additions
Global $TPL _type;
$TPL _type = Array (
' Manage ' = ',
' User ' = '
);
Language additions
Global $LANGUAGE;
$LANGUAGE = Array ();
/********************************************************************/
To define a program run-time message that consists of two languages
Global $RUNTIME _msg;
$RUNTIME _msg = Array (
' cannot_is_null ' = = Array (' cannot be empty ', ' e cannot be null '),
' submit_success ' = = Array (' Submit success ', ' E commit succeeded ')
);
Interface Default configuration
Global $MSGBD _conf;
$MSGBD _conf = Array (
' Tpltype ' = $TPL _type[0],//default template style settings
' Language ' = $LANGUAGE [0]//default language settings
);
Default management mode
Global $MANAGE _model; 0, Inheritance tree Management, 1, Administrator judgment Management
?>
  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.