select 对象中 (可以多重选择的multiple)

gongcaihua3 2003-10-23 10:23:20
怎么判断当前的是否对象是否选择
...全文
35 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ttaomeng 2003-10-31
  • 打赏
  • 举报
回复
for (var i=0; i<document.form1.select1.options.length; i++)
{
if (document.form1.select1.options[i].selected)
{

}
}
梦想成真2003 2003-10-31
  • 打赏
  • 举报
回复
for (var i=0; i<document.form1.select1.options.length; i++)
{
if (document.form1.select1.options[i].selected==true)
{

}
}
document.form1.select1.selectindex返回最小的options索引
chinahaohao 2003-10-31
  • 打赏
  • 举报
回复
document.form.select.options[i].selected==true
Visual C++MFC入门教程 目录 +-- 第一章 VC入门 |------ 1.1 如何学好VC |------ 1.2 理解Windows消息机制 |------ 1.3 利用Visual C++/MFC开发Windows程序的优势 |------ 1.4 利用MFC进行开发的通用方法介绍 |------ 1.5 MFC常用类,宏,函数介绍 +-- 第二章 图形输出 |------ 2.1 和GUI有关的各种对象 |------ 2.2 在窗口输出文字 |------ 2.3 使用点,刷子,笔进行绘图 |------ 2.4 在窗口绘制设备相关位图,图标,设备无关位图 |------ 2.5 使用各种映射方式 |------ 2.6 多边形和剪贴区域 +-- 第三章 文档视结构 |------ 3.1 文档 视图 框架窗口间的关系和消息传送规律 |------ 3.2 接收用户输入 |------ 3.3 使用菜单 |------ 3.4 文档,视,框架之间相互作用 |------ 3.5 利用序列化进行文件读写 |------ 3.6 MFC所提供的各种视类介绍 +-- 第四章 窗口控件 |------ 4.1 Button |------ 4.2 Static Box |------ 4.3 Edit Box |------ 4.4 Scroll Bar |------ 4.5 List Box/Check List Box |------ 4.6 Combo Box/Combo Box Ex |------ 4.7 Tree Ctrl |------ 4.8 List Ctrl |------ 4.9 Tab Ctrl |------ 4.A Tool Bar |------ 4.B Status Bar |------ 4.C Dialog Bar |------ 4.D 利用AppWizard创建并使用ToolBar StatusBar Dialog Bar |------ 4.E General Window |------ 4.F 关于WM_NOTIFY的使用方法 +-- 第五章 对话框 |------ 5.1 使用资源编辑器编辑对话框 |------ 5.2 创建有模式对话框 |------ 5.3 创建无模式对话框 |------ 5.4 在对话框进行消息映射 |------ 5.5 在对话框进行数据交换和数据检查 |------ 5.6 使用属性对话框 |------ 5.7 使用通用对话框 |------ 5.8 建立以对话框为基础的应用 |------ 5.9 使用对话框作为子窗口 +-- 第六章 网络通信开发 |------ 6.1 WinSock介绍 |------ 6.2 利用WinSock进行无连接的通信 +------ 6.3 利用WinSock建立有连接的通信   第一章 VC入门 1.1 如何学好VC 这个问题很多朋友都问过我,当然流汗是必须的,但同时如果按照某种思路进行有计划的学习就会起到更好的效果。万事开头难,为了帮助朋友们更快的掌握VC开发,下面我将自己的一点体会讲一下: 1、需要有好的C/C++基础。正所谓“磨刀不误砍柴工”,最开始接触VC时不要急于开始Windows程序开发,而是应该进行一些字符界面程序的编写。这样做的目的主要是增加对语言的熟悉程度,同时也训练自己的思维和熟悉一些在编程常犯的错误。更重要的是理解并能运用C++的各种特性,这些在以后的开发都会有很大的帮助,特别是利用MFC进行开发的朋友对C++一定要能熟练运用。 2、理解Windows的消息机制,窗口句柄和其他GUI句柄的含义和用途。了解和MFC各个类功能相近的API函数。 3、一定要理解MFC消息映射的作用。 4、训练自己在编写代码时不使用参考书而是使用Help Online。 5、记住一些常用的消息名称和参数的意义。 6、学会看别人的代码。 7、多看书,少买书,买书前一定要慎重。 8、闲下来的时候就看参考书。 9、多来我的主页。^O^ 后面几条是我个人的一点意见,你可以根据需要和自身的情况选用适用于自己的方法。 此外我将一些我在选择参考书时的原则: 对于初学者:应该选择一些内容比较全面的书籍,并且书籍的内容应该以合理的方式安排,在使用该书时可以达到循序渐进的效果,书的代码要有详细的讲解。尽量买翻译的书,因为这些书一般都比较易懂,而且语言比较轻松。买书前一定要慎重如果买到不好用的书可能会对自己的学习积极性产生击。 对于已经掌握了VC的朋友:这种程度的开发者应该加深自己对系统原理,技术要点的认识。需要选择一些对原理讲解的比较透彻的书籍,这样一来才会对新技术有更多的了解,最好书对技术的应用有一定的阐述。尽量选择示范代码必较精简的书,可以节约银子。 此外最好涉猎一些辅助性的书籍。 1.2 理解Windows消息机制 Windows系统是一个消息驱动的OS,什么是消息呢?我很难说得清楚,也很难下一个定义(谁在嘘我),我下面从不同的几个方面讲解一下,希望大家看了后有一点了解。 1、消息的组成:一个消息由一个消息名称(UINT),和两个参数(WPARAM,LPARAM)。当用户进行了输入或是窗口的状态发生改变时系统都会发送消息到某一个窗口。例如当菜单转之后会有WM_COMMAND消息发送,WPARAM的高字(HIWORD(wParam))是命令的ID号,对菜单来讲就是菜单ID。当然用户也可以定义自己的消息名称,也可以利用自定义消息来发送通知和传送数据。 2、谁将收到消息:一个消息必须由一个窗口接收。在窗口的过程(WNDPROC)可以对消息进行分析,对自己感兴趣的消息进行处理。例如你希望对菜单选择进行处理那么你可以定义对WM_COMMAND进行处理的代码,如果希望在窗口进行图形输出就必须对WM_PAINT进行处理。 3、未处理的消息到那里去了:M$为窗口编写了默认的窗口过程,这个窗口过程将负责处理那些你不处理消息。正因为有了这个默认窗口过程我们才可以利用Windows的窗口进行开发而不必过多关注窗口各种消息的处理。例如窗口在被拖动时会有很多消息发送,而我们都可以不予理睬让系统自己去处理。 4、窗口句柄:说到消息就不能不说窗口句柄,系统通过窗口句柄来在整个系统唯一标识一个窗口,发送一个消息时必须指定一个窗口句柄表明该消息由那个窗口接收。而每个窗口都会有自己的窗口过程,所以用户的输入就会被正确的处理。例如有两个窗口共用一个窗口过程代码,你在窗口一上按下鼠标时消息就会通过窗口一的句柄被发送到窗口一而不是窗口二。 5、示例:下面有一段伪代码演示如何在窗口过程处理消息 LONG yourWndProc(HWND hWnd,UINT uMessageType,WPARAM wP,LPARAM) { switch(uMessageType) { //使用SWITCH语句将各种消息分开 case(WM_PAINT): doYourWindow(...);//在窗口需要重新绘制时进行输出 break; case(WM_LBUTTONDOWN): doYourWork(...);//在鼠标左键被按下时进行处理 break; default: callDefaultWndProc(...);//对于其它情况就让系统自己处理 break; } } 接下来谈谈什么是消息机制:系统将会维护一个或多个消息队列,所有产生的消息都回被放入或是插入队列。系统会在队列取出每一条消息,根据消息的接收句柄而将该消息发送给拥有该窗口的程序的消息循环。每一个运行的程序都有自己的消息循环,在循环得到属于自己的消息并根据接收窗口的句柄调用相应的窗口过程。而在没有消息时消息循环就将控制权交给系统所以Windows可以同时进行多个任务。下面的伪代码演示了消息循环的用法: while(1) { id=getMessage(...); if(id == quit) break; translateMessage(...); } 当该程序没有消息通知时getMessage就不会返回,也就不会占用系统的CPU时间。 下图为消息投递模式 在16位的系统系统只有一个消息队列,所以系统必须等待当前任务处理消息后才可以发送下一消息到相应程序,如果一个程序陷如死循环或是耗时操作时系统就会得不到控制权。这种多任务系统也就称为协同式的多任务系统。Windows3.X就是这种系统。而32位的系统每一运行的程序都会有一个消息队列,所以系统可以在多个消息队列转换而不必等待当前程序完成消息处理就可以得到控制权。这种多任务系统就称为抢先式的多任务系统。Windows95/NT就是这种系统。 1.3 利用Visual C++/MFC开发Windows程序的优势 MFC借助C++的优势为Windows开发开辟了一片新天地,同时也借助ApplicationWizzard使开发者摆脱离了那些每次都必写基本代码,借助ClassWizard和消息映射使开发者摆脱了定义消息处理时那种混乱和冗长的代码段。更令人兴奋的是利用C++的封装功能使开发者摆脱Windows各种句柄的困扰,只需要面对C++对象,这样一来使开发更接近开发语言而远离系统。(但我个人认为了解系统原理对开发很有帮助) 正因为MFC是建立在C++的基础上,所以我强调C/C++语言基础对开发的重要性。利用C++的封装性开发者可以更容易理解和操作各种窗口对象;利用C++的派生性开发者可以减少开发自定义窗口的时间和创造出可重用的代码;利用虚拟性可以在必要时更好的控制窗口的活动。而且C++本身所具备的超越C语言的特性都可以使开发者编写出更易用,更灵活的代码。 在MFC对消息的处理利用了消息映射的方法,该方法的基础是宏定义实现,通过宏定义将消息分派到不同的成员函数进行处理。下面简单讲述一下这种方法的实现方法: 代码如下 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() //}}AFX_MSG_MAP ON_COMMAND(ID_FONT_DROPDOWN, DoNothing) END_MESSAGE_MAP() 经过编译后,代码被替换为如下形式(这只是作讲解,实际情况比这复杂得多): //BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) CMainFrame::newWndProc(...) { switch(...) { //{{AFX_MSG_MAP(CMainFrame) // ON_WM_CREATE() case(WM_CREATE): OnCreate(...); break; //}}AFX_MSG_MAP // ON_COMMAND(ID_FONT_DROPDOWN, DoNothing) case(WM_COMMAND): if(HIWORD(wP)==ID_FONT_DROPDOWN) { DoNothing(...); } break; //END_MESSAGE_MAP() } } newWndProc就是窗口过程只要是该类的实例生成的窗口都使用该窗口过程。 所以了解了Windows的消息机制在加上对消息映射的理解就很容易了解MFC开发的基本思路了。 1.4 利用MFC进行开发的通用方法介绍 以下是我在最初学习VC时所常用的开发思路和方法,希望能对初学VC的朋友有所帮助和启发。 1、开发需要读写文件的应用程序并且有简单的输入和输出可以利用单文档视结构。 2、开发注重交互的简单应用程序可以使用对话框为基础的窗口,如果文件读写简单这可利用CFile进行。 3、开发注重交互并且文件读写复杂的的简单应用程序可以利用以CFormView为基础视的单文档视结构。 4、利用对话框得到用户输入的数据,在等级提高后可使用就地输入。 5、在对多文档要求不强烈时尽量避免多文档视结构,可以利用分隔条产生单文档多视结构。 6、在要求在多个文档间传递数据时使用多文档视结构。 7、学会利用子窗口,并在自定义的子窗口包含多个控件达到封装功能的目的。 8、尽量避免使用多文档多视结构。 9、不要使用多重继承并尽量减少一个类封装过多的功能。 1.5 MFC常用类,宏,函数介绍 常用类 CRect:用来表示矩形的类,拥有四个成员变量:top left bottom right。分别表是左上角和右下角的坐标。可以通过以下的方法构造: CRect( int l, int t, int r, int b ); 指明四个坐标 CRect( const RECT& srcRect ); 由RECT结构构造 CRect( LPCRECT lpSrcRect ); 由RECT结构构造 CRect( POINT point, SIZE size ); 有左上角坐标和尺寸构造 CRect( POINT topLeft, POINT bottomRight ); 有两点坐标构造 下面介绍几个成员函数: int Width( ) const; 得到宽度 int Height( ) const; 得到高度 CSize Size( ) const; 得到尺寸 CPoint& TopLeft( ); 得到左上角坐标 CPoint& BottomRight( ); 得到右下角坐标 CPoint CenterPoint( ) const; 得当心坐标 此外矩形可以和点(CPoint)相加进行位移,和另一个矩形相加得到“并”操作后的矩形。 CPoint:用来表示一个点的坐标,有两个成员变量:x y。 可以和另一个点相加。 CString:用来表示可变长度的字符串。使用CString可不指明内存大小,CString会根据需要自行分配。下面介绍几个成员函数: GetLength 得到字符串长度 GetAt 得到指定位置处的字符 operator + 相当于strcat void Format( LPCTSTR lpszFormat, ... ); 相当于sprintf Find 查找指定字符,字符串 Compare 比较 CompareNoCase 不区分大小写比较 MakeUpper 改为小写 MakeLower 改为大写 CStringArray:用来表示可变长度的字符串数组。数组每一个元素为CString对象的实例。下面介绍几个成员函数: Add 增加CString RemoveAt 删除指定位置CString对象 RemoveAll 删除数组所有CString对象 GetAt 得到指定位置的CString对象 SetAt 修改指定位置的CString对象 InsertAt 在某一位置插入CString对象 常用宏 RGB TRACE ASSERT VERIFY 常用函数 CWindApp* AfxGetApp(); HINSTANCE AfxGetInstanceHandle( ); HINSTANCE AfxGetResourceHandle( ); int AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 );用于弹出一个消息框 第二章 图形输出 2.1 和GUI有关的各种对象 在Windows有各种GUI对象(不要和C++对象混淆),当你在进行绘图就需要利用这些对象。而各种对象都拥有各种属性,下面分别讲述各种GUI对象和拥有的属性。 字体对象CFont用于输出文字时选用不同风格和大小的字体。可选择的风格包括:是否为斜体,是否为粗体,字体名称,是否有下划线等。颜色和背景色不属于字体的属性。关于如何创建和使用字体在2.2 在窗口输出文字会详细讲解。 刷子CBrush对象决定填充区域时所采用的颜色或模板。对于一个固定色的刷子来讲它的属性为颜色,是否采用网格和网格的类型如水平的,垂直的,交叉的等。你也可以利用8*8的位图来创建一个自定义模板的刷子,在使用这种刷子填充时系统会利用位图逐步填充区域。关于如何创建和使用刷子在2.3 使用刷子,笔进行绘图会详细讲解。 画笔CPen对象在画点和画线时有用。它的属性包括颜色,宽度,线的风格,如虚线,实线,点划线等。关于如何创建和使用画笔在2.3 使用刷子,笔进行绘图会详细讲解。 位图CBitmap对象可以包含一幅图像,可以保存在资源。关于如何使用位图在2.4 在窗口绘制设备相关位图,图标,设备无关位图会详细讲解。 还有一种特殊的GUI对象是多边形,利用多边形可以很好的限制作图区域或是改变窗口外型。关于如何创建和使用多边形在2.6 多边形和剪贴区域会详细讲解。 在Windows使用GUI对象必须遵守一定的规则。首先需要创建一个合法的对象,不同的对象创建方法不同。然后需要将该GUI对象选入DC,同时保存DC原来的GUI对象。如果选入一个非法的对象将会引起异常。在使用完后应该恢复原来的对象,这一点特别重要,如果保存一个临时对象在DC,而在临时对象被销毁后可能引起异常。有一点必须注意,每一个对象在重新创建前必须销毁,下面的代码演示了这一种安全的使用方法: OnDraw(CDC* pDC) { CPen pen1,pen2; pen1.CreatePen(PS_SOLID,2,RGB(128,128,128));//创建对象 pen2.CreatePen(PS_SOLID,2,RGB(128,128,0));//创建对象 CPen* pPenOld=(CPen*)pDC->SelectObject(&pen1);//选择对象进DC drawWithPen1... (CPen*)pDC->SelectObject(&pen2);//选择对象进DC drawWithPen2... pen1.DeleteObject();//再次创建前先销毁 pen1.CreatePen(PS_SOLID,2,RGB(0,0,0));//再次创建对象 (CPen*)pDC->SelectObject(&pen1);//选择对象进DC drawWithPen1... pDC->SelectObject(pOldPen);//恢复 } 此外系统还拥有一些库存GUI对象,你可以利用CDC::SelectStockObject(SelectStockObject( int nIndex )选入这些对象,它们包括一些固定颜色的刷子,画笔和一些基本字体。 • BLACK_BRUSH Black brush. • DKGRAY_BRUSH Dark gray brush. • GRAY_BRUSH Gray brush. • HOLLOW_BRUSH Hollow brush. • LTGRAY_BRUSH Light gray brush. • NULL_BRUSH Null brush. • WHITE_BRUSH White brush. • BLACK_PEN Black pen. • NULL_PEN Null pen. • WHITE_PEN White pen. • ANSI_FIXED_FONT ANSI fixed system font. • ANSI_VAR_FONT ANSI variable system font. • DEVICE_DEFAULT_FONT Device-dependent font. • OEM_FIXED_FONT OEM-dependent fixed font. • SYSTEM_FONT The system font. By default, Windows uses the system font to draw menus, dialog-box controls, and other text. In Windows versions 3.0 and later, the system font is proportional width; earlier versions of Windows use a fixed-width system font. • SYSTEM_FIXED_FONT The fixed-width system font used in Windows prior to version 3.0. This object is available for compatibility with earlier versions of Windows. • DEFAULT_PALETTE Default color palette. This palette consists of the 20 static colors in the system palette. 这些对象留在DC是安全的,所以你可以利用选入库存对象来作为恢复DCGUI对象。 大家可能都注意到了绘图时都需要一个DC对象,DC(Device Context设备环境)对象是一个抽象的作图环境,可能是对应屏幕,也可能是对应打印机或其它。这个环境是设备无关的,所以你在对不同的设备输出时只需要使用不同的设备环境就行了,而作图方式可以完全不变。这也就是Windows耀眼的一点设备无关性。如同你将对一幅画使用照相机或复印机将会产生不同的输出,而不需要对画进行任何调整。DC的使用会穿插在本章进行介绍。 2.2 在窗口输出文字 在这里我假定读者已经利用ApplicationWizard生成了一个SDI界面的程序代码。接下来的你只需要在CView派生类的OnDraw成员函数加入绘图代码就可以了。在这里我需要解释一下OnDraw函数的作用,OnDraw函数会在窗口需要重绘时自动被调用,传入的参数CDC* pDC对应的就是DC环境。使用OnDraw的优点就在于在你使用打印功能的时候传入OnDraw的DC环境将会是打印机绘图环境,使用打印预览时传入的是一个称为CPreviewDC的绘图环境,所以你只需要一份代码就可以完成窗口/打印预览/打印机绘图三重功能。利用Windows的设备无关性和M$为打印预览所编写的上千行代码你可以很容易的完成一个具有所见即所得的软件。 输出文字一般使用CDC::BOOL TextOut( int x, int y, const CString& str )和CDC::int DrawText( const CString& str, LPRECT lpRect, UINT nFormat )两个函数,对TextOut来讲只能输出单行的文字,而DrawText可以指定在一个矩形输出单行或多行文字,并且可以规定对齐方式和使用何种风格。nFormat可以是多种以下标记的组合(利用位或操作)以达到选择输出风格的目的。 • DT_BOTTOM底部对齐 Specifies bottom-justified text. This value must be combined with DT_SINGLELINE. • DT_CALCRECT计算指定文字时所需要矩形尺寸 Determines the width and height of the rectangle. If there are multiple lines of text, DrawText will use the width of the rectangle pointed to by lpRect and extend the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText will modify the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text, but does not draw the text. • DT_CENTER部对齐 Centers text horizontally. • DT_END_ELLIPSIS or DT_PATH_ELLIPSIS Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. The given string is not modified unless the DT_MODIFYSTRING flag is specified. You can specify DT_END_ELLIPSIS to replace characters at the end of the string, or DT_PATH_ELLIPSIS to replace characters in the middle of the string. If the string contains backslash (\) characters, DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash. • DT_EXPANDTABS Expands tab characters. The default number of characters per tab is eight. • DT_EXTERNALLEADING Includes the font抯 external leading in the line height. Normally, external leading is not included in the height of a line of text. • DT_LEFT左对齐 Aligns text flush-left. • DT_MODIFYSTRING Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified. Note Some uFormat flag combinations can cause the passed string to be modified. Using DT_MODIFYSTRING with either DT_END_ELLIPSIS or DT_PATH_ELLIPSIS may cause the string to be modified, causing an assertion in the CString override. • DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used. • DT_NOPREFIX禁止使用&前缀 Turns off processing of prefix characters. Normally, DrawText interprets the ampersand (&) mnemonic-prefix character as a directive to underscore the character that follows, and the two-ampersand (&&) mnemonic-prefix characters as a directive to print a single ampersand. By specifying DT_NOPREFIX, this processing is turned off. • DT_PATH_ELLIPSIS • DT_RIGHT右对齐 Aligns text flush-right. • DT_SINGLELINE单行输出 Specifies single line only. Carriage returns and linefeeds do not break the line. • DT_TABSTOP设置TAB字符所占宽度 Sets tab stops. The high-order byte of nFormat is the number of characters for each tab. The default number of characters per tab is eight. • DT_TOP定部对齐 Specifies top-justified text (single line only). • DT_VCENTER部对齐 Specifies vertically centered text (single line only). • DT_WORDBREAK每行只在单词间被折行 Specifies word-breaking. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by lpRect. A carriage return杔inefeed sequence will also break the line. 在输出文字时如果希望改变文字的颜色,你可以利用CDC::SetTextColor( COLORREF crColor )进行设置,如果你希望改变背景色就利用CDC::SetBkColor( COLORREF crColor ),很多时候你可能需要透明的背景色你可以利用CDC::SetBkMode( int nBkMode )设置,可接受的参数有 • OPAQUE Background is filled with the current background color before the text, hatched brush, or pen is drawn. This is the default background mode. • TRANSPARENT Background is not changed before drawing. 接下来讲讲如何创建字体,你可以创建的字体有两种:库存字体CDC::CreateStockObject( int nIndex )和自定义字体。 在创建非库存字体时需要填充一个LOGFONT结构并使用CFont::CreateFontIndirect(const LOGFONT* lpLogFont ),或使用CFont::CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename )其的参数和LOGFONT的分量有一定的对应关系。下面分别讲解参数的意义: nHeight 字体高度(逻辑单位)等于零为缺省高度,否则取绝对值并和可用的字体高度进行匹配。 nWidth 宽度(逻辑单位)如果为零则使用可用的横纵比进行匹配。 nEscapement 出口矢量与X轴间的角度 nOrientation 字体基线与X轴间的角度 nWeight 字体粗细,可取以下值 Constant Value FW_DONTCARE 0 FW_THIN 100 FW_EXTRALIGHT 200 FW_ULTRALIGHT 200 FW_LIGHT 300 FW_NORMAL 400 FW_REGULAR 400 FW_MEDIUM 500 FW_SEMIBOLD 600 FW_DEMIBOLD 600 FW_BOLD 700 FW_EXTRABOLD 800 FW_ULTRABOLD 800 FW_BLACK 900 FW_HEAVY 900 bItalic 是否为斜体 bUnderline 是否有下划线 cStrikeOut 是否带删除线 nCharSet 指定字符集合,可取以下值 Constant Value ANSI_CHARSET 0 DEFAULT_CHARSET 1 SYMBOL_CHARSET 2 SHIFTJIS_CHARSET 128 OEM_CHARSET 255 nOutPrecision 输出精度 OUT_CHARACTER_PRECIS OUT_STRING_PRECIS OUT_DEFAULT_PRECIS OUT_STROKE_PRECIS OUT_DEVICE_PRECIS OUT_TT_PRECIS OUT_RASTER_PRECIS nClipPrecision 剪辑精度,可取以下值 CLIP_CHARACTER_PRECIS CLIP_MASK CLIP_DEFAULT_PRECIS CLIP_STROKE_PRECIS CLIP_ENCAPSULATE CLIP_TT_ALWAYS CLIP_LH_ANGLES nQuality 输出质量,可取以下值 • DEFAULT_QUALITY Appearance of the font does not matter. • DRAFT_QUALITY Appearance of the font is less important than when PROOF_QUALITY is used. For GDI raster fonts, scaling is enabled. Bold, italic, underline, and strikeout fonts are synthesized if necessary. • PROOF_QUALITY Character quality of the font is more important than exact matching of the logical-font attributes. For GDI raster fonts, scaling is disabled and the font closest in size is chosen. Bold, italic, underline, and strikeout fonts are synthesized if necessary. nPitchAndFamily 字体间的间距 lpszFacename 指定字体名称,为了得到系统所拥有的字体可以利用EmunFontFamiliesEx。 此外可以利用CFontDialog来得到用户选择的字体的LOGFONT数据。 最后我讲一下文本坐标的计算,利用CDC::GetTextExtent( const CString& str )可以得到字符串的在输出时所占用的宽度和高度,这样就可以在手工输出多行文字时使用正确的行距。另外如果需要更精确的对字体高度和宽度进行计算就需要使用CDC::GetTextMetrics( LPTEXTMETRIC lpMetrics ) 该函数将会填充TEXTMETRIC结构,该结构的分量可以非常精确的描述字体的各种属性。 2.3 使用点,刷子,笔进行绘图 在Windows画点的方法很简单,只需要调用COLORREF CDC::SetPixel( int x, int y, COLORREF crColor )就可以在指定点画上指定颜色,同时返回原来的颜色。COLORREF CDC::GetPixel( int x, int y)可以得到指定点的颜色。在Windows应该少使用画点的函数,因为这样做的执行效率比较低。 刷子和画笔在Windows作图是使用最多的GUI对象,本节在讲解刷子和画笔使用方法的同时也讲述一写基本作图函数。 在画点或画线时系统使用当前DC的画笔,所以在创建画笔后必须将其选入DC才会在绘图时产生效果。画笔可以通过CPen对象来产生,通过调用CPen::CreatePen( int nPenStyle, int nWidth, COLORREF crColor )来创建。其nPenStyle指名画笔的风格,可取如下值: • PS_SOLID 实线 Creates a solid pen. • PS_DASH 虚线,宽度必须为一 Creates a dashed pen. Valid only when the pen width is 1 or less, in device units. • PS_DOT 点线,宽度必须为一 Creates a dotted pen. Valid only when the pen width is 1 or less, in device units. • PS_DASHDOT 点划线,宽度必须为一 Creates a pen with alternating dashes and dots. Valid only when the pen width is 1 or less, in device units. • PS_DASHDOTDOT 双点划线,宽度必须为一 Creates a pen with alternating dashes and double dots. Valid only when the pen width is 1 or less, in device units. • PS_NULL 空线,使用时什么也不会产生 Creates a null pen. • PS_ENDCAP_ROUND 结束处为圆形 End caps are round. • PS_ENDCAP_SQUARE 结束处为方形 End caps are square. nWidth和crColor为线的宽度和颜色。 刷子是在画封闭曲线时用来填充的颜色,例如当你画圆形或方形时系统会用当前的刷子对内部进行填充。刷子可利用CBrush对象产生。通过以下几种函数创建刷子: • BOOL CreateSolidBrush( COLORREF crColor ); 创建一种固定颜色的刷子 • BOOL CreateHatchBrush( int nIndex, COLORREF crColor ); 创建指定颜色和网格的刷子,nIndex可取以下值: • HS_BDIAGONAL Downward hatch (left to right) at 45 degrees • HS_CROSS Horizontal and vertical crosshatch • HS_DIAGCROSS Crosshatch at 45 degrees • HS_FDIAGONAL Upward hatch (left to right) at 45 degrees • HS_HORIZONTAL Horizontal hatch • HS_VERTICAL Vertical hatch • BOOL CreatePatternBrush( CBitmap* pBitmap ); 创建以8*8位图为模板的刷子 在选择了画笔和刷子后就可以利用Windows的作图函数进行作图了,基本的画线函数有以下几种 • CDC::MoveTo( int x, int y ); 改变当前点的位置 • CDC::LineTo( int x, int y ); 画一条由当前点到参数指定点的线 • CDC::BOOL Arc( LPCRECT lpRect, POINT ptStart, POINT ptEnd ); 画弧线 • CDC::BOOL Polyline( LPPOINT lpPoints, int nCount ); 将多条线依次序连接 基本的作图函数有以下几种: • CDC::BOOL Rectangle( LPCRECT lpRect ); 矩形 • CDC::RoundRect( LPCRECT lpRect, POINT point ); 圆角矩形 • CDC::Draw3dRect( int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight ); 3D边框 • CDC::Chord( LPCRECT lpRect, POINT ptStart, POINT ptEnd ); 扇形 • CDC::Ellipse( LPCRECT lpRect ); 椭圆形 • CDC::Pie( LPCRECT lpRect, POINT ptStart, POINT ptEnd ); • CDC::Polygon( LPPOINT lpPoints, int nCount ); 多边形 对于矩形,圆形或类似的封闭曲线,系统会使用画笔绘制边缘,使用刷子填充内部。如果你不希望填充或是画出边缘,你可以选入空刷子(NULL_PEN)或是(NULL_BRUSH)空笔。 下面的代码创建一条两象素宽的实线并选入DC。并进行简单的作图: { ... CPen pen; pen.CreatePen(PS_SOLID,2,RGB(128,128,128)); CPen* pOldPen=(CPen*)dc.SelectObject(&pen); dc.SelectStockObject(NULL_BRUSH);//选入空刷子 dc.Rectangle(CRect(0,0,20,20));//画矩形 ... } 2.4 在窗口绘制设备相关位图,图标,设备无关位图 在Windows可以将预先准备好的图像复制到显示区域,这种内存拷贝执行起来是非常快的。在Windows提供了两种使用图形拷贝的方法:通过设备相关位图(DDB)和设备无关位图(DIB)。 DDB可以用MFC的CBitmap来表示,而DDB一般是存储在资源文件,在加载时只需要通过资源ID号就可以将图形装入。BOOL CBitmap::LoadBitmap( UINT nIDResource )可以装入指定DDB,但是在绘制时必须借助另一个和当前绘图DC兼容的内存DC来进行。通过CDC::BitBlt( int x, int y, int nWidth, int nHeight, CDC* pSrcDC, int xSrc, int ySrc, DWORD dwRop )绘制图形,同时指定光栅操作的类型。BitBlt可以将源DC位图复制到目的DC,其前四个参数为目的区域的坐标,接下来是源DC指针,然后是源DC的起始坐标,由于BitBlt为等比例复制,所以不需要再次指定长宽,(StretchBlt可以进行缩放)最后一个参数为光栅操作的类型,可取以下值: • BLACKNESS 输出区域为黑色 Turns all output black. • DSTINVERT 反色输出区域 Inverts the destination bitmap. • MERGECOPY 在源和目的间使用AND操作 Combines the pattern and the source bitmap using the Boolean AND operator. • MERGEPAINT 在反色后的目的和源间使用OR操作 Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator. • NOTSRCCOPY 将反色后的源拷贝到目的区 Copies the inverted source bitmap to the destination. • PATINVERT 源和目的间进行XOR操作 Combines the destination bitmap with the pattern using the Boolean XOR operator. • SRCAND 源和目的间进行AND操作 Combines pixels of the destination and source bitmaps using the Boolean AND operator. • SRCCOPY 复制源到目的区 Copies the source bitmap to the destination bitmap. • SRCINVERT 源和目的间进行XOR操作 Combines pixels of the destination and source bitmaps using the Boolean XOR operator. • SRCPAINT 源和目的间进行OR操作 Combines pixels of the destination and source bitmaps using the Boolean OR operator. • WHITENESS 输出区域为白色 Turns all output white. 下面用代码演示这种方法: CYourView::OnDraw(CDC* pDC) { CDC memDC;//定义一个兼容DC memDC.CreateCompatibleDC(pDC);//创建DC CBitmap bmpDraw; bmpDraw.LoadBitmap(ID_BMP) ;//装入DDB CBitmap* pbmpOld=memDC.SelectObject(&bmpDraw) ; //保存原有DDB,并选入新DDB入DC pDC->BitBlt(0,0,20,20,&memDC,0,0,SRCCOPY) ; //将源DC(0,0,20,20)复制到目的DC(0,0,20,20) pDC->BitBlt(20,20,40,40,&memDC,0,0,SRCAND); //将源DC(0,0,20,20)和目的DC(20,20,40,40)区域进行AND操作 memDC.SelectObject(pbmpOld) ;//选入原DDB } (图标并不是一个GDI对象,所以不需要选入DC)在MFC没有一个专门的图标类,因为图标的操作比较简单,使用HICON CWinApp::LoadIcon( UINT nIDResource )或是HICON CWinApp::LoadStandardIcon( LPCTSTR lpszIconName ) 装入后就可以利用BOOL CDC::DrawIcon( int x, int y, HICON hIcon )绘制。由于在图标可以指定透明区域,所以在某些需要使用非规则图形而且面积不大的时候使用图标会比较简单。下面给出简单的代码: OnDraw(CDC* pDC) { HICON hIcon1=AfxGetApp()->LoadIcon(IDI_I1); HICON hIcon2=AfxGetApp()->LoadIcon(IDI_I2); pDC->DrawIcon(0,0,hIcon1); pDC->DrawIcon(0,40,hIcon2); DestroyIcon(hIcon1); DestroyIcon(hIcon2); } 同样在MFC也没有提供一个DIB的类,所以在使用DIB位图时我们需要自己读取位图文件的头信息,并读入数据,并利用API函数StretchDIBits绘制。位图文件以BITMAPFILEHEADER结构开始,然后是BITMAPINFOHEADER结构和调色版信息和数据,其实位图格式是图形格式最简单的一种,而且也是Windows可以理解的一种。我不详细讲解DIB位图的结构,提供一个CDib类供大家使用,这个类包含了基本的功能如:Load,Save,Draw。DownLoad CDib 4K 2.5 使用各种映射方式 所谓的映射方式简单点讲就是坐标的安排方式,系统默认的映射方式为MM_TEXT即X坐标向右增加,Y坐标向下增加,(0,0)在屏幕左上方,DC的每一点就是屏幕上的一个象素。也许你会认为这种方式下是最好理解的,但是一个点和象素对应的关系在屏幕上看来是正常的,但到了打印机上就会很不正常。因为我们作图是以点为单位并且打印机的分辨率远远比显示器高(800DPI 800点每英寸)所以在打印机上图形看起来就会很小。这样就需要为打印另做一套代码而加大了工作量。如果每个点对应0.1毫米那么在屏幕上的图形就会和打印出来的图形一样大小。 通过int CDC::SetMapMode( int nMapMode )可以指定映射方式,可用的有以下几种: • MM_HIENGLISH 每点对应0.001英寸 Each logical unit is converted to 0.001 inch. Positive x is to the right; positive y is up. • MM_HIMETRIC 每点对应0.001毫米 Each logical unit is converted to 0.01 millimeter. Positive x is to the right; positive y is up. • MM_LOENGLISH 每点对应0.01英寸 Each logical unit is converted to 0.01 inch. Positive x is to the right; positive y is up. • MM_LOMETRIC 每点对应0.001毫米 Each logical unit is converted to 0.1 millimeter. Positive x is to the right; positive y is up. • MM_TEXT 象素对应 Each logical unit is converted to 1 device pixel. Positive x is to the right; positive y is down. 以上几种映射默认的原点在屏幕左上方。除MM_TEXT外都为X坐标向右增加,Y坐标向上增加,和自然坐标是一致的。所以在作图是要注意什么时候应该使用负坐标。而且以上的映射都是X-Y等比例的,即相同的长度在X,Y轴上显示的长度都是相同的。 DownLoad Sample 另外的一种映射方式为MM_ANISOTROPIC,这种方式可以规定不同的长宽比例。在设置这映射方式后必须调用CSize CDC::SetWindowExt( SIZE size )和CSize CDC::SetViewportExt( SIZE size )来设定长宽比例。系统会根据两次设定的长宽的比值来确定长宽比例。下面给出一段代码比较映射前后的长宽比例: OnDraw(CDC* pDC) { CRect rcC1(200,0,400,200); pDC->FillSolidRect(rcC1,RGB(0,0,255)); pDC->SetMapMode(MM_ANISOTROPIC ); CSize sizeO; sizeO=pDC->SetWindowExt(5,5); TRACE("winExt %d %d\n",sizeO.cx,sizeO.cy); sizeO=pDC->SetViewportExt(5,10); TRACE("ViewExt %d %d\n",sizeO.cx,sizeO.cy); CRect rcC(0,0,200,200); pDC->FillSolidRect(rcC,RGB(0,128,0)); } 上面代码在映射后画出的图形将是一个长方形。 DownLoad Sample 最后讲讲视原点(viewport origin),你可以通过调用CPoint CDC::SetViewportOrg( POINT point )重新设置原点的位置,这就相对于对坐标进行了位移。例如你将原点设置在(20,20)那么原来的(0,0)就变成了(-20,-20)。 2.6 多边形和剪贴区域 多边形也是一个GDI对象,同样遵守其他GDI对象的规则,只是通常都不将其选入DC。在MFC多边形有CRgn表示。多边形用来表示一个不同与矩形的区域,和矩形具有相似的操作。如:检测某点是否在内部,并操作等。此外还得到一个包含此多边形的最小矩形。下面介绍一下多边形类的成员函数: • CreateRectRgn 由矩形创建一个多边形 • CreateEllipticRgn 由椭圆创建一个多边形 • CreatePolygonRgn 创建一个有多个点围成的多边形 • PtInRegion 某点是否在内部 • CombineRgn 两个多边形相并 • EqualRgn 两个多边形是否相等 在本节讲演多边形的意义在于重新在窗口作图时提高效率。因为引发窗口重绘的原因是某个区域失效,而失效的区域用多边形来表示。假设窗口大小为500*400当上方的另一个窗口从(0,0,10,10)移动到(20,20,30,30)这时(0,0,10,10)区域就失效了,而你只需要重绘这部分区域而不是所有区域,这样你程序的执行效率就会提高。 通过调用API函数int GetClipRgn( HDC hdc, HRGN hrgn)就可以得到失效区域,但是一般用不着那么精确而只需得到包含该区域的最小矩形就可以了,所以可以利用int CDC::GetClipBox( LPRECT lpRect )完成这一功能。 第三章 文档视结构 3.1 文档 视图 框架窗口间的关系和消息传送规律 在MFCM$引入了文档-视结构的概念,文档相当于数据容器,视相当于查看数据的窗口或是和数据发生交互的窗口。(这一结构在MFC的OLE,ODBC开发时又得到更多的拓展)因此一个完整的应用一般由四个类组成:CWinApp应用类,CFrameWnd窗口框架类,CDocument文档类,CView视类。(VC6支持创建不带文档-视的应用) 在程序运行时CWinApp将创建一个CFrameWnd框架窗口实例,而框架窗口将创建文档模板,然后有文档模板创建文档实例和视实例,并将两者关联。一般来讲我们只需对文档和视进行操作,框架的各种行为已经被MFC安排好了而不需人为干预,这也是M$设计文档-视结构的本意,让我们将注意力放在完成任务上而从界面编写解放出来。 在应用一个视对应一个文档,但一个文档可以包含多个视。一个应用只用一个框架窗口,对多文档界面来讲可能有多个MDI子窗口。每一个视都是一个子窗口,在单文档界面父窗口即是框架窗口,在多文档界面父窗口为MDI子窗口。一个多文档应用可以包含多个文档模板,一个模板定义了一个文档和一个或多个视之间的对应关系。同一个文档可以属于多个模板,但一个模板只允许定义一个文档。同样一个视也可以属于多个文档模板。(不知道我说清楚没有) 接下来看看如何在程序得到各种对象的指针: • 全局函数AfxGetApp可以得到CWinApp应用类指针 • AfxGetApp()->m_pMainWnd为框架窗口指针 • 在框架窗口:CFrameWnd::GetActiveDocument得到当前活动文档指针 • 在框架窗口:CFrameWnd::GetActiveView得到当前活动视指针 • 在视:CView::GetDocument得到对应的文档指针 • 在文档:CDocument::GetFirstViewPosition,CDocument::GetNextView用来遍历所有和文档关联的视。 • 在文档:CDocument::GetDocTemplate得到文档模板指针 • 在多文档界面:CMDIFrameWnd::MDIGetActive得到当前活动的MDI子窗口 一般来讲用户输入消息(如菜单选择,鼠标,键盘等)会先发往视,如果视未处理则会发往框架窗口。所以定义消息映射时定义在视就可以了,如果一个应用同时拥有多个视而当前活动视没有对消息进行处理则消息会发往框架窗口。 3.2 接收用户输入 在视接收鼠标输入: 鼠标消息是我们常需要处理的消息,消息分为:鼠标移动,按钮按下/松开,双击。利用ClassWizard可以轻松的添加这几种消息映射,下面分别讲解每种消息的处理。 WM_MOUSEMOVE对应的函数为OnMouseMove( UINT nFlags, CPoint point ),nFlags表明了当前一些按键的消息,你可以通过“位与”操作进行检测。 • MK_CONTROL Ctrl键是否被按下 Set if the CTRL key is down. • MK_LBUTTON 鼠标左键是否被按下 Set if the left mouse button is down. • MK_MBUTTON 鼠标间键是否被按下 Set if the middle mouse button is down. • MK_RBUTTON 鼠标右键是否被按下 Set if the right mouse button is down. • MK_SHIFT Shift键是否被按下 Set if the SHIFT key is down. point表示当前鼠标的设备坐标,坐标原点对应视左上角。 WM_LBUTTONDOWN/WM_RBUTTONDOWN(鼠标左/右键按下)对应的函数为OnLButtonDown/OnRButtonDown( UINT nFlags, CPoint point )参数意义和OnMouseMove相同。 WM_LBUTTONUP/WM_RBUTTONUP(鼠标左/右键松开)对应的函数为OnLButtonUp/OnRButtonUp( UINT nFlags, CPoint point )参数意义和OnMouseMove相同。 WM_LBUTTONDBLCLK/WM_RBUTTONDBLCLK(鼠标左/右键双击)对应的函数为OnLButtonDblClk/OnRButtonDblClk( UINT nFlags, CPoint point )参数意义和OnMouseMove相同。 下面我用一段伪代码来讲解一下这些消息的用法: 代码的作用是用鼠标拉出一个矩形 global BOOL fDowned;//是否在拉动 global CPoint ptDown;//按下位置 global CPoint ptUp;//松开位置 OnLButtonDown(UINT nFlags, CPoint point) { fDowned=TRUE; ptUp=ptDown=point; DrawRect(); ... } OnMouseMove(UINT nFlags, CPoint point) { if(fDowned) { DrawRect();//恢复上次所画的矩形 ptUp=point; DrawRect();//画新矩形 } } OnLButtonUp(UINT nFlags, CPoint point) { if(fDowned) { DrawRect();//恢复上次所画的矩形 ptUp=point; DrawRect();//画新矩形 fDowned=FALSE; } } DrawRect() {//以反色屏幕的方法画出ptDown,ptUp标记的矩形 CClientDC dc(this); MakeRect(ptDown,ptUp); SetROP(NOT); Rect(); } 坐标间转换:在以上的函数point参数对应的都是窗口的设备坐标,我们应该将设备坐标和逻辑坐标相区别,在图32_g1由于窗口使用了滚动条,所以传入的设备坐标是对应于当前窗口左上角的坐标,没有考虑是否滚动,而逻辑坐标必须考虑滚动后对应的坐标,所以我以黄线虚拟的表达一个逻辑坐标的区域。可以看得出同一点在滚动后的坐标值是不同的,这一规则同样适用于改变了映射方式的窗口,假设你将映射方式设置为每点为0.01毫米,那么设备坐标所对应的逻辑坐标也需要重新计算。进行这种转换需要写一段代码,所幸的是系统提供了进行转换的功能DC的DPtoLP,LPtoDP,下面给出代码完成由设备坐标到逻辑坐标的转换。 图32_g1 CPoint CYourView::FromDP(CPoint point) { CClientDC dc(this); CPoint ptRet=point; dc.PrepareDC();//必须先准备DC,这在使用滚动时让DC重新计算坐标 //如果你作图设置了不同的映射方式,则在下面需要设置 dc.SetMapMode(...) // dc.DPtoLP(&ptRet);//DP->LP进行转换 return ptRet; } 在图32_g1以蓝线标记的是屏幕区域,红线标记的客户区域。利用ScreenToClient,ClientToScreen可以将坐标在这两个区域间转换。 在视接收键盘输入: 键盘消息有三个:键盘被按下/松开,输入字符。其输入字符相当于直接得到用户输入的字符这在不需要处理按键细节时使用,而键盘被按下/松开在按键状态改变时发送。 WM_CHAR对应的函数为OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ),其nChar为被按下的字符,nRepCnt表明在长时间为松开时相当于的按键次数,nFlags的不同位代表不同的含义,在这里一般不使用。 WM_KEYDOWN/WM_KEYUP所对应的函数为OnKeyDown/OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags )nChar代表按键的虚拟码值,如VK_ALT为ALT键,VK_CONTROL为Ctrl键。nFlags各位的含义如下: Value Description 0? Scan code (OEM-dependent value). 8 Extended key, such as a function key or a key on the numeric keypad (1 if it is an extended key). 9?0 Not used. 11?2 Used internally by Windows. 13 Context code (1 if the ALT key is held down while the key is pressed; otherwise 0). 14 Previous key state (1 if the key is down before the call, 0 if the key is up). 15 Transition state (1 if the key is being released, 0 if the key is being pressed). 3.3 使用菜单 利用菜单接受用户命令是一很简单的交互方法,同时也是一种很有效的方法。通常菜单作为一资源存储在文件,因此我们可以在设计时就利用资源编辑器设计好一个菜单。关于使用VC设计菜单我就不再多讲了,但你在编写菜单时应该尽量在属性对话框的底部提示(Prompt)处输入文字,这虽然不是必要的,但MFC在有状态栏和工具条的情况下会使用该文字,文字的格式为“状态栏出说明\n工具条提示”。 图33_g1 我们要面临的任务是如何知道用户何时选择了菜单,他选的是什么菜单项。当用户选择了一个有效的菜单项时系统会向应用发送一个WM_COMMAND消息,在消息的参数表明来源。在MFC我们只需要进行一次映射,将某一菜单ID映射到一处理函数,图33_g2。在这里我们在CView的派生类处理菜单消息,同时我对同一ID设置两个消息映射,接下来将这两种映射的作用。 图33_g2 ON_COMMAND 映射的作用为在用户选择该菜单时调用指定的处理函数。如:ON_COMMAND(IDM_COMMAND1, OnCommand1)会使菜单被选择时调用OnCommand1成员函数。 ON_UPDATE_COMMAND_UI(IDM_COMMAND1, OnUpdateCommand1) 映射的作用是在菜单被显示时通过调用指定的函数来进行确定其状态。在这个处理函数你可以设置菜单的允许/禁止状态,其显示字符串是什么,是否在前面打钩。函数的参数为CCmdUI* pCmdUI,CCmdUI是MFC专门为更新命令提供的一个类,你可以调用 • Enable 设置允许/禁止状态 • SetCheck 设置是否在前面打钩 • SetText 设置文字 下面我讲解一个例子:我在CView派生类有一个变量m_fSelected,并且在视处理两个菜单的消息,当IDM_COMMAND1被选时,对m_fSelected进行逻辑非操作,当IDM_COMMAND2被选时出一提示;同时IDM_COMMAND1根据m_fSelected决定菜单显示的文字和是否在前面打上检查符号,IDM_COMMAND2根据m_fSelected的值决定菜单的允许/禁止状态。下面是代码和说明:下载示例代码 17K void CMenuDView::OnCommand1() { m_fSelected=!m_fSelected; TRACE("command1 selected\n"); } void CMenuDView::OnUpdateCommand1(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_fSelected);//决定检查状态 pCmdUI->SetText(m_fSelected?"当前被选":"当前未被选");//决定所显示的文字 } void CMenuDView::OnUpdateCommand2(CCmdUI* pCmdUI) {//决定是否为允许 pCmdUI->Enable(m_fSelected); } void CMenuDView::OnCommand2() {//选时给出提示 AfxMessageBox("你选了command2"); } 接下来再讲一些通过代码操纵菜单的方法,在MFC有一个类CMenu用来处理和菜单有关的功能。在生成一个CMenu对象时你需要从资源装如菜单,通过调用BOOL CMenu::LoadMenu( UINT nIDResource )进行装入,然后你就可以对菜单进行动态的修改,所涉及到的函数有: • CMenu* GetSubMenu( int nPos ) 一位置得到子菜单的指针,因为一个CMenu对象只能表示一个弹出菜单,如果菜单的某一项也为弹出菜单,就需要通过该函数获取指针。 • BOOL AppendMenu( UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL ) 在末尾添加一项,nFlag为MF_SEPARATOR表示增加一个分隔条,这样其他两个参数将会被忽略;为MF_STRING表示添加一个菜单项uIDNewItem为该菜单的ID命令值;为MF_POPUP表示添加一个弹出菜单项,这时uIDNewItem为另一菜单的句柄HMENU。lpszNewItem为菜单文字说明。 • BOOL InsertMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL )用于在指定位置插入一菜单,位置由变量nPosition指明。如果nFlags包含MF_BYPOSITION则表明插入在nPosition位置,如果包含MF_BYCOMMAND表示插入在命令ID为nPosition的菜单处。 • BOOL ModifyMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL )用于修改某一位置的菜单,如果nFlags包含MF_BYPOSITION则表明修改nPosition位置的菜单,如果包含MF_BYCOMMAND表示修改命令ID为nPosition处的菜单。 • BOOL RemoveMenu( UINT nPosition, UINT nFlags )用于删除某一位置的菜单。如果nFlags包含MF_BYPOSITION则表明删除nPosition位置的菜单,如果包含MF_BYCOMMAND表示删除命令ID为nPosition处的菜单。 • BOOL AppendMenu( UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp ) 和 BOOL InsertMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp )可以添加一位图菜单,但这样的菜单在选时只是反色显示,并不美观。 视图是没有菜单的,在框架窗口才有,所以只有用AfxGetApp()->m_pMainWnd->GetMenu()才能得到应用的菜单指针。 最后我讲一下如何在程序弹出一个菜单,你必须先装入一个菜单资源,你必需得到一个弹出菜单的指针然后调用BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL )弹出菜单,你需要指定(x,y)为菜单弹出的位置,pWnd为接收命令消息的窗口指针。下面有一段代码说明方法,下载示例代码 17K。当然为了处理消息你应该在pWnd指明的窗口对菜单命令消息进行映射。 CMenu menu; menu.LoadMenu(IDR_POPUP); CMenu* pM=menu.GetSubMenu(0); CPoint pt; GetCursorPos(&pt); pM->TrackPopupMenu(TPM_LEFTALIGN,pt.x,pt.y,this); 另一种做法是通过CMenu::CreatePopupMenu()建立一个弹出菜单,然后使用TrackPopupMenu弹出菜单。使用CreatePopupMenu创建的菜单也可以将其作为一个弹出项添加另一个菜单。下面的伪代码演示了如何创建一个弹出菜单并进行修改后弹出: CMenu menu1,menu2; menu1.CreatePopupMenu menu1.InsertMenu(1) menu1.InsertMenu(2) menu1.InsertMenu(3) menu2.CreatePopupMenu menu2.AppendMenu(MF_POPUP,1,menu1.Detach()) 将弹出菜单加入 or InsertMenu... menu2.InsertMenu("string desc"); menu.TrackPopupMenu(...) 3.4 文档,视,框架之间相互作用 一般来说用户的输入/输出基本都是通过视进行,但一些例外的情况下可能需要和框架直接发生作用,而在多视的情况下如何在视之间传递数据。 在使用菜单时大家会发现当一个菜单没有进行映射处理时为禁止状态,在多视的情况下菜单的状态和处理映射是和当前活动视相联系的,这样MFC可以保证视能正确的接收到各种消息,但有时候也会产生不便。有一个解决办法就是在框架对消息进行处理,这样也可以保证当前文档可以通过框架得到当前消息。 在用户进行输入后如何使视的状态得到更新?这个问题在一个文档对应一个视图时是不存在的,但是现在有一个文档对应了两个视图,当在一个视上进行了输入时如何保证另一个视也得到通知呢?MFC的做法是利用文档来处理的,因为文档管理着当前和它联系的视,由它来通知各个视是最合适的。让我们同时看两个函数: • void CView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint ) • void CDocument::UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL ) 当文档的UpdateAllViews被调用时和此文档相关的所有视的OnUpdate都会被调用,而参数lHint和pHint都会被传递。这样一来发生改变视就可以通知其他的兄弟了。那么还有一个问题:如何在OnUpdate知道是那个视图发生了改变呢,这就可以利用pHint参数,只要调用者将this指针赋值给参数就可以了,当然完全可以利用该参数传递更复杂的结构。 视的初始化,当一个文档被打开或是新建一个文档时视图的CView::OnInitialUpdate()会被调用,你可以通过重载该函数对视进行初始化,并在结束前调用父类的OnInitialUpdate,因为这样可以保证OnUpdate会被调用。 文档内容的清除,当文档被关闭时(比如退出或是新建前上一个文档清除)void CDocument::DeleteContents ()会被调用,你可以通过重载该函数来进行清理工作。 在单文档结构上面两点尤其重要,因为软件运行文档对象和视对象只会被产生并删除一次。所以应该将上面两点和C++对象构造和构析分清楚。 最后将一下文档模板(DocTemplate)的作用,文档模板分为两类单文档模板和多文档模板,分别由CSingleDocTemplate和CMultiDocTemplate表示,模板的作用在于记录文档,视,框架之间的对应关系。还有一点就是模板可以记录应用程序可以打开的文件的类型,当打开文件时会根据文档模板的信息选择正确的文档和视。模板是一个比较抽想的概念,一般来说是不需要我们直接进行操作的。 当使用者通过视修改了数据时,应该调用GetDocument()->SetModifiedFlag(TRUE)通知文档数据已经被更新,这样在关闭文档时会自动询问用户是否保存数据。 好象这一节讲的有些乱,大家看后有什么想法和问题请在VCHelp论坛上留言,我会尽快回复并且会对本节内容重新整理和修改。 3.5 利用序列化进行文件读写 在很多应用我们需要对数据进行保存,或是从介质上读取数据,这就涉及到文件的操作。我们可以利用各种文件存取方法完成这些工作,但MFC也提供了一种读写文件的简单方法——“序列化”。序列化机制通过更高层次的接口功能向开发者提供了更利于使用和透明于字节流的文件操纵方法,举一个例来讲你可以将一个字串写入文件而不需要理会具体长度,读出时也是一样。你甚至可以对字符串数组进行操作。在MFC提供的可自动分配内存的类的支持下你可以更轻松的读/写数据。你也可以根据需要编写你自己的具有序列化功能的类。 序列化在最低的层次上应该被需要序列化的类支持,也就是说如果你需要对一个类进行序列化,那么这个类必须支持序列化。当通过序列化进行文件读写时你只需要该类的序列化函数就可以了。 怎样使类具有序列化功能呢?你需要以下的工作: • 该类从CObject派生。 • 在类声明包括DECLARE_SERIAL宏定义。 • 提供一个缺省的构造函数。 • 在类实现Serialze函数 • 使用IMPLEMENT_SERIAL指明类名和版本号 下面的代码建立了一个简单身份证记录的类,同时也能够支持序列化。 in H struct strPID { char szName[10]; char szID[16]; struct strPID* pNext; }; class CAllPID : public CObject { public: DECLARE_SERIAL(CAllPID) CAllPID(); ~CAllPID(); public:// 序列化相关 struct strPID* pHead; //其他的成员函数 void Serialize(CArchive& ar); }; in CPP IMPLEMENT_SERIAL(CAllPID,CObject,1) // version is 1,版本用于读数据时的检测 void CAllPID::Serialize(CArchive& ar) { int iTotal; if(ar.IsStoring()) {//保存数据 iTotal=GetTotalID();//得到链表的记录数量 arr<26;i++) ar<>iTotal; for(int i=0;i26;j++) ar>>*(((BYTE*)pID)+j);//读一个strPID所有的数据 //修改链表 } } } 当然上面的代码很不完整,但已经可以说明问题。这样CAllPID就是一个可以支持序列化的类,并且可以根据记录的数量动态分配内存。在序列化我们使用了CArchive类,该类用于在序列化时提供读写支持,它重载了<>运算符号,并且提供Read和Write函数对数据进行读写。 下面看看如何在文档使用序列化功能,你只需要修改文档类的Serialize(CArchive& ar)函数,并调用各个进行序列化的类的Serial进行数据读写就可以了。当然你也可以在文档类的内部进行数据读写,下面的代码利用序列化功能读写数据: class CYourDoc : public CDocument { void Serialize(CArchive& ar); CString m_szDesc; CAllPID m_allPID; ...... } void CYourDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) {//由于CString对CArchive定义了<>操作符号,所以可以直接利用>>和<< ar<>m_szDesc; } m_allPID.Serialize(ar);//调用数据类的序列化函数 3.6 MFC所提供的各种视类介绍 MFC提供了丰富的视类供开发者使用,下面对各个类进行介绍: CView类是最基本的视类只支持最基本的操作。 CScrollView类提供了滚动的功能,你可以利用void CScrollView::SetScrollSizes( int nMapMode, SIZE sizeTotal, const SIZE& sizePage = sizeDefault, const SIZE& sizeLine = sizeDefault )设置滚动尺寸,和坐标映射模式。但是在绘图和接收用户输入时需要对坐标进行转换。请参见3.2 接收用户输入。 CFormView类提供用户在资源文件定义界面的能力,并可以将子窗口和变量进行绑定。通过UpdateData函数让数据在变量和子窗口间交换。 CTreeView类利用TreeCtrl界面作为视界面,通过调用CTreeCtrl& CTreeView::GetTreeCtrl( ) const得到CTreeCtrl的引用。 CListView类利用ListCtrl界面作为视界面,通过调用CTreeCtrl& CTreeView::GetTreeCtrl( ) const得到CListCtrl的引用。 CEditView类利用Edit接收用户输入,它具有输入框的一切功能。通过调用CEdit& CEditView::GetEditCtrl( ) const得到Edit&的引用。void CEditView::SetPrinterFont( CFont* pFont )可以设置打印字体。 CRichEditView类作为Rich Text Edit(富文本输入)的视类,提供了可以按照格式显示文本的能力,在使用时需要CRichEditDoc的支持。 第四章 窗口控件 4.1 Button 按钮窗口(控件)在MFC使用CButton表示,CButton包含了三种样式的按钮,Push Button,Check Box,Radio Box。所以在利用CButton对象生成按钮窗口时需要指明按钮的风格。 创建按钮:BOOL CButton::Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );其lpszCaption是按钮上显示的文字,dwStyle为按钮风格,除了Windows风格可以使用外(如WS_CHILD|WS_VISUBLE|WS_BORDER)还有按钮专用的一些风格。 • BS_AUTOCHECKBOX 检查框,按钮的状态会自动改变 Same as a check box, except that a check mark appears in the check box when the user selects the box; the check mark disappears the next time the user selects the box. • BS_AUTORADIOBUTTON 圆形选择按钮,按钮的状态会自动改变 Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group. • BS_AUTO3STATE 允许按钮有三种状态即:选,未选,未定 Same as a three-state check box, except that the box changes its state when the user selects it. • BS_CHECKBOX 检查框 Creates a small square that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style). • BS_DEFPUSHBUTTON 默认普通按钮 Creates a button that has a heavy black border. The user can select this button by pressing the ENTER key. This style enables the user to quickly select the most likely option (the default option). • BS_LEFTTEXT 左对齐文字 When combined with a radio-button or check-box style, the text appears on the left side of the radio button or check box. • BS_OWNERDRAW 自绘按钮 Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class. • BS_PUSHBUTTON 普通按钮 Creates a pushbutton that posts a WM_COMMAND message to the owner window when the user selects the button. • BS_RADIOBUTTON 圆形选择按钮 Creates a small circle that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style). Radio buttons are usually used in groups of related but mutually exclusive choices. • BS_3STATE 允许按钮有三种状态即:选,未选,未定 Same as a check box, except that the box can be dimmed as well as checked. The dimmed state typically is used to show that a check box has been disabled. rect为窗口所占据的矩形区域,pParentWnd为父窗口指针,nID为该窗口的ID值。 获取/改变按钮状态:对于检查按钮和圆形按钮可能有两种状态,选和未选,如果设置了BS_3STATE或BS_AUTO3STATE风格就可能出现第三种状态:未定,这时按钮显示灰色。通过调用int CButton::GetCheck( ) 得到当前是否被选,返回0:未选,1:选,2:未定。调用void CButton::SetCheck( int nCheck );设置当前选状态。 处理按钮消息:要处理按钮消息需要在父窗口进行消息映射,映射宏为ON_BN_CLICKED( id, memberFxn )id为按钮的ID值,就是创建时指定的nID值。处理函数原型为afx_msg void memberFxn( ); 4.2 Static Box 静态文本控件的功能比较简单,可作为显示字符串,图标,位图用。创建一个窗口可以使用成员函数: BOOL CStatic::Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff ); 其dwStyle将指明该窗口的风格,除了子窗口常用的风格WS_CHILD,WS_VISIBLE外,你可以针对静态控件指明专门的风格。 • SS_CENTER,SS_LEFT,SS_RIGHT 指明字符显示的对齐方式。 • SS_GRAYRECT 显示一个灰色的矩形 • SS_NOPREFIX 如果指明该风格,对于字符&将直接显示,否则&将作为转义符,&将不显示而在其后的字符将有下划线,如果需要直接显示&必须使用&&表示。 • SS_BITMAP 显示位图 • SS_ICON 显示图标 • SS_CENTERIMAGE 图象居显示 控制显示的文本利用成员函数SetWindowText/GetWindowText用于设置/得到当前显示的文本。 控制显示的图标利用成员函数SetIcon/GetIcon用于设置/得到当前显示的图标。 控制显示的位图利用成员函数SetBitmap/GetBitmap用于设置/得到当前显示的位图。下面一段代码演示如何创建一个显示位图的静态窗口并设置位图 CStatic* pstaDis=new CStatic; pstaDis->Create("",WS_CHILD|WS_VISIBLE|SS_BITMAP|SSCENTERIMAGE, CRect(0,0,40,40),pWnd,1); CBitmap bmpLoad; bmpLoad.LoadBitmap(IDB_TEST); pstaDis->SetBitmap(bmpLoad.Detach()); 4.3 Edit Box Edit窗口是用来接收用户输入最常用的一个控件。创建一个输入窗口可以使用成员函数: BOOL CEdit::Create( LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff ); 其dwStyle将指明该窗口的风格,除了子窗口常用的风格WS_CHILD,WS_VISIBLE外,你可以针对输入控件指明专门的风格。 • ES_AUTOHSCROLL,ES_AUTOVSCROLL 指明输入文字超出显示范围时自动滚动。 • ES_CENTER,ES_LEFT,ES_RIGHT 指定对齐方式 • ES_MULTILINE 是否允许多行输入 • ES_PASSWORD 是否为密码输入框,如果指明该风格则输入的文字显示为* • ES_READONLY 是否为只读 • ES_UPPERCASE,ES_LOWERCASE 显示大写/小写字符 控制显示的文本利用成员函数SetWindowText/GetWindowText用于设置/得到当前显示的文本。 通过GetLimitText/SetLimitText可以得到/设置在输入框输入的字符数量。 由于在输入时用户可能选择某一段文本,所以通过void CEdit::GetSel( int& nStartChar, in
1. Introduction to Zend Framework 1.1. 概述 1.2. 安装 2. Zend_Acl 2.1. 简介 2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) 2.1.4. 注册角色(Role) 2.1.5. 定义访问控制 2.1.6. 查询 ACL 2.2. 精细的访问控制 2.2.1. 精细的访问控制 2.2.2. 除去访问控制 2.3. 高级用法 2.3.1. 保存 ACL 数据确保持久性 2.3.2. 使用声明(Assert)来编写条件性的 ACL 规则 3. Zend_Auth 3.1. 简介 3.1.1. 适配器 3.1.2. 结果 3.1.3. 身份的持久(Persistence) 3.1.3.1. 在PHP Session 的缺省持久(Persistence) 3.1.3.2. 实现订制存储 3.1.4. 使用Zend_Auth 3.2. 数据库表认证 3.2.1. 简介 3.2.2. 高级使用:持久一个 DbTable 结果对象 3.2.3. 高级用法示例 3.3. 摘要式认证 3.3.1. 简介 3.3.2. 规范(Specifics) 3.3.3. 身份(Identity) 3.4. HTTP 认证适配器 3.4.1. 简介 3.4.2. 设计回顾 3.4.3. 配置选项 3.4.4. Resolvers 3.4.4.1. 文件 Resolver 3.4.5. 基本用法 4. Zend_Cache 4.1. 简介 4.2. 缓存原理 4.2.1. Zend_Cache 工厂方法 4.2.2. 标记纪录 4.2.3. 缓存清理 4.3. Zend_Cache前端 4.3.1. Zend_Cache_Core 4.3.1.1. 简介 4.3.1.2. 可用选项 4.3.1.3. 例子 4.3.2. Zend_Cache_Frontend_Output 4.3.2.1. 简介 4.3.2.2. 可用的选项 4.3.2.3. 例子 4.3.3. Zend_Cache_Frontend_Function 4.3.3.1. Introduction 4.3.3.2. A可用的选项 4.3.3.3. 例子 4.3.4. Zend_Cache_Frontend_Class 4.3.4.1. Introduction 4.3.4.2. Available options 4.3.4.3. Examples 4.3.5. Zend_Cache_Frontend_File 4.3.5.1. Introduction 4.3.5.2. Available options 4.3.5.3. Examples 4.3.6. Zend_Cache_Frontend_Page 4.3.6.1. Introduction 4.3.6.2. Available options (for this frontend in Zend_Cache factory) 4.3.6.3. Examples 4.4. Zend_Cache后端 4.4.1. Zend_Cache_Backend_File 4.4.2. Zend_Cache_Backend_Sqlite 4.4.3. Zend_Cache_Backend_Memcached 4.4.4. Zend_Cache_Backend_Apc 4.4.5. Zend_Cache_Backend_ZendPlatform 5. Zend_Config 5.1. 简介 5.2. 操作理论 5.3. Zend_Config_Ini 5.4. Zend_Config_Xml 6. Zend_Console_Getopt 6.1. Getopt 简介 6.2. 声明 Getopt 规则 6.2.1. 用短语法声明选项 6.2.2. 用长语法声明选项 6.3. 读取(Fetching)选项和参数 6.3.1. 操作 Getopt 异常 6.3.2. 通过名字读取 (Fetching)选项 6.3.3. 报告选项 6.3.4. 读取非选项参数 6.4. 配置 Zend_Console_Getopt 6.4.1. 添加选项规则 6.4.2. 添加帮助信息 6.4.3. 添加选项别名 6.4.4. 添加参数列表 6.4.5. 添加配置 7. Zend_Controller 7.1. Zend_Controller 快速入门 7.1.1. 简介 7.1.2. 入门 7.1.2.1. 文件系统的组织结构 7.1.2.2. 设置文件根目录 7.1.2.3. 创建URL重写规则 7.1.2.4. 创建你的bootstrap文件 7.1.2.5. 创建默认的控制器(Action Controller) 7.1.2.6. 创建你的视图脚本 7.1.2.7. 创建你自己的错误控制器 7.1.2.8. 访问站点! 7.2. Zend_Controller 基础 7.3. 前端控制器 7.3.1. 概述 7.3.2. 主要方法 7.3.2.1. getInstance() 7.3.2.2. setControllerDirectory() 和 addControllerDirectory() 7.3.2.3. dispatch() 7.3.2.4. run() 7.3.3. 环境访问器方法 7.3.4. 前端控制器参数 7.3.5. 继承前端控制器 7.4. 请求对象 7.4.1. 介绍 7.4.2. HTTP 请求 7.4.2.1. 访问请求数据 7.4.2.2. 基地址和子目录 7.4.2.3. 决定请求方式 7.4.2.4. 删除 AJAX 请求 7.4.3. 子类化请求对象 7.5. 标准路由器:Zend_Controller_Router_Rewrite 7.5.1. 简介 7.5.2. 使用路由器 7.5.3. 基本的Rewrite路由器操作 7.5.4. 缺省路由 7.5.5. 基本 URL 和子目录 7.5.6. Route Types 7.5.6.1. Zend_Controller_Router_Route 7.5.6.1.1. 变量缺省 7.5.6.1.2. 变量请求 7.5.6.2. Zend_Controller_Router_Route_Static 7.5.6.3. Zend_Controller_Router_Route_Regex 7.5.7. 使用 Zend_Config with the RewriteRouter 7.5.8. Subclassing the Router 7.6. 分发器 7.6.1. 概述 7.6.2. 子类化分发器 7.7. 动作控制器 7.7.1. 简介 7.7.2. 对象初始化 7.7.3. 派遣前后的钩子 7.7.4. 访问器 7.7.5. 视图集成 7.7.5.1. 视图初始化 7.7.5.2. 解析(Rendering)视图 7.7.6. 实用方法 7.7.7. 继承(Subclassing)动作控制器 7.8. 动作助手 7.8.1. 介绍 7.8.2. 初始化助手 7.8.3. 助手经纪人 7.8.4. 内建的动作助手 7.8.4.1. 动作堆栈(助手) 7.8.4.2. AutoComplete 7.8.4.2.1. AutoCompletion with Dojo 7.8.4.2.2. AutoCompletion with Scriptaculous 7.8.4.3. ContextSwitch and AjaxContext 7.8.4.3.1. 缺省可用的上下文 7.8.4.3.2. 创建定制的上下文 7.8.4.3.3. 为每个动作设置上下文 7.8.4.3.4. 初始化上下文开关 7.8.4.3.5. 另外的功能 7.8.4.3.6. AjaxContext 函数 7.8.4.4. FlashMessenger 7.8.4.4.1. 简介 7.8.4.4.2. Basic Usage Example 7.8.4.5. JSON 7.8.4.6. 转向器(Redirector) 7.8.4.6.1. 介绍 7.8.4.6.2. 基础用例 7.8.4.7. ViewRenderer 7.8.4.7.1. 介绍 7.8.4.7.2. API 7.8.4.7.3. 基础用法示例 7.8.4.7.4. 高级用法示例 7.8.5. 编写自己的助手 7.9. 响应对象 7.9.1. 用法 7.9.2. 处理消息头 7.9.3. 命名片段 7.9.4. 在响应对象测试异常 7.9.5. 子类化响应对象 7.10. 插件 7.10.1. 简介 7.10.2. 编写插件 7.10.3. 使用插件 7.10.4. 获取和控制插件 7.10.5. 包含在标准发行包的插件 7.10.5.1. 动作堆栈 7.10.5.2. Zend_Controller_Plugin_ErrorHandler 7.10.5.2.1. 使用 ErrorHandler 作为一个 404 处理器(handler) 7.10.5.2.2. 处理以前呈现的(rendered)输出 7.10.5.2.3. 插件用法示例 7.10.5.2.4. 错误控制器示例 7.11. 使用传统的模块目录结构 7.11.1. 简介 7.11.2. 指定模块控制器目录 7.11.3. Routing to modules 7.11.4. 模块或全局缺省控制器 7.12. MVC 异常 7.12.1. 介绍 7.12.2. 如何处理异常? 7.12.3. 可能遭遇的MVC异常 7.13. 从以前的版本移植 7.13.1. 从 1.0.x 到 1.5.0 或更新的版本的移植 7.13.2. 从 0.9.3 到 1.0.0RC1 或更新的版本的移植 7.13.3. 从 0.9.2 移植到 0.9.3 或更新的版本 7.13.4. 从 0.6.0 移植到 0.8.0 或更新的版本 7.13.5. 从 0.2.0 或以前的版本移植到 0.6.0 8. Zend_Currency 8.1. Zend_Currency 简介 8.1.1. 为什么使用 Zend_Currency ? 8.2. 如何使用货币 8.2.1. 从货币创建输出 8.2.2. 修改货币格式 8.2.3. Zend_Currency 的信息方法 8.2.4. 设置新缺省值 8.2.5. 加速 Zend_Currency 8.3. 从前面的版本迁移 8.3.1. 从 1.0.2 到 1.0.3 或更新的迁移 9. Zend_Date 9.1. Introduction 9.1.1. Always Set a Default Timezone 9.1.2. Why Use Zend_Date? 9.2. 操作理论 9.2.1. 内部(Internals) 9.3. Basic Methods 9.3.1. The current date 9.3.2. Zend_Date by Example 9.3.2.1. Ouput a Date 9.3.2.2. Setting a Date 9.3.2.3. Adding and Subtracting Dates 9.3.2.4. Comparation of dates 9.4. Zend_Date API Overview 9.4.1. Zend_Date Options 9.4.1.1. Selecting the date format type 9.4.1.2. DST and Date Math 9.4.1.3. Month Calculations 9.4.1.4. Speed up date localization and normalization with Zend_Cache 9.4.1.5. Receiving syncronised timestamps with Zend_TimeSync 9.4.2. Working with Date Values 9.4.3. Basic Zend_Date Operations Common to Many Date Parts 9.4.3.1. List of Date Parts 9.4.3.2. List of Date Operations 9.4.4. Comparing Dates 9.4.5. Getting Dates and Date Parts 9.4.6. Working with Fractions of Seconds 9.4.7. Sunrise / Sunset 9.5. Creation of dates 9.5.1. Create the actual date 9.5.2. Create a date from database 9.5.3. Create dates from an array 9.6. Constants for General Date Functions 9.6.1. Using Constants 9.6.2. List of All Constants 9.6.3. Self-Defined OUTPUT Formats with ISO 9.6.4. Self-defined OUTPUT formats using PHP's date() format specifiers 9.7. Working examples 9.7.1. Checking dates 9.7.2. Sunrise and Sunset 9.7.3. Timezones 10. Zend_Db 10.1. Zend_Db_Adapter 10.1.1. 简介 10.1.2. 添加引号防止数据库攻击 10.1.3. 直接查询 10.1.4. 事务处理 10.1.5. 插入数据行 10.1.6. 更新数据行 10.1.7. 删除数据行 10.1.8. 取回查询结果 10.2. Zend_Db_Statement 10.2.1. Creating a Statement 10.2.2. Executing a Statement 10.2.3. Fetching Results from a SELECT Statement 10.2.3.1. Fetching a Single Row from a Result Set 10.2.3.2. Fetching a Complete Result Set 10.2.3.3. Changing the Fetch Mode 10.2.3.4. Fetching a Single Column from a Result Set 10.2.3.5. Fetching a Row as an Object 10.3. Zend_Db_Profiler 10.3.1. Introduction 10.3.2. Using the Profiler 10.3.3. Advanced Profiler Usage 10.3.3.1. Filter by query elapsed time 10.3.3.2. Filter by query type 10.3.3.3. Retrieve profiles by query type 10.4. Zend_Db_Select 10.4.1. 简介 10.4.2. 同一表查询多列数据 10.4.3. 多表联合查询 10.4.4. WHERE条件 10.4.5. GROUP BY分句 10.4.6. HAVING 条件 10.4.7. ORDER BY 分句 10.4.8. 通过总数和偏移量进行LIMIT限制 10.4.9. 通过页数和总数进行LIMIT限制 10.5. Zend_Db_Table 10.5.1. 简介 10.5.2. 开始 10.5.3. 表名和主键 10.5.4. 插入数据 10.5.5. 更新数据 10.5.6. Deleting Rows 10.5.7. 根据主键查找数据 10.5.8. 取回一条记录 10.5.9. 取回多条记录 10.5.10. Adding Domain Logic 10.6. Zend_Db_Table_Row 10.6.1. 简介 10.6.2. 取回一条记录 10.6.3. 修改数据 10.7. Zend_Db_Table_Rowset 10.7.1. 简介 10.7.2. 取回结果集 10.7.3. 遍历结果集 10.8. Zend_Db_Table Relationships 10.8.1. Introduction 10.8.2. Defining Relationships 10.8.3. Fetching a Dependent Rowset 10.8.4. Fetching a Parent Row 10.8.5. Fetching a Rowset via a Many-to-many Relationship 10.8.6. Cascading Write Operations 10.8.6.1. Notes Regarding Cascading Operations 11. Zend_Debug 11.1. 输出变量的值 (Dumping Variables) 12. Zend_Exception 12.1. 使用“异常” 13. Zend_Feed 13.1. 介绍 13.2. 导入Feeds 13.2.1. 定制 feeds 13.2.1.1. 导入定制的数组 13.2.1.2. 导入定制的数据源 13.2.1.3. Dumping feed 内容 13.3. 从网页上获得Feed 13.4. RSS Feed的使用 13.5. Atom Feed的使用 13.6. 单个Atom条目的处理 13.7. 修改Feed和条目结构 13.8. 自定义Feed和条目类 14. Zend_Filter 14.1. 简介 14.1.1. 什么是过滤器(filter)? 14.1.2. 过滤器的基本用法 14.1.3. 使用静态 get() 方法 14.2. 标准过滤器类 14.2.1. Alnum 14.2.2. Alpha 14.2.3. BaseName 14.2.4. Digits 14.2.5. Dir 14.2.6. HtmlEntities 14.2.7. Int 14.2.8. RealPath 14.2.9. StringToLower 14.2.10. StringToUpper 14.2.11. StringTrim 14.2.12. StripTags 14.3. 过滤器链 14.4. 编写过滤器 14.5. Zend_Filter_Input 14.5.1. Declaring Filter and Validator Rules 14.5.2. Creating the Filter and Validator Processor 14.5.3. Retrieving Validated Fields and other Reports 14.5.3.1. Querying if the input is valid 14.5.3.2. Getting Invalid, Missing, or Unknown Fields 14.5.3.3. Getting Valid Fields 14.5.4. Using Metacommands to Control Filter or Validator Rules 14.5.4.1. The FIELDS metacommand 14.5.4.2. The PRESENCE metacommand 14.5.4.3. The DEFAULT_VALUE metacommand 14.5.4.4. The ALLOW_EMPTY metacommand 14.5.4.5. The BREAK_CHAIN metacommand 14.5.4.6. The MESSAGES metacommand 14.5.4.7. Using options to set metacommands for all rules 14.5.5. Adding Filter Class Namespaces 14.6. Zend_Filter_Inflector 14.6.1. Operation 14.6.2. Setting Paths To Alternate Filters 14.6.3. Setting the Inflector Target 14.6.4. Inflection Rules 14.6.4.1. Static Rules 14.6.4.2. Filter Inflector Rules 14.6.4.3. Setting Many Rules At Once 14.6.5. Utility Methods 14.6.6. Using Zend_Config with Zend_Filter_Inflector 15. Zend_Form 15.1. Zend_Form 15.2. Zend_Form 快速起步 15.2.1. 创建表单对象 15.2.2. 添加表单元素 15.2.3. 解析(Render)表单 15.2.4. 检查表单是否有效 15.2.5. 获得错误状态 15.2.6. 放到一起 15.2.7. 使用 Zend_Config 对象 15.2.8. 结论 15.3. 使用 Zend_Form_Element 生成表单元素 15.3.1. 插件加载器 15.3.2. 过滤器 15.3.3. 校验器 15.3.4. 装饰器 15.3.5. 元数据和属性 15.3.6. 标准元素 15.3.7. Zend_Form_Element 方法 15.3.8. 配置 15.3.9. 定制元素 15.4. 使用 Zend_Form 生成表单 15.4.1. 插件加载器 15.4.2. 元素(Elements) 15.4.2.1. 组装和读取数值 15.4.2.2. 全局操作 15.4.2.3. 和元素交互使用的方法 15.4.3. 显示组(Display Groups) 15.4.3.1. 全局操作 15.4.3.2. 使用定制的显示组类 15.4.3.3. 和显示组交互使用的方法 15.4.3.4. Zend_Form_DisplayGroup 方法 15.4.4. 子表单 15.4.4.1. 全局操作 15.4.4.2. 和子表单交互使用的方法 15.4.5. 元数据(Metadata)和属性(Attributes) 15.4.6. 装饰器 15.4.7. 校验 15.4.8. 方法 15.4.9. 配置 15.4.10. 定制表单 15.5. 使用 Zend_Form_Decorator 生成定制的表单标识(Markup) 15.5.1. 操作 15.5.2. 标准装饰器 15.5.3. 定制装饰器 15.6. Zend Framework 带有的标准表单元素 15.6.1. Zend_Form_Element_Button 15.6.2. Zend_Form_Element_Checkbox 15.6.3. Zend_Form_Element_Hidden 15.6.4. Zend_Form_Element_Hash 15.6.5. Zend_Form_Element_Image 15.6.6. Zend_Form_Element_MultiCheckbox 15.6.7. Zend_Form_Element_Multiselect 15.6.8. Zend_Form_Element_Password 15.6.9. Zend_Form_Element_Radio 15.6.10. Zend_Form_Element_Reset 15.6.11. Zend_Form_Element_Select 15.6.12. Zend_Form_Element_Submit 15.6.13. Zend_Form_Element_Text 15.6.14. Zend_Form_Element_Textarea 15.7. Zend Framework 带有的标准表单装饰器(Decorators) 15.7.1. Zend_Form_Decorator_Callback 15.7.2. Zend_Form_Decorator_Description 15.7.3. Zend_Form_Decorator_DtDdWrapper 15.7.4. Zend_Form_Decorator_Errors 15.7.5. Zend_Form_Decorator_Fieldset 15.7.6. Zend_Form_Decorator_Form 15.7.7. Zend_Form_Decorator_FormElements 15.7.8. Zend_Form_Decorator_HtmlTag 15.7.9. Zend_Form_Decorator_Image 15.7.10. Zend_Form_Decorator_Label 15.7.11. Zend_Form_Decorator_ViewHelper 15.7.12. Zend_Form_Decorator_ViewScript 15.8. Zend_Form 的国际化 15.8.1. 在表单初始化 I18n 15.8.2. 标准 I18N 目标 15.9. Zend_Form 的高级用法 15.9.1. 数组符号(Notation) 15.9.2. 多页表单 16. Zend_Gdata 16.1. Introduction to Gdata 16.1.1. Structure of Zend_Gdata 16.1.2. Interacting with Google Services 16.1.3. Obtaining instances of Zend_Gdata classes 16.1.4. Google Data Client Authentication 16.1.5. Dependencies 16.1.6. Creating a new Gdata client 16.1.7. Common query parameters 16.1.8. Fetching a feed 16.1.9. Working with multi-page feeds 16.1.10. Working with data in feeds and entries 16.1.11. Updating entries 16.1.12. Posting entries to Google servers 16.1.13. Deleting entries on Google servers 16.2. Authenticating with AuthSub 16.2.1. Creating an AuthSub authenticated Http Client 16.2.2. Revoking AuthSub authentication 16.3. Authenticating with ClientLogin 16.3.1. Creating a ClientLogin authenticated Http Client 16.3.2. Terminating a ClientLogin authenticated Http Client 16.4. Using Google Calendar 16.4.1. Connecting To The Calendar Service 16.4.1.1. Authentication 16.4.1.2. Creating A Service Instance 16.4.2. Retrieving A Calendar List 16.4.3. Retrieving Events 16.4.3.1. Queries 16.4.3.2. Retrieving Events In Order Of Start Time 16.4.3.3. Retrieving Events In A Specified Date Range 16.4.3.4. Retrieving Events By Fulltext Query 16.4.3.5. Retrieving Individual Events 16.4.4. Creating Events 16.4.4.1. Creating Single-Occurrence Events 16.4.4.2. Event Schedules and Reminders 16.4.4.3. Creating Recurring Events 16.4.4.4. Using QuickAdd 16.4.5. Modifying Events 16.4.6. Deleting Events 16.4.7. Accessing Event Comments 16.5. Using Google Documents List Data API 16.5.1. Get a List of Documents 16.5.2. Upload a Document 16.5.3. Searching the documents feed 16.5.3.1. Get a List of Word Processing Documents 16.5.3.2. Get a List of Spreadsheets 16.5.3.3. Performing a text query 16.6. Using Google Spreadsheets 16.6.1. Create a Spreadsheet 16.6.2. Get a List of Spreadsheets 16.6.3. Get a List of Worksheets 16.6.4. Interacting With List-based Feeds 16.6.4.1. Get a List-based Feed 16.6.4.2. Reverse-sort Rows 16.6.4.3. Send a Structured Query 16.6.4.4. Add a Row 16.6.4.5. Edit a Row 16.6.4.6. Delete a Row 16.6.5. Interacting With Cell-based Feeds 16.6.5.1. Get a Cell-based Feed 16.6.5.2. Send a Cell Range Query 16.6.5.3. Change Contents of a Cell 16.7. Using Google Apps Provisioning 16.7.1. Setting the current domain 16.7.1.1. Setting the domain for the service class 16.7.1.2. Setting the domain for query classes 16.7.2. Interacting with users 16.7.2.1. Creating a user account 16.7.2.2. Retrieving a user account 16.7.2.3. Retrieving all users in a domain 16.7.2.4. Updating a user account 16.7.2.4.1. Resetting a user's password 16.7.2.4.2. Forcing a user to change their password 16.7.2.4.3. Suspending a user account 16.7.2.4.4. Granting administrative rights 16.7.2.5. Deleting user accounts 16.7.3. Interacting with nicknames 16.7.3.1. Creating a nickname 16.7.3.2. Retrieving a nickname 16.7.3.3. Retrieving all nicknames for a user 16.7.3.4. Retrieving all nicknames in a domain 16.7.3.5. Deleting a nickname 16.7.4. Interacting with email lists 16.7.4.1. Creating an email list 16.7.4.2. Retrieving all email lists to which a recipient is subscribed 16.7.4.3. Retrieving all email lists in a domain 16.7.4.4. Deleting an email list 16.7.5. Interacting with email list recipients 16.7.5.1. Adding a recipient to an email list 16.7.5.2. Retrieving the list of subscribers to an email list 16.7.5.3. Removing a recipient from an email list 16.7.6. Handling errors 16.8. Using Google Base 16.8.1. Connect To The Base Service 16.8.1.1. Authentication 16.8.1.2. Create A Service Instance 16.8.2. Retrieve Items 16.8.2.1. Send a Structured Query 16.8.2.1.1. Query Customer Items Feed 16.8.2.1.2. Query Snippets Feed 16.8.2.2. Iterate through the Items 16.8.3. Insert, Update, and Delete Customer Items 16.8.3.1. Insert an Item 16.8.3.2. Modify an Item 16.8.3.3. Delete an Item 16.9. Using the YouTube data API 16.9.1. Retrieving video feeds 16.9.1.1. Searching for videos by metadata 16.9.1.2. Searching for videos by categories and tags/keywords 16.9.1.3. Retrieving standard feeds 16.9.1.4. Retrieving videos uploaded by a user 16.9.1.5. Retrieving videos favorited by a user 16.9.1.6. Retrieving video responses for a video 16.9.2. Retrieving video comments 16.9.3. Retrieving playlist feeds 16.9.3.1. Retrieving the playlists of a user 16.9.3.2. Retrieving a specific playlist 16.9.4. Retrieving a list of a user's subscriptions 16.9.5. Retrieving a user's profile 16.10. Using Picasa Web Albums 16.10.1. Connecting To The Service 16.10.1.1. Authentication 16.10.1.2. Creating A Service Instance 16.10.2. Understanding and Constructing Queries 16.10.3. Retrieving Feeds And Entries 16.10.3.1. Retrieving A User 16.10.3.2. Retrieving An Album 16.10.3.3. Retrieving A Photo 16.10.3.4. Retrieving A Comment 16.10.3.5. Retrieving A Tag 16.10.4. Creating Entries 16.10.4.1. Creating An Album 16.10.4.2. Creating A Photo 16.10.4.3. Creating A Comment 16.10.4.4. Creating A Tag 16.10.5. Deleting Entries 16.10.5.1. Deleting An Album 16.10.5.2. Deleting A Photo 16.10.5.3. Deleting A Comment 16.10.5.4. Deleting A Tag 16.10.5.5. Optimistic Concurrency (Notes On Deletion) 16.11. Catching Gdata Exceptions 17. Zend_Http 17.1. Zend_Http_Client 17.1.1. 简介 17.1.2. 带有指定的HTTP头的基本 GET 请求 17.1.3. 发送请求到多个域名 17.1.4. 改变HTTP timeout时间 17.1.5. 动态指定HTTP Header 17.1.6. 构造 HTTP POST, PUT, 和 DELETE 请求 17.2. Zend_Http_Client - Advanced Usage 17.2.1. HTTP Redirections 17.2.2. Adding Cookies and Using Cookie Persistence 17.2.3. Setting Custom Request Headers 17.2.4. File Uploads 17.2.5. Sending Raw POST Data 17.2.6. HTTP Authentication 17.2.7. Sending Multiple Requests With the Same Client 17.3. Zend_Http_Client - Connection Adapters 17.3.1. Overview 17.3.2. The Socket Adapter 17.3.3. The Proxy Adapter 17.3.4. The Test Adapter 17.3.5. Creating your own connection adapters 17.4. Zend_Http_Cookie and Zend_Http_CookieJar 17.4.1. Introduction 17.4.2. Instantiating Zend_Http_Cookie Objects 17.4.3. Zend_Http_Cookie getter methods 17.4.4. Zend_Http_Cookie: Matching against a scenario 17.4.5. The Zend_Http_CookieJar Class: Instantiation 17.4.6. Adding Cookies to a Zend_Http_CookieJar object 17.4.7. Retrieving Cookies From a Zend_Http_CookieJar object 17.5. Zend_Http_Response 17.5.1. 简介 18. Zend_Json 18.1. 简介 18.2. 基本用法 18.3. JSON 对象 18.4. XML 到 JSON 转换 19. Zend_Layout 19.1. 简介 19.2. Zend_Layout 快速入门 19.2.1. 布局脚本 19.2.2. 和Zend Framework MVC一起使用 Zend_Layout 19.2.3. 使用Zend_Layout做为独立的组件 19.2.4. 尝试一下布局 19.3. Zend_Layout 配置选项 19.3.1. 范例 19.4. Zend_Layout 高级用法 19.4.1. 定制视图对象 19.4.2. 定制前端控制器插件 19.4.3. 定制动作助手 19.4.4. 定制布局脚本路径解析(Resolution):使用变形器(Inflector) 20. Zend_Loader 20.1. 动态加载文件和类 20.1.1. 加载文件 20.1.2. 加载类 20.1.3. 判定某个文件是否可读 20.1.4. 使用 Autoloader 20.2. 加载插件 20.2.1. 基本用例 20.2.2. 处理插件路径 20.2.3. 测试插件和获取类的名字 21. Zend_Locale 21.1. Introduction 21.1.1. What is Localization 21.1.2. What is a Locale? 21.1.3. How are Locales Represented? 21.1.4. Selecting the Right Locale 21.1.5. Usage of automatic Locales 21.1.6. Using a default Locale 21.1.7. ZF Locale-Aware Classes 21.1.8. Zend_Locale_Format::setOptions(array $options) 21.1.9. Speed up Zend_Locale and it's subclasses 21.2. Using Zend_Locale 21.2.1. Copying, Cloning, and Serializing Locale Objects 21.2.2. Equality 21.2.3. Default locales 21.2.4. Set a new locale 21.2.5. Getting the language and region 21.2.6. Obtaining localized strings 21.2.7. Obtaining translations for "yes" and "no" 21.2.8. Get a list of all known locales 21.3. Normalization and Localization 21.3.1. Number normalization: getNumber($input, Array $options) 21.3.1.1. Precision and Calculations 21.3.2. Number localization 21.3.3. Number testing 21.3.4. Float value normalization 21.3.5. Floating point value localization 21.3.6. Floating point value testing 21.3.7. Integer value normalization 21.3.8. Integer point value localization 21.3.9. Integer value testing 21.3.10. Numeral System Conversion 21.3.10.1. List of supported numeral systems 21.4. Working with Dates and Times 21.4.1. Normalizing Dates and Times 21.4.2. Testing Dates 21.4.3. Normalizing a Time 21.4.4. Testing Times 21.5. Supported Languages for Locales 21.6. Supported Regions for Locales 22. Zend_Log 22.1. 概述 22.1.1. 创建Log 22.1.2. 日志消息 22.1.3. 销毁Log 22.1.4. 使用内建的消息等级 22.1.5. 添加用户定义的日志等级 22.1.6. 理解日志事件 22.2. Writers 22.2.1. 写入到流(Streams) 22.2.2. 写入到数据库 22.2.3. 踩熄Writer 22.2.4. 测试 Mock 22.2.5. 组合Writers 22.3. Formatters 22.3.1. 简单格式化 22.3.2. 格式化到XML 22.4. 过滤器 22.4.1. 对所有Writer过滤 22.4.2. 过滤一个Writer实例 23. Zend_Mail 23.1. 简介 23.1.1. 起步 23.1.2. 配置缺省的 sendmail 传送器(transport) 23.2. 通过SMTP发送邮件 23.3. 通过一个SMTP连接发送多个邮 23.4. 使用不同的Transport对象 23.5. HTML邮件 23.6. 附件 23.7. 增加收件人 23.8. 控制MIME分界线 23.9. 外加邮件头信息 23.10. 字符集 23.11. 编码 23.12. SMTP 身份验证 23.13. Securing SMTP Transport 23.14. Reading Mail Messages 23.14.1. Simple example using Pop3 23.14.2. Opening a local storage 23.14.3. Opening a remote storage 23.14.4. Fetching messages and simple methods 23.14.5. Working with messages 23.14.6. Checking for flags 23.14.7. Using folders 23.14.8. Advanced Use 23.14.8.1. Using NOOP 23.14.8.2. Caching instances 23.14.8.3. Extending Protocol Classes 23.14.8.4. Using Quota (since 1.5) 24. Zend_Measure 24.1. Introduction 24.2. Creation of Measurements 24.2.1. Creating measurements from integers and floats 24.2.2. Creating measurements from strings 24.2.3. Measurements from localized strings 24.3. Outputting measurements 24.3.1. Automatic output 24.3.2. Outputting values 24.3.3. Output with unit of measurement 24.3.4. Output as localized string 24.4. Manipulating Measurements 24.4.1. Convert 24.4.2. Add and subtract 24.4.3. Compare 24.4.4. Compare 24.4.5. Manually change values 24.4.6. Manually change types 24.5. Types of measurements 24.5.1. Hints for Zend_Measure_Binary 24.5.2. Hints for Zend_Measure_Number 24.5.3. Roman numbers 25. Zend_Memory 25.1. 概述 25.1.1. 简介 25.1.2. 操作原理 25.1.2.1. 内存管理器 25.1.2.2. 内存容器 25.1.2.3. 锁定的内存 25.1.2.4. 可移动内存 25.2. 内存管理器 25.2.1. 创建一个内存管理器 25.2.2. 管理内存对象 25.2.2.1. 创建可移动的对象 25.2.2.2. 创建锁定的对象 25.2.2.3. 销毁对象 25.2.3. 内存管理器设置 25.2.3.1. 内存限制 25.2.3.2. MinSize 25.3. 内存对象 25.3.1. 可移动的 25.3.2. 锁定的 25.3.3. 内存容器 '值' 属性. 25.3.4. 内存容器接口 25.3.4.1. getRef() 方法 25.3.4.2. touch() 方法 25.3.4.3. lock() 方法 25.3.4.4. unlock() 方法 25.3.4.5. isLocked() 方法 26. Zend_Mime 26.1. Zend_Mime 26.1.1. 简介 26.1.2. 静态方法和常量 26.1.3. 实例化Zend_Mime 26.2. Zend_Mime_Message 26.2.1. 简介 26.2.2. 实例化 26.2.3. 增加MIME消息段 26.2.4. 分界线处理 26.2.5. 解析字符串,创建Zend_Mime_Message对象(实验性的) 26.3. Zend_Mime_Part 26.3.1. 简介 26.3.2. 实例化 26.3.3. 解析(rendering)消息段为字符串的方法 27. Zend_Pdf 27.1. 简介 27.2. 生成和加载 PDF 文档 27.3. 保存修改到 PDF 文档 27.4. 文档页面 27.4.1. 页面生成 27.4.2. 页面克隆 27.5. Drawing. 27.5.1. Geometry. 27.5.2. Colors. 27.5.3. Shape Drawing. 27.5.4. Text Drawing. 27.5.5. Using fonts. 27.5.6. Starting in 1.5, Extracting fonts. 27.5.7. Image Drawing. 27.5.8. Line drawing style. 27.5.9. Fill style. 27.5.10. Rotations. 27.5.11. Save/restore graphics state. 27.5.12. Clipping draw area. 27.5.13. Styles. 27.6. Zend_Pdf module usage example. 28. Zend_Registry 28.1. 使用对象注册表(Registry) 28.1.1. 设置Registry的值 28.1.2. 获取Registry的值 28.1.3. 创建一个Registry对象 28.1.4. 像访问数组一样访问Registry对象 28.1.5. 对象方式访问Registry 28.1.6. 查询一个索引是否存在 28.1.7. 扩展Registry对象 28.1.8. 删除静态注册表 29. Zend_Rest 29.1. Introduction 29.2. Zend_Rest_Client 29.2.1. Introduction 29.2.2. Responses 29.2.3. Request Arguments 29.3. Zend_Rest_Server 29.3.1. Introduction 29.3.2. REST Server Usage 29.3.3. Calling a Zend_Rest_Server Service 29.3.4. Sending A Custom Status 29.3.5. Returning Custom XML Responses 30. Zend_Search_Lucene 30.1. 概述 30.1.1. 简介 30.1.2. 文档和字段对象 30.1.3. 理解字段类型 30.2. 建立索引 30.2.1. 创建新索引 30.2.2. 更新索引 30.3. 搜索索引 30.3.1. 建立查询 30.3.2. 搜索结果 30.3.3. 结果评分 30.4. Query Language 30.4.1. Terms 30.4.2. Fields 30.4.3. Starting in 1.5, Wildcards 30.4.4. Term Modifiers 30.4.5. Starting in 1.5, Range Searches 30.4.6. Starting in 1.5, Fuzzy Searches 30.4.7. Proximity Searches 30.4.8. Boosting a Term 30.4.9. Boolean Operators 30.4.9.1. AND 30.4.9.2. OR 30.4.9.3. NOT 30.4.9.4. &&, ||, and ! operators 30.4.9.5. + 30.4.9.6. - 30.4.9.7. No Operator 30.4.10. Grouping 30.4.11. Field Grouping 30.4.12. Escaping Special Characters 30.5. 查询类型 30.5.1. 单项查询 30.5.2. 多项查询 30.5.3. 短语查询 30.6. 字符集 30.6.1. UTF-8 和单字节字符集支持 30.7. 扩展性 30.7.1. 文本分析 30.7.2. 评分算法 30.7.3. 存储容器 30.8. 与 Java Lucene 的互操作性 30.8.1. 文件格式 30.8.2. 索引目录 30.8.3. Java 源代码 30.9. Advanced 30.9.1. Using the index as static property 30.10. Best Practices 30.10.1. Field names 30.10.2. Indexing performance 30.10.3. Index during Shut Down 30.10.4. Retrieving documents by unique id 30.10.5. Memory Usage 30.10.6. Encoding 30.10.7. Index maintenance 31. Zend_Server 31.1. 简介 31.2. Zend_Server_Reflection 31.2.1. 简介 31.2.2. 用法 32. Zend_Service 32.1. 简介 32.2. Zend_Service_Akismet 32.2.1. Introduction 32.2.2. Verify an API key 32.2.3. Check for spam 32.2.4. Submitting known spam 32.2.5. Submitting false positives (ham) 32.2.6. Zend-specific Accessor Methods 32.3. Zend_Service_Amazon 32.3.1. Introduction 32.3.2. Country Codes 32.3.3. Looking up a Specific Amazon Item by ASIN 32.3.4. Performing Amazon Item Searches 32.3.5. Using the Alternative Query API 32.3.5.1. Introduction 32.3.6. Zend_Service_Amazon Classes 32.3.6.1. Zend_Service_Amazon_Item 32.3.6.1.1. Zend_Service_Amazon_Item::asXML() 32.3.6.1.2. Properties 32.3.6.2. Zend_Service_Amazon_Image 32.3.6.2.1. Properties 32.3.6.3. Zend_Service_Amazon_ResultSet 32.3.6.3.1. Zend_Service_Amazon_ResultSet::totalResults() 32.3.6.4. Zend_Service_Amazon_OfferSet 32.3.6.4.1. Properties 32.3.6.5. Zend_Service_Amazon_Offer 32.3.6.5.1. Zend_Service_Amazon_Offer Properties 32.3.6.6. Zend_Service_Amazon_SimilarProduct 32.3.6.6.1. Properties 32.3.6.7. Zend_Service_Amazon_Accessories 32.3.6.7.1. Properties 32.3.6.8. Zend_Service_Amazon_CustomerReview 32.3.6.8.1. Properties 32.3.6.9. Zend_Service_Amazon_EditorialReview 32.3.6.9.1. Properties 32.3.6.10. Zend_Service_Amazon_Listmania 32.3.6.10.1. Properties 32.4. Zend_Service_Audioscrobbler 32.4.1. Introduction to Searching Audioscrobbler 32.4.2. Users 32.4.3. Artists 32.4.4. Tracks 32.4.5. Tags 32.4.6. Groups 32.4.7. Forums 32.5. Zend_Service_Delicious 32.5.1. Introduction 32.5.2. Retrieving posts 32.5.3. Zend_Service_Delicious_PostList 32.5.4. Editing posts 32.5.5. Deleting posts 32.5.6. Adding new posts 32.5.7. Tags 32.5.8. Bundles 32.5.9. Public data 32.5.9.1. Public posts 32.5.10. HTTP client 32.6. Zend_Service_Flickr 32.6.1. 对Flickr搜索的介绍 32.6.2. 查找 Flickr 用户 32.6.3. 获得 Flickr 图像详细资料 32.6.4. Zend_Service_Flickr 类 32.6.4.1. Zend_Service_Flickr_ResultSet 32.6.4.1.1. 属性 32.6.4.1.2. Zend_Service_Flickr_ResultSet::totalResults() 32.6.4.2. Zend_Service_Flickr_Result 32.6.4.2.1. 属性 32.6.4.3. Zend_Service_Flickr_Image 32.6.4.3.1. 属性 32.7. Zend_Service_Simpy 32.7.1. Introduction 32.7.2. Links 32.7.3. Tags 32.7.4. Notes 32.7.5. Watchlists 32.8. Zend_Service_StrikeIron 32.8.1. Overview 32.8.2. Registering with StrikeIron 32.8.3. Getting Started 32.8.4. Making Your First Query 32.8.5. Examining Results 32.8.6. Handling Errors 32.8.7. Checking Your Subscription 32.9. Zend_Service_StrikeIron: Bundled Services 32.9.1. ZIP Code Information 32.9.2. U.S. Address Verification 32.9.3. Sales & Use Tax Basic 32.10. Zend_Service_StrikeIron: Advanced Uses 32.10.1. Using Services by WSDL 32.10.2. Viewing SOAP Transactions 32.11. Zend_Service_Yahoo 32.11.1. 简介 32.11.2. 用Yahoo!来搜索网页 32.11.3. 用Yahoo!来查找图片 32.11.4. Finding Local Businesses and Services with Yahoo! 32.11.5. 搜索Yahoo! 新闻 32.11.6. Zend_Service_Yahoo 类 32.11.6.1. Zend_Service_Yahoo_ResultSet 32.11.6.1.1. Zend_Service_Yahoo_ResultSet::totalResults() 32.11.6.1.2. Properties 32.11.6.2. Zend_Service_Yahoo_WebResultSet 32.11.6.3. Zend_Service_Yahoo_ImageResultSet 32.11.6.4. Zend_Service_Yahoo_LocalResultSet 32.11.6.5. Zend_Service_Yahoo_NewsResultSet 32.11.6.6. Zend_Service_Yahoo_Result 32.11.6.6.1. Properties 32.11.6.7. Zend_Service_Yahoo_WebResult 32.11.6.7.1. 属性 32.11.6.8. Zend_Service_Yahoo_ImageResult 32.11.6.8.1. 属性 32.11.6.9. Zend_Service_Yahoo_LocalResult 32.11.6.9.1. 属性 32.11.6.10. Zend_Service_Yahoo_NewsResult 32.11.6.10.1. 属性 32.11.6.11. Zend_Service_Yahoo_Image 32.11.6.11.1. Properties 33. Zend_Session 33.1. 简介 33.2. 基本用法 33.2.1. 实例教程 33.2.2. 迭代会话命名空间 33.2.3. 会话命名空间的访问器 33.3. 高级用法 33.3.1. 开启会话 33.3.2. 锁住会话命名空间 33.3.3. 命名空间过期 33.3.4. 会话封装和控制器 33.3.5. 防止每个命名空间有多重实例 33.3.6. 使用数组 33.3.7. 在对象使用会话 33.3.8. 在单元测试使用会话 33.4. 全局会话管理 33.4.1. 配置选项 33.4.2. 错误:Headers Already Sent 33.4.3. 会话标识符 33.4.3.1. 会话劫持和会话固定 33.4.4. rememberMe(integer $seconds) 33.4.5. forgetMe() 33.4.6. sessionExists() 33.4.7. destroy(bool $remove_cookie = true, bool $readonly = true) 33.4.8. stop() 33.4.9. writeClose($readonly = true) 33.4.10. expireSessionCookie() 33.4.11. setSaveHandler(Zend_Session_SaveHandler_Interface $interface) 33.4.12. namespaceIsset($namespace) 33.4.13. namespaceUnset($namespace) 33.4.14. namespaceGet($namespace) 33.4.15. getIterator() 34. Zend_Translate 34.1. 简介 34.1.1. 开始多语言化 34.2. Zend_Translate适配器 34.2.1. 如何判断使用哪种翻译适配器 34.2.1.1. Zend_Translate_Adapter_Array 34.2.1.2. Zend_Translate_Adapter_Csv 34.2.1.3. Zend_Translate_Adapter_Gettext 34.2.1.4. Zend_Translate_Adapter_Tbx 34.2.1.5. Zend_Translate_Adapter_Tmx 34.2.1.6. Zend_Translate_Adapter_Qt 34.2.1.7. Zend_Translate_Adapter_Xliff 34.2.1.8. Zend_Translate_Adapter_XmlTm 34.2.2. 集成编写自己的适配器 34.2.3. 加速所有的适配器 34.3. Using Translation Adapters 34.3.1. Translation Source Structures 34.3.2. Creating array source files 34.3.3. Creating Gettext Source Files 34.3.4. Creating TMX Source Files 34.3.5. Creating CSV Source Files 34.3.6. Options for adapters 34.3.7. Handling languages 34.3.7.1. Automatically handling of languages 34.3.8. Automatic source detection 34.3.8.1. Language through naming directories 34.3.8.2. Language through filenames 34.3.8.2.1. Complete Filename 34.3.8.2.2. Extension of the file 34.3.8.2.3. Filename tokens 34.3.9. Checking for translations 34.3.10. Access to the source data 35. Zend_Uri 35.1. Zend_Uri 35.1.1. 概述 35.1.2. 新建一个URI 35.1.3. 操作现有的URI 35.1.4. URI 验证 35.1.5. 公共实例方法 35.1.5.1. 取得URI的Schema 35.1.5.2. 取得整个URI 35.1.5.3. 验证URI 36. Zend_Validate 36.1. 简介 36.1.1. 什么是校验器(validator)? 36.1.2. 校验器的基本用法 36.1.3. 定制消息 36.1.4. 使用静态 is() 方法 36.2. 标准校验类 36.2.1. Alnum 36.2.2. Alpha 36.2.3. Barcode 36.2.4. Between 36.2.5. Ccnum 36.2.6. 日期 36.2.7. 数字 36.2.8. Email 地址 36.2.9. 浮点数 36.2.10. GreaterThan 36.2.11. 十六进制数 36.2.12. 主机名 36.2.13. InArray 36.2.14. 整数 36.2.15. Ip 36.2.16. LessThan 36.2.17. NotEmpty 36.2.18. Regex 36.2.19. StringLength 36.3. 校验器链 36.4. 编写校验器 37. Zend_Version 37.1. 读取Zend Framework的当前版本 38. Zend_View 38.1. 简介 38.1.1. 控制器脚本 38.1.2. 视图脚本 38.1.3. 选项 38.1.4. 实用访问器 38.2. 控制器脚本 38.2.1. 变量赋值 38.2.2. 调用视图脚本并打印输出 38.2.3. 视图脚本的路径 38.3. 视图脚本 38.3.1. 转义输出(Escaping Output) 38.3.2. 使用模板系统 38.3.2.1. 使用View脚本的模板系统 38.3.2.2. 通过Zend_View_Interface接口使用模板系统 38.4. 视图助手(View Helper) 38.4.1. 基本的助手 38.4.1.1. 动作视图助手 38.4.1.2. 区域助手(Partial Helper) 38.4.1.3. 占位符助手(Placeholder Helper) 38.4.1.3.1. 具体占位符实现 38.4.1.4. 文档类型助手(Doctype Helper) 38.4.1.5. HeadLink 助手 38.4.1.6. HeadMeta 助手 38.4.1.7. HeadScript 助手 38.4.1.8. HeadStyle 助手 38.4.1.9. HeadTitle 助手 38.4.1.10. InlineScript 助手 38.4.1.11. JSON 助手 38.4.1.12. 翻译助手 38.4.2. 助手的路径 38.4.3. 编写自定义的助手类 39. Zend_XmlRpc 39.1. 介绍 39.2. Zend_XmlRpc_Client 39.2.1. 介绍 39.2.2. 带参数 39.2.2.1. 以PHP本地变量的形式传递参数 39.2.2.2. 以Zend_XmlRpc_Value 对象的形式传递参数 39.2.2.3. 将一个XML字符串解析为XML-RPC参数 39.2.3. 参数类型提示 39.2.4. 获取响应 39.3. Zend_XmlRpc_Server 39.3.1. Introduction 39.3.2. Basic Usage 39.3.3. Server Structure 39.3.4. Conventions 39.3.5. Utilizing Namespaces 39.3.6. Custom Request Objects 39.3.7. Custom Responses 39.3.8. Handling Exceptions via Faults 39.3.9. Caching Server Definitions Between Requests 39.3.10. Usage Examples 39.3.10.1. Basic Usage 39.3.10.2. Attaching a class 39.3.10.3. Attaching several classes using namespaces 39.3.10.4. Specifying exceptions to use as valid fault responses 39.3.10.5. Utilizing a custom request object 39.3.10.6. Utilizing a custom response object 39.3.10.7. Cache server definitions between requests A. 系统需求 A.1. PHP 版本需求 A.2. PHP 扩展 A.3. Zend Framework 组件 B. Zend Framework PHP 编码标准 B.1. 绪论 B.1.1. 适用范围 B.1.2. 目标 B.2. PHP File 文件格式 B.2.1. 常规 B.2.2. 缩进 B.2.3. 行的最大长度 B.2.4. 行结束标志 B.3. 命名约定 B.3.1. 类 B.3.2. 接口 B.3.3. 文件名 B.3.4. 函数和方法 B.3.5. 变量 B.3.6. 常量 B.4. 编码风格 B.4.1. PHP 代码划分(Demarcation) B.4.2. 字符串 B.4.2.1. 字符串文字 B.4.2.2. 包含单引号(')的字符串文字 B.4.2.3. 变量替换 B.4.2.4. 字符串连接 B.4.3. 数组 B.4.3.1. 数字索引数组 Numerically Indexed Arrays B.4.3.2. 关联数组 B.4.4. 类 B.4.4.1. 类的声明 B.4.4.2. 类成员变量 B.4.5. 函数和方法 B.4.5.1. 函数和方方声明 B.4.5.2. 函数和方法的用法 B.4.6. 控制语句 B.4.6.1. If / Else / Elseif B.4.6.2. Switch B.4.7. 注释文档 B.4.7.1. 格式 B.4.7.2. 文件 B.4.7.3. 类 B.4.7.4. 函数 C. 版权信息 索引 表格清单 2.1. 一个CMS范例的访问控制 3.1. 配置选项 4.1. 核心前端选项 4.2. 函数前端选项 4.3. Class frontend options 4.4. File frontend options 4.5. Page frontend options 4.6. 文件后端选项 4.7. Sqlite 后端选项 4.8. Memcached 后端选项 5.1. Zend_Config_Ini 构造器参数 8.1. 选择货币描述的常量 8.2. 选择货币位置的常量 9.1. Date Parts 9.2. Basic Operations 9.3. Date Comparison Methods 9.4. Date Output Methods 9.5. Date Output Methods 9.6. Miscellaneous Methods 9.7. Operations involving Zend_Date::HOUR 9.8. Day Constants 9.9. Week Constants 9.10. Month Constants 9.11. Year Constants 9.12. Time Constants 9.13. Timezone Constants 9.14. Date Format Constants (formats include timezone) 9.15. Date and Time Formats (format varies by locale) 9.16. Constants for ISO 8601 date output 9.17. Constants for PHP date output 9.18. Types of supported horizons for sunset and sunrise 17.1. Zend_Http_Client_Adapter_Socket configuration parameters 17.2. Zend_Http_Client configuration parameters 21.1. Details for getTranslationList($type = null, $locale = null, $value = null) 21.2. Details for getTranslation($value = null, $type = null, $locale = null) 21.3. Differences between ZF 1.0 and ZF 1.5 21.4. Format tokens for self generated number formats 21.5. List of supported numeral systems 21.6. Key values for getDate() with option 'fix_date' 21.7. Return values 21.8. Format definition 21.9. Example formats 21.10. List of all supported languages 21.11. List of all supported regions 23.1. Mail Read Feature Overview 23.2. Mail Folder Names 24.1. List of measurement types 30.1. Zend_Search_Lucene_Field 类型 32.1. Zend_Service_Amazon_Item Properties 32.2. Zend_Service_Amazon_Image Properties 32.3. Zend_Service_Amazon_OfferSet Properties 32.4. Properties 32.5. Zend_Service_Amazon_SimilarProduct Properties 32.6. Zend_Service_Amazon_Accessories Properties 32.7. Zend_Service_Amazon_CustomerReview Properties 32.8. Zend_Service_Amazon_EditorialReview Properties 32.9. Zend_Service_Amazon_Listmania Properties 32.10. Methods for retrieving public data 32.11. Methods of the Zend_Service_Delicious_SimplePost class 32.12. Zend_Service_Flickr_ResultSet 属性 32.13. Zend_Service_Flickr_Result 属性 32.14. Zend_Service_Flickr_Image 属性 32.15. Zend_Service_Yahoo_ResultSet 32.16. Zend_Service_Yahoo_LocalResultSet 属性 32.17. Zend_Service_Yahoo_Result Properties 32.18. Zend_Service_Yahoo_WebResult 属性 32.19. Zend_Service_Yahoo_ImageResult 属性 32.20. Zend_Service_Yahoo_LocalResult 属性 32.21. Zend_Service_Yahoo_NewsResult 属性 32.22. Zend_Service_Yahoo_Image Properties 34.1. Zend_Translate适配器 34.2. Options for Translation Adapters 39.1. PHP本地变量类型转化为XML-RPC类型 39.2. Zend_XmlRpc_Value 对象声明的XML-RPC类型 A.1. Zend Framework 使用的 PHP 扩展 A.2. Zend Framework 组件以及其使用到的 PHP 扩展 范例清单 2.1. 角色之间的多重继承 3.1. 修改 Session 名字空间 3.2. 使用定制存储类 3.3. 基本用法 4.1. 调用 Zend_Cache::factory()取得一个前端 4.2. Caching a database query result 4.3. 用Zend_Cache 输出前端缓存输出 5.1. 使用 Zend_Config 本身 5.2. Using Zend_Config with a PHP Configuration File 5.3. 使用 Zend_Config_Ini 5.4. 使用Zend_Config_Xml 6.1. 使用短语法 6.2. 使用长语法 6.3. 捕捉 Getopt 异常 6.4. 使用 getOption() 6.5. 使用 __get() 和 __isset() 魔术方法 6.6. 使用 getRemainingArgs() 6.7. 使用 addRules() 6.8. 使用 setHelp() 6.9. 使用 setAliases() 6.10. 使用 addArguments() 和 setArguments() 6.11. 使用 setOption() 6.12. 使用 setOptions() 7.1. 如何处理不存在的动作 7.2. 用动作、控制器和模块名来添加一个任务 7.3. 使用请求对象添加一个任务 7.4. AutoCompletion with Dojo Using Zend MVC 7.5. 允许动作响应 Ajax 的请求 7.6. 设定选项 7.7. 使用默认设定 7.8. 使用goto()的_forward()API 7.9. 通过gotoRoute()使用路由组装(route assembly) 7.10. 基本用法 7.11. 禁用自动解析 7.12. 选择另外的视图脚本 7.13. 修改注册的视图Modifying the registered view 7.14. 修改路径规则 7.15. 一个动作解析多个视图脚本 7.16. Standard usage 7.17. Setting a different error handler 7.18. Using accessors 8.1. 从实际地方创建 Zend_Currency 的实例 8.2. 创建 Zend_Currency 实例的其它例子 8.3. 为货币创建输出 8.4. 修改货币的显示格式 8.5. 从货币获取信息 8.6. 设置新地方 8.7. 缓存货币 9.1. Setting a default timezone 9.2. Creating the current date 9.3. get() - output a date 9.4. set() - set a date 9.5. add() - adding dates 9.6. compare() - compare dates 9.7. equals() - identify a date or date part 9.8. User-specified input date format 9.9. Operating on Parts of Dates 9.10. Date creation by instance 9.11. Static date creation 9.12. Quick creation of dates from database date values 9.13. Convenient creation of dates from database date values 9.14. Date creation by array 9.15. Example usage for self-defined ISO formats 9.16. Example usage for self-defined formats with PHP specifier 9.17. Checking dates 9.18. Getting all available cities 9.19. Getting the location for a city 9.20. Calculating sun informations 9.21. Working with timezones 9.22. Multiple timezones 10.1. Creating a SQL statement object with query() 10.2. Using a SQL statement constructor 10.3. Executing a statement with positional parameters 10.4. Executing a statement with named parameters 10.5. Using fetch() in a loop 10.6. Using fetchAll() 10.7. Setting the fetch mode 10.8. Using fetchColumn() 10.9. Using fetchObject() 10.10. Fetching a Dependent Rowset 10.11. Fetching a Dependent Rowset By a Specific Rule 10.12. Fetching a Dependent Rowset using a Zend_Db_Table_Select 10.13. Fetching Dependent Rowsets using the Magic Method 10.14. Fetching the Parent Row 10.15. Fetching a Parent Row By a Specific Rule 10.16. Fetching the Parent Row using the Magic Method 10.17. Fetching a Rowset with the Many-to-many Method 10.18. Fetching a Rowset with the Many-to-many Method By a Specific Rule 10.19. Fetching Rowsets using the Magic Many-to-many Method 10.20. Example of a Cascading Delete 10.21. Example Declaration of Cascading Operations 11.1. dump()方法使用示例 12.1. 捕捉一个异常的例子 13.1. 用Zend_Feed来处理RSS Feed数据 13.2. Atom Feed的基本用法 13.3. 读取Atom Feed的单个条目 13.4. 用条目对象直接访问Atom Feed的单个条目 13.5. 修改一个已存在的条目 13.6. 用自定义的命名空间创建一个Atom条目元素 13.7. 用自定义的命名空间继承Atom条目类 14.1. Transforming CamelCaseText to another format 14.2. Setting Multiple Rules at Once 14.3. Using Zend_Config with Zend_Filter_Inflector 15.1. 定制标签 15.2. 为所有元素设置前缀路径 15.3. 为所有元素设置装饰器(Decorators) 15.4. 为所有元素设置过滤器 15.5. 为所有的显示组设置装饰器前缀路径 15.6. 为所有显示组设置装饰器 15.7. 注册表单示例 17.1. 执行一个基本的 GET 请求 17.2. 创建一个基本的Zend_Http_Client 17.3. 发送多条header信息 17.4. 发送请求到多个域名 17.5. 用Zend_Http_Client发送POST 数据 17.6. Forcing RFC 2616 Strict Redirections on 301 and 302 Responses 17.7. Setting Cookies Using setCookie() 17.8. Enabling Cookie Stickiness 17.9. Setting A Single Custom Request Header 17.10. Setting Multiple Custom Request Headers 17.11. Using setFileUpload to Upload Files 17.12. Sending Raw POST Data 17.13. Setting HTTP Authentication User and Password 17.14. Performing consecutive requests with one client 17.15. Changing the HTTPS transport layer 17.16. Using Zend_Http_Client behind a proxy server 17.17. Testing Against a Single HTTP Response Stub 17.18. Testing Against Multiple HTTP Response Stubs 17.19. Creating your own connection adapter 17.20. Instantiating a Zend_Http_Cookie object 17.21. Stringifying a Zend_Http_Cookie object 17.22. Using getter methods with Zend_Http_Cookie 17.23. Matching cookies 17.24. 处理HTTP应答 19.1. 传递选项给构造器或startMvc() 19.2. 使用setOption() 和 setConfig() 19.3. 使用访问器 19.4. 使用Zend_Layout访问器来修改变形器(inflector) 19.5. Zend_Layout 变形器的直接修改 19.6. 定制变形器(inflectors) 20.1. loadFile() 方法范例 20.2. Example of loadClass() method 20.3. isReadable()示例: 20.4. 注册 autoloader callback 方法范例 20.5. 从继承类注册 autoload callback 方法范例 21.1. Choosing a specific locale 21.2. Automatically selecting a locale 21.3. Using automatic locales 21.4. Handling locale exceptions 21.5. Setting a default locale 21.6. Dates default to correct locale of web users 21.7. Overriding default locale selection 21.8. Performance optimization when using a default locale 21.9. Dates default to correct locale of web users 21.10. Using STANDARD definitions for setOptions() 21.11. clone 21.12. Check for equal locales 21.13. Get default locales 21.14. setLocale 21.15. getLanguage and getRegion 21.16. getTranslationList 21.17. getTranslationList 21.18. Converting country name in one language to another 21.19. All available translations 21.20. All Languages written in their native language 21.21. getQuestion() 21.22. getLocaleList() 21.23. Number normalization 21.24. Number normalization with precision 21.25. Number localization 21.26. Number localization with precision 21.27. Using a self defined number format 21.28. Number testing 21.29. Floating point value normalization 21.30. Floating point value localization 21.31. Floating point value testing 21.32. Integer value normalization 21.33. Integer value localization 21.34. Integer value testing 21.35. Converting numerals from Eastern Arabic scripts to European/Latin scripts 21.36. Converting numerals from Latin script to Eastern Arabic script 21.37. Getting 4 letter CLDR script code using a native-language name of the script 21.38. Normalizing a date 21.39. Normalizing a date by locale 21.40. Normalizing a date with time 21.41. Normalizing a userdefined date 21.42. Automatic correction of input dates 21.43. Date testing 21.44. Normalize an unknown time 21.45. Testing a time 23.1. 使用Zend_Mail发送简单邮件 23.2. 传递另外的参数给 Zend_Mail_Transport_Sendmail 传送器 23.3. 通过 SMTP 发送邮件 23.4. 通过一个SMTP连接发送多个邮件 23.5. 手工控制传送器连接 23.6. 使用不同的Transport对象 23.7. 发送HTML邮件 23.8. 带附件的邮件 23.9. 更改MIME分界线 23.10. 外加邮件头信息 23.11. 在 Zend_Mail_Transport_Smtp 使用身份验证 23.12. Enabling a secure connection within Zend_Mail_Transport_Smtp 24.1. Converting measurements 24.2. The meter measurement 24.3. Creation using integer and floating values 24.4. Creation using strings 24.5. Arbitrary text input containing measurements 24.6. Localized string 24.7. Automatic output 24.8. Output a value 24.9. Outputting units 24.10. Convert 24.11. Adding units 24.12. Subtract 24.13. Different measurements 24.14. Identical measurements 24.15. Difference 24.16. Changing a value 24.17. Changing the type 25.1. 使用 Zend_Memory 组件 27.1. 生成新的或加载 PDF 文档 27.2. 请求 PDF 文档的指定版本 27.3. Save PDF document. 27.4. PDF 文档页面管理 27.5. Cloning existing page. 27.6. Draw a string on the page. 27.7. Draw a UTF-8-encoded string on the page. 27.8. Create a standard font. 27.9. Create a TrueType font. 27.10. Create a TrueType font, but do not embed it in the PDF document. 27.11. Do not throw an exception for fonts that cannot be embeded. 27.12. Do not compress an embedded font. 27.13. Combining font embedding options. 27.14. Extracting fonts from a loaded document. 27.15. Extracting font from a loaded document by specifying font name. 27.16. Image drawing. 27.17. Zend_Pdf module usage demo. 28.1. set() 使用示例: 28.2. get() 方法示例: 28.3. 迭代一个registry对象: 28.4. 创建一个registry对象 28.5. Example of initializing the static registry 28.6. array 方式访问示例: 28.7. 对象形式的访问: 28.8. isRegistered() 示例: 28.9. isset() 示例: 28.10. 指定静态注册表的类名: 28.11. _unsetInstance() 示例: 29.1. A basic REST request 29.2. Response Status 29.3. Using Technorati's Rest Service 29.4. Example Technorati Response 29.5. Setting Request Arguments 29.6. Basic Zend_Rest_Server Usage - Classes 29.7. Basic Zend_Rest_Server Usage - Functions 29.8. Returning Custom Status 29.9. Return Custom XML 30.1. 自定义文本分析程序 32.1. isSpam() Usage 32.2. submitSpam() Usage 32.3. submitHam() Usage 32.4. Search Amazon Using the Traditional API 32.5. Search Amazon Using the Query API 32.6. Choosing an Amazon Web Service Country 32.7. Looking up a Specific Amazon Item by ASIN 32.8. Performing Amazon Item Searches 32.9. Using the ResponseGroup Option 32.10. Search Amazon Using the Alternative Query API 32.11. Retrieving User Profile Information 32.12. Retrieving a User's Weekly Artist Chart 32.13. Retrieving Related Artists 32.14. Get all posts 32.15. Accessing post lists 32.16. Filtering a Post List with Specific Tags 32.17. Filtering a Post List by URL 32.18. Post editing 32.19. Method call chaining 32.20. Deleting posts 32.21. Adding a post 32.22. Tags 32.23. Bundles 32.24. Retrieving public data 32.25. Changing the HTTP client of Zend_Rest_Client 32.26. Configuring your HTTP client to keep connections alive 32.27. 简单的 Flickr 照片搜索 32.28. 用email地址来查找Flickr用户 32.29. 获得 Flickr 图像详细资料 32.30. Querying Links 32.31. Modifying Links 32.32. Working With Tags 32.33. Working With Notes 32.34. Retrieving Watchlists 32.35. 用Yahoo!来搜索网页 32.36. 用Yahoo!来查找图片 32.37. 用Yahoo!查找本地商务和服务信息 32.38. 搜索Yahoo! 新闻 33.1. 页面浏览计数 33.2. 新方法: 使用命名空间避免冲突 33.3. 老方法: PHP会话访问 33.4. 会话迭代 33.5. 访问会话数据 33.6. 开启全局会话 33.7. 锁住会话命名空间 33.8. 过期的例子 33.9. 带有生命期的控制器命名空间会话 33.10. 限制命名空间访问单一实例 33.11. 修改带有会话命名空间的数组数据 33.12. 在会话存储之前构造数组 33.13. 方案:重新分配一个被修改的数组 33.14. 方案:存储包括引用的数组 33.15. PHPUnit Testing Code Dependent on Zend_Session 33.16. 使用Zend_Config配置Zend_Session 33.17. 会话固定 34.1. Example of single-language PHP code 34.2. Example of multi-lingual PHP code 34.3. Example TMX file 34.4. Example CSV file 34.5. Example CSV file two 34.6. Using translation options 34.7. Handling languages with adapters 34.8. How automatically language detection works 34.9. Scanning a directory structure for sources 34.10. Directory scanning for languages 34.11. Filename scanning for languages 34.12. Checking if a text is translatable 34.13. Handling languages with adapters 35.1. 使用Zend_Uri::factory()创建一个新的URI 35.2. 使用Zend_Uri::factory()操作一个现有的URI 35.3. 使用Zend_Uri::check()进行URI 验证 35.4. 从Zend_Uri_* 对象取得模式 35.5. 从一个Zend_Uri_* 对象取得整个URI 35.6. 验证一个 Zend_Uri_* 对象 36.1. 创建简单校验类 36.2. 编写有独立条件的校验类 36.3. 带有独立条件、多重失败原因的校验 37.1. compareVersion()方法示例: 38.1. 动作视图助手的基本用法 38.2. Partials 的基本用法 38.3. 使用 PartialLoop 来解析可迭代的(Iterable)的模型 38.4. 在其它模块解析 Partials 38.5. 占位符的基本用法 38.6. 用占位符来聚合内容 38.7. 使用占位符(Placeholders)来抓取内容 38.8. Doctype 助手的基本用法 38.9. 获取 Doctype 38.10. HeadLink 助手的基本用法 38.11. HeadMeta 助手基本用法 38.12. HeadScript 助手基本用法 38.13. Capturing Scripts Using the HeadScript Helper 38.14. HeadStyle 助手的基本用法 38.15. 用 HeadStyle 助手抓取样式声明 38.16. HeadTitle 助手基本用法 38.17. 已注册的实例 38.18. 在视图里 38.19. 直接用法 38.20. 单个参数 38.21. 参数列表 38.22. 参数数组 38.23. 动态修改地点 (locale) 38.24. 静态修改地点 (locale) 38.25. 获得当前设置的地点 39.1. 一个基本的XML-RPC请求 39.2. 用类型提示来调用一个XML-RPC服务
NHIBERNATE - 符合.Net习惯的关系数据库持久化 NHibernate参考文档 2.0.0 -------------------------------------------------------------------------------- 目录 前言 1. 第一个NHibernate应用程序 1.1. 开始NHibernate之旅 1.2. 第一个持久化类 1.3. 映射cat 1.4. 与Cat同乐 1.5. 总结 2. 体系结构(Architecture) 2.1. 概况(Overview) 2.2. 实例状态 2.3. 上下文相关的(Contextual)Session 3. 配置 3.1. 可编程的配置方式 3.2. 获得ISessionFactory 3.3. 用户自行提供ADO.NET连接 3.4. NHibernate提供ADO.NET连接 3.5. 可选的配置属性 3.5.1. SQL方言 3.5.2 外连接抓取(Outer Join Fetching) 3.5.3. 查询缓存 3.5.4. 查询语言的替换 3.6. 日志 3.7. 实现NamingStrategy 3.8. XML配置文件 4. 持久化类(Persistent Classes) 4.1. 一个简单的POCO例子 4.1.1. 为持久化成员变量声明读写属性 4.1.2. 实现一个默认的构造器(constructor) 4.1.3. 提供一个标识属性(identifier property)(可选) 4.1.4. 使用非不可继承的(non-sealed)类以及虚方法(virtual methods) (可选) 4.2. 实现继承(Inheritance) 4.3. 实现 Equals() 和 GetHashCode() 方法 4.4. 持久化生命周期(Lifecycle)的回调(Callbacks) 4.5. 合法性验证(IValidatable)回调 5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. XML名称空间 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.4.1. (主键生成策略)generator 5.1.4.2. 高/低位算法(Hi/Lo Algorithm) 5.1.4.3. 唯一标识16进制算法(UUID Algorithm ) 5.1.4.4. 唯一标识字符串算法 5.1.4.5. 唯一标识GUID算法 5.1.4.6. 标识字段和序列(Identity columns and Sequences) 5.1.4.7. 程序分配的标识符(Assigned Identifiers) 5.1.5. (联合主键)composite-id 5.1.6. 鉴别器(discriminator) 5.1.7. 版本(version)(可选) 5.1.8. 时间戳 (可选) 5.1.9. 属性 5.1.10. 多对一 5.1.11. 一对一 5.1.12. 组件(component), 动态组件(dynamic-component) 5.1.13. 子类 5.1.14. 连接的子类(joined-subclass) 5.1.15. 联合子类(union-subclass) 5.1.16. 连接 5.1.17. map, set, list, bag 5.1.18. 引用(import) 5.2. NHibernate 的类型 5.2.1. 实体(Entities)和值(values) 5.2.2. 基本值类型 5.2.3. 自定义值类型 5.2.4. Any类型映射 5.3. SQL引号包围的标识符 5.4. 模块化映射文件 5.5. 数据库生成属性(Generated Properties) 5.6. 数据库辅助对象 6. 集合类(Collections)映射 6.1. 持久化集合类 6.2. 集合外键(Collection foreign keys) 6.3. 值集合于多对多关联(Collections of values and many-to-many associations) 6.4. 一对多关联 6.5. 延迟加载 6.6. 有序集合(Sorted collections) 6.7. 使用 6.8. 双向关联(Bidirectional associations) 6.9. 三重关联(Ternary associations) 6.10. 异质关联(Heterogeneous Associations) 6.11. 集合例子(Collection example) 7. 组件(Component)映射 7.1. 依赖对象(Dependent objects) 7.2. 在集合出现的依赖对象 (Collections of dependent objects) 7.3. 组件作为IDictionary的索引(Components as IDictionary indices ) 7.4. 组件作为联合标识符(Components as composite identifiers) 7.5. 动态组件 8. 继承映射(Inheritance Mappings) 8.1. 三种策略 8.1.1. 每个类分层结构一张表(Table per class hierarchy) 8.1.2. 每个子类一张表(Table per subclass) 8.1.3. 每个子类一张表(Table per subclass),使用辨别标志(Discriminator) 8.1.4. 混合使用“每个类分层结构一张表”和“每个子类一张表” 8.1.5. 每个具体类一张表(Table per concrete class) 8.1.6. 每个具体类一张表使用隐式多态 8.1.7. 隐式多态和其他继承映射混合使用 8.2. 限制 9. 持久化数据管理 9.1. 创建持久化对象 9.2. 加载载对象 9.3. 查询 9.3.1. 标量(Scalar)查询 9.3.2. IQuery接口 9.3.3. 过滤集合 9.3.4. 条件查询(Criteria queries) 9.3.5. 使用原生SQL的查询 9.4. 修改持久化对象 9.4.1. 使用同一个ISession持久化对象 9.4.2. 修改脱管(Detached)对象 9.4.3. 重新附脱管(Detached)对像 9.5. 删除持久化对象 9.6. 刷出 9.7. 结束ISession 9.7.1. 清除ISession 9.7.2. 提交数据库事务 9.7.3. 关闭ISession 9.8. 异常处理 9.9. 生命周期与对象图 9.10. 拦截器 9.11. 元数据API 10. 事务和并发 10.1. 配置,会话与工厂 10.2. 线程与连接 10.3. 关注对象标识(Considering object identity) 10.4. 乐观并发控制(Optimistic concurrency control) 10.4.1. 长会话自动版本化 10.4.2. 多事务自动版本化 10.4.3. 定制自动版本化行为 10.4.4. 应用程序级别的版本检查(Application version checking) 10.5. 会话断开连接 10.6. 悲观锁定(Pessimistic Locking) 10.7. 连接释放模式(Connection Release Modes) 11. 拦截器与事件 11.1. 拦截器 11.2. 事件系统 12. HQL: NHibernate查询语言 12.1. 大小写敏感性问题 12.2. from子句 12.3. 关联(Association)与连接(Join) 12.4. select子句 12.5. 聚集函数 12.6. 多态查询 12.7. where子句 12.8. 表达式 12.9. order by子句 12.10. group by子句 12.11. 子查询 12.12. HQL示例 12.13. 小技巧 & 小窍门 13. 条件查询(Criteria Queries) 13.1. 创建一个ICriteria实例 13.2. 限制结果集内容 13.3. 结果集排序 13.4. 关联 13.5. 动态关联抓取 13.6. 查询示例 13.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 13.8. 离线(detached)查询和子查询 14. 原生SQL查询 14.1. 使用ISQLQuery 14.1.1. 标量查询(Scalar queries) 14.1.2. 实体查询(Entity queries) 14.1.3. 处理关联和集合类(Handling associations and collections) 14.1.4. 返回多个实体(Returning multiple entities) 14.1.4.1. 别名和属性引用(Alias and property references) 14.1.5. 返回非受管实体(Returning non-managed entities) 14.1.6. 处理继承(Handling inheritance) 14.1.7. 参数(Parameters) 14.2. 命名SQL查询 14.2.1. 使用return-property来明确地指定字段/别名 14.2.2. 使用存储过程来查询 14.2.2.1. 使用存储过程的规则和限制 14.3. 定制SQL用来create,update和delete 14.4. 定制装载SQL 15. 过滤数据 15.1. NHibernate 过滤器(filters) 16. 提升性能 16.1. 抓取策略(Fetching strategies) 16.1.1. 操作延迟加载的关联 16.1.2. 调整抓取策略(Tuning fetch strategies) 16.1.3. 单端关联代理(Single-ended association proxies) 16.1.4. 初始化集合和代理(Initializing collections and proxies) 16.1.5. 使用批量抓取(Using batch fetching) 16.1.6. 使用子查询抓取(Using subselect fetching) 16.2. 二级缓存(The Second Level Cache) 16.2.1. 缓存映射(Cache mappings) 16.2.2. 策略:只读缓存(Strategy: read only) 16.2.3. 策略:读/写缓存(Strategy: read/write) 16.2.4. 策略:非严格读/写缓存(Strategy: nonstrict read/write) 16.2.5. 并发策略兼容性 16.3. 管理缓存(Managing the caches) 16.4. 查询缓存(The Query Cache) 16.5. 理解集合性能(Understanding Collection performance) 16.5.1. 分类(Taxonomy) 16.5.2. Lists, maps 和sets用于更新效率最高 16.5.3. Bag和list是反向集合类效率最高的 16.5.4. 一次性删除(One shot delete) 16.6. 批量更新(Batch updates) 16.7. Multi Query 16.8. 多重条件查询 17. 工具箱指南 17.1. 数据库结构生成(schema generation) 17.1.1. 对schema定制化(Customizing the schema) 17.1.2. 运行该工具 17.1.3. 配置属性(Properties) 17.1.4. 使用NAnt 17.2. 代码生成 17.2.1. 配置文件(可选) 17.2.2. 元数据属性 17.2.3. 基本的finder生成器(Basic finder generator) 17.2.4. 基于Velocity的渲染器/生成器(Velocity based renderer/generator) 17.3. 映射文件生成器(Mapping File Generation) 17.3.1. 运行工具 18. 示例:父子关系(Parent Child Relationships) 18.1. 关于collections需要注意的一点 18.2. 双向的一对多关系(Bidirectional one-to-many) 18.3. 级联生命周期(Cascading lifecycle) 18.4. 使用级联更新 18.5. 结论 19. 示例:Weblog 应用程序 19.1. 持久化类 19.2. NHibernate 映射 19.3. NHibernate 代码 20. 示例:复杂映射实例 20.1. Employer(雇主)/Employee(雇员) 20.2. Author(作家)/Work(作品) 20.3. Customer(客户)/Order(订单)/Product(产品) 21. 最佳实践 I. NHibernateContrib 参考文档 前言 22.2. Prevalence Cache 配置 22.1. 如何使用缓存? 22.2. Prevalence Cache 配置 22.3. SysCache 配置 22.4. SysCache2 配置 22.4.1. 表依赖缓存 22.4.2. SQL依赖缓存 22.4.3. 聚集依赖缓存 22.4.4. 附加设置 22.4.5. 补丁
NHIBERNATE - 符合.Net习惯的关系数据库持久化 NHibernate参考文档 2.0.0 目录 前言 1. 第一个NHibernate应用程序 1.1. 开始NHibernate之旅 1.2. 第一个持久化类 1.3. 映射cat 1.4. 与Cat同乐 1.5. 总结 2. 体系结构(Architecture) 2.1. 概况(Overview) 2.2. 实例状态 2.3. 上下文相关的(Contextual)Session 3. 配置 3.1. 可编程的配置方式 3.2. 获得ISessionFactory 3.3. 用户自行提供ADO.NET连接 3.4. NHibernate提供ADO.NET连接 3.5. 可选的配置属性 3.5.1. SQL方言 3.5.2 外连接抓取(Outer Join Fetching) 3.5.3. 查询缓存 3.5.4. 查询语言的替换 3.6. 日志 3.7. 实现NamingStrategy 3.8. XML配置文件 4. 持久化类(Persistent Classes) 4.1. 一个简单的POCO例子 4.1.1. 为持久化成员变量声明读写属性 4.1.2. 实现一个默认的构造器(constructor) 4.1.3. 提供一个标识属性(identifier property)(可选) 4.1.4. 使用非不可继承的(non-sealed)类以及虚方法(virtual methods) (可选) 4.2. 实现继承(Inheritance) 4.3. 实现 Equals() 和 GetHashCode() 方法 4.4. 持久化生命周期(Lifecycle)的回调(Callbacks) 4.5. 合法性验证(IValidatable)回调 5. 对象/关系数据库映射基础(Basic O/R Mapping) 5.1. 映射定义(Mapping declaration) 5.1.1. XML名称空间 5.1.2. hibernate-mapping 5.1.3. class 5.1.4. id 5.1.4.1. (主键生成策略)generator 5.1.4.2. 高/低位算法(Hi/Lo Algorithm) 5.1.4.3. 唯一标识16进制算法(UUID Algorithm ) 5.1.4.4. 唯一标识字符串算法 5.1.4.5. 唯一标识GUID算法 5.1.4.6. 标识字段和序列(Identity columns and Sequences) 5.1.4.7. 程序分配的标识符(Assigned Identifiers) 5.1.5. (联合主键)composite-id 5.1.6. 鉴别器(discriminator) 5.1.7. 版本(version)(可选) 5.1.8. 时间戳 (可选) 5.1.9. 属性 5.1.10. 多对一 5.1.11. 一对一 5.1.12. 组件(component), 动态组件(dynamic-component) 5.1.13. 子类 5.1.14. 连接的子类(joined-subclass) 5.1.15. 联合子类(union-subclass) 5.1.16. 连接 5.1.17. map, set, list, bag 5.1.18. 引用(import) 5.2. NHibernate 的类型 5.2.1. 实体(Entities)和值(values) 5.2.2. 基本值类型 5.2.3. 自定义值类型 5.2.4. Any类型映射 5.3. SQL引号包围的标识符 5.4. 模块化映射文件 5.5. 数据库生成属性(Generated Properties) 5.6. 数据库辅助对象 6. 集合类(Collections)映射 6.1. 持久化集合类 6.2. 集合外键(Collection foreign keys) 6.3. 值集合于多对多关联(Collections of values and many-to-many associations) 6.4. 一对多关联 6.5. 延迟加载 6.6. 有序集合(Sorted collections) 6.7. 使用 6.8. 双向关联(Bidirectional associations) 6.9. 三重关联(Ternary associations) 6.10. 异质关联(Heterogeneous Associations) 6.11. 集合例子(Collection example) 7. 组件(Component)映射 7.1. 依赖对象(Dependent objects) 7.2. 在集合出现的依赖对象 (Collections of dependent objects) 7.3. 组件作为IDictionary的索引(Components as IDictionary indices ) 7.4. 组件作为联合标识符(Components as composite identifiers) 7.5. 动态组件 8. 继承映射(Inheritance Mappings) 8.1. 三种策略 8.1.1. 每个类分层结构一张表(Table per class hierarchy) 8.1.2. 每个子类一张表(Table per subclass) 8.1.3. 每个子类一张表(Table per subclass),使用辨别标志(Discriminator) 8.1.4. 混合使用“每个类分层结构一张表”和“每个子类一张表” 8.1.5. 每个具体类一张表(Table per concrete class) 8.1.6. 每个具体类一张表使用隐式多态 8.1.7. 隐式多态和其他继承映射混合使用 8.2. 限制 9. 持久化数据管理 9.1. 创建持久化对象 9.2. 加载载对象 9.3. 查询 9.3.1. 标量(Scalar)查询 9.3.2. IQuery接口 9.3.3. 过滤集合 9.3.4. 条件查询(Criteria queries) 9.3.5. 使用原生SQL的查询 9.4. 修改持久化对象 9.4.1. 使用同一个ISession持久化对象 9.4.2. 修改脱管(Detached)对象 9.4.3. 重新附脱管(Detached)对像 9.5. 删除持久化对象 9.6. 刷出 9.7. 结束ISession 9.7.1. 清除ISession 9.7.2. 提交数据库事务 9.7.3. 关闭ISession 9.8. 异常处理 9.9. 生命周期与对象图 9.10. 拦截器 9.11. 元数据API 10. 事务和并发 10.1. 配置,会话与工厂 10.2. 线程与连接 10.3. 关注对象标识(Considering object identity) 10.4. 乐观并发控制(Optimistic concurrency control) 10.4.1. 长会话自动版本化 10.4.2. 多事务自动版本化 10.4.3. 定制自动版本化行为 10.4.4. 应用程序级别的版本检查(Application version checking) 10.5. 会话断开连接 10.6. 悲观锁定(Pessimistic Locking) 10.7. 连接释放模式(Connection Release Modes) 11. 拦截器与事件 11.1. 拦截器 11.2. 事件系统 12. HQL: NHibernate查询语言 12.1. 大小写敏感性问题 12.2. from子句 12.3. 关联(Association)与连接(Join) 12.4. select子句 12.5. 聚集函数 12.6. 多态查询 12.7. where子句 12.8. 表达式 12.9. order by子句 12.10. group by子句 12.11. 子查询 12.12. HQL示例 12.13. 小技巧 & 小窍门 13. 条件查询(Criteria Queries) 13.1. 创建一个ICriteria实例 13.2. 限制结果集内容 13.3. 结果集排序 13.4. 关联 13.5. 动态关联抓取 13.6. 查询示例 13.7. 投影(Projections)、聚合(aggregation)和分组(grouping) 13.8. 离线(detached)查询和子查询 14. 原生SQL查询 14.1. 使用ISQLQuery 14.1.1. 标量查询(Scalar queries) 14.1.2. 实体查询(Entity queries) 14.1.3. 处理关联和集合类(Handling associations and collections) 14.1.4. 返回多个实体(Returning multiple entities) 14.1.4.1. 别名和属性引用(Alias and property references) 14.1.5. 返回非受管实体(Returning non-managed entities) 14.1.6. 处理继承(Handling inheritance) 14.1.7. 参数(Parameters) 14.2. 命名SQL查询 14.2.1. 使用return-property来明确地指定字段/别名 14.2.2. 使用存储过程来查询 14.2.2.1. 使用存储过程的规则和限制 14.3. 定制SQL用来create,update和delete 14.4. 定制装载SQL 15. 过滤数据 15.1. NHibernate 过滤器(filters) 16. 提升性能 16.1. 抓取策略(Fetching strategies) 16.1.1. 操作延迟加载的关联 16.1.2. 调整抓取策略(Tuning fetch strategies) 16.1.3. 单端关联代理(Single-ended association proxies) 16.1.4. 初始化集合和代理(Initializing collections and proxies) 16.1.5. 使用批量抓取(Using batch fetching) 16.1.6. 使用子查询抓取(Using subselect fetching) 16.2. 二级缓存(The Second Level Cache) 16.2.1. 缓存映射(Cache mappings) 16.2.2. 策略:只读缓存(Strategy: read only) 16.2.3. 策略:读/写缓存(Strategy: read/write) 16.2.4. 策略:非严格读/写缓存(Strategy: nonstrict read/write) 16.2.5. 并发策略兼容性 16.3. 管理缓存(Managing the caches) 16.4. 查询缓存(The Query Cache) 16.5. 理解集合性能(Understanding Collection performance) 16.5.1. 分类(Taxonomy) 16.5.2. Lists, maps 和sets用于更新效率最高 16.5.3. Bag和list是反向集合类效率最高的 16.5.4. 一次性删除(One shot delete) 16.6. 批量更新(Batch updates) 16.7. Multi Query 16.8. 多重条件查询 17. 工具箱指南 17.1. 数据库结构生成(schema generation) 17.1.1. 对schema定制化(Customizing the schema) 17.1.2. 运行该工具 17.1.3. 配置属性(Properties) 17.1.4. 使用NAnt 17.2. 代码生成 17.2.1. 配置文件(可选) 17.2.2. 元数据属性 17.2.3. 基本的finder生成器(Basic finder generator) 17.2.4. 基于Velocity的渲染器/生成器(Velocity based renderer/generator) 17.3. 映射文件生成器(Mapping File Generation) 17.3.1. 运行工具 18. 示例:父子关系(Parent Child Relationships) 18.1. 关于collections需要注意的一点 18.2. 双向的一对多关系(Bidirectional one-to-many) 18.3. 级联生命周期(Cascading lifecycle) 18.4. 使用级联更新 18.5. 结论 19. 示例:Weblog 应用程序 19.1. 持久化类 19.2. NHibernate 映射 19.3. NHibernate 代码 20. 示例:复杂映射实例 20.1. Employer(雇主)/Employee(雇员) 20.2. Author(作家)/Work(作品) 20.3. Customer(客户)/Order(订单)/Product(产品) 21. 最佳实践 I. NHibernateContrib 参考文档 前言 22.2. Prevalence Cache 配置 22.1. 如何使用缓存? 22.2. Prevalence Cache 配置 22.3. SysCache 配置 22.4. SysCache2 配置 22.4.1. 表依赖缓存 22.4.2. SQL依赖缓存 22.4.3. 聚集依赖缓存 22.4.4. 附加设置 22.4.5. 补丁

87,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧