Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 68 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
68
Dung lượng
1,26 MB
Nội dung
Chapter 5 [ 251 ] How does it work? The following is a sample that could bring the portlet Orbeon Forms into the portal. 1 Download the WAR le ${orbeon.forms.portlet.war} from http:// liferay.cignex.com/palm_tree/book/0387/chapter05/orbeon.war 2. Drop the WAR le ${orbeon.forms.portlet.war} in the folder $LIFERAY_ HOME/deploy when the portal is running. Create forms As you can see, once the portlet gets deployed properly, you would see the welcome message about the Orbeon Forms example portlet with a few links like viewing and editing portlet preferences and the following examples. Calculator: an example for calculator; Flickr Resize: an example for Flickr Google Suggests: sample of Google suggestions function; Translate: sample of Google translation; Wizard with Switch: sample of Wizard with Switch Wizard with PFC: sample of Wizard with PFC (PowerBuilder Foundation Class) Bookshelf form - Summary (FR): an XForm example with summary; Bookshelf form - New (FR): a New XForm example Wikis, Web Forms, and Polls [ 252 ] As shown in the following screenshot, you would be able to update the sample XForm Bookshelf form - Summary (FR). Of course, you can nd the sample XForm at the folder $AS_WEB_APP_HOME/orbeon/WEB-INF/resources/forms/orbeon/ bookshelf/form and the XForm le form.xhtml as well. Note that results of forms won't be stored in the portal but in Orbeon Forms. Polls Do you want to keep track of votes on "Is Liferay Book a proper book"? The Polls portlet (portlet ID 25) and the Polls Display portlet (portlet ID 59) are useful tools. The Polls portlet allows us to create multiple choice polls that keep track of votes and display results on a page where a lot of separate polls could be managed, and it is congurable to display a specic poll's results; while the Polls Display portlet allows us to vote for a specic poll's question and view the results. The Polls portlet First of all, we plan to add questions. As an administrator, you may need to create a lot of questions for polls, like "Is Liferay Book a proper book?", "Do you plan to buy Liferay book next month?", and then manage these questions as well as the votes on these questions. Let's do it using the following steps: Chapter 5 [ 253 ] 1. Log in as an admin, say "Palm Tree". 2. Go to Manage | Control Panel under the dock bar menu. 3. Go to Polls under the category Content of Control Panel. 4. Select a group, using default value like Content for Guest, since you are coming from the Guest public pages. 5. Click on the button "Add Question" under the portlet Polls. 6. Input the name "Is Liferay Book a proper book", description "votes"; by the way, you have options to input the name and the description in different languages. 7. Type values for choices a. and b., for example "yes" and "no"; there must be at least two choices—these can't be deleted. 8. Add more choices by clicking on the Add Choice button. After clicking on the Add Choice button, you can delete a choice by clicking on the Delete button located next to the choice name input box. 9. Check the checkbox Never Expire, using default settings; but you can uncheck the checkbox and also set an expiration date. 10. Set Permissions by clicking on the link Congure. To congure additional permissions, click on the link More; here we use default settings like checking the checkbox Public. 11. Click on the Save button to save the inputs. Wikis, Web Forms, and Polls [ 254 ] Of course, you can add other questions. After adding the question "Do you plan to buy Liferay book next month", you could view the questions. As shown in the preceding screenshot, poll questions are displayed as question name, numbers of votes, last vote date, expiration date, and actions with a set of icons: edit, permissions, and delete. By default, this portlet will display all questions scoped into the current group for the current user who has the proper permissions. Note that the Polls portlet is visible in the Control Panel under the category Content only. Editing a question All questions are editable. Supposed that we want to change the description of the questions "Do you plan to buy Liferay book next month" from "Liferay book" to "votes for Liferay book", we need to update it. Let's do it by following these steps: 1. Locate the question, say "Do you plan to buy Liferay book next month" in Polls portlet, and click on the icon Edit from the Actions next to the question. 2. Type the value of the description like "votes for Liferay book". 3. Click on the Save button to save the inputs. Deleting a question All questions are removable. Let's say that the question "Do you plan to buy Liferay book next month" does not exist anymore, then we need to delete it. Let's delete it by following these steps: 4. Locate the question "Do you plan to buy Liferay book next month" that you want to delete. 5. Click on the Delete icon from the Actions located next to the question. 6. A screen will appear asking if you want to delete this. Click on the OK button to conrm deletion. Chapter 5 [ 255 ] Note that deleting a question will delete all related votes which belong to this question. Viewing votes Suppose that you want to view votes for the question "Do you plan to buy Liferay book next month" in different ways. You can simply click on the name of the question and then click on View Results. You will see votes in percentage or other charts such as Area, Horizontal Bar, Line, Pie, and Vertical Bar. Furthermore, you can view actual voters if you have proper permissions. There are three votes on the question "Do you plan to buy Liferay book next month". You could see votes in percentage, actual voters displayed together with choice and vote date, and a Pie chart as an example. What's happening? As you can see, the portlet Polls is located at position 9 under the category Content of the Control Panel. At the same time, you would have the capability to export / import polls under the More | Export/Import. Why, you may ask? The portal has some default settings for the portlet Polls, as follows, in $PORTAL_ ROOT_HOME/WEB-INF/liferay-portlet.xml . <portlet-data-handler-class>com.liferay.portlet.polls.lar. PollsPortletDataHandlerImpl</portlet-data-handler-class> <control-panel-entry-category>content</control-panel-entry-category> <control-panel-entry-weight>9.0</control-panel-entry-weight> The preceding code shows that the portlet Polls will appear in the category Content via the tag control-panel-entry-category and position 9 via the tag control- panel-entry-weight . Meanwhile, the content polls could be backed up as a LAR le via the tag portlet-data-handler-class. Features As you can see, we can summarize the following features of the Polls portlet. • Manages (add, delete, and update) questions with multiple choices • Creates a graph showing the votes automatically • Expires the poll automatically • Fine grained permissions and role-based access control for polls Wikis, Web Forms, and Polls [ 256 ] • Each user can vote on a specic question only once • Export and import data, for example, questions, votes, and permissions, for a given group • Scope polls into different groups (communities and organizations) and portal instances The Polls Display portlet Do you want to display a specic poll's results in the Intranet? The Polls Display portlet would be a useful tool. The Polls Display portlet allows users to vote for a specic poll's questions and see the results of votes. Note that questions must be created from the Polls portlet in the Control Panel under the category Content. As shown in above image, we're going to put votes on the question "Do you plan to buy Liferay book next month" in a page of Guest public pages. Afterwards, users can vote on this question and view the vote results. At the same time, you would see one more portlet instances in the following screenshot – this is called instance-able. As you can see in the Polls Display portlet, polls votes for a given question, for example, "Do you plan to buy Liferay book next month", are displayed as percentages, numbers of votes, and choice names. The selected question name is shown at the upper-left and the total votes are shown at the bottom-left. By default, this portlet will display all votes of a given poll question for the current users who have proper permissions. How to achieve it? As an administrator, you can create a page "Polls" in the Guest public pages rst, and then add the portlet Polls Display by clicking on Add | More under the dock bar menu. Afterwards, you can select different poll questions by simply clicking on the More | Conguration icon at the upper-right of the Polls Display portlet. Then you can select a question from a list of poll questions to be published in the website by selecting Setup | Current tab. Chapter 5 [ 257 ] Of course, you could archive current settings by selecting Setup | Archive tab. Furthermore, you can congure permissions if you have the proper access right by selecting the Permissions tab and set up sharing by selecting the Sharing tab. In this example, you can select a question, for example, "Do you plan to buy Liferay book next month" under More | Conguration | Setup | Current | Question. Then you can click on the Save button when you are ready. From now on, when guests view the page "Polls", they can view vote results. When a user like "Lotti Stein" as a member of Guest signs in and views the page "Polls", she would see the vote page with a button "Vote" and a set of selections with the radio button such as "yes" and "no" rst. After choosing an answer and clicking on the Vote button, she would be able to see vote results. What's happening? As you have noticed, you can add more than one Polls Display portlet in a given page, while there is only one Polls portlet at the category Content of the Control Panel. Why are they different? The portlet Polls Display was specied as being instance-able as follows in $PORTAL_ROOT_HOME/WEB-INF/liferay-portlet.xml. <configuration-action-class>com.liferay.portlet.pollsdisplay.action. ConfigurationActionImpl</configuration-action-class> <instanceable>true</instanceable> The preceding code sets the instance-able value to true, that is, the portlet Polls Display can appear multiple times on a page. Of course, you can set it to false so that the portlet can only appear once on a page. The default value is false. The portlet Polls doesn't have the above settings, thus it uses the default value—the portlet Polls can only appear once on a page. In addition, the preceding code shows that the tag configuration-action- class allows users to congure the portlet at runtime. This is the reason that the portlet Polls Display has the capabilities to be congured at runtime. If the tag configuration-action-class isn't specied in portlet conguration, then there would be no tab Setup under More | Conguration. As you can see, the portlet Polls doesn't have this setting. Therefore, it uses the default value—the portlet Polls doesn't have tab Setup under More | Conguration. Wikis, Web Forms, and Polls [ 258 ] Features As you can see, the portlet Polls Display has the following features: • Easily congure the questions and change the question to be displayed • Instance-able: the portlet can appear multiple times on a page. Therefore, you can publish more and more questions in a page with multiple portlet instances • Publish questions across groups—for example, default group and shared global • One user can vote once only for a given question Assigning permissions As stated above, trying to log in as an administrator "Palm Tree" and going to Manage | Control Panel, you will see Polls under the category Content of Control Panel. As mentioned earlier, the user "Lotti Stein" is also a member of the Guest community. Try to log in as "Lotti Stein", and go to Manage | Control Panel. You will see that Polls under the category Content of Control Panel is invisible. What's happening? This is something related to permissions. In general, there are three levels of permissions: permissions on portlets, permissions on polls, and permissions on poll questions. The Permissions on Polls portlet The following table shows the permissions on Polls portlet. The role Community Member may set up all permissions (marked as 'X'): Access in Control Panel, Conguration, and View. While the role Guest only has the possibility to set up View (marked as 'X'). By default, a community user has the action View (marked as '*') as well as that of a guest. Action Description Community Guest Access in Control Panel Ability to access the portlet Wiki in Control Panel X Conguration Ability to congure portlet X View Ability to view the content of the portlet X, * X, * Obviously, as a member of the Guest community, "Lotti Stein" only has the permission View on the portlet Polls by default. As the role Community Member doesn't have permission Conguration and Access in Control Panel, "Lotti Stein" also wouldn't have these permissions. That is, "Lotti Stein" doesn't have ability to congure the portlet Polls and access the portlet Polls in the Control Panel. Chapter 5 [ 259 ] As you can see, even though the user "Lotti Stein" has the permission View, she wouldn't access the portlet in the Control Panel. The reason is that she doesn't have the permission Access in Control Panel. Let's say that you want the user "Lotti Stein" to be able to see the portlet Polls in the Control Panel. How would you implement it? You can assign permissions via the Roles. The following is an example—the user "Lotti Stein" is a member of the role "MB Topic Admin". 1. Log in as an admin, for example "Palm Tree". 2. First click on Roles under the category Portal of Control Panel. 3. Then locate a role, say "MB Topic Admin". 4. Then click on the Dene Permissions icon from the Actions next to the right of the role. 5. Click on the Applications | Polls link, select checkboxes Access in Control Panel and View. 6. Click on the Save button. As shown in the preceding steps, the user "Lotti Stein" has permission actions Access in Control Panel and View through the role "MB Topic Admin". That is, the user "Lotti Stein" has the ability to access the portlet Rolls in the Control Panel. Try to log in as "Lotti Stein", you would see Polls under the category Content of Control Panel. Permissions on the Polls Display portlet The following table shows permissions on the Polls Display portlet. The role Community Member may set up all permissions (marked as 'X') including Conguration and View. While the role Guest only has the possibility to set up permission View (marked as 'X'). By default, a community user has the action View (marked as '*') similar to that of a guest. Action Description Community Guest Conguration Ability to congure the portlet X View Ability to view the content of the portlet X, * X, * Obviously, as a member of the Guest community, "Lotti Stein", only has the permission View on the portlet Wiki by default. As the role Community Member doesn't have permission Conguration, "Lotti Stein" also wouldn't have this permission. That is, "Lotti Stein" doesn't have the ability to congure the portlet Polls Display in the page "Polls". Wikis, Web Forms, and Polls [ 260 ] Permissions on Polls As you can see, if logged in as "Lotti Stein", you would see Polls under the category Content of the Control Panel. You would see a set of questions displayed with Question, Number of Votes, Last Vote Date, and Expiration Date when you click on Polls, but you wouldn't see the button "Add Question". That is, the user "Lotti Stein" doesn't have the ability to add questions. Why? The following table shows permissions on Polls. Both the Community Member and the Guest roles don't have the permission Add Question by default. Action Description Community Guest Add Question Ability to add questions As you can see, as a member of the Guest community, "Lotti Stein" doesn't have the permission Add Question. If we want the user "Lotti Stein" to have the permission Add Question, how do we implement this requirement? The following is an example. 1. Log in as an admin, say "Palm Tree". 2. Click on Roles under the category Portal of the Control Panel rst. 3. Then locate a role, say "MB Topic Admin". 4. Then click on the Dene Permissions icon from the Actions next to the right of the role. 5. Click on the Content | Polls link, select Add Question checkbox under Polls. 6. Click on the Save button. As shown in the preceding steps, the user "Lotti Stein" has the permission action Add Question using the role "MB Topic Admin". That is, the user "Lotti Stein" has the ability to add questions in the portlet Polls. When you try to log in as "Lotti Stein", you would see the button Add Question under the portlet Polls under the category Content of the Control Panel. Note that the permission Add Question was used for all content poll questions in a group, not for individual poll questions. Therefore, you couldn't assign this permission to any individual content. Permissions on Polls Questions As a user at the "Palm Tree Publications" enterprise, like "Lotti Stein", you have the proper permissions View and Add Vote on the question "Is Liferay Book a proper book?". However, you do not have permissions such as Update and Delete. [...]... may need to add polls as a type of Web Content Structure, just as that of Image Gallery images and Document Library documents Moreover, you can build dynamic articles with polls For more details, you can refer to Chapter 7, Customizing CMS and WCM, Liferay Portal 5. 2 Systems Development [ 264 ] Chapter 5 Enhancement At the time of writing of this book, only those questions that get scoped to the group... screenshot [ 268 ] Chapter 6 1 First of all, log in as an administrator, say Palm Tree, and locate Go To | liferay. com under the dock bar menu 2 Add a page called "Blogs" in the Guest community public pages by clicking on Add Page under the dock bar menu 3 Add the Blogs portlet in the page "Blogs" of the Guest community where you want to manage Blogs entries by clicking on Add | More… under the dock bar... php?Action=Blink/addblink.php&url=$ {liferay: social-bookmark:url}&Title =$ {liferay: social-bookmark:title} social.bookmark.post.url[delicious]=http://del.icio.us/ post?url=$ {liferay: social-bookmark:url}&title=$ {liferay: socialbookmark:title} social.bookmark.post.url[digg]=http://digg.com/submit?phase=2&url=${li feray:social-bookmark:url} social.bookmark.post.url[furl]=http://furl.net/storeIt jsp?u=$ {liferay: social-bookmark:url}&t=$ {liferay: socialbookmark:title}... framework as follows in $PORTAL_ ROOT_HOME/WEB-INF/ liferay- portlet.xml com .liferay. portlet.blogs.util.Indexer com .liferay. portlet.blogs.util.BlogsOpenSearchImpl com .liferay. portlet.blogs.social.BlogsActivityInterpreter com .liferay. portlet.blogs.asset.BlogsEntryAssetRendererFactory... does each entry have a flag? There is a taglib called allowing you to flag any type of content or pages in any portlet If you are interested in details, you could also find implementation of flags at $PORTAL_ ROOT_HOME/html/taglib/ui/flags/page.jsp On the other hand, you could find UI taglib at $PORTAL_ ROOT_HOME/html/portlet/ blogs/view_entry_content.jspf... taglib called that allows for the posting of entries to various popular social bookmarking sites You could find the UI taglib at $PORTAL_ ROOT_HOME/html/portlet/blogs/view_entry_content.jspf If you are interested in more details, you could also find the implementation of the social bookmarks at $PORTAL_ ROOT_HOME/html/... nodes and pages • Publish wiki pages • Convert documents • Set up Web Forms • Integrate portal with Orbeon forms • How to work with Alloy UI forms • Configure the Polls portlet • Display polls In the next chapter, we're going to introduce blogs, RSS, and the WYSIWYG editor [ 2 65 ] Blogs, WYSIWYG Editors, and RSS In the intranet website "bookpub.com" of the enterprise "Palm Tree Publications", it would... social.bookmark.post.url[newsvine]=http://www.newsvine.com/_tools/ seed&save?u=$ {liferay: social-bookmark:url}&h=$ {liferay: socialbookmark:title} social.bookmark.post.url[reddit]=http://reddit.com/ submit?url=$ {liferay: social-bookmark:url}&title=$ {liferay: socialbookmark:title} social.bookmark.post.url[technorati]=http://technorati.com/cosmos/sea rch.html?url=$ {liferay: social-bookmark:url} As shown in the preceding code,... comments? There is a taglib called that allows us to comment any type of content or pages in any portlet If you are interested in more details, then you could also find implementation of comments at $PORTAL_ ROOT_HOME/html/taglib/ui/ discussion/page.jsp Meanwhile, you could find UI taglib at $PORTAL_ ROOT_HOME/html/portlet/blogs/view_entry.jspf... type="text/javascript"> Liferay. Service.Polls = { servicePackage: "com .liferay. portlet.polls.service." }; // ignore details As shown in the preceding code, it uses JSON API (for example, com .liferay portlet.polls.service.) and Velocity templates (for example, $poll) to form JavaScript functions: vote and addVote You may refer to JavaScript service.js in $PORTAL_ ROOT_HOME/html/js /liferay Of course, . images and Document Library documents. Moreover, you can build dynamic articles with polls. For more details, you can refer to Chapter 7, Customizing CMS and WCM, Liferay Portal 5. 2 Systems. you may ask? The portal has some default settings for the portlet Polls, as follows, in $PORTAL_ ROOT_HOME/WEB-INF /liferay- portlet.xml . <portlet-data-handler-class>com .liferay. portlet.polls.lar. PollsPortletDataHandlerImpl</portlet-data-handler-class> <control-panel-entry-category>content</control-panel-entry-category> <control-panel-entry-weight>9.0</control-panel-entry-weight> The. Chapter 5 [ 251 ] How does it work? The following is a sample that could bring the portlet Orbeon Forms into the portal. 1 Download the WAR le ${orbeon.forms.portlet.war} from http:// liferay. cignex.com/palm_tree/book/0387/chapter 05/ orbeon.war 2.