Issues

ZF-6078: Auto-switch http/https scheme for Google Ajax Libraries URLs

Description

Hello,

It would be nice if depending on whether current page was requested via secured connection or unsecured, the helpers would return secured/unsecured URLs appropriately. Why this is important:

Suppose I have a secured page https://domain.com/test All images/asset files are served via HTTPS. However, the helpers output:

Causing some browsers to show security dialogs that not all content is secured.

Comments

very good request, i wasn't thinking about this issue. I'll implement it.

I made the following addition to my ZendX library.

ZendX\Jquery.php removed line: 37 const CDN_BASE_GOOGLE = 'http://ajax.googleapis.com/ajax/libs/jquery/';

added line: 37 const CDN_BASE_GOOGLE_HTTPS = 'https://ajax.googleapis.com/ajax/libs/jquery/';

const CDN_BASE_GOOGLE_HTTP = '<a rel="nofollow" href="http://ajax.googleapis.com/ajax/libs/jquery/">http://ajax.googleapis.com/ajax/libs/jquery/</a>';

ZendX\JQuery\View\Helper\Jquery\Container.php

removed line: 727 $source = ZendX_JQuery::CDN_BASE_GOOGLE . $this->getCdnVersion() . ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE;

added line: 727 if ($this->_isSSL()) { $source = ZendX_JQuery::CDN_BASE_GOOGLE_HTTPS . $this->getCdnVersion() . ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE; } else { $source = ZendX_JQuery::CDN_BASE_GOOGLE_HTTP . $this->getCdnVersion() . ZendX_JQuery::CDN_JQUERY_PATH_GOOGLE; }

added line: 739 /** * Check if the current connection is SSL or not. * * @return boolean / protected function _isSSL() { if($_SERVER['https'] == 1) / Apache / { return TRUE; } elseif ($_SERVER['https'] == 'on') / IIS / { return TRUE; } elseif ($_SERVER['SERVER_PORT'] == 443) / others / { return TRUE; } else { return FALSE; / just using http */ } }

i've added the changes in a text file since formating is a bit off here :-/

Actually, I was thinking about an easier way, similar to:


const CDN_BASE_GOOGLE = 'ajax.googleapis.com/ajax/libs/jquery/';
Zend_Controller_Front::getInstance()->getRequest()->getScheme();
//...
$source = Zend_Controller_Front::getInstance()->getRequest()->getScheme() . '://' . ZendX_JQuery::CDN_BASE_GOOGLE . $this->getCdnVersion() . ...

thus no need for a _isSSL();

fixed by adding boolean flag function on the jQuery Container to handle SSL or not SSL.