authorize() This method authorizes everyone on the intranet to view the resource manager and, therefore, always returns TRUE. Creating a Search Manager Application This application, irm_search_mngr.php, is responsible for managing search oper- ations. This application is included on the CD-ROM in the ch11/apps directory. This application has the following methods. run() When the application is run, this method is called. It does the following: ◆ It creates a theme object, $this->themeObj. ◆ The current user’s theme choice is stored in $this->theme by calling the getUserTheme() method of the theme object created. ◆ Next, if the query parameter $cmd is set to search, it calls the displaySearchResult() method; if $cmd is set to previous or next, then it calls displaySearResultNextandPrevious(); if it is set to mostvisited, then it calls showMostVisitedResource() to show the most visited resources; if it is set to topranking, then it calls showTopRankingResource() to show the top-ranking resources; if the $cmd is set to title, rating, or addedby, then it calls sortAndDisplay(); and if $cmd is set to nothing then it calls showMenu(). In other words, the run() method decides which functionality is requested by the user and calls the appropriate driver method to perform the desired operations. populateCategory() This method is used to populate the list of all available main categories. It works as follows: ◆ This method is called with the template name ($template), the block name ($blockName), and the default selected value ($selectValue). ◆ A new Category object called $categoryObj is created and the getCategoryList() method of that object is called to generate the avail- able main categories name and stored in an array named $categoryList. 386 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 386 ◆ If the category list is not empty, then it sets the category ID and name for each category in the list; otherwise, it returns null. ◆ If $blockName is set to jsblock, then it parses the jsCategoryBlock and sets the output into the $category variable. Otherwise, it parses the categoryBlock block if the category ID is not equal to the $selectValue and sets the output in the $category variable. ◆ Finally, this method returns the value of $category variable. populateSubCategory() This method is used to populate the subcategory list for the given category. It works as follows: ◆ This method is called with the template name ($template), category ID ($cat_id), and block name ($blockName), where the subcategory will be populated. ◆ A new object of the Category class is created named $subcatagoryObj, and the getSubCategoryList() method is called from the class with the given category ID ($cat_id) as a parameter. The subcategory list is then stored in the array named $subcategoryList. ◆ If the subcategory list is not there, then it checks the given block name. Then it sets the subcategory name and ID in respective variables in the given block and sets the output in the $subCategory variable parsing the block. ◆ Finally, this method returns the subcategory list stored in the $subCategory. populateResource() This method is used to display resources to show the search result. It works as follows: ◆ This method is called with a template name ($template), resource display starting point ($startingPoint), and block name ($blockName) where the resource information is displayed. ◆ Next it sets the resource information in the template. ◆ Then It sets the alternative different colors in rows to display, parses each row, and stores it in the $resource variable. ◆ Finally, it returns the value of $resource. showMenu() This method is used to display the menu shown in the search index page. It works as follows: Chapter 11: Internet Resource Manager 387 14 549669 ch11.qxd 4/4/03 9:25 AM Page 387 ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ It creates an object of the Category class named $catObj and shows the category and subcategory names with the number of resources belonging to respective categories. ◆ Then It calls the populateCategory() method to show the category list in the drop-down list in the template. ◆ It creates an object of the User class named $userObj and calls the getUserList() method to populate all the user lists. ◆ Next it checks whether the viewer is an administrator of the IRM applica- tion or not. If she is not an administrator, it gives only the add resource link. On the other hand, If she is an administrator, it gives the category and resource manager link along with the add resource. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. displaySearchResult() This method is used to display the results after executing a search operation. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Then it creates a Resource class object named $resourceObj and calls the searchResource() method with the search criteria given by the user and stores it in the array named $resourceList. ◆ It creates a User class object named $userObj and calls the getUserInfo() method to get the name of the user who added the resource. ◆ Next, it assigns the search result in the SESSION_SEARCH_LIST session variable and assigns the value in the SESSION_PAGE_SIZE session variable if it is given by the user from the search interface. If it is not given by the user, then it assigns the default value (DEFAULT_PAGE_SIZE), which is con- figurable via irm.conf. ◆ Then It calls the populateResource() method to show the search result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. 388 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 388 sortAndDisplay() This method is used to sort the search result according to user’s criteria. This method works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ This method stores the value of the session variable in an array object named $data, which is used to sort the data. ◆ Next it checks the $cmd value, which contains sorting criteria. If $cmd is set to ‘title’, then it calls usort() with ‘sortByResourceTitle’ as the function parameter to sort the search result according to resource title and checks the $sorttype value. Depending on the value of $sorttype, array_reverse() is called to reverse the sorting result. ◆ If the $cmd is set to rating, then it calls usort() with sortByResourceRating as the function parameter to sort the result depending on the $sorttype value according to the resource rating. ◆ If the $cmd is set to addedby, then it calls usort() with ‘sortByResourceAddedBy’ as the function parameter. ◆ Then the method registers the SESSION_SEARCH_LIST session variable and assigns the sorted result in that variable. ◆ Next it calls the populateResource() method to show the sorted result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. displaySearResultNextandPrevious() This method is used to display the previous/next page results after executing a search operation. This method works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Now it checks the $cmd value. If it is set to ‘next’, then it generates the next page resource starting point. If $cmd is set to ‘previousBlock’, then it generates the previous page starting point. ◆ Next it calls the populateResource() method to show the sorted result. ◆ Finally, the showWithTheme() method is called with the output of parsing the main HTML template block to embed with the user’s theme template. Chapter 11: Internet Resource Manager 389 14 549669 ch11.qxd 4/4/03 9:25 AM Page 389 showTopRankingResource() This method is used to display the top-ranked resources. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Next it registers the session variables SESSION_SEARCH_LIST and SESSION_PAGE_SIZE to store the search output and number of resources that needs to be shown each page, respectively. ◆ Then it creates a Resource class object named $resourceObj and calls the getTopRankingList() method with the defined variable ‘TOPRANKING’ (which is configurable in the irm.conf) to get the top-ranking resource. ◆ It creates a User class object named $userObj and calls getUserInfo() method to get the name of the user who added the resource. ◆ It sets the result and parses the main block. Then it calls the showWithTheme() method to embed the output with the user’s theme template. showMostVisitedResource() This method is used to display the most visited resources. It works as follows: ◆ A template object is created named $menuTemplate. To load, the template file named $IRM_SEARCH_RESULT_TEMPLATE (configurable via irm.conf) is passed to the method. ◆ Next it registers the session variables SESSION_SEARCH_LIST and SESSION_PAGE_SIZE to store the search output and number of resources to be shown in each page, respectively. ◆ Then It creates an object of Resource class named $resourceObj and calls the getMostVisitedResource() method with a arameter called MOSTVISITED, which specifies the number of the most visited resource to be shown (configurable in the irm.conf). ◆ It calls the getResourceInfo() method to get information for each resource and stores in the session variable SESSION_SEARCH_LIST and displays the search result. ◆ Finally the showWithTheme() method is called with the output of parsing the main block to embed with the user’s theme template. showWithTheme() This method is use to show the user’s theme template. It works as follows: 390 Part II: Developing Intranet Solutions 14 549669 ch11.qxd 4/4/03 9:25 AM Page 390 . and, therefore, always returns TRUE. Creating a Search Manager Application This application, irm_search_mngr .php, is responsible for managing search oper- ations. This application is included on the CD-ROM