📄 02-files.sgml
字号:
<!-- $Id: 02-files.sgml,v 1.1.1.1 2000/04/17 16:39:58 kk Exp $ --><sect1>Files, classes and functions<p>PHPLIB contains a set of core classes and functions that offersession tracking, per-session and per-user persistent variables,user authentication and permission checking. Building upon thiscore functionality, PHPLIB offers a set of commonly needed"background" classes and a set of "HTML widgets", classes thatallow you to quickly generate HTML based user interfaces.All PHPLIB definitions are designed that you don't need tochange any of these files. Your customization of PHPLIB can becontained in two or three files, depending on the setup:<tt/local.inc/, <tt/setup.inc/ and, in some cases,<tt/prepend.php3/. You <em/NEVER/ need to change any other filewith PHPLIB. Details are outlined below.<sect2>Customization<p>The following three files are the only files from PHPLIB thatrequire changes in normal PHPLIB applications. <descrip><tag>Application configuration in <tt/local.inc/:</tag><p>Your application will almost certainly not work with the default values supplied by the above classes. You are supposed to extend the classes described below as you see fit.<p>In your subclasses, you only have to specify what is different in your application. These are things like database host names, database names, table names and username/password combinations. You need to provide login screen definitions (HTML) and user validation functions (SQL) to make the example work.<p>The distribution provides a <tt/local.inc/ to illustrate a typical setup. These definitions are also needed to get the administration and testing scripts provided with the distribution to run.<p>The file is required and you must change it for your setup.<tag>Application setup in <tt/setup.inc/:</tag><p>The <tt/Session/ class provides the ability to execute initialization code at session setup. See the class description for instructions on how to set this up. Per convention, we store such code in <tt/setup.inc/ in the include directory. The code is being executed whenever a new user connection to out application and a new session is started.<p>The file is optional. No default is provided.<tag>Selection of automatically loaded classes in <tt/prepend.php3/</tag><p>The file <tt/prepend.php3/ determines which code is being loaded for all PHP3 interpreted pages. Normally, we include the class definitions for all core classes in this file: <tt/db_mysql.inc/, <tt/session.inc/, <tt/auth.inc/, <tt/perm.inc/, <tt/user.inc/, then your local customizations from <tt/local.inc/ and the page management functions from <tt/page.inc/. You must change <tt/prepend.php3/ to reflect the database interface that you are using: Change the <tt/require/ statement for <tt/db_mysql.inc/ appropriately. If you are not using some core features from PHPLIB in your application or if you want some other features to be present on all your pages, you can delete or add <tt/require/ statements for their respective include files here.<p>The file is required. You must change it for your setup, unless you are using MySQL.</descrip><sect2>Core functionality<p>The following files are included from <tt/prepend.php3/ andprovide definitions for the core classes of PHPLIB. We recommendthat you always include all of them, as they are a tightlyintegrated set of classes with many dependencies among them.<descrip><tag>Class <tt/DB_Sql/ defined in exactly one of<tt/db_mysql.inc/, <tt/db_msql.inc/, <tt/db_pgsql.inc/, <tt/db_odbc.inc/, <tt/db_sybase.inc/, <tt/db_mssql.inc/,<tt/db_oracle.inc/ or <tt/db_oci8.inc/:</tag><p>A database access class for your database server. PHPLIB depends on the presence of a SQL database server. Depending on the type of your database server, you have to select the appropriate include file. The file contains the definition of a class <tt/DB_Sql/ suitable for your database server.<p>The class manages a database connection (connection setup is implicit) and result memory is managed automatically.<p>An independent class.<tag>Class <tt/Session/ defined in <tt/session.inc/:</tag><p>Manages an arbitrary amount of arbitrarily named session variables of scalar, array and object types (Object support requires that you implement two instance variables in your classes). Tracks sessions via cookies or a <tt/get/-variable appended to each URL.<p>Depends on <tt/DB_Sql/.<tag>Class <tt/Auth/ defined in <tt/auth.inc/:</tag><p>Manages session authentication. Sessions are authenticated against usernames and passwords in a database. Authentication can be time limited.<p>Depends on <tt/Session/ and <tt/DB_Sql/.<tag>Class <tt/Perm/ defined in <tt/perm.inc/:</tag><p>Manages permission checks on authenticated session pages. Protected pages are only accessible to users with the specified rights.<p>Depends on <tt/Auth/, <tt/Session/ and <tt/DB_Sql/.<tag>Class <tt/User/ defined in <tt/user.inc/:</tag><p>Manages user dependent variables. Unlike session variables these are bound to a user id, not to a session id. They are persistent over multiple sessions, but are only available after a user has been authenticated.<p>Depends on <tt/Auth/, <tt/Session/ and <tt/DB_Sql/, extension of <tt/Session/.<tag>functions <tt/page_open()/ and <tt/page_close()/defined in <tt/page.inc/:</tag><p>Setup and Shutdown functions, must be present on any session page.<p>Depend on <tt/Session/.</descrip><sect2>Extended functionality<p>The extended functionality classes offer GUI-less backgroundfeatures that are commonly needed in HTML-applications. Theymay make use of core functionality (indicated for each classbelow).<descrip><tag><tt/Cart/ in <tt/cart.inc/:</tag><p>Manages a simple shopping cart. Items can be put into the cart, taken out of the cart and the carts contents can be enumerated.<p>Depends on <tt/Session/ to be useful. Requires that you add the statement <tt/require("cart.inc")/ to <tt/prepend.php3/.<tag><tt/Template/ in <tt/template.inc/:</tag><p>Manages templates and variable replacement. Templates can be stored in files. They are loaded on demand and variables are replaced in these files.<p>An independent class. Requires that you add the statement <tt/require("template.inc")/ to <tt/prepend.php3/ or that you include it manually on each page where you want to use it.</descrip><sect2>HTML widgets<p>HTML widgets are classes that generate some HTML-code (oftenforms or tables) to display GUI-elements. We try to providefunctionality commonly used in applications, in a way that theactual look of the GUI-elements can be easily customized.<descrip><tag><tt/CSV_Table/ in <tt/csv_table.inc/:</tag><p>Creates a dump of a two dimensional array or a query result in CSV format, suitable for loading into a database or a spreadsheet program.<p>Depends on <tt/Table/, extension of <tt/Table/.<tag><tt/Sql_Query/ in <tt/sql_query.inc/:</tag><p>Create a selection widget that allows a user to choose arbitrary conditions on one or more table columns. SQL is being created from these selections that can be used in the where-clause of a larger SQL select statement.<p>Depends on <tt/Session/ and <tt/DB_Sql/. Requires that you add the statement <tt/require("sqlquery.inc")/ to <tt/prepend.php3/.<tag><tt/Table/ in <tt/table.inc/:</tag><p>Creates HTML tables from two dimensional arrays or from database query results. The class can either filter out the desired columns from an array or you can explicitly name which columns to show. A heading can be turned on if desired. All generated HTML elements are tagged with a classname you specify for stylesheet support, if needed. When used in a form tag, each table row can be prefixed with a checkbox input element to allow for row selection.<p>An independent class.<tag><tt/Form/ in <tt/oohforms.inc/:</tag><p>Creates HTML forms from feature→value arrays. This provides asingle syntax for creating all of the different types of formelements. The class provides easy access to Javascript and serverside validation, and supports 'freezing' some or all of the formelements to display static data. In addition, the library relies onobject oriented implementations for the various form elements andthese can easily be extended and customized.<p>An independent class.</descrip>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -