📄 03-page.sgml
字号:
<!-- $Id: 03-page.sgml,v 1.1.1.1 2000/04/17 16:40:01 kk Exp $ --><sect1>Page Management<p><sect2>Accessible Functions<p>Page Management currently consists a collection of functions:<descrip><tag>page_open(array("feature" => "classname"))</tag>This function is to be called with an array of pagefeatures/classname pairs. Valid features are at the moment:<descrip><tag>sess</tag><p>This page makes use of session variables.<tag>auth</tag><p>This page uses session authentication. If youspecify the <tt/auth/ feature, you MUST specifythe <tt/sess/ feature, also.<tag>perm</tag><p>This page is protected by permissions and onlyaccessible to authenticated users with matching rights.If you specify the <tt/perm/ feature, you MUST specifythe <tt/auth/ and <tt/sess/ features, also.<tag>user</tag><p>This page makes use of user variables. If you specifythe <tt/user/ feature, you MUST specify the <tt/auth/ and<tt/sess/ features, also.</descrip>Each feature specifies the name of the class that implements that feature,for example<code> page_open(array("sess" => "Shop_Session"));</code>The function creates an instance of <tt/Shop_Session/ as<tt/$sess/ and initializes it. It also checks featuredependencies. Note that you are expected to provide animplementation of the class <tt/Shop_Session/. This isusually done in <tt/local.inc/ and usually you do so byextending the provided <tt/Session/ class.Examples on how to do this is given in the documentation belowwhen the classes are introduced.<tag>page_close()</tag><p>At the end of your page (after all results have been calculated)you have to call <tt/page_close()/. This will save allpage state, session and user variables into database. Changes tosession or user variables after <tt/page_close()/ hasbeen called are not recorded. Currently it is allowed to call<tt/page_close()/ multiple times on a single page (notguaranteed for future versions!). Each time session state will besaved.<em/Note:/ This is going to change. When we introduce recordlocking, it is important that you call <tt/page_close()/ onlyonce per page, because that will implicitly unlock your sessionrecord. Also, it is important that you call <tt/page_close()/ asearly as possible on a page so that the locking time is keptminimal.<tag>sess_load(array("var" => "classname")</tag><p> <em/Advanced feature/. Some applications have need to manuallyload data belonging to one or multiple session classes. @@TODO<tag>sess_save(array("var" => "classname"))</tag><em/Advanced feature/. @@TODO</descrip><sect2>Example<p><tscreen><code><?php page_open(array("sess" => "Shop_Session")); $sess->register("s"); // See "Session" below for explanation. ?><html><h1><?php print ++$s ?></h1></html><?php page_close(); ?></code></tscreen><sect2>The "cart" feature is gone<p> There used to be a feature "cart" for <tt/page_open()/ inversions of PHPLIB up to release-5. The cart has been removedfrom the core functionality of PHPLIB to keep the library small,maintainable and structured. Consequently the "cart" feature isgone.The <tt/Cart/ class is still present and exists as an extendedfeature. You have to include and instantiate your cart manuallyon that pages that use it, though. See the <tt/Cart/ class formore information.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -