* @link http://www.nonumber.nl * @copyright Copyright (C) 2010 NoNumber! All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // Ensure this file is being included by a parent file defined( '_JEXEC' ) or die( 'Restricted access' ); /** * Title Element * * Available extra parameters: * title The title * description The description * message_type none, message, notice, error? * image Image (and path) to show on the right * show_apply Show an apply tick image on the right (only if the image is not set) * url The main url * download_url The url of the download location * help_url The url of the help page * version_url The url to the new version folder (default = [url]/versions/) * version_path The path to version folder * version_file The filename of the current version file */ class JElementTitle extends JElement { /** * Element name * * @access protected * @var string */ var $_name = 'Title'; function fetchTooltip( $label, $description, &$node, $control_name, $name ) { $nostyle = $node->attributes( 'nostyle' ); if ( $nostyle ) { return JElement::fetchTooltip( $label, '', $node, $control_name, $name ); } return; } function fetchElement( $name, $value, &$node, $control_name ) { $start = $node->attributes( 'start' ); $end = $node->attributes( 'end' ); $blocktype = $node->attributes( 'blocktype' ); if ( $end ) { $html = ''; if ( $blocktype == 'fieldset' ) { $html .= ''; } $random = rand( 1000, 10000 ); $html .= '
'; $html .= ''; return $html; } $title = $node->attributes( 'label' ); $description = $node->attributes( 'description' ); $lang_folder = $node->attributes( 'language_folder' ); $message_type = $node->attributes( 'message_type' ); $image = $node->attributes( 'image' ); $image_w = $node->attributes( 'image_w' ); $image_h = $node->attributes( 'image_h' ); $show_apply = $node->attributes( 'show_apply' ); $nostyle = $node->attributes( 'nostyle' ); $toggle = $node->attributes( 'toggle' ); $file_root = str_replace( '\\', '/', str_replace( JPATH_SITE, '', dirname( __FILE__ ) ) ); $document =& JFactory::getDocument(); $document->addScript( JURI::root(true).$file_root.'/title.js' ); if ( $nostyle ) { return JText::_( $description ); } // The main url $url = $node->attributes( 'url' ); $download = $node->attributes( 'download_url' ); $help = $node->attributes( 'help_url' ); $version = $node->attributes( 'version' ); $version_url = $this->def( $node->attributes( 'version_url' ), $url.'/versions/' ); $version_file = $node->attributes( 'version_file' ); $msg = ''; if ( $lang_folder ) { // Include extra language file $lang = JFactory::getLanguage(); $lang = str_replace( '_', '-', $lang->_lang ); if ( strpos( $lang_folder, '/administrator' ) === 0 ) { $lang_folder = str_replace( '/', DS, str_replace( '/administrator', JPATH_ADMINISTRATOR, $lang_folder ) ); } else { $lang_folder = JPATH_SITE.str_replace( '/', DS, $lang_folder ); } $lang_file = 'en-GB.inc.php'; if ( file_exists( $lang_folder.DS.$lang_file ) ) { include $lang_folder.DS.$lang_file; } if ( $lang != 'en-GB' ) { $lang_file = $lang.'.inc.php'; if ( !file_exists( $lang_folder.DS.$lang_file ) ) { $include_file = 'en-GB.inc.php'; } if ( file_exists( $lang_folder.DS.$lang_file ) ) { include $lang_folder.DS.$lang_file; } } } if ( $title ) { $title = JText::_( $title ); } $user = JFactory::getUser(); if( strlen( $version ) && strlen( $version_file ) && ( $user->usertype == 'Super Administrator' || $user->usertype == 'Administrator' ) ) { // Import library dependencies require_once dirname( __FILE__ ).DS.'version_check.php'; $msg = NoNumberVersionCheck::setMessage( $version, $version_file, $version_url, $download ); if ( $version ) { if ( $title ) { $title .= ' v'.$version; } else { $title = JText::_( 'Version' ).' '.$version; } } } if ( $url ) { $url = ''; } if ( $image ) { $image = str_replace( '/', "\n", str_replace( '\\', '/', $image ) ); $image = explode( "\n", trim( $image ) ); if ( $image['0'] == 'administrator' ) { $image['0'] = JURI::base(true); } else { $image['0'] = JURI::root(true).'/'.$image['0']; } $image = $url.'
';
$html .= $apply_button;
}
if ( $toggle && $description ) {
$el = 'document.getElementById( \''.$control_name.$name.'description\' )';
$onclick =
'if( this.innerHTML == \''.JText::_( JText::_( 'Show' ).' '.$title ).'\' ){'
.$el.'.style.display = \'block\';'
.'this.innerHTML = \''.JText::_( JText::_( 'Hide' ).' '.$title ).'\';'
.'}else{'
.$el.'.style.display = \'none\';'
.'this.innerHTML = \''.JText::_( JText::_( 'Show' ).' '.$title ).'\';'
.'}'
.'this.blur();return false;'
;
$html .= ''."\n";
$html .= '