Annotation of /mambo/branches/4.6/includes/frontend.php
Parent Directory
|
Revision Log
Revision 3 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: frontend.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 11 : | /** | ||
| 12 : | * Displays the capture output of the main element | ||
| 13 : | */ | ||
| 14 : | function mosMainBody() { | ||
| 15 : | // message passed via the url | ||
| 16 : | $mosmsg = mosGetParam( $_REQUEST, 'mosmsg', '' ); | ||
| 17 : | if (!get_magic_quotes_gpc()) { | ||
| 18 : | $mosmsg = addslashes( $mosmsg ); | ||
| 19 : | } | ||
| 20 : | |||
| 21 : | $popMessages = false; | ||
| 22 : | |||
| 23 : | if ($mosmsg && !$popMessages) { | ||
| 24 : | echo "\n<div class=\"message\">$mosmsg</div>"; | ||
| 25 : | } | ||
| 26 : | |||
| 27 : | echo $GLOBALS['_MOS_OPTION']['buffer']; | ||
| 28 : | |||
| 29 : | if ($mosmsg && $popMessages) { | ||
| 30 : | echo "\n<script language=\"javascript\">alert('$mosmsg');</script>"; | ||
| 31 : | } | ||
| 32 : | } | ||
| 33 : | /** | ||
| 34 : | * Utility functions and classes | ||
| 35 : | */ | ||
| 36 : | function mosLoadComponent( $name ) { | ||
| 37 : | // set up some global variables for use by the frontend component | ||
| 38 : | global $mainframe, $database; | ||
| 39 : | include( $mainframe->getCfg( 'absolute_path' )."/components/com_$name/$name.php" ); | ||
| 40 : | } | ||
| 41 : | /** | ||
| 42 : | * Cache some modules information | ||
| 43 : | * @return array | ||
| 44 : | */ | ||
| 45 : | function &initModules() { | ||
| 46 : | global $database, $my, $Itemid; | ||
| 47 : | |||
| 48 : | if (!isset( $GLOBALS['_MOS_MODULES'] )) { | ||
| 49 : | $query = "SELECT id, title, module, position, content, showtitle, params" | ||
| 50 : | ."\nFROM #__modules AS m, #__modules_menu AS mm" | ||
| 51 : | . "\nWHERE m.published='1' AND m.access <= '$my->gid' AND m.client_id='0'" | ||
| 52 : | . "\nAND mm.moduleid=m.id" | ||
| 53 : | . "\nAND (mm.menuid = '$Itemid' OR mm.menuid = '0')" | ||
| 54 : | . "\nORDER BY ordering"; | ||
| 55 : | |||
| 56 : | $database->setQuery( $query ); | ||
| 57 : | $modules = $database->loadObjectList(); | ||
| 58 : | foreach ($modules as $module) { | ||
| 59 : | $GLOBALS['_MOS_MODULES'][$module->position][] = $module; | ||
| 60 : | } | ||
| 61 : | } | ||
| 62 : | return $GLOBALS['_MOS_MODULES']; | ||
| 63 : | } | ||
| 64 : | /** | ||
| 65 : | * @param string THe template position | ||
| 66 : | */ | ||
| 67 : | function mosCountModules( $position='left' ) { | ||
| 68 : | global $database, $my, $Itemid; | ||
| 69 : | $modules =& initModules(); | ||
| 70 : | if (isset( $GLOBALS['_MOS_MODULES'][$position] )) { | ||
| 71 : | return count( $GLOBALS['_MOS_MODULES'][$position] ); | ||
| 72 : | } else { | ||
| 73 : | return 0; | ||
| 74 : | } | ||
| 75 : | } | ||
| 76 : | /** | ||
| 77 : | * @param string The position | ||
| 78 : | * @param int The style. 0=normal, 1=horiz, -1=no wrapper | ||
| 79 : | */ | ||
| 80 : | function mosLoadModules( $position='left', $style=0 ) { | ||
| 81 : | global $mosConfig_gzip, $mosConfig_absolute_path, $database, $my, $Itemid, $mosConfig_caching; | ||
| 82 : | |||
| 83 : | $tp = mosGetParam( $_GET, 'tp', 0 ); | ||
| 84 : | if ($tp) { | ||
| 85 : | echo '<div style="height:50px;background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">'; | ||
| 86 : | echo $position; | ||
| 87 : | echo '</div>'; | ||
| 88 : | return; | ||
| 89 : | } | ||
| 90 : | $style = intval( $style ); | ||
| 91 : | $cache =& mosCache::getCache( 'com_content' ); | ||
| 92 : | |||
| 93 : | require_once( $mosConfig_absolute_path . '/includes/frontend.html.php' ); | ||
| 94 : | |||
| 95 : | $allModules =& initModules(); | ||
| 96 : | if (isset( $GLOBALS['_MOS_MODULES'][$position] )) { | ||
| 97 : | $modules = $GLOBALS['_MOS_MODULES'][$position]; | ||
| 98 : | } else { | ||
| 99 : | $modules = array(); | ||
| 100 : | } | ||
| 101 : | |||
| 102 : | if (count( $modules ) < 1) { | ||
| 103 : | $style = 0; | ||
| 104 : | } | ||
| 105 : | if ($style == 1) { | ||
| 106 : | echo "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | ||
| 107 : | echo "<tr>\n"; | ||
| 108 : | } | ||
| 109 : | $prepend = ($style == 1) ? "<td valign=\"top\">\n" : ''; | ||
| 110 : | $postpend = ($style == 1) ? "</td>\n" : ''; | ||
| 111 : | |||
| 112 : | $count = 1; | ||
| 113 : | foreach ($modules as $module) { | ||
| 114 : | $params =& new mosParameters( $module->params ); | ||
| 115 : | |||
| 116 : | echo $prepend; | ||
| 117 : | |||
| 118 : | if ((substr("$module->module",0,4))=="mod_") { | ||
| 119 : | if ($params->get('cache') == 1 && $mosConfig_caching == 1) { | ||
| 120 : | $cache->call('modules_html::module2', $module, $params, $Itemid, $style ); | ||
| 121 : | } else { | ||
| 122 : | modules_html::module2( $module, $params, $Itemid, $style, $count ); | ||
| 123 : | } | ||
| 124 : | } else { | ||
| 125 : | if ($params->get('cache') == 1 && $mosConfig_caching == 1) { | ||
| 126 : | $cache->call('modules_html::module', $module, $params, $Itemid, $style ); | ||
| 127 : | } else { | ||
| 128 : | modules_html::module( $module, $params, $Itemid, $style ); | ||
| 129 : | } | ||
| 130 : | } | ||
| 131 : | |||
| 132 : | echo $postpend; | ||
| 133 : | $count++; | ||
| 134 : | } | ||
| 135 : | if ($style == 1) { | ||
| 136 : | echo "</tr>\n</table>\n"; | ||
| 137 : | } | ||
| 138 : | } | ||
| 139 : | /** | ||
| 140 : | * Assembles head tags | ||
| 141 : | */ | ||
| 142 : | function mosShowHead() { | ||
| 143 : | global $database, $option, $my, $mainframe, $_VERSION; | ||
| 144 : | global $mosConfig_MetaDesc, $mosConfig_MetaKeys, $mosConfig_live_site, $mosConfig_sef, $mosConfig_absolute_path, $mosConfig_sitename, $mosConfig_favicon; | ||
| 145 : | |||
| 146 : | $task = mosGetParam( $_REQUEST, 'task', '' ); | ||
| 147 : | |||
| 148 : | $mainframe->appendMetaTag( 'description', $mosConfig_MetaDesc ); | ||
| 149 : | $mainframe->appendMetaTag( 'keywords', $mosConfig_MetaKeys ); | ||
| 150 : | $mainframe->addMetaTag( 'Generator', $_VERSION->PRODUCT . " - " . $_VERSION->COPYRIGHT); | ||
| 151 : | $mainframe->addMetaTag( 'robots', 'index, follow' ); | ||
| 152 : | |||
| 153 : | echo $mainframe->getHead(); | ||
| 154 : | |||
| 155 : | if ( isset($mosConfig_sef) && $mosConfig_sef ) { | ||
| 156 : | echo "<base href=\"$mosConfig_live_site/\" />\r\n"; | ||
| 157 : | } | ||
| 158 : | |||
| 159 : | if ( $my->id ) { | ||
| 160 : | ?> | ||
| 161 : | <script language="JavaScript1.2" src="<?php echo $mosConfig_live_site;?>/includes/js/mambojavascript.js" type="text/javascript"></script> | ||
| 162 : | <?php | ||
| 163 : | } | ||
| 164 : | |||
| 165 : | // support for Firefox Live Bookmarks ability for site syndication | ||
| 166 : | $query = "SELECT a.id" | ||
| 167 : | . "\n FROM #__components AS a" | ||
| 168 : | . "\n WHERE a.name = 'Syndicate'" | ||
| 169 : | ; | ||
| 170 : | $database->setQuery( $query ); | ||
| 171 : | $id = $database->loadResult(); | ||
| 172 : | |||
| 173 : | // load the row from the db table | ||
| 174 : | $row = new mosComponent( $database ); | ||
| 175 : | $row->load( $id ); | ||
| 176 : | |||
| 177 : | // get params definitions | ||
| 178 : | $params =& new mosParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' ); | ||
| 179 : | |||
| 180 : | $live_bookmark = $params->get( 'live_bookmark', 0 ); | ||
| 181 : | |||
| 182 : | if ( $live_bookmark ) { | ||
| 183 : | // custom bookmark file name | ||
| 184 : | $bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); | ||
| 185 : | |||
| 186 : | $link_file = $mosConfig_live_site .'/cache/'. $bookmark_file; | ||
| 187 : | $filename = $mosConfig_absolute_path .'/cache/'. $bookmark_file; | ||
| 188 : | |||
| 189 : | $cache = $params->get( 'cache', 1 ); | ||
| 190 : | $cache_time = $params->get( 'cache_time', 3600 ); | ||
| 191 : | $title = $params->def( 'title', $mosConfig_sitename ); | ||
| 192 : | |||
| 193 : | // checks to see if cache file exists, to determine whether to create a new one | ||
| 194 : | if ( !file_exists( $filename ) || ( ( time() - filemtime( $filename ) ) > $cache_time ) ) { | ||
| 195 : | $tempTask = $task; | ||
| 196 : | $task = 'live_bookmark'; | ||
| 197 : | |||
| 198 : | // sets bookmark feed type | ||
| 199 : | $_GET['feed'] = str_replace( '.xml', '', $live_bookmark ); | ||
| 200 : | |||
| 201 : | // loads rss component to create bookmark file | ||
| 202 : | require_once( $mosConfig_absolute_path .'/components/com_rss/rss.php' ); | ||
| 203 : | $task = $tempTask; | ||
| 204 : | } | ||
| 205 : | |||
| 206 : | // outputs link tag for page | ||
| 207 : | ?> | ||
| 208 : | <link rel="alternate" type="application/rss+xml" title="<?php echo $title; ?>" href="<?php echo $link_file; ?>" /> | ||
| 209 : | <?php | ||
| 210 : | } | ||
| 211 : | |||
| 212 : | // favourites icon | ||
| 213 : | if ( !$mosConfig_favicon ) { | ||
| 214 : | $mosConfig_favicon = 'favicon.ico'; | ||
| 215 : | } | ||
| 216 : | $icon = $mosConfig_absolute_path .'/images/'. $mosConfig_favicon; | ||
| 217 : | // checks to see if file exists | ||
| 218 : | if ( !file_exists( $icon ) ) { | ||
| 219 : | $icon = $mosConfig_live_site .'/images/favicon.ico'; | ||
| 220 : | } else { | ||
| 221 : | $icon = $mosConfig_live_site .'/images/' .$mosConfig_favicon; | ||
| 222 : | } | ||
| 223 : | |||
| 224 : | // outputs link tag for page | ||
| 225 : | ?> | ||
| 226 : | <link rel="shortcut icon" href="<?php echo $icon;?>" /> | ||
| 227 : | <?php | ||
| 228 : | } | ||
| 229 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

