<?php
-/**
- * Toolbox Classes :)
- *
- * <p>
+/**
+ * Toolbox Classes :)
+ *
+ * <p>
* $Id: class_template.inc,v 1.1.1.1 2007/04/19 13:06:15 matrix Exp $
- * NOTE: for the search engine freindly url's use .htaccess file.
- * need to make sure .htaccess is enabled or this work work
- * to turn off seo url's set define SEO_URL to 0 in setup file
- * </p>
+ * NOTE: for the search engine freindly url's use .htaccess file.
+ * need to make sure .htaccess is enabled or this work work
+ * to turn off seo url's set define SEO_URL to 0 in setup file
+ * </p>
*
* @package Toolbox Library
* @subpackage Template Library
* @filesource
- *
+ *
*/
/**
* Require DocBlock
*/
require_once(BASE."classes/class_toolbox.inc");
/**
- * Template Class :)
+ * Template Class :)
*
* <p>
* $Id: class_template.inc,v 1.1.1.1 2007/04/19 13:06:15 matrix Exp $
* include_once('setup.phtml');
* include_once(BASE.'classes/class_template.inc');
* $catid = ( $_GET['catid'] ) ? $_GET['catid']: HOME_ID;
- * $toolbox =& new GLM_TEMPLATE( $catid );
+ * $toolbox = new GLM_TEMPLATE( $catid );
* if($catid == 1)
* {
- * // title and meta description for home page only
- * $title = '';
- * $meta = '';
+ * // title and meta description for home page only
+ * $title = '';
+ * $meta = '';
* }
* else
* {
- * $title = $toolbox->title().' - Site Name';
- * $meta = $toolbox->meta();
+ * $title = $toolbox->title().' - Site Name';
+ * $meta = $toolbox->meta();
* }
* ?>
* <title><?php echo $title;?></title>
* @package Toolbox Library
* @subpackage Template Library
* @category Template
- * @author Steve Sutton <steve@gaslightmedia.com>
+ * @author Steve Sutton <steve@gaslightmedia.com>
* @copyright 2007
* @version $Revision: 1.1.1.1 $
* @since $Date: 2007/04/19 13:06:15 $
*/
class GLM_TEMPLATE{
- /** @var string header_begin The style starting for header */
- var $header_begin;
- /** @var string header_end The style ending for header*/
- var $header_end;
- /** @var string subheader_begin The style starting for header */
- var $subheader_begin;
- /** @var string subheader_end The style ending for header*/
- var $subheader_end;
- /** @var string img_align The alignment of images*/
- var $img_align;
- /** @var string img_alternate 1 alternate images 0 not*/
- var $img_alternate;
- /** @var string img_size The path to the image directory*/
- var $img_size;
- /** @var object DB The database class*/
- var $DB;
- /** @var array data The category array*/
- var $data;
- /** @var array items The items array*/
- var $items;
- /** @var string type The type*/
- var $type;
- /** @var string whole_thread The thread string*/
- var $whole_thread;
- /** @var integer thread_count The thread count*/
- var $thread_count;
- /** @var integer catid catid for the page */
- var $catid;
- /** @var array $pages */
- var $pages;
- /** @var string $active_query string adding active = 't' to queries only if ACTIVE_FLAG is set to true */
- var $active_query;
- /** @var integer $template integer determines page layout */
- var $template;
- /** @var string $php_ext pgae extension for php pages .php or .phtml */
- var $php_ext;
-
- /**
- * GLM_TEMPLATE
- *
- * @param mixed $catid current page category id
- * @param mixed $DB Object passed from GLM_DB if done
- * @access public
- * @return string
- */
- function GLM_TEMPLATE( $catid, $DB = NULL )
- {
- $this->catid = $this->get_catid( $catid ); // sets $this->catid
- $this->set_DB( &$DB ); // using a reference to $DB (should be started on setup.phtml
- //$this->Member = $this->set_member(); // used for cvb's
- $this->header_begin = "<h1>"; // class="content" should not be used anymore
- $this->header_end = "</h1>"; // create style for p h1 h2 tags if needed try to keep it clean
- $this->subheader_begin = "<h2>"; // should not be using h3 here duh go from 1 to 2 instead
- $this->subheader_end = "</h2>"; // like your suppose to
- $this->img_alternate = 1; // for alternating images set to 1 else leave alone
- $this->img_align = "left"; // the starting postion for images change to left if needed
- $this->img_size = RESIZED; // img_size are RESIZED,MIDSIZED,THUMB do not use ORIGINAL
- $this->whole_thread = ""; // do not touch this it is used for menu generation
- $this->thread_count = 1; // also used for menu generation
- $this->php_ext = '.php'; // defaults to .php
- $this->set_pages( &$GLOBALS['PAGES'] ); // Uses the PAGE array set in setup.phtml
- $this->page_status( $catid ); // tell if page is active, deleted or inactive
- $this->set_active_query(); // set active query string
- }
-
- /**
- * page_status
- *
- * tell if page is active, deleted or inactive
- * this will redirect to the index.php page if the
- * id has been deleted or not active
- * it will display message about page not found.
- *
- * @param mixed $id
- * @access public
- * @return string
- */
- function page_status( $id )
- {
- if( $id == '' )
- {
- return( false );
- }
- if( $id == HOME_ID )
- {
- $this->page_status = 'Good';
- }
- $query = "select id,active from bus_category where id = $id;";
-
- if( $data = $this->DB->db_auto_get_data( $query ) )
- {
- if( $data[0]['active'] == 'f' && !strstr( $_SERVER['HTTP_REFERER'],'admin/' ) )
- {
- $this->page_status = 'Bad';
- }
- else
- {
- $this->page_status = 'Good';
- }
- }
- else
- {
- // page was deleted and no longer avail.
- // give 301 redirect and go back to index page
- header('HTTP/1.1 301 Moved Permanently');
- header('Location: '.BASE_URL);
- exit();
- }
- }
- /**
- * set_active_query: some toolboxes have an active flag some do not
- * so this is to allow both with and without a flag.
- *
- * @uses ACTIVE_FLAG
- *
- * @return void
- * @access public
- **/
- function set_active_query()
- {
- if( ACTIVE_FLAG )
- {
- $this->active_query = " and active = 't'";
- }
- return( $this->active_query );
- }
- /**
- * set_member
- *
- * @access public
- * @return string
- */
- function set_member()
- {
- if( MEMBERS_DB && $this->catid )
- {
- require_once(BASE.'classes/class_members.inc');
- $Member =& new glm_members( &$this );
- return( $Member );
- }
- }
- /**
- * get_seo_url:
- * grab category part of the search engine friendly url
- * looks at define for seo_url to see weather to use the seach engine friendly url's or not
- *
- * @param integer $id:
- * @param boolean $slash = 1 : to put a slash on end or not
- * @uses BASE_URL
- * @uses SEO_URL
- * @uses HOME_ID
- * @uses GLM_TEMPLATE::$php_ext
- * @uses GLM_TEMPLATE::set_name_url()
- * @uses GLM_TEMPLATE::get_category_name()
- * @uses GLM_TEMPLATE::get_base_url()
- *
- * @return string $url for page.
- * @access public
- **/
- function get_seo_url( $id, $slash = 1 )
- {
- if( $id == HOME_ID && $GLOBALS['GLM_SERVER_ID'] != 'devsys.gaslightmedia.com' )
- {
- return( BASE_URL );
- }
- elseif( $id == HOME_ID && $GLOBALS['GLM_SERVER_ID'] == 'devsys.gaslightmedia.com' )
- {
- return( BASE_URL.'index.php' );
- }
- if( SEO_URL )
- {
- $url = BASE_URL;
- $url .= GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_name( $id, "bus_category", $this->DB ) );
- $url = strip_tags( $url );
- $url = htmlspecialchars( $url );
- if( $slash )
- {
- $url .= '/';
- }
- }
- else
- {
- $url = $this->get_base_url( $id );
- if( $url )
- {
- $url = BASE_URL.$url;
- $url .= $this->php_ext.'?catid='.$id;
- }
- else
- {
- $url = BASE_URL;
- }
- }
-
- return( $url );
- }
- /**
- * set_DB: set the DB up to be that of the global one if it exists
- *
- * @param object $DB : the DB object
- * @uses GLM_DB
- *
- * @return void
- * @access public
- **/
- function set_DB( $DB )
- {
- if( isset( $DB ) )
- {
- $this->DB =& $DB;
- }
- else
- {
- $this->DB =& new GLM_DB();
- }
- }
-
- /**
- * set_pages: grab the globals for the pages an use this for
- * the pages array for the class
- *
- * @return void
- * @access public
- **/
- function set_pages( $pages )
- {
- if( is_array( $pages ) )
- {
- $this->pages =& $pages;
- }
- }
-
- /**
- * set_catid:Set the class catid var
- * @param integer $catid: $catid
- *
- * @deprecated using get_catid
- * @return void
- * @access public
- **/
- function set_catid( $catid )
- {
- if( is_numeric( $catid ) )
- {
- $this->catid = $catid;
- }
- else
- {
- $this->catid = 1;
- }
- }
-
- /**
- * get_id_from_path_info: takes the path_info and gets a catid from bus_category table
- * NOTE: not used.
- *
- * @deprecated using .htaccess file for this when using seo url's
- * @return int catid
- * @access public
- **/
- function get_id_from_path_info()
- {
- return( false );
- }
-
- /**
- * get_catid: setting catid for class
+ /** @var string header_begin The style starting for header */
+ var $header_begin;
+ /** @var string header_end The style ending for header*/
+ var $header_end;
+ /** @var string subheader_begin The style starting for header */
+ var $subheader_begin;
+ /** @var string subheader_end The style ending for header*/
+ var $subheader_end;
+ /** @var string img_align The alignment of images*/
+ var $img_align;
+ /** @var string img_alternate 1 alternate images 0 not*/
+ var $img_alternate;
+ /** @var string img_size The path to the image directory*/
+ var $img_size;
+ /** @var object DB The database class*/
+ var $DB;
+ /** @var array data The category array*/
+ var $data;
+ /** @var array items The items array*/
+ var $items;
+ /** @var string type The type*/
+ var $type;
+ /** @var string whole_thread The thread string*/
+ var $whole_thread;
+ /** @var integer thread_count The thread count*/
+ var $thread_count;
+ /** @var integer catid catid for the page */
+ var $catid;
+ /** @var array $pages */
+ var $pages;
+ /** @var string $active_query string adding active = 't' to queries only if ACTIVE_FLAG is set to true */
+ var $active_query;
+ /** @var integer $template integer determines page layout */
+ var $template;
+ /** @var string $php_ext pgae extension for php pages .php or .phtml */
+ var $php_ext;
+
+ /**
+ * GLM_TEMPLATE
+ *
+ * @param mixed $catid current page category id
+ * @param mixed $DB Object passed from GLM_DB if done
+ * @access public
+ * @return string
+ */
+ function GLM_TEMPLATE( $catid, $DB = NULL )
+ {
+ $this->catid = $this->get_catid( $catid ); // sets $this->catid
+ $this->set_DB( &$DB ); // using a reference to $DB (should be started on setup.phtml
+ //$this->Member = $this->set_member(); // used for cvb's
+ $this->header_begin = "<h1>"; // class="content" should not be used anymore
+ $this->header_end = "</h1>"; // create style for p h1 h2 tags if needed try to keep it clean
+ $this->subheader_begin = "<h2>"; // should not be using h3 here duh go from 1 to 2 instead
+ $this->subheader_end = "</h2>"; // like your suppose to
+ $this->img_alternate = 1; // for alternating images set to 1 else leave alone
+ $this->img_align = "left"; // the starting postion for images change to left if needed
+ $this->img_size = RESIZED; // img_size are RESIZED,MIDSIZED,THUMB do not use ORIGINAL
+ $this->whole_thread = ""; // do not touch this it is used for menu generation
+ $this->thread_count = 1; // also used for menu generation
+ $this->php_ext = '.php'; // defaults to .php
+ $this->set_pages( &$GLOBALS['PAGES'] ); // Uses the PAGE array set in setup.phtml
+ $this->page_status( $catid ); // tell if page is active, deleted or inactive
+ $this->set_active_query(); // set active query string
+ }
+
+ /**
+ * page_status
+ *
+ * tell if page is active, deleted or inactive
+ * this will redirect to the index.php page if the
+ * id has been deleted or not active
+ * it will display message about page not found.
+ *
+ * @param mixed $id
+ * @access public
+ * @return string
+ */
+ function page_status( $id )
+ {
+ if( $id == '' )
+ {
+ return( false );
+ }
+ if( $id == HOME_ID )
+ {
+ $this->page_status = 'Good';
+ }
+ $query = "select id,active from bus_category where id = $id;";
+
+ if( $data = $this->DB->db_auto_get_data( $query ) )
+ {
+ if( $data[0]['active'] == 'f' && !strstr( $_SERVER['HTTP_REFERER'],'admin/' ) )
+ {
+ $this->page_status = 'Bad';
+ }
+ else
+ {
+ $this->page_status = 'Good';
+ }
+ }
+ else
+ {
+ // page was deleted and no longer avail.
+ // give 301 redirect and go back to index page
+ header('HTTP/1.1 301 Moved Permanently');
+ header('Location: '.BASE_URL);
+ exit();
+ }
+ }
+ /**
+ * set_active_query: some toolboxes have an active flag some do not
+ * so this is to allow both with and without a flag.
+ *
+ * @uses ACTIVE_FLAG
+ *
+ * @return void
+ * @access public
+ **/
+ function set_active_query()
+ {
+ if( ACTIVE_FLAG )
+ {
+ $this->active_query = " and active = 't'";
+ }
+ return( $this->active_query );
+ }
+ /**
+ * set_member
+ *
+ * @access public
+ * @return string
+ */
+ function set_member()
+ {
+ if( MEMBERS_DB && $this->catid )
+ {
+ require_once(BASE.'classes/class_members.inc');
+ $Member = new glm_members( &$this );
+ return( $Member );
+ }
+ }
+ /**
+ * get_seo_url:
+ * grab category part of the search engine friendly url
+ * looks at define for seo_url to see weather to use the seach engine friendly url's or not
+ *
+ * @param integer $id:
+ * @param boolean $slash = 1 : to put a slash on end or not
+ * @uses BASE_URL
+ * @uses SEO_URL
+ * @uses HOME_ID
+ * @uses GLM_TEMPLATE::$php_ext
+ * @uses GLM_TEMPLATE::set_name_url()
+ * @uses GLM_TEMPLATE::get_category_name()
+ * @uses GLM_TEMPLATE::get_base_url()
+ *
+ * @return string $url for page.
+ * @access public
+ **/
+ function get_seo_url( $id, $slash = 1 )
+ {
+ if( $id == HOME_ID && $GLOBALS['GLM_SERVER_ID'] != 'devsys.gaslightmedia.com' )
+ {
+ return( BASE_URL );
+ }
+ elseif( $id == HOME_ID && $GLOBALS['GLM_SERVER_ID'] == 'devsys.gaslightmedia.com' )
+ {
+ return( BASE_URL.'index.php' );
+ }
+ if( SEO_URL )
+ {
+ $url = BASE_URL;
+ $url .= GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_name( $id, "bus_category", $this->DB ) );
+ $url = strip_tags( $url );
+ $url = htmlspecialchars( $url );
+ if( $slash )
+ {
+ $url .= '/';
+ }
+ }
+ else
+ {
+ $url = $this->get_base_url( $id );
+ if( $url )
+ {
+ $url = BASE_URL.$url;
+ $url .= $this->php_ext.'?catid='.$id;
+ }
+ else
+ {
+ $url = BASE_URL;
+ }
+ }
+
+ return( $url );
+ }
+ /**
+ * set_DB: set the DB up to be that of the global one if it exists
+ *
+ * @param object $DB : the DB object
+ * @uses GLM_DB
+ *
+ * @return void
+ * @access public
+ **/
+ function set_DB( $DB )
+ {
+ if( isset( $DB ) )
+ {
+ $this->DB = $DB;
+ }
+ else
+ {
+ $this->DB = new GLM_DB();
+ }
+ }
+
+ /**
+ * set_pages: grab the globals for the pages an use this for
+ * the pages array for the class
+ *
+ * @return void
+ * @access public
+ **/
+ function set_pages( $pages )
+ {
+ if( is_array( $pages ) )
+ {
+ $this->pages = $pages;
+ }
+ }
+
+ /**
+ * set_catid:Set the class catid var
+ * @param integer $catid: $catid
+ *
+ * @deprecated using get_catid
+ * @return void
+ * @access public
+ **/
+ function set_catid( $catid )
+ {
+ if( is_numeric( $catid ) )
+ {
+ $this->catid = $catid;
+ }
+ else
+ {
+ $this->catid = 1;
+ }
+ }
+
+ /**
+ * get_id_from_path_info: takes the path_info and gets a catid from bus_category table
+ * NOTE: not used.
+ *
+ * @deprecated using .htaccess file for this when using seo url's
+ * @return int catid
+ * @access public
+ **/
+ function get_id_from_path_info()
+ {
+ return( false );
+ }
+
+ /**
+ * get_catid: setting catid for class
+ *
+ * We should be using the $_POST or $_GET globals here
+ *
+ * @return int catid
+ * @access public
+ **/
+ function get_catid( $catid )
+ {
+ if( is_numeric( $_GET['catid'] ) )
+ {
+ return( $_GET['catid'] );
+ }
+ elseif( is_numeric( $_POST['catid'] ) )
+ {
+ return( $_POST['catid'] );
+ }
+ else
+ {
+ return( $this->catid = $catid );
+ }
+ }
+
+ /**
+ * set_contact:Set the contact string
+ * <code><p><strong>Contact Name:</strong> {$text}</p></code>
+ *
+ * @param string $text: The text as string
+ * @param string $email: email if givin
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_contact( $text, $email )
+ {
+ if( $email != "" )
+ {
+ $text = "";
+ }
+ else
+ {
+ $text = '<p><strong>Contact Name:</strong> '.$text.'</p>';
+ }
+ return($text);
+ }
+
+ /**
+ * set_text:Set the contact string
+ * <code><p>{$text}</code>
+ * @param string $text: The text as string
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_text( $text )
+ {
+ if("" == str_replace("<br />","",trim($text)))
+ {
+ return(false);
+ }
+ if( $text != "" )
+ {
+ $text = $this->keyword_replace( $text );
+ $text = $text;
+ }
+ return($text);
+ }
+
+ /**
+ * get_image_path: get image path from the size used
+ *
+ * @uses MIDSIZED_PATH
+ * @uses RESIZED_PATH
+ * @uses THUMB_PATH
+ *
+ * @return path for images
+ * @access public
+ **/
+ function get_image_path()
+ {
+ if( strstr($this->img_size,'midsized/') )
+ {
+ return( MIDSIZED_PATH );
+ }
+ if( strstr($this->img_size,'resized/') )
+ {
+ return( RESIZED_PATH );
+ }
+ if( strstr($this->img_size,'thumb/') )
+ {
+ return( THUMB_PATH );
+ }
+ }
+
+ /**
+ * set_img:Set the image string
+ * <p><code>
+ * <div class="image{$align}" style="width: {$width}px" src="{$size}{$image}" {$titletag}>
+ * <div class="imagecaption">{$caption}</div>
+ * </div>
+ * </code>
+ * </p>
+ *
+ * @param string $image: The image
+ * @param string $size: The path
+ * @param string $align: The alignment
+ * @param string $name: The image_name (displayed under image)
+ * @param string $alt_title text for use in alt and title tags
+ * @param string $caption Text for image caption if given
+ * @uses GLM_TEMPLATE::get_image_path()
+ *
+ * @return void
+ * @access public
+ **/
+ function set_img( $image, $size, $align, $alt_title = NULL, $caption = NULL )
+ {
+ if( $image != "" )
+ {
+ if( $caption != '' )
+ {
+ $caption = str_replace('&','&',$caption);
+ $titletag = 'title="'.htmlspecialchars(strip_tags($caption)).'"';
+ $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
+ }
+ elseif( $alt_title != '')
+ {
+ $alt_title = str_replace('&','&',$alt_title);
+ $titletag = 'title="'.htmlspecialchars(strip_tags($alt_title)).'"';
+ $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
+ }
+ else
+ {
+ $titletag = 'title="'.htmlspecialchars(strip_tags($image)).'"';
+ $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
+ }
+ if( $align != "" )
+ {
+ $img_align = 'class="image'.$align.'"';
+ }
+ $path = $this->get_image_path();
+ if( is_file( $path.$image ) )
+ {
+ $image_size = getimagesize( $path.$image );
+ $img_attr = $image_size[3];
+ }
+ $img = '
+ <div '.$img_align.' style="width: '.$image_size[0].'px">
+ ';
+ $img .= '<img '.$img_attr.' src="'.$size.$image.'" '.$titletag.'>';
+ if( $caption )
+ {
+ $img .= '
+ <div class="imagecaption">'.$caption.'</div>
+ ';
+ }
+ $img .= '</div>
+ ';
+ return($img);
+ }
+ }
+
+ /**
+ * set_url:Set the url string
+ * <p>
+ * <code><p><a href="http://{$url}" target="_blank">{$text}</a></code>
+ * </p>
+ *
+ * @param string $url: The url
+ * @param string $text: The text as string
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_url( $url, $text )
+ {
+ if( $url != "" )
+ {
+ if( !$text )
+ {
+ $text = $url;
+ }
+ if( strtolower( substr( $url, 0, 7 ) ) == "https://" )
+ {
+ $url = '<p><a href="'.$url.'" target="_blank">'.htmlspecialchars($text).'</a></p>';
+ }
+ else
+ {
+ $url = '<p><a href="http://'.$url.'" target="_blank">'.htmlspecialchars($text).'</a></p>';
+ }
+ }
+ return( $url );
+ }
+
+ /**
+ * set_email:Set the email string
+ * <code><p><strong>Contact:</strong> <a href="mailto:{$email}" target="_blank">{$text}</a></p></code>
+ * @param string $email: The email as string
+ * @param string $contact: The contactname this is used as the link text
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_email( $email, $contact )
+ {
+ if( $email != "" )
+ {
+ if( $contact != "" )
+ {
+ $email = '<p><strong>Contact:</strong> <a href="mailto:'.$email.'" target="_blank">'.htmlspecialchars($contact).'</a></p>';
+ }
+ else
+ {
+ $email = '<p><strong>Email:</strong> <a href="mailto:'.$email.'" target="_blank">'.htmlspecialchars($email).'</a></p>';
+ }
+ }
+ return( $email );
+ }
+
+ /**
+ * set_header:Set the header string
+ * @param string $text: The text as string
+ * @uses GLM_TEMPLATE::header_begin()
+ * @uses GLM_TEMPLATE::header_end()
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_header( $text )
+ {
+ if( $text != "" )
+ {
+ $text = $this->header_begin.htmlspecialchars($text).$this->header_end;
+ }
+ return( $text );
+ }
+
+ /**
+ * set_subheader:Set the subheader string
+ * @param string $text: The text as string
+ * @uses GLM_TEMPLATE::subheader_begin()
+ * @uses GLM_TEMPLATE::subheader_end()
+ *
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_subheader( $text )
+ {
+ if( $text != "" )
+ {
+ $text = $this->subheader_begin.htmlspecialchars($text).$this->subheader_end;
+ }
+ return( $text );
+ }
+
+ /**
+ * set_phone:Set the phone string
+ * <code><p><strong>Phone:</strong> {$text}</p></code>
+ * @param string $text: The text as string
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_phone( $text )
+ {
+ if( $text != "" )
+ {
+ $text = '<p><strong>Phone:</strong> '.$text.'</p>';
+ }
+ return( $text );
+ }
+
+ /**
+ * set_fax:Set the fax string
+ * <code><p><strong>Fax:</strong> {$text}</p></code>
+ * @param string $text: The text as string
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_fax( $text )
+ {
+ if( $text != "" )
+ {
+ $text = '<p><strong>Fax:</strong> '.htmlspecialchars($text).'</p>';
+ }
+ return( $text );
+ }
+
+ /**
+ * set_file:Set the file string
+ * <code><p><strong>Contact Name:</strong> {$text}</p></code>
+ * @param string $text: The text as string
+ * @param string $name: The file name displayed
+ * @uses URL_BASE
+ *
+ * @return string $text
+ * @access public
+ **/
+ function set_file( $text, $name )
+ {
+ if( $text != "" )
+ {
+ $outtext = '<p><a';
+ if(preg_match("/[.]([A-Z0-9]{3}$)/i",$text,$tmp))
+ {
+ $outtext .= ' class="'.strtolower($tmp[1]).'"';
+ }
+ $outtext .= ' href="'.URL_BASE.'uploads/'.$text.'" target="_blank">';
+ if($name)
+ {
+ $outtext .= htmlspecialchars($name);
+ }
+ else
+ {
+ $outtext .= htmlspecialchars($text);
+ }
+ $outtext .= '</a>';
+ if(preg_match("/[.]([A-Z0-9]{3}$)/i",$text,$tmp))
+ {
+ $outtext .= '<a href="'.BASE_URL.'download.php?file='.$text.'" class="download">Click here to Download </a>';
+ }
+ $outtext .= '</p>';
+ }
+ return( $outtext );
+ }
+
+ /**
+ * set_address:set_address
+ * <code><p>{$address}<br>{$city},{$state} {$zip}</p></code>
+ * @param array $data: data contain the address info for display.
+ *
+ * @return string $address
+ * @access public
+ **/
+ function set_address( $data )
+ {
+ $address = "";
+ if( $data["address"] )
+ {
+ $address .= $data["address"];
+ }
+ if( $data["city"] && $data["state"] && $data["zip"] )
+ {
+ $address .= '<br>'.$data["city"].', '.$data["state"].' '.$data["zip"];
+ }
+ elseif( $data["city"] && $data["state"] )
+ {
+ $address .= '<br>'.$data["city"].', '.$data["state"];
+ }
+ elseif( $data["city"] )
+ {
+ $address .= '<br>'.$data["city"];
+ }
+ if( $address != "" )
+ {
+ return( '<p>'.$address.'<br></p>' );
+ }
+ }
+
+ /**
+ * get_all:Does the query and set_data calls boths arrays
+ *
+ * @uses GLM_TEMPLATE::set_data()
+ * @uses GLM_TEMPLATE::$data
+ * @uses GLM_TEMPLATE::$items
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function get_all( $type = NULL )
+ {
+ $catid = $this->catid;
+ if( $type == 1 || !$type )
+ {
+ $cat_query = "select * from bus_category where id = $catid order by pos";
+ $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) );
+ $this->data = $res[0];
+ }
+ if( $type == 2 || !$type )
+ {
+ $item_query = "select b.* from bus b left outer join bus_category_bus bcb on (bcb.busid = b.id) where bcb.catid = $catid order by bcb.pos";
+ $this->items = $this->set_data( $this->DB->db_auto_get_data( $item_query ) );
+ $file_query = "select * from files where bus_id in ( select bus_id from bus_category_bus where catid = ".$this->catid." ) order by bus_id,pos;";
+ if( $file_data = $this->DB->db_auto_get_data( $file_query ) )
+ {
+ foreach( $file_data as $file_row )
+ {
+ $this->item_files[$file_row['bus_id']][] = GLM_TEMPLATE::set_file( $file_row['filename'],$file_row['urltext'] );
+ }
+ }
+ }
+ }
+
+ /**
+ * call all class methods to set tho data elements
+ *
+ * <p>This is hightly dependant on the three tables of bus bus_category and bus_category_bus
+ * set_data:Calls each function of the class
+ * based on the key af the array $data[0][$key]</p>
+ * @todo Really need to look at enhancing this function for different datasetups.
+ * @param array $data: The input array from db query
+ * @uses GLM_TEMPLATE::$img_size
+ * @uses GLM_TEMPLATE::$img_align
+ * @uses GLM_TEMPLATE::$img_alternate
+ * @uses GLM_TEMPLATE::set_text()
+ * @uses GLM_TEMPLATE::set_header()
+ * @uses GLM_TEMPLATE::set_subheader()
+ * @uses GLM_TEMPLATE::set_url()
+ * @uses GLM_TEMPLATE::set_address()
+ * @uses GLM_TEMPLATE::set_img()
+ * @uses GLM_TEMPLATE::set_email()
+ * @uses GLM_TEMPLATE::set_phone()
+ *
+ * @return array data The finished array
+ * @access public
+ **/
+ function set_data( $data )
+ {
+ if( is_array( $data ) )
+ {
+ foreach( $data as $k => $val )
+ {
+ foreach( $val as $key => $value )
+ {
+ if( strstr( $key, "image" ) && !strstr( $key, "name") && $value != "" )
+ {
+ $titletag = ( $data[$k]['category'] ) ? $data[$k]['category'] : $data[$k]['name'];
+ //$data[$k][$key."_name"] = $value;
+ $data[$k][$key] = $this->set_img( $value, $this->img_size, $this->img_align, $titletag, $data[$k][$key."name"] );
+ if( !strstr( $key, "name" ) )
+ {
+ if( $this->img_align == "right" && $this->img_alternate )
+ {
+ $this->img_align = "left";
+ }
+ elseif( $this->img_alternate )
+ {
+ $this->img_align = "right";
+ }
+ }
+ }
+ elseif( strstr($key,"file") && strstr($key,"name") && $value!="" )
+ {
+ }
+ elseif( strstr($key,"url") && strstr($key,"name") && $value!="" )
+ {
+ }
+ elseif( strstr($key,"descr") && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
+ }
+ elseif( $key == "contactname" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_contact( $value, $data[$k]['email'] );
+ }
+ elseif($key == "name" && $value!="")
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value );
+ }
+ elseif( strstr( $key, "header" ) && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value );
+ }
+ elseif( $key == "intro" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_header( $value );
+ }
+ elseif( $key == "category" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_header( $value );
+ }
+ elseif( $key == "url" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_url( $value, $data[$k]["urlname"] );
+ }
+ elseif( $key == "email" && $value!="")
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_email( $value, $data[$k]["contactname"] );
+ }
+ elseif( $key == "phone" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_phone($value);
+ }
+ elseif( $key == "fax" && $value != "" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_fax( $value );
+ }
+ elseif (strstr( $key, "file" ) && $value!="")
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_file( $value, $data[$k][$key.'name'] );
+ }
+ elseif( $key == "address" )
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_address( $data[$k] );
+ }
+ elseif( $key == "id" )
+ {
+ $data[$k][$key] = $value;
+ }
+ else
+ {
+ $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
+ }
+ }
+ }
+ return( $data );
+ }
+ return( false );
+ }
+
+ /**
+ * load_static_page:using object buffer include the page $catid.phtml from static dir
+ and return it as string
+ *
+ * @return string $text
+ * @access public
+ **/
+ function load_static_page()
+ {
+ if( file_exists( BASE."static/".$this->catid.".phtml" ) )
+ {
+ ob_start();
+ include("static/".$this->catid.".phtml");
+ $text = ob_get_contents();
+ ob_end_clean();
+ return($text);
+ }
+ }
+
+ /**
+ * clean_text:get rid of single br or p br tags left from htmlarea when textarea is empty.
+ * @param string $output:
+ *
+ * @return string text cleaned
+ * @access public
+ **/
+ function clean_text($output)
+ {
+ $output = str_replace("<br />","<br>",$output);
+ $output = str_replace("<p><br></p>","",$output);
+ return($output);
+ }
+
+ /**
+ * get_category: grab just category contents
+ * @param integer $catid: id of bus_category
+ * @param object $DB:
+ * @param boolean $showimg=1: weather or not to show category image
+ * @uses DELUXE_TOOLBOX
+ * @uses HOME_PAGE_EVENTS
+ * @uses GLM_TEMPLATE::clean_text()
+ * @uses GLM_TEMPLATE::get_home_events()
+ *
+ * @return string $output
+ * @access public
+ **/
+ function get_category( $showimg = 1,$showdiv=1 )
+ {
+ if( DELUXE_TOOLBOX )
+ {
+ $this->get_template( "cat" );
+ }
+
+ if( !$this->data )
+ {
+ $this->get_all( 1 );
+ }
+ $data = $this->data;
+ if( !$data["image"] && !$data["description"] && !$data["intro"] && ( $this->catid != 1 && HOME_PAGE_EVENTS != true ) )
+ {
+ return( false );
+ }
+ if($showdiv==1)
+ {
+ $output .= '<div id="category">
+ ';
+ }
+ if( $this->catid == 1 && HOME_PAGE_EVENTS )
+ {
+ $output .= $this->get_home_events();
+ }
+ if($data["image"] || $data["description"] || $data["intro"] )
+ {
+ if($showimg == 1)
+ {
+ $output .=$data["image"]." ";
+ }
+ $output .=$data["intro"]." ";
+ $output .=$data["description"]." ";
+ }
+ if($showdiv==1)
+ {
+ $output .= '</div>
+ ';
+ }
+ $output = GLM_TEMPLATE::clean_text($output);
+ return( $output );
+
+ }
+
+ /**
+ * photo_module
+ * Load the photo gallery into page
+ *
+ * @access public
+ * @return string
+ */
+ function photo_module()
+ {
+ $query = "select photocat_id from photo_category_bus where buscat_id = $this->catid;";
+ if( $pData = $this->DB->db_auto_get_data( $query ) )
+ {
+ if( count( $pData ) > 1 )
+ {
+ foreach( $pData as $pKey => $pVal )
+ {
+ $photocatid[] = $pVal['photocat_id'];
+ }
+ }
+ else
+ {
+ $photocatid = $pData[0]['photocat_id'];
+ }
+ if( is_numeric( $photocatid ) || is_array( $photocatid ) )
+ {
+ if( !$_GET['photo_catid'] )
+ {
+ $_GET['photo_catid'] = $photocatid;
+ }
+ ob_start();
+ include_once(BASE.'static/photo.php');
+ $out .= ob_get_contents();
+ ob_end_clean();
+ }
+ }
+ return( $out );
+ }
+
+ /**
+ * get_page: replacing template_parser with get_page function
+ *
+ * @uses GLM_TEMPLATE::get_category() For building the main page section
+ * @uses GLM_TEMPLATE::get_listings() For building out the paragraph sections
+ *
+ * @return string $out NEED to echo results of this function
+ * @access public
+ **/
+ function get_page( $showimg = 1,$showdiv=1 )
+ {
+ if( $this->page_status != 'Good' )
+ {
+ return('<h1>Sorry this page is temporary Taken Down!</h1>');
+ }
+ if( GOOGLE_SEARCH && ( $_POST['Query'] || $_GET['Query'] ) ) // for the gogle search engine api
+ { // if Query is sent display search results
+ ini_set('include_path', BASE.'google' . ':' .ini_get('include_path'));
+ ob_start();
+ include_once(GOOGLE."search.php");
+ include_once(GOOGLE."results.php");
+
+ echo SearchResults();
+ $out = '<div id="toolbox">'.ob_get_contents().'</div>';
+ ob_end_clean();
+ }
+ elseif(MEMBERS_DB && $this->Member->member_sections[$this->catid] )
+ {
+ if( !$_GET['id'] )
+ {
+ $out .= '<div id="toolbox">'.$this->get_category( $showimg,$showdiv );
+ $out .= $this->get_listings().'</div>';
+ }
+ ob_start();
+ $out .= $this->Member->get_list();
+ $out .= ob_get_contents();
+ ob_end_clean();
+ }
+ else
+ {
+ $out .= '<div id="toolbox">'.$this->get_category( $showimg,$showdiv );
+ $out .= $this->get_listings().'</div>';
+ if( PHOTO_GALLERY )
+ {
+ $out .= $this->photo_module();
+ }
+ }
+ return( $out );
+ }
+
+ /**
+ * get_template: get the template type of the bus_category
+ * @param mixed $type : 'cat' or 'list'
+ *
+ * @uses GLM_DB::db_auto_get_data()
+ * @uses GLM_TEMLATE::img_align()
+ * @uses GLM_TEMLATE::img_alternate()
+ * @uses GLM_TEMLATE::$template
+ *
+ * @return void
+ * @access public
+ **/
+ function get_template( $type )
+ {
+ $query = "select template from bus_category where id = ".$this->catid;
+ $data = $this->DB->db_auto_get_data( $query );
+ switch( $type )
+ {
+ case "cat":
+ switch( $data[0]['template'] )
+ {
+ case "5":
+ case "4":
+ case "2":
+ $this->img_align = "left";
+ break;
+
+ default:
+ $this->img_align = "right";
+ break;
+ }
+ break;
+
+ case "list":
+ switch( $data[0]['template'] )
+ {
+ case "6":
+ case "2":
+ $this->img_align = "left";
+ $this->img_alternate = 0;
+ break;
+
+ case "5":
+ case "1":
+ $this->img_align = "right";
+ $this->img_alternate = 0;
+ break;
+
+ case "4":
+ $this->img_align = "right";
+ $this->img_alternate = 1;
+ break;
+
+ case "3":
+ $this->img_align = "left";
+ $this->img_alternate = 1;
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
+ return( $this->template = $data[0]['template'] );
+ }
+ /**
+ * template_parser:This function creates data
+ * and items arrays and does the output for the page.
+ *
+ * @uses DELUXE_TOOLBOX
+ * @uses GLM_TEMPLATE::$items
+ * @uses GLM_TEMPLATE::get_template()
+ * @uses GLM_TEMPLATE::get_all()
+ * @uses GLM_TEMPLATE::load_static_page()
+ * @uses GLM_TEMPLATE::clean_text()
+ * @uses GLM_TEMPLATE::$item_files
+ *
+ * @return void
+ * @access public
+ **/
+ function get_listings()
+ {
+ // grab category and items into data and items respectfully
+ if( DELUXE_TOOLBOX )
+ {
+ $this->get_template( "list" );
+ }
+
+ if( !is_array( $this->items ) )
+ {
+ $this->get_all( 2 );
+ }
+
+ // load any static category page from the static directory
+ // hard codded content would have $catid.phtml page for it
+ $output .= $this->load_static_page();
+ switch($this->type)
+ {
+
+ default:
+ if(is_array($this->items))
+ {
+ foreach($this->items as $key=>$val)
+ {
+ //$output .= '<div class="clearer"></div>';
+ // items can be moved around as needed
+ $output .= '<div class="listing">'."\n";
+ $output .= $val["image"];
+ $output .= $val["name"];
+ $output .= $val["address"];
+ $output .= $val["description"];
+ $output .= $val["contactname"];
+ $output .= $val["email"];
+ $output .= $val["phone"];
+ $output .= $val["fax"];
+ $output .= $val["url"];
+ if( is_array( $this->item_files[$val['id']] ) )
+ {
+ $output .= implode("",$this->item_files[$val['id']]);
+ }
+ $output .= "</div>"."\n";
+ }
+ }
+ break;
+ }
+ $output = GLM_TEMPLATE::clean_text($output);
+ return( $output );
+ }
+
+ /**
+ * sub_nav:Create a sub navigation 4 across
+ *
+ * @param integer $catid: The catid for the page
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function sub_nav($catid)
+ {
+ //$catid = $this->get_top_parent($catid);
+ $query1 = "SELECT category FROM bus_category WHERE id = $catid";
+ $data1 = $this->DB->db_auto_get_data( $query1 );
+ $out = '<div id="nav-sub">
+ <h3>'.htmlentities( strip_tags( $data1[0]['category'] ) ,ENT_QUOTES,'UTF-8').'</h3>';
+
+ $query = "SELECT id,category,intro FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";
+ $data = $this->DB->db_auto_get_data($query);
+ if(is_array($data))
+ {
+ $counter = 1;
+ foreach($data as $key=>$val)
+ {
+ $url = $this->get_seo_url( $val['id'] );
+ $title = strip_tags(addslashes($val['intro']));
+ //GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_Name( $val['id'],"bus_category",$this->DB ) );
+ $out .= '<a title="'.$title.'" href="'.$url.'">';
+ $out .= $val["category"];
+ $out .= '</a><br>';
+ }
+ }
+ $out .= '</div>';
+ return( $out );
+ }
+
+ /**
+ * get_home_events: get events flaged as home events
+ * @param object $DB: DB reference to DB obj
+ *
+ * @uses GLM_TEMPLATE::get_event_date()
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function get_home_events()
+ {
+ $query = "select id,header,descr,bdate,edate,img from event where home = 't' and visable='t' and edate >= current_date;";
+ $data = $this->DB->db_auto_get_data($query);
+ if(is_array($data))
+ {
+ $output = '<div id="events">UPCOMING EVENTS<div id="eventsbox">
+ ';
+ foreach($data as $key=>$value)
+ {
+ $id = $value['id'];
+ $header = $value['header'];
+ $title = strip_tags(addslashes($header));
+ $descr = substr( strip_tags( addslashes( $value['descr'] ) ), 0, 50 );
+ $sdate = strtotime($value['bdate']);
+ $edate = strtotime($value['edate']);
+ $dates = GLM_TEMPLATE::get_event_date($sdate,$edate,"timestamp");
+ $output .= $dates;
+ $output .= '<h3><a title="" href="events.phtml?eventid='.$id.'">'.$header.'</a></h3>';
+ }
+ $output .= '</div></div>';
+ return($output);
+ }
+ else
+ {
+ return( '' );
+ }
+ }
+
+ /**
+ * get_event_date: make the event date human readable
+ * @param string $sdate: start date
+ * @param string $edate: end date
+ * @param string $dateType: dateType Postgres,etc
+ *
+ * @return string
+ * @access public
+ **/
+ function get_event_date($sdate,$edate,$dateType)
+ {
+ switch($dateType)
+ {
+ case "Postgres":
+ if(preg_match("/([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})/",$sdate,$spt))
+ {
+ $mon = $spt[1];
+ $day = $spt[2];
+ $yr = $spt[3];
+ }
+
+ if(preg_match("/([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})/",$edate,$ept))
+ {
+ $mon2 = $ept[1];
+ $day2 = $ept[2];
+ $yr2 = $ept[3];
+ }
+ break;
+
+ case "timestamp":
+ $mon = date("m",$sdate);
+ $day = date("d",$sdate);
+ $yr = date("Y",$sdate);
+ $mon2 = date("m",$edate);
+ $day2 = date("d",$edate);
+ $yr2 = date("Y",$edate);
+ break;
+
+ }$start = mktime(0,0,0,$mon,$day,$yr);
+ $end = mktime(0,0,0,$mon2,$day2,$yr2);
+ if ($day == $day2 && $mon == $mon2 && $yr == $yr2)
+ {
+ $dateparam = "F jS, Y";
+ $date_begin = date($dateparam, $start) ;
+ $date_end = "";
+ }
+ elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2)
+ {
+ $dateparam1 = "F jS, Y -";
+ $dateparam2 = "Y";
+ $date_begin = date($dateparam1, $start);
+ $date_end = date($dateparam2, $end);
+ }
+ elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2)
+ {
+ $dateparam1 = "F jS -";
+ $dateparam2 = "jS, Y";
+ $date_begin = date($dateparam1, $start);
+ $date_end = date($dateparam2, $end);
+ }
+ elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2)
+ {
+ $dateparam1 = "F jS, Y -";
+ $dateparam2 = "F jS, Y";
+ $date_begin = date($dateparam1, $start);
+ $date_end = date($dateparam2, $end);
+ }
+ elseif ($yr == $yr2)
+ {
+ $dateparam1 = "F jS -";
+ $dateparam2 = "F jS, Y";
+ $date_begin = date($dateparam1, $start);
+ $date_end = date($dateparam2, $end);
+ }
+ else
+ {
+ $dateparam1 = "F jS, Y -";
+ $dateparam2 = "F jS, Y";
+ $date_begin = date($dateparam1, $start);
+ $date_end = date($dateparam2, $end);
+ }
+
+ return($date_begin." ".$date_end);
+ }
+
+ /**
+ * is_sub_id:Check to see if catid is sub of category
+ *
+ * @param integer $catid: the catid looking at
+ * @param integer $category: to see if it is in category
+ * @param object $DB: Db object reference
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return bool
+ * @access public
+ **/
+ function is_sub_id($catid,$category,&$DB)
+ {
+ if( !is_numeric( $catid ) )
+ {
+ return( false );
+ }
+ if($category==$catid)
+ {
+ return(true);
+ }
+ $query = "select id,parent from bus_category where id = $catid";
+ $data = $DB->db_auto_get_data($query);
+ $parent = $data[0]['parent'];
+ if($parent == 0)
+ {
+ return(false);
+ }
+ else
+ {
+ return( GLM_TEMPLATE::is_sub_id($parent,$category,&$DB) );
+ }
+ }
+
+ /**
+ * get_parent: get parent for this category
+ *
+ * @param integer $catid: id
+ * @param object $DB: database obj
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return int $parent
+ * @access public
+ **/
+ function get_parent($catid,&$DB)
+ {
+ $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos";
+ $data = $DB->db_auto_get_data($query);
+ return( $data[0]["parent"] );
+ }
+
+ /**
+ * get_sub_nav:
+ * @param integer $catid:
+ * @param object $DB:
+ *
+ * @uses GLM_TEMPLATE::get_parent()
+ * @uses GLM_TEMPLATE::get_seo_url()
+ * @uses GLM_TEMPLATE::is_sub_id()
+ * @uses GLM_TEMPLATE::get_sub_nav()
+ * @uses GLM_TEMPLATE::has_subs()
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function get_sub_nav($catid,&$DB)
+ {
+ $parentid = GLM_TEMPLATE::get_parent($catid,&$DB);
+ //echo $parentid.'<br>';
+ $query = "SELECT id,category,intro FROM bus_category WHERE parent = $parentid ".$this->active_query." ORDER BY pos";
+ $data = $DB->db_auto_get_data($query);
+ if(is_array($data))
+ {
+ $output = '<div id="subnav">';
+ $counter = 1;
+ foreach($data as $key=>$val)
+ {
+ $url = $this->get_seo_url( $val['id'] );
+ $title = strip_tags(addslashes($val['intro']));
+ if(GLM_TEMPLATE::is_sub_id($catid,$parentid,&$DB) && (GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) || $val['id'] == $catid) )
+ {
+ $output .= '<a title="'.$title.'" class="current" href="'.$url.'">';
+ }
+ else
+ {
+ $output .= '<a title="'.$title.'" href="'.$url.'">';
+ }
+ $output .= $val["category"];
+ $output .= '</a>';
+ if( GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) && GLM_TEMPLATE::has_subs($val['id'],&$DB))
+ {
+ $output .= GLM_TEMPLATE::get_sub_nav($val["id"],&$DB,$catid);
+ }
+ }
+ $output .= '</div>';
+ $output = GLM_TEMPLATE::clean_text($output);
+ echo $output;
+ }
+ return(false);
+ }
+
+ /**
+ * has_subs:
+ * @param integer $catid:
+ * @param object $DB:
+ *
+ * @uses GLM_TEMPLATE::$active_query
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function has_subs($catid,&$DB)
+ {
+ $query = "SELECT id FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";
+ $data = $DB->db_auto_get_data($query);
+ if(is_array($data))
+ {
+ return(true);
+ }
+ else
+ {
+ return(false);
+ }
+ }
+
+
+ /**
+ * get_top_parent:Get the highest level parent id (not 0 )for the category.
+ *
+ * <p><b>NOTICE:</b> This is ment to get the top level parent not the parent of the id given.</p>
+ *
+ * @param integer $id: The catid for the page.
+ * @param object $DB: obj
+ * @uses GLM_TEMPLATE::get_top_parent()
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return int $parent
+ * @access public
+ **/
+ function get_top_parent($id,&$DB)
+ {
+ if( $id == 0 )
+ {
+ return( 0 );
+ }
+ $qs = "select parent from bus_category where id = $id";
+ $parentrow = $DB->db_auto_get_data( $qs );
+ if($parentrow[0]['parent'] == 0)
+ {
+ return($id);
+ }
+ else
+ {
+ return( GLM_TEMPLATE::get_top_parent($parentrow[0]['parent'],&$DB) );
+ }
+ }
+
+ /**
+ * get_main_cats
+ *
+ * @access public
+ * @return string
+ */
+ function get_main_cats()
+ {
+ static $main_cats_array;
+ if( !is_array( $main_cats_array ) )
+ {
+ $query = "select id,category from bus_category where parent = 0 order by pos;";
+ if( $data = $this->DB->db_auto_get_data( $query ) )
+ {
+ foreach( $data as $row )
+ {
+ $main_cats_array[$row['id']] = htmlentities(strip_tags($row['category']),ENT_QUOTES,'UTF-8');
+ }
+ }
+ }
+ return( $main_cats_array );
+ }
+ /**
+ * show_catimg:output the category image.
+ *
+ * @param integer $catid: The catid for the page.
+ * @uses GLM_TEMPLATE::MIDSIZED
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function show_catimg($catid)
+ {
+ $query = "SELECT image FROM bus_category WHERE id = $catid";
+ $data = $this->DB->db_auto_get_data($query);
+ if($data[0]["image"]!="")
+ {
+ $img = '<img src="'.MIDSIZED.$data[0]["image"].'" border="0" vspace="30" hspace="0">';
+ }
+ else
+ {
+ $img = '<img src="assets/logo_small.gif" width="150" height="85" vspace="0" hspace="0" border="0" alt="Birchwood Construction"><BR>';
+ }
+ echo $img;
+ echo '<BR><img src="assets/clear.gif" height="30" width="1">';
+ }
+
+
+ /**
+ * get_catheader:output the category name.
+ *
+ * @param integer $catid: The catid for the page
+ * @param object $DB: db obj
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function get_catheader($catid,$DB)
+ {
+ $query = "SELECT category FROM bus_category WHERE id = $catid";
+ $data = $DB->db_auto_get_data($query);
+ if($data[0]['category']!="")
+ {
+ $header = strip_tags($data[0]['category']);
+ }
+ else
+ {
+ $header = '';
+ }
+ return( $header );
+ }
+
+ /**
+ * get_catintro: return the category page name.
+ *
+ * @param integer $catid: The catid for the page
+ * @param object $DB: db obj
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function get_catintro($catid)
+ {
+ $query = "SELECT intro FROM bus_category WHERE id = $catid";
+ $data = $this->DB->db_auto_get_data($query);
+ if($data[0]['intro']!="")
+ {
+ $header = strip_tags($data[0]['intro']);
+ }
+ else
+ {
+ $header = '';
+ }
+ return( $header );
+ }
+
+ /**
+ * show_catheader:
+ *
+ * @param integer $catid:
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function show_catheader($catid)
+ {
+ $query = "SELECT category FROM bus_category WHERE id = $catid";
+ $data = $this->DB->db_auto_get_data($query);
+ if($data[0][category]!="")
+ {
+ $header = $data[0][category];
+ }
+ else
+ {
+ $header = ' ';
+ }
+ echo $header;
+ }
+
+ /**
+ * get_menu_string:get categories for the phplayermenu
+ *
+ * @uses GLM_TEMPLATE::sort_childs()
+ * @uses GLM_TEMPLATE::convert_to_thread()
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function get_menu_string()
+ {
+ $query = "SELECT id,parent,category FROM bus_category WHERE id != 0 ".$this->active_query." ORDER BY parent,pos";
+ $data = $this->DB->db_auto_get_data($query);
+ $newdata = GLM_TEMPLATE::sort_childs($data);
+ $string = GLM_TEMPLATE::convert_to_thread($newdata,$newdata[0]);
+ return($string);
+ }
+
+
+ /**
+ * get_menu_array: like get_menu_string but returns an array
+ *
+ * @uses GLM_TEMPLATE::sort_childs()
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function get_menu_array()
+ {
+ $query = "SELECT id,parent,category FROM bus_category WHERE id != 0 ".$this->active_query." ORDER BY parent,pos";
+ $data = $this->DB->db_auto_get_data($query);
+ $newdata = GLM_TEMPLATE::sort_childs($data);
+ return $newdata;
+ }
+
+ /**
+ * sort_childs:
+ * @param array $threads:
+ *
+ * @return string
+ * @access public
+ **/
+ function sort_childs($threads)
+ {
+ foreach($threads as $var=>$value)
+ {
+ $childs[$value["parent"]][$value["id"]] = $value;
+ }
+ return($childs);
+ }
+
+ /**
+ * convert_to_thread:
+ *
+ * @param array $threads:
+ * @param array $thread:
+ * @uses GLM_TEMPLATE::$thread_count
+ * @uses GLM_TEMPLATE::$whole_thread
+ * @uses GLM_TEMPLATE::get_seo_url()
+ * @uses GLM_TEMPLATE::convert_to_thread()
+ *
+ * @return string
+ * @access public
+ **/
+ function convert_to_thread($threads, $thread)
+ {
+ foreach($thread as $parent=>$value)
+ {
+ $this->whole_thread .= str_repeat(".",$this->thread_count);
+ $this->whole_thread .= "|".htmlentities($value['category'],ENT_QUOTES,'UTF-8');
+ $url = $this->get_seo_url( $value['id'] );
+ $this->whole_thread .= "|".$url;
+ $this->whole_thread .="\n";
+ if($threads[$parent])
+ {
+ $this->thread_count++;
+ GLM_TEMPLATE::convert_to_thread($threads, $threads[$parent]);
+ }
+ }
+ $this->thread_count--;
+ return $this->whole_thread;
+ }
+
+
+ /**
+ * has_children: return true or false if this category has sub categories under it.
+ *
+ * @param integer $catid:
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function has_children($catid)
+ {
+ // returns number of children that $catid has
+ $qs="SELECT count(*) FROM bus_category WHERE parent=$catid ".$this->active_query."";
+ $row=$this->DB->db_auto_get_data($qs);
+ return $row[0]['count'];
+ }
+
+ /**
+ * get_ancestors:get the ancestors for this category
+ *
+ * @param integer $catid: catid
+ * @param integer $count: starting counter
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return array
+ * @access public
+ **/
+ function get_ancestors($catid,$count)
+ {
+ if( $count == 0 )
+ {
+ unset( $this->ancestors );
+ }
+ if($catid)
+ {
+ $query = "SELECT id,category,parent
+ FROM bus_category
+ WHERE id = ".$catid."
+ ".$this->active_query;
+ $res = $this->DB->db_auto_get_data($query);
+ $id = $res[0]['id'];
+ $parent = $res[0]['parent'];
+ $category = $res[0]['category'];
+ $this->ancestors[$count]['id'] = $id;
+ $this->ancestors[$count]['label'] = $category;
+
+ $url = $this->get_seo_url( $id );
+ $this->ancestors[$count]['link'] = $url;
+ GLM_TEMPLATE::get_ancestors($parent,$count+1,$conn);
+
+ return (array_reverse($this->ancestors) );
+ }
+ }
+
+ /**
+ * meta_tags: create the meta description content for this page.
+ * this is taken from the category description.
+ * this should be only done for all but the home page.
+ * $meta = ( $catid != 1 ) ? $toolbox->meta_tags() : '';
+ *
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function meta_tags()
+ {
+ $query = "select description from bus_category where id = ".$this->catid;
+ $data = $this->DB->db_auto_get_data( $query );
+ $description = htmlentities( substr( trim( strip_tags( $data[0]['description'] ) ), 0, 250 ),ENT_QUOTES,'UTF-8' );
+ return( $description );
+ }
+
+ /**
+ * title: create the title for the page.
+ * this should be only done for all but the home page.
+ * $title = ( $catid != 1 ) ? $toolbox->title() : '';
+ *
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function title()
+ {
+ $query = "select category,intro from bus_category where id = ".$this->catid;
+ $data = $this->DB->db_auto_get_data( $query );
+ if( $data[0]['intro'] )
+ {
+ $title = strip_tags( $data[0]['intro'] );
+ }
+ else
+ {
+ $title = strip_tags( $data[0]['category'] );
+ }
+ return( htmlentities( $title.' - ',ENT_QUOTES,'UTF-8' ) );
+ }
+
+ /**
+ * get_bottom_nav: generate a top level only bottom navigation for the pages.
+ *
+ * @param integer $parent=0:
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function get_bottom_nav($parent=0)
+ {
+ $out = '';
+ $query = "select id,category,intro from bus_category where id != 1 and parent = $parent ".$this->active_query." order by pos asc";
+ $row = $this->DB->db_auto_get_data( $query );
+ $url = $this->get_seo_url( HOME_ID );
+ $links[] = '<a href="'.$url.'">Home</a>';
+ if( !is_array( $row ) )
+ {
+ return( false );
+ }
+ else
+ {
+ $out .= '<div id="nav-bottom">';
+ for( $i=0; $i<sizeof( $row ); $i++)
+ {
+ $category = htmlentities(strip_tags($row[$i]['category']),ENT_QUOTES,'UTF-8');
+ $url = $this->get_seo_url( $row[$i]['id'] );
+ $links[] = '<a href="'.$url.'">'.$category."</a>\n";
+ }
+ if( is_array( $links) )
+ {
+ $out .= implode(" | ",$links);
+ }
+ $out .= '</div>';
+ return( $out );
+ }
+ }
+
+
+ /**
+ * make_ul_menu: create url list of categories
+ *
+ * @param integer $parent parent to start from
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function make_ul_menu( $parent = 0 )
+ {
+ $qs = "SELECT id,category,intro FROM bus_category WHERE parent = $parent ".$this->active_query." ORDER BY pos";
+ $data = $this->DB->db_auto_get_data($qs);
+ if(!is_array($data))
+ {
+ return( false );
+ }
+ else
+ {
+ foreach( $data as $key => $row )
+ {
+ $url = $this->get_seo_url( $row['id'] );
+ $title = strip_tags(addslashes($row['intro']));
+ $return.='
+ <li><a title="'.htmlentities($title,ENT_QUOTES,'UTF-8').'" href="'.$url.'"';
+ if( $this->catid == $row['id'] )
+ {
+ $return .= ' id="current"';
+ }
+ $return .= '>'.htmlentities($row['category'],ENT_QUOTES,'UTF-8')."</a>";
+ if( $this->has_subs( $row['id'], &$this->DB ) && ( $this->is_sub_id( $this->catid, $row['id'], &$this->DB ) || $this->catid == $row['id'] ) )
+ {
+ $ret2 = $this->make_ul_menu( $row['id'] );
+ $return.=$ret2;
+ }
+ $return.="
+ </li>";
+ }
+ $main_cats = $this->get_main_cats();
+ if( $main_cats[$parent] )
+ {
+ $return = '<div id="subnav">
+ <div id="subnav-header">'.$this->get_catheader( $parent ,&$this->DB ).'</div>
+ <ul id="navlist">'.$return.'</ul>
+ </div>
+ ';
+ return( $return );
+ }
+ else
+ {
+ $return = '
+ <ul>'.$return.'</ul>
+ ';
+ return( $return );
+ }
+ }
+ }
+
+ /**
+ * print_ancestors:print out the ancestors
+ * @param integer $catid: the id to start at.
+ *
+ * @return string
+ * @access public
+ **/
+ function print_ancestors($catid)
+ {
+ return( $this->get_bread_crumbs( $catid ) );
+ }
+
+ /**
+ * get_bread_crumbs
+ *
+ * @param mixed $catid
+ * @access public
+ * @return string
+ */
+ function get_bread_crumbs( $catid )
+ {
+ $string = $this->get_ancestors( $catid, 0 );
+ if(is_array($string))
+ {
+ $end = count( $string ) - 1;
+ for($i=0;$i<$end;$i++)
+ {
+ $outarray[] = '<a href="'.$string[$i]["link"].'">'.$string[$i]["label"].'</a>';
+ }
+ $outarray[] = $this->get_catheader( $catid, &$this->DB );
+ if( is_array( $outarray ) && count( $outarray ) > 1 )
+ {
+ $out .= implode( " » ", $outarray );
+ }
+ if( $out )
+ {
+ $return = '<div id="breadcrumbs">'.$out.'</div>';
+ }
+ }
+ return( $return );
+ }
+
+ /**
+ * build_picklist:
+ * @param string $fieldname:
+ * @param array $data:
+ * @param mixed $selected:
+ * @param string $type = "standard":
+ * @param boolean $auto = 0:
+ * @param integer $width = NULL :
+ *
+ * @uses GLM_TOOLBOX::build_picklist()
+ *
+ * @return string
+ * @access public
+ **/
+ function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
+ {
+ return( GLM_TOOLBOX::build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL ) );
+ }
+
+ /**
+ * keyword_replace:
+ *
+ * @param string $string:
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return string
+ * @access public
+ **/
+ function keyword_replace($string)
+ {
+ //return($string);
+ if($search = strstr($string,"{"))
+ {
+ if(preg_match("/\{([A-Z0-9\&\-\,\'\" ]*)\}/i",$string,$needle))
+ {
+ if($needle[0] != "")
+ {
+ $qs = "SELECT id,category
+ FROM bus_category
+ WHERE trim(keyword) = '".trim($needle[1])."'";
+
+ $keyres = $this->DB->db_auto_get_data($qs);
+ $parent = $this->get_top_parent($keyres[0]['id'],&$this->DB);
+ $url = $this->get_seo_url( $keyres[0]['id'] );
+ $replacement = "<a href=\"".$url."\">".htmlspecialchars($keyres[0]['category'])."</a>";
+ $string = str_replace($needle[0],$replacement,$string);
+ }
+ }
+ else{
+ return($string);
+ }
+ if($search = strstr($string,"{"))
+ return($this->keyword_replace($string));
+ }
+ return($string);
+ }
+ /**
+ * getIdFromName:
+ *
+ * @param string $name:
+ * @param string $table:
+ * @param object $DB:
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @deprecated Don't use this! THIS IS A WARNING (this funcion will be gone next time)
+ * @return string
+ * @access public
+ **/
+ function get_id_from_name( $name, $table, &$DB)
+ {
+ if( $name == "" )
+ {
+ return( 0 );
+ }
+ if( is_numeric( $name ) )
+ {
+ return( $name );
+ }
+ if( preg_match("/(.*)/$/",$name,$tmp) )
+ {
+ $name = $tmp[1];
+ }
+ $category = "category";
+ if( preg_match("/-([0-9]*)$/",$name,$tmp ) )
+ {
+ $id = $tmp[1];
+ return( $id );
+ }
+ // should already be returning id at this point
+ // putting the _id on the end of all url's as
+ // the other way is very inifiecent for the database.
+ $name = str_replace( "-"," ",$name );
+ $query = "select id from $table where trim(lower(replace(replace(replace(replace(replace(replace($category,'\'',''),'/',''),'-',' '),'#',''),'&',''),'?',''))) = '".trim(strtolower($name))."'";
+ $data = $DB->db_auto_get_data( $query );
+ if( is_array( $data ) )
+ {
+ foreach( $data as $key=>$val )
+ {
+ $catid = $val['id'];
+ }
+ return( $catid );
+ }
+ else
+ {
+ return( 0 );
+ }
+ }
+
+ /**
+ * get_base_url: generate the base of the url for the given category id
+ * @param integer $id :
*
- * We should be using the $_POST or $_GET globals here
- *
- * @return int catid
- * @access public
- **/
- function get_catid( $catid )
- {
- if( is_numeric( $_GET['catid'] ) )
- {
- return( $_GET['catid'] );
- }
- elseif( is_numeric( $_POST['catid'] ) )
- {
- return( $_POST['catid'] );
- }
- else
- {
- return( $this->catid = $catid );
- }
- }
-
- /**
- * set_contact:Set the contact string
- * <code><p><strong>Contact Name:</strong> {$text}</p></code>
- *
- * @param string $text: The text as string
- * @param string $email: email if givin
- *
- * @return string $text
- * @access public
- **/
- function set_contact( $text, $email )
- {
- if( $email != "" )
- {
- $text = "";
- }
- else
- {
- $text = '<p><strong>Contact Name:</strong> '.$text.'</p>';
- }
- return($text);
- }
-
- /**
- * set_text:Set the contact string
- * <code><p>{$text}</code>
- * @param string $text: The text as string
- *
- * @return string $text
- * @access public
- **/
- function set_text( $text )
- {
- if("" == str_replace("<br />","",trim($text)))
- {
- return(false);
- }
- if( $text != "" )
- {
- $text = $this->keyword_replace( $text );
- $text = $text;
- }
- return($text);
- }
-
- /**
- * get_image_path: get image path from the size used
- *
- * @uses MIDSIZED_PATH
- * @uses RESIZED_PATH
- * @uses THUMB_PATH
- *
- * @return path for images
- * @access public
- **/
- function get_image_path()
- {
- if( strstr($this->img_size,'midsized/') )
- {
- return( MIDSIZED_PATH );
- }
- if( strstr($this->img_size,'resized/') )
- {
- return( RESIZED_PATH );
- }
- if( strstr($this->img_size,'thumb/') )
- {
- return( THUMB_PATH );
- }
- }
-
- /**
- * set_img:Set the image string
- * <p><code>
- * <div class="image{$align}" style="width: {$width}px" src="{$size}{$image}" {$titletag}>
- * <div class="imagecaption">{$caption}</div>
- * </div>
- * </code>
- * </p>
- *
- * @param string $image: The image
- * @param string $size: The path
- * @param string $align: The alignment
- * @param string $name: The image_name (displayed under image)
- * @param string $alt_title text for use in alt and title tags
- * @param string $caption Text for image caption if given
- * @uses GLM_TEMPLATE::get_image_path()
- *
- * @return void
- * @access public
- **/
- function set_img( $image, $size, $align, $alt_title = NULL, $caption = NULL )
- {
- if( $image != "" )
- {
- if( $caption != '' )
- {
- $caption = str_replace('&','&',$caption);
- $titletag = 'title="'.htmlspecialchars(strip_tags($caption)).'"';
- $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
- }
- elseif( $alt_title != '')
- {
- $alt_title = str_replace('&','&',$alt_title);
- $titletag = 'title="'.htmlspecialchars(strip_tags($alt_title)).'"';
- $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
- }
- else
- {
- $titletag = 'title="'.htmlspecialchars(strip_tags($image)).'"';
- $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"';
- }
- if( $align != "" )
- {
- $img_align = 'class="image'.$align.'"';
- }
- $path = $this->get_image_path();
- if( is_file( $path.$image ) )
- {
- $image_size = getimagesize( $path.$image );
- $img_attr = $image_size[3];
- }
- $img = '
- <div '.$img_align.' style="width: '.$image_size[0].'px">
- ';
- $img .= '<img '.$img_attr.' src="'.$size.$image.'" '.$titletag.'>';
- if( $caption )
- {
- $img .= '
- <div class="imagecaption">'.$caption.'</div>
- ';
- }
- $img .= '</div>
- ';
- return($img);
- }
- }
-
- /**
- * set_url:Set the url string
- * <p>
- * <code><p><a href="http://{$url}" target="_blank">{$text}</a></code>
- * </p>
- *
- * @param string $url: The url
- * @param string $text: The text as string
- *
- * @return string $text
- * @access public
- **/
- function set_url( $url, $text )
- {
- if( $url != "" )
- {
- if( !$text )
- {
- $text = $url;
- }
- if( strtolower( substr( $url, 0, 7 ) ) == "https://" )
- {
- $url = '<p><a href="'.$url.'" target="_blank">'.htmlspecialchars($text).'</a></p>';
- }
- else
- {
- $url = '<p><a href="http://'.$url.'" target="_blank">'.htmlspecialchars($text).'</a></p>';
- }
- }
- return( $url );
- }
-
- /**
- * set_email:Set the email string
- * <code><p><strong>Contact:</strong> <a href="mailto:{$email}" target="_blank">{$text}</a></p></code>
- * @param string $email: The email as string
- * @param string $contact: The contactname this is used as the link text
- *
- * @return string $text
- * @access public
- **/
- function set_email( $email, $contact )
- {
- if( $email != "" )
- {
- if( $contact != "" )
- {
- $email = '<p><strong>Contact:</strong> <a href="mailto:'.$email.'" target="_blank">'.htmlspecialchars($contact).'</a></p>';
- }
- else
- {
- $email = '<p><strong>Email:</strong> <a href="mailto:'.$email.'" target="_blank">'.htmlspecialchars($email).'</a></p>';
- }
- }
- return( $email );
- }
-
- /**
- * set_header:Set the header string
- * @param string $text: The text as string
- * @uses GLM_TEMPLATE::header_begin()
- * @uses GLM_TEMPLATE::header_end()
- *
- * @return string $text
- * @access public
- **/
- function set_header( $text )
- {
- if( $text != "" )
- {
- $text = $this->header_begin.htmlspecialchars($text).$this->header_end;
- }
- return( $text );
- }
-
- /**
- * set_subheader:Set the subheader string
- * @param string $text: The text as string
- * @uses GLM_TEMPLATE::subheader_begin()
- * @uses GLM_TEMPLATE::subheader_end()
- *
- *
- * @return string $text
- * @access public
- **/
- function set_subheader( $text )
- {
- if( $text != "" )
- {
- $text = $this->subheader_begin.htmlspecialchars($text).$this->subheader_end;
- }
- return( $text );
- }
-
- /**
- * set_phone:Set the phone string
- * <code><p><strong>Phone:</strong> {$text}</p></code>
- * @param string $text: The text as string
- *
- * @return string $text
- * @access public
- **/
- function set_phone( $text )
- {
- if( $text != "" )
- {
- $text = '<p><strong>Phone:</strong> '.$text.'</p>';
- }
- return( $text );
- }
-
- /**
- * set_fax:Set the fax string
- * <code><p><strong>Fax:</strong> {$text}</p></code>
- * @param string $text: The text as string
- *
- * @return string $text
- * @access public
- **/
- function set_fax( $text )
- {
- if( $text != "" )
- {
- $text = '<p><strong>Fax:</strong> '.htmlspecialchars($text).'</p>';
- }
- return( $text );
- }
-
- /**
- * set_file:Set the file string
- * <code><p><strong>Contact Name:</strong> {$text}</p></code>
- * @param string $text: The text as string
- * @param string $name: The file name displayed
- * @uses URL_BASE
- *
- * @return string $text
- * @access public
- **/
- function set_file( $text, $name )
- {
- if( $text != "" )
- {
- $outtext = '<p><a';
- if(preg_match("/[.]([A-Z0-9]{3}$)/i",$text,$tmp))
- {
- $outtext .= ' class="'.strtolower($tmp[1]).'"';
- }
- $outtext .= ' href="'.URL_BASE.'uploads/'.$text.'" target="_blank">';
- if($name)
- {
- $outtext .= htmlspecialchars($name);
- }
- else
- {
- $outtext .= htmlspecialchars($text);
- }
- $outtext .= '</a>';
- if(preg_match("/[.]([A-Z0-9]{3}$)/i",$text,$tmp))
- {
- $outtext .= '<a href="'.BASE_URL.'download.php?file='.$text.'" class="download">Click here to Download </a>';
- }
- $outtext .= '</p>';
- }
- return( $outtext );
- }
-
- /**
- * set_address:set_address
- * <code><p>{$address}<br>{$city},{$state} {$zip}</p></code>
- * @param array $data: data contain the address info for display.
- *
- * @return string $address
- * @access public
- **/
- function set_address( $data )
- {
- $address = "";
- if( $data["address"] )
- {
- $address .= $data["address"];
- }
- if( $data["city"] && $data["state"] && $data["zip"] )
- {
- $address .= '<br>'.$data["city"].', '.$data["state"].' '.$data["zip"];
- }
- elseif( $data["city"] && $data["state"] )
- {
- $address .= '<br>'.$data["city"].', '.$data["state"];
- }
- elseif( $data["city"] )
- {
- $address .= '<br>'.$data["city"];
- }
- if( $address != "" )
- {
- return( '<p>'.$address.'<br></p>' );
- }
- }
-
- /**
- * get_all:Does the query and set_data calls boths arrays
- *
- * @uses GLM_TEMPLATE::set_data()
- * @uses GLM_TEMPLATE::$data
- * @uses GLM_TEMPLATE::$items
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function get_all( $type = NULL )
- {
- $catid = $this->catid;
- if( $type == 1 || !$type )
- {
- $cat_query = "select * from bus_category where id = $catid order by pos";
- $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) );
- $this->data = $res[0];
- }
- if( $type == 2 || !$type )
- {
- $item_query = "select b.* from bus b left outer join bus_category_bus bcb on (bcb.busid = b.id) where bcb.catid = $catid order by bcb.pos";
- $this->items = $this->set_data( $this->DB->db_auto_get_data( $item_query ) );
- $file_query = "select * from files where bus_id in ( select bus_id from bus_category_bus where catid = ".$this->catid." ) order by bus_id,pos;";
- if( $file_data = $this->DB->db_auto_get_data( $file_query ) )
- {
- foreach( $file_data as $file_row )
- {
- $this->item_files[$file_row['bus_id']][] = GLM_TEMPLATE::set_file( $file_row['filename'],$file_row['urltext'] );
- }
- }
- }
- }
-
- /**
- * call all class methods to set tho data elements
- *
- * <p>This is hightly dependant on the three tables of bus bus_category and bus_category_bus
- * set_data:Calls each function of the class
- * based on the key af the array $data[0][$key]</p>
- * @todo Really need to look at enhancing this function for different datasetups.
- * @param array $data: The input array from db query
- * @uses GLM_TEMPLATE::$img_size
- * @uses GLM_TEMPLATE::$img_align
- * @uses GLM_TEMPLATE::$img_alternate
- * @uses GLM_TEMPLATE::set_text()
- * @uses GLM_TEMPLATE::set_header()
- * @uses GLM_TEMPLATE::set_subheader()
- * @uses GLM_TEMPLATE::set_url()
- * @uses GLM_TEMPLATE::set_address()
- * @uses GLM_TEMPLATE::set_img()
- * @uses GLM_TEMPLATE::set_email()
- * @uses GLM_TEMPLATE::set_phone()
- *
- * @return array data The finished array
- * @access public
- **/
- function set_data( $data )
- {
- if( is_array( $data ) )
- {
- foreach( $data as $k => $val )
- {
- foreach( $val as $key => $value )
- {
- if( strstr( $key, "image" ) && !strstr( $key, "name") && $value != "" )
- {
- $titletag = ( $data[$k]['category'] ) ? $data[$k]['category'] : $data[$k]['name'];
- //$data[$k][$key."_name"] = $value;
- $data[$k][$key] = $this->set_img( $value, $this->img_size, $this->img_align, $titletag, $data[$k][$key."name"] );
- if( !strstr( $key, "name" ) )
- {
- if( $this->img_align == "right" && $this->img_alternate )
- {
- $this->img_align = "left";
- }
- elseif( $this->img_alternate )
- {
- $this->img_align = "right";
- }
- }
- }
- elseif( strstr($key,"file") && strstr($key,"name") && $value!="" )
- {
- }
- elseif( strstr($key,"url") && strstr($key,"name") && $value!="" )
- {
- }
- elseif( strstr($key,"descr") && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
- }
- elseif( $key == "contactname" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_contact( $value, $data[$k]['email'] );
- }
- elseif($key == "name" && $value!="")
- {
- $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value );
- }
- elseif( strstr( $key, "header" ) && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value );
- }
- elseif( $key == "intro" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_header( $value );
- }
- elseif( $key == "category" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_header( $value );
- }
- elseif( $key == "url" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_url( $value, $data[$k]["urlname"] );
- }
- elseif( $key == "email" && $value!="")
- {
- $data[$k][$key] = GLM_TEMPLATE::set_email( $value, $data[$k]["contactname"] );
- }
- elseif( $key == "phone" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_phone($value);
- }
- elseif( $key == "fax" && $value != "" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_fax( $value );
- }
- elseif (strstr( $key, "file" ) && $value!="")
- {
- $data[$k][$key] = GLM_TEMPLATE::set_file( $value, $data[$k][$key.'name'] );
- }
- elseif( $key == "address" )
- {
- $data[$k][$key] = GLM_TEMPLATE::set_address( $data[$k] );
- }
- elseif( $key == "id" )
- {
- $data[$k][$key] = $value;
- }
- else
- {
- $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
- }
- }
- }
- return( $data );
- }
- return( false );
- }
-
- /**
- * load_static_page:using object buffer include the page $catid.phtml from static dir
- and return it as string
- *
- * @return string $text
- * @access public
- **/
- function load_static_page()
- {
- if( file_exists( BASE."static/".$this->catid.".phtml" ) )
- {
- ob_start();
- include("static/".$this->catid.".phtml");
- $text = ob_get_contents();
- ob_end_clean();
- return($text);
- }
- }
-
- /**
- * clean_text:get rid of single br or p br tags left from htmlarea when textarea is empty.
- * @param string $output:
- *
- * @return string text cleaned
- * @access public
- **/
- function clean_text($output)
- {
- $output = str_replace("<br />","<br>",$output);
- $output = str_replace("<p><br></p>","",$output);
- return($output);
- }
-
- /**
- * get_category: grab just category contents
- * @param integer $catid: id of bus_category
- * @param object $DB:
- * @param boolean $showimg=1: weather or not to show category image
- * @uses DELUXE_TOOLBOX
- * @uses HOME_PAGE_EVENTS
- * @uses GLM_TEMPLATE::clean_text()
- * @uses GLM_TEMPLATE::get_home_events()
- *
- * @return string $output
- * @access public
- **/
- function get_category( $showimg = 1,$showdiv=1 )
- {
- if( DELUXE_TOOLBOX )
- {
- $this->get_template( "cat" );
- }
-
- if( !$this->data )
- {
- $this->get_all( 1 );
- }
- $data = $this->data;
- if( !$data["image"] && !$data["description"] && !$data["intro"] && ( $this->catid != 1 && HOME_PAGE_EVENTS != true ) )
- {
- return( false );
- }
- if($showdiv==1)
- {
- $output .= '<div id="category">
- ';
- }
- if( $this->catid == 1 && HOME_PAGE_EVENTS )
- {
- $output .= $this->get_home_events();
- }
- if($data["image"] || $data["description"] || $data["intro"] )
- {
- if($showimg == 1)
- {
- $output .=$data["image"]." ";
- }
- $output .=$data["intro"]." ";
- $output .=$data["description"]." ";
- }
- if($showdiv==1)
- {
- $output .= '</div>
- ';
- }
- $output = GLM_TEMPLATE::clean_text($output);
- return( $output );
-
- }
-
- /**
- * photo_module
- * Load the photo gallery into page
- *
- * @access public
- * @return string
- */
- function photo_module()
- {
- $query = "select photocat_id from photo_category_bus where buscat_id = $this->catid;";
- if( $pData = $this->DB->db_auto_get_data( $query ) )
- {
- if( count( $pData ) > 1 )
- {
- foreach( $pData as $pKey => $pVal )
- {
- $photocatid[] = $pVal['photocat_id'];
- }
- }
- else
- {
- $photocatid = $pData[0]['photocat_id'];
- }
- if( is_numeric( $photocatid ) || is_array( $photocatid ) )
- {
- if( !$_GET['photo_catid'] )
- {
- $_GET['photo_catid'] = $photocatid;
- }
- ob_start();
- include_once(BASE.'static/photo.php');
- $out .= ob_get_contents();
- ob_end_clean();
- }
- }
- return( $out );
- }
-
- /**
- * get_page: replacing template_parser with get_page function
- *
- * @uses GLM_TEMPLATE::get_category() For building the main page section
- * @uses GLM_TEMPLATE::get_listings() For building out the paragraph sections
- *
- * @return string $out NEED to echo results of this function
- * @access public
- **/
- function get_page( $showimg = 1,$showdiv=1 )
- {
- if( $this->page_status != 'Good' )
- {
- return('<h1>Sorry this page is temporary Taken Down!</h1>');
- }
- if( GOOGLE_SEARCH && ( $_POST['Query'] || $_GET['Query'] ) ) // for the gogle search engine api
- { // if Query is sent display search results
- ini_set('include_path', BASE.'google' . ':' .ini_get('include_path'));
- ob_start();
- include_once(GOOGLE."search.php");
- include_once(GOOGLE."results.php");
-
- echo SearchResults();
- $out = '<div id="toolbox">'.ob_get_contents().'</div>';
- ob_end_clean();
- }
- elseif(MEMBERS_DB && $this->Member->member_sections[$this->catid] )
- {
- if( !$_GET['id'] )
- {
- $out .= '<div id="toolbox">'.$this->get_category( $showimg,$showdiv );
- $out .= $this->get_listings().'</div>';
- }
- ob_start();
- $out .= $this->Member->get_list();
- $out .= ob_get_contents();
- ob_end_clean();
- }
- else
- {
- $out .= '<div id="toolbox">'.$this->get_category( $showimg,$showdiv );
- $out .= $this->get_listings().'</div>';
- if( PHOTO_GALLERY )
- {
- $out .= $this->photo_module();
- }
- }
- return( $out );
- }
-
- /**
- * get_template: get the template type of the bus_category
- * @param mixed $type : 'cat' or 'list'
- *
- * @uses GLM_DB::db_auto_get_data()
- * @uses GLM_TEMLATE::img_align()
- * @uses GLM_TEMLATE::img_alternate()
- * @uses GLM_TEMLATE::$template
- *
- * @return void
- * @access public
- **/
- function get_template( $type )
- {
- $query = "select template from bus_category where id = ".$this->catid;
- $data = $this->DB->db_auto_get_data( $query );
- switch( $type )
- {
- case "cat":
- switch( $data[0]['template'] )
- {
- case "5":
- case "4":
- case "2":
- $this->img_align = "left";
- break;
-
- default:
- $this->img_align = "right";
- break;
- }
- break;
-
- case "list":
- switch( $data[0]['template'] )
- {
- case "6":
- case "2":
- $this->img_align = "left";
- $this->img_alternate = 0;
- break;
-
- case "5":
- case "1":
- $this->img_align = "right";
- $this->img_alternate = 0;
- break;
-
- case "4":
- $this->img_align = "right";
- $this->img_alternate = 1;
- break;
-
- case "3":
- $this->img_align = "left";
- $this->img_alternate = 1;
- break;
-
- default:
- break;
- }
- break;
- }
- return( $this->template = $data[0]['template'] );
- }
- /**
- * template_parser:This function creates data
- * and items arrays and does the output for the page.
- *
- * @uses DELUXE_TOOLBOX
- * @uses GLM_TEMPLATE::$items
- * @uses GLM_TEMPLATE::get_template()
- * @uses GLM_TEMPLATE::get_all()
- * @uses GLM_TEMPLATE::load_static_page()
- * @uses GLM_TEMPLATE::clean_text()
- * @uses GLM_TEMPLATE::$item_files
- *
- * @return void
- * @access public
- **/
- function get_listings()
- {
- // grab category and items into data and items respectfully
- if( DELUXE_TOOLBOX )
- {
- $this->get_template( "list" );
- }
-
- if( !is_array( $this->items ) )
- {
- $this->get_all( 2 );
- }
-
- // load any static category page from the static directory
- // hard codded content would have $catid.phtml page for it
- $output .= $this->load_static_page();
- switch($this->type)
- {
-
- default:
- if(is_array($this->items))
- {
- foreach($this->items as $key=>$val)
- {
- //$output .= '<div class="clearer"></div>';
- // items can be moved around as needed
- $output .= '<div class="listing">'."\n";
- $output .= $val["image"];
- $output .= $val["name"];
- $output .= $val["address"];
- $output .= $val["description"];
- $output .= $val["contactname"];
- $output .= $val["email"];
- $output .= $val["phone"];
- $output .= $val["fax"];
- $output .= $val["url"];
- if( is_array( $this->item_files[$val['id']] ) )
- {
- $output .= implode("",$this->item_files[$val['id']]);
- }
- $output .= "</div>"."\n";
- }
- }
- break;
- }
- $output = GLM_TEMPLATE::clean_text($output);
- return( $output );
- }
-
- /**
- * sub_nav:Create a sub navigation 4 across
- *
- * @param integer $catid: The catid for the page
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function sub_nav($catid)
- {
- //$catid = $this->get_top_parent($catid);
- $query1 = "SELECT category FROM bus_category WHERE id = $catid";
- $data1 = $this->DB->db_auto_get_data( $query1 );
- $out = '<div id="nav-sub">
- <h3>'.htmlentities( strip_tags( $data1[0]['category'] ) ,ENT_QUOTES,'UTF-8').'</h3>';
-
- $query = "SELECT id,category,intro FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";
- $data = $this->DB->db_auto_get_data($query);
- if(is_array($data))
- {
- $counter = 1;
- foreach($data as $key=>$val)
- {
- $url = $this->get_seo_url( $val['id'] );
- $title = strip_tags(addslashes($val['intro']));
- //GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_Name( $val['id'],"bus_category",$this->DB ) );
- $out .= '<a title="'.$title.'" href="'.$url.'">';
- $out .= $val["category"];
- $out .= '</a><br>';
- }
- }
- $out .= '</div>';
- return( $out );
- }
-
- /**
- * get_home_events: get events flaged as home events
- * @param object $DB: DB reference to DB obj
- *
- * @uses GLM_TEMPLATE::get_event_date()
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function get_home_events()
- {
- $query = "select id,header,descr,bdate,edate,img from event where home = 't' and visable='t' and edate >= current_date;";
- $data = $this->DB->db_auto_get_data($query);
- if(is_array($data))
- {
- $output = '<div id="events">UPCOMING EVENTS<div id="eventsbox">
- ';
- foreach($data as $key=>$value)
- {
- $id = $value['id'];
- $header = $value['header'];
- $title = strip_tags(addslashes($header));
- $descr = substr( strip_tags( addslashes( $value['descr'] ) ), 0, 50 );
- $sdate = strtotime($value['bdate']);
- $edate = strtotime($value['edate']);
- $dates = GLM_TEMPLATE::get_event_date($sdate,$edate,"timestamp");
- $output .= $dates;
- $output .= '<h3><a title="" href="events.phtml?eventid='.$id.'">'.$header.'</a></h3>';
- }
- $output .= '</div></div>';
- return($output);
- }
- else
- {
- return( '' );
- }
- }
-
- /**
- * get_event_date: make the event date human readable
- * @param string $sdate: start date
- * @param string $edate: end date
- * @param string $dateType: dateType Postgres,etc
- *
- * @return string
- * @access public
- **/
- function get_event_date($sdate,$edate,$dateType)
- {
- switch($dateType)
- {
- case "Postgres":
- if(preg_match("/([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})/",$sdate,$spt))
- {
- $mon = $spt[1];
- $day = $spt[2];
- $yr = $spt[3];
- }
-
- if(preg_match("/([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})/",$edate,$ept))
- {
- $mon2 = $ept[1];
- $day2 = $ept[2];
- $yr2 = $ept[3];
- }
- break;
-
- case "timestamp":
- $mon = date("m",$sdate);
- $day = date("d",$sdate);
- $yr = date("Y",$sdate);
- $mon2 = date("m",$edate);
- $day2 = date("d",$edate);
- $yr2 = date("Y",$edate);
- break;
-
- }$start = mktime(0,0,0,$mon,$day,$yr);
- $end = mktime(0,0,0,$mon2,$day2,$yr2);
- if ($day == $day2 && $mon == $mon2 && $yr == $yr2)
- {
- $dateparam = "F jS, Y";
- $date_begin = date($dateparam, $start) ;
- $date_end = "";
- }
- elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2)
- {
- $dateparam1 = "F jS, Y -";
- $dateparam2 = "Y";
- $date_begin = date($dateparam1, $start);
- $date_end = date($dateparam2, $end);
- }
- elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2)
- {
- $dateparam1 = "F jS -";
- $dateparam2 = "jS, Y";
- $date_begin = date($dateparam1, $start);
- $date_end = date($dateparam2, $end);
- }
- elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2)
- {
- $dateparam1 = "F jS, Y -";
- $dateparam2 = "F jS, Y";
- $date_begin = date($dateparam1, $start);
- $date_end = date($dateparam2, $end);
- }
- elseif ($yr == $yr2)
- {
- $dateparam1 = "F jS -";
- $dateparam2 = "F jS, Y";
- $date_begin = date($dateparam1, $start);
- $date_end = date($dateparam2, $end);
- }
- else
- {
- $dateparam1 = "F jS, Y -";
- $dateparam2 = "F jS, Y";
- $date_begin = date($dateparam1, $start);
- $date_end = date($dateparam2, $end);
- }
-
- return($date_begin." ".$date_end);
- }
-
- /**
- * is_sub_id:Check to see if catid is sub of category
- *
- * @param integer $catid: the catid looking at
- * @param integer $category: to see if it is in category
- * @param object $DB: Db object reference
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return bool
- * @access public
- **/
- function is_sub_id($catid,$category,&$DB)
- {
- if( !is_numeric( $catid ) )
- {
- return( false );
- }
- if($category==$catid)
- {
- return(true);
- }
- $query = "select id,parent from bus_category where id = $catid";
- $data = $DB->db_auto_get_data($query);
- $parent = $data[0]['parent'];
- if($parent == 0)
- {
- return(false);
- }
- else
- {
- return( GLM_TEMPLATE::is_sub_id($parent,$category,&$DB) );
- }
- }
-
- /**
- * get_parent: get parent for this category
- *
- * @param integer $catid: id
- * @param object $DB: database obj
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return int $parent
- * @access public
- **/
- function get_parent($catid,&$DB)
- {
- $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos";
- $data = $DB->db_auto_get_data($query);
- return( $data[0]["parent"] );
- }
-
- /**
- * get_sub_nav:
- * @param integer $catid:
- * @param object $DB:
- *
- * @uses GLM_TEMPLATE::get_parent()
- * @uses GLM_TEMPLATE::get_seo_url()
- * @uses GLM_TEMPLATE::is_sub_id()
- * @uses GLM_TEMPLATE::get_sub_nav()
- * @uses GLM_TEMPLATE::has_subs()
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function get_sub_nav($catid,&$DB)
- {
- $parentid = GLM_TEMPLATE::get_parent($catid,&$DB);
- //echo $parentid.'<br>';
- $query = "SELECT id,category,intro FROM bus_category WHERE parent = $parentid ".$this->active_query." ORDER BY pos";
- $data = $DB->db_auto_get_data($query);
- if(is_array($data))
- {
- $output = '<div id="subnav">';
- $counter = 1;
- foreach($data as $key=>$val)
- {
- $url = $this->get_seo_url( $val['id'] );
- $title = strip_tags(addslashes($val['intro']));
- if(GLM_TEMPLATE::is_sub_id($catid,$parentid,&$DB) && (GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) || $val['id'] == $catid) )
- {
- $output .= '<a title="'.$title.'" class="current" href="'.$url.'">';
- }
- else
- {
- $output .= '<a title="'.$title.'" href="'.$url.'">';
- }
- $output .= $val["category"];
- $output .= '</a>';
- if( GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) && GLM_TEMPLATE::has_subs($val['id'],&$DB))
- {
- $output .= GLM_TEMPLATE::get_sub_nav($val["id"],&$DB,$catid);
- }
- }
- $output .= '</div>';
- $output = GLM_TEMPLATE::clean_text($output);
- echo $output;
- }
- return(false);
- }
-
- /**
- * has_subs:
- * @param integer $catid:
- * @param object $DB:
- *
- * @uses GLM_TEMPLATE::$active_query
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function has_subs($catid,&$DB)
- {
- $query = "SELECT id FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";
- $data = $DB->db_auto_get_data($query);
- if(is_array($data))
- {
- return(true);
- }
- else
- {
- return(false);
- }
- }
-
-
- /**
- * get_top_parent:Get the highest level parent id (not 0 )for the category.
- *
- * <p><b>NOTICE:</b> This is ment to get the top level parent not the parent of the id given.</p>
- *
- * @param integer $id: The catid for the page.
- * @param object $DB: obj
- * @uses GLM_TEMPLATE::get_top_parent()
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return int $parent
- * @access public
- **/
- function get_top_parent($id,&$DB)
- {
- if( $id == 0 )
- {
- return( 0 );
- }
- $qs = "select parent from bus_category where id = $id";
- $parentrow = $DB->db_auto_get_data( $qs );
- if($parentrow[0]['parent'] == 0)
- {
- return($id);
- }
- else
- {
- return( GLM_TEMPLATE::get_top_parent($parentrow[0]['parent'],&$DB) );
- }
- }
-
- /**
- * get_main_cats
- *
- * @access public
- * @return string
- */
- function get_main_cats()
- {
- static $main_cats_array;
- if( !is_array( $main_cats_array ) )
- {
- $query = "select id,category from bus_category where parent = 0 order by pos;";
- if( $data = $this->DB->db_auto_get_data( $query ) )
- {
- foreach( $data as $row )
- {
- $main_cats_array[$row['id']] = htmlentities(strip_tags($row['category']),ENT_QUOTES,'UTF-8');
- }
- }
- }
- return( $main_cats_array );
- }
- /**
- * show_catimg:output the category image.
- *
- * @param integer $catid: The catid for the page.
- * @uses GLM_TEMPLATE::MIDSIZED
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function show_catimg($catid)
- {
- $query = "SELECT image FROM bus_category WHERE id = $catid";
- $data = $this->DB->db_auto_get_data($query);
- if($data[0]["image"]!="")
- {
- $img = '<img src="'.MIDSIZED.$data[0]["image"].'" border="0" vspace="30" hspace="0">';
- }
- else
- {
- $img = '<img src="assets/logo_small.gif" width="150" height="85" vspace="0" hspace="0" border="0" alt="Birchwood Construction"><BR>';
- }
- echo $img;
- echo '<BR><img src="assets/clear.gif" height="30" width="1">';
- }
-
-
- /**
- * get_catheader:output the category name.
- *
- * @param integer $catid: The catid for the page
- * @param object $DB: db obj
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function get_catheader($catid,$DB)
- {
- $query = "SELECT category FROM bus_category WHERE id = $catid";
- $data = $DB->db_auto_get_data($query);
- if($data[0]['category']!="")
- {
- $header = strip_tags($data[0]['category']);
- }
- else
- {
- $header = '';
- }
- return( $header );
- }
-
- /**
- * get_catintro: return the category page name.
- *
- * @param integer $catid: The catid for the page
- * @param object $DB: db obj
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function get_catintro($catid)
- {
- $query = "SELECT intro FROM bus_category WHERE id = $catid";
- $data = $this->DB->db_auto_get_data($query);
- if($data[0]['intro']!="")
- {
- $header = strip_tags($data[0]['intro']);
- }
- else
- {
- $header = '';
- }
- return( $header );
- }
-
- /**
- * show_catheader:
- *
- * @param integer $catid:
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function show_catheader($catid)
- {
- $query = "SELECT category FROM bus_category WHERE id = $catid";
- $data = $this->DB->db_auto_get_data($query);
- if($data[0][category]!="")
- {
- $header = $data[0][category];
- }
- else
- {
- $header = ' ';
- }
- echo $header;
- }
-
- /**
- * get_menu_string:get categories for the phplayermenu
- *
- * @uses GLM_TEMPLATE::sort_childs()
- * @uses GLM_TEMPLATE::convert_to_thread()
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function get_menu_string()
- {
- $query = "SELECT id,parent,category FROM bus_category WHERE id != 0 ".$this->active_query." ORDER BY parent,pos";
- $data = $this->DB->db_auto_get_data($query);
- $newdata = GLM_TEMPLATE::sort_childs($data);
- $string = GLM_TEMPLATE::convert_to_thread($newdata,$newdata[0]);
- return($string);
- }
-
-
- /**
- * get_menu_array: like get_menu_string but returns an array
- *
- * @uses GLM_TEMPLATE::sort_childs()
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function get_menu_array()
- {
- $query = "SELECT id,parent,category FROM bus_category WHERE id != 0 ".$this->active_query." ORDER BY parent,pos";
- $data = $this->DB->db_auto_get_data($query);
- $newdata = GLM_TEMPLATE::sort_childs($data);
- return $newdata;
- }
-
- /**
- * sort_childs:
- * @param array $threads:
- *
- * @return string
- * @access public
- **/
- function sort_childs($threads)
- {
- foreach($threads as $var=>$value)
- {
- $childs[$value["parent"]][$value["id"]] = $value;
- }
- return($childs);
- }
-
- /**
- * convert_to_thread:
- *
- * @param array $threads:
- * @param array $thread:
- * @uses GLM_TEMPLATE::$thread_count
- * @uses GLM_TEMPLATE::$whole_thread
- * @uses GLM_TEMPLATE::get_seo_url()
- * @uses GLM_TEMPLATE::convert_to_thread()
- *
- * @return string
- * @access public
- **/
- function convert_to_thread($threads, $thread)
- {
- foreach($thread as $parent=>$value)
- {
- $this->whole_thread .= str_repeat(".",$this->thread_count);
- $this->whole_thread .= "|".htmlentities($value['category'],ENT_QUOTES,'UTF-8');
- $url = $this->get_seo_url( $value['id'] );
- $this->whole_thread .= "|".$url;
- $this->whole_thread .="\n";
- if($threads[$parent])
- {
- $this->thread_count++;
- GLM_TEMPLATE::convert_to_thread($threads, $threads[$parent]);
- }
- }
- $this->thread_count--;
- return $this->whole_thread;
- }
-
-
- /**
- * has_children: return true or false if this category has sub categories under it.
- *
- * @param integer $catid:
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function has_children($catid)
- {
- // returns number of children that $catid has
- $qs="SELECT count(*) FROM bus_category WHERE parent=$catid ".$this->active_query."";
- $row=$this->DB->db_auto_get_data($qs);
- return $row[0]['count'];
- }
-
- /**
- * get_ancestors:get the ancestors for this category
- *
- * @param integer $catid: catid
- * @param integer $count: starting counter
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return array
- * @access public
- **/
- function get_ancestors($catid,$count)
- {
- if( $count == 0 )
- {
- unset( $this->ancestors );
- }
- if($catid)
- {
- $query = "SELECT id,category,parent
- FROM bus_category
- WHERE id = ".$catid."
- ".$this->active_query;
- $res = $this->DB->db_auto_get_data($query);
- $id = $res[0]['id'];
- $parent = $res[0]['parent'];
- $category = $res[0]['category'];
- $this->ancestors[$count]['id'] = $id;
- $this->ancestors[$count]['label'] = $category;
-
- $url = $this->get_seo_url( $id );
- $this->ancestors[$count]['link'] = $url;
- GLM_TEMPLATE::get_ancestors($parent,$count+1,$conn);
-
- return (array_reverse($this->ancestors) );
- }
- }
-
- /**
- * meta_tags: create the meta description content for this page.
- * this is taken from the category description.
- * this should be only done for all but the home page.
- * $meta = ( $catid != 1 ) ? $toolbox->meta_tags() : '';
- *
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function meta_tags()
- {
- $query = "select description from bus_category where id = ".$this->catid;
- $data = $this->DB->db_auto_get_data( $query );
- $description = htmlentities( substr( trim( strip_tags( $data[0]['description'] ) ), 0, 250 ),ENT_QUOTES,'UTF-8' );
- return( $description );
- }
-
- /**
- * title: create the title for the page.
- * this should be only done for all but the home page.
- * $title = ( $catid != 1 ) ? $toolbox->title() : '';
- *
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function title()
- {
- $query = "select category,intro from bus_category where id = ".$this->catid;
- $data = $this->DB->db_auto_get_data( $query );
- if( $data[0]['intro'] )
- {
- $title = strip_tags( $data[0]['intro'] );
- }
- else
- {
- $title = strip_tags( $data[0]['category'] );
- }
- return( htmlentities( $title.' - ',ENT_QUOTES,'UTF-8' ) );
- }
-
- /**
- * get_bottom_nav: generate a top level only bottom navigation for the pages.
- *
- * @param integer $parent=0:
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function get_bottom_nav($parent=0)
- {
- $out = '';
- $query = "select id,category,intro from bus_category where id != 1 and parent = $parent ".$this->active_query." order by pos asc";
- $row = $this->DB->db_auto_get_data( $query );
- $url = $this->get_seo_url( HOME_ID );
- $links[] = '<a href="'.$url.'">Home</a>';
- if( !is_array( $row ) )
- {
- return( false );
- }
- else
- {
- $out .= '<div id="nav-bottom">';
- for( $i=0; $i<sizeof( $row ); $i++)
- {
- $category = htmlentities(strip_tags($row[$i]['category']),ENT_QUOTES,'UTF-8');
- $url = $this->get_seo_url( $row[$i]['id'] );
- $links[] = '<a href="'.$url.'">'.$category."</a>\n";
- }
- if( is_array( $links) )
- {
- $out .= implode(" | ",$links);
- }
- $out .= '</div>';
- return( $out );
- }
- }
-
-
- /**
- * make_ul_menu: create url list of categories
- *
- * @param integer $parent parent to start from
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function make_ul_menu( $parent = 0 )
- {
- $qs = "SELECT id,category,intro FROM bus_category WHERE parent = $parent ".$this->active_query." ORDER BY pos";
- $data = $this->DB->db_auto_get_data($qs);
- if(!is_array($data))
- {
- return( false );
- }
- else
- {
- foreach( $data as $key => $row )
- {
- $url = $this->get_seo_url( $row['id'] );
- $title = strip_tags(addslashes($row['intro']));
- $return.='
- <li><a title="'.htmlentities($title,ENT_QUOTES,'UTF-8').'" href="'.$url.'"';
- if( $this->catid == $row['id'] )
- {
- $return .= ' id="current"';
- }
- $return .= '>'.htmlentities($row['category'],ENT_QUOTES,'UTF-8')."</a>";
- if( $this->has_subs( $row['id'], &$this->DB ) && ( $this->is_sub_id( $this->catid, $row['id'], &$this->DB ) || $this->catid == $row['id'] ) )
- {
- $ret2 = $this->make_ul_menu( $row['id'] );
- $return.=$ret2;
- }
- $return.="
- </li>";
- }
- $main_cats = $this->get_main_cats();
- if( $main_cats[$parent] )
- {
- $return = '<div id="subnav">
- <div id="subnav-header">'.$this->get_catheader( $parent ,&$this->DB ).'</div>
- <ul id="navlist">'.$return.'</ul>
- </div>
- ';
- return( $return );
- }
- else
- {
- $return = '
- <ul>'.$return.'</ul>
- ';
- return( $return );
- }
- }
- }
-
- /**
- * print_ancestors:print out the ancestors
- * @param integer $catid: the id to start at.
- *
- * @return string
- * @access public
- **/
- function print_ancestors($catid)
- {
- return( $this->get_bread_crumbs( $catid ) );
- }
-
- /**
- * get_bread_crumbs
- *
- * @param mixed $catid
- * @access public
- * @return string
- */
- function get_bread_crumbs( $catid )
- {
- $string = $this->get_ancestors( $catid, 0 );
- if(is_array($string))
- {
- $end = count( $string ) - 1;
- for($i=0;$i<$end;$i++)
- {
- $outarray[] = '<a href="'.$string[$i]["link"].'">'.$string[$i]["label"].'</a>';
- }
- $outarray[] = $this->get_catheader( $catid, &$this->DB );
- if( is_array( $outarray ) && count( $outarray ) > 1 )
- {
- $out .= implode( " » ", $outarray );
- }
- if( $out )
- {
- $return = '<div id="breadcrumbs">'.$out.'</div>';
- }
- }
- return( $return );
- }
-
- /**
- * build_picklist:
- * @param string $fieldname:
- * @param array $data:
- * @param mixed $selected:
- * @param string $type = "standard":
- * @param boolean $auto = 0:
- * @param integer $width = NULL :
- *
- * @uses GLM_TOOLBOX::build_picklist()
- *
- * @return string
- * @access public
- **/
- function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
- {
- return( GLM_TOOLBOX::build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL ) );
- }
-
- /**
- * keyword_replace:
- *
- * @param string $string:
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return string
- * @access public
- **/
- function keyword_replace($string)
- {
- //return($string);
- if($search = strstr($string,"{"))
- {
- if(preg_match("/\{([A-Z0-9\&\-\,\'\" ]*)\}/i",$string,$needle))
- {
- if($needle[0] != "")
- {
- $qs = "SELECT id,category
- FROM bus_category
- WHERE trim(keyword) = '".trim($needle[1])."'";
-
- $keyres = $this->DB->db_auto_get_data($qs);
- $parent = $this->get_top_parent($keyres[0]['id'],&$this->DB);
- $url = $this->get_seo_url( $keyres[0]['id'] );
- $replacement = "<a href=\"".$url."\">".htmlspecialchars($keyres[0]['category'])."</a>";
- $string = str_replace($needle[0],$replacement,$string);
- }
- }
- else{
- return($string);
- }
- if($search = strstr($string,"{"))
- return($this->keyword_replace($string));
- }
- return($string);
- }
- /**
- * getIdFromName:
- *
- * @param string $name:
- * @param string $table:
- * @param object $DB:
- * @uses GLM_DB::db_auto_get_data()
- *
- * @deprecated Don't use this! THIS IS A WARNING (this funcion will be gone next time)
- * @return string
- * @access public
- **/
- function get_id_from_name( $name, $table, &$DB)
- {
- if( $name == "" )
- {
- return( 0 );
- }
- if( is_numeric( $name ) )
- {
- return( $name );
- }
- if( preg_match("/(.*)/$/",$name,$tmp) )
- {
- $name = $tmp[1];
- }
- $category = "category";
- if( preg_match("/-([0-9]*)$/",$name,$tmp ) )
- {
- $id = $tmp[1];
- return( $id );
- }
- // should already be returning id at this point
- // putting the _id on the end of all url's as
- // the other way is very inifiecent for the database.
- $name = str_replace( "-"," ",$name );
- $query = "select id from $table where trim(lower(replace(replace(replace(replace(replace(replace($category,'\'',''),'/',''),'-',' '),'#',''),'&',''),'?',''))) = '".trim(strtolower($name))."'";
- $data = $DB->db_auto_get_data( $query );
- if( is_array( $data ) )
- {
- foreach( $data as $key=>$val )
- {
- $catid = $val['id'];
- }
- return( $catid );
- }
- else
- {
- return( 0 );
- }
- }
-
- /**
- * get_base_url: generate the base of the url for the given category id
- * @param integer $id :
- *
- * @return string
- * @access public
- **/
- function get_base_url( $id )
- {
- if( $this->pages[$id] )
- {
- $page = $this->pages[$id];
- }
- else
- {
- $page = $this->pages['default'];
- }
- if( $GLOBALS['GLM_SERVER_ID'] == 'ws1.gaslightmedia.com' && $this->catid == 1 )
- {
- $page = '';
- }
- return( $page );
- }
-
- /**
- * getCategoryName:
- * used mostly for getting category name for search engine friendly url's
- *
- * @param integer $id:
- * @param string $table:
- * @param object &$DB :
- * @uses GLM_DB::db_auto_get_data()
- *
- * @return void
- * @access public
- **/
- function get_category_name( $id, $table,&$DB )
- {
- if( !is_numeric( $id ) )
- {
- return( false );
- }
- if($table == "class_category")
- {
- $category = "name";
- }
- else
- {
- $category = "category";
- }
- $query = "select $category from $table where id = $id";
- $data = $DB->db_auto_get_data( $query );
- if( is_array( $data ) )
- {
-
- $add = '-'.$id;
- if( $data[0]['category'] )
- {
- $category = $data[0]['category'].$add;
- }
- elseif( $data[0]['name'])
- {
- $category = $data[0]['name'].$add;
- }
- else
- {
- $category = $add;
- }
- return( htmlspecialchars($category) );
- }
- }
-
-
- /**
- * setNameUrl:
- * @param string $name :
- *
- * @return string
- * @access public
- **/
- function set_name_url( $name )
- {
- $name = preg_replace("/[\/#&?'\"]|amp;/",strip_tags( strtolower( trim( $name ) ) ) );
-// $name = strtolower( str_replace( " ","-",trim( $name ) ) );
-// $name = str_replace( "/","",$name );
-// $name = str_replace( "#","",$name );
-// $name = str_replace( "&","",$name );
-// $name = str_replace( "amp;","",$name );
-// $name = str_replace( "?","",$name );
-// $name = str_replace( "'","",$name );
- return( htmlspecialchars( $name ) );
- }
-
- /** valid email
- *
- * <p>Checks for a valid format and good (mx check)
- * email address.</p>
- * @deprecated using GLM_TOOLBOX::valid_email()
- * @uses GLM_TOOLBOX::valid_email()
- *
- * @param string email the email address as string.
- * @return boolean
- */
- function valid_email( $email )
- {
- return( GLM_TOOLBOX::valid_email( $email ) );
- }
+ * @return string
+ * @access public
+ **/
+ function get_base_url( $id )
+ {
+ if( $this->pages[$id] )
+ {
+ $page = $this->pages[$id];
+ }
+ else
+ {
+ $page = $this->pages['default'];
+ }
+ if( $GLOBALS['GLM_SERVER_ID'] == 'ws1.gaslightmedia.com' && $this->catid == 1 )
+ {
+ $page = '';
+ }
+ return( $page );
+ }
+
+ /**
+ * getCategoryName:
+ * used mostly for getting category name for search engine friendly url's
+ *
+ * @param integer $id:
+ * @param string $table:
+ * @param object &$DB :
+ * @uses GLM_DB::db_auto_get_data()
+ *
+ * @return void
+ * @access public
+ **/
+ function get_category_name( $id, $table,&$DB )
+ {
+ if( !is_numeric( $id ) )
+ {
+ return( false );
+ }
+ if($table == "class_category")
+ {
+ $category = "name";
+ }
+ else
+ {
+ $category = "category";
+ }
+ $query = "select $category from $table where id = $id";
+ $data = $DB->db_auto_get_data( $query );
+ if( is_array( $data ) )
+ {
+
+ $add = '-'.$id;
+ if( $data[0]['category'] )
+ {
+ $category = $data[0]['category'].$add;
+ }
+ elseif( $data[0]['name'])
+ {
+ $category = $data[0]['name'].$add;
+ }
+ else
+ {
+ $category = $add;
+ }
+ return( htmlspecialchars($category) );
+ }
+ }
+
+
+ /**
+ * setNameUrl:
+ * @param string $name :
+ *
+ * @return string
+ * @access public
+ **/
+ function set_name_url( $name )
+ {
+ $name = preg_replace("/[\/#&?'\"]|amp;/",strip_tags( strtolower( trim( $name ) ) ) );
+// $name = strtolower( str_replace( " ","-",trim( $name ) ) );
+// $name = str_replace( "/","",$name );
+// $name = str_replace( "#","",$name );
+// $name = str_replace( "&","",$name );
+// $name = str_replace( "amp;","",$name );
+// $name = str_replace( "?","",$name );
+// $name = str_replace( "'","",$name );
+ return( htmlspecialchars( $name ) );
+ }
+
+ /** valid email
+ *
+ * <p>Checks for a valid format and good (mx check)
+ * email address.</p>
+ * @deprecated using GLM_TOOLBOX::valid_email()
+ * @uses GLM_TOOLBOX::valid_email()
+ *
+ * @param string email the email address as string.
+ * @return boolean
+ */
+ function valid_email( $email )
+ {
+ return( GLM_TOOLBOX::valid_email( $email ) );
+ }
}
?>