1. Trang chủ
  2. » Công Nghệ Thông Tin

Secure PHP Development- P84 pptx

5 202 0
Tài liệu đã được kiểm tra trùng lặp

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 83,15 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

◆ Finally, the showWithThememethod is called with the output of parsing the main block to embed with the user’s theme template.. It works as follows: ◆ A template object is created named

Trang 1

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->themeby calling the

getUserTheme()method of the theme object created

◆ Next, if the query parameter $cmdis set to search, it calls the

displaySearchResult()method; if $cmdis set to previousor 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

$cmdis set to title, rating, or addedby, then it calls sortAndDisplay(); and if $cmdis 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 Categoryobject called $categoryObjis 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

Trang 2

◆ 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 $blockNameis set to jsblock, then it parses the jsCategoryBlock

and sets the output into the $categoryvariable Otherwise, it parses the

categoryBlockblock if the category ID is not equal to the $selectValue

and sets the output in the $categoryvariable

◆ Finally, this method returns the value of $categoryvariable

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 Categoryclass 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 $subCategoryvariable 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 $resourcevariable

◆ 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:

Trang 3

◆ 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 Categoryclass named $catObjand 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 Userclass named $userObjand 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 Resourceclass object named $resourceObjand calls the searchResource()method with the search criteria given by the user and stores it in the array named $resourceList

◆ It creates a Userclass object named $userObjand 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_LISTsession variable and assigns the value in the SESSION_PAGE_SIZEsession 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

Trang 4

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 $cmdvalue, which contains sorting criteria If $cmdis 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 $sorttypevalue Depending on the value of $sorttype,

array_reverse()is called to reverse the sorting result

◆ If the $cmdis set to rating, then it calls usort()with

sortByResourceRatingas the function parameter to sort the result depending on the $sorttypevalue according to the resource rating

◆ If the $cmdis set to addedby, then it calls usort()with

‘sortByResourceAddedBy’as the function parameter

◆ Then the method registers the SESSION_SEARCH_LISTsession 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 $cmdvalue If it is set to ‘next’, then it generates the next page resource starting point If $cmdis 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

Trang 5

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_LISTand

SESSION_PAGE_SIZEto store the search output and number of resources that needs to be shown each page, respectively

◆ Then it creates a Resourceclass object named $resourceObjand 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 Userclass object named $userObjand 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_LISTand

SESSION_PAGE_SIZEto store the search output and number of resources

to be shown in each page, respectively

◆ Then It creates an object of Resourceclass named $resourceObjand 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_LISTand 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:

Ngày đăng: 07/07/2014, 07:20