Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-framework-comparison-backbase-ajax-framework-vs-other-similar-framework-part-2
Packt
12 Mar 2010
10 min read
Save for later

Framework Comparison: Backbase AJAX framework Vs Other Similar Framework (Part 2)

Packt
12 Mar 2010
10 min read
An integration example We are going to discuss an example of integrating a data grid widget as it is offered by the Ext JS framework, into the Backbase framework. We have a dual purpose for this: Firstly, it will give you a feel for what it is like to program using a framework that employs JavaScript exclusively Secondly, we show that it is fairly easy to incorporate functionality that is offered by another framework or library, if for some reason you prefer that over what is offered by Backbase or if it offers something additional To start, we are going to display a data grid with XML data. For clarity, we show the code for the dataGrid here: <b:dataGrid width="100%" e_behavior="b:dataGridSortOneColumn" sortDirection="descending" sortField="startDate"> <b:dataGridCol dataField="name" width="150px"> name</b:dataGridCol> <b:dataGridCol dataField="description" width="250px"> description</b:dataGridCol> <b:dataGridCol dataField="startDate" width="90px"> start date</b:dataGridCol> <b:dataGridCol dataField="endDate" width="90px"> end date</b:dataGridCol> <b:dataSource e_behavior="b:localData" dataType="application/xml" requestType="application/xml"> <b:dataContainer> <xi:include href="data/tripdata.xml" /> </b:dataContainer> </b:dataSource></b:dataGrid> Of course, we have to embed this file into an HTML page, which we assume that you know how to do. So far, nothing new. But we know that Ext JS offers a very nice data grid and let's assume now that we would like to use the Ext JS grid in our application instead of the Backbase dataGrid. Our first question is what the example would look like, without using the Backbase framework: <html> <head> <title>XML Grid Example</title> <link rel="stylesheet" type="text/css" href="ext/ext-all.css" /> <script type="text/javascript" src="ext/ext-base.js"> </script> <script type="text/javascript" src="ext/ext-all.js"> </script> <link rel="stylesheet" type="text/css" href="ext/grid-examples.css" /> <link rel="stylesheet" type="text/css" href="ext/examples.css" /> <!-- The javascript for the example --> <script type="text/javascript" src="tripdata-grid.js"> </script> </head> <body> <h1>XML Grid Example</h1> <p> The data in the grid is loaded from tripdata.xml </p> <div id="tripdata-grid"></div> </body> </html> We hear you say :"Huh! Where is my grid?" We just see a div that suggests holding the div because of the value of the id attribute. In the previous sections, we have claimed a few times that declarative code using XML markup is preferable over a pure JavaScript approach, and here you see why. Compare this with the grid we coded for the pure Backbase solution and then decide for yourself. We do not want to pick on Ext JS in particular because all pure JavaScript libraries and frameworks are like this. Some call this unobtrusive JavaScript and will tell you it is a virtue! To know what is going on, we need to look at the JavaScript file in tripdata-grid.js: Ext.onReady(function(){ // create the Data Store var store = new Ext.data.Store({ // load using HTTP url: 'data/tripdata.xml', // the return will be XML, so let's set up a reader reader: new Ext.data.XmlReader({ // records will have an "Item" tag record: 'record', id: 'id', totalRecords: '@totalRecords' }, [ // set up the fields mapping into the xml doc // The first needs mapping, the others are very basic 'name', 'description', 'startDate', 'endDate', ]) }); // create the grid var grid = new Ext.grid.GridPanel({ store: store, columns: [ {header: "Name", width: 200, dataIndex: 'name', sortable: true}, {header: "Description", width: 400, dataIndex: 'description', sortable: true}, {header: "Start Date", width: 80, dataIndex: 'startDate', sortable: true}, {header: "End Date", width: 80, dataIndex: 'endDate', sortable: true} ], renderTo:'tripdata-grid', width:780, height:160 }); store.load();}); If you study this piece of JavaScript, you will probably understand how the grid is coded. You can see that similar concepts are used as for a dataGrid in the Backbase framework. There is a data source called Ext.data.Store with fields, there is an Ext.data.XmlReader that reads and maps the data like a data container in the Backbase framework, and there is a grid with columns, here it's called Ext.grid.GridPanel, where the columns are embedded as anonymous objects. Here is a picture of what the grid looks like when the example is executed: Another problem with this kind of JavaScript coding is that everything, the name of the XML file, the names of the columns, and the div where the grid is rendered is hard coded. If we want to use the grid in a different situation, the best we can do is cut and paste this code and adapt it to the new situation. For our example, we have already done this, using the original example and changing it to suit our trip data. What if you have five grids in your application? Do you still know from the id of the div which is which? And what particular mappings to XML fields you were using or column sorting, and so on? Or which JavaScript file contains the code to fill the grid? You would have to open up the JavaScript files to find out. To improve on the situation, you could try to generalize the data grid functionality and encapsulate it into a parameterized function. You could embed the JavaScript code in script tags right where the div is that contains the grid. Within a short time, your HTML page will become cluttered with intangible JavaScript and your UI designers will probably not be very happy. There is nothing technically wrong with putting any JavaScript in your Backbase application, although it is probably necessary to keep grid code like this outside the Backbase areas. But, there is an alternative: use the TDL markup language of the Backbase framework. We are going to encapsulate the Ext JS grid into a Backbase widget. From the description above, you would've guessed that we need four elements for our grid example. We will call them grid, gridCol, dataStore, and field. Further more, we thought it was a good idea to place the widgets in their own namespace: http://www.extjs.com/ext30. The code that you need to put into a Backbase application for an Ext JS grid, after you have done the integration, looks like this: <ext:grid width="780"> <ext:dataStore url="data/tripdata.xml"> <ext:field name="name" /> <ext:field name="description" /> <ext:field name="startDate" /> <ext:field name="endDate" /> </ext:dataStore> <ext:gridCol header="Name" width="200" dataIndex="name" sortable="true" /> <ext:gridCol header="Description" width="400" dataIndex="description" sortable="true" /> <ext:gridCol header="Start Date" width="80" dataIndex="startDate" sortable="true" /> <ext:gridCol header="End Date" width="80" dataIndex="endDate" sortable="true" /> </ext:grid> We hope you agree that this code is similar to the code we made for the pure Backbase example, except for the names of the widgets and the attributes used. We could have made them more similar to the Backbase equivalents, but we have chosen to define names closer to the names used in the pure Ext JS example. Now that you have seen what the final result is, it will be easier to understand the definition in TDL for the grid itself: The grid needs to have two attributes to hold the size of the grid: width and height. The template of the grid element needs to be a div that can be used to attach the Ext JS grid to. Using this div to put the grid, we do not need the external div with a specific id <d:element name="grid"> <d:attribute name="width" default="500" /> <d:attribute name="height" default="160" /> <d:template type="application/xhtml+xml"> <div > <d:content /> </div> </d:template> <d:handler event="DOMNodeInsertedIntoDocument" type="text/javascript"> // The rendering of the div takes place here. </d:handler> </d:element> If you look at the JavaScript code for the example (tripdata-grid.js), you will see that the grid is rendered after the page is loaded, using Ext.onReady(function(){...}. We mimic this behavior by using the DOMNodeInsertedIntoDocument event. Here is the code for the event handler: <d:handler event="DOMNodeInsertedIntoDocument" type="text/javascript"> // get the store var oStoreEl = this.getElementsByTagNameNS('http://www.extjs.com/ext30', 'dataStore')[0]; var store = oStoreEl.getStore(); // create the grid columns var aColElements = this.getElementsByTagNameNS ('http://www.extjs.com/ext30', 'gridCol'); var aCols = new Array(); for (var i=0; i < aColElements.length ; i++) { aCols[i] = { header: aColElements[i].getAttribute('header'), width: parseFloat(aColElements[i].getAttribute('width')), dataIndex: aColElements[i].getAttribute('dataIndex'), sortable: (aColElements[i].getAttribute('sortable') == 'true')? true : false }; } // create the grid var grid = new Ext.grid.GridPanel({ store: store, columns: aCols, renderTo: this.viewGate, width: parseFloat(this.getAttribute('width')), height: parseFloat(this.getAttribute('height')) });store.load();</d:handler> The code in the DOMNodeInsertedIntoDocument event handler is essentially a copy of the original example code. Look carefully at the following though: The dataStore widget is created by placing the widget as a nested element within the grid element. All we need to do is find it, using this.getElementsByTagNameNS('http://www.extjs.com/ext30', 'dataStore')[0]. The Ext JS dataStore object is created by calling the getStore() method on the dataStore element. Be careful to make the distinction between the Ext JS data.Store object that we get returned from the getStore() method and the Backbase dataStore that is returned by the getElementsByTagNameNS function. In a very similar way as finding the data store, we find a set of gridCol elements. The anonymous column elements in the array that we will need to create the grid are created using the attributes provided in the gridCol elements. Next, the grid itself, a new Ext.grid.GridPanel object is created, which has the store object and the column array we created before as arguments. The width and the height are taken from the width and height attributes, which have a default value, therefore, you will always see a grid, even if it does not have theproper size. Note in particular the renderTo attribute, which specifies this.viewGate, indicating that the grid will be rendered as child of the view node of the widget. This is exactly what we want because the grid will be shown where the grid widget is placed, and no extra div with a specific id is needed.
Read more
  • 0
  • 0
  • 1737

article-image-managing-menus-joomla-15-part-2
Packt
12 Mar 2010
9 min read
Save for later

Managing Menus in Joomla! 1.5: Part 2

Packt
12 Mar 2010
9 min read
Time for action—tweak the menu position and orientation Placing a second menu in the left-hand side column makes it very prominent. You might notice that site visitors find this second menu distracting. And after all, the static links to information about SRUP aren't really that important. Why not move the menu somewhere down the page? We'll publish the SRUP links as a horizontal menu at the very bottom. By default, at the bottom of the screen there's a copyright notice. We'll start by removing this to make room for the new menu. Removing the copyright notice involves deleting a few lines of code from the template HTML. If you want to move the menu to any other screen position you can skip the first three steps: Navigate to Extensions | Template Manager. Select the rhuk_milkyway template and click on Edit HTML. In the HTML editor screen, find and select the following code: <p id="power_by"> <?php echo JText::_('Powered by') ?><a href="http://www.joomla.org">Joomla!</a>.<?php echoJText::_('Valid') ?> <a href="http://validator.w3.org/check/referer">XHTML</a> <?php echo JText::_('and') ?> <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.</p> Press the Delete key to remove the selected code and click on Save. You can preview the frontend to check if the copyright notice has effectively disappeared. To have the About SRUP menu occupy the free position, we'll edit the menu module properties: Navigate to Extensions | Module Manager and click on the About SRUP menu module. In the Position drop-down box, select syndicate. This is the bottom most position in this template. In the Parameters section, click on Module Parameters and set the Menu Style to Legacy – Horizontal. This will make Joomla! display the links horizontally side by side in a table row. Click on Other Parameters. In the Spacer text box, enter a character to display in between the horizontal links. In this example, we'll enter two dashes. The effect is that the menu links will be displayed as follows:Who are SRUP? -- Mission Statement -- Contact Click on Apply and click on Preview. The menu has been moved to the bottom of the page: What just happened? We've just removed the copyright notice that by default appears at the bottom of the template. This creates room for a separate "About SRUP" menu. To get this menu to display at the bottom position we've changed its module position and the menu style (the links orientation) from the default values. The result is that the menu is now displayed as row of links at the bottom of the page. This makes them much less prominent. Only visitors looking for these links will really notice them. This kind of presentation is a good choice for links that don't fit the main navigation menus. In this example, we've moved links on the organization behind the site to the bottom menu. In real life, it's common to publish static links there (such as About This Site, Disclaimer, and Sitemap). Menu Manager or Module Manager?To customize a menu, you'll sometimes use the Menu Manager, and sometimes use the Module Manager. What's the difference? The Menu Manager is used for everything that has to do with the contents of the menu. Anything to do with the display of the menu module you control through the module settings. Option 3: Creating submenu items There's still room for improvement in our Main Menu. Although there are now only five links left, the way they're organized might still confuse visitors. Having a News link and a separate News Archive link, both on the same menu level, is odd. Visitors will expect a News link in a main site menu, but News Archive shouldn't really be a top-level link. Joomla! allows you to add a secondary level to a menu so let's change News Archive into a secondary link that will only display after the News link has been clicked. Time for action—create a secondary menu item Let's remove the News Archive link from the primary level in the Main Menu and show it as a sublevel link: To edit the Main Menu contents, navigate to Menus | Main Menu. Click on the title of the item you want to edit, News Archive. In the Menu Item Details section, the parent item is set to top. Change the parent item to News: Click on Save. In the list of menu items in the Menu Item Manager, the new sublevel menu item is shown indented: Click on Preview to see the output on the frontend. The Main Menu now shows four primary links. When the visitor clicks on News, a secondary link News Archive is displayed: What just happened? By assigning a parent item to a menu link you can create a submenu item. Of course, submenus aren't the only way to make secondary content visible. The main links, can point to overview pages with links to content from sections or categories. Those "secondary home pages" can make secondary menu links superfluous. However, sometimes it's better to add sublevels in the menu itself. If you have items outside of the section or category structure (such as uncategorized pages), submenus can clarify the coherence of the site. You can have main ("parent") links and secondary ("child") links. Creating split submenus When you want to use submenus on your site, you can also choose an altogether different presentation from what you've just seen. You're not limited to having submenu items shown within the main menu, as it's also possible to place main navigation links horizontally along the top of the page and display second level links in a separate menu (for example, in a vertical menu in the left-hand side column). This creates a clear visual distinction between the main menu items and their submenu items. At the same time the visitor can see that those two menus are related. The parent item can be displayed as "active" (using a different style or color) when the related submenu is displayed. An example is shown in the following screenshot. The primary link, Activities, is shown in a (horizontal) main menu bar. When this link is clicked a separate submenu shows secondary links (submenu links) to two category overview pages (Meetings and Lectures): How do you build this kind of menu system in Joomla!? In short, you create a copy of the main menu, set the original main menu to show only the top-level links, and set the copy to show only the second-level links. Joomla! will automatically display the appropriate submenu when the parent item is chosen in the top menu. We won't add a split menu system to our example site as it doesn't have the amount of content that would justify an elaborate multi-level navigation. However, feel free to experiment on your own website, as this is a very powerful technique. The following are the required steps in more detail: Suppose you have created a Main Menu with two or more links to sublevel items. Navigate to Extensions | Module Manager. Select the Main Menu module and click on Copy. The same list now contains an item called Copy of Main Menu. Open that copy and enter another title (for example, Submenu). Select Position: left. In the Module Parameters, set the Start Level to 1 and the End Level to 1. This will make the menu display only second-level menu items. Now edit the Main Menu module to show only the top-level items. Set Start Level to 0 and End Level to 0. The menu is done! The submenus now only display when the corresponding main-level link is clicked. Have a go hero—arrange menus any way you like Joomla!'s split menu capabilities allow you to design exactly the type of navigation that's appropriate for your site. You can place a row of main menu links at the top of the page and position secondary (submenu) links in the left-hand side or right-hand side column. Try to figure out what arrangement of main and secondary links fits your site best and how you can realize this in Joomla!. Here are a few suggestions (some common arrangements of site navigation) to get you going: By default, Joomla's main menu links are displayed as a vertical row in the left-hand side column. How can you achieve a horizontal row of main menu links, as shown in the first three images above? Have a look again at the Time for action - Tweak the menu position and orientation earlier in this article. It shows the easiest way to change the menu orientation in Joomla!, selecting the appropriate Menu Style in the menu module editing screen. However, there are templates that are specifically designed to support horizontal menus. These contain the appropriate module positions and module styling for a main horizontal menu (and do a much better job at this than the default Joomla template). Exploring menu module settings When creating or editing a menu module, the module details and parameters allow you to control exactly where the menu is shown and how it displays. In many cases, the default settings will do—but if you really want control over your menus, it's a good idea to explore the wide range of additional possibilities these settings provide. In the Module Manager, click on the menu name (such as Main Menu or About SRUP). The Module: [Edit] screen appears. The three main sections of the Module: [Edit] screen are Details, Menu Assignment, and Parameters.
Read more
  • 0
  • 0
  • 2117

article-image-multi-user-environment-mediawiki-11-sequel
Packt
12 Mar 2010
9 min read
Save for later

Multi-user Environment in MediaWiki 1.1- A Sequel

Packt
12 Mar 2010
9 min read
Time for action-reverting to previous content In our example, it appears that someone has not only changed the text for one of our pages, but someone has vandalized it as well. While one edit may be a legitimate change, as the sysop we don't want this page edited by the public, so we are going to revert to the previous page. In the case of vandalism, we have no other choice than to go back to the clean version of the page. The following screenshot shows the two changes made to the page. Following the screenshot, we will learn how to revert to the original page. Open your wiki and navigate to the page you wish to make changes to. Click on the history tab at the top of the page and you will be taken to the page history. Locate the time and date of the revision you wish to revert to. Click on the ti me and date link. In our example, we selected 21:39, 14 September 2009. We will now be taken to the page that existed on that date, and at that time. Click on the edit tab at the top of the page. You will now be taken to the editing page. As we are reverting, we don't need to make any changes. It is good practice to put something in the edit summary referring to the fact that you reverted to an earlier page. Click on Save page. A newline will be added to the page history reflecting the changes you just made as shown in the following screenshot: In the case of vandalism, it may be wise to check the contribution history of the user who vandalized the article by clicking on their IP address or user name. Clicking on their IP will often bring you directly to their user contribution page. If you are able to click on their user name, that will bring you to their user page. In the lower-left corner, there is a toolbox with a User contributions link. Click on this link. If this user is vandalizing many articles, you may need to take action. What just happened? When we noticed that our page had been edited and we did not approve of the changes, we used the page history to revert to an earlier version of the content that met our approval.In our example, we were able to revert from a legitimate change as well as an attack by a vandal. We also learned that when a vandal strikes our wiki, we may want to check their User contributions page to see what other articles they may have wreaked havoc on. More administrative tools MediaWiki has quite a few more tools that the administrator can use to help monitor a multi-user wiki. While some of these have been mentioned already in the text, such as edit summaries and minor changes, they need further explanation. Edit summaries We had a brief discussion about edit summaries in the last exercise when we were reverting to an earlier revision of a page. It is highly recommended that anyone editing a page fills in the Summary field because it makes it easier for you and your fellow contributors to understand what has been changed. It is also extremely helpful when going through the history of the page. The edit summary box can hold one line of 200 characters. If you attempt to enter more than this, only the first 200 characters will be displayed and the rest will be disregarded. In the case of a small addition to an article, it is highly recommended the full text of this addition be copied to the Summary field, giving a maximum of information with a minimum of effort. This way, readers of the summary will be unlikely to check the page itself as they already know the extent of the edit. These kinds of summaries allow users to check Recent changes, page history, and User contributions very efficiently. In addition to a summary of the change itself, the Summary field may also contain an explanation of the change. Note that if the reason for an edit is not clear, it is more likely to be reverted, especially in the case that some text is deleted. To give a longer explanation, use the talk page and make a note about it in the edit summary. After saving the page, the summary cannot be edited, so try to avoid any errors. Minor changes If you look at the previous screenshot, you will see a check box labeled This is a minor edit.Minor edits have been glossed over in this article but now, we will give them a bit more attention. When editing a page, logged-in users may mark a change to a page as a minor edit. Minor edits deal with changes such as correcting a type, changing the format of the content, or changing the presentation of the content. Minor edits usually do not involve changing the actual content of the page. By contrast, a major edit makes the article worth reviewing for anyone who watches it closely. Therefore, any change that affects the meaning of an article is not minor, even if it involves one word. The distinction between major and minor edits is significant because you may decide to ignore minor edits when viewing recent changes. Logged-in users can even set their preferences to not display such edits. No one wants to be fooled into ignoring a significant change to an article simply because it was marked minor, of course. So remember to consider the opinions of other editors when choosing this option. Users who are not logged into the wiki are not able to mark changes as minor because of the potential for vandalism. The ability to mark changes as minor is another way you can entice your visitors to register. It is always better to mark the edit as minor if you are doing the following changes: Spelling corrections Simple formatting (capitalization, bold, italics, and so on) Formatting that does not change the meaning of the page (for example, adding horizontal lines or splitting a paragraph into two where such splitting isn't contentious) Obvious factual errors (changing 1873 to 1973, where the event in question clearly took place in 1973) Fixing layout errors We have to remember the following things when we are marking an edit as minor edit: Any change to the wikitext, even if it does not affect the presentation of the page in HTML (for example, adding a space or a line break), will still be treated as a change according to the database. Marking a major change as a minor one is considered bad manners, especially if the change involves the deletion of some text. Reverting pages is not likely to be considered minor under most circumstances. W hen the status of a page is disputed, and particularly if an edit war is brewing, then it's better not to mark any edit as minor. Reverting blatant vandalism is an exception to this rule. A user's watchlist will only list the most recent change made to a page, even if that edit was minor. Therefore, a minor change will supersede a major one in the watchlist. This is because a user who keeps a watchlist is generally interested in all changes made to a page. If you are uncertain about the changes made to a page, double-check the page history. If you accidentally mark an edit as minor when it was in fact a major edit, you should make a second "dummy" edit, but make a note in the edit summary that "the previous edit was major". As a trivial edit to be made for this purpose, just opening the edit box and saving (changing nothing) will not work, neither will adding a blank space at the end of a line or a blank line at the end of the page—in these cases the edit is canceled and its summary discarded. However, you can add an extra space between two words, or can even add a line break. These changes are preserved in the wikitext and recorded as a change, although they do not change the rendered page. It may be worth communicating any disagreement about what is minor via Talk or a message to the contributor, being careful to avoid a flame war with other users. There is a gray area here, and many contributors will appreciate feedback on whether they've got it right. It is also good to remember the following terms since we are using them every now and then: Dummy edit: A dummy edit is a change in wikitext that has little or no effect on the rendered page, but saves a useful dummy edit summary. The dummy edit summary can be used for text messaging, and correcting a previous edit summary such as an accidental marking of a previous edit as "minor". Text messaging via the edit summary is a way of communicating with other editors. Text messages may be seen by dotted IP number editors who don't have a user talk page, or editors who haven't read the subject's talk page, if it exists. A dummy edit should be checked as "minor" by logged-in editors. Consider the following example: Changing the number of newlines in the edit text, such as putting a newline where no newline exists or adding one more newline to two existing newlines, has no effect on the rendered page. But changing from one newline to two newlines makes a rendered difference as it creates spacing between the contents in Mediawiki and may not be a dummy edit. Adding newlines to the end of the article will not save as a dummy edit. Dotted IP number editors are editors who are referred to by their IP address in the dotted decimal notation rather than a username, for example, 192.168.1.230. Null edit: A null edit occurs if a page save is made when the wikitext is not changed, which is useful for refreshing the cache. A null edit will not record an edit, make any entry in the page history in recent changes, and so on. The edit summary is discarded. Consider the following examples: Opening the edit window and saving. Adding newlines only to the end of the article and saving is also a null edit.
Read more
  • 0
  • 0
  • 1458

article-image-set-your-own-profile-mahara-part-2
Packt
12 Mar 2010
6 min read
Save for later

Set up your own Profile in Mahara: Part 2

Packt
12 Mar 2010
6 min read
Adding a text box to your profile page One useful thing you can add to your profile page, or any View, is a text box. These are extremely useful for giving meaning to your web page. You can use the text box to put in descriptions or snippets of information that help structure your View in a more logical way. In the next Time for action section we look at how exactly you add a text box to your profile page. Along the way, you will encounter for the fi rst ti me Mahara's drag-and-drop user interface for adding items to Views, which is is very exciting! One of the things that make Mahara stand out is its flexible framework for creating web pages. It is extremely intuitive as you will see, and reflects in some ways how you would create a poster display—taking bits of information such as text and pictures, moving them around until you are happy with their location and then sticking them in place. Of course, the advantage is that, with Mahara, they aren't stuck down forever with glue and can be repositioned whenever you like. Let's add a text box to our profile View. Time for action – creating a text box for your profile page Click on the Edit Profile Page button in the Profile submenu. You will see a page that looks a bit like this: You will notice that you are being encouraged to select different blocks from within a set of six tabs at the top of the screen and drag them down onto your View page. Later we will be looking at these blocks and learning how to position them on our page. However, right now we are focusing on how to work with the text box. Click into the tab called General. You should see this: Click and drag the text box icon somewhere onto the space below to position it amongst the other blocks already on your View layout. You will see the other blocks move as you are dragging to make space for the text box. You will also see a dotted gray line showing you where the new block will appear. Here is a basic diagram showing the drag-and-drop action: Can't drag and drop in Internet Explorer 6.The functionality allowing us to drag blocks around the page when we are editing a Mahara View is enabled by JavaScript. Most modern browsers support JavaScript as default, including Firefox, Safari, and Internet Explorer 7 and 8. Unfortunately, many people are still running Internet Explorer 6 and Mahara's drag-and-drop facility won't work in this browser because of problems (or bugs) it has with layout that newer browsers don't. You can still use IE 6 without the drag and drop feature, and use the radio buttons instead, but we recommend you to upgrade your Internet Explorer browser or (even better) download an open source browser such as Mozilla's Firefox: www.mozilla.com/firefox/. A box will open. Click into the Block Title and add your title. Click into the Block Content box. Type in here the body of your text box. Janet Norman decided that she would like to have some information about Mahara on her profile page. Click Save to finish and that's it, you've added you first text box. What just happened? You just added a text box to your profile page. A section on your View is called a block, and you've just learned how to add a new text box by clicking and dragging it onto your profile page. Blocks are what Mahara uses to personalize your profile page and your Views. You can add and delete blocks, and move them around. There are actually quite a variety of blocks, and the Mahara developers are keen to keep adding to the list. We have started here with a basic text box, as it's probably the one you will use most frequently. One of the things you probably noticed when adding text to your text box was that you have a number of editing options available. Janet would like to make her text look more interesting, so let's revisit our text box and look at what these options do. Options in the text editor You will probably find that you have already used most of the options in the text editor when working in word processing programs. Let’s have a quick look at some of the most commonly used options. Icons Function These icons can be used to make your characters bold, italicized, or underlined   Align your text to the left, to the center, to the right or justify your text into a square, newspaper-style layout.   Add bullets or numbers to your lists of text.   To toggle your page into HTML mode.   Add a hyperlink to your text.   Break an existing hyperlink.   Now let's try formatting some of the text you have just entered. Time for action – editing a text box by adding a hyperlink Open the text block you created earlier for editing. You can do this by clicking on the icon that looks a little bit like a cog at the top of the block. We are going to add a hyperlink to the text. Did you notice that the two link icons are grayed out and unclickable? This is because you can't hyperlink to something before you have highlighted it. Do this by clicking and dragging you mouse over the text you want to hyperlink. Now you should see the two hyperlink buttons in color. Click the Make Hyperlink button (the one that looks like a chain) to start creating your hyperlink from the word(s) that are highlighted. Jane has chosen to make a link from the word "Mahara" to the Mahara website. You should see a new dialogue box similar to the one below: You now get the chance to enter your link. Jane therefore enters a link to the Mahara website http://mahara.org. She has also added a Title to her link. This title displays when the user hovers over the link. Click Insert, which will create your link. To finish, remember to click Save, otherwise you will lose the work you have just done. You should see the link highlighted in a different color: What just happened? You just edited a text box by adding a hyperlink. In the last section, we showed you that HTML editing is one of the options in the text editor. Web developers have traditionally used HTML code to write their web pages. It will be useful for regular Mahara users to learn a bit of basic HTML in order to gain more control over their Mahara View pages. The World Wide Web Consortium offers free, beginner-level HTML tutorials at http://www.w3schools.com/html/.
Read more
  • 0
  • 0
  • 1648

article-image-cissp-vulnerability-and-penetration-testing-access-control
Packt
12 Mar 2010
6 min read
Save for later

CISSP: Vulnerability and Penetration Testing for Access Control

Packt
12 Mar 2010
6 min read
IT components such as operating systems, application software, and even networks, have many vulnerabilities. These vulnerabilities are open to compromise or exploitation. This creates the possibility for penetration into the systems that may result in unauthorized access and a compromise of confidentiality, integrity, and availability of information assets. Vulnerability tests are performed to identify vulnerabilities while penetration tests are conducted to check the following: The possibility of compromising the systems such that the established access control mechanisms may be defeated and unauthorized access is gained The systems can be shut down or overloaded with malicious data using techniques such as DoS attacks, to the point where access by legitimate users or processes may be denied Vulnerability assessment and penetration testing processes are like IT audits. Therefore, it is preferred that they are performed by third parties. The primary purpose of vulnerability and penetration tests is to identify, evaluate, and mitigate the risks due to vulnerability exploitation. Vulnerability assessment Vulnerability assessment is a process in which the IT systems such as computers and networks, and software such as operating systems and application software are scanned in order to indentify the presence of known and unknown vulnerabilities. Vulnerabilities in IT systems such as software and networks can be considered holes or errors. These vulnerabilities are due to improper software design, insecure coding, or both. For example, buffer overflow is a vulnerability where the boundary limits for an entity such as variables and constants are not properly defined or checked. This can be compromised by supplying data which is greater than what the entity can hold. This results in a memory spill over into other areas and thereby corrupts the instructions or code that need to be processed by the microprocessor. When a vulnerability is exploited it results in a security violation, which will result in a certain impact. A security violation may be an unauthorized access, escalation of privileges, or denial-of-service to the IT systems. Tools are used in the process of identifying vulnerabilities. These tools are called vulnerability scanners. A vulnerability scanning tool can be a hardware-based or software application. Generally, vulnerabilities can be classified based on the type of security error. A type is a root cause of the vulnerability. Vulnerabilities can be classified into the following types: Access Control Vulnerabilities It is an error due to the lack of enforcement pertaining to users or functions that are permitted, or denied, access to an object or a resource. Examples: Improper or no access control list or table No privilege model Inadequate file permissions Improper or weak encoding Security violation and impact: Files, objects, or processes can be accessed directly without authenticationor routing. Authentication Vulnerabilities It is an error due to inadequate identification mechanisms so that a user or a process is not correctly identified. Examples: Weak or static passwords Improper or weak encoding, or weak algorithms Security violation and impact: An unauthorized, or less privileged user (for example, Guest user), or a less privileged process gains higher privileges, such as administrative or root access to the system Boundary Condition Vulnerabilities It is an error due to inadequate checking and validating mechanisms such that the length of the data is not checked or validated against the size of the data storage or resource. Examples: Buffer overflow Overwriting the original data in the memory Security violation and impact: Memory is overwritten with some arbitrary code so that is gains access to programs or corrupts the memory. This will ultimately crash the operating system. An unstable system due to memory corruption may be exploited to get command prompt, or shell access, by injecting an arbitrary code Configuration Weakness Vulnerabilities It is an error due to the improper configuration of system parameters, or leaving the default configuration settings as it is, which may not be secure. Examples: Default security policy configuration File and print access in Internet connection sharing Security violation and impact: Most of the default configuration settings of many software applications are published and are available in the public domain. For example, some applications come with standard default passwords. If they are not secured, they allow an attacker to compromise the system. Configuration weaknesses are also exploited to gain higher privileges resulting in privilege escalation impacts. Exception Handling Vulnerabilities It is an error due to improper setup or coding where the system fails to handle, or properly respond to, exceptional or unexpected data or conditions. Example: SQL Injection Security violation and impact: By injecting exceptional data, user credentials can be captured by an unauthorized entity Input Validation Vulnerabilities It is an error due to a lack of verification mechanisms to validate the input data or contents. Examples: Directory traversal Malformed URLs Security violation and impact: Due to poor input validation, access to system-privileged programs may be obtained. Randomization Vulnerabilities It is an error due to a mismatch in random data or random data for the process. Specifically, these vulnerabilities are predominantly related to encryption algorithms. Examples: Weak encryption key Insufficient random data Security violation and impact: Cryptographic key can be compromised which will impact the data and access security. Resource Vulnerabilities It is an error due to a lack of resources availability for correct operations or processes. Examples: Memory getting full CPU is completely utilized Security violation and impact: Due to the lack of resources the system becomes unstable or hangs. This results in a denial of services to the legitimate users. State Error It is an error that is a result of the lack of state maintenance due to incorrect process flows. Examples: Opening multiple tabs in web browsers Security violation and impact: There are specific security attacks, such as Cross-site scripting (XSS), that will result in user-authenticated sessions being hijacked. Information security professionals need to be aware of the processes involved in identifying system vulnerabilities. It is important to devise suitable countermeasures, in a cost effective and efficient way, to reduce the risk factor associated with the identified vulnerabilities. Some such measures are applying patches supplied by the application vendors and hardening the systems.
Read more
  • 0
  • 0
  • 7042

article-image-multi-user-environment-mediawiki-11
Packt
12 Mar 2010
2 min read
Save for later

Multi-user Environment in MediaWiki 1.1

Packt
12 Mar 2010
2 min read
Many organizations use MediaWiki as the platform to deliver content with no option for editing or creating. Even though these options exist, in its truest form, a wiki is a collaborative environment. This means we may have multiple users accessing the system and participating in building the wiki. The count might be more than few thousands for a given moment if the site is popular. With any platform that caters to a diverse group of people, issues are bound to arise. Contributors may make mistakes in their articles, there may be conflicts over changes made to a page, and many other issues can arise when dealing with people. Working in a multi-user environment definitely has its advantages, but as a wiki administrator, it is important to keep in mind that not all users have good intentions. As the system is open, anyone—including malicious users with bad intentions—can partake in any activity on the site. An open system can face a lot of user-related problems. The first major problem is that anyone can edit or add contents. This can be dangerous if the added content is not legal or if it is copyrighted. As the user can avoid being tracked, the site has to take the responsibility for such acts. Another major attack can be on the content itself—people with bad intentions can change content without any reason or present false information. Vandalism is also a common occurrence on such sites, and the concerns regarding false information have plagued even the most well-respected of sites—Wikipedia. In this article, we will take a detailed look at these issues and learn how we can address them.
Read more
  • 0
  • 0
  • 1686
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-lotus-quickr-connectors-and-lotus-sametime
Packt
12 Mar 2010
3 min read
Save for later

Lotus Quickr Connectors and Lotus Sametime

Packt
12 Mar 2010
3 min read
Lotus QuickPlace/Quickr is IBM's team collaboration product. It provides template-based services and a set of content connectors, allowing end users to quickly create interactive team places, all without the need for administrator intervention. Visit http://www.ibm.com/software/sw-lotus/products/product3.nsf/wdocs/ltwhome. Lotus Sametime is IBM's unified communications and collaboration product.It provides enterprise-class instant messaging and web conferencing services, as well as a platform for many other capabilities. This includes telephony and voice integration services. Visit http://www.ibm.com/software/sw-lotus/products/product3.nsf/wdocs/st75home. Read Integrating Lotus QuickPlace/Quickr with IBM Lotus Notes and Domino 8.5.1 article to get a much better understanding of the topic being discussed. Lotus Quickr Connectors One of the key features of Quickr is the openness provided by the connector architecture. These connectors allow for direct interaction with the Quickr servers independently of the backend architecture (WebSphere Portal/Domino). The installation of these is via the large link on the main page of either edition. The preceding link will initiate the download and  installation of the connector's package. This is handled as a standard MSI package starting you at the welcome screen. Click Next to continue. Next is the license text. After you have read all of the content and gotten agreement from your legal department, click Next to continue. The next screen allows for a custom setup of the Connectors. Select the desired options and click Next. If you select Notes as a Quickr Connector type, you will be asked for the file page of the Notes client installation. Change the path, if necessary, to match your installation and click Next . If you select Sametime as a Quickr Connector  type, you will be asked for the file page of the Sametime client installation. Change the path, if necessary, to match your installation and click Next. The connector will now be installed on your machine. After the installation process has completed, the following screen will appear. The two options can remain selected if necessary. It is advised to at least launch the Microsoft Windows Explorer connector. This will allow you to add Quickr servers to the configuration.           From the Quickr icon on the Microsoft Windows task bar, select Add Places to install your first connection to a Quickr server. At least one connection is necessary. It does not matter if this is pointing to a J2EE or Domino edition backend, as both will function the same via the connectors. In the Add Places section of Lotus Quickr Connectors dialog, enter the server path and user credentials for the server. This could be different for different Quickr servers, depending on the directory configuration. After entering the information, click on Next.
Read more
  • 0
  • 0
  • 2144

article-image-set-your-own-profile-mahara-part-1
Packt
12 Mar 2010
7 min read
Save for later

Set up your own Profile in Mahara: Part 1

Packt
12 Mar 2010
7 min read
For this article, we are going to concentrate on the Profile tab of the main menu. The very first thing that most Mahara users want to do is customize their own profile space, making it unique to them. We will show you how to do that. For the following examples, we will be working with Janet Norman of PI Inc, showing you how she has configured her profile space. Why not set up your own profile in the demonstration site as you work through the examples? Let's start by looking at profile information. Profile information Later you will set up your own profile page—showing yourself and your knowledge off to others in an attractively personalized way. However, before you do that, you need to add some profile informati on. Your profile information is the first example we will see of "stuff " that you can add to Mahara. When we say stuff we simply mean informati on, or items that can then be viewed later or arranged into web pages, which we will see when we look at your profile page. You are now going to set up some profile information as "stuff " that you can select from and use. We will look at three types of profile information—your profile itself, profile icons, along with your resumé, goals, and skills. Editing your profile Let's show you how to edit your profile. Any information you enter into your profile is private from everyone except the Mahara Site Administrators. You will get to choose who can view what, later on in the Mahara process. Time for action – editing your profile Click the Profile button on the main menu. You will notice that Mahara has opened the Profile submenu. The Edit Profile tab is selected when you first enter your profile space. Let's take a quick look at Janet's profile. You will notice that the About Me tab is selected. Janet has already entered her name. Say something about yourself! Scroll down to the Introduction section of the About Me page and enter some text. Here is what Janet Norman typed in: Whenever you make any changes, click the Save Profile button at the bottom of the page. Next, click the Contact Information to the right of the About me tab. You will see that you are expected to fill out some telephone numbers and addresses. The first thing you should notice is that you can have more than one e-mail address in a Mahara site. To add another e-mail address, click the link to Add email address. The e-mail address will receive a confi rmati on e-mail from the Mahara site and you will have to go to your e-mail account and follow the link to confirm it is genuine. You can now use radio buttons to toggle which e-mail address you would like to use as default for your account. This selection is important because it is at this address that you will receive system messages. You will also noti ce that you can delete an e-mail address by clicking the small, red-colored cross to the right of the e-mail address. Fill in your contact information on this page. Remember, you don't have to complete all the fields if you don't want to. Click the tab called Messaging. Mahara will bring together the types of people you are likely to engage with in live text, audio, and video conferences. People can display these contact details to each other in their profile page and other web pages. Enter your contact details for the facilities you use on this page. If you are still not using live conferencing tools, perhaps now is the time to start thinking about it. Finally, click the tab called General. On this page enter your Occupation and Industry (remember to click the Save Profile button when you have finished). Janet Norman typed this: What just happened? You have just completed your profile by entering some information about yourself, including your personal information, what messaging/conference tools you use, and your Industry background. Both the Contact Information and Messaging information are private and will only be seen if you add them to a web page. This is because you don't necessarily want anybody in the Mahara site to be able to see your telephone number and address for security reasons. Help!If you have found so far that you wish you had a bit more information about what certain options do, then don't worry! Mahara is very well documented software. On most pages, you will see litt le question mark icons. If ever in doubt, click on these and you will be given very useful and specific help relati ng to your area of doubt. Let's now continue to add some more stuff into our profile, with profile icons. Profile icons Profile icons bring your profile to life! They are the first thing that people see about you when they are interacting with you in different areas of the site. Mahara allows you to upload up to five different profile icons. This becomes very useful when you are making web pages out of your stuff . You can present yourself to different audiences in different ways, simply by altering your profie icon. For example, you can display a serious passport photo to your professional work colleagues, a more informal photo to your closest work colleagues, perhaps an avatar for public groups where you would like to be a bit more anonymous, and a picture of you having fun at a party for some of your more social interactions. Time for action – uploading your profile icons Let's get a few different profile icons online. Click the Profile submenu button called Profile Icons. Click Browse to find the profi le icon you want to upload from your computer or USB stick (or wherever). Don't forget to add an Image Title for your profile icon before you click the upload button. You are allowed to upload up to five profile icons and you can delete any icon at any point. You will need to choose one of your icons as your default profile icon which should probably be a fairly sensible one. Janet Norman has already uploaded two profile icons: What just happened? You have just uploaded a profile icon to represent yourself in your Mahara site. As we saw in the Time for action section, Janet has uploaded two icons. One of these is an avatar of herself and the other is the company logo. She plans to use the company logo in places where she would like to appear more professional, whereas the avatar will be used more generally. Make yourself an avatar! An avatar is simply a character or cartoon representation of yourself. If you don't want a passport photograph as your profile icon, an avatar is a good alternative. There are many websites that help you create your own. A few of the most fun include the Simpsons Avatar Maker (http://www.simpsonsmovie.com), DoppelMe (http://www.doppelme.com), and Mr Picassohead (http://www.mrpicassohead.com). Editing your resumé goals and skills No longer will you need to trawl through ancient hard drives trying to find the resumé you last wrote five years ago. Instead, you can keep your resumé information within your Mahara system and update it when you make changes. How impressive will you look when you show your resumé to your prospective employer as a web page rather than on a piece of paper. There are three tabs remaining in the profile submenu that allow us to add stuff to our site. The remaining things we can add are: Resumé information: You can record your career and educational achievements. Goals information: Here you can set ourselves personal, academic, and career-related targets for your future. Skills information: You can record for yourselves what you perceive to be your personal, academic, and work-related skills.
Read more
  • 0
  • 3
  • 3522

article-image-framework-comparison-backbase-ajax-framework-vs-other-similar-framework-part-1
Packt
12 Mar 2010
6 min read
Save for later

Framework Comparison: Backbase AJAX framework Vs Other Similar Framework (Part 1)

Packt
12 Mar 2010
6 min read
The landscape of client-side technologies Since 2005, when the term AJAX was invented, many JavaScript libraries and tools have popped up. In fact, there have been several tools earlier to aid DHTML development, which can be seen as predecessors for the AJAX tools and libraries. One of these is the earlier version of the Backbase framework, and another example is Bindows. Some of those libraries survived the AJAX technology hype and grew into a solid base for many RIA projects and services, whereas some vanished.Libraries that survived have gone through a series of transformations and refactoring phases as well as marketing repositioning attempts. By now, there are hundreds of libraries, frameworks, and other tools, and it is not easy at all to find your way in this abundance and make the right choice. Before we get to the actual comparison of the Backbase AJAX framework against similar solutions, we should look around to see how the canvas of relevant technologies is laid out. So, let's first go through the tree of technologies until we end up in a group where Backbase resides. We mentioned earlier in this book that there were a number of other versions of the Backbase framework, all Java-related, such as a JSF Edition. These products are currently supported only for existing customers and not available for new development. Therefore, they are not included in this comparison. Of course, it is still possible to easily use Java with the Backbase Client Framework! Server-side and client-side Until recently, we thought of web applications as websites being created and run on a web server somewhere on the Internet. The server-side application was entirely responsible for the page generation: it checked for authorization, retrieved data from data sources, and generated static web pages filled in with the data. With time, server output in HTML became enhanced with scripts running on the client-side, but the page generation and the business logic between user interactions was still processed on the server-side. To aid such rather complex development, several technologies and frameworks are available, for example, GWT, ASP.NET MVC, and ZK. Today, web applications development has radically changed; the frontend of the application is moving to the client-side, the web browser. Both application logic and UI generation are moving with it. This is exactly where client-side toolkits come into play. Let's proceed with those and ignore the server-dependent frameworks in the rest of this article. See the end of this article for more information on the frameworks mentioned earlier in this section. Client-side libraries and frameworks Most of JavaScript toolkits position themselves today as frameworks, although they called themselves libraries earlier. Some may really have evolved into a framework, whereas others are still, libraries. In reality, it is not easy to differentiate between the two types of software: libraries and frameworks. The common understanding of a library concludes that a library is designed to execute a well-defined task, for example, a library can decode data or, in the case of a JavaScript toolkit, it can simplify DOM traversal. As a library is designed to execute a certain task or a couple of tasks, it is usually not extensible in nature. A software framework usually has wider scope. Eventually, it could be composed of several libraries. A framework, opposite to what a library does, allows and sometimes even requires extensions. A JavaScript framework often provides means to create widgets; it enables its own event's flow and provides well-designed APIs to those widgets. Is it important to know whether a certain JavaScript toolkit is a library or a framework? We believe, yes, it is important. In practice, you will see that a library is often used to fine-tune web pages, while a framework is used to build true client-side applications. For example, the Script.aculo.us library provides great visual effects that can be used to improve web page appearance and interaction, while the framework qooxdoo can hardly be used for that purpose; it is only suitable for building an application. Being categorized as a library does not decrease the quality or capabilities of a toolkit. Instead, it properly positions software so that a right choice can be made based on the purpose of using it. jQuery, MooTools, Prototype.js, and Script.aculo.us are all JavaScript libraries, and they are great at what they had been designed for: enhancing web pages without changing much in the overall development process. We will not include the JavaScript libraries mentioned in this section further in our comparison. Flash, Silverlight, and JavaScript-based frameworks For the sake of completeness of the technology comparison, it may also be interesting to check out how some AJAX frameworks stand compared to plugin-based solutions, such as, Flash or Silverlight. Both Flash and Silverlight employ XML for application layout, MXML and XAML respectively. Both Flash and Silverlight have a way to extend their component base by implementing custom tags in custom namespaces, something that the Backbase AJAX framework also offers. Both platforms, similar to some JavaScript-based frameworks, implement the Document Object Model, which enables document access and event flow, although Silverlight provides a custom, lighter version of the DOM API. Styling is not done with CSS, in either Flash or Silverlight. The plugin-based solutions such as Flash and Silverlight are both great choices for building Rich Internet Applications that run on a desktop. They are not usable for mobile devices because these plugins do not run on them. Client-side GUI framework and application framework There is another category of frameworks that we would like to exclude from our comparison: the application frameworks. Examples of such a framework are Cappuccino, SproutCore, and PureMVC. PureMVC is, as the name suggests, a framework that is there to help you implement the MVC part of your application. To position Cappuccino, we quote here some text from their website, which sums up very nicely what it is trying to achieve: Cappuccino is not designed for building web sites, or making existing sites more "dynamic". We think these goals are too far removed from those of application development to be served well by a single framework. Projects like Prototype and jQuery are excellent at those tasks, but they are forced by their nature to make compromises which render them ineffective at application development. On the other end of the existing frameworks are technologies like SproutCore . While SproutCore set out with similar goals to Cappuccino, it takes a distinctly different approach. It still relies on HTML, CSS, JavaScript, Prototype, and an entirely new and unique set of APIs. It also requires special development software and a compilation step. The Backbase AJAX framework is not an application framework; rather it is a GUI framework. For smaller to medium-sized applications, you do not need an application framework, as long as you structure your application correctly. For larger applications, you could consider developing your own client MVC support, or try to integrate with a framework like PureMVC.
Read more
  • 0
  • 0
  • 5343

article-image-upgrading-home-network-small-business-system-using-pfsense
Packt
11 Mar 2010
7 min read
Save for later

Upgrading a Home Network to a Small Business System Using pfSense

Packt
11 Mar 2010
7 min read
I believe the most significant leap in understanding networking comes from learning how to turn a simple home network into a full-featured small business environment.  Surprisingly, I’ve never come across a plain-language tutorial on how to do just that.  However, I’ve learned a great deal throughout my career so far and today, I intend to write the article I wish I had found several years ago. Prerequisites Cable/DSL/FIOS Modem—Any internet connection device that has Ethernet out will do. Wireless Router or Switch—Either will do. Be sure to read the next section for clarification. Firewall Computer —The key to a business type environment is a dedicated hardware firewall.  We’ll be using pfSense, and if you check the hardware requirements you’ll see that an older machine will do nicely.  Any machine to be configured as a firewall requires a minimum of two Ethernet ports. Client Computer—A laptop or desktop computer to be used as a client.  Windows or Linux will both work, but I’ll only be referencing Windows commands in this tutorial. Disable All Security Software on All Client Machines—Make sure you disable Windows Firewall and any other security software you may have.  This introduces an added level of software security that will only hang you up while you’re trying to establish that your hardware firewall is working correctly. Network Device Clarification It’s very important to understand the similarities and differences between the core types of networking equipment.  The following should shed some light on the subject, in order of simplest to most complex: Network Interface Card—Every type of wired networking device has at least 1 NIC, with 1 Ethernet port. A NIC can have multiple Ethernet ports. Each Ethernet port has a unique MAC address. Cross-Over Cable—A crossover cable is sometimes needed to connect two network devices together without a switch. This may be the case if you’re using older hardware, and you want to connect a single client computer to your firewall computer. Most of the newer hardware “autosenses” regular and crossover cables so both will work automatically, but if you’re not receiving a signal or seeing any flashing lights then try using a crossover cable. Switch—A switch adds more ports to your network and eliminates the need for a crossover cable. A typical 8-port switch will have 1 Ethernet cable running to the firewall, and the other 7 cables running to clients or other network devices.  It’s important to remember that it doesn’t matter which cable goes in to which port, they are all the same. Router—A router provides an interface between two (or more) networks and will also usually act as a DHCP server. That's why on a router you have a special WAN port for that huge network we call the internet, and then a port for your internal Local Area Network (LAN). As a DHCP server, it’s responsible for automatically assigning an IP address to any device connected to the LAN and then it routes all traffic between both networks. Wireless Access Point—A wireless access point (WAP) is simply a wireless switch. When you connect to one, it’s the same as if you would have plugged your computer into a switch. "Wireless Router"—I have put this item in quotes because it’s important to understand that this type of device that most of us own is usually a combination of all the devices above. It has built-in NICs with Ethernet ports. It auto-senses crossover connections so they are never an issue. It routes traffic from that special WAN (usually labeled “Internet”) port to other ports for you to use as a LAN. Those 4 other ports are all for the same single subnet (your LAN) so that means it’s actually a 4-port switch. Additionally, those antennas provide WAP functionality. Acronym Reference WAN—Wide Area Network. Also known as the internet. LAN—Local Area Network. Your internal network, also known as your domain or your intranet. DMZ—De-Militarized Zone. A fancy name for just another type of internal network just like your LAN. The difference is, using firewall rules you prevent any traffic that comes into your DMZ subnet from going to your LAN subnet, for security purposes. This is where you would host a web server or FTP server, a place where anyone on the internet can access certain things without having access to your private LAN devices. DHCP—A type of service that automatically hands out IP addresses. Many types of network devices are configurable as DHCP servers. WAP—Wireless Access Point.  Essentially, a wireless switch. NIC—Network Interface Card. * WAN’s, LAN’s  and DMZ’s are all the same type of Ethernet network.  They all use the same hardware and work in the same way.  They are just given special names to differentiate how these networks are used. Part 1 – Understanding your Existing Home Network The diagram above is very typical of home networks. Study the diagram carefully and note the following key points of interest: The wireless router can connect clients wirelessly using its built-in WAP. The wireless router can connect wired clients using its built-in 4-port switch. While not noticeable in the diagram, those wired clients could be connected via crossover cable (as long as the client’s NIC’s also support "autosensing"). And again, while not noticeable, the wireless router is likely configured as a DHCP server and will automatically hand out (and keep track of) IP addresses for each client that connects to it. Unfortunately, this diagram fails to illustrate the importance of subnets. Also referred to as interfaces, subnets are the keystones of understanding how to take your network to the next level: This illustration highlights a few more key benefits and limitations of a typical home network: The wireless router is the central piece of the network. The wireless router provides a ton of functionality for a single network device.  It’s a router, autosensing switch, WAP, DHCP server and most even have very limited firewall functionality (allow/block IP’s, website filtering, port-forwarding, etc). The wireless router is limited to two interfaces, the WAN and the LAN. So how do we resolve these limitations? How do we bump our network up a notch? We replace that wireless router with a serious hardware firewall. We take an old computer we have laying around and we turn it into router on steroids. Enter pfSense. Part 2 – Creating a Small Business Network Now that we thoroughly understand what we’ve already got, let’s take a look at what we want to create: As you can see in the diagram above, our dedicated firewall is the centerpiece of our small business network.  Any firewall requires a minimum of two different interfaces, which means it requires a minimum of two NICs.  It should be obvious that the network illustrated above has four, but we’ll only be using two for this tutorial. Books from Packt Cacti 0.8 Network Monitoring FreePBX 2.5 Powerful Telephony Solutions Building Enterprise Ready Telephony Systems with sipXecs 4.0 Asterisk 1.4 – the Professional’s Guide ASP.NET 3.5 CMS Development Choosing an Open Source CMS: Beginner's Guide 3D Game Development with Microsoft Silverlight 3: Beginner's Guide Magento: Beginner's Guide  
Read more
  • 0
  • 0
  • 8826
article-image-managing-users-php-nuke
Packt
09 Mar 2010
19 min read
Save for later

Managing Users with PHP-Nuke

Packt
09 Mar 2010
19 min read
PHP-Nuke is about web communities, and communities need members. PHP-Nuke enables visitors to your site to create and maintain their own user account, and add their personal details. This is usually required for them to post their own new stories, make comments, or contribute to discussions in the forums. Those annoying little tasks like managing lost passwords are also taken care of for you by PHP-Nuke. User accounts can be created in two ways: By the super user (that's you) By the user registering on your site The second method involves a confirmation email sent to the user's email account. This email contains a link for them to click and confirm their registration to activate their account (this needs to be done within 24 hours or the registration expires). Once a visitor is registered on your site, the gates to enjoy the full glory of your site will be thrown wide open. Visitors, or users as you could now call them, will be able to contribute to discussions on forums, add comment on posted stories, even add their own new stories, as well as access parts of the site that are off-limits to the 'riff-raff' unregistered visitor. Ingredients of a User Every user requires a certain amount of information to uniquely identify them in PHP-Nuke. There are the usual three things required of every user in PHP-Nuke: A nickname: This is an alias or username if you like. This identifies who the user is, and is their online identity in PHP-Nuke. A password: This is required to verify that the user is who they claim to be. A valid email address: This is where the confirmation email is to be sent. Once the user account is created for a user, the user is of course able to modify their details, and also view the details of other users. Information such as the URL of the user's own website, messenger ID (MSN, AIM, and others), their location, and interests are also part of the user 'profile', but are not compulsory. By default, the real email address of any user is never made public, for both security and to prevent harvesting by spammers. Users can specify a 'fake email' address, possibly in spam-obfuscated form (for example, address_at_mydomain.com) which will be displayed to other users, although this is not required. A user's privacy is always protected. Setting Up a New User User management starts by clicking the Users icon in the Modules Administration menu: Clicking on this icon brings you to the User's Administration panel. This panel consists of two mini-panels, Edit User and Add a New User , whose use is given away by their titles. We'll start by setting up a new user. Our user will imaginatively be called testuser. Time For Action—Setting Up a New User Manually If you're not at the User's Administration panel, click on the Users icon in the Modules Administration menu. In the Add a New User panel, enter testuser into the Nickname field. Enter Test User into the Name field. Enter your own email address into the Email field. Scroll down to the Password field. Enter testuser as the password. Click the Add User button. When the page reloads, you will be taken straight back to the administration homepage. What Just Happened? We created a new user. For this simple user, we only specified the required fields Nickname, Email, and Password, and provided a single piece of personal information, Name. Failing to specify the required fields will mean that the user is not set up, and you will be prompted to go back and add the missing fields. No email notification is sent to the user when the user is set up in this way, and no confirmation of the registration is required. As soon as you click Add User, provided all the required fields have been entered, the user is ready to go. Editing the details of a user is equally easy, but you do have to know their nickname to edit the details. Simply enter this into the Nickname field of the Edit User panel, select Modify from the drop-down box and click Ok! If you have taken a sudden dislike to a particular user, enter their nickname into the Nickname field and select Delete from the drop-down box, click Ok! and they are gone forever (the account, not the person). Subscribing a User Once a user has been created, you have the option to subscribe this user. We mentioned the idea of Subscribed Users in earlier articles; it's a mechanism for restricting module access to specific groups of people, such as fee-paying customers. There is only one group of Subscribed Users in PHP-Nuke at present, so once a user has a subscription, they are able to access any module restricted to Subscribed Users only. The option to subscribe a user is not available when you create the user manually, as we did above. To find the option, you have to edit the user's details. This is done by entering their username into the Edit User panel, selecting Modify from the drop-down box, and clicking on the Ok! button. The subscription options are near the bottom of the user details, underneath the newsletter option. The Subscribe User option does not refer to 'subscribing to' the newsletter; you sign up the user or remove them from your newsletter mailing list with the Newsletter option. The Subscribe User option makes the user into one of the site's elite, a Subscribed User. If you subscribe the user, then you must specify the Subscription Period. This is the length of time that the user remains subscribed, and ranges from 1 year to 10 years, in yearly increments. If you leave the Subscription Period at None then the user will not be subscribed. Once a user has been subscribed, you can change their subscription details from the same panel: You can unsubscribe the user, or extend their subscription period. To shorten the subscription period, you would have to unsubscribe the user, subscribe them again, and then set the new period. Subscribed users are reminded of the passing of time and the impending expiry of their subscriptions when they visit the Your Account module—we'll further explore this module later in the article: Time For Action—Registering as a User This time we'll register to create a user account as a normal visitor would. We'll call the user account userdude. If you do not have your mail server set up, then you will just have to follow the text and screenshots for now. The confirmation email sent by PHP-Nuke is a key part of the registration process, and includes a special link for the visitor to click to activate their account. Don't worry though, when your site is live on your web hosting account, you will undoubtedly be able to access a mail server. If you are still logged in as the super user, logout by clicking the Logout icon in either of the administration menus, or click the Logout link in the Administration block. If you are still logged in as testuser, logout by clicking on the Your Account link in the modules block, then click the Logout/Exit link in the navigation bar that appears: Alternatively, you can enter the logout URL directly: http://localhost/nuke/modules.php?name=Your_Account&op=logout You will be redirected to the site homepage. Now click the Your Account link in the Modules block: Click the New User Registration link. This brings you to the New User Registration panel. The top part of that panel is shown here: Enter the Nickname of userdude. Enter your own email address into the Email field. We are going to use userdude for the password as well as the nickname. If you think of another password at this point, enter it instead. Then put the password into the Re-type password field as well. Click the New User button. You will come to the final step of the registration process: Click the Finish button. Open up your email client, and log in to check your mail. You should find a mail with the subject New User Account Activation waiting for you. It will be from the email address you specified in the Administrator Email field in the Site Configuration Menu. The body of that email will look something like this: Welcome to the Dinosaur Portal You or someone else has used your email account (myaddress@packtpub.com) to register an account at the Dinosaur Portal To finish the registration process you should visit the following link in the next 24 hours to activate your user account, otherwise the information will be automatically deleted by the system and you should apply again: http://thedinosaurportal.com/modules.php?name=Your_Account&op=activate&use rname=userdude&check_num=64ad845758d7f8f572b12800f60842ba Following is the member information: -Nickname: userdude -Password: userdude Click the link in the email, or copy the link and paste it into your browser, and you will be taken to the New User Activation page where you will see a message of the form: userdude: Your account has been activated. Please login from this link using your assigned Nickname and Password. Clicking on this link takes you back to the User Registration/Login page of the Your Account module, and you can use your nickname and password to login. What Just Happened? You just created a new user account. The page for logging in is the homepage of the Your Account module. We'll talk more about this module in a minute; as you could guess, it handles everything to do with 'your' user account. If the visitor is not logged in, they are presented with the login panel when they visit the Your Account module page. From here they can enter their nickname and password to log in, or click the New User Registration link to register a new user account, as we did. For visitors that have forgotten their password, clicking on the Lost your Password? link will take them to a screen where they can enter their nickname, and an email will be sent to their registered email address containing a confirmation code, a random-looking 10 digit string; with this code they can have their password changed. A new, random password is generated and emailed to them. PHP-Nuke never stores raw passwords in its database, so it can never reveal any password. With the new password, the user can log in and change their password to something easier to remember. The registration process for the user is straightforward; they only require a nickname, a valid email address, and a password. There are certain rules, however, that are followed by PHP-Nuke: Only one occurrence of an email address is allowed on the system; if someone uses an email address that belongs to another user account that address will be rejected, and the user will have to choose another. Only one occurrence of a particular nickname is allowed as well; the system will check the uniqueness of the nickname before creating the account. After the visitor clicks Finish on the final step, the user account is created. Following that, the confirmation email is sent to the email address. If the email address specified is invalid, or not the visitor's email address, then that visitor will have to create their account with a new email address. If the user doesn't mind being embarrassed, they can contact the site administrator, or wait 24 hours for the account to be deleted from the list of 'waiting to be activated' accounts, and then try again. You will notice that the link to activate the account contains the URL of your PHP-Nuke site: http://thedinosaurportal.com/modules.php?name=Your_Account&op=activate&use rname=userdude&check_num=64ad845758d7f8f572b12800f60842ba It is very important that you have configured your Site URL option correctly in the Web Site Configuration menu (we saw this in Aritcle 4). If you haven't done that, then the activation link will point to the wrong site! The check_num part of the URL is what identifies the unregistered visitor to the system. When the visitor registers his details, PHP-Nuke stores them in the database along with the check_num value. When the visitor visits the above link, PHP-Nuke will check the value of check_num against the values stored in the database, and if it finds a match, it will move that visitor's details to the proper users table in the database, and remove them from the table of visitors waiting to confirm their registration. That's all there is to creating user accounts. It is possible to turn off the registration, so that only the administrator can create accounts. If you feel the need for this, you can read more about it in the PHP-Nuke HOWTO: http://www.karakas-online.de/EN-Book/disable-registration.html That section of the PHP-Nuke HOWTO also has a number of other user account hacks that you can make use of. Graphical Code for User Registration PHP-Nuke enables you to add a security code to the login or registration pages on the site. The security code is a small graphic with some digits, and is shown under the password fields, along with a textbox for the visitor to type in the digits from the graphic. The point of this device is to prevent automated registrations; without typing the correct digits into the Type Security Code field, the submission will not be accepted. The digits displayed in the image are not part of the page HTML, and the only way for the digits to be read is to actually see them when they are displayed on a monitor. Use of the security code is controlled by a setting in the file config.php in the root of your PHP-Nuke installation. (This was the file in which we made some database settings in Article 2.) The setting to change is the value of the $gfx_chk variable. By default, it looks like this in the file, which means that the security code is not used: $gfx_chk = 0; The config.php file itself has a description of the values for this variable as seen in the table: Value Effect on the Security Code 0 Security code is never used. 1 Security code only appears on the administrators login page (admin.php). 2 Security code only appears on the normal user login page. 3 Security code only appears for new user registrations. 4 Security code appears for user login and new user registrations. Thus to have the security code appear only at the administrator login, you would set $gfx_chk to 1 and then save the config.php file: $gfx_chk = 1; For the graphical code to function properly, the GD extension will need to work properly with PHP on the web server. The GD extension takes care of drawing the graphics, and if this isn't functioning for whatever reason (possibly it's not installed), then the graphic will not be displayed properly, and it will be impossible to determine the security code. In that case, you will have to change the setting in config.php to remove the graphical code. If you are running your site on a web hosting account and the graphical security code is not being displayed when it should, then you should contact your host's technical support to find out if there is a problem with the GD extension. You can tell if the GD extension is installed by using the phpinfo() PHP function. Open a text editor and enter the following code: <?php phpinfo(); ?> Save this file as phpinfo.php in the web server root (xampphtdocs). When you navigate to that page in your browser, a number of PHP settings are displayed, including the status of the GD extension: If you do not see a table like the one above on the page, or if it does not say enabled next to GD Support, then contact your host's technical support. The XAMPP package we install in Appendix A has GD installed and working. Seeing Who's Who Log in to your site as the super user and activate the Members List module (deactivated by default). After activation there will be an additional option available in the Modules block called the Members List module, which provides anyone able to view this module with a list of the registered users: Clicking on the username will bring up a view of that user's profile: This is only a view of the user profile, and it is not an editable form. You will notice the word Forum in the above screenshot. The user profile displayed here is actually the user profile from the Forums module (and note also that the Forums module needs to be activated for this screen to be seen). You will also notice that the name of the site is wrong—it says MySite.com, which is not the value we set for our site name. This is because the Forums module has its own set of configuration settings. We will see how to set these in Article 8. Also note that the Members List module takes information from the Forums module configuration settings. The Forums module is a complete application—phpBB, one of the best pieces of free, open-source forum software around—integrated into PHP-Nuke. One aspect of the integration is the shared user account—the user account you create for the PHP-Nuke site also functions as a user account on the forums. As a user, it is possible to work with your details in two places in PHP-Nuke—from the Your Account module and also from within the Forums module. Although there are two views of information, and two places to edit your details, there is still only one user account. At the moment, the Your Account module offers more user details than are found in the Forums module, such as newsletter subscription information. The integration between the PHP-Nuke user account and the user account for the Forums module has gradually become tighter over the versions of PHP-Nuke, and they are likely to 'converge' further in future versions of PHP-Nuke. Once a user account is created, and the user has logged in, a whole new world opens up to them. The Your Account Module The Your Account module is a visitor's space. The visitor is guided round their space by a graphical navigation bar as seen below: Before we look at each of these links, let's mention what else is on the front page of the Your Account module: My Headlines: The user can view a list of headlines from an RSS news feed of another site. The user can select from one of the headline sites that we saw in the previous article, or enter the URL of the site directly. Broadcast Public Message: The user can enter the text of a public message to be shown to all current visitors of the site. We'll look at this in a moment. These two features are not always displayed; their display is controlled by options in the Web Site Configuration menu that we'll see in a moment. However, the user is always able to see their Last 10 Comments posted and their Last 10 News Submissions on this page. Returning to our discussion of the links in the navigation bar of the Your Account module, we've already seen what the Logout/Exit link does; it logs the visitor out. The Themes link takes the visitor to a page from where they can choose one from the list of themes installed on the site. We'll look at the Comments link in detail in the next article; it leads to options for viewing and posting comments on stories. Note that when you are logged in as the super user, the Your Account module displays another panel called Administration Functions. This panel allows you to modify certain details of that user. We will talk about these in the next article and meet them in their natural context. Editing the User Profile The Your Info link takes the user to their user profile. We saw some of the options here when we looked at creating the user manually. These options are generally for personal details (name, email, and so on), newsletter subscription, private message options, and forum configuration, among others. The options themselves are straightforward. A number of options in the user profile correspond to forum profile options, and don't particularly affect the user outside of the Forums module. After making any changes to a user profile, the Save Changes button needs to be clicked to save these changes. Note that the Save Changes button is not the button at the very bottom of the user details page—the Save Changes button is above the Avatar Control Panel: The button at the bottom of the form is marked Submit , and is only active when the options in the Avatar Control Panel are enabled. The Avatar Control Panel seen at the bottom of the user profile contains an interesting option. An avatar is a small graphic, representing you as an online character. You can choose a graphic from the already existing library by clicking on the Show Gallery button next to the Select Avatar from gallery option: Clicking on this button brings up a selection of little images for the user to choose from. Simply click on the required image and this will be assigned to the user profile: Clicking the Back to Profile link will return you to the Your Info page. The library of images you just saw can be found in the modulesForumsimagesavatarsgallery folder of your PHP-Nuke installation. If you want you can add in more images here, but make sure your image is a GIF file, and that it isn't more than 80 pixels wide or 80 pixels high. Your Account Configuration The Your Home link provides some options for configuring Your Account further: From this panel, the number of news stories displayed on the homepage of the site can be controlled. Remember, this setting only applies to you—and only when you are logged in.
Read more
  • 0
  • 0
  • 15884

article-image-network-based-ubuntu-installations
Packt
08 Mar 2010
4 min read
Save for later

Network Based Ubuntu Installations

Packt
08 Mar 2010
4 min read
I will first outline the requirements and how to get started with a network installation. Next I will walk through a network installation including screenshots for every step. I will also include text descriptions of each step and screenshot. Requirements In order to install a machine over the network you'll need the network installer image. Unfortunately these images are not well publicized, and rarely listed alongside the other .ISO images. For this reason I have included direct download links to the 32bit and 64bit images. It is important that you download the network installer images from the same mirror that you will be installing from. These images are often bound to the kernel and library versions contained within the repository, and a mismatch will cause a failed installation. 32 bit http://archive.ubuntu.com/ubuntu/dists/karmic/main/installer-i386/current/images/netboot/mini.iso 64bit http://archive.ubuntu.com/ubuntu/dists/karmic/main/installer-amd64/current/images/netboot/mini.iso If you'd prefer to use a different repository, simply look for the "installer-$arch" folder within the main folder of the version you'd like to install. Once you've downloaded your preferred image you'll need to write the image to a CD. This can be done from an existing Linux installation (Ubuntu or otherwise), by following the steps below: Navigate to your download location (likely ~/Downloads/) Right-click on the mini.iso file Select Write to Disk... This will present you with an ISO image burning utility. Simply verify that it recognizes a disk in your CD writer, and that it has selected the mini.iso for writing. An image of this size (~12M) should only take a minute to write. If possible, you may want to burn this image to a business card CD. Due to the size of the installation image (~12M), you'll have plenty of room on even the smallest media. Installation Congratulations. You're now the proud owner of an Ubuntu network installation CD. You can use this small CD to install an Ubuntu machine anywhere you have access to an Ubuntu repository. This can be a public repository or a local repository. If you'd like to create a local repository you may want to read the article on Creating a Local Ubuntu Repository using Apt-Mirror and Apt-Cacher, for additional information on creating a mirror or caching server. To kick off your installation simply reboot your machine and instruct it to boot off a CD. This is often done by pressing a function key during the initial boot process. On many Dell machines this is the F12 button. Some machines are already configured to boot from a CD if present during the boot process. If this is not the case for you, please consult your BIOS settings for more information. When the CD boots you'll be presented with a very basic prompt. Simply press ENTER to continue. This will then load the Ubuntu specific boot menu. For this article I selected Install from the main menu. The other options are beyond the scope of this tutorial. This will load some modules and then start the installation program. The network installer is purely text based. This may seem like a step backward for those used to the LiveCD graphical installers, but the text based nature allows for greater flexibility and advanced features. During the following screens I will outline what the prompts are asking for, and what additional options (if any) are available at each stage. The first selection menu that you will be prompted with is the language menu. This should default to "English". Of course you can select your preferred language as needed. Second, to verify the language variant, you'll need to select your country. Based on your first selection your menu may not appear with the same options as in this screenshot. Third you'll be asked to select or verify your keyboard layout. The installer will ask you if you'd like to automatically detect the proper keyboard layout. If you select Yes you will be prompted to press specific keys from a displayed list until it has verified your layout. If you select No you'll be prompted to select your layout from a list.
Read more
  • 0
  • 0
  • 4399

article-image-organizing-your-wikis-content-mediawiki-11-extension
Packt
04 Mar 2010
9 min read
Save for later

Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

Packt
04 Mar 2010
9 min read
Page templates Often times, we may have content that we need to include on several pages. For instance, we may want to include a legal disclaimer to certain pages. Or maybe we want to include a header or footer to all pages that fall into a specific category. Basically, if we have content that we want to include on more than one page, we can use a template. Creating a template means we don't have to type the same disclaimer, or header, or footer every time we want to put it onto a page. Instead, we only have to create the template, and include the template tag wherever we want the content to be displayed. If this reason is not enough to make use of templates, consider this—if we want to change some of the content in let's say, the disclaimer, we only need to change the template and all the pages will be updated. If we weren't using a template, we would have to find each page where the disclaimer content was entered and make the necessary changes to keep it consistent. Using templates is just smart management. Time for action – creating a template We are going to use the URL method to create a new template. When we do this, we will create an empty page where we can create the template. Once it is saved, it can be added to any page we choose with the template tag {{templatename}}. Of course, the name we save our template as will be substituted for templatename. For our sample wiki, we will create a template that adds a thank you to the user for supporting free and open source software. A link to both the Free Software Foundation and the Open Source Initiative will be included as well. This template can then be added to the bottom of each page that describes software. Open your web browser. In the address bar, type http://www.wikiname.com/index.php/Template:nameofyourtemplate . For the example wiki, we will enter http://www.flosspropopulo.com/index.php/Template:Thank you. Hit Enter . After you hit the Enter key, you will be taken to the new Template page. Click on edit this page to create and write the content for your template. For the sample wiki, we use: Thank you for supporting free and open source software.You can learn more about these projects from http://www.fsf.org and http://www.opensource.org. Click Show preview to see your new template. If you are satisfied, click Save page. Open an existing page in your wiki. At the bottom of the page, type {{templatename}} substituting your template for templatename. In the example, we will be opening the OpenOffice.org page and typing {{Thank you}} at the bottom. Click on Save page. What just happened? While creating a new template, we created a footer that can be added to any page simply by using the template tag in a page. This tag {{templatename}} is what placed the content below the horizontal rule in the previous screenshot. Anytime we include the tag for this template, {{Thank you}}, this piece of content will appear. Templates with parameters While the last use of the template tag can really benefit us when we are creating our pages, there is another manner in which we can use templates in our wiki. Do you remember when we created a new namespace called Tutorials? Let's say that we want users to create tutorials for us on our site. Now, if we have 20 different users contributing tutorials, I will bet that there will be 20 different layouts for our tutorial pages. To help keep things more consistent, we can add parameters to our template so that it acts like a subroutine would in a program. Each page where we use this template would have the same parameters; however, the values for each would change. This keeps the pages in the tutorial namespace consistent. A subroutine is a section of code in a program that executes a task that is one part of the larger program as a whole. Time for action – using parameters in a template While this may seem a bit difficult at first, after you complete the exercise you will see how simple it really is. If you have programming experience, the concepts of this should be second nature to you. In our example, we will make the parameters boldface by enclosing them with '''. However this is not necessary. What is necessary is for us to enclose the value of the parameter in triple brackets {{{ and }}}. For example: '''parameter'''||{{{value}}} Notice that the parameter is separated from the value by two pipes (||). Create a new template page using the URL method. For the example wiki, we will create a template called Tutorial by typing http://www.flosspropopulo.com/index.php/Template:Tutorial. Now, we need to create our template. We use the {| to open the syntax and |} to close it. Use some of the formatting techniques we have learned. For an example, we will use: {|style="width:80%; " border=0"|-|width=30%||width=70%||-| colspan="2" align="center"|'''{{{TutorialName}}}'''|-|'''Introduction'''||{{{intro}}}|-|'''Prerequisites'''||{{{prereq}}}|-|'''Steps'''||{{{steps}}}|-|'''Summary'''||{{{summary}}}|} This can serve as a guide for you as well. Simply change the parameters and the values to something that better reflects your wiki. Make sure the syntax is correct by clicking on Show preview. If everything looks like the following screenshot, you can click Save page. If anything is off, double check your syntax and make the necessary corrections. Now that we have created the template let's put it to use. We will need to pass on values on to our parameters on this page. Open a new page for editing. Open the template with double brackets {{. Using the example, we would type {{Tutorial |. Make sure to end this line with a pipe. Hit Enter to drop to the next line. Now we will pass values on to the parameters. Type your first parameter followed by an equal sign (=) and the value. For example, TutorialName = Installing MediaWiki|. Hit Enter and give your next parameter a value. Continue with this until all parameters have a value. Close the page with double brackets, }}. Click Show preview to see if everything is good. If you like what you see, click Save page. What just happened? Using the template namespace, we were able to assign parameters to our template. Now, we can apply this template to any page that we want to have a consistent look. Once we declare this template on a new page, we need to pass values on to the parameters. If you don't pass a value to a parameter, it will display the wikitext for the missing parameter. For example, if we fail to include an Introduction using the sample tutorial, the page will display {{{intro}}} where the introduction would be. The pages will now have the same layout, however the content will change. Using this technique, we created a template called Tutorial for the sample wiki and applied it to a new page. We also saw that we can apply many of the formatting techniques we have learned so far to our template to give it a more unique look and to separate items on the page. Have a go hero Templates are a great way to give your wiki a consistent look. Go ahead and create some templates that you can apply to pages in your wiki. For starters, create a disclaimer or some other type of footer that you will use on certain pages and apply this template to your wiki. Once you have been able to master this, go ahead and create a template that makes use of parameters unique to your wiki. If you are interested in learning more about parameters used with templates, search the Internet for Named and Numbered parameters. You can visit the MediaWiki page: http://meta.wikimedia.org/wiki/Help:Template#Parameters that specifically addresses parameter use in a template. Page redirection If you have spent any significant time surfing the web, you must have surely come across an instance when you follow a link but are redirected to another page. Generally, this happens for one of the two reasons, either because the content you are looking for has been moved to a different page, or because the page you are on has a similar URL to the page where the content is housed. The latter happens frequently when someone has multiple domains all pointing to one website. For instance, www.mysite.com hosts the website but www.mysite.org and www.mysite.net redirect to www.mysite.com so that visitors can view the content. Both instances would be ideal scenarios where we would redirect a page in our wiki as well. Take for instance our page OpenOffice.org from the example. Perhaps someone wrote an article on Star Office years ago. When the name was changed to OpenOffice.org, we could redirect the Star Office page to the newly created OpenOffice.org page. The second instance from above could be used because generally, people refer to OpenOffice.org as simply Open Office. We could then create a page called Open Office and redirect it to the OpenOffice.org page. Both are accomplished by adding the wikitext: #REDIRECT [[Article name]] to the beginning of the edit box. It is important to note that when redirecting an article that contains content, the content does not move to the new page. You can create a new page with the redirect tag as well.
Read more
  • 0
  • 0
  • 1887
article-image-apache-myfaces-extensions-validator
Packt
04 Mar 2010
14 min read
Save for later

Apache MyFaces Extensions Validator

Packt
04 Mar 2010
14 min read
Setting up ExtVal As with all other libraries, we start by downloading ExtVal and installing it in our project. As with many other JSF libraries, the ExtVal project has different branches for JSF 1.1 and 1.2. The first two digits of ExtVal’s version number are the JSF version they are made for. So ExtVal 1.1.x is the xth version of ExtVal for JSF 1.1, whereas ExtVal 1.2.x is the xth version for JSF 1.2. Versions of ExtVal are not released very often. At the time of writing this article, only two official releases have been published for each branch. According to the lead developer of ExtVal, a third release (1.1.3 and 1.2.3) is in the works for both branches, as well as a first release from the new JSF 2.0 branch. Apart from stable releases, ExtVal offers snapshot builds that are created on a regular basis. The snapshots are created manually, which gives some guarantees about the quality compared to automatically-created daily releases. No snapshots with major bugs will be created. According to the lead developer of ExtVal, the snapshot builds have “milestone quality”. Because of some issues and limitations in ExtVal 1.2.2, a snapshot build of ExtVal 1.2.3 was used while writing this article. A stable release of ExtVal 1.2.3 is expected to be available soon after the publishing date of this article. Stable releases can be downloaded from the ExtVal download site at http://myfaces.apache.org/extensions/validator/download.html. The downloaded ZIP file will contain all of the ExtVal modules, as listed in the next table. Note that more modules may be added to ExtVal in future releases. It is also possible that additional support modules will be provided by others. For example, a JSF component project may create a support module to get the most out of its components with ExtVal. Regarding component support modules, it is also worth mentioning the “Sandbox 890” project, which provides proof of concept implementations of support modules for some non-MyFaces component libraries. Currently, proofs of concept are available for IceFaces, PrimeFaces, RichFaces, and OpenFaces. Library Description myfaces-extval-core-1.2.x.jar The core of ExtVal. This library should be added to the project in all cases. myfaces-extval-property-validation-1.2.x.jar Extension module that adds several custom ExtVal annotations that we can use in our Model layer. myfaces-extval-generic-support-1.2.x.jar Extension module for generic JSF component support. This library should be added to the project in almost all cases. There are two cases when we don't need this generic support library, which are as follows: If we're using a support library for a specific component library, such as the Trinidad support module mentioned in the following row in this table If the component library we're using is 100% compliant with the JSF specification, which is almost never the case If no specific support module is in use, and it is unclear if the generic module is needed, it is safe to add it anyway. It is also a good idea to take a look at the Tested Compatibility section on the ExtVal wiki at http://wiki.apache.org/myfaces/Extensions/Validator/. myfaces-extval-trinidad-support-1.2.x.jar Extension module that supports the MyFaces Trinidad JSF components. If we use this one, we don't need the "generic support" module. The Trinidad support module will make use of Trinidad's client-side validation options where possible. So we get client-side validation based on annotations in our Model with no extra effort. myfaces-extval-bean-validation-1.2.x.jar Extension module that adds support for Bean Validation (JSR 303) annotations. This module will be available from the third release of ExtVal (*.*.3). Snapshot builds of ExtVal can be downloaded from ExtVal’s Maven snapshot repository, which can be found at http://people.apache.org/maven-snapshot-repository/org/apache/myfaces/extensions/validator/. In the case of snapshot builds, no single ZIP file is available, and each module has to be downloaded separately as a JAR file. Note that if Maven is used, there is no need to manually download the snapshots. In that case, we only have to change the version number in the pom.xml file to a snapshot version number, and Maven will automatically download the latest snapshot. The following table lists the URLs within the Maven repository from where the modules can be downloaded: Module URL Core myfaces-extval-core/ Property validation validation-modules/myfaces-extval-property-validation/ Generic support component-support-modules/myfaces-extval-generic-support/ Trinidad support component-support-modules/myfaces-extval-trinidad-support/ Bean validation (JSR 303) validation-modules/myfaces-extval-bean-validation/ URLs in this table are relative to the URL of the Maven repository that we just saw. After each URL, 1.2.x-SNAPSHOT/ has to be appended, where 1.2.x has to be replaced by the appropriate version number. Once we’ve finished downloading, we can start adding the JARs to our project. ExtVal differs in one thing from other libraries—it needs to access our Model and View project. So we have to add the ExtVal libraries to the lib directory of the EAR, instead of the WAR or the JAR with the entities. Some libraries that ExtVal uses have to be moved there as well. If we don’t do this, we’ll end up with all sorts of weird exceptions related to class-loading errors. Libraries that are added to the lib directory of an EAR are automatically available to all contained WAR and JAR files. However, depending on the IDE and build system that we are using, we may have to take some additional steps to be able to build the WAR and JAR with dependencies to the libraries in the EAR’s lib directory. This image shows a simplified structure of the EAR with ExtVal’s libraries added to it. Note that the MyFaces ExtVal and dependencies node in the image actually represents multiple JAR files. It is important to verify that none of the libraries that are in the lib directory of the EAR are included in either the WAR or the entities JAR. Otherwise, we could still encounter class-loading conflicts. The following table lists all of the libraries that have to be moved into the EAR to avoid these class-loading conflicts: Library Explanation myfaces-extval-*.jar Of course, all of the needed ExtVal JARs should be in the EAR. asm-1.5.x.jar, cglib-2.x_y.jar These are libraries that ExtVal depends on. They are bundled with the ExtVal download. They're not bundled with snapshot releases. jsf-facelets.jar We're using Facelets, so ExtVal has to use it to add validations within our Facelets pages. So if we didn't use Facelets, this one would not be needed. myfaces-api-1.2.*, myfaces-impl-1.2.* We're using MyFaces Core as JSF implementation. ExtVal will need those libs too. Note that if we use the application server's default JSF implementation, we don't have to add these either to the EAR or to the WAR. trinidad-api-1.2.*, trinidad-impl-1.2.* We're using Trinidad, and ExtVal offers some Trinidad-specific features through the "Trinidad support" extension. In that case, the Trinidad libraries should be in the EAR too. commons-*.jar Various libraries that we just mentioned depend on one or more libraries from the Apache Commons project. They should also be moved to the EAR file to be sure that no class-loading errors occur. Note that the aforementioned changes in our project structure are necessary only because we chose to have our Model layer in a separate JAR file. In smaller projects, it is often the case that the whole project is deployed as a single WAR file without enclosing it in an EAR. If we had chosen that strategy, no changes to the structure would have been necessary and we could have added all of the libraries to the WAR file, as we would do with any other library. Other than including the necessary libraries as discussed before, no configuration is needed to get started with ExtVal. ExtVal uses the convention over configuration pattern extensively. That means, a lot of sensible defaults are chosen, and as long as we’re satisfied with the defaults, no configuration is needed. The next section will get us started with some basic ExtVal usage. Bug with Trinidad tables There’s a bug in ExtVal that can cause some weird behavior in Trinidad’s <tr:table> component. Only the first row will be populated with data, and other rows will not show any data. This happens only when a Facelets composite component is used to add the columns to the table—exactly what we do in our example application. The bug can be found in the JIRA bug tracker for ExtVal at https://issues.apache.org/jira/browse/EXTVAL-77.. There’s a workaround for the bug that we can use until it gets fixed. Be warned that this workaround may have other side effects. This workaround is shown in the following code snippet, in which we have created a class called DevStartupListener: public class DevStartupListener extends AbstractStartupListener { @Override protected void init() { ExtValContext.getContext().addGlobalProperty(ExtValRendererProxy.KEY, null, true); } } The required imports are in the org.apache.myfaces.extensions.validator.core package and subpackages. Register this class as a phase listener in the faces-config.xml file: <lifecycle> <phase-listener>inc.monsters.mias.workaround.DevStartupListener</phase-listener> </lifecycle> You’re all set, and the <tr:table> will now act as expected. Don’t forget to remove this workaround if the bug gets fixed in a future release of ExtVal. Basic usage After setting up ExtVal, the basic usage is very simple. Let’s explore a simple example in our MIAS application. In our Kid.java entity, we have some JPA annotations that map the properties of the Kid bean to a database table. Let’s take a closer look at the lastName property of our Kid bean: @Column(name = "LAST_NAME", nullable = false, length = 30) private String lastName; The @Column annotation maps the lastName property to the LAST_NAME column in the database. It also shows some information that is derived from the table definition in the database. nullable = false means the database won’t accept an empty value in this field, and length = 30 means that no more than 30 characters can be stored in the corresponding database column. This information could be used for validation in our View layer. If we hadn’t used ExtVal, we would have added a required="true" attribute to the input element in our EditKid.xhtml page. We also would have added a <tr:validateLength > component to the input component, or we could have set the maximumLength attribute. But all of these things would have been a duplication of information and logic, and would thus break the DRY principle. With ExtVal, we don’t have to duplicate this information anymore. Whenever ExtVal encounters a nullable = false setting, it will automatically add a required="true" attribute to the corresponding input element. In the same way, it will translate the length = 30 from the @Column annotation into a maximumLength attribute on the input component. The next screenshot shows ExtVal in action. (Note that all validators, and the required and maximumLength attributes were removed from the JSF code before the screenshot was taken.) The really nice thing about this example is that the validations created by ExtVal make use of Trinidad’s client-side validation capabilities. In other words, the error message is created within the user’s web browser before any input is sent to the server. Complementing JPA annotations It’s nice that we can reuse our JPA annotations for validation. But the chances are that not all validation that we want can be expressed in JPA annotations. For that reason, ExtVal offers a set of extra annotations that we can add to our beans to complement the implicit validation constraints that ExtVal derives from JPA annotations. These annotations are a part of the myfaces-extval-propertyvalidation-1.2.x.jar library. For example, if we want to add a minimum length to the lastName fi eld, we could use the @Length annotation as follows: @Length(minimum = 5) @Column(name = "LAST_NAME", nullable = false, length = 30) private String lastName; Note that if, for some reason, we couldn’t use the length = 30 setting on the @Column annotation, the @Length annotation also has a maximum property that can be set. The @Length annotation can be imported from the org.apache.myfaces.extensions.validator.baseval.annotation package, which is where the other annotations that ExtVal offers are also located. The following image shows the minimum length validation in action: As the example in the screenshot shows, setting a minimum input length of five characters for a name might not be a good idea. However, that’s an entirely different discussion Using ExtVal annotations for standard JSF validators For each of the validator components that is a part of the JSF standard, there is an annotation in ExtVal’s Property Validation library. These are covered briefly in the following subsections. Note that ExtVal will automatically use any overridden versions of the standard validators, if they are present in the project. Defining length validation For the length validation of input strings, the @Length annotation can be used, as shown in the previous example. This annotation relies on the javax.faces.validator.LengthValidator to implement the validation. The following table lists the available properties: Property Type Explanation minimum int The minimum length (inclusive) in characters of the input string maximum int The maximum length (inclusive) of the input string in characters Defining double range validation To validate if a double value is within a certain range, the @DoubleRange annotation can be used, which delegates the implementation of the validation to the javax.faces.validator.DoubleRangeValidator validator. See the following table for the available properties: Property Type Explanation minimum double The minimum value (inclusive) of the double input maximum double The maximum value (inclusive)of the double input Defining long range validation What @DoubleRange annotation does for doubles, the @LongRange annotation does for long values. It uses javax.faces.validator.LongRangeValidator for the implementation: Property Type Explanation minimum long The minimum value (inclusive) of the long input maximum long The maximum value (inclusive) of the long input Defining required fields The example given at the beginning of this section showed how ExtVal can create a required="true" attribute based on an @Column annotation with the nullable = false setting. If it is not possible to use this setting, ExtVal also has an alternative @Required annotation . Just add this annotation to a field to make it required Using ExtVal’s additional annotations Apart from the annotations that correspond to the standard JSF validators, some additional annotations exist in the Property Validation module that perform other validations. These are listed in the following subsections. Whereas the validations based on the JSF standard validators use the error messages provided by the JSF validators, the additional validations cannot use standard messages from JSF. Therefore, standard messages are provided by ExtVal. Should you want to use your own message, all additional annotations have a validationErrorMsgKey property that can be used to assign a message key for the error message. We’ll discuss custom error messages in more detail later in this article. Defining pattern-based validation Validation with regular expressions is very powerful, and is very usable for validating phone numbers, postal codes, tax numbers, and any other data that has to fit in a certain pattern. Regular expression-based validation can be added by using the @Pattern annotation. For example, to allow only letters and spaces in the firstName field, we could write: @Pattern(value="[A-Za-z ]*") @Column(name = "FIRST_NAME", nullable = false, length = 30) private String firstName; For completeness, the following table lists the arguments of the @Pattern annotation: Property Type Required Explanation value String[] Required Array of regular expression patterns. Beware if you add more than one pattern that the input must match all patterns. It is easy to make any input invalid by using two patterns that are mutually exclusive. validatonErrorMsgKey String Optional Optional key for alternative error message.
Read more
  • 0
  • 0
  • 2127

article-image-organizing-your-wikis-content-mediawiki-11
Packt
04 Mar 2010
6 min read
Save for later

Organizing Your Wiki's Content in MediaWiki 1.1

Packt
04 Mar 2010
6 min read
We have focused mainly on organizing content rather creating content in your wiki in this article. We assume you should have a few pages in your wiki. As our wiki grows in popularity, the amount of content it hosts will continue to grow so it is important to organize the content in your wiki so that our wiki looks better to our visitors and editing and reviewing content is much easier for our users. If we think of our wiki as a library, it is easy to see why we need to organize our wiki. After all, if you walk into a library with no system for organizing the books, movies, music, periodicals, and others you would find it hard to locate what you are looking for. Likewise, if we have no order in our wiki, then our visitors could find themselves frustrated when trying to find the information they are looking for. If they become too frustrated, they will go elsewhere. Namespaces Namespaces are used by MediaWiki to group together pages that have a similar purpose such as Help pages, User profiles, or Talk pages. This is not to be confused with pages that contain similar content. These pages are grouped by categories which we will discuss later in this article. Pages that exist within a namespace in a wiki are noted by the namespace prefix that helps to form the title of the page. For example, if we have a page called Uploading a video file that exists in the Help namespace, it would appear as Help:Uploading a video file. Perhaps you want to create a new page for an upcoming marketing project for your company. This would appear as Project: Marketing project. MediaWiki makes use of 18 built-in namespaces. The odd number namespaces are talk namespaces while even numbered ones represent subject namespaces. Numerical index Namespace Description 0 Main This groups together a majority of the site's content. There is no namespace prefix for the mainspace. 1 Talk The discussion pages attached to the mainspace pages. 2 User Pages that contain information about users and their history. 3 User talk Used to leave messages to a user. 4 Project Used for information related to the operation and development of the wiki. This is also known as the meta namespace. 5 Project talk Used to discuss project pages. 6 File Stores metadata for files uploaded to the wiki. This includes images, sound, video, and other files accessed through the Media namespace. 7 File talk Used to discuss files and media. 8 MediaWiki Contains system messages and other important content. 9 MediaWiki talk Discussion pages related to the MediaWiki namespace. 10 Template Used to hold templates used in the wiki. 11 Template talk Discussion pages for the various templates used in the wiki. 12 Help Holds help files, how-tos, and other instructions for users. 13 Help talk Used to hold discussions related to the help files. 14 Category Holds information related to the different categories created for the wiki. 15 Category talk Used to hold discussions regarding the wiki's categories. -2 Media Used for direct linking to media files [[Media:song.ogg]] rather than the information page. -1 Special Groups special pages created by MediaWiki itself. Talk pages are accessed by clicking on the discussion tab at the top of a page. The last two namespaces, denoted by the negative sign, are used for pages created by MediaWiki. Users cannot create, delete, or edit any pages in these two namespaces without special extensions. The remaining 16 namespaces are all used for user-created content. The following screenshot shows the Help namespace for the Joomla! documentation wiki (http://docs.joomla.org/Beginners ): Time for action – creating a page in a namespace Content that is housed in many of the namespaces is created on the fly. For instance, when you first register as a user, a new page in the User namespace is created. When you create a Help page, a new page appears in the Help namespace. If you add to the discussion page for an article on your wiki, a new talk page is created. For Main, Project, Template, Help, and Category pages, we can add new pages directly into the namespace. For example, if our IT department wanted a user manual for a new software package that was just installed, we could create a project page for this. In this instance, we would have to designate the namespace or it would default to a regular article. Open your wiki in your browser and log in. In your browser's address bar, type the following: http://www.yoursitename.com/index.php/Project:Project page name. For the example site, I will be entering: http://www.flosspropopulo.com/index.php/Project:Using our new software . Hit Enter. Your new page should open up and look similar to the following screenshot: Right now, the project page tab is red because the page doesn't exist yet. Click on the edit this page link to create the page. When you are satisfied with the page, click Save page. When the page has been saved, it will look similar to this: You may have noticed that while the tab reads project page, the namespace is the title of our wiki. In this example, Floss Pro Populo appears instead of the word Project. As the project page deals with organization of the wiki, it defaults to the wiki's sitename to represent a project taking place within the wiki itself. This can be changed; however, it is something that should be done by more advanced MediaWiki administrators. What just happened? Instead of simply creating a new page, we used the URL to create a new page and included it in a specific namespace. In this example, we created a new Project page explaining the project that will include creating a user manual for a new software package. We also saw that of the 18 namespaces, we can directly create new pages using this method in only five of them. The other 13 namespaces have their pages created by MediaWiki itself when different actions are taken. If you try to create a page in a namespace that doesn't exist, it will default to the Main namespace. MediaWiki will not create the new namespace for you. Pop quiz – namespaces Namespaces are important because they help keep our pages organized. As an administrator, it is important to know what kind of pages the different namespaces hold so we can find what we are looking for. To make user that you have a solid grasp of namespaces, let's take a moment to test your knowledge. All namespaces can be edited by the users. True False Most pages in the namespaces are created by MediaWiki when the user does something. Which of the following namespaces allows the user to directly create a new page (by using the URL)? Help File Special User According to the example above, which URL will correctly create a new page in the Category namespace? Category:New page http://www.wikiname.com/Category:New page http://www.wikiname.com/index.php/Category:New page
Read more
  • 0
  • 0
  • 2292
Modal Close icon
Modal Close icon