' ); define( 'DOMAIN', 'CoyoteTours.us' ); // class page { //Declare class properties private $db; //Declare HTML properties private $markupHead; private $markupBody; private $markupFoot; private $markup; //Declare page properties directly related to the markup of the dynamic template protected $id; protected $name; protected $title; protected $path; protected $parentId; protected $nLevel; protected $nLeft; protected $nRight; protected $keywords; protected $description; protected $type; protected $active; //Retrieve an array of columns from the database row associated with the top level of the URL path private function page_columns( $urlPath, $db ) { //Send query to the database for the row whose url_path column is the same as the URL path top-level $result = $db->query( 'select * from pages where url_path = "' . $db->real_escape_string( $urlPath ) . '" limit 1' ); //Display an error page when there is no matching record in the database if( $result->num_rows > 0 ) { //Create an object from the query result row $row = $result->fetch_object( ); //Define the page properties $this->id = $row->page_id; $this->name = $row->name; $this->title = $row->title; $this->path = $row->url_path; $this->parentId = $row->parent_id; $this->nLevel = $row->nlevel; $this->nLeft = $row->nleft; $this->nRight = $row->nright; $this->keywords = $row->meta_keywords; $this->description = $row->meta_description; $this->type = $row->type; $this->active = $row->active; } else { //Redirect to page not found and exit application header( 'Location: 404.txt' ); exit; } } //Determine the URL path top level by parsing the url_path query string variable private function path_toplevel( $urlPath ) { //Create an array from the folders of the URL path $folders = explode( '/', $urlPath ); //Returns top level of URL path, the last key in the array return( $folders[ ( count( $folders ) - 1 ) ] ); } // public function __construct( $urlPath, $db ) { //Define a reference to the database object $this->db = $db; //Determine the URL path's top level, the current page //$this->urlPath_topLevel = $this->path_toplevel( $urlPath ); //Create an associative array whose keys have the values of the columns belonging to the row associated with the top-level of the URL path $this->page_columns( $this->path_toplevel( $urlPath ), $this->db ); $this->markupHead = $this->markup_head( ); $this->markupBody = $this->markup_body( $this->type ); $this->markupFoot = $this->markup_foot( ); $this->markup = $this->markup_compile( ); } //Create the HTML for the page header private function markup_head( ) { // $markup = DOCTYPE . "\n"; $markup .= '' . "\n"; $markup .= '
' . "\n"; $markup .= '' . $this->text . '
' . "\n"; $markup .= '