OpenCMS 7 Develement 章节翻译-1 Chapter3 - Registering the Content Type
来源:互联网 发布:手机暖手宝软件 编辑:程序博客网 时间:2024/04/27 13:38
注册内容类型
为了注册OpemCMS系统的Schema文件,我们首先需要给模块数据库中添加一项。模块定义在OpemCCMS系统所有的一个XML配置数据库中。对大多数数据项来说,我们希望OpenCMS系统通过系统管理员入口管理这个文件的内容,那是因为还没有入口来添加新的数据类型。因此,我们需要直接编辑OpemCMS系统的模块数据库文件。
可以在这个地方找到模块数据库文件(module database file):
<openmcms_install>/WEB-INF/config/opencms-modules.xml
让我们来编辑这个文件并添加对应我们已经定义的内容类型的来源类型(resource type)。我们可以在opencms-vfs.xml 或者 opencms-modules.xml配置文件中注册来源类型的定义(resource type definitions)信息。但是,在模板中定义来源类型之后,我们必须确定所定义类型是能够很容易被传输的(transported)。为了能够让我们定义的内容类型添加到我们定义的模块,我必须在 pencms-modules.xml 中查找我们定义的模块 com.deepthoughts.template。
我们可以发现下面的定义信息:
<module>
<name>com.deepthoughts.templates</name>
<nicename><![CDATA[Deep Thoughts Templates]]></nicename>
<group>DeepThoughts</group>
<class/>
<description><![CDATA[This module contains the definitions for our
content types and the templates for the deepthoughts.com site]]></
description>
<version>0.1</version>
<authorname><![CDATA[Your Name]]></authorname>
<authoremail><![CDATA[Your eMail]]></authoremail>
<datecreated/>
<userinstalled/>
<dateinstalled/>
<dependencies/>
<exportpoints>
<exportpoint uri="/system/modules/com.deepthoughts.templates
/lib/" destination="WEB-INF/lib/"/>
<exportpoint uri="/system/modules/com.deepthoughts.templates
/classes/" destination="WEB-INF/classes/"/>
</exportpoints>
<resources>
<resource uri="/system/modules/com.deepthoughts.templates/"/>
</resources>
<parameters/>
</module>
在此处需要注意的是,这里定义的模块和后台管理界面中出现的模块信息是一致的。在这里不多做介绍。
为了定义新内容类型,我需要给模块定义信息后插入下面一项:
<resourcetypes>
<type class="org.opencms.file.types.CmsResourceTypeXmlContent"
name="blogentry" id="3000">
<param name="schema">/system/modules
/com.deepthoughts.templates/schemas/blogentry.xsd
</param>
</type>
</resourcetypes>
此项定义信息插入在<parameters/>之后。
此项包含的信息域属性为:
l type:此元素(element)说明了一个新的来源类型(resource type)。
² class: 这个属性指定了一个从I_CmsResourceType接口(interface)实现得来的java类(java class)。我们的应当使用 CmsResourceTypeXmlContent java 类,来得到结构化的XML类容类型。
² name: 这个属性值指得是我们定义的新的来源类型(resource type)的名称。
² id: 这个属性是用来标识(identify)我们的数据来源类型(type of out resource)的唯一id值。应当小心选择指定该属性值,因为来源类型的id属性值不能和其他冲突,而且该值一旦被指定便不能再修改。
第二项我们必须定义是菜单信息,定义该项可以让用户从工作台创建一个新的数据源实例。这一项在explorertypes元素中定义:
<explorertypes>
<explorertype name="blogentry" key="fileicon.blogentry"
icon="xmlcontent.gif" reference="xmlcontent">
<newresource uri="newresource_xmlcontent.jsp?
newresourcetype=blogentry" order="25"
info="desc.blogentry"/>
<accesscontrol>
<accessentry principal="ROLE.WORKPLACE_USER"
permissions="+r+v+w+c"/>
</accesscontrol>
</explorertype>
</explorertypes>
该项包含的信息域为:
l explorertype:该元素定义了工作台(Workplace Explorer)如何将我们的数据源定义(resource)展现在用户端。
² name:该属性为自定义数据来源类型( our resource type)的名称
² key:该属性指得是一个属性文件里的一项,该项信息包含了界面上的标签文本。将该文本置入属性文件中可以支持用户交互界面的本地化处理,也就是如果是英文版程序,只需要修改属性文件即可变为中文版。
² icon:该属性指定了该数据来源类型在工作台上显示界面的显示图标文件名称,在这里我们指定了已经存在的文件xmlcontent.gif
² reference:如果当前内容类型(content type)是从其他类型继承,则该值代表父类型。所有XML结构的内容类型应当继承于XML Content 类型,因此该属性值为“xmlcontent”
l newresource:该元素(element)定义了工作台程序如何来生成我们定义的来源(our resource)的实例
² uri:此处属性值指定了来实例化(instantiate)我们的来源类型实例(instance)的一个被调用的URI地址。对大多数来源类型来说,我可以使用在/system/workplace/commons文件夹下的默认JSP文件中的一个。对于所有的XML 结构的内容类型(XML structured content types)来说,我们可以使用newresource_xmlcontent.jsp 文件,并且设置newresourcetype参数为我们自己的来源类型(resource type )
² order:设置信息项在工作台上的显示顺序,升序排列。(This attribute sets the order in which the item will appear in the Workplace Explorer. Items with lower numbers will appear before the ones with higher numbers.)
² info:此属性指定了属性文件(properties file)中的一项,该项包行了内容类型在界面(UI)上的描述信息。
l accesscontrol/accessentry:此种元素允许我们给来源类型(resource type)添加访问控制权限的规则信息。
² principal:规则适用对象范围的信息。
² permisson:规则使用的证书掩码(permission mask)信息。
- OpenCMS 7 Develement 章节翻译-1 Chapter3 - Registering the Content Type
- the table of content-type
- RFC1341(MIME): 7 The Multipart Content-Type英译中
- B-Human CodeRelease2013-Chapter3翻译
- content-type
- Content Type
- content-type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- content type
- Content-Type
- content-type
- content-type
- Content-Type
- Project Management
- 黄炎培——职业教育实施之希望
- 用 PHP开发多任务应用程序
- 做一个下花痴又有什么关系?
- Windows下基于Apache服务器的PHP环境搭建
- OpenCMS 7 Develement 章节翻译-1 Chapter3 - Registering the Content Type
- JAVA字符集和字符串的编码
- 我迷失在你的背影中
- 老妈的泪
- 又进了一步
- Composite模式
- 自己编了个提示器(可以定时关机)
- 我彻底的喜欢上了这里,我喜欢这里的人们和这里能够找到的宝贝
- 软件开发者面试百问-----除了IDE以外,你还喜欢哪些必不可少的工具?