Project

General

Profile

Bug #3282 » 3282.patch

krileon, 17 February 2012 19:09

View differences:

administrator/components/com_comprofiler/plugin.foundation.php
$this->_renderCheckOutput();
// }
}
/**
* Adds custom $html into <head> portion before all other headers are loaded
*
* @param string $html
*/
function addPreHeadCustomHtml( $html ) {
$this->_head['preHeader'][] = $html;
$this->_renderCheckOutput();
}
/**
* Adds custom $html into <head> portion after all other headers are loaded
*
* @param string $html
*/
function addPostHeadCustomHtml( $html ) {
$this->_head['postHeader'][] = $html;
$this->_renderCheckOutput();
}
/**
* Returns direction 'ltr' or 'rtl' for global document
*
......
}
}
function _renderingInit() {
$this->_head = array( 'metaTags' => array(), 'linksCustom' => array(), 'stylesheets' => array(), 'styles' => array(), 'scriptsUrl' => array(), 'scripts' => array(), 'custom' => array() );
$this->_head = array( 'metaTags' => array(), 'linksCustom' => array(), 'stylesheets' => array(), 'styles' => array(), 'scriptsUrl' => array(), 'scripts' => array(), 'custom' => array(), 'preHeader' => array(), 'postHeader' => array() );
}
/**
* Renders the portion going into the <head> if CMS doesn't support correct ordering
......
function _renderHead( ) {
$html = null;
if ( $this->_output == 'html' ) {
// if there are pre header things:
foreach ( $this->_head['preHeader'] as $preheader ) {
$html[] = $preheader;
}
if ( $this->_cmsDoc === null ) {
// <base> is done outside
// metaTags:
......
foreach ( $this->_head['custom'] as $custom ) {
$html[] = $custom;
}
// if there are post header things:
foreach ( $this->_head['postHeader'] as $postheader ) {
$html[] = $postheader;
}
}
// reset the headers, in case we get late callers from outside the component (modules):
$this->_renderingInit();
......
// JHtml::_('behavior.jquery', '1.6.7', 'components/com_comprofiler/js/../js/jquery-' . _CB_JQUERY_VERSION . '/', array( 'jquery.autogrow', 'jquery.colorinput', 'jquery.jmap'), '$("p").css("color","red") ;');
} else {
*/
static $cbjqueryloaded = false;
if ( ! defined( 'J_JQUERY_LOADED' ) ) {
$this->document->addHeadScriptUrl( '/components/com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/jquery-' . _CB_JQUERY_VERSION . '.js', true, null, 'jQuery.noConflict();' );
// Store previous defines if present so they can be restored later:
$preJquery = "if ( typeof $ != 'undefined' ) { var \$OLD = $; } if ( typeof jQuery != 'undefined' ) { var jQueryOLD = jQuery; }";
// Pre head is used because it loads first before all other CB header content:
$this->document->addPreHeadCustomHtml( '<script type="text/javascript">' . $preJquery . '</script>' );
// Define CBs deep no conflict and redefine jquery variables for usage inside of CB plugins and jquery scripts:
$postJquery = "var cbjQuery = jQuery.noConflict( true ); var $ = cbjQuery; var jQuery = cbjQuery;";
$this->document->addHeadScriptUrl( '/components/com_comprofiler/js/jquery-' . _CB_JQUERY_VERSION . '/jquery-' . _CB_JQUERY_VERSION . '.js', true, null, $postJquery );
define( 'J_JQUERY_LOADED', 1 );
$cbjqueryloaded = true;
}
// Lets restore the jquery selector if cbs jquery was never used:
if ( ! $cbjqueryloaded ) {
static $cbjqueryrestore = 0;
// Check if we've already restored CBs jquery selector to normal jquery selector:
if ( ! $cbjqueryrestore++ ) {
// Reroute cbjQuery to jQuery if CB jquery loading is disabled:
$this->document->addPreHeadCustomHtml( '<script type="text/javascript">var cbjQuery = jQuery;</script>' );
}
}
foreach ( $this->_jQueryPlugins as $plugin => $pluginPath ) {
if ( ! isset( $this->_jQueryPluginsSent[$plugin] ) ) {
$this->document->addHeadScriptUrl( $pluginPath, true, null, null, ( $plugin == 'excanvas' ? '<!--[if lte IE 8]>' : '' ), ( $plugin == 'excanvas' ? '<![endif]-->' : '' ) );
......
*/
$jQcodes = trim( implode( "\n", $this->_jQueryCodes ) );
if ( $jQcodes !== '' ) {
$jsCodeTxt = 'jQuery(document).ready(function($){' . "\n"
. $jQcodes
. "});"
;
$jsCodeTxt = "cbjQuery( document ).ready( function( $ ) {"
. "\n"
. "var jQuery = $;" // lets ensure plugins using jQuery inline are getting cbs jquery object (for late loaded jquery)
. "\n"
. $jQcodes
. "\n"
. "});";
$this->document->addHeadScriptDeclaration( $jsCodeTxt );
}
$this->_jQueryCodes = array();
// Check if CBs actual jquery was loaded as it's a define so it can be disabled externally:
if ( $cbjqueryloaded ) {
static $cbjqueryrevert = 0;
// Check if we've already reverted jquerys selectors:
if ( ! $cbjqueryrevert++ ) {
// Revert the jQuery defines to their previous values if they were defined; otherwise keep CBs:
$revertJquery = "if ( typeof \$OLD != 'undefined' ) { var $ = \$OLD; } if ( typeof jQueryOLD != 'undefined' ) { var jQuery = jQueryOLD; }";
// Post head is used because it loads last after all other CB header content
// This won't fix jquery that's loaded in late, but that's ok as we're just fixing jquery plugins loaded in that are using jQuery and $:
$this->document->addPostHeadCustomHtml( '<script type="text/javascript">' . $revertJquery . '</script>' );
}
}
/*
}
*/
(1-1/3)