array('osCommerce, Open Source E-Commerce Solutions')); /** * Holds javascript filenames to be included in the page * * The javascript files must be plain javascript files without any PHP logic, and are linked to from the page * * @var array * @access private */ var $_javascript_filenames = array('includes/general.js'); /** * Holds javascript PHP filenames to be included in the page * * The javascript PHP filenames can consist of PHP logic to produce valid javascript syntax, and is embedded in the page * * @var array * @access private */ var $_javascript_php_filenames = array(); /** * Holds blocks of javascript syntax to embedd into the page * * Each block must contain its relevant tags * * @var array * @access private */ var $_javascript_blocks = array(); /** * Hold the extra modules to load on the page * * @var array * @access public */ var $_extra_page_modules = array('before' => array(), 'after' => array()); /** * Setup the template class with the requested page module * * @param string $module The default page module to setup * @return object */ function &setup($module) { $group = basename($_SERVER['PHP_SELF']); if (($pos = strrpos($group, '.')) !== false) { $group = substr($group, 0, $pos); } if (empty($_GET) === false) { $first_array = array_slice($_GET, 0, 1); $_module = tep_sanitize_string(basename(key($first_array))); if (file_exists('includes/content/' . $group . '/' . $_module . '.php')) { $module = $_module; } } include('includes/content/' . $group . '/' . $module . '.php'); $_page_module_name = 'osC_' . ucfirst($group) . '_' . ucfirst($module); $object = new $_page_module_name(); return $object; } /** * Returns the template name * * @access public * @return string */ function getTemplate() { return $this->_template; } /** * Returns the page module name * * @access public * @return string */ function getModule() { return $this->_module; } /** * Returns the page group name * * @access public * @return string */ function getGroup() { return $this->_group; } /** * Returns the title of the page * * @access public * @return string */ function getPageTitle() { return $this->_page_title; } /** * Returns the tags of the page separated by a comma * * @access public * @return string */ function getPageTags() { $tag_string = ''; foreach ($this->_page_tags as $key => $values) { $tag_string .= '' . "\n"; } return $tag_string . "\n"; } /** * Return the boxes assigned to the page content * * @param string $group The group name of boxes to include that the template has provided * @return array */ function getPageBoxes($group) { static $osC_Boxes; if (isset($osC_Boxes) === false) { $osC_Boxes = new osC_Boxes(); } return $osC_Boxes->getGroup($group); } /** * Returns the image of the page * * @access public * @return string */ function getPageImage() { return $this->_page_image; } /** * Returns the content filename of the page * * @access public * @return string */ function getPageContentsFilename() { return $this->_page_contents; } /** * Returns the javascript to link from or embedd to on the page * * @access public * @return string */ function getJavascript() { if (!empty($this->_javascript_filenames)) { echo $this->_getJavascriptFilenames(); } if (!empty($this->_javascript_php_filenames)) { $this->_getJavascriptPhpFilenames(); } if (!empty($this->_javascript_blocks)) { echo $this->_getJavascriptBlocks(); } } /** * Checks to see if the page has a title set * * @access public * @return boolean */ function hasPageTitle() { return !empty($this->_page_title); } /** * Checks to see if the page has a meta tag set * * @access public * @return boolean */ function hasPageTags() { return !empty($this->_page_tags); } /** * Checks to see if the page has javascript to link to or embedd from * * @access public * @return boolean */ function hasJavascript() { return (!empty($this->_javascript_filenames) || !empty($this->_javascript_php_filenames) || !empty($this->_javascript_blocks)); } /** * Sets the name of the template to use * * @param string $template The name of the template to set * @access public */ function setTemplate($template) { $this->_template = $template; } /** * Sets the title of the page * * @param string $title The title of the page to set to * @access public */ function setPageTitle($title) { $this->_page_title = $title; } /** * Sets the image of the page * * @param string $image The image of the page to set to * @access public */ function setPageImage($image) { $this->_page_image = $image; } /** * Sets the content of the page * * @param string $filename The content filename to include on the page * @access public */ function setPageContentsFilename($filename) { $this->_page_contents_filename = $filename; } /** * Adds a tag to the meta keywords array * * @param string $key The keyword for the meta tag * @param string $value The value for the meta tag using the key * @access public */ function addPageTags($key, $value) { $this->_page_tags[$key][] = $value; } /** * Adds a javascript file to link to * * @param string $filename The javascript filename to link to * @access public */ function addJavascriptFilename($filename) { $this->_javascript_filenames[] = $filename; } /** * Adds a PHP based javascript file to embedd on the page * * @param string $filename The PHP based javascript filename to embedd * @access public */ function addJavascriptPhpFilename($filename) { $this->_javascript_php_filenames[] = $filename; } /** * Adds javascript logic to the page * * @param string $javascript The javascript block to add on the page * @access public */ function addJavascriptBlock($javascript) { $this->_javascript_blocks[] = $javascript; } /** * Adds an extra module to load on the page, either before or after the page content * * @param object $class The class instance to initialize the extra module * @param string $location Load the extra module "before" or "after" the page content * @access public */ function addContentModule($class, $location = 'before') { if (isset($GLOBALS[$class])) { $GLOBALS[$class]->contentModuleInitialize(); $this->_extra_page_modules[$location][] = $GLOBALS[$class]->getContentModule(); } elseif (isset($_SESSION[$class])) { $_SESSION[$class]->contentModuleInitialize(); $this->_extra_page_modules[$location][] = $_SESSION[$class]->getContentModule(); } } /** * Returns the javascript filenames to link to on the page * * @access private * @return string */ function _getJavascriptFilenames() { $js_files = ''; foreach ($this->_javascript_filenames as $filenames) { $js_files .= '' . "\n"; } return $js_files; } /** * Returns the PHP javascript files to embedd on the page * * @access private */ function _getJavascriptPhpFilenames() { foreach ($this->_javascript_php_filenames as $filenames) { include($filenames); } } /** * Returns javascript blocks to add to the page * * @access private * @return string */ function _getJavascriptBlocks() { return implode("\n", $this->_javascript_blocks); } } ?>