Liferay Portal 6 Enterprise Intranets phần 8 ppsx

68 593 0
Liferay Portal 6 Enterprise Intranets phần 8 ppsx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 8 [ 457 ] For articles in a portal instance, you could be able to assign permission in the Control Panel through custom regular roles. For a set of articles, there is no direct solution at the time of writing, but you may have to assign permissions individually. Permissions on structures, templates, and feeds We can set up permissions based on individual structures, templates, or feeds, or based on a group or portal instance. Since permissions on structures, templates, and feeds are the same, we discuss them together. Eventually, different model-resources (such as JournalStructure, JournalTemplate, and JournalFeed) of structure, template, and feed are different and separated. However, each model resource has the same permission specication. The following table shows permissions on structures, templates, and feeds. The role Community Member user is set up with all permissions (marked as 'X'): View, Delete, Permissions, and Update, while the role Guest is set up with the permissions: View, Delete, and Permissions. By default, the role Community Member has the permission action View (marked as '*') as well as that of the role Guest. Action Description Community Guest View Ability to view structure, template, or feed X, * X, * Delete Ability to delete structure, template, or feed X X Permissions Assign permission on structure or template X X Update Edit this structure or template X Similar to that of articles, you can assign permissions in the following scopes: • Individual structures, templates, or feeds • All structures, templates, or feeds in a group like the Guest community • All structures, templates, or feeds in the current portal instance Enhancement As stated, it is possible to assign permissions on individual web content, on all web content in a scope of a group, and on all web content in the current portal instance. Assigning permissions on a set of web content is missing, that is, Journal Articles. Thus, it would be better to provide folders to group web content, than to provide the ability to assign permissions based on folders. This feature is unavailable, but highly expected. CMS and WCM [ 458 ] In addition, the summary, that is, the abstract of web content, should be localizable. Moreover, the feature for adding the opportunity to mark Web Content Structure elds as required is also highly expected. What's happening? The following diagram depicts the relationships conceptually among article, template, and structure. Normally, an article may have one template associated with it. It is possible that an article may not use any template, while a template may serve many articles. This is the reason why we can view articles by a given template. In particular, each article may have a number of comments (that is, posts and replies) and ratings associated. Moreover, each article may have a list of versions, and each article may also have many tags and categories associated—thus you would be able to classify articles via categories or organize articles in your own way by tags. More interestingly, each article has a different status: approved or not approved, expired, or review. As you can see, you can set the review status on articles, for example, someone creates an article, and another group of people can review the same article. Similarly, you can set the expired status on articles. Once an article is expired, it can't be displayed anymore. It should be archived as well. Similarly, a template may have one structure associated with it or it does not employ any structure. Meanwhile, a structure may serve many templates. Thus, on one hand, we can edit a structure by a given template. On the other hand, we can view templates and articles by a given structure. In particular, each template and/or structure has a unique URL and a WebDAV URL which can be used to reference it. By the way, a structure has hierarchy, that is, each structure can have another structure as its parent in order to share common elds among structures. Chapter 8 [ 459 ] Building structures A structure is an XML (Extensible Mark-up Language) denition of the dynamic parts of the article. These parts may be text, a text box, a text Area (HTML), an image, Image Gallery, Document Library, a Boolean ag (true or false), a selection list, a multiple selection list, and so on. Actually, the structure is a specic XML schema. By structures, we can unify articles with the same numbers and types of items. For example, the page "About Us" of "Palm Tree Publications" might have ve articles, each requiring a title, a caption, and an image for the headquarters, an image and a text area for the US ofce, and a text area and an image for the Germany ofce. A structure would be created with three images, two texts, and two text areas, each named accordingly. This allows writers to create the individual articles and other texts without needing to recreate the page structure for each article. Based on the example (Original Required View), the structure lists out the eight content pieces: • One text element named "title" (1). • One text box element named "caption" (2). • Two text area elements named "text_us" (5) and "text_de" (6), in particular, a link to a document from Document Library "Open Source project" (8). • Three image elements named "image_caption" (3), "image_us" (4), and "image_de" (7). The following is the real code of the structure "Structure About Us". <root> <dynamic-element name='title' type='text' index-type='text' repeatable='false'></dynamic-element><! ignore details > </root> Creating templates Template (Web Template) is a pattern to rapidly generate and mass-produce web pages, associated to a structure. A template denes the layout of the article and determines how content items will be arranged. Templates used for creating articles can be created in XSL, Velocity (VM), CSS, Free- Marker, and so on. You can create many templates for one structure, or you can give writers discretion in deciding the best layout. CMS and WCM [ 460 ] The following is the real code of the template "Template About Us" in VM. <html> <head> <title>$reserved-article-id.getData()</title> </head> <! ignore details > </html> Constructing articles An article is the actual content of the web page, which is associated with a structure and a template. Each content piece is populated with actual text and images. Each article is integrated with two statuses of workow, either approved or not approved. Meanwhile, each article may have a set of dates associated such as display date, expiration date, review date, and so on. There are three kinds of users involved in an article's lifecycle: designers, writers, and editors. Typically, designers create structures and templates rst, then articles are written normally by writers, and editors edit and approve articles. Finally, articles are displayed or made expired by designers. By default, article types include Announcements, Blogs, News, General, Press Release, and Test. The following table depicts default type names and descriptions. Type name Description Announcements Publications made known publicly Blogs Frequent and chronological publications of personal thoughts and Web links News Information about recent events or happenings General General publications / information Press release News that is sent out or released by the company making the news.s Test Testing information It is important to note that these article types are congurable. For example, you can congure articles types in portal-ext.properties by removing Test as follows: journal.article.types=announcements,blogs,general,news,press-release The preceding code sets the list of article types. Note that the display text of each of the article types is set in content/Language.properties. Chapter 8 [ 461 ] Setup As you have seen, when setting up e-mail notication, there are default settings. Why? The portal has specied the following properties to congure e-mail notication settings in portal.properties. journal.email.from.name=Joe Bloggs journal.email.from.address=test@liferay.com journal.email.article.approval.denied.enabled=false ## ignore details journal.email.article.review.body=com/liferay/ portlet/journal/dependencies/email_article_review_body.tmpl Of course, you would be able to override these settings in web UI under More | Conguration | Setup | Current of the portlet Web Content Management. Alternatively, you may override the preceding settings in portal-ext.properties. When adding web content, you would see that the ID is generated automatically and is different from that of structure, template, and feed. Why so? The portal has set the following properties in portal.properties. journal.article.force.autogenerate.id=true journal.article.force.increment.version=false journal.article.check.interval=15 journal.article.view.permission.check.enabled=false journal.article.comments.enabled=true As shown in the preceding code, the property journal.article.force. autogenerate.id is set to true if the article IDs should always be auto-generated. You may set the property journal.article.force.increment.version to true so that only the latest version of an article, which is also not approved, can be saved without incrementing version. The property journal.article.check. interval sets the interval on which the Check-Article-Job will run in one minute increments. You may set journal.article.view.permission.check.enabled to true to check that a user has the VIEW permission on a Journal article (web content) when its content is rendered. When adding web content, you would be able to specify the abstract of web content called summary, especially small image on web content. Sometimes, you may see a message saying—wrong le extension or too big le. Why does this happen? The portal has set the following properties for small images in portal.properties. journal.image.small.max.size=51200 journal.image.extensions=.gif,.jpeg,.jpg,.png CMS and WCM [ 462 ] As shown in the preceding code, the property journal.image.small.max.size sets the maximum le size and valid le extensions for images. A value of 0 for the maximum le size can be used to indicate unlimited le size. However, the maximum le size allowed is set in the property com.liferay.portal.upload. UploadServletRequestImpl.max.size . The property journal.image.extensions sets permission on all le extensions. A le extension of * will permit all le extensions. In short, you would be able to override the preceding properties in portal-ext.properties. Conguration The Web Content Management portlet is the main management interface for integrated web publishing system, allowing users to create, edit, and publish articles, as well as article templates for one-click changes in layout, built in workow, article versioning, search, and metadata. Considering the pattern Portal-Group-Page-Content, the content of the Web Content Management portlet could be scoped into a group, for example, all pages including both private and public pages, by default. Alternatively, it could be scoped into an individual page. This means that a set of data, for example, web contents, structures, templates, and feeds, is isolated from other data of the same portlet. How can we customize scope features? The portal has default settings for the Web Content Management portlet, as follows, in $PORTAL_ROOT_HOME/WEB-INF/ liferay-portlet.xml . <configuration-action-class>com.liferay.portlet.journal.action. ConfigurationActionImpl</configuration-action-class> <indexer-class>com.liferay.portlet.journal.util.JournalIndexer</ indexer-class> <open-search-class>com.liferay.portlet.journal.util. JournalOpenSearchImpl</open-search-class> <scheduler-class>com.liferay.portlet.journal.job.JournalScheduler</ scheduler-class> <friendly-url-mapper-class>com.liferay.portlet.journal. JournalFriendlyURLMapper</friendly-url-mapper-class> <portlet-data-handler-class>com.liferay.portlet.journal.lar. JournalPortletDataHandlerImpl</portlet-data-handler-class> <webdav-storage-token>journal</webdav-storage-token> <webdav-storage-class>com.liferay.portlet.journal.webdav. JournalWebDAVStorageImpl</webdav-storage-class> <control-panel-entry-category>content</control-panel-entry-category> <control-panel-entry-weight>1.0</control-panel-entry-weight> Chapter 8 [ 463 ] <asset-renderer-factory>com.liferay.portlet.journal.asset. JournalArticleAssetRendererFactory</asset-renderer-factory> <workflow-handler>com.liferay.portlet.journal.workflow. JournalArticleWorkflowHandler</workflow-handler> <scopeable>true</scopeable> The preceding code shows that the message boards portlet will appear in the Content category in position 1, and it is scope-able, that is, you are able to use the tab Scope and change the scope from default to the current page. There are also two tags related to WebDAV, namely, webdav-storage-token and webdav-storage-class. In addition, you would see the following tags: • configuration-action-class: For setup at More | Conguration | Setup | Current. • indexer-class: Search indexing. • open-search-class: Open-search implementation. • scheduler-class: Scheduling and publishing. • friendly-url-mapper-class: Friendly URL mapping. • workflow-handler: Pluggable workow implementations—it will appear automatically in the workow admin portlet (portlet ID 151) so users can associate workow entities with available permissions. Of course, you can register your own workow handler implementation for any entity you build like Document Library documents. • asset-renderer-factory: Asset renderer framework; thus you could publish web content via the Asset Publisher portlet. As mentioned earlier, the portlets Image Gallery (Portlet ID 31) and Document Library (Portlet ID 20) are available in a page and not in the Web Content Management portlet. Why, you ask? In the $PORTAL_ROOT_HOME/WEB-INF/liferay- display.xml , the portal has the following specication: <display> <category name="category.cms"> <portlet id="20" /> <portlet id="31" /> <! ignore details > </category> <! ignore details > <category name="category.hidden"> <portlet id="9" /> <portlet id="15" /> <! ignore details > CMS and WCM [ 464 ] </category> <! ignore details > </display> As shown in the preceding code, the portlets Image Gallery and Document Library are available at category.cms (display text Content Management), while the Web Content Management portlet can be found in category.hidden. Customization As stated earlier, we have discussed how to remove Test from the web content (article) types. But how do we add a new type in the journal article types? Let's say that you are going to add an article type article-content with display text Article Content, How do we implement this? The following is an option: • Add the following line at the end of portal-ext.properties. Of course, you can change the order of article types. journal.article.types=announcements,blogs,general,news,press- release,article-content • Create a folder content under the folder $PORTAL_ROOT_HOME/WEB-INF/ classes if the folder content doesn't exist. • Create a le Language-ext.properties under the folder $PORTAL_ROOT_ HOME/WEB-INF/classes/content if the le Language-ext.properties doesn't exist. • Add the following line at the end of Language-ext.properties. Obviously, you could have different display text. article-content=Article Content In short, to add a new article type, put a new type name as part of the value of the property journal.article.types in $PORTAL_ROOT_HOME/WEB-INF/classes/ portal-ext.properties , and then set the display text in $PORTAL_ROOT_HOME/WEB- INF/classes/content/Language-ext.properties . Default tokens The token @view_counter@ will be automatically translated to the logic of the view counter increment. It means that you would be able to add the views counter through the journal articles token. To do so, you can simply add @view_counter@ anywhere in the text and save it. If you are interested in inserting simple page breaks in articles, then you can simply add token @page_break@.How, you ask? The portal has specied the following property in portal.properties. journal.article.token.page.break=@page_break@ Chapter 8 [ 465 ] As shown in the preceding code, the property journal.article.token.page. break sets the token @page_break@, which is used when inserting simple page breaks in articles. Besides the tokens @view_counter@ and @page_break@, there is a set of tokens you can use at runtime, translating to their applicable runtime value at processing time. The following is a complete list of tokens and their runtime values. @cdn_host@: themeDisplay.getCDNHost() @company_id@: themeDisplay.getCompanyId() @group_id@: groupId @cms_url@: themeDisplay.getPathContext() + "/cms/servlet" @image_path@: themeDisplay.getPathImage() @friendly_url_private_group@: themeDisplay. getPathFriendlyURLPrivateGroup() @friendly_url_private_user@: themeDisplay. getPathFriendlyURLPrivateUser() @friendly_url_public@: themeDisplay.getPathFriendlyURLPublic() @main_path@: themeDisplay.getPathMain() @portal_ctx@: themeDisplay.getPathContext() @portal_url@: Http.removeProtocol(themeDisplay.getURLPortal()) @root_path@: themeDisplay.getPathContext() @theme_image_path@: themeDisplay.getPathThemeImages() @language_id@: the language_id of the current request Custom tokens A new property has been added for custom tokens in the portal. You would be able to set up a list of custom tokens and values of custom tokens as follows. • journal.article.custom.tokens=custom_token_1,custom_token_2 • journal.article.custom.token.value[custom_token_1]=This is the rst custom token. • journal.article.custom.token.value[custom_token_2]=This is the second custom token. The portal provides capability to set a list of custom tokens that will be replaced when article content is rendered. For example, if the property journal.article. custom.tokens is set to "custom_token_1", then "@custom_token_1@" will be replaced with its token value This is the rst custom token before an article is displayed; and if the property journal.article.custom.tokens is set to "custom_ token_2 ", then "@custom_token_2@" will be replaced with its token value This is the second custom token before an article is displayed. CMS and WCM [ 466 ] Default templates There are various types of elds available in structured content, which allows velocity macros to be used to display structured content. The following is a list of velocity macros used for Journal Articles—web contents. reserved-article-id, reserved-article-version, reserved-article- title, reserved-article-create-date, reserved-article-modified- date, reserved-article-display-date, reserved-article-author-id, reserved-article-author-name, reserved-article-author-email- address, reserved-article-author-comments, reserved-article- author-organization, reserved-article-author-location,reserved- article-author-job-title. Moreover, you can use velocity macros in JournalVmUtil and VelocityVariables, request (e.g., request.attributes.USER_ID), company, companyId, groupId, journalTemplatesPath, locale, and randomNamespace. Of course, you can also use customized velocity macros in your article templates. In addition, you can get the list of available variables in VelocityVariables by referring to the Chapter 7, Customizing CMS and WCM of the book Liferay Portal 5.2 Systems Development. Publishing Web Content We have used the Web Content Management portlet to create web content (called articles) stored in WMS. Now we are ready to publish content in websites. Suppose that there are two pages, namely, "Articles" and "About Us" under the "Home" page on the Guest community public pages. The "Articles" page will display all articles, and users can navigate these articles, while the "About Us" page will display the article "About Us" only. The portlets Web Content Display and Web Content List would be very useful for these two scenarios. The Web Content Display portlet As an administrator of the enterprise "Palm Tree Publications", you need to create a page called "About Us" under the page "Home" at the Guest community and then add the portlet Web Content Display (portlet ID 56) in the page "About Us". Finally, publish the article "About Us" in the page "About Us". Let's do it by following these steps: 1. Add a page called "About Us" under the page "Home" at the Guest community public pages, if the page is not there. [...]... Download the WAR file ${layouttpl.war} from http:/ /liferay. cignex com/palm_tree/book/0 387 /chapter 08/ 2-1-2-columns-layouttpl6.0.0.1.war 2 Drop the WAR file ${layouttpl.war} to the folder $LIFERAY_ HOME/deploy when the portal is running 3 Add the following line at the end of portal- ext.proporties nested.portlets.layout.template.default=2_1_2_columns 4 Stop the portal and restart it That's it When going to... feel of the theme has been specified at /WEB-INF /liferay- look-andfeel.xml The SO theme has the following definition at /WEB-INF /liferay- lookand-feel.xml 6. 0.0+ . from http:/ /liferay. cignex. com/palm_tree/book/0 387 /chapter 08/ 2-1-2-columns-layouttpl- 6. 0.0.1.war 2. Drop the WAR le ${layouttpl.war} to the folder $LIFERAY_ HOME/deploy when the portal is running. 3 <control-panel-entry-category>content</control-panel-entry-category> <control-panel-entry-weight>1.0</control-panel-entry-weight> Chapter 8 [ 463 ] <asset-renderer-factory>com .liferay. portlet.journal.asset. JournalArticleAssetRendererFactory</asset-renderer-factory> <workflow-handler>com .liferay. portlet.journal.workflow. JournalArticleWorkflowHandler</workflow-handler> <scopeable>true</scopeable> The. token @page_break@.How, you ask? The portal has specied the following property in portal. properties. journal.article.token.page.break=@page_break@ Chapter 8 [ 465 ] As shown in the preceding code,

Ngày đăng: 12/08/2014, 21:20

Mục lục

    Chapter 8: CMS and WCM

    Web Content Management portlet

    Permissions on structures, templates, and feeds

    What's happening?

    The Web Content Display portlet

    The Web Content List portlet

    The XSL Content portlet

    Chapter 9: Social Office, Hooks, and Custom Fields

    Sample of a Chat portlet

    Checking for online friends

Tài liệu cùng người dùng

Tài liệu liên quan