class ipSeoMeta extends skin_global(~id~) { private function retrievePageUrl() { $url = !$_SERVER['HTTPS'] || $_SERVER['HTTPS'] == 'off' ? 'http://' : 'https://'; $url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $url = str_replace( array( $this->settings['board_url'], '/index.php?', '/index.php' ), '', $url ); return $url; } public function globalTemplate( $html, $documentHeadItems, $css, $jsModules, $metaTags, array $header_items, $items=array(), $footer_items=array(), $stats=array()) { /* App disabled? */ if ( ! IPSLib::appIsInstalled('ipseo') ) { return parent::globalTemplate( $html, $documentHeadItems, $css, $jsModules, $metaTags, $header_items, $items, $footer_items, $stats ); } /* Init vars */ $meta = $this->cache->getCache('ipseo_meta'); $newTitle = ''; /* Handle meta tags */ if( is_array($meta) && count($meta) ) { $currentUrl = $this->retrievePageUrl(); foreach( $meta as $page => $tags ) { if( is_array($tags) && count($tags) ) { $match = str_replace('/', '\/', $page); $match = str_replace('-', '\-', $match); $match = str_replace('_', '\_', $match); $match = str_replace('.', '\.', $match); $match = str_replace('*', '(.*)?', $match); if( preg_match('/^' . $match . '$/', $currentUrl ) ) { foreach( $tags as $tag => $val ) { if ( $tag == 'title' ) { $newTitle = $val; } $metaTags[ $tag ] = $val; } } } } } /* Got a new title to replace? */ if ( $newTitle ) { $oldTitle = str_replace( ' - ' . $this->settings['board_name'], '', $header_items['title'] ); $header_items['title'] = str_replace( '{oldTitle}', $oldTitle, $newTitle ); } $rtn = parent::globalTemplate( $html, $documentHeadItems, $css, $jsModules, $metaTags, $header_items, $items, $footer_items, $stats ); /* Gooooogle analytics?! */ if ( ! empty($this->settings['ipseo_ga']) ) { $rtn = str_replace('', $this->settings['ipseo_ga'] . '', $rtn); } /* Live editing meta tags? */ if ( $this->memberData['g_access_cp'] && ! empty($this->memberData['_cache']['ipseo_live_meta_edit']) ) { ipsRegistry::getclass('class_localization')->loadLanguageFile( array( 'public_lang' ), 'ipseo' ); $rtn = str_replace( "", $this->registry->output->getTemplate('ipseo')->metaEditor( $metaTags, $this->retrievePageUrl() ) . "", $rtn ); } //----------------------------------------- // Return //----------------------------------------- return $rtn; } }