Archive for October, 2007

Chapter 8: Intranet Simple Document Publisher 265 Configuration (Managed web hosting)

Saturday, October 27th, 2007

Chapter 8: Intranet Simple Document Publisher 265 Configuration Variable Purpose $LD_CATEGORY_NAV_DIR The fully qualified path for the category navigation file. Ideally, you should set this to a path that is outside your Web document tree and the files in this directory should have only read/write permissions for the Web server user which runs the PHP scripts. $LD_CATEGORY_NAV_OUTFILE The category navigation file created by the simple document publishing system. $LD_CATEGORY_NAV_TEMPLATE The category navigation template file used to generate the navigation file pointed by $LD_CATEGORY_NAV_OUTFILE. $DEFAULT_THEME The default theme index in the $THEME_TEMPLATE array. $USER_DEFAULTS A user s theme and auto tip default settings. $TIP_SCRIPT The name of the tip script. $TIP_URL The Web-relative path for the tip files. $MAX_AVAILABLE_TIP The maximum number of tips from which to display the tip. $THEME_TEMPLATE[n] The list of theme templates $PRINT_TEMPLATE[n] The list of print templates associative with the theme templates. The directory structure used in the ld.conf file supplied in ch8 directory on the CD-ROM may need to be tailored to your own system s requirements. Here is what the current directory structure looks like: htdocs ($ROOT_PATH same as %DocumentRoot%) | +—home (base intranet application discussed in chapter 7) | | | +—templates | | | +—themes (theme templates used by all intranet apps) <–+ | | +—photos (user photos used by all intranet apps) |

Affordable web design - 264 Part II: Developing Intranet Solutions TABLE 8-2

Friday, October 26th, 2007

264 Part II: Developing Intranet Solutions TABLE 8-2 LD.CONF VARIABLES (Continued) Configuration Variable Purpose $LD_VIEW_RESPONSE_TEMPLATE Name of the document response view template file. $ADD_MOD_DOC_TEMPLATE Name of the add/modify document entry form template file. $ADD_MOD_CATEGORY_TEMPLATE Name of the add/modify category entry form template file. $ANNOUNCE_LD_ADDED_TEMPLATE Name of the new document announcement message template file. $ANNOUNCE_LD_MOD_TEMPLATE Name of the document modification announcement message template file. $LD_VISIT_LIST_TEMPLATE Name of the document track listing template file. $LD_REORDER_CAT_TEMPLATE Name of the category reordering entry form template file. ODD_COLOR Color defined for odd rows when displaying tabular data such as document track listing. EVEN_COLOR Color defined for even rows when displaying tabular data such as document track listing. $ratings Defines an associative array used to display response rating information. USER_DB_URL The fully qualified authentication database URL. LD_ADMIN_TYPE The administrative user type value. CAT_PER_LINE The number of categories per row to show in a navigation table, which is created in the navigation file. SEPARATOR The characters that separate each navigation entry (category) in the navigation, which is created in the navigation file. LD_UPDATE_TITLE The MOTD message header used to announce updated documents via MOTD. LD_ADD_TITLE The MOTD message header used to announce new documents via MOTD.

Chapter 8: (Web hosting faq) Intranet Simple Document Publisher 263 Configuration

Friday, October 26th, 2007

Chapter 8: Intranet Simple Document Publisher 263 Configuration Variable Purpose $LD_RESPONSE_MNGR Name of the application that manages responses to documents. $LD_ADMIN_MNGR Name of the application that allows administrative users to manage categories. $LD_VISIT_LIST_MNGR Name of the application that allows users to view document-tracking information. $LD_DB_URL The fully qualified URL for the database used to store the documents and categories. $LD_CATEGORY_TBL Name of the category table in the database. $LD_DOC_TBL Name of the document table in the database. $LD_RESPONSE_TBL Name of the response table in the database. $USER_PREFERENCE_TBL Name of the user preference table in the database. $MESSAGE_TBL Name of the MOTD message table in the database. $LD_CAT_PUB_TBL Name of the category publishers table in the database. $LD_CAT_VIEW_TBL Name of the category viewers table in the database. $LD_TRACK_TBL Name of the document tracking data table in the database. $MSG_VIEWER_TBL Name of the message viewer list table in the database. $AUTH_DB_TBL Name of the user authentication table in the database. $STATUS_TEMPLATE Name of the status template file used to display status messages. $LD_HOME_TEMPLATE Name of the document index template file. $LD_DETAILS_TEMPLATE Name of the document details template file. $LD_RESPONSE_TEMPLATE Name of the document response entry form template file. Continued

262 Part II: (Free php web host) Developing Intranet Solutions TABLE 8-2

Thursday, October 25th, 2007

262 Part II: Developing Intranet Solutions TABLE 8-2 LD.CONF VARIABLES (Continued) Configuration Variable Purpose $APPLICATION_NAME Internal name of the application. $DEFAULT_LANGUAGE Set to the default (two-character) language code. $ROOT_PATH Set to the root path of the application. $REL_ROOT_PATH Relative path to the root directory. $REL_APP_PATH Relative application path as seen from the web browser. $TEMPLATE_DIR The fully qualified path to the template directory. $THEME_TEMPLATE_DIR The fully qualified path to the theme template directory. $REL_PHOTO_DIR The Web-relative path to the photo directory used to store user photos. $PHOTO_DIR The fully qualified path to the photo directory. $DEFAULT_PHOTO Name of the default photo file, which is used when a user does not have a photo in the photo directory. $CLASS_DIR The fully qualified path to the class directory. $REL_TEMPLATE_DIR The Web relative path to the template directory used. $CATEGORY_CLASS Name of the Category class file. $DOC_CLASS Name of the Doc class file. $RESPONSE_CLASS Name of the Response class file. $MESSAGE_CLASS Name of the Message class file. This class is developed for the MOTD application, discussed in the Chapter 7. $LD_MNGR Name of the application that shows document indexes for a given category or all categories. $LD_DETAILS_MNGR Name of the application that shows document details.

Chapter 8: Intranet (Msn web hosting) Simple Document Publisher 261 Setting

Thursday, October 25th, 2007

Chapter 8: Intranet Simple Document Publisher 261 Setting up Application Configuration Files Like all other applications we ve developed in this book, the document publishing applications also use a standard set of configuration, message, and error files. These files are discussed in the following sections. The main configuration file The primary configuration file for the entire document publishing system is called ld.conf. Table 8-2 discusses each configuration variable. TABLE 8-2 LD.CONF VARIABLES Configuration Variable Purpose $PEAR_DIR Set to the directory containing the PEAR package; specifically the DB module needed for class.DBI.php in our application framework. $PHPLIB_DIR Set to the PHPLIB directory, which contains the PHPLIB packages (specifically, the template.inc package needed for template manipulation). $APP_FRAMEWORK_DIR Set to our application framework directory. $PATH Set to the combined directory path consisting of $PEAR_DIR, $PHPLIB_DIR, and $APP_FRAMEWORK_DIR. This path is used with the ini_set() method to redefine the php.ini entry for include_path to include $PATH ahead of the default path. This allows PHP to find our application framework, PHPLIB, and PEAR-related files. $AUTHENTICATION_URL Set to the central login application URL. $LOGOUT_URL Set to the central logout application URL. $HOME_URL Set to the topmost URL of the site. If the URL redirection application does not find a valid URL in the e-campaign database to redirect to for a valid request, it uses this URL as a default. Continued

Web hosting servers - 260 Part II: Developing Intranet Solutions . addResponse():

Wednesday, October 24th, 2007

260 Part II: Developing Intranet Solutions . addResponse(): This method adds new response to the LD_RESPONSE table of the database. The attributes such as response ID, category number, subject, document ID, rate, response time, and so on are passed into an associative array as parameters to this method. It works as follows: The SQL statement is prepared using the $this->std_fields array that contains all the attributes of the LD_RESPONSE table and the values from the associative array that has been passed as parameter. The values of the parameter are formatted using the quote() method of the $this->dbi object. After executing the SQL statement, the newly added response s RESPONSE_ID is retrieved using another SQL statement. If the insertion query is successful, this method returns the response ID of the newly added response. Otherwise, it returns FALSE. Following are the other methods in this class: Method Description setResponseID() Sets the response ID. If the response ID is provided as the parameter, it is set as the object s response ID; otherwise, the current response ID is returned. getResponseSubject() Returns the subject of the current response. It takes the response ID as the parameter. getResponseDocID() Returns the document ID of the current response. It takes the response ID as the parameter. getResponder() Returns the responder of the current response. It takes response ID as the parameter. getResponseBody() Returns the body of the current response. Response ID is passed to this method as the parameter. getAvgRatingByDocID() Returns the average rating of a given document. It takes the document ID as the parameter. getTotalResponseByDocID() Returns the total number of responses for the given document. This method takes the document ID as the parameter. deleteResponse() Deletes the response from the database. It will delete all data related to the response from the database. It takes response ID as the parameter.

Chapter 8: Intranet Simple Document (Best web hosting site) Publisher 259 Following

Wednesday, October 24th, 2007

Chapter 8: Intranet Simple Document Publisher 259 Following are the response class methods: . Response(): This is the constructor method that creates the response object. This method does the following: Sets the object variable cat_tbl, which holds the category table name, to $LD_CATEGORY_TBL, which is loaded from the ld.conf file. Sets the object variable doc_tbl, which holds the document table name, to $LD_DOC_TBL, which is loaded from the ld.conf file. Sets the object variable resp_tbl, which holds the response table name, to $LD_RESPONSE_TBL, which is loaded from the ld.conf file. Sets the object variable dbi to point to the class.DBI.php-provided object, which is passed to the constructor by an application. The dbi member variable holds the DBI object that is used to communicate with the back-end database. Calls setResponseID() to set the response ID of the object. Sets the object variable std_fields, which is an array that contains the LD_RESPONSE table attributes and their data type. . loadResponseInfo(): This method loads all attribute values into the response object from the LD_RESPONSE table by the specified response ID. This is how it works: It calls setResponseID() to set the passed response ID to the current object. If no response ID is passed, the current object s response ID is taken. The $this->dbi object is used to retrieve all the attribute values of the given response from the LD_RESPONSE table. Each of the values is set to the current object so that they can be retrieved at any time using the other get methods of this class. For example $this->RESPONDER is set the username who responded (i.e. provided feedback) to a document. . getResponsesByDocID(): This method returns all responses for a given document ID. This is how it works: It executes a SQL query that retrieves all the attributes of the LD_RESPONSE table for a given document ID. It stores the result of the query in an array unless the result set is empty. The method returns null when there is no result found from the query; otherwise, it returns the array.

258 Part II: Developing Intranet Solutions The following (Web hosting faq)

Tuesday, October 23rd, 2007

258 Part II: Developing Intranet Solutions The following are other methods of this class: Method Description setDocID() Sets the document ID. If the document ID is provided as a parameter, it is set as the object s document ID; otherwise, the current object s document ID is returned. getHeading() Returns the heading of the current document object. It takes document ID as a parameter. getPublishDate() Returns the publishing date of the current document object. It also takes document ID as a parameter. getBody() Returns the body of the current document object. Document ID is passed into this method as a parameter. getCategory() Returns the category of the current document object. It takes document ID as a parameter. deleteDoc() Deletes the document from the database. It will delete all data related to the document from the database. It takes the ID of the document to be deleted as the parameter. deleteResponsesByDocID() Deletes all responses related for any doc from the database. It takes document ID as the parameter. trackVisit() Tracks visits to the given document and enters new track information (document ID, user ID, and visit timestamp) into the LD_TRACK table of the database. It takes document ID, user ID, and the timestamp as parameters. It returns TRUE upon successful insertion; otherwise, it returns FALSE. The Response class The Response class provides the response object. The response object is used to manipulate response data. Applications can add or remove responses using the response object. The ch08/apps/class/class.Response.php file in the CDROM is an implementation of this class.

Web hosting uk - Chapter 8: Intranet Simple Document Publisher 257 .

Tuesday, October 23rd, 2007

Chapter 8: Intranet Simple Document Publisher 257 . modifyDoc(): This method updates document information in the database. Attributes such as document ID, category number, heading, body of the document, and publish date are passed in an associative array as parameters to this method. It works as follows: The SQL statement is prepared using the $this->std_fields array that contains all the attributes of the LD_DOCUMENT table and the values from the associative array that has been passed as a parameter. The values of the parameter are formatted using the quote() method of the $this->dbi object. If the update query is successful, this method returns TRUE. Otherwise, it returns FALSE. . getDocsByCatID(): This method returns all documents that are to be published until the current time related to the given category from the database. This method takes category ID as the parameter. It works as follows: It executes a SQL statement that retrieves all the documents up to the current timestamp for the given category. It stores the result into an array if the result set is not empty. It returns the array, or, if the result is empty, it returns null. . getAllDocsByCatID(): This method returns all documents that fall under the given category. This also takes category ID as a parameter. It works as follows: It executes a SQL statement that retrieves all the documents for the given category. It stores the result into an array if the result set is not empty. It returns null if the result is empty. Otherwise, it returns the array. . getTrackDetails(): This method returns all tracking information for the given document. It works as follows: It executes a SQL query that retrieves all the user IDs and their visit timestamps for the given document ID. The result is stored in an array if it is not empty. The method returns null when the result set is empty. Otherwise, it returns the array.

256 Part II: Developing Intranet Solutions Sets (Com web hosting)

Tuesday, October 23rd, 2007

256 Part II: Developing Intranet Solutions Sets an object variable called fields, which holds a comma separated list of fields from the std_fields set earlier. Sets the object variable dbi to point to the class.DBI.php-provided object, which is passed to the constructor by an application. The dbi member variable holds the DBI object that is used to communicate with the back-end database. Calls setDocID()to set the document ID of the object. Sets an object variable called std_fields, which is an array that contains the LD_DOCUMENT table attributes and their data type. . loadDocInfo(): This method loads all attribute values into the document object from the LD_DOCUMENT table by the specified document ID. This is how it works: setDocID() is called to set the passed document ID to the current object. If no document ID is passed, the current object s document ID is taken. The $this->dbi object is used to retrieve all the attribute values of the given document from the LD_DOCUMENT table. Each of the values is set to the current object so that they can be retrieved at any time using the other get methods of this class. For example $this->DOC_NAME is set the value of the DOC_NAME of the given document. This method sets all the attributes such as document ID, category number, heading, body of the document, and publish date for a given document. . addDoc(): This method adds new documents to the database. Attributes such as document ID, category number, heading, body of the document, and publish date are passed in an associative array as parameters to this method. It works as follows: The SQL statement is prepared using the $this->std_fields array that contains all the attributes of the LD_DOCUMENT table and the values from the associative array that has been passed as parameter. The values of the parameter are formatted using the quote() method of the $this->dbi object. After executing the SQL statement, the newly added document s DOC_ID is retrieved using another SQL statement. If the insertion query is successful, this method returns the category ID of the newly added category. Otherwise, it returns FALSE.